his_api_controller.go 1.2MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575
  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/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "io"
  23. "io/ioutil"
  24. //"math"
  25. "math/rand"
  26. "net/http"
  27. "net/url"
  28. "os"
  29. "path/filepath"
  30. "regexp"
  31. "strconv"
  32. "strings"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole/oleutil"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.getString("ids")
  160. //ids := c.getint("admin_")
  161. admin_user_id, _ := c.GetInt64("admin_user_id")
  162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  163. id_arr := strings.Split(ids, ",")
  164. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. //库盘
  167. for _, drug := range drugs {
  168. if drug.IsPc == 0 && drug.IsBg == 0 {
  169. var struct3501 models.Struct3501
  170. struct3501.OrgName = miConfig.OrgName
  171. struct3501.AccessKey = miConfig.AccessKey
  172. struct3501.Opter = roles.UserName
  173. struct3501.RequestUrl = miConfig.Url
  174. struct3501.Url = miConfig.Url
  175. struct3501.AppId = miConfig.Cainfo
  176. struct3501.AppSecret = miConfig.AppSecret
  177. struct3501.Enckey = miConfig.EncKey
  178. struct3501.SignKey = miConfig.SignKey
  179. struct3501.SecretKey = miConfig.SecretKey
  180. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  181. struct3501.FixmedinsHilistId = miConfig.Code
  182. struct3501.FixmedinsHilistName = miConfig.OrgName
  183. struct3501.RxFlag = "0"
  184. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  185. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  186. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  187. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  188. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02 15:04:05")
  189. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  190. struct3501.Memo = "入库"
  191. result1, result2, result3 := service.FJyb3501(struct3501)
  192. fmt.Println(result1)
  193. fmt.Println(result2)
  194. fmt.Println(result3)
  195. var struct3502 models.Struct3502
  196. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  197. struct3502.FixmedinsHilistId = miConfig.Code
  198. struct3502.FixmedinsHilistName = miConfig.OrgName
  199. struct3502.FixmedinsCode = miConfig.Code
  200. struct3502.RxFlag = "0"
  201. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  202. struct3502.OrgName = miConfig.OrgName
  203. struct3502.AccessKey = miConfig.AccessKey
  204. struct3502.RequestUrl = miConfig.Url
  205. struct3502.SecretKey = miConfig.SecretKey
  206. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  207. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  208. struct3502.Url = miConfig.Url
  209. struct3502.AppId = miConfig.Cainfo
  210. struct3502.AppSecret = miConfig.AppSecret
  211. struct3502.Enckey = miConfig.EncKey
  212. struct3502.SignKey = miConfig.SignKey
  213. struct3502.SecretKey = miConfig.SecretKey
  214. struct3502.InvChgType = "102"
  215. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  216. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  217. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  218. result11, result22, result33 := service.FJyb3502(struct3502)
  219. fmt.Println(result11)
  220. fmt.Println(result22)
  221. fmt.Println(result33)
  222. }
  223. //变更
  224. if drug.IsPc == 1 && drug.IsBg == 0 {
  225. var struct3502 models.Struct3502
  226. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  227. struct3502.FixmedinsHilistId = miConfig.Code
  228. struct3502.FixmedinsHilistName = miConfig.OrgName
  229. struct3502.FixmedinsCode = miConfig.Code
  230. struct3502.RxFlag = "0"
  231. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  232. struct3502.OrgName = miConfig.OrgName
  233. struct3502.AccessKey = miConfig.AccessKey
  234. struct3502.RequestUrl = miConfig.Url
  235. struct3502.SecretKey = miConfig.SecretKey
  236. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  237. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  238. struct3502.InvChgType = "102"
  239. struct3502.Url = miConfig.Url
  240. struct3502.AppId = miConfig.Cainfo
  241. struct3502.AppSecret = miConfig.AppSecret
  242. struct3502.Enckey = miConfig.EncKey
  243. struct3502.SignKey = miConfig.SignKey
  244. struct3502.SecretKey = miConfig.SecretKey
  245. struct3502.FixmedinsBchno = ""
  246. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  247. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  248. result1, result2, result3 := service.FJyb3502(struct3502)
  249. fmt.Println(result1)
  250. fmt.Println(result2)
  251. fmt.Println(result3)
  252. }
  253. }
  254. }
  255. func (c *HisApiController) DeletePCandBG() {
  256. ids := c.getString("ids")
  257. id_arr := strings.Split(ids, ",")
  258. admin_user_id, _ := c.GetInt64("admin_user_id")
  259. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  260. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  262. for _, item := range drugs {
  263. if item.IsPc == 1 && item.IsBg == 1 {
  264. var struct3507 models.Struct3507
  265. struct3507.FixmedinsBchno = ""
  266. struct3507.InvDataType = "1"
  267. struct3507.Opter = roles.UserName
  268. struct3507.OrgName = miConfig.OrgName
  269. struct3507.AccessKey = miConfig.AccessKey
  270. struct3507.RequestUrl = miConfig.Url
  271. struct3507.SecretKey = miConfig.SecretKey
  272. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  273. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  274. struct3507.Url = miConfig.Url
  275. struct3507.AppId = miConfig.Cainfo
  276. struct3507.AppSecret = miConfig.AppSecret
  277. struct3507.Enckey = miConfig.EncKey
  278. struct3507.SignKey = miConfig.SignKey
  279. struct3507.SecretKey = miConfig.SecretKey
  280. service.FJyb3507(struct3507)
  281. var struct3507_2 models.Struct3507
  282. struct3507_2.OrgName = miConfig.OrgName
  283. struct3507_2.AccessKey = miConfig.AccessKey
  284. struct3507_2.RequestUrl = miConfig.Url
  285. struct3507_2.SecretKey = miConfig.SecretKey
  286. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  287. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  288. struct3507_2.Url = miConfig.Url
  289. struct3507_2.AppId = miConfig.Cainfo
  290. struct3507_2.AppSecret = miConfig.AppSecret
  291. struct3507_2.Enckey = miConfig.EncKey
  292. struct3507_2.SignKey = miConfig.SignKey
  293. struct3507_2.SecretKey = miConfig.SecretKey
  294. struct3507_2.FixmedinsBchno = ""
  295. struct3507_2.InvDataType = "2"
  296. service.FJyb3507(struct3507_2)
  297. }
  298. if item.IsPc == 1 && item.IsBg == 0 {
  299. var struct3507 models.Struct3507
  300. struct3507.OrgName = miConfig.OrgName
  301. struct3507.AccessKey = miConfig.AccessKey
  302. struct3507.RequestUrl = miConfig.Url
  303. struct3507.SecretKey = miConfig.SecretKey
  304. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  305. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  306. struct3507.Url = miConfig.Url
  307. struct3507.AppId = miConfig.Cainfo
  308. struct3507.AppSecret = miConfig.AppSecret
  309. struct3507.Enckey = miConfig.EncKey
  310. struct3507.SignKey = miConfig.SignKey
  311. struct3507.SecretKey = miConfig.SecretKey
  312. struct3507.FixmedinsBchno = ""
  313. struct3507.InvDataType = "1"
  314. service.FJyb3507(struct3507)
  315. }
  316. }
  317. }
  318. func (c *HisApiController) DeleteXSandBG() {
  319. ids := c.getString("ids")
  320. id_arr := strings.Split(ids, ",")
  321. admin_user_id, _ := c.GetInt64("admin_user_id")
  322. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  323. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  324. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  325. for _, item := range drugs {
  326. if item.IsPc == 1 && item.IsBg == 1 {
  327. var struct3507 models.Struct3507
  328. struct3507.FixmedinsBchno = ""
  329. struct3507.InvDataType = "1"
  330. struct3507.OrgName = miConfig.OrgName
  331. struct3507.AccessKey = miConfig.AccessKey
  332. struct3507.RequestUrl = miConfig.Url
  333. struct3507.SecretKey = miConfig.SecretKey
  334. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  335. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  336. struct3507.Url = miConfig.Url
  337. struct3507.AppId = miConfig.Cainfo
  338. struct3507.AppSecret = miConfig.AppSecret
  339. struct3507.Enckey = miConfig.EncKey
  340. struct3507.SignKey = miConfig.SignKey
  341. struct3507.SecretKey = miConfig.SecretKey
  342. struct3507.FixmedinsBchno = ""
  343. struct3507.InvDataType = "1"
  344. service.FJyb3507(struct3507)
  345. var struct3507_2 models.Struct3507
  346. struct3507_2.OrgName = miConfig.OrgName
  347. struct3507_2.AccessKey = miConfig.AccessKey
  348. struct3507_2.RequestUrl = miConfig.Url
  349. struct3507_2.SecretKey = miConfig.SecretKey
  350. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  351. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  352. struct3507_2.FixmedinsBchno = ""
  353. struct3507_2.InvDataType = "2"
  354. struct3507_2.Url = miConfig.Url
  355. struct3507_2.AppId = miConfig.Cainfo
  356. struct3507_2.AppSecret = miConfig.AppSecret
  357. struct3507_2.Enckey = miConfig.EncKey
  358. struct3507_2.SignKey = miConfig.SignKey
  359. struct3507_2.SecretKey = miConfig.SecretKey
  360. struct3507_2.FixmedinsBchno = ""
  361. struct3507_2.InvDataType = "1"
  362. service.FJyb3507(struct3507_2)
  363. }
  364. if item.IsPc == 1 && item.IsBg == 0 {
  365. var struct3507 models.Struct3507
  366. struct3507.OrgName = miConfig.OrgName
  367. struct3507.AccessKey = miConfig.AccessKey
  368. struct3507.RequestUrl = miConfig.Url
  369. struct3507.SecretKey = miConfig.SecretKey
  370. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  371. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  372. struct3507.FixmedinsBchno = ""
  373. struct3507.InvDataType = "1"
  374. service.FJyb3507(struct3507)
  375. }
  376. }
  377. }
  378. func (c *HisApiController) ChangeDrug() {
  379. ids := c.getString("ids")
  380. id_arr := strings.Split(ids, ",")
  381. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  382. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  383. for _, item := range flows {
  384. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  385. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  386. if prescription.OrderStatus == 2 { //已经结算
  387. //判断是否已经销售
  388. if item.IsSale == 1 { //是否已经销售,1是 0否
  389. //是否已经变更 1是 0否
  390. if item.IsChange == 0 { //没变更,进行变更操作
  391. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  392. }
  393. } else { //没销售,
  394. //进行商品销售接口
  395. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  396. if item.IsChange == 0 { //没变更,进行变更操作
  397. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  398. }
  399. }
  400. } else { //还没结算
  401. if item.IsChange == 0 { //没变更,进行变更操作
  402. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  403. }
  404. }
  405. } else if item.ConsumableType == 7 {
  406. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  407. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  408. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  409. //判断是否已经销售
  410. if item.IsSale == 1 { //是否已经销售,1是 0否
  411. //是否已经变更 1是 0否
  412. if item.IsChange == 0 { //没变更,进行变更操作
  413. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  414. }
  415. } else { //没销售,
  416. //进行商品销售退货接口
  417. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  418. if item.IsChange == 0 { //没变更,进行变更操作
  419. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  420. }
  421. }
  422. } else { //还没结算
  423. if item.IsChange == 0 { //没变更,进行变更操作
  424. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  425. }
  426. }
  427. } else { //其他方式
  428. if item.IsChange == 0 { //没变更,进行变更操作
  429. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  430. }
  431. }
  432. }
  433. }
  434. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  435. var struct3502 models.Struct3502
  436. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  437. struct3502.FixmedinsHilistId = miConfig.Code
  438. struct3502.FixmedinsHilistName = miConfig.OrgName
  439. struct3502.FixmedinsCode = miConfig.Code
  440. struct3502.RxFlag = "0"
  441. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  442. struct3502.OrgName = miConfig.OrgName
  443. struct3502.AccessKey = miConfig.AccessKey
  444. struct3502.RequestUrl = miConfig.Url
  445. struct3502.SecretKey = miConfig.SecretKey
  446. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  447. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  448. struct3502.Url = miConfig.Url
  449. struct3502.AppId = miConfig.Cainfo
  450. struct3502.AppSecret = miConfig.AppSecret
  451. struct3502.Enckey = miConfig.EncKey
  452. struct3502.SignKey = miConfig.SignKey
  453. struct3502.SecretKey = miConfig.SecretKey
  454. struct3502.InvChgType = chgType
  455. struct3502.FixmedinsBchno = ""
  456. struct3502.Cnt = strconv.FormatInt(count, 10)
  457. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  458. result1, result2, result3 := service.FJyb3502(struct3502)
  459. fmt.Println(result1)
  460. fmt.Println(result2)
  461. fmt.Println(result3)
  462. }
  463. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  464. var struct3505 models.Struct3505
  465. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  466. struct3505.FixmedinsHilistId = miConfig.Code
  467. struct3505.FixmedinsHilistName = miConfig.OrgName
  468. struct3505.FixmedinsCode = miConfig.Code
  469. struct3505.FixmedinsBchno = ""
  470. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  471. struct3505.PrscDrName = roles.UserName
  472. struct3505.PharName = ""
  473. struct3505.PharPracCertNo = ""
  474. order := service.GetHisOrderByNumber(pre.BatchNumber)
  475. struct3505.SetlId = order.SetlId
  476. struct3505.MdtrtSn = order.MdtrtId
  477. struct3505.ManuLotnum = ""
  478. struct3505.ManuDate = ""
  479. struct3505.ExpyEnd = ""
  480. struct3505.RxFlag = "0"
  481. struct3505.TrdnFlag = "1"
  482. struct3505.Url = miConfig.Url
  483. struct3505.AppId = miConfig.Cainfo
  484. struct3505.AppSecret = miConfig.AppSecret
  485. struct3505.Enckey = miConfig.EncKey
  486. struct3505.SignKey = miConfig.SignKey
  487. struct3505.SecretKey = miConfig.SecretKey
  488. struct3505.RtalDocno = order.Number
  489. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  490. struct3505.SelRetnCnt = strValue
  491. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  492. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  493. struct3505.SelRetnOpterName = roles_two.UserName
  494. if order.IsMedicineInsurance == 1 {
  495. struct3505.MdtrtSetlType = "1"
  496. } else {
  497. struct3505.MdtrtSetlType = "2"
  498. }
  499. struct3505.OrgName = miConfig.OrgName
  500. struct3505.AccessKey = miConfig.AccessKey
  501. struct3505.RequestUrl = miConfig.Url
  502. struct3505.SecretKey = miConfig.SecretKey
  503. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  504. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  505. result1, result2, result3 := service.FJyb3505(struct3505)
  506. fmt.Println(result1)
  507. fmt.Println(result2)
  508. fmt.Println(result3)
  509. }
  510. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  511. var struct3506 models.Struct3506
  512. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  513. struct3506.FixmedinsHilistId = miConfig.Code
  514. struct3506.FixmedinsHilistName = miConfig.OrgName
  515. struct3506.FixmedinsCode = miConfig.Code
  516. struct3506.FixmedinsBchno = ""
  517. order := service.GetHisOrderByNumber(pre.BatchNumber)
  518. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  519. struct3506.ManuLotnum = ""
  520. struct3506.ManuDate = ""
  521. struct3506.MdtrtSn = order.MdtrtId
  522. struct3506.ExpyEnd = ""
  523. struct3506.RxFlag = "0"
  524. struct3506.TrdnFlag = "1"
  525. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  526. struct3506.SelRetnCnt = strValue
  527. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  528. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  529. struct3506.SelRetnOpterName = roles_two.UserName
  530. struct3506.OrgName = miConfig.OrgName
  531. struct3506.AccessKey = miConfig.AccessKey
  532. struct3506.RequestUrl = miConfig.Url
  533. struct3506.SecretKey = miConfig.SecretKey
  534. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  535. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  536. struct3506.Url = miConfig.Url
  537. struct3506.AppId = miConfig.Cainfo
  538. struct3506.AppSecret = miConfig.AppSecret
  539. struct3506.Enckey = miConfig.EncKey
  540. struct3506.SignKey = miConfig.SignKey
  541. struct3506.SecretKey = miConfig.SecretKey
  542. result1, result2, result3 := service.FJyb3506(struct3506)
  543. fmt.Println(result1)
  544. fmt.Println(result2)
  545. fmt.Println(result3)
  546. }
  547. func (c *HisApiController) Get1318() {
  548. adminUser := c.GetAdminUserInfo()
  549. admin_user_id, _ := c.GetInt64("admin_user_id")
  550. code := c.GetString("code")
  551. code = ""
  552. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  553. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  554. api := ""
  555. if miConfig.MdtrtareaAdmvs == "320921" {
  556. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  557. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  558. } else {
  559. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  560. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  561. }
  562. resp, requestErr := http.Get(api)
  563. if requestErr != nil {
  564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. }
  567. body, ioErr := ioutil.ReadAll(resp.Body)
  568. if ioErr != nil {
  569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  571. return
  572. }
  573. var respJSON map[string]interface{}
  574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  577. return
  578. }
  579. //var res Result2406
  580. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  581. result, _ := json.Marshal(respJSON)
  582. if err := json.Unmarshal([]byte(result), &res); err != nil {
  583. utils.ErrorLog("解析失败:%v", err)
  584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  585. return
  586. }
  587. if res.Infcode == "0" {
  588. c.ServeSuccessJSON(map[string]interface{}{
  589. "result": "",
  590. })
  591. } else {
  592. c.ServeSuccessJSON(map[string]interface{}{
  593. "failed_code": -10,
  594. "msg": res.ErrMsg,
  595. })
  596. */return
  597. //}
  598. }
  599. func (c *HisApiController) Get2503() {
  600. adminUser := c.GetAdminUserInfo()
  601. admin_user_id, _ := c.GetInt64("admin_user_id")
  602. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  603. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  604. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  605. }
  606. func (c *HisApiController) Get2406() {
  607. id, _ := c.GetInt64("id")
  608. record_time := c.GetString("record_time")
  609. his_patient_id, _ := c.GetInt64("his_patient_id")
  610. admin_user_id, _ := c.GetInt64("admin_user_id")
  611. diagnosis_id := c.GetString("diagnosis")
  612. timeLayout := "2006-01-02"
  613. loc, _ := time.LoadLocation("Local")
  614. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  615. if err != nil {
  616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  617. return
  618. }
  619. recordDateTime := theTime.Unix()
  620. adminUser := c.GetAdminUserInfo()
  621. diagnosis_ids := strings.Split(diagnosis_id, ",")
  622. var config []*models.HisXtDiagnoseConfig
  623. for _, item := range diagnosis_ids {
  624. id, _ := strconv.ParseInt(item, 10, 64)
  625. diagnosisConfig, _ := service.FindDiagnoseById(id)
  626. config = append(config, &diagnosisConfig)
  627. }
  628. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  629. fmt.Println(his_patient_id)
  630. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  631. //timestamp := time.Now().Unix()
  632. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  633. var patientPrescription models.HisPrescriptionInfo
  634. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  635. if patientPrescription.ID == 0 {
  636. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  637. }
  638. var res2 Result2406
  639. if miConfig.MdtrtareaAdmvs == "341203" {
  640. data := make(map[string]interface{})
  641. client := &http.Client{}
  642. data["psn_no"] = his.PsnNo
  643. data["mdtrt_id"] = his.Number
  644. data["operator"] = roles.UserName
  645. data["cert_no"] = his.IdCardNo
  646. data["org_name"] = miConfig.OrgName
  647. data["psn_name"] = his.Name
  648. data["ipt_otp_no"] = his.IptOtpNo
  649. data["ipt_psn_sp_flag_type"] = "0901"
  650. data["ipt_psn_sp_flag"] = "1"
  651. data["fixmedins_code"] = miConfig.Code
  652. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  653. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  654. data["url"] = miConfig.Url
  655. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  656. bytesData, _ := json.Marshal(data)
  657. var req *http.Request
  658. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  659. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  660. resp, _ := client.Do(req)
  661. defer resp.Body.Close()
  662. body, ioErr := ioutil.ReadAll(resp.Body)
  663. if ioErr != nil {
  664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  666. return
  667. }
  668. var respJSON map[string]interface{}
  669. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  672. return
  673. }
  674. status := respJSON["data"].(map[string]interface{})["status"].(string)
  675. if status == "0" {
  676. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  677. c.ServeSuccessJSON(map[string]interface{}{
  678. "failed_code": -10,
  679. "msg": err_msg,
  680. })
  681. return
  682. }
  683. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  684. userJSONBytes, _ := json.Marshal(respJSON)
  685. fmt.Println("log")
  686. fmt.Println(string(userJSONBytes))
  687. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  688. utils.ErrorLog("解析失败:%v", err)
  689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  690. return
  691. }
  692. }
  693. if res2.Infcode != 0 {
  694. adminUser := c.GetAdminUserInfo()
  695. errlog := &models.HisOrderError{
  696. UserOrgId: adminUser.CurrentOrgId,
  697. Ctime: time.Now().Unix(),
  698. Mtime: time.Now().Unix(),
  699. ErrMsg: res2.ErrMsg,
  700. Status: 1,
  701. PatientId: id,
  702. RecordTime: recordDateTime,
  703. Stage: 3,
  704. }
  705. service.CreateErrMsgLog(errlog)
  706. c.ServeSuccessJSON(map[string]interface{}{
  707. "failed_code": -10,
  708. "msg": res2.ErrMsg,
  709. })
  710. return
  711. } else {
  712. c.ServeSuccessJSON(map[string]interface{}{
  713. "msg": "上传成功",
  714. })
  715. return
  716. }
  717. }
  718. func (c *HisApiController) Get4105() {
  719. }
  720. func (c *HisApiController) Post5302() {
  721. patient_id, _ := c.GetInt64("id")
  722. admin_user_id, _ := c.GetInt64("admin_user_id")
  723. p, _ := service.GetHisPatientById(patient_id)
  724. adminUser := c.GetAdminUserInfo()
  725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  726. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  727. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  728. }
  729. func (c *HisApiController) Get4104() {
  730. }
  731. type Output struct {
  732. CertNo string `json:"certno"`
  733. PsnName string `json:"psn_name"`
  734. CardNo string `json:"card_no"`
  735. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  736. CardSN string `json:"card_sn"`
  737. PsnCertType string `json:"psn_cert_type"`
  738. MdtrtCertNo string `json:"mdtrt_cert_no"`
  739. MdtrtCertType string `json:"mdtrt_cert_type"`
  740. QRCode string `json:"qrCode"`
  741. EcToken string `json:"ecToken"`
  742. }
  743. type AHResponse struct {
  744. Body AHBody `json:"body"`
  745. Code int `json:"code"`
  746. CSBCode int `json:"csbCode"`
  747. Message string `json:"message"`
  748. RequestID string `json:"requestId"`
  749. State struct{} `json:"state"`
  750. }
  751. type AHBody struct {
  752. ErrMsg string `json:"err_msg"`
  753. InfRefMsgID string `json:"inf_refmsgid"`
  754. InfCode int `json:"infcode"`
  755. Output struct {
  756. Result []struct {
  757. BasMednFlag string `json:"bas_medn_flag"`
  758. ChldMedcFlag string `json:"chld_medc_flag"`
  759. ChrgitmLv string `json:"chrgitm_lv"`
  760. Cnt float64 `json:"cnt"`
  761. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  762. DrtReimFlag string `json:"drt_reim_flag"`
  763. FeedetlSn string `json:"feedetl_sn"`
  764. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  765. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  766. InscpScpAmt float64 `json:"inscp_scp_amt"`
  767. ListSpItemFlag string `json:"list_sp_item_flag"`
  768. LmtUsedFlag string `json:"lmt_used_flag"`
  769. MedChrgitmType string `json:"med_chrgitm_type"`
  770. Memo string `json:"memo"`
  771. OverlmtAmt float64 `json:"overlmt_amt"`
  772. PreselfpayAmt float64 `json:"preselfpay_amt"`
  773. Pric float64 `json:"pric"`
  774. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  775. SelfpayProp float64 `json:"selfpay_prop"`
  776. } `json:"result"`
  777. } `json:"output"`
  778. }
  779. type Response struct {
  780. Output Output `json:"output"`
  781. Infcode int `json:"infcode"`
  782. InfRefMsgID string `json:"inf_refmsgid"`
  783. RefMsgTime string `json:"refmsg_time"`
  784. RespondTime string `json:"respond_time"`
  785. ErrMsg string `json:"err_msg"`
  786. WarnMsg string `json:"warn_msg"`
  787. SignType string `json:"signtype"`
  788. CAInfo string `json:"cainfo"`
  789. }
  790. func (c *HisApiController) Getquerydata() {
  791. query_type, _ := c.GetInt64("type")
  792. refd_setl_flag := c.GetString("refd_setl_flag")
  793. med_type := c.GetString("med_type")
  794. //admin_user_id,_ := c.GetInt64("admin_user_id")
  795. cert_no := c.GetString("cert_no")
  796. psn_no := c.GetString("psn_no")
  797. start_time := c.GetString("start_time")
  798. end_time := c.GetString("end_time")
  799. page, _ := c.GetInt64("page")
  800. limit, _ := c.GetInt64("limit")
  801. var bp models.BusinessParams5262
  802. bp.RefdSetlFlag = refd_setl_flag
  803. bp.MedType = med_type
  804. bp.Certno = cert_no
  805. bp.Psnno = psn_no
  806. bp.QBegntime = start_time
  807. bp.QEndtime = end_time
  808. if query_type == 1 { //本地
  809. Post5262(c, bp, page, limit)
  810. } else { //异地
  811. Post5267(c, bp, page, limit)
  812. }
  813. }
  814. func (c *HisApiController) Drugscheck() {
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. adminUser := c.GetAdminUserInfo()
  817. var queryResult []QueryResult
  818. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  819. for _, item := range drugs {
  820. result := QueryResult{
  821. ID: item.ID,
  822. Name: item.DrugName,
  823. Code: item.MedicalInsuranceNumber,
  824. List_type_code: "101",
  825. }
  826. queryResult = append(queryResult, result)
  827. }
  828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  829. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  830. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  831. for _, item := range queryResult {
  832. 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)
  833. }
  834. }
  835. func (c *HisApiController) Goodcheck() {
  836. admin_user_id, _ := c.GetInt64("admin_user_id")
  837. adminUser := c.GetAdminUserInfo()
  838. var queryResult []QueryResult
  839. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  840. for _, item := range goods {
  841. result := QueryResult{
  842. ID: item.ID,
  843. Name: item.GoodName,
  844. Code: item.SocialSecurityDirectoryCode,
  845. List_type_code: "301",
  846. }
  847. queryResult = append(queryResult, result)
  848. }
  849. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  850. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  851. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  852. for _, item := range queryResult {
  853. 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)
  854. //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)
  855. }
  856. }
  857. func (c *HisApiController) Projectcheck() {
  858. admin_user_id, _ := c.GetInt64("admin_user_id")
  859. adminUser := c.GetAdminUserInfo()
  860. var queryResult []QueryResult
  861. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  862. for _, item := range projects {
  863. result := QueryResult{
  864. ID: item.ID,
  865. Name: item.ProjectName,
  866. Code: item.MedicalCode,
  867. List_type_code: "201",
  868. }
  869. queryResult = append(queryResult, result)
  870. }
  871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  872. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  873. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  874. for _, item := range queryResult {
  875. 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)
  876. }
  877. }
  878. //func (c *HisApiController)CancleDia(){
  879. //
  880. // id, _ := c.GetInt64("id")
  881. // record_time := c.GetString("record_time")
  882. // his_patient_id, _ := c.GetInt64("his_patient_id")
  883. //
  884. // admin_user_id, _ := c.GetInt64("admin_user_id")
  885. //
  886. // diagnosis_id := c.GetString("diagnosis")
  887. // sick_type, _ := c.GetInt64("sick_type")
  888. // reg_type, _ := c.GetInt64("p_type")
  889. // begin_time := c.GetString("begin_time")
  890. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  891. //
  892. //
  893. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  894. //
  895. // fmt.Println(acct_used_flag)
  896. //
  897. //
  898. // timeLayout := "2006-01-02"
  899. // loc, _ := time.LoadLocation("Local")
  900. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  901. // if err != nil {
  902. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  903. // return
  904. // }
  905. // recordDateTime := theTime.Unix()
  906. // adminUser := c.GetAdminUserInfo()
  907. //
  908. //
  909. //
  910. //
  911. //
  912. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  913. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  914. // var patientPrescription models.HisPrescriptionInfo
  915. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  916. // if patientPrescription.ID == 0 {
  917. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  918. // }
  919. // //if patientPrescription.Do
  920. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  921. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  922. //
  923. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  924. //
  925. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  926. //
  927. // var config []*models.HisXtDiagnoseConfig
  928. // for _, item := range diagnosis_ids {
  929. // id, _ := strconv.ParseInt(item, 10, 64)
  930. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  931. // config = append(config, &diagnosisConfig)
  932. // }
  933. //
  934. // sickConfig, _ := service.FindSickById(sick_type)
  935. //
  936. //
  937. // data := make(map[string]interface{})
  938. // client := &http.Client{}
  939. // data["psn_no"] = his.PsnNo
  940. // data["mdtrt_id"] = his.Number
  941. // data["doctor"] = roles.UserName
  942. // data["department"] = department.Name
  943. // data["org_name"] = miConfig.OrgName
  944. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  945. // data["doctor_id"] = doctor_info.DoctorNumber
  946. // data["new_doctor_name"] = doctor_info.UserName
  947. // data["fixmedins_code"] = miConfig.Code
  948. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  949. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  950. // data["secret_key"] = miConfig.SecretKey
  951. // data["sick_code"] = sickConfig.CountryCode
  952. // data["sick_name"] = sickConfig.ClassName
  953. // data["url"] = miConfig.Url
  954. // data["ak"] = miConfig.AccessKey
  955. // data["begin_time"] = begin_time
  956. // data["cainfo"] = miConfig.Cainfo
  957. // data["is_vaild"] = "0"
  958. //
  959. // data["dept"] = strconv.FormatInt(department.ID, 10)
  960. // data["config"] = config
  961. // bytesData, _ := json.Marshal(data)
  962. //
  963. // var req *http.Request
  964. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  965. // resp, _ := client.Do(req)
  966. // defer resp.Body.Close()
  967. // body, ioErr := ioutil.ReadAll(resp.Body)
  968. // if ioErr != nil {
  969. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  971. // return
  972. // }
  973. // var respJSON map[string]interface{}
  974. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  975. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  976. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  977. // return
  978. // }
  979. //
  980. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  981. // userJSONBytes, _ := json.Marshal(respJSON)
  982. // fmt.Println("log")
  983. // fmt.Println(string(userJSONBytes))
  984. //
  985. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  986. // utils.ErrorLog("解析失败:%v", err)
  987. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  988. // return
  989. // }
  990. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  991. // res2.Output = ressix10265.Output
  992. // res2.ErrMsg = ressix10265.ErrMsg
  993. // res2.Cainfo = ressix10265.Cainfo
  994. // res2.WarnMsg = ressix10265.WarnMsg
  995. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  996. // res2.Infcode = infocode
  997. //
  998. //}
  999. func (c *HisApiController) Get4102() {
  1000. order_id, _ := c.GetInt64("order_id")
  1001. admin_user_id, _ := c.GetInt64("admin_user_id")
  1002. stas_type := c.GetString("stas_type")
  1003. order, _ := service.GetHisOrderByIDTwo(order_id)
  1004. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1006. var pp models.PublicParams
  1007. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1008. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1009. pp.FixmedinsName = miConfig.OrgName
  1010. pp.FixmedinsCode = miConfig.Code
  1011. pp.RequestUrl = miConfig.Url
  1012. pp.Cainfo = miConfig.Cainfo
  1013. pp.SecretKey = miConfig.SecretKey
  1014. pp.AccessKey = miConfig.AccessKey
  1015. pp.OpterName = curRoles.UserName
  1016. if miConfig.MdtrtareaAdmvs == "350500" {
  1017. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1018. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1019. saveLog(result, request, "4102", "清单确认")
  1020. var dat map[string]interface{}
  1021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1022. fmt.Println(dat)
  1023. } else {
  1024. fmt.Println(err)
  1025. }
  1026. var empty ResultFourteen
  1027. userJSONBytes, _ := json.Marshal(dat)
  1028. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1029. utils.ErrorLog("解析失败:%v", err)
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1031. return
  1032. }
  1033. if empty.Infcode == 0 {
  1034. c.ServeSuccessJSON(map[string]interface{}{
  1035. "msg": "确认成功",
  1036. })
  1037. return
  1038. }
  1039. } else {
  1040. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1041. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1042. result3, request3 := service.Jxyb4105(pp)
  1043. saveLog(result, request, "4102", "清单确认")
  1044. saveLog(result2, request2, "4103", "清单确认")
  1045. saveLog(result3, request3, "4105", "清单统计")
  1046. var dat map[string]interface{}
  1047. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1048. fmt.Println(dat)
  1049. } else {
  1050. fmt.Println(err)
  1051. }
  1052. var empty ResultFourteen
  1053. userJSONBytes, _ := json.Marshal(dat)
  1054. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1055. utils.ErrorLog("解析失败:%v", err)
  1056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1057. return
  1058. }
  1059. if empty.Infcode == 0 {
  1060. c.ServeSuccessJSON(map[string]interface{}{
  1061. "msg": "确认成功",
  1062. })
  1063. return
  1064. }
  1065. }
  1066. }
  1067. // 对账权限查询
  1068. func (c *HisApiController) Get3260() {
  1069. admin_user_id, _ := c.GetInt64("admin_user_id")
  1070. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1071. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1072. var api string
  1073. var res models.JSResult3260
  1074. if miConfig.MdtrtareaAdmvs == "320921" {
  1075. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1076. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1077. } else {
  1078. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1079. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1080. }
  1081. resp, requestErr := http.Get(api)
  1082. if requestErr != nil {
  1083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1084. return
  1085. }
  1086. body, ioErr := ioutil.ReadAll(resp.Body)
  1087. if ioErr != nil {
  1088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1090. return
  1091. }
  1092. var respJSON map[string]interface{}
  1093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1099. result, _ := json.Marshal(respJSON)
  1100. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1101. utils.ErrorLog("解析失败:%v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. if res.Infcode == "0" {
  1106. c.ServeSuccessJSON(map[string]interface{}{
  1107. "result": res.Output.Data,
  1108. })
  1109. } else {
  1110. c.ServeSuccessJSON(map[string]interface{}{
  1111. "failed_code": -10,
  1112. "msg": res.ErrMsg,
  1113. })
  1114. return
  1115. }
  1116. }
  1117. func (c *HisApiController) Get3261() {
  1118. admin_user_id, _ := c.GetInt64("admin_user_id")
  1119. //month := c.GetString("month")
  1120. startTime := c.GetString("start_time")
  1121. //endTime, _ := c.GetString("end_time")
  1122. times := strings.Split(startTime, "-")
  1123. stmt_mon := times[0] + times[1]
  1124. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1125. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1126. var api string
  1127. var res models.JSResult3261
  1128. //var res10265 Result5301For10265
  1129. if miConfig.MdtrtareaAdmvs == "320921" {
  1130. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1131. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1132. } else {
  1133. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1134. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1135. }
  1136. resp, requestErr := http.Get(api)
  1137. if requestErr != nil {
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. body, ioErr := ioutil.ReadAll(resp.Body)
  1142. if ioErr != nil {
  1143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1145. return
  1146. }
  1147. var respJSON map[string]interface{}
  1148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1151. return
  1152. }
  1153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1154. result, _ := json.Marshal(respJSON)
  1155. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1156. utils.ErrorLog("解析失败:%v", err)
  1157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1158. return
  1159. }
  1160. if res.Infcode == "0" {
  1161. c.ServeSuccessJSON(map[string]interface{}{
  1162. "result": res.Output,
  1163. })
  1164. } else {
  1165. c.ServeSuccessJSON(map[string]interface{}{
  1166. "failed_code": -10,
  1167. "msg": res.ErrMsg,
  1168. })
  1169. return
  1170. }
  1171. }
  1172. type TempFun struct {
  1173. FundKey string
  1174. FundCode string
  1175. }
  1176. func (c *HisApiController) Get3262() {
  1177. admin_user_id, _ := c.GetInt64("admin_user_id")
  1178. startTime := c.GetString("start_time")
  1179. endTime := c.GetString("end_time")
  1180. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1181. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1182. //timeLayout := "2006-01-02"
  1183. //loc, _ := time.LoadLocation("Local")
  1184. //var theStartTIme int64
  1185. //if len(startTime) > 0 {
  1186. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1187. // if err != nil {
  1188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1189. // return
  1190. // }
  1191. // theStartTIme = theTime.Unix()
  1192. //}
  1193. //var theEndtTIme int64
  1194. //if len(endTime) > 0 {
  1195. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1196. // if err != nil {
  1197. // utils.ErrorLog(err.Error())
  1198. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1199. // return
  1200. // }
  1201. // theEndtTIme = theTime.Unix()
  1202. //}
  1203. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1204. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1205. for _, team := range datas {
  1206. fmt.Println(team.PsnTime)
  1207. for _, team_two := range datas_two {
  1208. fmt.Println(team_two.PsnTime)
  1209. if team.FundKey == team_two.FundKey {
  1210. fmt.Println(team_two.PsnTime)
  1211. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1212. fmt.Println(team.PsnTime)
  1213. }
  1214. }
  1215. }
  1216. fmt.Println("1111")
  1217. fmt.Println(datas)
  1218. fmt.Println("1111")
  1219. var twos []models.FixMonRecDetailFileInTwo
  1220. for _, team := range datas {
  1221. var two models.FixMonRecDetailFileInTwo
  1222. two.MedType = team.MedType
  1223. two.Insutype = team.Insutype
  1224. two.PsnType = team.PsnType
  1225. two.MedType = team.MedType
  1226. two.FixBlngAdmdvs = "999999"
  1227. two.InsuAdmdvs = "555555"
  1228. two.PsnTime = team.PsnTime
  1229. two.PsnCnt = team.PsnCnt
  1230. two.FundKey = team.FundKey
  1231. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1232. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1233. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1234. two.MedfeeSumAmt = ms
  1235. two.InscpAmt = ia
  1236. two.FundPaySumAmt = fps
  1237. twos = append(twos, two)
  1238. }
  1239. //startTime := c.GetString("start_time")
  1240. //endTime, _ := c.GetString("end_time")
  1241. times := strings.Split(startTime, "-")
  1242. stmt_mon := times[0] + times[1]
  1243. var funs []models.FundDetail
  1244. for _, item := range datas {
  1245. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1246. funs = append(funs, fun...)
  1247. }
  1248. var funInfos []models.Fund
  1249. //for _, item := range funs {
  1250. // var rf []models.FundInfo
  1251. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1252. // for _, subitem := range rf {
  1253. // var fund models.Fund
  1254. // fund.FundCode = subitem.FundPayType
  1255. // fund.FundName = subitem.FundPayTypeName
  1256. // fund.FundAmt = subitem.FundPayAmt
  1257. // fund.FundKey = item.FundKey
  1258. // fund.InsuAdmdvs = "555555"
  1259. // fund.FixBlngAdmdvs = "999999"
  1260. // funInfos = append(funInfos, fund)
  1261. // }
  1262. //}
  1263. var tempFuns []TempFun
  1264. for _, funInfo := range funInfos {
  1265. var tempFun TempFun
  1266. tempFun.FundKey = funInfo.FundKey
  1267. tempFun.FundCode = funInfo.FundCode
  1268. tempFuns = append(tempFuns, tempFun)
  1269. }
  1270. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1271. fmt.Println(tempFuns)
  1272. var funInfosTwo []models.Fund
  1273. decimal.DivisionPrecision = 2
  1274. for _, item := range tempFuns {
  1275. var fund models.Fund
  1276. for _, subItem := range funInfos {
  1277. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1278. fund.FundKey = subItem.FundKey
  1279. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1280. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1281. fund.FundName = subItem.FundName
  1282. fund.FundCode = subItem.FundCode
  1283. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1284. }
  1285. }
  1286. funInfosTwo = append(funInfosTwo, fund)
  1287. }
  1288. fmt.Println("funInfosTwo")
  1289. fmt.Println(funInfosTwo)
  1290. var upld_btch string
  1291. var empty models.JSResultEmpty
  1292. data := make(map[string]interface{})
  1293. data["org_name"] = miConfig.OrgName
  1294. data["doctor"] = curRoles.UserName
  1295. data["doctor_name"] = curRoles.UserName
  1296. data["fixmedins_code"] = miConfig.Code
  1297. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1298. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1299. data["secret_key"] = miConfig.SecretKey
  1300. data["url"] = miConfig.Url
  1301. data["ak"] = miConfig.AccessKey
  1302. data["cainfo"] = miConfig.Cainfo
  1303. data["datas"] = twos
  1304. data["fund"] = funInfosTwo
  1305. fmt.Println(twos)
  1306. month := time.Unix(1557042972, 0).Format("1")
  1307. year := time.Now().Format("2006")
  1308. month = time.Now().Format("01")
  1309. day := time.Now().Format("02")
  1310. hour := time.Now().Format("15")
  1311. min := time.Now().Format("04")
  1312. sec := time.Now().Format("05")
  1313. fix_fill_date := year + month + day + hour + min + sec
  1314. data["fix_fill_dept"] = miConfig.OrgName
  1315. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1316. data["fix_fill_psn"] = curRoles.UserName
  1317. data["fix_fill_date"] = fix_fill_date
  1318. data["stmt_loc"] = "2"
  1319. data["setl_mon"] = stmt_mon
  1320. upld_btch = "0"
  1321. data["upld_btch"] = upld_btch
  1322. //fmt.Println(data)
  1323. client := &http.Client{}
  1324. bytesData, _ := json.Marshal(data)
  1325. var req *http.Request
  1326. if miConfig.MdtrtareaAdmvs == "320921" {
  1327. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1328. } else {
  1329. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1330. }
  1331. resp, _ := client.Do(req)
  1332. defer resp.Body.Close()
  1333. body, ioErr := ioutil.ReadAll(resp.Body)
  1334. if ioErr != nil {
  1335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1337. }
  1338. var respJSON map[string]interface{}
  1339. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1340. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. }
  1343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1344. //fmt.Println(respJSON)
  1345. result, _ := json.Marshal(respJSON)
  1346. //fmt.Println(result)
  1347. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1348. utils.ErrorLog("解析失败:%v", err)
  1349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. }
  1351. if empty.Infcode != "0" {
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "failed_code": -10,
  1354. "msg": empty.ErrMsg,
  1355. })
  1356. return
  1357. } else {
  1358. c.ServeSuccessJSON(map[string]interface{}{
  1359. "msg": "上传成功",
  1360. })
  1361. return
  1362. }
  1363. }
  1364. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1365. newArr = make([]TempFun, 0)
  1366. for i := 0; i < len(arr); i++ {
  1367. repeat := false
  1368. for j := i + 1; j < len(arr); j++ {
  1369. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1370. repeat = true
  1371. break
  1372. }
  1373. }
  1374. if !repeat {
  1375. newArr = append(newArr, arr[i])
  1376. }
  1377. }
  1378. return
  1379. }
  1380. func (c *HisApiController) Get3263() {
  1381. admin_user_id, _ := c.GetInt64("admin_user_id")
  1382. startTime := c.GetString("start_time")
  1383. //endTime, _ := c.GetString("end_time")
  1384. times := strings.Split(startTime, "-")
  1385. setl_mon := times[0] + times[1]
  1386. upld_btch := "0"
  1387. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1389. var result3263 models.JSResult3263
  1390. data := make(map[string]interface{})
  1391. data["org_name"] = miConfig.OrgName
  1392. data["doctor"] = curRoles.UserName
  1393. data["doctor_name"] = curRoles.UserName
  1394. data["fixmedins_code"] = miConfig.Code
  1395. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1396. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1397. data["secret_key"] = miConfig.SecretKey
  1398. data["url"] = miConfig.Url
  1399. data["ak"] = miConfig.AccessKey
  1400. data["cainfo"] = miConfig.Cainfo
  1401. data["setl_mon"] = setl_mon
  1402. data["stmt_loc"] = "2"
  1403. data["upld_btch"] = upld_btch
  1404. client := &http.Client{}
  1405. bytesData, _ := json.Marshal(data)
  1406. var req *http.Request
  1407. if miConfig.MdtrtareaAdmvs == "320921" {
  1408. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1409. } else {
  1410. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1411. }
  1412. resp, _ := client.Do(req)
  1413. defer resp.Body.Close()
  1414. body, ioErr := ioutil.ReadAll(resp.Body)
  1415. if ioErr != nil {
  1416. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1418. }
  1419. var respJSON map[string]interface{}
  1420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1423. }
  1424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1425. fmt.Println(respJSON)
  1426. result, _ := json.Marshal(respJSON)
  1427. fmt.Println(result)
  1428. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1429. utils.ErrorLog("解析失败:%v", err)
  1430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1431. }
  1432. if result3263.Infcode != "0" {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "failed_code": -10,
  1435. "msg": result3263.ErrMsg,
  1436. })
  1437. return
  1438. } else {
  1439. c.ServeSuccessJSON(map[string]interface{}{
  1440. "list": result3263.Output,
  1441. })
  1442. return
  1443. }
  1444. }
  1445. func (c *HisApiController) Get3264() {
  1446. admin_user_id, _ := c.GetInt64("admin_user_id")
  1447. startTime := c.GetString("start_time")
  1448. //endTime, _ := c.GetString("end_time")
  1449. times := strings.Split(startTime, "-")
  1450. setl_mon := times[0] + times[1]
  1451. upld_btch := "0"
  1452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1454. //solidify_id := []
  1455. var result3263 models.JSResult3263
  1456. data := make(map[string]interface{})
  1457. data["org_name"] = miConfig.OrgName
  1458. data["doctor"] = curRoles.UserName
  1459. data["doctor_name"] = curRoles.UserName
  1460. data["fixmedins_code"] = miConfig.Code
  1461. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1462. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1463. data["secret_key"] = miConfig.SecretKey
  1464. data["url"] = miConfig.Url
  1465. data["ak"] = miConfig.AccessKey
  1466. data["cainfo"] = miConfig.Cainfo
  1467. data["setl_mon"] = setl_mon
  1468. data["stmt_loc"] = "2"
  1469. data["upld_btch"] = upld_btch
  1470. client := &http.Client{}
  1471. bytesData, _ := json.Marshal(data)
  1472. var req3263 *http.Request
  1473. if miConfig.MdtrtareaAdmvs == "320921" {
  1474. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1475. } else {
  1476. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1477. }
  1478. resp, _ := client.Do(req3263)
  1479. defer resp.Body.Close()
  1480. body, ioErr := ioutil.ReadAll(resp.Body)
  1481. if ioErr != nil {
  1482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1484. }
  1485. var respJSON3263 map[string]interface{}
  1486. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1489. }
  1490. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1491. fmt.Println(respJSON3263)
  1492. result, _ := json.Marshal(respJSON3263)
  1493. fmt.Println(result)
  1494. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1495. utils.ErrorLog("解析失败:%v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. }
  1498. var ids []string
  1499. for _, item := range result3263.Output {
  1500. ids = append(ids, item.SolidifyID)
  1501. }
  1502. var empty models.JSResultEmpty
  1503. data2 := make(map[string]interface{})
  1504. data2["org_name"] = miConfig.OrgName
  1505. data2["doctor"] = curRoles.UserName
  1506. data2["doctor_name"] = curRoles.UserName
  1507. data2["fixmedins_code"] = miConfig.Code
  1508. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1509. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1510. data2["secret_key"] = miConfig.SecretKey
  1511. data2["url"] = miConfig.Url
  1512. data2["ak"] = miConfig.AccessKey
  1513. data2["cainfo"] = miConfig.Cainfo
  1514. data2["setl_mon"] = setl_mon
  1515. data2["stmt_loc"] = "2"
  1516. data2["upld_btch"] = upld_btch
  1517. data2["solidify_id"] = ids
  1518. client2 := &http.Client{}
  1519. bytesData2, _ := json.Marshal(data2)
  1520. var req *http.Request
  1521. if miConfig.MdtrtareaAdmvs == "320921" {
  1522. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1523. } else {
  1524. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1525. }
  1526. resp2, _ := client2.Do(req)
  1527. defer resp.Body.Close()
  1528. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1529. if ioErr2 != nil {
  1530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. }
  1533. var respJSON map[string]interface{}
  1534. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1537. }
  1538. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1539. fmt.Println(respJSON)
  1540. result2, _ := json.Marshal(respJSON)
  1541. fmt.Println(result2)
  1542. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1543. utils.ErrorLog("解析失败:%v", err)
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. }
  1546. if empty.Infcode != "0" {
  1547. c.ServeSuccessJSON(map[string]interface{}{
  1548. "failed_code": -10,
  1549. "msg": empty.ErrMsg,
  1550. })
  1551. return
  1552. } else {
  1553. c.ServeSuccessJSON(map[string]interface{}{
  1554. "msg": "",
  1555. })
  1556. return
  1557. }
  1558. }
  1559. func (c *HisApiController) Get3265() {
  1560. admin_user_id, _ := c.GetInt64("admin_user_id")
  1561. startTime := c.GetString("start_time")
  1562. //endTime, _ := c.GetString("end_time")
  1563. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1565. times := strings.Split(startTime, "-")
  1566. setl_mon := times[0] + times[1]
  1567. var upld_btch string
  1568. upld_btch = "0"
  1569. //var empty models.JSResultEmpty
  1570. var result3265 models.JSResult3264
  1571. var result3263 models.JSResult3263
  1572. data2 := make(map[string]interface{})
  1573. data2["org_name"] = miConfig.OrgName
  1574. data2["doctor"] = curRoles.UserName
  1575. data2["doctor_name"] = curRoles.UserName
  1576. data2["fixmedins_code"] = miConfig.Code
  1577. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1578. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1579. data2["secret_key"] = miConfig.SecretKey
  1580. data2["url"] = miConfig.Url
  1581. data2["ak"] = miConfig.AccessKey
  1582. data2["cainfo"] = miConfig.Cainfo
  1583. data2["setl_mon"] = setl_mon
  1584. data2["stmt_loc"] = "2"
  1585. data2["upld_btch"] = upld_btch
  1586. client2 := &http.Client{}
  1587. bytesData2, _ := json.Marshal(data2)
  1588. var req3263 *http.Request
  1589. if miConfig.MdtrtareaAdmvs == "320921" {
  1590. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1591. } else {
  1592. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1593. }
  1594. resp2, _ := client2.Do(req3263)
  1595. defer resp2.Body.Close()
  1596. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1597. if ioErr2 != nil {
  1598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1600. }
  1601. var respJSON3263 map[string]interface{}
  1602. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1605. }
  1606. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1607. fmt.Println(respJSON3263)
  1608. result2, _ := json.Marshal(respJSON3263)
  1609. fmt.Println(result2)
  1610. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1611. utils.ErrorLog("解析失败:%v", err)
  1612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1613. }
  1614. var ids []string
  1615. for _, item := range result3263.Output {
  1616. ids = append(ids, item.SolidifyID)
  1617. }
  1618. data := make(map[string]interface{})
  1619. data["org_name"] = miConfig.OrgName
  1620. data["doctor"] = curRoles.UserName
  1621. data["doctor_name"] = curRoles.UserName
  1622. data["fixmedins_code"] = miConfig.Code
  1623. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1624. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1625. data["secret_key"] = miConfig.SecretKey
  1626. data["url"] = miConfig.Url
  1627. data["ak"] = miConfig.AccessKey
  1628. data["cainfo"] = miConfig.Cainfo
  1629. data["setl_mon"] = setl_mon
  1630. data["solidify_id"] = ids
  1631. month := time.Unix(1557042972, 0).Format("1")
  1632. year := time.Now().Format("2006")
  1633. month = time.Now().Format("01")
  1634. day := time.Now().Format("02")
  1635. hour := time.Now().Format("15")
  1636. min := time.Now().Format("04")
  1637. sec := time.Now().Format("05")
  1638. fix_fill_date := year + month + day + hour + min + sec
  1639. data["fix_fill_dept"] = miConfig.OrgName
  1640. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1641. data["fix_fill_psn"] = curRoles.UserName
  1642. data["fix_fill_date"] = fix_fill_date
  1643. data["stmt_loc"] = "2"
  1644. data["upld_btch"] = upld_btch
  1645. client := &http.Client{}
  1646. bytesData, _ := json.Marshal(data)
  1647. var req *http.Request
  1648. if miConfig.MdtrtareaAdmvs == "320921" {
  1649. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1650. } else {
  1651. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1652. }
  1653. resp, _ := client.Do(req)
  1654. defer resp.Body.Close()
  1655. body, ioErr := ioutil.ReadAll(resp.Body)
  1656. if ioErr != nil {
  1657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1659. }
  1660. var respJSON map[string]interface{}
  1661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. }
  1665. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1666. fmt.Println(respJSON)
  1667. result, _ := json.Marshal(respJSON)
  1668. fmt.Println(result)
  1669. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1670. utils.ErrorLog("解析失败:%v", err)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. }
  1673. if result3265.Infcode != "0" {
  1674. c.ServeSuccessJSON(map[string]interface{}{
  1675. "failed_code": -10,
  1676. "msg": result3265.ErrMsg,
  1677. })
  1678. return
  1679. } else {
  1680. c.ServeSuccessJSON(map[string]interface{}{
  1681. "info": result3265.Output,
  1682. })
  1683. return
  1684. }
  1685. }
  1686. func (c *HisApiController) Get3266() {
  1687. admin_user_id, _ := c.GetInt64("admin_user_id")
  1688. startTime := c.GetString("start_time")
  1689. //endTime, _ := c.GetString("end_time")
  1690. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1692. times := strings.Split(startTime, "-")
  1693. stmt_mon := times[0] + times[1]
  1694. var upld_btch string
  1695. //var empty models.JSResultEmpty
  1696. var result3265 models.JSResult3264
  1697. data := make(map[string]interface{})
  1698. data["org_name"] = miConfig.OrgName
  1699. data["doctor"] = curRoles.UserName
  1700. data["doctor_name"] = curRoles.UserName
  1701. data["fixmedins_code"] = miConfig.Code
  1702. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1703. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1704. data["secret_key"] = miConfig.SecretKey
  1705. data["url"] = miConfig.Url
  1706. data["ak"] = miConfig.AccessKey
  1707. data["cainfo"] = miConfig.Cainfo
  1708. data["setl_mon"] = stmt_mon
  1709. month := time.Unix(1557042972, 0).Format("1")
  1710. year := time.Now().Format("2006")
  1711. month = time.Now().Format("01")
  1712. day := time.Now().Format("02")
  1713. hour := time.Now().Format("15")
  1714. min := time.Now().Format("04")
  1715. sec := time.Now().Format("05")
  1716. fix_fill_date := year + month + day + hour + min + sec
  1717. data["fix_fill_dept"] = miConfig.OrgName
  1718. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1719. data["fix_fill_psn"] = curRoles.UserName
  1720. data["fix_fill_date"] = fix_fill_date
  1721. data["stmt_loc"] = "2"
  1722. upld_btch = "0"
  1723. data["upld_btch"] = upld_btch
  1724. client := &http.Client{}
  1725. bytesData, _ := json.Marshal(data)
  1726. var req *http.Request
  1727. if miConfig.MdtrtareaAdmvs == "320921" {
  1728. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1729. } else {
  1730. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1731. }
  1732. resp, _ := client.Do(req)
  1733. defer resp.Body.Close()
  1734. body, ioErr := ioutil.ReadAll(resp.Body)
  1735. if ioErr != nil {
  1736. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. }
  1739. var respJSON map[string]interface{}
  1740. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1743. }
  1744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1745. fmt.Println(respJSON)
  1746. result, _ := json.Marshal(respJSON)
  1747. fmt.Println(result)
  1748. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1749. utils.ErrorLog("解析失败:%v", err)
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1751. }
  1752. if result3265.Infcode != "0" {
  1753. c.ServeSuccessJSON(map[string]interface{}{
  1754. "failed_code": -10,
  1755. "msg": result3265.ErrMsg,
  1756. })
  1757. return
  1758. } else {
  1759. c.ServeSuccessJSON(map[string]interface{}{
  1760. "info": result3265.Output,
  1761. })
  1762. return
  1763. }
  1764. }
  1765. func (c *HisApiController) Get3267() {
  1766. admin_user_id, _ := c.GetInt64("admin_user_id")
  1767. startTime := c.GetString("start_time")
  1768. //endTime, _ := c.GetString("end_time")
  1769. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1770. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1771. times := strings.Split(startTime, "-")
  1772. setl_mon := times[0] + times[1]
  1773. var upld_btch string
  1774. //var empty models.JSResultEmpty
  1775. var result3265 models.JSResult3264
  1776. upld_btch = "0"
  1777. data := make(map[string]interface{})
  1778. data["org_name"] = miConfig.OrgName
  1779. data["doctor"] = curRoles.UserName
  1780. data["doctor_name"] = curRoles.UserName
  1781. data["fixmedins_code"] = miConfig.Code
  1782. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1783. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1784. data["secret_key"] = miConfig.SecretKey
  1785. data["url"] = miConfig.Url
  1786. data["ak"] = miConfig.AccessKey
  1787. data["cainfo"] = miConfig.Cainfo
  1788. data["setl_mon"] = setl_mon
  1789. data["stmt_loc"] = "2"
  1790. data["upld_btch"] = upld_btch
  1791. client := &http.Client{}
  1792. bytesData, _ := json.Marshal(data)
  1793. var req *http.Request
  1794. if miConfig.MdtrtareaAdmvs == "320921" {
  1795. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1796. } else {
  1797. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1798. }
  1799. resp, _ := client.Do(req)
  1800. defer resp.Body.Close()
  1801. body, ioErr := ioutil.ReadAll(resp.Body)
  1802. if ioErr != nil {
  1803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1805. }
  1806. var respJSON map[string]interface{}
  1807. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1810. }
  1811. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1812. fmt.Println(respJSON)
  1813. result, _ := json.Marshal(respJSON)
  1814. fmt.Println(result)
  1815. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1816. utils.ErrorLog("解析失败:%v", err)
  1817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1818. }
  1819. if result3265.Infcode != "0" {
  1820. c.ServeSuccessJSON(map[string]interface{}{
  1821. "failed_code": -10,
  1822. "msg": result3265.ErrMsg,
  1823. })
  1824. return
  1825. } else {
  1826. c.ServeSuccessJSON(map[string]interface{}{
  1827. "info": result3265.Output.Data,
  1828. })
  1829. return
  1830. }
  1831. }
  1832. func (c *HisApiController) Get3268() {
  1833. admin_user_id, _ := c.GetInt64("admin_user_id")
  1834. startTime := c.GetString("start_time")
  1835. endTime := c.GetString("end_time")
  1836. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1837. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1838. times := strings.Split(startTime, "-")
  1839. setl_mon := times[0] + times[1]
  1840. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1841. var twos []models.FixMonRecDetailFileInTwo
  1842. var funs []models.FundDetail
  1843. for _, item := range datas {
  1844. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1845. funs = append(funs, fun...)
  1846. }
  1847. var funInfos []models.Fund
  1848. //for _, item := range funs {
  1849. // var rf []models.FundInfo
  1850. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1851. // for _, subitem := range rf {
  1852. // var fund models.Fund
  1853. // fund.FundCode = subitem.FundPayType
  1854. // fund.FundName = subitem.FundPayTypeName
  1855. // fund.FundAmt = subitem.FundPayAmt
  1856. // fund.FundKey = item.FundKey
  1857. // fund.InsuAdmdvs = "555555"
  1858. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1859. // funInfos = append(funInfos, fund)
  1860. // }
  1861. //}
  1862. for _, team := range datas {
  1863. var two models.FixMonRecDetailFileInTwo
  1864. two.SetlDate = time.Now().Format("2006-01-02")
  1865. two.MedType = team.MedType
  1866. two.Insutype = team.Insutype
  1867. two.PsnType = team.PsnType
  1868. two.MedType = team.MedType
  1869. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1870. two.InsuAdmdvs = team.InsuAdmdvs
  1871. two.PsnTime = team.PsnTime
  1872. two.PsnCnt = team.PsnCnt
  1873. two.FundKey = team.FundKey
  1874. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1875. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1876. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1877. two.MedfeeSumAmt = ms
  1878. two.InscpAmt = ia
  1879. two.FundPaySumAmt = fps
  1880. twos = append(twos, two)
  1881. }
  1882. var upld_btch string
  1883. upld_btch = "0"
  1884. var empty models.JSResultEmpty
  1885. data := make(map[string]interface{})
  1886. data["org_name"] = miConfig.OrgName
  1887. data["doctor"] = curRoles.UserName
  1888. data["doctor_name"] = curRoles.UserName
  1889. data["fixmedins_code"] = miConfig.Code
  1890. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1891. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1892. data["secret_key"] = miConfig.SecretKey
  1893. data["url"] = miConfig.Url
  1894. data["ak"] = miConfig.AccessKey
  1895. data["cainfo"] = miConfig.Cainfo
  1896. data["datas"] = twos
  1897. data["fund"] = funInfos
  1898. data["setl_mon"] = setl_mon
  1899. month := time.Unix(1557042972, 0).Format("1")
  1900. year := time.Now().Format("2006")
  1901. month = time.Now().Format("01")
  1902. day := time.Now().Format("02")
  1903. hour := time.Now().Format("15")
  1904. min := time.Now().Format("04")
  1905. sec := time.Now().Format("05")
  1906. fix_fill_date := year + month + day + hour + min + sec
  1907. data["fix_fill_dept"] = miConfig.OrgName
  1908. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1909. data["fix_fill_psn"] = curRoles.UserName
  1910. data["fix_fill_date"] = fix_fill_date
  1911. data["stmt_loc"] = "2"
  1912. data["upld_btch"] = upld_btch
  1913. client := &http.Client{}
  1914. bytesData, _ := json.Marshal(data)
  1915. var req *http.Request
  1916. if miConfig.MdtrtareaAdmvs == "320921" {
  1917. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1918. } else {
  1919. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1920. }
  1921. resp, _ := client.Do(req)
  1922. defer resp.Body.Close()
  1923. body, ioErr := ioutil.ReadAll(resp.Body)
  1924. if ioErr != nil {
  1925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1927. }
  1928. var respJSON map[string]interface{}
  1929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1932. }
  1933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1934. fmt.Println(respJSON)
  1935. result, _ := json.Marshal(respJSON)
  1936. fmt.Println(result)
  1937. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1938. utils.ErrorLog("解析失败:%v", err)
  1939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1940. }
  1941. if empty.Infcode != "0" {
  1942. c.ServeSuccessJSON(map[string]interface{}{
  1943. "failed_code": -10,
  1944. "msg": empty.ErrMsg,
  1945. })
  1946. return
  1947. } else {
  1948. c.ServeSuccessJSON(map[string]interface{}{
  1949. "msg": "上传成功",
  1950. })
  1951. return
  1952. }
  1953. }
  1954. func (c *HisApiController) Get3269() {
  1955. admin_user_id, _ := c.GetInt64("admin_user_id")
  1956. startTime := c.GetString("start_time")
  1957. //endTime, _ := c.GetString("end_time")
  1958. times := strings.Split(startTime, "-")
  1959. setl_mon := times[0] + times[1]
  1960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1962. var result3263 models.JSResult3263
  1963. data := make(map[string]interface{})
  1964. data["org_name"] = miConfig.OrgName
  1965. data["doctor"] = curRoles.UserName
  1966. data["doctor_name"] = curRoles.UserName
  1967. data["fixmedins_code"] = miConfig.Code
  1968. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1969. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1970. data["secret_key"] = miConfig.SecretKey
  1971. data["url"] = miConfig.Url
  1972. data["ak"] = miConfig.AccessKey
  1973. data["cainfo"] = miConfig.Cainfo
  1974. data["setl_mon"] = setl_mon
  1975. data["stmt_loc"] = "2"
  1976. client := &http.Client{}
  1977. bytesData, _ := json.Marshal(data)
  1978. var req *http.Request
  1979. if miConfig.MdtrtareaAdmvs == "320921" {
  1980. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1981. } else {
  1982. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1983. }
  1984. resp, _ := client.Do(req)
  1985. defer resp.Body.Close()
  1986. body, ioErr := ioutil.ReadAll(resp.Body)
  1987. if ioErr != nil {
  1988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1990. }
  1991. var respJSON map[string]interface{}
  1992. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1995. }
  1996. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1997. fmt.Println(respJSON)
  1998. result, _ := json.Marshal(respJSON)
  1999. fmt.Println(result)
  2000. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2001. utils.ErrorLog("解析失败:%v", err)
  2002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2003. }
  2004. if result3263.Infcode != "0" {
  2005. c.ServeSuccessJSON(map[string]interface{}{
  2006. "failed_code": -10,
  2007. "msg": result3263.ErrMsg,
  2008. })
  2009. return
  2010. } else {
  2011. c.ServeSuccessJSON(map[string]interface{}{
  2012. "msg": "上传成功",
  2013. })
  2014. return
  2015. }
  2016. }
  2017. func (c *HisApiController) Get3270() {
  2018. admin_user_id, _ := c.GetInt64("admin_user_id")
  2019. startTime := c.GetString("start_time")
  2020. //endTime, _ := c.GetString("end_time")
  2021. times := strings.Split(startTime, "-")
  2022. setl_mon := times[0] + times[1]
  2023. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2024. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2025. var result3263 models.JSResult3263
  2026. data2 := make(map[string]interface{})
  2027. data2["org_name"] = miConfig.OrgName
  2028. data2["doctor"] = curRoles.UserName
  2029. data2["doctor_name"] = curRoles.UserName
  2030. data2["fixmedins_code"] = miConfig.Code
  2031. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2032. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2033. data2["secret_key"] = miConfig.SecretKey
  2034. data2["url"] = miConfig.Url
  2035. data2["ak"] = miConfig.AccessKey
  2036. data2["cainfo"] = miConfig.Cainfo
  2037. data2["setl_mon"] = setl_mon
  2038. data2["stmt_loc"] = "2"
  2039. client2 := &http.Client{}
  2040. bytesData2, _ := json.Marshal(data2)
  2041. var req3263 *http.Request
  2042. if miConfig.MdtrtareaAdmvs == "320921" {
  2043. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2044. } else {
  2045. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2046. }
  2047. resp2, _ := client2.Do(req3263)
  2048. defer resp2.Body.Close()
  2049. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2050. if ioErr2 != nil {
  2051. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2053. }
  2054. var respJSON3263 map[string]interface{}
  2055. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2058. }
  2059. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2060. fmt.Println(respJSON3263)
  2061. result2, _ := json.Marshal(respJSON3263)
  2062. fmt.Println(result2)
  2063. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2064. utils.ErrorLog("解析失败:%v", err)
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2066. }
  2067. var ids []string
  2068. for _, item := range result3263.Output {
  2069. ids = append(ids, item.SolidifyID)
  2070. }
  2071. var result3264 models.JSResult3264
  2072. data := make(map[string]interface{})
  2073. data["org_name"] = miConfig.OrgName
  2074. data["doctor"] = curRoles.UserName
  2075. data["doctor_name"] = curRoles.UserName
  2076. data["fixmedins_code"] = miConfig.Code
  2077. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2078. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2079. data["secret_key"] = miConfig.SecretKey
  2080. data["url"] = miConfig.Url
  2081. data["ak"] = miConfig.AccessKey
  2082. data["cainfo"] = miConfig.Cainfo
  2083. data["setl_mon"] = setl_mon
  2084. data["stmt_loc"] = "2"
  2085. data["solidify_id"] = ids
  2086. client := &http.Client{}
  2087. bytesData, _ := json.Marshal(data)
  2088. var req *http.Request
  2089. if miConfig.MdtrtareaAdmvs == "320921" {
  2090. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2091. } else {
  2092. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2093. }
  2094. resp, _ := client.Do(req)
  2095. defer resp.Body.Close()
  2096. body, ioErr := ioutil.ReadAll(resp.Body)
  2097. if ioErr != nil {
  2098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2100. }
  2101. var respJSON map[string]interface{}
  2102. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2105. }
  2106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2107. fmt.Println(respJSON)
  2108. result, _ := json.Marshal(respJSON)
  2109. fmt.Println(result)
  2110. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2111. utils.ErrorLog("解析失败:%v", err)
  2112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2113. }
  2114. if result3264.Infcode != "0" {
  2115. c.ServeSuccessJSON(map[string]interface{}{
  2116. "failed_code": -10,
  2117. "msg": result3264.ErrMsg,
  2118. })
  2119. return
  2120. } else {
  2121. c.ServeSuccessJSON(map[string]interface{}{
  2122. "info": result3264.Output,
  2123. })
  2124. return
  2125. }
  2126. }
  2127. func (c *HisApiController) Get3271() {
  2128. admin_user_id, _ := c.GetInt64("admin_user_id")
  2129. startTime := c.GetString("start_time")
  2130. //endTime, _ := c.GetString("end_time")
  2131. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2133. times := strings.Split(startTime, "-")
  2134. setl_mon := times[0] + times[1]
  2135. //var empty models.JSResultEmpty
  2136. var result3265 models.JSResult3264
  2137. var result3263 models.JSResult3263
  2138. data2 := make(map[string]interface{})
  2139. data2["org_name"] = miConfig.OrgName
  2140. data2["doctor"] = curRoles.UserName
  2141. data2["doctor_name"] = curRoles.UserName
  2142. data2["fixmedins_code"] = miConfig.Code
  2143. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2144. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2145. data2["secret_key"] = miConfig.SecretKey
  2146. data2["url"] = miConfig.Url
  2147. data2["ak"] = miConfig.AccessKey
  2148. data2["cainfo"] = miConfig.Cainfo
  2149. data2["setl_mon"] = setl_mon
  2150. data2["stmt_loc"] = "2"
  2151. client2 := &http.Client{}
  2152. bytesData2, _ := json.Marshal(data2)
  2153. var req3263 *http.Request
  2154. if miConfig.MdtrtareaAdmvs == "320921" {
  2155. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2156. } else {
  2157. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2158. }
  2159. resp2, _ := client2.Do(req3263)
  2160. defer resp2.Body.Close()
  2161. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2162. if ioErr2 != nil {
  2163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2165. }
  2166. var respJSON3263 map[string]interface{}
  2167. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2168. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2170. }
  2171. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2172. fmt.Println(respJSON3263)
  2173. result2, _ := json.Marshal(respJSON3263)
  2174. fmt.Println(result2)
  2175. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2176. utils.ErrorLog("解析失败:%v", err)
  2177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2178. }
  2179. var ids []string
  2180. for _, item := range result3263.Output {
  2181. ids = append(ids, item.SolidifyID)
  2182. }
  2183. data := make(map[string]interface{})
  2184. data["org_name"] = miConfig.OrgName
  2185. data["doctor"] = curRoles.UserName
  2186. data["doctor_name"] = curRoles.UserName
  2187. data["fixmedins_code"] = miConfig.Code
  2188. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2189. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2190. data["secret_key"] = miConfig.SecretKey
  2191. data["url"] = miConfig.Url
  2192. data["ak"] = miConfig.AccessKey
  2193. data["cainfo"] = miConfig.Cainfo
  2194. data["setl_mon"] = setl_mon
  2195. data["solidify_id"] = ids
  2196. month := time.Unix(1557042972, 0).Format("1")
  2197. year := time.Now().Format("2006")
  2198. month = time.Now().Format("01")
  2199. day := time.Now().Format("02")
  2200. hour := time.Now().Format("15")
  2201. min := time.Now().Format("04")
  2202. sec := time.Now().Format("05")
  2203. fix_fill_date := year + month + day + hour + min + sec
  2204. data["fix_fill_dept"] = miConfig.OrgName
  2205. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2206. data["fix_fill_psn"] = curRoles.UserName
  2207. data["fix_fill_date"] = fix_fill_date
  2208. data["stmt_loc"] = "2"
  2209. client := &http.Client{}
  2210. bytesData, _ := json.Marshal(data)
  2211. var req *http.Request
  2212. if miConfig.MdtrtareaAdmvs == "320921" {
  2213. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2214. } else {
  2215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2216. }
  2217. resp, _ := client.Do(req)
  2218. defer resp.Body.Close()
  2219. body, ioErr := ioutil.ReadAll(resp.Body)
  2220. if ioErr != nil {
  2221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2223. }
  2224. var respJSON map[string]interface{}
  2225. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2226. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2228. }
  2229. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2230. fmt.Println(respJSON)
  2231. result, _ := json.Marshal(respJSON)
  2232. fmt.Println(result)
  2233. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2234. utils.ErrorLog("解析失败:%v", err)
  2235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2236. }
  2237. if result3265.Infcode != "0" {
  2238. c.ServeSuccessJSON(map[string]interface{}{
  2239. "failed_code": -10,
  2240. "msg": result3265.ErrMsg,
  2241. })
  2242. return
  2243. } else {
  2244. c.ServeSuccessJSON(map[string]interface{}{
  2245. "info": result3265.Output.Data,
  2246. })
  2247. return
  2248. }
  2249. }
  2250. func (c *HisApiController) Get3272() {
  2251. admin_user_id, _ := c.GetInt64("admin_user_id")
  2252. startTime := c.GetString("start_time")
  2253. //endTime, _ := c.GetString("end_time")
  2254. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2255. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2256. times := strings.Split(startTime, "-")
  2257. setl_mon := times[0] + times[1]
  2258. var upld_btch string
  2259. //var empty models.JSResultEmpty
  2260. var result3265 models.JSResult3264
  2261. data := make(map[string]interface{})
  2262. data["org_name"] = miConfig.OrgName
  2263. data["doctor"] = curRoles.UserName
  2264. data["doctor_name"] = curRoles.UserName
  2265. data["fixmedins_code"] = miConfig.Code
  2266. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2267. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2268. data["secret_key"] = miConfig.SecretKey
  2269. data["url"] = miConfig.Url
  2270. data["ak"] = miConfig.AccessKey
  2271. data["cainfo"] = miConfig.Cainfo
  2272. data["setl_mon"] = setl_mon
  2273. month := time.Unix(1557042972, 0).Format("1")
  2274. year := time.Now().Format("2006")
  2275. month = time.Now().Format("01")
  2276. day := time.Now().Format("02")
  2277. hour := time.Now().Format("15")
  2278. min := time.Now().Format("04")
  2279. sec := time.Now().Format("05")
  2280. fix_fill_date := year + month + day + hour + min + sec
  2281. data["fix_fill_dept"] = miConfig.OrgName
  2282. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2283. data["fix_fill_psn"] = curRoles.UserName
  2284. data["fix_fill_date"] = fix_fill_date
  2285. data["stmt_loc"] = "2"
  2286. data["upld_btch"] = upld_btch
  2287. client := &http.Client{}
  2288. bytesData, _ := json.Marshal(data)
  2289. var req *http.Request
  2290. if miConfig.MdtrtareaAdmvs == "320921" {
  2291. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2292. } else {
  2293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2294. }
  2295. resp, _ := client.Do(req)
  2296. defer resp.Body.Close()
  2297. body, ioErr := ioutil.ReadAll(resp.Body)
  2298. if ioErr != nil {
  2299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2301. }
  2302. var respJSON map[string]interface{}
  2303. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2306. }
  2307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2308. fmt.Println(respJSON)
  2309. result, _ := json.Marshal(respJSON)
  2310. fmt.Println(result)
  2311. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2312. utils.ErrorLog("解析失败:%v", err)
  2313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2314. }
  2315. if result3265.Infcode != "0" {
  2316. c.ServeSuccessJSON(map[string]interface{}{
  2317. "failed_code": -10,
  2318. "msg": result3265.ErrMsg,
  2319. })
  2320. return
  2321. } else {
  2322. c.ServeSuccessJSON(map[string]interface{}{
  2323. "info": result3265.Output,
  2324. })
  2325. return
  2326. }
  2327. }
  2328. func (c *HisApiController) Get3273() {
  2329. admin_user_id, _ := c.GetInt64("admin_user_id")
  2330. startTime := c.GetString("start_time")
  2331. //endTime, _ := c.GetString("end_time")
  2332. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2333. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2334. times := strings.Split(startTime, "-")
  2335. setl_mon := times[0] + times[1]
  2336. var result3265 models.JSResult3264
  2337. data := make(map[string]interface{})
  2338. data["org_name"] = miConfig.OrgName
  2339. data["doctor"] = curRoles.UserName
  2340. data["doctor_name"] = curRoles.UserName
  2341. data["fixmedins_code"] = miConfig.Code
  2342. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2343. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2344. data["secret_key"] = miConfig.SecretKey
  2345. data["url"] = miConfig.Url
  2346. data["ak"] = miConfig.AccessKey
  2347. data["cainfo"] = miConfig.Cainfo
  2348. data["setl_mon"] = setl_mon
  2349. data["stmt_loc"] = "2"
  2350. client := &http.Client{}
  2351. bytesData, _ := json.Marshal(data)
  2352. var req *http.Request
  2353. if miConfig.MdtrtareaAdmvs == "320921" {
  2354. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2355. } else {
  2356. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  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. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2364. }
  2365. var respJSON map[string]interface{}
  2366. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2369. }
  2370. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2371. fmt.Println(respJSON)
  2372. result, _ := json.Marshal(respJSON)
  2373. fmt.Println(result)
  2374. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2375. utils.ErrorLog("解析失败:%v", err)
  2376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2377. }
  2378. if result3265.Infcode != "0" {
  2379. c.ServeSuccessJSON(map[string]interface{}{
  2380. "failed_code": -10,
  2381. "msg": result3265.ErrMsg,
  2382. })
  2383. return
  2384. } else {
  2385. c.ServeSuccessJSON(map[string]interface{}{
  2386. "info": result3265.Output.Data,
  2387. })
  2388. return
  2389. }
  2390. }
  2391. func (c *HisApiController) Get3274() {
  2392. //if miConfig.MdtrtareaAdmvs == "320921" {
  2393. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2394. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2395. // "&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
  2396. //
  2397. //} else {
  2398. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2399. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2400. // "&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
  2401. //
  2402. //}
  2403. }
  2404. func (c *HisApiController) Get3275() {
  2405. //if miConfig.MdtrtareaAdmvs == "320921" {
  2406. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2407. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2408. // "&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
  2409. //
  2410. //} else {
  2411. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2412. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2413. // "&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
  2414. //
  2415. //}
  2416. }
  2417. func (c *HisApiController) Get3276() {
  2418. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2419. //month := c.GetString("month")
  2420. //
  2421. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2422. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2423. //var api string
  2424. //var res Result5301
  2425. //
  2426. //if miConfig.MdtrtareaAdmvs == "320921" {
  2427. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2428. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2429. //} else {
  2430. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2431. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2432. //}
  2433. //
  2434. //resp, requestErr := http.Get(api)
  2435. //if requestErr != nil {
  2436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2437. // return
  2438. //}
  2439. //
  2440. //body, ioErr := ioutil.ReadAll(resp.Body)
  2441. //if ioErr != nil {
  2442. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. // return
  2445. //}
  2446. //var respJSON map[string]interface{}
  2447. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2448. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2450. // return
  2451. //}
  2452. //
  2453. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2454. //result, _ := json.Marshal(respJSON)
  2455. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2456. // utils.ErrorLog("解析失败:%v", err)
  2457. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2458. // return
  2459. //}
  2460. }
  2461. func (c *HisApiController) Get3277() {
  2462. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2463. //month := c.GetString("month")
  2464. //
  2465. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2466. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2467. //var api string
  2468. //var res Result5301
  2469. //
  2470. //if miConfig.MdtrtareaAdmvs == "320921" {
  2471. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2472. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2473. //} else {
  2474. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2475. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2476. //}
  2477. //
  2478. //resp, requestErr := http.Get(api)
  2479. //if requestErr != nil {
  2480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2481. // return
  2482. //}
  2483. //
  2484. //body, ioErr := ioutil.ReadAll(resp.Body)
  2485. //if ioErr != nil {
  2486. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2488. // return
  2489. //}
  2490. //var respJSON map[string]interface{}
  2491. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2492. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2494. // return
  2495. //}
  2496. //
  2497. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2498. //result, _ := json.Marshal(respJSON)
  2499. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2500. // utils.ErrorLog("解析失败:%v", err)
  2501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2502. // return
  2503. //}
  2504. }
  2505. func (c *HisApiController) GetCFYLJG001() {
  2506. admin_user_id, _ := c.GetInt64("admin_user_id")
  2507. patient_id, _ := c.GetInt64("patient_id")
  2508. his_patient_id, _ := c.GetInt64("his_patient_id")
  2509. record_time := c.GetString("record_time")
  2510. admin_user_id = 3626
  2511. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2512. psn, _ := service.GetPsnByPatientId(patient_id)
  2513. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2515. var cFYLJG001 models.CFYLJG001
  2516. timeLayout := "2006-01-02"
  2517. loc, _ := time.LoadLocation("Local")
  2518. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2519. if err != nil {
  2520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2521. return
  2522. }
  2523. recordDateTime := theTime.Unix()
  2524. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2525. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2526. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2527. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2528. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2529. for _, item := range prescriptions {
  2530. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2531. if his.IdCardType == 1 {
  2532. bas := strings.Split(psn.CardInfo, "|")
  2533. basNumber := bas[1]
  2534. fmt.Println(basNumber)
  2535. card_sn := bas[3]
  2536. card_no := bas[2]
  2537. cFYLJG001.MdtrtCertType = "03"
  2538. cFYLJG001.CardSn = card_sn
  2539. cFYLJG001.MdtrtCertNo = card_no
  2540. cFYLJG001.EcToken = ""
  2541. cFYLJG001.AuthNo = ""
  2542. } else if his.IdCardType == 2 {
  2543. cFYLJG001.MdtrtCertType = "02"
  2544. cFYLJG001.CardSn = ""
  2545. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2546. cFYLJG001.EcToken = ""
  2547. cFYLJG001.AuthNo = ""
  2548. } else if his.IdCardType == 4 {
  2549. cFYLJG001.MdtrtCertType = "01"
  2550. cFYLJG001.CardSn = ""
  2551. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2552. cFYLJG001.EcToken = psn.VerifyNumber
  2553. cFYLJG001.AuthNo = ""
  2554. }
  2555. cFYLJG001.BizTypeCode = "01"
  2556. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2557. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2558. cFYLJG001.RxTypeCode = "1"
  2559. tempTime := time.Unix(item.PreTime, 0)
  2560. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2561. cFYLJG001.PrscTime = timeFormatOne
  2562. var count float64
  2563. if item.Type == 1 {
  2564. for _, sumItem := range item.HisDoctorAdviceInfo {
  2565. count = count + sumItem.PrescribingNumber
  2566. }
  2567. }
  2568. cFYLJG001.RxDrugCnt = count
  2569. cFYLJG001.ValiDays = "5"
  2570. ts := time.Unix(item.PreTime, 0)
  2571. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2572. tempTime3 := time.Unix(record_time2, 0)
  2573. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2574. cFYLJG001.ValiEndTime = timeFormat3
  2575. cFYLJG001.RxCotnFlag = "0"
  2576. for _, subItem := range item.HisDoctorAdviceInfo {
  2577. var drug models.RxDrug
  2578. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2579. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2580. drug.RxItemTypeCode = "11"
  2581. drug.DrugDosform = "乳膏剂" //TODO
  2582. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2583. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2584. }
  2585. drug.MedcWayDscr = subItem.DeliveryWay
  2586. tempTime2 := time.Unix(subItem.StartTime, 0)
  2587. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2588. drug.MedcBegntime = timeFormatTwo
  2589. if subItem.Day > 0 {
  2590. ts := time.Unix(subItem.StartTime, 0)
  2591. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2592. tempTime4 := time.Unix(record_time, 0)
  2593. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2594. drug.MedcEndtime = timeFormat5
  2595. } else {
  2596. tempTime2 := time.Unix(subItem.StartTime, 0)
  2597. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2598. drug.MedcEndtime = timeFormatTwo
  2599. }
  2600. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2601. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2602. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2603. drug.DrugCnt = subItem.PrescribingNumber
  2604. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2605. drug.DrugGenname = subItem.AdviceName
  2606. drug.MedcWayCodg = subItem.DeliveryWay
  2607. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2608. drug.SinDoscnt = subItem.SingleDose
  2609. drug.SinDosunt = subItem.SingleDoseUnit
  2610. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2611. drug.UsedFrquName = subItem.ExecutionFrequency
  2612. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2613. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2614. drug.HospApprFlag = "1"
  2615. cFYLJG001.List = append(cFYLJG001.List, drug)
  2616. }
  2617. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2618. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2619. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2620. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2621. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2622. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2623. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2624. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2625. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2626. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2627. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2628. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2629. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2630. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2631. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2632. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2633. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2634. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2635. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2636. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2637. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2638. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2639. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2640. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2641. tempTime2 := time.Now().Unix()
  2642. tempTime6 := time.Unix(tempTime2, 0)
  2643. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2644. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2645. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2646. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2647. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2648. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2649. //memo := make(map[string]interface{})
  2650. //inputData := make(map[string]interface{}, 0)
  2651. //type MyData struct {
  2652. // Insutype string `json:"insutype"`
  2653. //}
  2654. //
  2655. // data := MyData{
  2656. // Insutype: his.Insutype,
  2657. //}
  2658. //
  2659. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2660. var config []*models.HisXtDiagnoseConfig
  2661. for _, item := range diagnosis_ids {
  2662. id, _ := strconv.ParseInt(item, 10, 64)
  2663. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2664. config = append(config, &diagnosisConfig)
  2665. }
  2666. for index, subitem := range config {
  2667. if index == 0 {
  2668. var dia models.DiseInfo
  2669. dia.DiagType = "1"
  2670. dia.MaindiagFlag = "1"
  2671. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2672. dia.DiagCode = subitem.CountryCode
  2673. dia.DiagName = subitem.ClassName
  2674. dia.DiagDept = "肾内科"
  2675. dia.DiagDrNo = doctor.DoctorNumber
  2676. dia.DiagDrName = doctor.UserName
  2677. tempTime3 := time.Unix(item.PreTime, 0)
  2678. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2679. dia.DiagTime = timeFormatTwo
  2680. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2681. } else {
  2682. var dia models.DiseInfo
  2683. dia.DiagType = "1"
  2684. dia.MaindiagFlag = "0"
  2685. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2686. dia.DiagCode = subitem.CountryCode
  2687. dia.DiagName = subitem.ClassName
  2688. dia.DiagDept = "肾内科"
  2689. dia.DiagDrNo = doctor.DoctorNumber
  2690. dia.DiagDrName = doctor.UserName
  2691. tempTime3 := time.Unix(item.PreTime, 0)
  2692. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2693. dia.DiagTime = timeFormatTwo
  2694. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2695. }
  2696. }
  2697. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2698. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2699. var res ResultCFYLJG001
  2700. var respJSON2 map[string]interface{}
  2701. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2704. return
  2705. }
  2706. userJSONBytes2, _ := json.Marshal(respJSON2)
  2707. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2708. utils.ErrorLog("解析失败:%v", err)
  2709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2710. return
  2711. }
  2712. if res.Infcode == -1 {
  2713. c.ServeSuccessJSON(map[string]interface{}{
  2714. "failed_code": -10,
  2715. "msg": res.ErrMsg,
  2716. })
  2717. return
  2718. } else {
  2719. var flow models.HisPrescriptionFlow
  2720. flow.Ctime = time.Now().Unix()
  2721. flow.SignDigest = ""
  2722. flow.RxTraceCode = res.Output.RxTraceCode
  2723. flow.HiRxno = res.Output.HiRxno
  2724. flow.MID = his.Number
  2725. flow.Status = 1
  2726. flow.DCode = doctor_info.DoctorNumber
  2727. flow.OriginalRxFile = ""
  2728. flow.OriginalValue = ""
  2729. flow.SignCertDn = ""
  2730. flow.UserOrgId = 10454
  2731. flow.SignCertSn = ""
  2732. flow.Mtime = time.Now().Unix()
  2733. service.Createflow(&flow)
  2734. c.ServeSuccessJSON(map[string]interface{}{
  2735. "msg": "上传成功",
  2736. })
  2737. }
  2738. }
  2739. }
  2740. func (c *HisApiController) GetCFYLJG002() {
  2741. admin_user_id, _ := c.GetInt64("admin_user_id")
  2742. his_patient_id, _ := c.GetInt64("his_patient_id")
  2743. record_time := c.GetString("record_time")
  2744. admin_user_id = 3626
  2745. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2746. //id, _ := c.GetInt64("id")
  2747. admin_user_id = 3626
  2748. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2749. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2750. flow, _ := service.Getflowtwo(his.Number)
  2751. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2752. //record_time := c.GetString("record_time")
  2753. patient_id, _ := c.GetInt64("patient_id")
  2754. //patient_id = 23834
  2755. //record_time = "2023-09-18"
  2756. timeLayout := "2006-01-02"
  2757. loc, _ := time.LoadLocation("Local")
  2758. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2759. if err != nil {
  2760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2761. return
  2762. }
  2763. recordDateTime := theTime.Unix()
  2764. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2765. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2766. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2767. dept, _ := service.GetDepartMentDetail(info.Departments)
  2768. inputData := make(map[string]interface{})
  2769. inputData["rxTraceCode"] = flow.RxTraceCode
  2770. inputData["hiRxno"] = flow.HiRxno
  2771. inputData["mdtrtId"] = flow.MID
  2772. inputData["patnName"] = his.PsnName
  2773. inputData["psnCertType"] = his.PsnCertType
  2774. inputData["certno"] = his.Certno
  2775. inputData["fixmedinsName"] = miConfig.OrgName
  2776. inputData["fixmedinsCode"] = miConfig.Code
  2777. inputData["drCode"] = doctor_info.DoctorNumber
  2778. inputData["prscDrName"] = doctor_info.UserName
  2779. inputData["pharDeptName"] = dept.Name
  2780. inputData["pharDeptCode"] = dept.Number
  2781. inputData["pharProfttlCodg"] = dept.Name
  2782. inputData["pharProfttlName"] = ""
  2783. inputData["pharCode"] = "HY440309002107"
  2784. inputData["pharCertType"] = "01"
  2785. inputData["pharCertno"] = "430482199408260023"
  2786. inputData["pharName"] = "彭斯遥"
  2787. inputData["pharPracCertNo"] = ""
  2788. tempTime2 := time.Unix(info.Ctime, 0)
  2789. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2790. inputData["pharChkTime"] = timeFormatTwo
  2791. bytesData, _ := json.Marshal(inputData)
  2792. fmt.Println(string(bytesData))
  2793. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2794. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2795. if err != nil {
  2796. fmt.Println("Error reading PDF file:", err)
  2797. return
  2798. }
  2799. // 将 PDF 文件内容进行 Base64 编码
  2800. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2801. fmt.Println(err)
  2802. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2803. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2804. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2805. var res2 Result002
  2806. var respJSON2 map[string]interface{}
  2807. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2810. return
  2811. }
  2812. userJSONBytes2, _ := json.Marshal(respJSON2)
  2813. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2814. utils.ErrorLog("解析失败:%v", err)
  2815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2816. return
  2817. }
  2818. if res2.Infcode == 0 {
  2819. flow.Ctime = time.Now().Unix()
  2820. flow.SignDigest = res2.Output.SignDigest
  2821. flow.RxFile = res2.Output.RxFile
  2822. flow.MID = his.Number
  2823. flow.Status = 1
  2824. flow.DCode = doctor_info.DoctorNumber
  2825. flow.OriginalRxFile = rx_encoded
  2826. flow.OriginalValue = encoded
  2827. flow.SignCertDn = res2.Output.SignCertDn
  2828. flow.SignCertSn = res2.Output.SignCertSn
  2829. flow.Mtime = time.Now().Unix()
  2830. service.Saveflow(flow)
  2831. c.ServeSuccessJSON(map[string]interface{}{
  2832. "msg": "预签名成功",
  2833. })
  2834. } else {
  2835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2836. return
  2837. }
  2838. }
  2839. func (c *HisApiController) GetCFYLJG003() {
  2840. admin_user_id, _ := c.GetInt64("admin_user_id")
  2841. his_patient_id, _ := c.GetInt64("his_patient_id")
  2842. record_time := c.GetString("record_time")
  2843. admin_user_id = 3626
  2844. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2845. //id, _ := c.GetInt64("id")
  2846. admin_user_id = 3626
  2847. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2849. flow, _ := service.Getflowtwo(his.Number)
  2850. //id = 3
  2851. patient_id, _ := c.GetInt64("patient_id")
  2852. //patient_id = 23834
  2853. //record_time = "2023-09-18"
  2854. timeLayout := "2006-01-02"
  2855. loc, _ := time.LoadLocation("Local")
  2856. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2857. if err != nil {
  2858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2859. return
  2860. }
  2861. recordDateTime := theTime.Unix()
  2862. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2863. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2864. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2865. dept, _ := service.GetDepartMentDetail(info.Departments)
  2866. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2867. var cFYLJG003 models.CFYLJG003
  2868. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2869. cFYLJG003.HiRxno = flow.HiRxno
  2870. cFYLJG003.MdtrtID = flow.MID
  2871. cFYLJG003.PatnName = his.Name
  2872. cFYLJG003.Certno = his.Certno
  2873. cFYLJG003.FixmedinsName = miConfig.OrgName
  2874. cFYLJG003.FixmedinsCode = miConfig.Code
  2875. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2876. cFYLJG003.PrscDrName = doctor_info.UserName
  2877. cFYLJG003.PharDeptName = dept.Name
  2878. cFYLJG003.PharDeptCode = dept.Number
  2879. cFYLJG003.PharCode = "HY440309002107"
  2880. cFYLJG003.PharCertType = "01"
  2881. cFYLJG003.PharCertno = "430482199408260023"
  2882. cFYLJG003.PharName = "彭斯遥"
  2883. cFYLJG003.PsnCertType = "01"
  2884. cFYLJG003.RxFile = flow.RxFile
  2885. cFYLJG003.SignDigest = flow.SignDigest
  2886. cFYLJG003.FixmedinsCode = miConfig.Code
  2887. cFYLJG003.PsnCertType = "01"
  2888. cFYLJG003.PharProfttlCodg = dept.Name
  2889. //inputData["pharProfttlCodg"] =dept.Name
  2890. tempTime2 := time.Unix(info.Ctime, 0)
  2891. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2892. cFYLJG003.PharChkTime = timeFormatTwo
  2893. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2894. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2895. var res ResultCFYLJG003
  2896. var respJSON2 map[string]interface{}
  2897. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2900. return
  2901. }
  2902. userJSONBytes2, _ := json.Marshal(respJSON2)
  2903. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2904. utils.ErrorLog("解析失败:%v", err)
  2905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2906. return
  2907. }
  2908. if res.Infcode == -1 {
  2909. c.ServeSuccessJSON(map[string]interface{}{
  2910. "failed_code": -10,
  2911. "msg": res.ErrMsg,
  2912. })
  2913. return
  2914. } else {
  2915. c.ServeSuccessJSON(map[string]interface{}{
  2916. "info": res.Output,
  2917. })
  2918. }
  2919. }
  2920. func (c *HisApiController) GetCFYLJG004() {
  2921. admin_user_id, _ := c.GetInt64("admin_user_id")
  2922. his_patient_id, _ := c.GetInt64("his_patient_id")
  2923. record_time := c.GetString("record_time")
  2924. admin_user_id = 3626
  2925. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2926. //id, _ := c.GetInt64("id")
  2927. admin_user_id = 3626
  2928. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2930. flow, _ := service.Getflowtwo(his.Number)
  2931. //id = 3
  2932. patient_id, _ := c.GetInt64("patient_id")
  2933. //patient_id = 23834
  2934. //record_time = "2023-09-18"
  2935. timeLayout := "2006-01-02"
  2936. loc, _ := time.LoadLocation("Local")
  2937. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2938. if err != nil {
  2939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2940. return
  2941. }
  2942. recordDateTime := theTime.Unix()
  2943. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2944. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2945. var cFYLJG004 models.CFYLJG004
  2946. cFYLJG004.HiRxno = flow.HiRxno
  2947. cFYLJG004.FixmedinsCode = miConfig.Code
  2948. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2949. cFYLJG004.UndoDrCertType = "01"
  2950. cFYLJG004.UndoRea = "撤销处方"
  2951. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2952. cFYLJG004.UndoDrName = doctor_info.UserName
  2953. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2954. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2955. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2956. var res ResultCFYLJG004
  2957. var respJSON2 map[string]interface{}
  2958. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2961. return
  2962. }
  2963. userJSONBytes2, _ := json.Marshal(respJSON2)
  2964. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2965. utils.ErrorLog("解析失败:%v", err)
  2966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2967. return
  2968. }
  2969. if res.Infcode == -1 {
  2970. c.ServeSuccessJSON(map[string]interface{}{
  2971. "failed_code": -10,
  2972. "msg": res.ErrMsg,
  2973. })
  2974. return
  2975. } else {
  2976. flow.Status = 0
  2977. service.Saveflow(flow)
  2978. c.ServeSuccessJSON(map[string]interface{}{
  2979. "msg": "撤销成功",
  2980. })
  2981. return
  2982. }
  2983. }
  2984. func (c *HisApiController) GetCFYLJG005() {
  2985. admin_user_id, _ := c.GetInt64("admin_user_id")
  2986. his_patient_id, _ := c.GetInt64("his_patient_id")
  2987. //record_time := c.GetString("record_time")
  2988. admin_user_id = 3626
  2989. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2990. //id, _ := c.GetInt64("id")
  2991. admin_user_id = 3626
  2992. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2993. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2994. flow, _ := service.Getflowtwo(his.Number)
  2995. //id = 3
  2996. var cFYLJG005 models.CFYLJG005
  2997. //patient_id, _ := c.GetInt64("patient_id")
  2998. cFYLJG005.HiRxno = flow.HiRxno
  2999. cFYLJG005.MdtrtID = flow.MID
  3000. cFYLJG005.EcToken = ""
  3001. cFYLJG005.PsnName = his.Name
  3002. cFYLJG005.PsnCertType = "01"
  3003. cFYLJG005.Certno = his.IdCardNo
  3004. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3005. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3006. var res ResultCFYLJG005
  3007. var respJSON2 map[string]interface{}
  3008. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3011. return
  3012. }
  3013. userJSONBytes2, _ := json.Marshal(respJSON2)
  3014. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3015. utils.ErrorLog("解析失败:%v", err)
  3016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3017. return
  3018. }
  3019. if res.Infcode == -1 {
  3020. c.ServeSuccessJSON(map[string]interface{}{
  3021. "failed_code": -10,
  3022. "msg": res.ErrMsg,
  3023. })
  3024. return
  3025. } else {
  3026. c.ServeSuccessJSON(map[string]interface{}{
  3027. "info": res.Output,
  3028. })
  3029. return
  3030. }
  3031. }
  3032. func (c *HisApiController) GetCFYLJG006() {
  3033. admin_user_id, _ := c.GetInt64("admin_user_id")
  3034. his_patient_id, _ := c.GetInt64("his_patient_id")
  3035. admin_user_id = 3626
  3036. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3037. //id, _ := c.GetInt64("id")
  3038. admin_user_id = 3626
  3039. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3041. flow, _ := service.Getflowtwo(his.Number)
  3042. //id = 3
  3043. patient_id, _ := c.GetInt64("patient_id")
  3044. var cFYLJG006 models.CFYLJG006
  3045. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3046. cFYLJG006.HiRxno = flow.HiRxno
  3047. cFYLJG006.MdtrtID = flow.MID
  3048. cFYLJG006.PsnName = patient.Name
  3049. cFYLJG006.PsnCertType = "01"
  3050. cFYLJG006.Certno = patient.IdCardNo
  3051. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3052. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3053. var res ResultCFYLJG006
  3054. var respJSON2 map[string]interface{}
  3055. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3058. return
  3059. }
  3060. userJSONBytes2, _ := json.Marshal(respJSON2)
  3061. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3062. utils.ErrorLog("解析失败:%v", err)
  3063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3064. return
  3065. }
  3066. if res.Infcode == -1 {
  3067. c.ServeSuccessJSON(map[string]interface{}{
  3068. "failed_code": -10,
  3069. "msg": res.ErrMsg,
  3070. })
  3071. return
  3072. } else {
  3073. c.ServeSuccessJSON(map[string]interface{}{
  3074. "info": res.Output,
  3075. })
  3076. return
  3077. }
  3078. }
  3079. func (c *HisApiController) GetCFYLJG007() {
  3080. admin_user_id, _ := c.GetInt64("admin_user_id")
  3081. his_patient_id, _ := c.GetInt64("his_patient_id")
  3082. admin_user_id = 3626
  3083. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3084. //id, _ := c.GetInt64("id")
  3085. admin_user_id = 3626
  3086. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3087. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3088. flow, _ := service.Getflowtwo(his.Number)
  3089. //id = 3
  3090. patient_id, _ := c.GetInt64("patient_id")
  3091. var cFYLJG007 models.CFYLJG007
  3092. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3093. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3094. cFYLJG007.HiRxno = flow.HiRxno
  3095. cFYLJG007.MdtrtID = flow.MID
  3096. cFYLJG007.PsnNo = his.PsnNo
  3097. cFYLJG007.PsnCertType = "01"
  3098. cFYLJG007.Certno = patient.IdCardNo
  3099. cFYLJG007.PsnName = patient.Name
  3100. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3101. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3102. var res ResultCFYLJG007
  3103. var respJSON2 map[string]interface{}
  3104. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3107. return
  3108. }
  3109. userJSONBytes2, _ := json.Marshal(respJSON2)
  3110. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3111. utils.ErrorLog("解析失败:%v", err)
  3112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3113. return
  3114. }
  3115. if res.Infcode == -1 {
  3116. c.ServeSuccessJSON(map[string]interface{}{
  3117. "failed_code": -10,
  3118. "msg": res.ErrMsg,
  3119. })
  3120. return
  3121. } else {
  3122. c.ServeSuccessJSON(map[string]interface{}{
  3123. "info": res,
  3124. })
  3125. return
  3126. }
  3127. }
  3128. func (c *HisApiController) GetCFYLJG008() {
  3129. admin_user_id, _ := c.GetInt64("admin_user_id")
  3130. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3131. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3132. var cFYLJG008 models.CFYLJG008
  3133. //id, _ := c.GetInt64("id")
  3134. patient_id, _ := c.GetInt64("patient_id")
  3135. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3136. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3137. //id = 3
  3138. //flow, _ := service.Getflow(id)
  3139. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3140. //
  3141. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3142. //patient_id, _ := c.GetInt64("patient_id")
  3143. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3144. record_time := c.GetString("record_time")
  3145. admin_user_id = 3626
  3146. patient_id = 19424
  3147. //his_patient_id = 263947
  3148. record_time = "2023-08-29"
  3149. timeLayout := "2006-01-02"
  3150. loc, _ := time.LoadLocation("Local")
  3151. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3152. if err != nil {
  3153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3154. return
  3155. }
  3156. recordDateTime := theTime.Unix()
  3157. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3158. cFYLJG008.FixmedinsName = ""
  3159. cFYLJG008.Lat = ""
  3160. cFYLJG008.Lng = ""
  3161. cFYLJG008.OrderType = "1"
  3162. cFYLJG008.PoolareaNo = ""
  3163. cFYLJG008.Lng = ""
  3164. cFYLJG008.PageNum = 1
  3165. cFYLJG008.PageSize = 10
  3166. var MPI models.MedinsProdInvChgDDTO
  3167. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3168. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3169. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3170. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3171. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3172. var res ResultCFYLJG008
  3173. var respJSON2 map[string]interface{}
  3174. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. return
  3178. }
  3179. userJSONBytes2, _ := json.Marshal(respJSON2)
  3180. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3181. utils.ErrorLog("解析失败:%v", err)
  3182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. return
  3184. }
  3185. if res.Infcode == -1 {
  3186. c.ServeSuccessJSON(map[string]interface{}{
  3187. "failed_code": -10,
  3188. "msg": res.ErrMsg,
  3189. })
  3190. return
  3191. } else {
  3192. c.ServeSuccessJSON(map[string]interface{}{
  3193. "info": res.Output,
  3194. })
  3195. return
  3196. }
  3197. }
  3198. func (c *HisApiController) GetBL4201A() {
  3199. order_id, _ := c.GetInt64("order_id")
  3200. admin_user_id, _ := c.GetInt64("admin_user_id")
  3201. order, _ := service.GetHisOrderByIDTwo(order_id)
  3202. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3203. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3204. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3205. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3206. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3207. department, _ := service.GetDepartMentDetail(his.Departments)
  3208. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3209. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3210. if order.ID == 0 {
  3211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3212. return
  3213. }
  3214. var struct4201A models.Struct4201A
  3215. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3216. for _, items := range order_info {
  3217. memo := make(map[string]interface{})
  3218. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3219. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3220. fsiOPFLD.MedType = "14"
  3221. fsiOPFLD.BkkpSn = items.FeedetlSn
  3222. fsiOPFLD.FixmedinsCode = miConfig.Code
  3223. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3224. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3225. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3226. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3227. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3228. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3229. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3230. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3231. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3232. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3233. fsiOPFLD.BilgDeptName = department.Name
  3234. fsiOPFLD.BilgDeptCodg = department.Number
  3235. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3236. fsiOPFLD.BilgDrName = doctor.UserName
  3237. fsiOPFLD.MedChrgitmType = "09"
  3238. memo["hosp_appr_flag"] = "1"
  3239. memo["invoice_no"] = order.MdtrtId
  3240. memo["memo"] = "自费"
  3241. bytesData, _ := json.Marshal(memo)
  3242. fsiOPFLD.Memo = string(bytesData)
  3243. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3244. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3245. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3246. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3247. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3248. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3249. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3250. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3251. fsiOPFLD.BilgDeptName = department.Name
  3252. fsiOPFLD.BilgDeptCodg = department.Number
  3253. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3254. fsiOPFLD.BilgDrName = doctor.UserName
  3255. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3256. case 0:
  3257. break
  3258. case 1:
  3259. fsiOPFLD.MedChrgitmType = "14"
  3260. break
  3261. case 2:
  3262. fsiOPFLD.MedChrgitmType = "05"
  3263. break
  3264. case 3:
  3265. fsiOPFLD.MedChrgitmType = "03"
  3266. break
  3267. case 4:
  3268. fsiOPFLD.MedChrgitmType = "03"
  3269. break
  3270. case 5:
  3271. fsiOPFLD.MedChrgitmType = "08"
  3272. break
  3273. case 6:
  3274. fsiOPFLD.MedChrgitmType = "14"
  3275. break
  3276. case 7:
  3277. fsiOPFLD.MedChrgitmType = "14"
  3278. break
  3279. case 8:
  3280. fsiOPFLD.MedChrgitmType = "03"
  3281. break
  3282. case 9:
  3283. fsiOPFLD.MedChrgitmType = "14"
  3284. break
  3285. case 10:
  3286. fsiOPFLD.MedChrgitmType = "14"
  3287. break
  3288. case 11:
  3289. fsiOPFLD.MedChrgitmType = "06"
  3290. break
  3291. case 12:
  3292. fsiOPFLD.MedChrgitmType = "12"
  3293. break
  3294. case 13:
  3295. fsiOPFLD.MedChrgitmType = "01"
  3296. break
  3297. case 14:
  3298. fsiOPFLD.MedChrgitmType = "04"
  3299. break
  3300. case 15:
  3301. fsiOPFLD.MedChrgitmType = "14"
  3302. break
  3303. }
  3304. memo["hosp_appr_flag"] = "1"
  3305. memo["invoice_no"] = order.MdtrtId
  3306. memo["memo"] = "自费"
  3307. bytesData, _ := json.Marshal(memo)
  3308. fsiOPFLD.Memo = string(bytesData)
  3309. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3310. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3311. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3312. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3313. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3314. fsiOPFLD.BilgDeptName = department.Name
  3315. fsiOPFLD.BilgDeptCodg = department.Number
  3316. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3317. fsiOPFLD.BilgDrName = doctor.UserName
  3318. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3319. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3320. fsiOPFLD.MedChrgitmType = "08"
  3321. memo["hosp_appr_flag"] = "1"
  3322. memo["invoice_no"] = order.MdtrtId
  3323. memo["memo"] = "自费"
  3324. bytesData, _ := json.Marshal(memo)
  3325. fsiOPFLD.Memo = string(bytesData)
  3326. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3327. }
  3328. }
  3329. }
  3330. for _, items := range order_info_two {
  3331. memo := make(map[string]interface{})
  3332. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3333. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3334. fsiOPFLD.MedType = "14"
  3335. fsiOPFLD.BkkpSn = items.FeedetlSn
  3336. fsiOPFLD.FixmedinsCode = miConfig.Code
  3337. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3338. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3339. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3340. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3341. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3342. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3343. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3344. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3345. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3346. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3347. fsiOPFLD.BilgDeptName = department.Name
  3348. fsiOPFLD.BilgDeptCodg = department.Number
  3349. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3350. fsiOPFLD.BilgDrName = doctor.UserName
  3351. fsiOPFLD.MedChrgitmType = "09"
  3352. memo["hosp_appr_flag"] = "1"
  3353. memo["invoice_no"] = order.MdtrtId
  3354. memo["memo"] = "自费"
  3355. bytesData, _ := json.Marshal(memo)
  3356. fsiOPFLD.Memo = string(bytesData)
  3357. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3358. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3359. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3360. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3361. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3362. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3363. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3364. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3365. fsiOPFLD.BilgDeptName = department.Name
  3366. fsiOPFLD.BilgDeptCodg = department.Number
  3367. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3368. fsiOPFLD.BilgDrName = doctor.UserName
  3369. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3370. case 0:
  3371. break
  3372. case 1:
  3373. fsiOPFLD.MedChrgitmType = "14"
  3374. break
  3375. case 2:
  3376. fsiOPFLD.MedChrgitmType = "05"
  3377. break
  3378. case 3:
  3379. fsiOPFLD.MedChrgitmType = "03"
  3380. break
  3381. case 4:
  3382. fsiOPFLD.MedChrgitmType = "03"
  3383. break
  3384. case 5:
  3385. fsiOPFLD.MedChrgitmType = "08"
  3386. break
  3387. case 6:
  3388. fsiOPFLD.MedChrgitmType = "14"
  3389. break
  3390. case 7:
  3391. fsiOPFLD.MedChrgitmType = "14"
  3392. break
  3393. case 8:
  3394. fsiOPFLD.MedChrgitmType = "03"
  3395. break
  3396. case 9:
  3397. fsiOPFLD.MedChrgitmType = "14"
  3398. break
  3399. case 10:
  3400. fsiOPFLD.MedChrgitmType = "14"
  3401. break
  3402. case 11:
  3403. fsiOPFLD.MedChrgitmType = "06"
  3404. break
  3405. case 12:
  3406. fsiOPFLD.MedChrgitmType = "12"
  3407. break
  3408. case 13:
  3409. fsiOPFLD.MedChrgitmType = "01"
  3410. break
  3411. case 14:
  3412. fsiOPFLD.MedChrgitmType = "04"
  3413. break
  3414. case 15:
  3415. fsiOPFLD.MedChrgitmType = "14"
  3416. break
  3417. }
  3418. memo["hosp_appr_flag"] = "1"
  3419. memo["invoice_no"] = order.MdtrtId
  3420. memo["memo"] = "自费"
  3421. bytesData, _ := json.Marshal(memo)
  3422. fsiOPFLD.Memo = string(bytesData)
  3423. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3424. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3425. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3426. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3427. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3428. fsiOPFLD.BilgDeptName = department.Name
  3429. fsiOPFLD.BilgDeptCodg = department.Number
  3430. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3431. fsiOPFLD.BilgDrName = doctor.UserName
  3432. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3433. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3434. fsiOPFLD.MedChrgitmType = "08"
  3435. memo["hosp_appr_flag"] = "1"
  3436. memo["invoice_no"] = order.MdtrtId
  3437. memo["memo"] = "自费"
  3438. bytesData, _ := json.Marshal(memo)
  3439. fsiOPFLD.Memo = string(bytesData)
  3440. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3441. }
  3442. }
  3443. }
  3444. fmt.Println(fsiOPFLDs)
  3445. struct4201A.Fopfd = fsiOPFLDs
  3446. fmt.Println(struct4201A.Fopfd)
  3447. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3448. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3449. var res2 ResultSix
  3450. var respJSON2 map[string]interface{}
  3451. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3454. return
  3455. }
  3456. userJSONBytes2, _ := json.Marshal(respJSON2)
  3457. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. if res2.Infcode != 0 {
  3463. c.ServeSuccessJSON(map[string]interface{}{
  3464. "failed_code": -10,
  3465. "msg": res2.ErrMsg,
  3466. })
  3467. return
  3468. } else {
  3469. order.IsUploadOrderInfo = 1
  3470. service.UpdateOrder(order)
  3471. c.ServeSuccessJSON(map[string]interface{}{
  3472. "msg": "上传成功",
  3473. })
  3474. }
  3475. }
  3476. func (c *HisApiController) Get2505() {
  3477. admin_user_id, _ := c.GetInt64("admin_user_id")
  3478. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3479. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3480. 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)
  3481. }
  3482. func (c *HisApiController) Get4201A() {
  3483. order_id, _ := c.GetInt64("order_id")
  3484. admin_user_id, _ := c.GetInt64("admin_user_id")
  3485. order, _ := service.GetHisOrderByIDTwo(order_id)
  3486. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3487. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3488. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3489. //order_info = append(order_info, order_info_two...)
  3490. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3491. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3492. department, _ := service.GetDepartMentDetail(his.Departments)
  3493. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3494. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3495. if order.ID == 0 {
  3496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3497. return
  3498. }
  3499. var struct4201A models.Struct4201A
  3500. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3501. for _, items := range order_info {
  3502. memo := make(map[string]interface{})
  3503. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3504. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3505. fsiOPFLD.MedType = "14"
  3506. fsiOPFLD.BkkpSn = items.FeedetlSn
  3507. fsiOPFLD.FixmedinsCode = miConfig.Code
  3508. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3509. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3510. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3511. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3512. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3513. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3514. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3515. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3516. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3517. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3518. fsiOPFLD.BilgDeptName = department.Name
  3519. fsiOPFLD.BilgDeptCodg = department.Number
  3520. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3521. fsiOPFLD.BilgDrName = doctor.UserName
  3522. fsiOPFLD.MedChrgitmType = "09"
  3523. memo["hosp_appr_flag"] = "1"
  3524. memo["invoice_no"] = order.MdtrtId
  3525. memo["memo"] = "自费"
  3526. bytesData, _ := json.Marshal(memo)
  3527. fsiOPFLD.Memo = string(bytesData)
  3528. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3529. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3530. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3531. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3532. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3533. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3534. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3535. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3536. fsiOPFLD.BilgDeptName = department.Name
  3537. fsiOPFLD.BilgDeptCodg = department.Number
  3538. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3539. fsiOPFLD.BilgDrName = doctor.UserName
  3540. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3541. case 0:
  3542. break
  3543. case 1:
  3544. fsiOPFLD.MedChrgitmType = "14"
  3545. break
  3546. case 2:
  3547. fsiOPFLD.MedChrgitmType = "05"
  3548. break
  3549. case 3:
  3550. fsiOPFLD.MedChrgitmType = "03"
  3551. break
  3552. case 4:
  3553. fsiOPFLD.MedChrgitmType = "03"
  3554. break
  3555. case 5:
  3556. fsiOPFLD.MedChrgitmType = "08"
  3557. break
  3558. case 6:
  3559. fsiOPFLD.MedChrgitmType = "14"
  3560. break
  3561. case 7:
  3562. fsiOPFLD.MedChrgitmType = "14"
  3563. break
  3564. case 8:
  3565. fsiOPFLD.MedChrgitmType = "03"
  3566. break
  3567. case 9:
  3568. fsiOPFLD.MedChrgitmType = "14"
  3569. break
  3570. case 10:
  3571. fsiOPFLD.MedChrgitmType = "14"
  3572. break
  3573. case 11:
  3574. fsiOPFLD.MedChrgitmType = "06"
  3575. break
  3576. case 12:
  3577. fsiOPFLD.MedChrgitmType = "12"
  3578. break
  3579. case 13:
  3580. fsiOPFLD.MedChrgitmType = "01"
  3581. break
  3582. case 14:
  3583. fsiOPFLD.MedChrgitmType = "04"
  3584. break
  3585. case 15:
  3586. fsiOPFLD.MedChrgitmType = "14"
  3587. break
  3588. }
  3589. memo["hosp_appr_flag"] = "1"
  3590. memo["invoice_no"] = order.MdtrtId
  3591. memo["memo"] = "自费"
  3592. bytesData, _ := json.Marshal(memo)
  3593. fsiOPFLD.Memo = string(bytesData)
  3594. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3595. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3596. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3597. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3598. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3599. fsiOPFLD.BilgDeptName = department.Name
  3600. fsiOPFLD.BilgDeptCodg = department.Number
  3601. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3602. fsiOPFLD.BilgDrName = doctor.UserName
  3603. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3604. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3605. fsiOPFLD.MedChrgitmType = "08"
  3606. memo["hosp_appr_flag"] = "1"
  3607. memo["invoice_no"] = order.MdtrtId
  3608. memo["memo"] = "自费"
  3609. bytesData, _ := json.Marshal(memo)
  3610. fsiOPFLD.Memo = string(bytesData)
  3611. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3612. }
  3613. }
  3614. }
  3615. for _, items := range order_info_two {
  3616. memo := make(map[string]interface{})
  3617. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3618. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3619. fsiOPFLD.MedType = "14"
  3620. fsiOPFLD.BkkpSn = items.FeedetlSn
  3621. fsiOPFLD.FixmedinsCode = miConfig.Code
  3622. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3623. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3624. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3625. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3626. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3627. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3628. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3629. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3630. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3631. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3632. fsiOPFLD.BilgDeptName = department.Name
  3633. fsiOPFLD.BilgDeptCodg = department.Number
  3634. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3635. fsiOPFLD.BilgDrName = doctor.UserName
  3636. fsiOPFLD.MedChrgitmType = "09"
  3637. memo["hosp_appr_flag"] = "1"
  3638. memo["invoice_no"] = order.MdtrtId
  3639. memo["memo"] = "自费"
  3640. bytesData, _ := json.Marshal(memo)
  3641. fsiOPFLD.Memo = string(bytesData)
  3642. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3643. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3644. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3645. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3646. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3647. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3648. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3649. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3650. fsiOPFLD.BilgDeptName = department.Name
  3651. fsiOPFLD.BilgDeptCodg = department.Number
  3652. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3653. fsiOPFLD.BilgDrName = doctor.UserName
  3654. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3655. case 0:
  3656. break
  3657. case 1:
  3658. fsiOPFLD.MedChrgitmType = "14"
  3659. break
  3660. case 2:
  3661. fsiOPFLD.MedChrgitmType = "05"
  3662. break
  3663. case 3:
  3664. fsiOPFLD.MedChrgitmType = "03"
  3665. break
  3666. case 4:
  3667. fsiOPFLD.MedChrgitmType = "03"
  3668. break
  3669. case 5:
  3670. fsiOPFLD.MedChrgitmType = "08"
  3671. break
  3672. case 6:
  3673. fsiOPFLD.MedChrgitmType = "14"
  3674. break
  3675. case 7:
  3676. fsiOPFLD.MedChrgitmType = "14"
  3677. break
  3678. case 8:
  3679. fsiOPFLD.MedChrgitmType = "03"
  3680. break
  3681. case 9:
  3682. fsiOPFLD.MedChrgitmType = "14"
  3683. break
  3684. case 10:
  3685. fsiOPFLD.MedChrgitmType = "14"
  3686. break
  3687. case 11:
  3688. fsiOPFLD.MedChrgitmType = "06"
  3689. break
  3690. case 12:
  3691. fsiOPFLD.MedChrgitmType = "12"
  3692. break
  3693. case 13:
  3694. fsiOPFLD.MedChrgitmType = "01"
  3695. break
  3696. case 14:
  3697. fsiOPFLD.MedChrgitmType = "04"
  3698. break
  3699. case 15:
  3700. fsiOPFLD.MedChrgitmType = "14"
  3701. break
  3702. }
  3703. memo["hosp_appr_flag"] = "1"
  3704. memo["invoice_no"] = order.MdtrtId
  3705. memo["memo"] = "自费"
  3706. bytesData, _ := json.Marshal(memo)
  3707. fsiOPFLD.Memo = string(bytesData)
  3708. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3709. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3710. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3711. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3712. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3713. fsiOPFLD.BilgDeptName = department.Name
  3714. fsiOPFLD.BilgDeptCodg = department.Number
  3715. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3716. fsiOPFLD.BilgDrName = doctor.UserName
  3717. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3718. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3719. fsiOPFLD.MedChrgitmType = "08"
  3720. memo["hosp_appr_flag"] = "1"
  3721. memo["invoice_no"] = order.MdtrtId
  3722. memo["memo"] = "自费"
  3723. bytesData, _ := json.Marshal(memo)
  3724. fsiOPFLD.Memo = string(bytesData)
  3725. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3726. }
  3727. }
  3728. }
  3729. fmt.Println(fsiOPFLDs)
  3730. struct4201A.Fopfd = fsiOPFLDs
  3731. fmt.Println(struct4201A.Fopfd)
  3732. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3733. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3734. var res2 ResultSix
  3735. var respJSON2 map[string]interface{}
  3736. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3739. return
  3740. }
  3741. userJSONBytes2, _ := json.Marshal(respJSON2)
  3742. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3743. utils.ErrorLog("解析失败:%v", err)
  3744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3745. return
  3746. }
  3747. if res2.Infcode != 0 {
  3748. c.ServeSuccessJSON(map[string]interface{}{
  3749. "failed_code": -10,
  3750. "msg": res2.ErrMsg,
  3751. })
  3752. return
  3753. } else {
  3754. order.IsUploadOrderInfo = 1
  3755. service.UpdateOrder(order)
  3756. c.ServeSuccessJSON(map[string]interface{}{
  3757. "msg": "上传成功",
  3758. })
  3759. }
  3760. }
  3761. func (c *HisApiController) Get4202() {
  3762. order_id, _ := c.GetInt64("order_id")
  3763. admin_user_id, _ := c.GetInt64("admin_user_id")
  3764. order, _ := service.GetHisOrderByIDTwo(order_id)
  3765. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3766. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3767. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3768. if order.ID == 0 {
  3769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3770. return
  3771. }
  3772. var struct4202 models.Struct4202
  3773. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3774. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3775. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3776. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3777. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3778. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3779. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3780. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3781. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3782. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3783. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3784. var config []*models.HisXtDiagnoseConfig
  3785. for _, item := range diagnosis_ids {
  3786. id, _ := strconv.ParseInt(item, 10, 64)
  3787. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3788. config = append(config, &diagnosisConfig)
  3789. }
  3790. var tempDiaginfos []models.OwnPayPatnDiagListD
  3791. for index, item := range config {
  3792. if index == 0 {
  3793. var tempDiaginfo models.OwnPayPatnDiagListD
  3794. tempDiaginfo.InoutDiagType = "1"
  3795. tempDiaginfo.DiagCode = item.CountryCode
  3796. tempDiaginfo.DiagName = item.CountryContentName
  3797. tempDiaginfo.DiagType = "1"
  3798. tempDiaginfo.DiagSrtNo = "1"
  3799. tempDiaginfo.MaindiagFlag = "1"
  3800. tempDiaginfo.ValiFlag = "1"
  3801. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3802. } else {
  3803. var tempDiaginfo models.OwnPayPatnDiagListD
  3804. tempDiaginfo.DiagCode = item.CountryCode
  3805. tempDiaginfo.DiagName = item.CountryContentName
  3806. tempDiaginfo.DiagType = "2"
  3807. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3808. tempDiaginfo.MaindiagFlag = "0"
  3809. tempDiaginfo.ValiFlag = "1"
  3810. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3811. }
  3812. }
  3813. struct4202.ODiagListD = tempDiaginfos
  3814. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3815. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3816. var res2 ResultSix
  3817. var respJSON2 map[string]interface{}
  3818. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3821. return
  3822. }
  3823. userJSONBytes2, _ := json.Marshal(respJSON2)
  3824. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3825. utils.ErrorLog("解析失败:%v", err)
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. if res2.Infcode != 0 {
  3830. c.ServeSuccessJSON(map[string]interface{}{
  3831. "failed_code": -10,
  3832. "msg": res2.ErrMsg,
  3833. })
  3834. return
  3835. } else {
  3836. order.IsUploadDiagnose = 1
  3837. service.UpdateOrder(order)
  3838. c.ServeSuccessJSON(map[string]interface{}{
  3839. "msg": "上传成功",
  3840. })
  3841. }
  3842. }
  3843. func (c *HisApiController) Get4203() {
  3844. admin_user_id, _ := c.GetInt64("admin_user_id")
  3845. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3847. order_id, _ := c.GetInt64("order_id")
  3848. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3849. number := ""
  3850. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3851. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3852. if his.ID == 0 {
  3853. number = hospital.Number
  3854. } else {
  3855. number = his.Number
  3856. }
  3857. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3858. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3859. var res2 ResultSix
  3860. var respJSON2 map[string]interface{}
  3861. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3862. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. return
  3865. }
  3866. userJSONBytes2, _ := json.Marshal(respJSON2)
  3867. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3868. utils.ErrorLog("解析失败:%v", err)
  3869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3870. return
  3871. }
  3872. if res2.Infcode != 0 {
  3873. c.ServeSuccessJSON(map[string]interface{}{
  3874. "failed_code": -10,
  3875. "msg": res2.ErrMsg,
  3876. })
  3877. return
  3878. } else {
  3879. order.IsUploadSuccess = 1
  3880. service.UpdateOrderTwo(order)
  3881. c.ServeSuccessJSON(map[string]interface{}{
  3882. "msg": "上传成功",
  3883. })
  3884. }
  3885. }
  3886. func (c *HisApiController) Get4205() {
  3887. order_id, _ := c.GetInt64("order_id")
  3888. admin_user_id, _ := c.GetInt64("admin_user_id")
  3889. fapiao_code := c.GetString("fapiao_code")
  3890. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3891. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3892. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3893. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3894. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3895. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3896. //order_info = append(order_info, order_info_two...)
  3897. department, _ := service.GetDepartMentDetail(his.Departments)
  3898. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3899. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3900. if order.ID == 0 {
  3901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3902. return
  3903. }
  3904. var struct4201A models.Struct4201A
  3905. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3906. for _, items := range order_info {
  3907. memo := make(map[string]interface{})
  3908. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3909. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3910. fsiOPFLD.MedType = pre.MedType
  3911. fsiOPFLD.FixmedinsCode = miConfig.Code
  3912. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3913. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3914. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3915. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3916. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3917. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3918. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3919. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3920. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3921. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3922. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3923. fsiOPFLD.BilgDeptName = department.Name
  3924. fsiOPFLD.BilgDeptCodg = department.Number
  3925. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3926. fsiOPFLD.BilgDrName = doctor.UserName
  3927. fsiOPFLD.MedChrgitmType = "09"
  3928. memo["hosp_appr_flag"] = "1"
  3929. memo["invoice_no"] = fapiao_code
  3930. memo["memo"] = "自费"
  3931. bytesData, _ := json.Marshal(memo)
  3932. fsiOPFLD.Memo = string(bytesData)
  3933. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3934. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3935. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3936. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3937. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3938. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3939. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3940. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3941. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3942. fsiOPFLD.BilgDeptName = department.Name
  3943. fsiOPFLD.BilgDeptCodg = department.Number
  3944. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3945. fsiOPFLD.BilgDrName = doctor.UserName
  3946. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3947. case 0:
  3948. break
  3949. case 1:
  3950. fsiOPFLD.MedChrgitmType = "14"
  3951. break
  3952. case 2:
  3953. fsiOPFLD.MedChrgitmType = "05"
  3954. break
  3955. case 3:
  3956. fsiOPFLD.MedChrgitmType = "03"
  3957. break
  3958. case 4:
  3959. fsiOPFLD.MedChrgitmType = "03"
  3960. break
  3961. case 5:
  3962. fsiOPFLD.MedChrgitmType = "08"
  3963. break
  3964. case 6:
  3965. fsiOPFLD.MedChrgitmType = "14"
  3966. break
  3967. case 7:
  3968. fsiOPFLD.MedChrgitmType = "14"
  3969. break
  3970. case 8:
  3971. fsiOPFLD.MedChrgitmType = "03"
  3972. break
  3973. case 9:
  3974. fsiOPFLD.MedChrgitmType = "14"
  3975. break
  3976. case 10:
  3977. fsiOPFLD.MedChrgitmType = "14"
  3978. break
  3979. case 11:
  3980. fsiOPFLD.MedChrgitmType = "06"
  3981. break
  3982. case 12:
  3983. fsiOPFLD.MedChrgitmType = "12"
  3984. break
  3985. case 13:
  3986. fsiOPFLD.MedChrgitmType = "01"
  3987. break
  3988. case 14:
  3989. fsiOPFLD.MedChrgitmType = "04"
  3990. break
  3991. case 15:
  3992. fsiOPFLD.MedChrgitmType = "14"
  3993. break
  3994. }
  3995. memo["hosp_appr_flag"] = "1"
  3996. memo["invoice_no"] = fapiao_code
  3997. memo["memo"] = "自费"
  3998. bytesData, _ := json.Marshal(memo)
  3999. fsiOPFLD.Memo = string(bytesData)
  4000. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4001. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4002. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4003. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4004. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4005. fsiOPFLD.BilgDeptName = department.Name
  4006. fsiOPFLD.BilgDeptCodg = department.Number
  4007. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4008. fsiOPFLD.BilgDrName = doctor.UserName
  4009. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4010. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4011. fsiOPFLD.MedChrgitmType = "08"
  4012. memo["hosp_appr_flag"] = "1"
  4013. memo["invoice_no"] = fapiao_code
  4014. memo["memo"] = "自费"
  4015. bytesData, _ := json.Marshal(memo)
  4016. fsiOPFLD.Memo = string(bytesData)
  4017. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4018. }
  4019. }
  4020. }
  4021. for _, items := range order_info_two {
  4022. memo := make(map[string]interface{})
  4023. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4024. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4025. fsiOPFLD.MedType = pre.MedType
  4026. fsiOPFLD.BkkpSn = items.FeedetlSn
  4027. fsiOPFLD.FixmedinsCode = miConfig.Code
  4028. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4029. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4030. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4031. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4032. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4033. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4034. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4035. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4036. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4037. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4038. fsiOPFLD.BilgDeptName = department.Name
  4039. fsiOPFLD.BilgDeptCodg = department.Number
  4040. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4041. fsiOPFLD.BilgDrName = doctor.UserName
  4042. fsiOPFLD.MedChrgitmType = "09"
  4043. memo["hosp_appr_flag"] = "1"
  4044. memo["invoice_no"] = fapiao_code
  4045. memo["memo"] = "自费"
  4046. bytesData, _ := json.Marshal(memo)
  4047. fsiOPFLD.Memo = string(bytesData)
  4048. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4049. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4050. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4051. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4052. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4053. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4054. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4055. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4056. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4057. fsiOPFLD.BilgDeptName = department.Name
  4058. fsiOPFLD.BilgDeptCodg = department.Number
  4059. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4060. fsiOPFLD.BilgDrName = doctor.UserName
  4061. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4062. case 0:
  4063. break
  4064. case 1:
  4065. fsiOPFLD.MedChrgitmType = "14"
  4066. break
  4067. case 2:
  4068. fsiOPFLD.MedChrgitmType = "05"
  4069. break
  4070. case 3:
  4071. fsiOPFLD.MedChrgitmType = "03"
  4072. break
  4073. case 4:
  4074. fsiOPFLD.MedChrgitmType = "03"
  4075. break
  4076. case 5:
  4077. fsiOPFLD.MedChrgitmType = "08"
  4078. break
  4079. case 6:
  4080. fsiOPFLD.MedChrgitmType = "14"
  4081. break
  4082. case 7:
  4083. fsiOPFLD.MedChrgitmType = "14"
  4084. break
  4085. case 8:
  4086. fsiOPFLD.MedChrgitmType = "03"
  4087. break
  4088. case 9:
  4089. fsiOPFLD.MedChrgitmType = "14"
  4090. break
  4091. case 10:
  4092. fsiOPFLD.MedChrgitmType = "14"
  4093. break
  4094. case 11:
  4095. fsiOPFLD.MedChrgitmType = "06"
  4096. break
  4097. case 12:
  4098. fsiOPFLD.MedChrgitmType = "12"
  4099. break
  4100. case 13:
  4101. fsiOPFLD.MedChrgitmType = "01"
  4102. break
  4103. case 14:
  4104. fsiOPFLD.MedChrgitmType = "04"
  4105. break
  4106. case 15:
  4107. fsiOPFLD.MedChrgitmType = "14"
  4108. break
  4109. }
  4110. memo["hosp_appr_flag"] = "1"
  4111. memo["invoice_no"] = fapiao_code
  4112. memo["memo"] = "自费"
  4113. bytesData, _ := json.Marshal(memo)
  4114. fsiOPFLD.Memo = string(bytesData)
  4115. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4116. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4117. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4118. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4119. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4120. fsiOPFLD.BilgDeptName = department.Name
  4121. fsiOPFLD.BilgDeptCodg = department.Number
  4122. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4123. fsiOPFLD.BilgDrName = doctor.UserName
  4124. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4125. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4126. fsiOPFLD.MedChrgitmType = "08"
  4127. memo["hosp_appr_flag"] = "1"
  4128. memo["invoice_no"] = fapiao_code
  4129. memo["memo"] = "自费"
  4130. bytesData, _ := json.Marshal(memo)
  4131. fsiOPFLD.Memo = string(bytesData)
  4132. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4133. }
  4134. }
  4135. }
  4136. fmt.Println(fsiOPFLDs)
  4137. struct4201A.Fopfd = fsiOPFLDs
  4138. fmt.Println(struct4201A.Fopfd)
  4139. var struct4202 models.Struct4202
  4140. timeLayout := "2006-01-02 15:04:05"
  4141. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4142. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4143. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4144. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4145. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4146. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4147. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4148. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4149. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4150. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4151. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4152. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4153. var config []*models.HisXtDiagnoseConfig
  4154. for _, item := range diagnosis_ids {
  4155. id, _ := strconv.ParseInt(item, 10, 64)
  4156. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4157. config = append(config, &diagnosisConfig)
  4158. }
  4159. var tempDiaginfos []models.OwnPayPatnDiagListD
  4160. for index, item := range config {
  4161. if index == 0 {
  4162. var tempDiaginfo models.OwnPayPatnDiagListD
  4163. tempDiaginfo.InoutDiagType = "1"
  4164. tempDiaginfo.DiagCode = item.CountryCode
  4165. tempDiaginfo.DiagName = item.CountryContentName
  4166. tempDiaginfo.DiagType = "1"
  4167. tempDiaginfo.DiagSrtNo = "1"
  4168. tempDiaginfo.MaindiagFlag = "1"
  4169. tempDiaginfo.ValiFlag = "1"
  4170. tempDiaginfo.DiagDrName = doctor.UserName
  4171. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4172. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4173. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4174. } else {
  4175. var tempDiaginfo models.OwnPayPatnDiagListD
  4176. tempDiaginfo.DiagCode = item.CountryCode
  4177. tempDiaginfo.DiagName = item.CountryContentName
  4178. tempDiaginfo.DiagType = "2"
  4179. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4180. tempDiaginfo.MaindiagFlag = "0"
  4181. tempDiaginfo.ValiFlag = "1"
  4182. tempDiaginfo.DiagDrName = doctor.UserName
  4183. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4184. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4185. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4186. }
  4187. }
  4188. struct4202.ODiagListD = tempDiaginfos
  4189. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4190. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4191. var res2 ResultSix
  4192. var respJSON2 map[string]interface{}
  4193. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4194. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4196. return
  4197. }
  4198. userJSONBytes2, _ := json.Marshal(respJSON2)
  4199. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4200. utils.ErrorLog("解析失败:%v", err)
  4201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. return
  4203. }
  4204. if res2.Infcode != 0 {
  4205. c.ServeSuccessJSON(map[string]interface{}{
  4206. "failed_code": -10,
  4207. "msg": res2.ErrMsg,
  4208. })
  4209. return
  4210. } else {
  4211. order.IsUploadDiagnose = 1
  4212. order.IsUploadOrderInfo = 1
  4213. service.UpdateOrderTwo(order)
  4214. c.ServeSuccessJSON(map[string]interface{}{
  4215. "msg": "上传成功",
  4216. })
  4217. }
  4218. }
  4219. func (c *HisApiController) Get4207() {
  4220. admin_user_id, _ := c.GetInt64("admin_user_id")
  4221. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4222. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4223. order_id, _ := c.GetInt64("order_id")
  4224. order, _ := service.GetHisOrderByIDTwo(order_id)
  4225. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4226. var struct4207 models.Struct4207
  4227. struct4207.PageNum = "1"
  4228. struct4207.PageSize = "1000"
  4229. struct4207.FixmedinsCode = miConfig.Code
  4230. struct4207.FixmedinsMdtrtID = order.Number
  4231. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4232. saveLog(result, requestLog, "4207", "查询")
  4233. var res2 ResultSix
  4234. var respJSON2 map[string]interface{}
  4235. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4238. return
  4239. }
  4240. userJSONBytes2, _ := json.Marshal(respJSON2)
  4241. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4242. utils.ErrorLog("解析失败:%v", err)
  4243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4244. return
  4245. }
  4246. if res2.Infcode != 0 {
  4247. c.ServeSuccessJSON(map[string]interface{}{
  4248. "failed_code": -10,
  4249. "msg": res2.ErrMsg,
  4250. })
  4251. return
  4252. } else {
  4253. c.ServeSuccessJSON(map[string]interface{}{
  4254. "msg": "查询成功",
  4255. })
  4256. }
  4257. }
  4258. func (c *HisApiController) Get4208() {
  4259. admin_user_id, _ := c.GetInt64("admin_user_id")
  4260. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4261. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4262. order_id, _ := c.GetInt64("order_id")
  4263. order, _ := service.GetHisOrderByIDTwo(order_id)
  4264. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4265. var struct4208 models.Struct4208
  4266. struct4208.PageNum = "1"
  4267. struct4208.PageSize = "1000"
  4268. struct4208.PsnCertType = "01"
  4269. struct4208.Certno = his.Certno
  4270. struct4208.MedType = order.MedType
  4271. struct4208.PsnName = his.Name
  4272. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4273. saveLog(result, requestLog, "4208", "查询")
  4274. var res2 ResultSix
  4275. var respJSON2 map[string]interface{}
  4276. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4279. return
  4280. }
  4281. userJSONBytes2, _ := json.Marshal(respJSON2)
  4282. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4283. utils.ErrorLog("解析失败:%v", err)
  4284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4285. return
  4286. }
  4287. if res2.Infcode != 0 {
  4288. c.ServeSuccessJSON(map[string]interface{}{
  4289. "failed_code": -10,
  4290. "msg": res2.ErrMsg,
  4291. })
  4292. return
  4293. } else {
  4294. c.ServeSuccessJSON(map[string]interface{}{
  4295. "msg": "查询成功",
  4296. })
  4297. }
  4298. }
  4299. func (c *HisApiController) Get4209() {
  4300. admin_user_id, _ := c.GetInt64("admin_user_id")
  4301. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4302. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4303. order_id, _ := c.GetInt64("order_id")
  4304. order, _ := service.GetHisOrderByIDTwo(order_id)
  4305. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4306. var struct4209 models.Struct4209
  4307. struct4209.FixmedinsMdtrtID = order.Number
  4308. struct4209.FixmedinsCode = miConfig.Code
  4309. struct4209.PageSize = "1000"
  4310. struct4209.PageNum = "1"
  4311. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4312. saveLog(result, requestLog, "4209", "查询")
  4313. var res2 ResultSix
  4314. var respJSON2 map[string]interface{}
  4315. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4318. return
  4319. }
  4320. userJSONBytes2, _ := json.Marshal(respJSON2)
  4321. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4322. utils.ErrorLog("解析失败:%v", err)
  4323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4324. return
  4325. }
  4326. if res2.Infcode != 0 {
  4327. c.ServeSuccessJSON(map[string]interface{}{
  4328. "failed_code": -10,
  4329. "msg": res2.ErrMsg,
  4330. })
  4331. return
  4332. } else {
  4333. c.ServeSuccessJSON(map[string]interface{}{
  4334. "msg": "查询成功",
  4335. })
  4336. }
  4337. }
  4338. type Result3101 struct {
  4339. Infcode string `json:"infcode"`
  4340. InfRefmsgid string `json:"inf_refmsgid"`
  4341. RefmsgTime string `json:"refmsg_time"`
  4342. RespondTime string `json:"respond_time"`
  4343. Enctype string `json:"enctype"`
  4344. Signtype string `json:"signtype"`
  4345. ErrMsg string `json:"err_msg"`
  4346. Output struct {
  4347. Result []struct {
  4348. JudgeResultDetailDtos []struct {
  4349. VolaItemType string `json:"vola_item_type"`
  4350. MdtrtID string `json:"mdtrt_id"`
  4351. JrdID string `json:"jrd_id"`
  4352. PatnID string `json:"patn_id"`
  4353. RxID string `json:"rx_id"`
  4354. VolaAmt interface{} `json:"vola_amt"`
  4355. } `json:"judge_result_detail_dtos"`
  4356. RuleID string `json:"rule_id"`
  4357. VolaEvid string `json:"vola_evid"`
  4358. MdtrtID string `json:"mdtrt_id"`
  4359. RuleName string `json:"rule_name"`
  4360. VolaAmtStas string `json:"vola_amt_stas"`
  4361. JrID string `json:"jr_id"`
  4362. PatnID string `json:"patn_id"`
  4363. SevDeg string `json:"sev_deg"`
  4364. VolaAmt float64 `json:"vola_amt"`
  4365. VolaBhvrType string `json:"vola_bhvr_type"`
  4366. VolaCont string `json:"vola_cont"`
  4367. } `json:"result"`
  4368. } `json:"output"`
  4369. }
  4370. type Resultgd3101 struct {
  4371. Infcode int64 `json:"infcode"`
  4372. InfRefmsgid string `json:"inf_refmsgid"`
  4373. RefmsgTime string `json:"refmsg_time"`
  4374. RespondTime string `json:"respond_time"`
  4375. Enctype string `json:"enctype"`
  4376. Signtype string `json:"signtype"`
  4377. ErrMsg string `json:"err_msg"`
  4378. Output struct {
  4379. Result []struct {
  4380. JudgeResultDetailDtos []struct {
  4381. VolaItemType string `json:"vola_item_type"`
  4382. MdtrtID string `json:"mdtrt_id"`
  4383. JrdID string `json:"jrd_id"`
  4384. PatnID string `json:"patn_id"`
  4385. RxID string `json:"rx_id"`
  4386. VolaAmt interface{} `json:"vola_amt"`
  4387. } `json:"judge_result_detail_dtos"`
  4388. RuleID string `json:"rule_id"`
  4389. VolaEvid string `json:"vola_evid"`
  4390. MdtrtID string `json:"mdtrt_id"`
  4391. RuleName string `json:"rule_name"`
  4392. VolaAmtStas string `json:"vola_amt_stas"`
  4393. JrID string `json:"jr_id"`
  4394. PatnID string `json:"patn_id"`
  4395. SevDeg string `json:"sev_deg"`
  4396. VolaAmt float64 `json:"vola_amt"`
  4397. VolaBhvrType string `json:"vola_bhvr_type"`
  4398. VolaCont string `json:"vola_cont"`
  4399. } `json:"result"`
  4400. } `json:"output"`
  4401. }
  4402. func (c *HisApiController) ReadEleToken() {
  4403. admin_user_id, _ := c.GetInt64("admin_user_id")
  4404. his_patient_id, _ := c.GetInt64("his_patient_id")
  4405. adminUser := c.GetAdminUserInfo()
  4406. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4407. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4408. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4409. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4410. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4411. if len(tokens) > 0 {
  4412. c.ServeSuccessJSON(map[string]interface{}{
  4413. "msg": "读取成功",
  4414. })
  4415. } else {
  4416. c.ServeSuccessJSON(map[string]interface{}{
  4417. "failed_code": -10,
  4418. "msg": "读取失败",
  4419. })
  4420. }
  4421. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4422. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4423. if len(tokens) > 0 {
  4424. c.ServeSuccessJSON(map[string]interface{}{
  4425. "msg": "读取成功",
  4426. })
  4427. } else {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "failed_code": -10,
  4430. "msg": "读取失败",
  4431. })
  4432. }
  4433. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4434. var api string
  4435. 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 +
  4436. "&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"
  4437. resp, requestErr := http.Get(api)
  4438. if requestErr != nil {
  4439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4440. }
  4441. body, ioErr := ioutil.ReadAll(resp.Body)
  4442. if ioErr != nil {
  4443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4445. }
  4446. var respJSON map[string]interface{}
  4447. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4450. return
  4451. }
  4452. var status string
  4453. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4454. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4455. var token string
  4456. var res ResultTwo //1101结果
  4457. var res10265 ResultTwo10265 //1101结果
  4458. if status == "0" { //读卡成功
  4459. var card_info string //卡信息
  4460. var busi_card_info string
  4461. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4462. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4463. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4464. fmt.Println(card_info)
  4465. fmt.Println(busi_card_info)
  4466. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4467. result, _ := json.Marshal(respJSON)
  4468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4469. utils.ErrorLog("解析失败:%v", err)
  4470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4471. return
  4472. }
  4473. res.ErrMsg = res10265.ErrMsg
  4474. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4475. res.Infcode = infocode
  4476. res.Output = res10265.Output
  4477. res.InfRefmsgid = res10265.InfRefmsgid
  4478. if res.Infcode == 0 {
  4479. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4480. if err == gorm.ErrRecordNotFound {
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4482. return
  4483. } else if err != nil {
  4484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4485. return
  4486. } else {
  4487. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4488. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4489. infoStr := string(Iinfos)
  4490. idetinfoStr := string(Idetinfos)
  4491. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4492. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4493. psn := &models.HisPsn{
  4494. PsnNo: res.Output.Baseinfo.PsnNo,
  4495. PatientId: patient.ID,
  4496. Certno: res.Output.Baseinfo.Certno,
  4497. Gend: res.Output.Baseinfo.Gend,
  4498. Naty: res.Output.Baseinfo.Naty,
  4499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4500. PsnName: res.Output.Baseinfo.PsnName,
  4501. Age: float64(age),
  4502. Brdy: b,
  4503. Idetinfo: idetinfoStr,
  4504. Insuinfo: infoStr,
  4505. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4506. CardInfo: card_info,
  4507. VerifyNumber: token,
  4508. IdCardType: 4,
  4509. }
  4510. var rf []*ResultFive
  4511. json.Unmarshal([]byte(infoStr), &rf)
  4512. var insutypes []*ResultFive
  4513. var insutype string
  4514. var is390 int = 0
  4515. var is310 int = 0
  4516. for _, item := range rf {
  4517. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4518. insutypes = append(insutypes, item)
  4519. }
  4520. }
  4521. if len(insutypes) == 1 {
  4522. insutype = insutypes[0].Insutype
  4523. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4524. } else {
  4525. for _, i := range insutypes {
  4526. if i.Insutype == "390" {
  4527. is390 = 1
  4528. }
  4529. if i.Insutype == "310" {
  4530. is310 = 1
  4531. }
  4532. }
  4533. }
  4534. if is390 == 1 {
  4535. insutype = "390"
  4536. }
  4537. if is310 == 1 {
  4538. insutype = "310"
  4539. }
  4540. if len(insutypes) == 0 {
  4541. insutype = "310"
  4542. }
  4543. service.CreateHisPsn(psn)
  4544. c.ServeSuccessJSON(map[string]interface{}{
  4545. "patient": patient,
  4546. "number": token,
  4547. "insutype": insutype,
  4548. })
  4549. }
  4550. } else {
  4551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4552. return
  4553. }
  4554. } else { //读卡失败
  4555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4556. return
  4557. }
  4558. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4559. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4560. if len(errMsg) == 0 {
  4561. type ELeData struct {
  4562. Data struct {
  4563. IdNo string `json:"idNo"`
  4564. IdType string `json:"idType"`
  4565. UserName string `json:"userName"`
  4566. EcToken string `json:"ecToken"`
  4567. InsuOrg string `json:"insuOrg"`
  4568. Gender string `json:"gender"`
  4569. Birthday string `json:"birthday"`
  4570. Nationality string `json:"nationality"`
  4571. Email string `json:"email"`
  4572. Extra string `json:"extra"`
  4573. } `json:"data"`
  4574. Code int `json:"code"`
  4575. Message string `json:"message"`
  4576. }
  4577. var ele ELeData
  4578. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4579. if err != nil {
  4580. utils.ErrorLog("解析失败:%v", err)
  4581. }
  4582. token := ele.Data.EcToken
  4583. if len(token) > 0 {
  4584. psn := &models.HisPsn{
  4585. PsnNo: his.PsnNo,
  4586. Age: 0,
  4587. PatientId: his.PatientId,
  4588. Certno: his.Certno,
  4589. Brdy: his.Brdy,
  4590. Gend: his.Gend,
  4591. Naty: his.Naty,
  4592. PsnCertType: his.PsnCertType,
  4593. PsnName: his.PsnName,
  4594. Idetinfo: his.Idetinfo,
  4595. Insuinfo: his.Iinfo,
  4596. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4597. CardInfo: outPutInfo,
  4598. VerifyNumber: token,
  4599. }
  4600. service.CreateHisPsn(psn)
  4601. }
  4602. if len(token) > 0 {
  4603. c.ServeSuccessJSON(map[string]interface{}{
  4604. "msg": "读取成功",
  4605. })
  4606. } else {
  4607. c.ServeSuccessJSON(map[string]interface{}{
  4608. "failed_code": -10,
  4609. "msg": "读取失败",
  4610. })
  4611. }
  4612. }
  4613. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4614. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4615. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4616. type ELeData struct {
  4617. Data struct {
  4618. IdNo string `json:"idNo"`
  4619. IdType string `json:"idType"`
  4620. UserName string `json:"userName"`
  4621. EcToken string `json:"ecToken"`
  4622. InsuOrg string `json:"insuOrg"`
  4623. Gender string `json:"gender"`
  4624. Birthday string `json:"birthday"`
  4625. Nationality string `json:"nationality"`
  4626. Email string `json:"email"`
  4627. Extra string `json:"extra"`
  4628. } `json:"data"`
  4629. Code int `json:"code"`
  4630. Message string `json:"message"`
  4631. }
  4632. var ele ELeData
  4633. err := json.Unmarshal([]byte(result), &ele)
  4634. if err != nil {
  4635. utils.ErrorLog("解析失败:%v", err)
  4636. }
  4637. token := ele.Data.EcToken
  4638. token = Remove0000(token)
  4639. fmt.Println(ele.Data.UserName)
  4640. 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)
  4641. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4642. var res ResultTwo
  4643. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4644. utils.ErrorLog("解析失败:%v", err)
  4645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4646. return
  4647. }
  4648. if res.Infcode == 0 {
  4649. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4650. if err == gorm.ErrRecordNotFound {
  4651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4652. return
  4653. } else if err != nil {
  4654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4655. return
  4656. } else {
  4657. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4658. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4659. infoStr := string(Iinfos)
  4660. idetinfoStr := string(Idetinfos)
  4661. psn := &models.HisPsn{
  4662. PsnNo: res.Output.Baseinfo.PsnNo,
  4663. PatientId: patient.ID,
  4664. Certno: res.Output.Baseinfo.Certno,
  4665. Gend: res.Output.Baseinfo.Gend,
  4666. Naty: res.Output.Baseinfo.Naty,
  4667. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4668. PsnName: res.Output.Baseinfo.PsnName,
  4669. Idetinfo: idetinfoStr,
  4670. Insuinfo: infoStr,
  4671. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4672. CardInfo: "",
  4673. VerifyNumber: token,
  4674. }
  4675. service.CreateHisPsn(psn)
  4676. c.ServeSuccessJSON(map[string]interface{}{
  4677. "patient": patient,
  4678. "number": token,
  4679. })
  4680. }
  4681. } else {
  4682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4683. return
  4684. }
  4685. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4686. idNo := c.GetString("idNo")
  4687. userName := c.GetString("userName")
  4688. ecToken := c.GetString("ecToken")
  4689. insuOrg := c.GetString("insuOrg")
  4690. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4691. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4692. var res ResultTwo
  4693. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4694. utils.ErrorLog("解析失败:%v", err)
  4695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4696. return
  4697. }
  4698. if res.Infcode == 0 {
  4699. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4700. if err == gorm.ErrRecordNotFound {
  4701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4702. return
  4703. } else if err != nil {
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4705. return
  4706. } else {
  4707. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4708. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4709. infoStr := string(Iinfos)
  4710. idetinfoStr := string(Idetinfos)
  4711. psn := &models.HisPsn{
  4712. PsnNo: res.Output.Baseinfo.PsnNo,
  4713. PatientId: patient.ID,
  4714. Certno: res.Output.Baseinfo.Certno,
  4715. Gend: res.Output.Baseinfo.Gend,
  4716. Naty: res.Output.Baseinfo.Naty,
  4717. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4718. PsnName: res.Output.Baseinfo.PsnName,
  4719. Idetinfo: idetinfoStr,
  4720. Insuinfo: infoStr,
  4721. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4722. CardInfo: "",
  4723. VerifyNumber: ecToken,
  4724. InsuplcAdmdvs: insuOrg,
  4725. }
  4726. service.CreateHisPsn(psn)
  4727. c.ServeSuccessJSON(map[string]interface{}{
  4728. "patient": patient,
  4729. "number": ecToken,
  4730. })
  4731. }
  4732. } else {
  4733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4734. return
  4735. }
  4736. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4737. res := c.GetoleInfo()
  4738. if res.Infcode == 0 {
  4739. var result string
  4740. if res.Output.MdtrtCertType == "01" {
  4741. 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)
  4742. } else if res.Output.MdtrtCertType == "02" {
  4743. 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)
  4744. } else if res.Output.MdtrtCertType == "03" {
  4745. 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)
  4746. }
  4747. var dat map[string]interface{}
  4748. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4749. fmt.Println(dat)
  4750. } else {
  4751. fmt.Println(err)
  4752. }
  4753. userJSONBytes, _ := json.Marshal(dat)
  4754. var res2 ResultTwo
  4755. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4756. utils.ErrorLog("解析失败:%v", err)
  4757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4758. return
  4759. }
  4760. if res2.Infcode == 0 {
  4761. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4762. if err == gorm.ErrRecordNotFound {
  4763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4764. return
  4765. } else if err != nil {
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4767. return
  4768. } else {
  4769. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4770. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4771. infoStr := string(Iinfos)
  4772. idetinfoStr := string(Idetinfos)
  4773. var rf []*ResultFive
  4774. json.Unmarshal([]byte(infoStr), &rf)
  4775. var insutypes []*ResultFive
  4776. var insutype string
  4777. var is390 int = 0
  4778. var is310 int = 0
  4779. //var insuplc_admdvs string
  4780. for _, item := range rf {
  4781. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4782. insutypes = append(insutypes, item)
  4783. }
  4784. }
  4785. if len(insutypes) == 1 {
  4786. insutype = insutypes[0].Insutype
  4787. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4788. } else {
  4789. for _, i := range insutypes {
  4790. if i.Insutype == "390" {
  4791. is390 = 1
  4792. }
  4793. if i.Insutype == "310" {
  4794. is310 = 1
  4795. }
  4796. }
  4797. }
  4798. if is390 == 1 {
  4799. insutype = "390"
  4800. }
  4801. if is310 == 1 {
  4802. insutype = "310"
  4803. }
  4804. if len(insutypes) == 0 {
  4805. insutype = "310"
  4806. }
  4807. psn := &models.HisPsn{
  4808. PsnNo: res2.Output.Baseinfo.PsnNo,
  4809. PatientId: patient.ID,
  4810. Certno: res2.Output.Baseinfo.Certno,
  4811. Gend: res2.Output.Baseinfo.Gend,
  4812. Naty: res2.Output.Baseinfo.Naty,
  4813. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4814. PsnName: res2.Output.Baseinfo.PsnName,
  4815. Idetinfo: idetinfoStr,
  4816. Insuinfo: infoStr,
  4817. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4818. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4819. VerifyNumber: res.Output.EcToken,
  4820. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4821. }
  4822. service.CreateHisPsn(psn)
  4823. c.ServeSuccessJSON(map[string]interface{}{
  4824. "patient": patient,
  4825. "number": res.Output.CardNo,
  4826. "insutype": insutype,
  4827. })
  4828. }
  4829. } else {
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4831. return
  4832. }
  4833. } else {
  4834. c.ServeSuccessJSON(map[string]interface{}{
  4835. "failed_code": -10,
  4836. "msg": res.ErrMsg,
  4837. })
  4838. }
  4839. } else {
  4840. //if initFlag == 0 {
  4841. // c.TestGetBasBaseInit()
  4842. //}
  4843. //token := c.GetEleBaseInfo()
  4844. //token = Remove0000(token)
  4845. type ELeData struct {
  4846. Code string `json:"code"`
  4847. Data struct {
  4848. Aac002 string `json:"aac002"`
  4849. Aaz500 string `json:"aaz500"`
  4850. ActCardNo string `json:"actCardNo"`
  4851. Bab520 string `json:"bab520"`
  4852. Bkz543 string `json:"bkz543"`
  4853. BusinessType string `json:"businessType"`
  4854. CertfCodg string `json:"certfCodg"`
  4855. EcIndexNo string `json:"ecIndexNo"`
  4856. EcToken string `json:"ecToken"`
  4857. ID0000 string `json:"id0000"`
  4858. IDNo string `json:"idNo"`
  4859. IDType string `json:"idType"`
  4860. Idcode string `json:"idcode"`
  4861. IdentityToken string `json:"identity_token"`
  4862. InsuOrg string `json:"insuOrg"`
  4863. OfficeID string `json:"officeId"`
  4864. OfficeName string `json:"officeName"`
  4865. OperatorID string `json:"operatorId"`
  4866. OperatorName string `json:"operatorName"`
  4867. OrgID string `json:"orgId"`
  4868. UserName string `json:"userName"`
  4869. } `json:"data"`
  4870. Infno interface{} `json:"infno"`
  4871. Message string `json:"message"`
  4872. OrgID string `json:"orgId"`
  4873. TransType string `json:"transType"`
  4874. }
  4875. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4876. fmt.Println(result)
  4877. outPutInfo := Remove0000(result)
  4878. fmt.Println(outPutInfo)
  4879. var ele ELeData
  4880. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4881. if err != nil {
  4882. utils.ErrorLog("解析失败:%v", err)
  4883. }
  4884. token := ele.Data.EcToken
  4885. var result2 string
  4886. var requestLog2 string
  4887. if len(token) > 0 {
  4888. if strings.Contains(ele.Data.IDNo, "HKG") {
  4889. 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)
  4890. } else {
  4891. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4892. }
  4893. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4894. var res ResultTwo
  4895. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4896. utils.ErrorLog("解析失败:%v", err)
  4897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4898. return
  4899. }
  4900. if res.Infcode == 0 {
  4901. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4902. if err == gorm.ErrRecordNotFound {
  4903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4904. return
  4905. } else if err != nil {
  4906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4907. return
  4908. } else {
  4909. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4910. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4911. infoStr := string(Iinfos)
  4912. idetinfoStr := string(Idetinfos)
  4913. psn := &models.HisPsn{
  4914. PsnNo: res.Output.Baseinfo.PsnNo,
  4915. PatientId: patient.ID,
  4916. Certno: res.Output.Baseinfo.Certno,
  4917. Gend: res.Output.Baseinfo.Gend,
  4918. Naty: res.Output.Baseinfo.Naty,
  4919. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4920. PsnName: res.Output.Baseinfo.PsnName,
  4921. Idetinfo: idetinfoStr,
  4922. Insuinfo: infoStr,
  4923. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4924. CardInfo: "",
  4925. VerifyNumber: token,
  4926. }
  4927. service.CreateHisPsn(psn)
  4928. c.ServeSuccessJSON(map[string]interface{}{
  4929. "msg": "读取成功",
  4930. })
  4931. }
  4932. } else {
  4933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4934. return
  4935. }
  4936. } else {
  4937. c.ServeSuccessJSON(map[string]interface{}{
  4938. "failed_code": -10,
  4939. "msg": "读取失败",
  4940. })
  4941. }
  4942. }
  4943. }
  4944. func (c *HisApiController) ReadEleFace() {
  4945. admin_user_id, _ := c.GetInt64("admin_user_id")
  4946. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4947. adminUser := c.GetAdminUserInfo()
  4948. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4949. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4950. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4951. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4952. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4953. if len(tokens) > 0 {
  4954. c.ServeSuccessJSON(map[string]interface{}{
  4955. "msg": "读取成功",
  4956. })
  4957. } else {
  4958. c.ServeSuccessJSON(map[string]interface{}{
  4959. "failed_code": -10,
  4960. "msg": "读取失败",
  4961. })
  4962. }
  4963. }
  4964. }
  4965. func (c *HisApiController) Get9001() {
  4966. adminUser := c.GetAdminUserInfo()
  4967. admin_user_id, _ := c.GetInt64("admin_user_id")
  4968. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4969. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4970. if miConfig.MdtrtareaAdmvs == "350500" {
  4971. service.GetFjAuthorizationInfo(miConfig.Code)
  4972. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4973. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4974. var dat map[string]interface{}
  4975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4976. fmt.Println(dat)
  4977. } else {
  4978. fmt.Println(err)
  4979. }
  4980. userJSONBytes, _ := json.Marshal(dat)
  4981. var res models.Result9001
  4982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4983. utils.ErrorLog("解析失败:%v", err)
  4984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4985. return
  4986. }
  4987. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4988. fmt.Println(miConfig.SecretKey)
  4989. var res models.Result9001Two
  4990. 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 +
  4991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4992. resp, requestErr := http.Get(api)
  4993. if requestErr != nil {
  4994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4995. return
  4996. }
  4997. body, ioErr := ioutil.ReadAll(resp.Body)
  4998. if ioErr != nil {
  4999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5001. return
  5002. }
  5003. var respJSON map[string]interface{}
  5004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5007. return
  5008. }
  5009. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5010. if status == "0" {
  5011. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5012. c.ServeSuccessJSON(map[string]interface{}{
  5013. "failed_code": -10,
  5014. "msg": err_msg,
  5015. })
  5016. return
  5017. }
  5018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5019. result, _ := json.Marshal(respJSON)
  5020. fmt.Println("log")
  5021. fmt.Println(string(result))
  5022. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5023. utils.ErrorLog("解析失败:%v", err)
  5024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5025. return
  5026. }
  5027. if res.Infcode == 0 {
  5028. sign := models.HisSignIn{
  5029. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5030. SignNo: res.Output.Signinoutb.SignNo,
  5031. SignTime: "",
  5032. Ctime: time.Now().Unix(),
  5033. Mtime: time.Now().Unix(),
  5034. Status: 1,
  5035. InputLog: "",
  5036. OutputLog: "",
  5037. FixmedinsCode: miConfig.Code,
  5038. }
  5039. err := service.CreateSignIn(&sign)
  5040. if err == nil {
  5041. c.ServeSuccessJSON(map[string]interface{}{
  5042. "msg": "签到成功",
  5043. })
  5044. }
  5045. } else {
  5046. c.ServeSuccessJSON(map[string]interface{}{
  5047. "failed_code": -10,
  5048. "msg": res.ErrMsg,
  5049. })
  5050. return
  5051. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5052. //return
  5053. }
  5054. } else {
  5055. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5056. var dat map[string]interface{}
  5057. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5058. fmt.Println(dat)
  5059. } else {
  5060. fmt.Println(err)
  5061. }
  5062. userJSONBytes, _ := json.Marshal(dat)
  5063. var res models.Result9001
  5064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5065. utils.ErrorLog("解析失败:%v", err)
  5066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5067. return
  5068. }
  5069. if res.Infcode == 0 {
  5070. sign := models.HisSignIn{
  5071. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5072. SignNo: res.Output.Signinoutb.SignNo,
  5073. SignTime: res.Output.Signinoutb.SignTime,
  5074. Ctime: time.Now().Unix(),
  5075. Mtime: time.Now().Unix(),
  5076. Status: 1,
  5077. InputLog: "",
  5078. OutputLog: "",
  5079. FixmedinsCode: miConfig.Code,
  5080. }
  5081. err := service.CreateSignIn(&sign)
  5082. if err == nil {
  5083. c.ServeSuccessJSON(map[string]interface{}{
  5084. "msg": "签到成功",
  5085. })
  5086. }
  5087. }
  5088. }
  5089. }
  5090. func Check3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Result3101) {
  5091. var res Result3101
  5092. adminUser := c.GetAdminUserInfo()
  5093. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5094. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5095. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5096. //record_time := c.GetString("record_time")
  5097. //trig_scen := c.GetString("trig_scen")
  5098. timeLayout := "2006-01-02"
  5099. loc, _ := time.LoadLocation("Local")
  5100. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5101. if err != nil {
  5102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5103. return res
  5104. }
  5105. recordDateTime := theTime.Unix()
  5106. var patientPrescription models.HisPrescriptionInfo
  5107. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5108. //if patientPrescription.ID == 0 {
  5109. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5110. //}
  5111. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5112. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5113. //
  5114. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5115. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5116. var pp models.PublicParams
  5117. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5118. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5119. pp.FixmedinsName = miConfig.OrgName
  5120. pp.FixmedinsCode = miConfig.Code
  5121. pp.RequestUrl = miConfig.Url
  5122. pp.Cainfo = miConfig.Cainfo
  5123. pp.SecretKey = miConfig.SecretKey
  5124. pp.AccessKey = miConfig.AccessKey
  5125. pp.OpterName = roles.UserName
  5126. var config []*models.HisXtDiagnoseConfig
  5127. for _, item := range diagnosis_ids {
  5128. id, _ := strconv.ParseInt(item, 10, 64)
  5129. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5130. config = append(config, &diagnosisConfig)
  5131. }
  5132. var pd models.PatientDtos
  5133. pd.PatnID = his.PsnNo
  5134. pd.PatnName = his.Name
  5135. pd.Gend = his.Gend
  5136. pd.Brdy = his.Brdy
  5137. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5138. pd.CurrMdtrtID = his.Number
  5139. var fed models.FsiEncounterDtos
  5140. fed.MdtrtID = his.Number
  5141. fed.MedinsID = miConfig.Code
  5142. fed.MedinsName = miConfig.OrgName
  5143. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5144. fed.MedMdtrtType = "1"
  5145. fed.MedinsType = "1"
  5146. fed.MedinsLv = "11"
  5147. tm := time.Unix(his.RecordDate, 0)
  5148. s_tm := tm.Format("2006-01-02 15:04:05")
  5149. fed.AdmDate = s_tm
  5150. fed.DscgDate = s_tm
  5151. fed.DscgMainDiseCodg = config[0].CountryCode
  5152. fed.DscgMainDiseName = config[0].CountryContentName
  5153. //诊断信息
  5154. var fdds []*models.FsiDiagnoseDtos
  5155. for index, item := range config {
  5156. if index == 0 {
  5157. var fdd models.FsiDiagnoseDtos
  5158. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5159. fdd.InoutDiseType = "1"
  5160. fdd.MaindiseFlag = "1"
  5161. fdd.DiseDate = s_tm
  5162. fdd.DiasSrtNo = "1"
  5163. fdd.DiseName = item.CountryContentName
  5164. fdd.DiseCodg = item.CountryCode
  5165. fdds = append(fdds, &fdd)
  5166. } else {
  5167. var fdd models.FsiDiagnoseDtos
  5168. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5169. fdd.InoutDiseType = "1"
  5170. fdd.MaindiseFlag = "1"
  5171. fdd.DiseDate = s_tm
  5172. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5173. fdd.DiseName = item.CountryContentName
  5174. fdd.DiseCodg = item.CountryCode
  5175. fdds = append(fdds, &fdd)
  5176. }
  5177. }
  5178. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5179. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5180. fed.AdmDeptName = department.Name
  5181. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5182. fed.DscgDeptName = department.Name
  5183. fed.MedMdtrtType = "1"
  5184. fed.MedType = "11"
  5185. //if his.Insutype == "390" {
  5186. // fed.MedType = "1402"
  5187. //} else {
  5188. // fed.MedType = "9933"
  5189. //}
  5190. var orders []*models.FsiOrderDtos
  5191. if trig_scen == "2" {
  5192. //处方医嘱信息
  5193. for _, item := range prescriptions {
  5194. for _, subItem := range item.HisDoctorAdviceInfo {
  5195. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5196. var order models.FsiOrderDtos
  5197. order.RxID = strconv.FormatInt(item.ID, 10)
  5198. order.Rxno = strconv.FormatInt(item.ID, 10)
  5199. order.LongDrordFlag = "0"
  5200. order.HilistType = "1"
  5201. order.ChrgType = "1"
  5202. order.DrordBhvr = "-"
  5203. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5204. order.HosplistName = subItem.BaseDrugLib.DrugName
  5205. order.HilistLv = "1"
  5206. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5207. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5208. order.HosplistName = subItem.BaseDrugLib.DrugName
  5209. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5210. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5211. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5212. order.OwnpayAmt = ""
  5213. order.SelfpayAmt = ""
  5214. order.Spec = ""
  5215. order.SpecUnt = ""
  5216. order.DrordBegnDate = s_tm
  5217. order.DrordStopDate = ""
  5218. order.DrordDrCodg = doctor_info.DoctorNumber
  5219. order.DrordDeptName = department.Name
  5220. order.DrordDeptCodg = department.Number
  5221. order.DrordDrName = doctor_info.UserName
  5222. order.DrordDrProfttl = "234"
  5223. order.CurrDrordFlag = "1"
  5224. orders = append(orders, &order)
  5225. }
  5226. }
  5227. for _, subItem := range item.HisPrescriptionProject {
  5228. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5229. var order models.FsiOrderDtos
  5230. order.RxID = strconv.FormatInt(item.ID, 10)
  5231. order.Rxno = strconv.FormatInt(item.ID, 10)
  5232. order.LongDrordFlag = "0"
  5233. order.HilistType = "1"
  5234. order.ChrgType = "1"
  5235. order.DrordBhvr = "-"
  5236. order.HilistCode = subItem.HisProject.MedicalCode
  5237. order.HosplistName = subItem.HisProject.ProjectName
  5238. order.HilistLv = "1"
  5239. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5240. order.HosplistCode = subItem.HisProject.MedicalCode
  5241. order.HosplistName = subItem.HisProject.ProjectName
  5242. order.Cnt = subItem.Count
  5243. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5244. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5245. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5246. order.OwnpayAmt = ""
  5247. order.SelfpayAmt = ""
  5248. order.Spec = ""
  5249. order.SpecUnt = ""
  5250. order.DrordBegnDate = s_tm
  5251. order.DrordStopDate = ""
  5252. order.DrordDrCodg = doctor_info.DoctorNumber
  5253. order.DrordDeptName = department.Name
  5254. order.DrordDeptCodg = department.Number
  5255. order.DrordDrName = doctor_info.UserName
  5256. order.DrordDrProfttl = "234"
  5257. order.CurrDrordFlag = "1"
  5258. orders = append(orders, &order)
  5259. }
  5260. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5261. var order models.FsiOrderDtos
  5262. order.RxID = strconv.FormatInt(item.ID, 10)
  5263. order.Rxno = strconv.FormatInt(item.ID, 10)
  5264. order.LongDrordFlag = "0"
  5265. order.HilistType = "1"
  5266. order.ChrgType = "1"
  5267. order.DrordBhvr = "-"
  5268. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5269. order.HosplistName = subItem.GoodInfo.GoodName
  5270. order.HilistLv = "1"
  5271. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5272. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5273. order.HosplistName = subItem.GoodInfo.GoodName
  5274. order.Cnt = subItem.Count
  5275. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5276. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5277. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5278. order.OwnpayAmt = ""
  5279. order.SelfpayAmt = ""
  5280. order.Spec = ""
  5281. order.SpecUnt = ""
  5282. order.DrordBegnDate = s_tm
  5283. order.DrordStopDate = ""
  5284. order.DrordDrCodg = doctor_info.DoctorNumber
  5285. order.DrordDeptName = department.Name
  5286. order.DrordDeptCodg = department.Number
  5287. order.DrordDrName = doctor_info.UserName
  5288. order.DrordDrProfttl = "234"
  5289. order.CurrDrordFlag = "1"
  5290. orders = append(orders, &order)
  5291. }
  5292. }
  5293. }
  5294. //处方医嘱信息
  5295. }
  5296. fed.MatnStas = "0"
  5297. fed.MedfeeSumamt = "0"
  5298. fed.OwnpayAmt = "0"
  5299. fed.SelfpayAmt = "0"
  5300. fed.AcctPayamt = "0"
  5301. fed.MaAmt = "0"
  5302. fed.HifpPayamt = "0"
  5303. fed.SetlTotlnum = "1"
  5304. fed.Insutype = his.Insutype
  5305. fed.ReimFlag = "0"
  5306. fed.OutSetlFlag = "0"
  5307. var fopd []*models.FsiOperationDtosData
  5308. data := make(map[string]interface{})
  5309. data["fed"] = fed
  5310. data["fdd"] = fdds
  5311. data["fod"] = orders
  5312. data["pd"] = pd
  5313. data["pp"] = pp
  5314. data["fopd"] = fopd
  5315. data["trig_scen"] = trig_scen
  5316. fmt.Println(data)
  5317. fmt.Println(fed)
  5318. fmt.Println(fdds)
  5319. fmt.Println(orders)
  5320. fmt.Println(pd)
  5321. fmt.Println(pp)
  5322. fmt.Println(fopd)
  5323. client := &http.Client{}
  5324. bytesData, _ := json.Marshal(data)
  5325. var req *http.Request
  5326. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5327. if miConfig.MdtrtareaAdmvs == "320921" {
  5328. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5329. } else {
  5330. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5331. }
  5332. resp, _ := client.Do(req)
  5333. defer resp.Body.Close()
  5334. body, ioErr := ioutil.ReadAll(resp.Body)
  5335. if ioErr != nil {
  5336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5338. return res
  5339. }
  5340. var respJSON map[string]interface{}
  5341. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5344. return res
  5345. }
  5346. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5347. fmt.Println(respJSON)
  5348. result, _ := json.Marshal(respJSON)
  5349. fmt.Println(result)
  5350. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5351. utils.ErrorLog("解析失败:%v", err)
  5352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5353. return res
  5354. }
  5355. return res
  5356. } else {
  5357. //if miConfig.MdtrtareaAdmvs == "441202" {
  5358. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5359. saveLog(output, input, "3101", "事前")
  5360. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5361. utils.ErrorLog("解析失败:%v", err)
  5362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5363. return
  5364. }
  5365. return res
  5366. //}
  5367. }
  5368. }
  5369. 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) {
  5370. adminUser := c.GetAdminUserInfo()
  5371. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5372. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5373. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5374. //record_time := c.GetString("record_time")
  5375. //trig_scen := c.GetString("trig_scen")
  5376. timeLayout := "2006-01-02"
  5377. loc, _ := time.LoadLocation("Local")
  5378. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5379. if err != nil {
  5380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5381. return res
  5382. }
  5383. recordDateTime := theTime.Unix()
  5384. var patientPrescription models.HisPrescriptionInfo
  5385. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5386. if patientPrescription.ID == 0 {
  5387. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5388. }
  5389. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5390. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5391. //
  5392. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5393. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5394. var pp models.PublicParams
  5395. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5396. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5397. pp.FixmedinsName = miConfig.OrgName
  5398. pp.FixmedinsCode = miConfig.Code
  5399. pp.RequestUrl = miConfig.Url
  5400. pp.Cainfo = miConfig.Cainfo
  5401. pp.SecretKey = miConfig.SecretKey
  5402. pp.AccessKey = miConfig.AccessKey
  5403. pp.OpterName = roles.UserName
  5404. var config []*models.HisXtDiagnoseConfig
  5405. for _, item := range diagnosis_ids {
  5406. id, _ := strconv.ParseInt(item, 10, 64)
  5407. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5408. config = append(config, &diagnosisConfig)
  5409. }
  5410. var pd models.PatientDtos
  5411. pd.PatnID = his.PsnNo
  5412. pd.PatnName = his.Name
  5413. pd.Gend = his.Gend
  5414. pd.Brdy = his.Brdy
  5415. pd.Poolarea = his.InsuplcAdmdvs
  5416. pd.CurrMdtrtID = his.Number
  5417. var fed models.FsiEncounterDtos
  5418. fed.MdtrtID = his.Number
  5419. fed.MedinsID = miConfig.Code
  5420. fed.MedinsName = miConfig.OrgName
  5421. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5422. fed.MedMdtrtType = "1"
  5423. fed.MedinsType = "1"
  5424. fed.MedinsLv = "11"
  5425. tm := time.Unix(his.RecordDate, 0)
  5426. s_tm := tm.Format("2006-01-02 15:04:05")
  5427. fed.AdmDate = s_tm
  5428. fed.DscgDate = s_tm
  5429. fed.DscgMainDiseCodg = config[0].CountryCode
  5430. fed.DscgMainDiseName = config[0].CountryContentName
  5431. //诊断信息
  5432. var fdds []*models.FsiDiagnoseDtos
  5433. for index, item := range config {
  5434. if index == 0 {
  5435. var fdd models.FsiDiagnoseDtos
  5436. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5437. fdd.InoutDiseType = "1"
  5438. fdd.MaindiseFlag = "1"
  5439. fdd.DiseDate = s_tm
  5440. fdd.DiasSrtNo = "1"
  5441. fdd.DiseName = item.CountryContentName
  5442. fdd.DiseCodg = item.CountryCode
  5443. fdds = append(fdds, &fdd)
  5444. } else {
  5445. var fdd models.FsiDiagnoseDtos
  5446. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5447. fdd.InoutDiseType = "1"
  5448. fdd.MaindiseFlag = "1"
  5449. fdd.DiseDate = s_tm
  5450. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5451. fdd.DiseName = item.CountryContentName
  5452. fdd.DiseCodg = item.CountryCode
  5453. fdds = append(fdds, &fdd)
  5454. }
  5455. }
  5456. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5457. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5458. fed.AdmDeptName = department.Name
  5459. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5460. fed.DscgDeptName = department.Name
  5461. fed.MedMdtrtType = "1"
  5462. fed.MedType = "11"
  5463. //if his.Insutype == "390" {
  5464. // fed.MedType = "1402"
  5465. //} else {
  5466. // fed.MedType = "9933"
  5467. //}
  5468. var orders []*models.FsiOrderDtos
  5469. if trig_scen == "2" {
  5470. //处方医嘱信息
  5471. for _, item := range prescriptions {
  5472. for _, subItem := range item.HisDoctorAdviceInfo {
  5473. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5474. var order models.FsiOrderDtos
  5475. order.RxID = strconv.FormatInt(item.ID, 10)
  5476. order.Rxno = strconv.FormatInt(item.ID, 10)
  5477. order.LongDrordFlag = "0"
  5478. order.HilistType = "1"
  5479. order.ChrgType = "1"
  5480. order.DrordBhvr = "-"
  5481. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5482. order.HosplistName = subItem.BaseDrugLib.DrugName
  5483. order.HilistLv = "1"
  5484. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5485. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5486. order.HosplistName = subItem.BaseDrugLib.DrugName
  5487. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5488. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5489. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5490. order.OwnpayAmt = ""
  5491. order.SelfpayAmt = ""
  5492. order.Spec = ""
  5493. order.SpecUnt = ""
  5494. order.DrordBegnDate = s_tm
  5495. order.DrordStopDate = ""
  5496. order.DrordDrCodg = doctor_info.DoctorNumber
  5497. order.DrordDeptName = department.Name
  5498. order.DrordDeptCodg = department.Number
  5499. order.DrordDrName = doctor_info.UserName
  5500. order.DrordDrProfttl = "234"
  5501. order.CurrDrordFlag = "1"
  5502. orders = append(orders, &order)
  5503. }
  5504. }
  5505. for _, subItem := range item.HisPrescriptionProject {
  5506. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5507. var order models.FsiOrderDtos
  5508. order.RxID = strconv.FormatInt(item.ID, 10)
  5509. order.Rxno = strconv.FormatInt(item.ID, 10)
  5510. order.LongDrordFlag = "0"
  5511. order.HilistType = "1"
  5512. order.ChrgType = "1"
  5513. order.DrordBhvr = "-"
  5514. order.HilistCode = subItem.HisProject.MedicalCode
  5515. order.HosplistName = subItem.HisProject.ProjectName
  5516. order.HilistLv = "1"
  5517. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5518. order.HosplistCode = subItem.HisProject.MedicalCode
  5519. order.HosplistName = subItem.HisProject.ProjectName
  5520. order.Cnt = subItem.Count
  5521. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5522. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5523. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5524. order.OwnpayAmt = ""
  5525. order.SelfpayAmt = ""
  5526. order.Spec = ""
  5527. order.SpecUnt = ""
  5528. order.DrordBegnDate = s_tm
  5529. order.DrordStopDate = ""
  5530. order.DrordDrCodg = doctor_info.DoctorNumber
  5531. order.DrordDeptName = department.Name
  5532. order.DrordDeptCodg = department.Number
  5533. order.DrordDrName = doctor_info.UserName
  5534. order.DrordDrProfttl = "234"
  5535. order.CurrDrordFlag = "1"
  5536. orders = append(orders, &order)
  5537. }
  5538. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5539. var order models.FsiOrderDtos
  5540. order.RxID = strconv.FormatInt(item.ID, 10)
  5541. order.Rxno = strconv.FormatInt(item.ID, 10)
  5542. order.LongDrordFlag = "0"
  5543. order.HilistType = "1"
  5544. order.ChrgType = "1"
  5545. order.DrordBhvr = "-"
  5546. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5547. order.HosplistName = subItem.GoodInfo.GoodName
  5548. order.HilistLv = "1"
  5549. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5550. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5551. order.HosplistName = subItem.GoodInfo.GoodName
  5552. order.Cnt = subItem.Count
  5553. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5554. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5555. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5556. order.OwnpayAmt = ""
  5557. order.SelfpayAmt = ""
  5558. order.Spec = ""
  5559. order.SpecUnt = ""
  5560. order.DrordBegnDate = s_tm
  5561. order.DrordStopDate = ""
  5562. order.DrordDrCodg = doctor_info.DoctorNumber
  5563. order.DrordDeptName = department.Name
  5564. order.DrordDeptCodg = department.Number
  5565. order.DrordDrName = doctor_info.UserName
  5566. order.DrordDrProfttl = "234"
  5567. order.CurrDrordFlag = "1"
  5568. orders = append(orders, &order)
  5569. }
  5570. }
  5571. }
  5572. //处方医嘱信息
  5573. }
  5574. fed.MatnStas = "0"
  5575. fed.MedfeeSumamt = "0"
  5576. fed.OwnpayAmt = "0"
  5577. fed.SelfpayAmt = "0"
  5578. fed.AcctPayamt = "0"
  5579. fed.MaAmt = "0"
  5580. fed.HifpPayamt = "0"
  5581. fed.SetlTotlnum = "1"
  5582. fed.Insutype = his.Insutype
  5583. fed.ReimFlag = "0"
  5584. fed.OutSetlFlag = "0"
  5585. var fopd []*models.FsiOperationDtosData
  5586. data := make(map[string]interface{})
  5587. data["fed"] = fed
  5588. data["fdd"] = fdds
  5589. data["fod"] = orders
  5590. data["pd"] = pd
  5591. data["pp"] = pp
  5592. data["fopd"] = fopd
  5593. data["trig_scen"] = trig_scen
  5594. fmt.Println(data)
  5595. fmt.Println(fed)
  5596. fmt.Println(fdds)
  5597. fmt.Println(orders)
  5598. fmt.Println(pd)
  5599. fmt.Println(pp)
  5600. fmt.Println(fopd)
  5601. client := &http.Client{}
  5602. bytesData, _ := json.Marshal(data)
  5603. var req *http.Request
  5604. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5605. if miConfig.MdtrtareaAdmvs == "320921" {
  5606. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5607. } else {
  5608. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5609. }
  5610. resp, _ := client.Do(req)
  5611. defer resp.Body.Close()
  5612. body, ioErr := ioutil.ReadAll(resp.Body)
  5613. if ioErr != nil {
  5614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return res
  5617. }
  5618. var respJSON map[string]interface{}
  5619. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5622. return res
  5623. }
  5624. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5625. fmt.Println(respJSON)
  5626. result, _ := json.Marshal(respJSON)
  5627. fmt.Println(result)
  5628. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5629. utils.ErrorLog("解析失败:%v", err)
  5630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5631. return res
  5632. }
  5633. return res
  5634. } else {
  5635. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5636. saveLog(output, input, "3101", "事前")
  5637. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5638. utils.ErrorLog("解析失败:%v", err)
  5639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5640. return
  5641. }
  5642. return res
  5643. }
  5644. return res
  5645. }
  5646. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5647. ////patient_id, _ := c.GetInt64("patient_id")
  5648. //order_id, _ := c.GetInt64("order_id")
  5649. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5650. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5651. //trig_scen := c.GetString("trig_scen")
  5652. adminUser := c.GetAdminUserInfo()
  5653. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5654. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5655. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5656. record_time := c.GetString("record_time")
  5657. order, _ := service.GetHisOrderByID(order_id)
  5658. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5659. timeLayout := "2006-01-02"
  5660. loc, _ := time.LoadLocation("Local")
  5661. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5662. if err != nil {
  5663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5664. return
  5665. }
  5666. recordDateTime := theTime.Unix()
  5667. var patientPrescription models.HisPrescriptionInfo
  5668. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5669. if patientPrescription.ID == 0 {
  5670. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5671. }
  5672. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5673. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5674. //
  5675. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5676. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5677. var pp models.PublicParams
  5678. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5679. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5680. pp.FixmedinsName = miConfig.OrgName
  5681. pp.FixmedinsCode = miConfig.Code
  5682. pp.RequestUrl = miConfig.Url
  5683. pp.Cainfo = miConfig.Cainfo
  5684. pp.SecretKey = miConfig.SecretKey
  5685. pp.AccessKey = miConfig.AccessKey
  5686. pp.OpterName = roles.UserName
  5687. var config []*models.HisXtDiagnoseConfig
  5688. for _, item := range diagnosis_ids {
  5689. id, _ := strconv.ParseInt(item, 10, 64)
  5690. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5691. config = append(config, &diagnosisConfig)
  5692. }
  5693. var pd models.PatientDtos
  5694. pd.PatnID = his.PsnNo
  5695. pd.PatnName = his.Name
  5696. pd.Gend = his.Gend
  5697. pd.Brdy = psn_info.Brdy
  5698. pd.Poolarea = his.InsuplcAdmdvs
  5699. pd.CurrMdtrtID = his.Number
  5700. var fed models.FsiEncounterDtos
  5701. fed.MdtrtID = his.Number
  5702. fed.MedinsID = miConfig.Code
  5703. fed.MedinsName = miConfig.OrgName
  5704. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5705. fed.MedMdtrtType = "1"
  5706. fed.MedinsType = "1"
  5707. fed.MedinsLv = "11"
  5708. tm := time.Unix(his.RecordDate, 0)
  5709. s_tm := tm.Format("2006-01-02 15:04:05")
  5710. fed.AdmDate = s_tm
  5711. fed.DscgDate = s_tm
  5712. fed.DscgMainDiseCodg = config[0].CountryCode
  5713. fed.DscgMainDiseName = config[0].CountryContentName
  5714. //诊断信息
  5715. var fdds []*models.FsiDiagnoseDtos
  5716. for index, item := range config {
  5717. if index == 0 {
  5718. var fdd models.FsiDiagnoseDtos
  5719. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5720. fdd.InoutDiseType = "1"
  5721. fdd.MaindiseFlag = "1"
  5722. fdd.DiseDate = s_tm
  5723. fdd.DiasSrtNo = "1"
  5724. fdd.DiseName = item.CountryContentName
  5725. fdd.DiseCodg = item.CountryCode
  5726. fdds = append(fdds, &fdd)
  5727. } else {
  5728. var fdd models.FsiDiagnoseDtos
  5729. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5730. fdd.InoutDiseType = "1"
  5731. fdd.MaindiseFlag = "1"
  5732. fdd.DiseDate = s_tm
  5733. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5734. fdd.DiseName = item.CountryContentName
  5735. fdd.DiseCodg = item.CountryCode
  5736. fdds = append(fdds, &fdd)
  5737. }
  5738. }
  5739. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5740. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5741. fed.AdmDeptName = department.Name
  5742. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5743. fed.DscgDeptName = department.Name
  5744. fed.MedType = order.MedType
  5745. //处方医嘱信息
  5746. var orders []*models.FsiOrderDtos
  5747. //for _, item := range prescriptions {
  5748. // for _, subItem := range item.HisDoctorAdviceInfo {
  5749. // var order models.FsiOrderDtos
  5750. // order.RxID = strconv.FormatInt(item.ID, 10)
  5751. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5752. // order.LongDrordFlag = "0"
  5753. // order.HilistType = "1"
  5754. // order.ChrgType = "1"
  5755. // order.DrordBhvr = "-"
  5756. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5757. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5758. // order.HilistLv = "1"
  5759. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5760. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5761. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5762. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5763. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5764. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5765. // order.OwnpayAmt = ""
  5766. // order.SelfpayAmt = ""
  5767. // order.Spec = ""
  5768. // order.SpecUnt = ""
  5769. // order.DrordBegnDate = s_tm
  5770. // order.DrordStopDate = ""
  5771. // order.DrordDrCodg = "1"
  5772. // order.DrordDeptName = department.Name
  5773. // order.DrordDrCodg = "1"
  5774. // order.DrordDrName = doctor_info.UserName
  5775. // order.DrordDrProfttl = ""
  5776. // order.CurrDrordFlag = "1"
  5777. // orders = append(orders, &order)
  5778. // }
  5779. // for _, subItem := range item.HisPrescriptionProject {
  5780. // if subItem.Type == 2 {
  5781. // var order models.FsiOrderDtos
  5782. // order.RxID = strconv.FormatInt(item.ID, 10)
  5783. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5784. // order.LongDrordFlag = "0"
  5785. // order.HilistType = "1"
  5786. // order.ChrgType = "1"
  5787. // order.DrordBhvr = "-"
  5788. // order.HilistCode = subItem.HisProject.MedicalCode
  5789. // order.HosplistName = subItem.HisProject.ProjectName
  5790. // order.HilistLv = "1"
  5791. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5792. // order.HosplistCode = subItem.HisProject.MedicalCode
  5793. // order.HosplistName = subItem.HisProject.ProjectName
  5794. // order.Cnt = subItem.Count
  5795. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5796. //
  5797. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5798. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5799. // order.OwnpayAmt = ""
  5800. // order.SelfpayAmt = ""
  5801. // order.Spec = ""
  5802. // order.SpecUnt = ""
  5803. // order.DrordBegnDate = s_tm
  5804. // order.DrordStopDate = ""
  5805. // order.DrordDrCodg = "1"
  5806. // order.DrordDeptName = department.Name
  5807. // order.DrordDrCodg = "1"
  5808. // order.DrordDrName = doctor_info.UserName
  5809. // order.DrordDrProfttl = ""
  5810. // order.CurrDrordFlag = "1"
  5811. // orders = append(orders, &order)
  5812. //
  5813. // }
  5814. // if subItem.Type == 3 {
  5815. //
  5816. // var order models.FsiOrderDtos
  5817. // order.RxID = strconv.FormatInt(item.ID, 10)
  5818. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5819. // order.LongDrordFlag = "0"
  5820. // order.HilistType = "1"
  5821. // order.ChrgType = "1"
  5822. // order.DrordBhvr = "-"
  5823. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5824. // order.HosplistName = subItem.GoodInfo.GoodName
  5825. // order.HilistLv = "1"
  5826. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5827. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5828. // order.HosplistName = subItem.GoodInfo.GoodName
  5829. // order.Cnt = subItem.Count
  5830. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5831. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5832. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5833. // order.OwnpayAmt = ""
  5834. // order.SelfpayAmt = ""
  5835. // order.Spec = ""
  5836. // order.SpecUnt = ""
  5837. // order.DrordBegnDate = s_tm
  5838. // order.DrordStopDate = ""
  5839. // order.DrordDrCodg = "1"
  5840. // order.DrordDeptName = department.Name
  5841. // order.DrordDrCodg = "1"
  5842. // order.DrordDrName = doctor_info.UserName
  5843. // order.DrordDrProfttl = ""
  5844. // order.CurrDrordFlag = "1"
  5845. // orders = append(orders, &order)
  5846. //
  5847. // }
  5848. // }
  5849. //}
  5850. for _, item := range prescriptions {
  5851. for _, subItem := range item.HisDoctorAdviceInfo {
  5852. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5853. var order models.FsiOrderDtos
  5854. order.RxID = strconv.FormatInt(item.ID, 10)
  5855. order.Rxno = strconv.FormatInt(item.ID, 10)
  5856. order.LongDrordFlag = "0"
  5857. order.HilistType = "1"
  5858. order.ChrgType = "1"
  5859. order.DrordBhvr = "-"
  5860. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5861. order.HosplistName = subItem.BaseDrugLib.DrugName
  5862. order.HilistLv = "1"
  5863. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5864. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5865. order.HosplistName = subItem.BaseDrugLib.DrugName
  5866. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5867. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5868. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5869. order.OwnpayAmt = ""
  5870. order.SelfpayAmt = ""
  5871. order.Spec = ""
  5872. order.SpecUnt = ""
  5873. order.DrordBegnDate = s_tm
  5874. order.DrordStopDate = ""
  5875. order.DrordDrCodg = doctor_info.DoctorNumber
  5876. order.DrordDeptName = department.Name
  5877. order.DrordDeptCodg = department.Number
  5878. order.DrordDrName = doctor_info.UserName
  5879. order.DrordDrProfttl = "234"
  5880. order.CurrDrordFlag = "1"
  5881. orders = append(orders, &order)
  5882. }
  5883. }
  5884. for _, subItem := range item.HisPrescriptionProject {
  5885. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5886. var order models.FsiOrderDtos
  5887. order.RxID = strconv.FormatInt(item.ID, 10)
  5888. order.Rxno = strconv.FormatInt(item.ID, 10)
  5889. order.LongDrordFlag = "0"
  5890. order.HilistType = "1"
  5891. order.ChrgType = "1"
  5892. order.DrordBhvr = "-"
  5893. order.HilistCode = subItem.HisProject.MedicalCode
  5894. order.HosplistName = subItem.HisProject.ProjectName
  5895. order.HilistLv = "1"
  5896. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5897. order.HosplistCode = subItem.HisProject.MedicalCode
  5898. order.HosplistName = subItem.HisProject.ProjectName
  5899. order.Cnt = subItem.Count
  5900. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5901. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5902. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5903. order.OwnpayAmt = ""
  5904. order.SelfpayAmt = ""
  5905. order.Spec = ""
  5906. order.SpecUnt = ""
  5907. order.DrordBegnDate = s_tm
  5908. order.DrordStopDate = ""
  5909. order.DrordDrCodg = doctor_info.DoctorNumber
  5910. order.DrordDeptName = department.Name
  5911. order.DrordDeptCodg = department.Number
  5912. order.DrordDrName = doctor_info.UserName
  5913. order.DrordDrProfttl = "234"
  5914. order.CurrDrordFlag = "1"
  5915. orders = append(orders, &order)
  5916. }
  5917. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5918. var order models.FsiOrderDtos
  5919. order.RxID = strconv.FormatInt(item.ID, 10)
  5920. order.Rxno = strconv.FormatInt(item.ID, 10)
  5921. order.LongDrordFlag = "0"
  5922. order.HilistType = "1"
  5923. order.ChrgType = "1"
  5924. order.DrordBhvr = "0"
  5925. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5926. order.HosplistName = subItem.GoodInfo.GoodName
  5927. order.HilistLv = "1"
  5928. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5929. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5930. order.HosplistName = subItem.GoodInfo.GoodName
  5931. order.Cnt = subItem.Count
  5932. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5933. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5934. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5935. order.OwnpayAmt = ""
  5936. order.SelfpayAmt = ""
  5937. order.Spec = ""
  5938. order.SpecUnt = ""
  5939. order.DrordBegnDate = s_tm
  5940. order.DrordStopDate = ""
  5941. order.DrordDrCodg = doctor_info.DoctorNumber
  5942. order.DrordDeptName = department.Name
  5943. order.DrordDeptCodg = department.Number
  5944. order.DrordDrName = doctor_info.UserName
  5945. order.DrordDrProfttl = "234"
  5946. order.CurrDrordFlag = "1"
  5947. orders = append(orders, &order)
  5948. }
  5949. }
  5950. }
  5951. //处方医嘱信息
  5952. fed.MatnStas = "0"
  5953. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5954. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5955. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5956. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5957. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5958. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5959. fed.SetlTotlnum = "1"
  5960. fed.Insutype = his.Insutype
  5961. fed.ReimFlag = "0"
  5962. fed.OutSetlFlag = "0"
  5963. var fopd []*models.FsiOperationDtosData
  5964. data := make(map[string]interface{})
  5965. data["fed"] = fed
  5966. data["fdd"] = fdds
  5967. data["fod"] = orders
  5968. data["pd"] = pd
  5969. data["pp"] = pp
  5970. data["fopd"] = fopd
  5971. data["trig_scen"] = trig_scen
  5972. client := &http.Client{}
  5973. bytesData, _ := json.Marshal(data)
  5974. var req *http.Request
  5975. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5976. if miConfig.MdtrtareaAdmvs == "320921" {
  5977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5978. } else {
  5979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5980. }
  5981. resp, _ := client.Do(req)
  5982. defer resp.Body.Close()
  5983. body, ioErr := ioutil.ReadAll(resp.Body)
  5984. if ioErr != nil {
  5985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5987. return res
  5988. }
  5989. var respJSON map[string]interface{}
  5990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5993. return res
  5994. }
  5995. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5996. result, _ := json.Marshal(respJSON)
  5997. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5998. utils.ErrorLog("解析失败:%v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return res
  6001. }
  6002. return res
  6003. } else {
  6004. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6005. saveLog(output, input, "3102", "事中")
  6006. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6007. utils.ErrorLog("解析失败:%v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. return res
  6012. }
  6013. return res
  6014. }
  6015. func Checkgd3101ForOne(c *HisApiController, patient_id int64, his models.VMHisPatient, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res2 Resultgd3101) {
  6016. var res Resultgd3101
  6017. adminUser := c.GetAdminUserInfo()
  6018. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6019. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6020. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6021. //record_time := c.GetString("record_time")
  6022. //trig_scen := c.GetString("trig_scen")
  6023. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6024. timeLayout := "2006-01-02"
  6025. loc, _ := time.LoadLocation("Local")
  6026. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6027. if err != nil {
  6028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6029. return res
  6030. }
  6031. recordDateTime := theTime.Unix()
  6032. var patientPrescription models.HisPrescriptionInfo
  6033. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6034. //if patientPrescription.ID == 0 {
  6035. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6036. //}
  6037. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6038. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6039. //
  6040. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6041. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6042. var pp models.PublicParams
  6043. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6044. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6045. pp.FixmedinsName = miConfig.OrgName
  6046. pp.FixmedinsCode = miConfig.Code
  6047. pp.RequestUrl = miConfig.Url
  6048. pp.Cainfo = miConfig.Cainfo
  6049. pp.SecretKey = miConfig.SecretKey
  6050. pp.AccessKey = miConfig.AccessKey
  6051. pp.OpterName = roles.UserName
  6052. var config []*models.HisXtDiagnoseConfig
  6053. for _, item := range diagnosis_ids {
  6054. id, _ := strconv.ParseInt(item, 10, 64)
  6055. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6056. config = append(config, &diagnosisConfig)
  6057. }
  6058. var pd models.PatientDtos
  6059. pd.PatnID = his.PsnNo
  6060. pd.PatnName = his.Name
  6061. pd.Gend = his.Gend
  6062. pd.Brdy = psn_info.Brdy
  6063. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6064. pd.CurrMdtrtID = his.Number
  6065. var fed models.FsiEncounterDtos
  6066. fed.MdtrtID = his.Number
  6067. fed.MedinsID = miConfig.Code
  6068. fed.MedinsName = miConfig.OrgName
  6069. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6070. fed.MedMdtrtType = "1"
  6071. fed.MedinsType = "1"
  6072. fed.MedinsLv = "11"
  6073. tm := time.Unix(his.RecordDate, 0)
  6074. s_tm := tm.Format("2006-01-02 15:04:05")
  6075. fed.AdmDate = s_tm
  6076. fed.DscgDate = s_tm
  6077. fed.DscgMainDiseCodg = config[0].CountryCode
  6078. fed.DscgMainDiseName = config[0].CountryContentName
  6079. //诊断信息
  6080. var fdds []*models.FsiDiagnoseDtos
  6081. for index, item := range config {
  6082. if index == 0 {
  6083. var fdd models.FsiDiagnoseDtos
  6084. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6085. fdd.InoutDiseType = "1"
  6086. fdd.MaindiseFlag = "1"
  6087. fdd.DiseDate = s_tm
  6088. fdd.DiasSrtNo = "1"
  6089. fdd.DiseName = item.CountryContentName
  6090. fdd.DiseCodg = item.CountryCode
  6091. fdds = append(fdds, &fdd)
  6092. } else {
  6093. var fdd models.FsiDiagnoseDtos
  6094. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6095. fdd.InoutDiseType = "1"
  6096. fdd.MaindiseFlag = "1"
  6097. fdd.DiseDate = s_tm
  6098. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6099. fdd.DiseName = item.CountryContentName
  6100. fdd.DiseCodg = item.CountryCode
  6101. fdds = append(fdds, &fdd)
  6102. }
  6103. }
  6104. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6105. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6106. fed.AdmDeptName = department.Name
  6107. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6108. fed.DscgDeptName = department.Name
  6109. fed.MedMdtrtType = "1"
  6110. fed.MedType = "11"
  6111. //if his.Insutype == "390" {
  6112. // fed.MedType = "1402"
  6113. //} else {
  6114. // fed.MedType = "9933"
  6115. //}
  6116. var orders []*models.FsiOrderDtos
  6117. if trig_scen == "2" {
  6118. //处方医嘱信息
  6119. for _, item := range prescriptions {
  6120. for _, subItem := range item.HisDoctorAdviceInfo {
  6121. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6122. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6123. var order models.FsiOrderDtos
  6124. order.RxID = strconv.FormatInt(item.ID, 10)
  6125. order.Rxno = strconv.FormatInt(item.ID, 10)
  6126. order.LongDrordFlag = "0"
  6127. order.HilistType = "1"
  6128. order.ChrgType = "1"
  6129. order.DrordBhvr = "0"
  6130. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6131. order.HosplistName = subItem.BaseDrugLib.DrugName
  6132. order.HilistLv = "1"
  6133. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6134. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6135. order.HosplistName = subItem.BaseDrugLib.DrugName
  6136. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6137. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6138. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6139. order.OwnpayAmt = ""
  6140. order.SelfpayAmt = ""
  6141. order.Spec = spec
  6142. order.SpecUnt = subItem.PrescribingNumberUnit
  6143. order.DrordBegnDate = s_tm
  6144. order.DrordStopDate = ""
  6145. order.DrordDrCodg = doctor_info.DoctorNumber
  6146. order.DrordDeptName = department.Name
  6147. order.DrordDeptCodg = department.Number
  6148. order.DrordDrName = doctor_info.UserName
  6149. order.DrordDrProfttl = "234"
  6150. order.CurrDrordFlag = "1"
  6151. orders = append(orders, &order)
  6152. }
  6153. }
  6154. for _, subItem := range item.HisPrescriptionProject {
  6155. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6156. var order models.FsiOrderDtos
  6157. order.RxID = strconv.FormatInt(item.ID, 10)
  6158. order.Rxno = strconv.FormatInt(item.ID, 10)
  6159. order.LongDrordFlag = "0"
  6160. order.HilistType = "1"
  6161. order.ChrgType = "1"
  6162. order.DrordBhvr = "0"
  6163. order.HilistCode = subItem.HisProject.MedicalCode
  6164. order.HosplistName = subItem.HisProject.ProjectName
  6165. order.HilistLv = "1"
  6166. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6167. order.HosplistCode = subItem.HisProject.MedicalCode
  6168. order.HosplistName = subItem.HisProject.ProjectName
  6169. order.Cnt = subItem.Count
  6170. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6171. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6172. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6173. order.OwnpayAmt = ""
  6174. order.SelfpayAmt = ""
  6175. order.Spec = subItem.Unit
  6176. order.SpecUnt = subItem.Unit
  6177. order.DrordBegnDate = s_tm
  6178. order.DrordStopDate = ""
  6179. order.DrordDrCodg = doctor_info.DoctorNumber
  6180. order.DrordDeptName = department.Name
  6181. order.DrordDeptCodg = department.Number
  6182. order.DrordDrName = doctor_info.UserName
  6183. order.DrordDrProfttl = "234"
  6184. order.CurrDrordFlag = "1"
  6185. orders = append(orders, &order)
  6186. }
  6187. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6188. var order models.FsiOrderDtos
  6189. order.RxID = strconv.FormatInt(item.ID, 10)
  6190. order.Rxno = strconv.FormatInt(item.ID, 10)
  6191. order.LongDrordFlag = "0"
  6192. order.HilistType = "1"
  6193. order.ChrgType = "1"
  6194. order.DrordBhvr = "0"
  6195. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6196. order.HosplistName = subItem.GoodInfo.GoodName
  6197. order.HilistLv = "1"
  6198. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6199. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6200. order.HosplistName = subItem.GoodInfo.GoodName
  6201. order.Cnt = subItem.Count
  6202. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6203. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6204. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6205. order.OwnpayAmt = ""
  6206. order.SelfpayAmt = ""
  6207. order.Spec = subItem.GoodInfo.SpecificationName
  6208. order.SpecUnt = subItem.Unit
  6209. order.DrordBegnDate = s_tm
  6210. order.DrordStopDate = ""
  6211. order.DrordDrCodg = doctor_info.DoctorNumber
  6212. order.DrordDeptName = department.Name
  6213. order.DrordDeptCodg = department.Number
  6214. order.DrordDrName = doctor_info.UserName
  6215. order.DrordDrProfttl = "234"
  6216. order.CurrDrordFlag = "1"
  6217. orders = append(orders, &order)
  6218. }
  6219. }
  6220. }
  6221. //处方医嘱信息
  6222. }
  6223. fed.MatnStas = "0"
  6224. fed.MedfeeSumamt = "0"
  6225. fed.OwnpayAmt = "0"
  6226. fed.SelfpayAmt = "0"
  6227. fed.AcctPayamt = "0"
  6228. fed.MaAmt = "0"
  6229. fed.HifpPayamt = "0"
  6230. fed.SetlTotlnum = "1"
  6231. fed.Insutype = his.Insutype
  6232. fed.ReimFlag = "0"
  6233. fed.OutSetlFlag = "0"
  6234. var fopd []*models.FsiOperationDtosData
  6235. data := make(map[string]interface{})
  6236. data["fed"] = fed
  6237. data["fdd"] = fdds
  6238. data["fod"] = orders
  6239. data["pd"] = pd
  6240. data["pp"] = pp
  6241. data["fopd"] = fopd
  6242. data["trig_scen"] = trig_scen
  6243. fmt.Println(data)
  6244. fmt.Println(fed)
  6245. fmt.Println(fdds)
  6246. fmt.Println(orders)
  6247. fmt.Println(pd)
  6248. fmt.Println(pp)
  6249. fmt.Println(fopd)
  6250. client := &http.Client{}
  6251. bytesData, _ := json.Marshal(data)
  6252. var req *http.Request
  6253. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6254. if miConfig.MdtrtareaAdmvs == "320921" {
  6255. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6256. } else {
  6257. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6258. }
  6259. resp, _ := client.Do(req)
  6260. defer resp.Body.Close()
  6261. body, ioErr := ioutil.ReadAll(resp.Body)
  6262. if ioErr != nil {
  6263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6265. return res
  6266. }
  6267. var respJSON map[string]interface{}
  6268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. return res
  6272. }
  6273. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6274. fmt.Println(respJSON)
  6275. result, _ := json.Marshal(respJSON)
  6276. fmt.Println(result)
  6277. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6278. utils.ErrorLog("解析失败:%v", err)
  6279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6280. return res
  6281. }
  6282. return res
  6283. } else {
  6284. //if miConfig.MdtrtareaAdmvs == "441202" {
  6285. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6286. saveLog(output, input, "3101", "事前")
  6287. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6288. utils.ErrorLog("解析失败:%v", err)
  6289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6290. return
  6291. }
  6292. return res
  6293. //}
  6294. }
  6295. }
  6296. 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) {
  6297. adminUser := c.GetAdminUserInfo()
  6298. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6299. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6301. //record_time := c.GetString("record_time")
  6302. //trig_scen := c.GetString("trig_scen")
  6303. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6304. timeLayout := "2006-01-02"
  6305. loc, _ := time.LoadLocation("Local")
  6306. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6307. if err != nil {
  6308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6309. return res
  6310. }
  6311. recordDateTime := theTime.Unix()
  6312. var patientPrescription models.HisPrescriptionInfo
  6313. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6314. if patientPrescription.ID == 0 {
  6315. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6316. }
  6317. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6318. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6319. //
  6320. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6321. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6322. var pp models.PublicParams
  6323. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6324. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6325. pp.FixmedinsName = miConfig.OrgName
  6326. pp.FixmedinsCode = miConfig.Code
  6327. pp.RequestUrl = miConfig.Url
  6328. pp.Cainfo = miConfig.Cainfo
  6329. pp.SecretKey = miConfig.SecretKey
  6330. pp.AccessKey = miConfig.AccessKey
  6331. pp.OpterName = roles.UserName
  6332. var config []*models.HisXtDiagnoseConfig
  6333. for _, item := range diagnosis_ids {
  6334. id, _ := strconv.ParseInt(item, 10, 64)
  6335. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6336. config = append(config, &diagnosisConfig)
  6337. }
  6338. var pd models.PatientDtos
  6339. pd.PatnID = his.PsnNo
  6340. pd.PatnName = his.Name
  6341. pd.Gend = his.Gend
  6342. pd.Brdy = psn_info.Brdy
  6343. pd.Poolarea = his.InsuplcAdmdvs
  6344. pd.CurrMdtrtID = his.Number
  6345. var fed models.FsiEncounterDtos
  6346. fed.MdtrtID = his.Number
  6347. fed.MedinsID = miConfig.Code
  6348. fed.MedinsName = miConfig.OrgName
  6349. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6350. fed.MedMdtrtType = "1"
  6351. fed.MedinsType = "1"
  6352. fed.MedinsLv = "11"
  6353. tm := time.Unix(his.RecordDate, 0)
  6354. s_tm := tm.Format("2006-01-02 15:04:05")
  6355. fed.AdmDate = s_tm
  6356. fed.DscgDate = s_tm
  6357. fed.DscgMainDiseCodg = config[0].CountryCode
  6358. fed.DscgMainDiseName = config[0].CountryContentName
  6359. //诊断信息
  6360. var fdds []*models.FsiDiagnoseDtos
  6361. for index, item := range config {
  6362. if index == 0 {
  6363. var fdd models.FsiDiagnoseDtos
  6364. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6365. fdd.InoutDiseType = "1"
  6366. fdd.MaindiseFlag = "1"
  6367. fdd.DiseDate = s_tm
  6368. fdd.DiasSrtNo = "1"
  6369. fdd.DiseName = item.CountryContentName
  6370. fdd.DiseCodg = item.CountryCode
  6371. fdds = append(fdds, &fdd)
  6372. } else {
  6373. var fdd models.FsiDiagnoseDtos
  6374. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6375. fdd.InoutDiseType = "1"
  6376. fdd.MaindiseFlag = "1"
  6377. fdd.DiseDate = s_tm
  6378. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6379. fdd.DiseName = item.CountryContentName
  6380. fdd.DiseCodg = item.CountryCode
  6381. fdds = append(fdds, &fdd)
  6382. }
  6383. }
  6384. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6385. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6386. fed.AdmDeptName = department.Name
  6387. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6388. fed.DscgDeptName = department.Name
  6389. fed.MedMdtrtType = "1"
  6390. fed.MedType = "11"
  6391. //if his.Insutype == "390" {
  6392. // fed.MedType = "1402"
  6393. //} else {
  6394. // fed.MedType = "9933"
  6395. //}
  6396. var orders []*models.FsiOrderDtos
  6397. if trig_scen == "2" {
  6398. //处方医嘱信息
  6399. for _, item := range prescriptions {
  6400. for _, subItem := range item.HisDoctorAdviceInfo {
  6401. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6402. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6403. var order models.FsiOrderDtos
  6404. order.RxID = strconv.FormatInt(item.ID, 10)
  6405. order.Rxno = strconv.FormatInt(item.ID, 10)
  6406. order.LongDrordFlag = "0"
  6407. order.HilistType = "1"
  6408. order.ChrgType = "1"
  6409. order.DrordBhvr = "0"
  6410. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6411. order.HosplistName = subItem.BaseDrugLib.DrugName
  6412. order.HilistLv = "1"
  6413. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6414. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6415. order.HosplistName = subItem.BaseDrugLib.DrugName
  6416. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6417. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6418. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6419. order.OwnpayAmt = ""
  6420. order.SelfpayAmt = ""
  6421. order.Spec = spec
  6422. order.SpecUnt = subItem.PrescribingNumberUnit
  6423. order.DrordBegnDate = s_tm
  6424. order.DrordStopDate = ""
  6425. order.DrordDrCodg = doctor_info.DoctorNumber
  6426. order.DrordDeptName = department.Name
  6427. order.DrordDeptCodg = department.Number
  6428. order.DrordDrName = doctor_info.UserName
  6429. order.DrordDrProfttl = "234"
  6430. order.CurrDrordFlag = "1"
  6431. orders = append(orders, &order)
  6432. }
  6433. }
  6434. for _, subItem := range item.HisPrescriptionProject {
  6435. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6436. var order models.FsiOrderDtos
  6437. order.RxID = strconv.FormatInt(item.ID, 10)
  6438. order.Rxno = strconv.FormatInt(item.ID, 10)
  6439. order.LongDrordFlag = "0"
  6440. order.HilistType = "1"
  6441. order.ChrgType = "1"
  6442. order.DrordBhvr = "0"
  6443. order.HilistCode = subItem.HisProject.MedicalCode
  6444. order.HosplistName = subItem.HisProject.ProjectName
  6445. order.HilistLv = "1"
  6446. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6447. order.HosplistCode = subItem.HisProject.MedicalCode
  6448. order.HosplistName = subItem.HisProject.ProjectName
  6449. order.Cnt = subItem.Count
  6450. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6451. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6452. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6453. order.OwnpayAmt = ""
  6454. order.SelfpayAmt = ""
  6455. order.Spec = subItem.Unit
  6456. order.SpecUnt = subItem.Unit
  6457. order.DrordBegnDate = s_tm
  6458. order.DrordStopDate = ""
  6459. order.DrordDrCodg = doctor_info.DoctorNumber
  6460. order.DrordDeptName = department.Name
  6461. order.DrordDeptCodg = department.Number
  6462. order.DrordDrName = doctor_info.UserName
  6463. order.DrordDrProfttl = "234"
  6464. order.CurrDrordFlag = "1"
  6465. orders = append(orders, &order)
  6466. }
  6467. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6468. var order models.FsiOrderDtos
  6469. order.RxID = strconv.FormatInt(item.ID, 10)
  6470. order.Rxno = strconv.FormatInt(item.ID, 10)
  6471. order.LongDrordFlag = "0"
  6472. order.HilistType = "1"
  6473. order.ChrgType = "1"
  6474. order.DrordBhvr = "0"
  6475. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6476. order.HosplistName = subItem.GoodInfo.GoodName
  6477. order.HilistLv = "1"
  6478. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6479. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6480. order.HosplistName = subItem.GoodInfo.GoodName
  6481. order.Cnt = subItem.Count
  6482. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6483. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6484. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6485. order.OwnpayAmt = ""
  6486. order.SelfpayAmt = ""
  6487. order.Spec = subItem.GoodInfo.SpecificationName
  6488. order.SpecUnt = subItem.Unit
  6489. order.DrordBegnDate = s_tm
  6490. order.DrordStopDate = ""
  6491. order.DrordDrCodg = doctor_info.DoctorNumber
  6492. order.DrordDeptName = department.Name
  6493. order.DrordDeptCodg = department.Number
  6494. order.DrordDrName = doctor_info.UserName
  6495. order.DrordDrProfttl = "234"
  6496. order.CurrDrordFlag = "1"
  6497. orders = append(orders, &order)
  6498. }
  6499. }
  6500. }
  6501. //处方医嘱信息
  6502. }
  6503. fed.MatnStas = "0"
  6504. fed.MedfeeSumamt = "0"
  6505. fed.OwnpayAmt = "0"
  6506. fed.SelfpayAmt = "0"
  6507. fed.AcctPayamt = "0"
  6508. fed.MaAmt = "0"
  6509. fed.HifpPayamt = "0"
  6510. fed.SetlTotlnum = "1"
  6511. fed.Insutype = his.Insutype
  6512. fed.ReimFlag = "0"
  6513. fed.OutSetlFlag = "0"
  6514. var fopd []*models.FsiOperationDtosData
  6515. data := make(map[string]interface{})
  6516. data["fed"] = fed
  6517. data["fdd"] = fdds
  6518. data["fod"] = orders
  6519. data["pd"] = pd
  6520. data["pp"] = pp
  6521. data["fopd"] = fopd
  6522. data["trig_scen"] = trig_scen
  6523. fmt.Println(data)
  6524. fmt.Println(fed)
  6525. fmt.Println(fdds)
  6526. fmt.Println(orders)
  6527. fmt.Println(pd)
  6528. fmt.Println(pp)
  6529. fmt.Println(fopd)
  6530. client := &http.Client{}
  6531. bytesData, _ := json.Marshal(data)
  6532. var req *http.Request
  6533. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6534. if miConfig.MdtrtareaAdmvs == "320921" {
  6535. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6536. } else {
  6537. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6538. }
  6539. resp, _ := client.Do(req)
  6540. defer resp.Body.Close()
  6541. body, ioErr := ioutil.ReadAll(resp.Body)
  6542. if ioErr != nil {
  6543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6545. return res
  6546. }
  6547. var respJSON map[string]interface{}
  6548. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. return res
  6552. }
  6553. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6554. fmt.Println(respJSON)
  6555. result, _ := json.Marshal(respJSON)
  6556. fmt.Println(result)
  6557. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6558. utils.ErrorLog("解析失败:%v", err)
  6559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6560. return res
  6561. }
  6562. return res
  6563. } else {
  6564. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6565. saveLog(output, input, "3101", "事前")
  6566. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6567. utils.ErrorLog("解析失败:%v", err)
  6568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6569. return
  6570. }
  6571. return res
  6572. }
  6573. return res
  6574. }
  6575. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6576. ////patient_id, _ := c.GetInt64("patient_id")
  6577. //order_id, _ := c.GetInt64("order_id")
  6578. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6579. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6580. //trig_scen := c.GetString("trig_scen")
  6581. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6582. utils.ErrorLog("解析失败:%v", psn_info)
  6583. adminUser := c.GetAdminUserInfo()
  6584. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6585. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6586. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6587. record_time := c.GetString("record_time")
  6588. order, _ := service.GetHisOrderByID(order_id)
  6589. timeLayout := "2006-01-02"
  6590. loc, _ := time.LoadLocation("Local")
  6591. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6592. if err != nil {
  6593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6594. return
  6595. }
  6596. recordDateTime := theTime.Unix()
  6597. var patientPrescription models.HisPrescriptionInfo
  6598. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6599. if patientPrescription.ID == 0 {
  6600. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6601. }
  6602. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6603. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6604. //
  6605. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6606. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6607. var pp models.PublicParams
  6608. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6609. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6610. pp.FixmedinsName = miConfig.OrgName
  6611. pp.FixmedinsCode = miConfig.Code
  6612. pp.RequestUrl = miConfig.Url
  6613. pp.Cainfo = miConfig.Cainfo
  6614. pp.SecretKey = miConfig.SecretKey
  6615. pp.AccessKey = miConfig.AccessKey
  6616. pp.OpterName = roles.UserName
  6617. var config []*models.HisXtDiagnoseConfig
  6618. for _, item := range diagnosis_ids {
  6619. id, _ := strconv.ParseInt(item, 10, 64)
  6620. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6621. config = append(config, &diagnosisConfig)
  6622. }
  6623. var pd models.PatientDtos
  6624. pd.PatnID = his.PsnNo
  6625. pd.PatnName = his.Name
  6626. pd.Gend = his.Gend
  6627. pd.Brdy = psn_info.Brdy
  6628. pd.Poolarea = his.InsuplcAdmdvs
  6629. pd.CurrMdtrtID = his.Number
  6630. var fed models.FsiEncounterDtos
  6631. fed.MdtrtID = his.Number
  6632. fed.MedinsID = miConfig.Code
  6633. fed.MedinsName = miConfig.OrgName
  6634. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6635. fed.MedMdtrtType = "1"
  6636. fed.MedinsType = "1"
  6637. fed.MedinsLv = "11"
  6638. tm := time.Unix(his.RecordDate, 0)
  6639. s_tm := tm.Format("2006-01-02 15:04:05")
  6640. fed.AdmDate = s_tm
  6641. fed.DscgDate = s_tm
  6642. fed.DscgMainDiseCodg = config[0].CountryCode
  6643. fed.DscgMainDiseName = config[0].CountryContentName
  6644. //诊断信息
  6645. var fdds []*models.FsiDiagnoseDtos
  6646. for index, item := range config {
  6647. if index == 0 {
  6648. var fdd models.FsiDiagnoseDtos
  6649. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6650. fdd.InoutDiseType = "1"
  6651. fdd.MaindiseFlag = "1"
  6652. fdd.DiseDate = s_tm
  6653. fdd.DiasSrtNo = "1"
  6654. fdd.DiseName = item.CountryContentName
  6655. fdd.DiseCodg = item.CountryCode
  6656. fdds = append(fdds, &fdd)
  6657. } else {
  6658. var fdd models.FsiDiagnoseDtos
  6659. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6660. fdd.InoutDiseType = "1"
  6661. fdd.MaindiseFlag = "1"
  6662. fdd.DiseDate = s_tm
  6663. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6664. fdd.DiseName = item.CountryContentName
  6665. fdd.DiseCodg = item.CountryCode
  6666. fdds = append(fdds, &fdd)
  6667. }
  6668. }
  6669. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6670. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6671. fed.AdmDeptName = department.Name
  6672. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6673. fed.DscgDeptName = department.Name
  6674. fed.MedType = order.MedType
  6675. //处方医嘱信息
  6676. var orders []*models.FsiOrderDtos
  6677. //for _, item := range prescriptions {
  6678. // for _, subItem := range item.HisDoctorAdviceInfo {
  6679. // var order models.FsiOrderDtos
  6680. // order.RxID = strconv.FormatInt(item.ID, 10)
  6681. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6682. // order.LongDrordFlag = "0"
  6683. // order.HilistType = "1"
  6684. // order.ChrgType = "1"
  6685. // order.DrordBhvr = "-"
  6686. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6687. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6688. // order.HilistLv = "1"
  6689. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6690. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6691. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6692. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6693. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6694. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6695. // order.OwnpayAmt = ""
  6696. // order.SelfpayAmt = ""
  6697. // order.Spec = ""
  6698. // order.SpecUnt = ""
  6699. // order.DrordBegnDate = s_tm
  6700. // order.DrordStopDate = ""
  6701. // order.DrordDrCodg = "1"
  6702. // order.DrordDeptName = department.Name
  6703. // order.DrordDrCodg = "1"
  6704. // order.DrordDrName = doctor_info.UserName
  6705. // order.DrordDrProfttl = ""
  6706. // order.CurrDrordFlag = "1"
  6707. // orders = append(orders, &order)
  6708. // }
  6709. // for _, subItem := range item.HisPrescriptionProject {
  6710. // if subItem.Type == 2 {
  6711. // var order models.FsiOrderDtos
  6712. // order.RxID = strconv.FormatInt(item.ID, 10)
  6713. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6714. // order.LongDrordFlag = "0"
  6715. // order.HilistType = "1"
  6716. // order.ChrgType = "1"
  6717. // order.DrordBhvr = "-"
  6718. // order.HilistCode = subItem.HisProject.MedicalCode
  6719. // order.HosplistName = subItem.HisProject.ProjectName
  6720. // order.HilistLv = "1"
  6721. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6722. // order.HosplistCode = subItem.HisProject.MedicalCode
  6723. // order.HosplistName = subItem.HisProject.ProjectName
  6724. // order.Cnt = subItem.Count
  6725. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6726. //
  6727. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6728. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6729. // order.OwnpayAmt = ""
  6730. // order.SelfpayAmt = ""
  6731. // order.Spec = ""
  6732. // order.SpecUnt = ""
  6733. // order.DrordBegnDate = s_tm
  6734. // order.DrordStopDate = ""
  6735. // order.DrordDrCodg = "1"
  6736. // order.DrordDeptName = department.Name
  6737. // order.DrordDrCodg = "1"
  6738. // order.DrordDrName = doctor_info.UserName
  6739. // order.DrordDrProfttl = ""
  6740. // order.CurrDrordFlag = "1"
  6741. // orders = append(orders, &order)
  6742. //
  6743. // }
  6744. // if subItem.Type == 3 {
  6745. //
  6746. // var order models.FsiOrderDtos
  6747. // order.RxID = strconv.FormatInt(item.ID, 10)
  6748. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6749. // order.LongDrordFlag = "0"
  6750. // order.HilistType = "1"
  6751. // order.ChrgType = "1"
  6752. // order.DrordBhvr = "-"
  6753. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6754. // order.HosplistName = subItem.GoodInfo.GoodName
  6755. // order.HilistLv = "1"
  6756. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6757. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6758. // order.HosplistName = subItem.GoodInfo.GoodName
  6759. // order.Cnt = subItem.Count
  6760. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6761. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6762. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6763. // order.OwnpayAmt = ""
  6764. // order.SelfpayAmt = ""
  6765. // order.Spec = ""
  6766. // order.SpecUnt = ""
  6767. // order.DrordBegnDate = s_tm
  6768. // order.DrordStopDate = ""
  6769. // order.DrordDrCodg = "1"
  6770. // order.DrordDeptName = department.Name
  6771. // order.DrordDrCodg = "1"
  6772. // order.DrordDrName = doctor_info.UserName
  6773. // order.DrordDrProfttl = ""
  6774. // order.CurrDrordFlag = "1"
  6775. // orders = append(orders, &order)
  6776. //
  6777. // }
  6778. // }
  6779. //}
  6780. for _, item := range prescriptions {
  6781. for _, subItem := range item.HisDoctorAdviceInfo {
  6782. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6783. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6784. var order models.FsiOrderDtos
  6785. order.RxID = strconv.FormatInt(item.ID, 10)
  6786. order.Rxno = strconv.FormatInt(item.ID, 10)
  6787. order.LongDrordFlag = "0"
  6788. order.HilistType = "1"
  6789. order.ChrgType = "1"
  6790. order.DrordBhvr = "0"
  6791. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6792. order.HosplistName = subItem.BaseDrugLib.DrugName
  6793. order.HilistLv = "1"
  6794. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6795. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6796. order.HosplistName = subItem.BaseDrugLib.DrugName
  6797. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6798. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6799. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6800. order.OwnpayAmt = ""
  6801. order.SelfpayAmt = ""
  6802. order.Spec = spec
  6803. order.SpecUnt = subItem.PrescribingNumberUnit
  6804. order.DrordBegnDate = s_tm
  6805. order.DrordStopDate = ""
  6806. order.DrordDrCodg = doctor_info.DoctorNumber
  6807. order.DrordDeptName = department.Name
  6808. order.DrordDeptCodg = department.Number
  6809. order.DrordDrName = doctor_info.UserName
  6810. order.DrordDrProfttl = "234"
  6811. order.CurrDrordFlag = "1"
  6812. orders = append(orders, &order)
  6813. }
  6814. }
  6815. for _, subItem := range item.HisPrescriptionProject {
  6816. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6817. var order models.FsiOrderDtos
  6818. order.RxID = strconv.FormatInt(item.ID, 10)
  6819. order.Rxno = strconv.FormatInt(item.ID, 10)
  6820. order.LongDrordFlag = "0"
  6821. order.HilistType = "1"
  6822. order.ChrgType = "1"
  6823. order.DrordBhvr = "0"
  6824. order.HilistCode = subItem.HisProject.MedicalCode
  6825. order.HosplistName = subItem.HisProject.ProjectName
  6826. order.HilistLv = "1"
  6827. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6828. order.HosplistCode = subItem.HisProject.MedicalCode
  6829. order.HosplistName = subItem.HisProject.ProjectName
  6830. order.Cnt = subItem.Count
  6831. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6832. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6833. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6834. order.OwnpayAmt = ""
  6835. order.SelfpayAmt = ""
  6836. order.Spec = subItem.Unit
  6837. order.SpecUnt = subItem.Unit
  6838. order.DrordBegnDate = s_tm
  6839. order.DrordStopDate = ""
  6840. order.DrordDrCodg = doctor_info.DoctorNumber
  6841. order.DrordDeptName = department.Name
  6842. order.DrordDeptCodg = department.Number
  6843. order.DrordDrName = doctor_info.UserName
  6844. order.DrordDrProfttl = "234"
  6845. order.CurrDrordFlag = "1"
  6846. orders = append(orders, &order)
  6847. }
  6848. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6849. var order models.FsiOrderDtos
  6850. order.RxID = strconv.FormatInt(item.ID, 10)
  6851. order.Rxno = strconv.FormatInt(item.ID, 10)
  6852. order.LongDrordFlag = "0"
  6853. order.HilistType = "1"
  6854. order.ChrgType = "1"
  6855. order.DrordBhvr = "0"
  6856. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6857. order.HosplistName = subItem.GoodInfo.GoodName
  6858. order.HilistLv = "1"
  6859. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6860. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6861. order.HosplistName = subItem.GoodInfo.GoodName
  6862. order.Cnt = subItem.Count
  6863. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6864. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6865. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6866. order.OwnpayAmt = ""
  6867. order.SelfpayAmt = ""
  6868. order.Spec = subItem.GoodInfo.SpecificationName
  6869. order.SpecUnt = subItem.Unit
  6870. order.DrordBegnDate = s_tm
  6871. order.DrordStopDate = ""
  6872. order.DrordDrCodg = doctor_info.DoctorNumber
  6873. order.DrordDeptName = department.Name
  6874. order.DrordDeptCodg = department.Number
  6875. order.DrordDrName = doctor_info.UserName
  6876. order.DrordDrProfttl = "234"
  6877. order.CurrDrordFlag = "1"
  6878. orders = append(orders, &order)
  6879. }
  6880. }
  6881. }
  6882. //处方医嘱信息
  6883. fed.MatnStas = "0"
  6884. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6885. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6886. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6887. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6888. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6889. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6890. fed.SetlTotlnum = "1"
  6891. fed.Insutype = his.Insutype
  6892. fed.ReimFlag = "0"
  6893. fed.OutSetlFlag = "0"
  6894. var fopd []*models.FsiOperationDtosData
  6895. data := make(map[string]interface{})
  6896. data["fed"] = fed
  6897. data["fdd"] = fdds
  6898. data["fod"] = orders
  6899. data["pd"] = pd
  6900. data["pp"] = pp
  6901. data["fopd"] = fopd
  6902. data["trig_scen"] = trig_scen
  6903. client := &http.Client{}
  6904. bytesData, _ := json.Marshal(data)
  6905. var req *http.Request
  6906. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6907. if miConfig.MdtrtareaAdmvs == "320921" {
  6908. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6909. } else {
  6910. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6911. }
  6912. resp, _ := client.Do(req)
  6913. defer resp.Body.Close()
  6914. body, ioErr := ioutil.ReadAll(resp.Body)
  6915. if ioErr != nil {
  6916. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6918. return res
  6919. }
  6920. var respJSON map[string]interface{}
  6921. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6922. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6924. return res
  6925. }
  6926. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6927. result, _ := json.Marshal(respJSON)
  6928. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6929. utils.ErrorLog("解析失败:%v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return res
  6932. }
  6933. return res
  6934. } else {
  6935. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6936. saveLog(output, input, "3102", "事中")
  6937. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6938. utils.ErrorLog("解析失败:%v", err)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. return
  6941. }
  6942. return res
  6943. }
  6944. return res
  6945. }
  6946. func (c *HisApiController) Check() {
  6947. psn_no := c.GetString("psn_no")
  6948. in := c.GetString("in")
  6949. mt := c.GetString("mt")
  6950. baseParams := models.BaseParams{
  6951. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6952. FixmedinsCode: "H15049901371",
  6953. InsuplcAdmdvs: "150499",
  6954. MdtrtareaAdmvs: "150499",
  6955. OrgName: "赤峰费森血液透析中心",
  6956. Doctor: "1111",
  6957. }
  6958. service.Gdyb2001(baseParams, psn_no, in, mt)
  6959. }
  6960. func (c *HisApiController) GetPsnNcdsInfo() {
  6961. admin_user_id, _ := c.GetInt64("admin_user_id")
  6962. patient_id, _ := c.GetInt64("patient_id")
  6963. id, _ := c.GetInt64("id")
  6964. adminUser := c.GetAdminUserInfo()
  6965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6966. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6967. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6968. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6969. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6970. //
  6971. //if psn_record.ID == 0 {
  6972. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6973. // return
  6974. //}
  6975. var res Result5301
  6976. var res10265 Result5301For10265
  6977. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6978. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6979. var api string
  6980. if miConfig.MdtrtareaAdmvs == "320921" {
  6981. 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 +
  6982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6983. } else {
  6984. 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 +
  6985. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6986. }
  6987. resp, requestErr := http.Get(api)
  6988. if requestErr != nil {
  6989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6990. return
  6991. }
  6992. body, ioErr := ioutil.ReadAll(resp.Body)
  6993. if ioErr != nil {
  6994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6996. return
  6997. }
  6998. var respJSON map[string]interface{}
  6999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7002. return
  7003. }
  7004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7005. result, _ := json.Marshal(respJSON)
  7006. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7007. utils.ErrorLog("解析失败:%v", err)
  7008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7009. return
  7010. }
  7011. res.ErrMsg = res10265.ErrMsg
  7012. res.Output = res10265.Output
  7013. res.InfRefmsgid = res10265.InfRefmsgid
  7014. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7015. res.Infcode = infocode
  7016. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7017. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7018. var api string
  7019. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7021. resp, requestErr := http.Get(api)
  7022. if requestErr != nil {
  7023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7024. return
  7025. }
  7026. body, ioErr := ioutil.ReadAll(resp.Body)
  7027. if ioErr != nil {
  7028. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7030. return
  7031. }
  7032. var respJSON map[string]interface{}
  7033. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7034. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7036. return
  7037. }
  7038. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7039. if status == "0" {
  7040. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7041. c.ServeSuccessJSON(map[string]interface{}{
  7042. "failed_code": -10,
  7043. "msg": err_msg,
  7044. })
  7045. return
  7046. }
  7047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7048. result, _ := json.Marshal(respJSON)
  7049. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7050. utils.ErrorLog("解析失败:%v", err)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7055. p, _ := service.GetHisPatientById(patient_id)
  7056. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7057. var dat map[string]interface{}
  7058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7059. fmt.Println(dat)
  7060. } else {
  7061. fmt.Println(err)
  7062. }
  7063. userJSONBytes, _ := json.Marshal(dat)
  7064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7065. utils.ErrorLog("解析失败:%v", err)
  7066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7067. return
  7068. }
  7069. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7070. p, _ := service.GetHisPatientById(patient_id)
  7071. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7072. var dat map[string]interface{}
  7073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7074. fmt.Println(dat)
  7075. } else {
  7076. fmt.Println(err)
  7077. }
  7078. userJSONBytes, _ := json.Marshal(dat)
  7079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7080. utils.ErrorLog("解析失败:%v", err)
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7082. return
  7083. }
  7084. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7085. p, _ := service.GetHisPatientById(patient_id)
  7086. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7087. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7088. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7089. resp, requestErr := http.Get(api)
  7090. if requestErr != nil {
  7091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. return
  7093. }
  7094. body, ioErr := ioutil.ReadAll(resp.Body)
  7095. if ioErr != nil {
  7096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7098. return
  7099. }
  7100. var respJSON map[string]interface{}
  7101. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7107. result, _ := json.Marshal(respJSON)
  7108. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7109. utils.ErrorLog("解析失败:%v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7114. p, _ := service.GetHisPatientById(patient_id)
  7115. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7116. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7117. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7118. resp, requestErr := http.Get(api)
  7119. if requestErr != nil {
  7120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7121. return
  7122. }
  7123. body, ioErr := ioutil.ReadAll(resp.Body)
  7124. if ioErr != nil {
  7125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7127. return
  7128. }
  7129. var respJSON map[string]interface{}
  7130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7133. return
  7134. }
  7135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7136. result, _ := json.Marshal(respJSON)
  7137. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7138. utils.ErrorLog("解析失败:%v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. return
  7141. }
  7142. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7143. p, _ := service.GetHisPatientById(patient_id)
  7144. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7145. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7146. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7147. resp, requestErr := http.Get(api)
  7148. if requestErr != nil {
  7149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7150. return
  7151. }
  7152. body, ioErr := ioutil.ReadAll(resp.Body)
  7153. if ioErr != nil {
  7154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7156. return
  7157. }
  7158. var respJSON map[string]interface{}
  7159. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7165. result, _ := json.Marshal(respJSON)
  7166. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7167. utils.ErrorLog("解析失败:%v", err)
  7168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7169. return
  7170. }
  7171. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7172. p, _ := service.GetHisPatientById(patient_id)
  7173. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7174. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7175. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7176. resp, requestErr := http.Get(api)
  7177. if requestErr != nil {
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. body, ioErr := ioutil.ReadAll(resp.Body)
  7182. if ioErr != nil {
  7183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. var respJSON map[string]interface{}
  7188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7194. result, _ := json.Marshal(respJSON)
  7195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7196. utils.ErrorLog("解析失败:%v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. } else {
  7201. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7202. var dat map[string]interface{}
  7203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7204. fmt.Println(dat)
  7205. } else {
  7206. fmt.Println(err)
  7207. }
  7208. userJSONBytes, _ := json.Marshal(dat)
  7209. if miConfig.Code == "H15049901371" {
  7210. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7211. utils.ErrorLog("解析失败:%v", err)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. return
  7214. }
  7215. res.InfRefmsgid = res10265.InfRefmsgid
  7216. res.Output = res10265.Output
  7217. res.ErrMsg = res10265.ErrMsg
  7218. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7219. res.Infcode = infocode
  7220. } else {
  7221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7222. utils.ErrorLog("解析失败:%v", err)
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. return
  7225. }
  7226. }
  7227. }
  7228. if res.Infcode == 0 {
  7229. c.ServeSuccessJSON(map[string]interface{}{
  7230. "result": res.Output.Result,
  7231. })
  7232. }
  7233. }
  7234. func (c *HisApiController) CheckInsutype() {
  7235. his_patient_id, _ := c.GetInt64("his_patient_id")
  7236. admin_user_id, _ := c.GetInt64("admin_user_id")
  7237. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7238. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7240. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7241. var dat map[string]interface{}
  7242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7243. fmt.Println(dat)
  7244. } else {
  7245. fmt.Println(err)
  7246. }
  7247. userJSONBytes, _ := json.Marshal(dat)
  7248. var res Result90100
  7249. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7250. utils.ErrorLog("解析失败:%v", err)
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7252. return
  7253. }
  7254. if res.Infcode != 0 {
  7255. c.ServeSuccessJSON(map[string]interface{}{
  7256. "failed_code": -10,
  7257. "msg": res.ErrMsg,
  7258. })
  7259. return
  7260. } else {
  7261. fmt.Println(res)
  7262. }
  7263. }
  7264. func (c *HisApiController) CheckCardPWD() {
  7265. card_pwd := c.GetString("card_pwd")
  7266. his_patient_id, _ := c.GetInt64("his_patient_id")
  7267. admin_user_id, _ := c.GetInt64("admin_user_id")
  7268. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7269. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7270. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7271. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7272. bas := strings.Split(psn.CardInfo, "|")
  7273. basNumber := bas[2]
  7274. if psn.InsuplcAdmdvs[:4] == "4403" {
  7275. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7276. var dat map[string]interface{}
  7277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7278. fmt.Println(dat)
  7279. } else {
  7280. fmt.Println(err)
  7281. }
  7282. userJSONBytes, _ := json.Marshal(dat)
  7283. var res Result90991
  7284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7285. utils.ErrorLog("解析失败:%v", err)
  7286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7287. return
  7288. }
  7289. if res.Infcode != 0 {
  7290. c.ServeSuccessJSON(map[string]interface{}{
  7291. "failed_code": -10,
  7292. "msg": res.ErrMsg,
  7293. })
  7294. return
  7295. } else {
  7296. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7297. var msg string
  7298. switch res.Output.Result.CardStat {
  7299. case "00":
  7300. msg = "未激活"
  7301. break
  7302. case "10":
  7303. msg = "激活"
  7304. break
  7305. case "20":
  7306. msg = "窗口挂失"
  7307. break
  7308. case "21":
  7309. msg = "电话挂失"
  7310. break
  7311. case "22":
  7312. msg = "单位网上申报挂失"
  7313. break
  7314. case "23":
  7315. msg = "保健办挂失"
  7316. break
  7317. case "24":
  7318. msg = "个人网上挂失"
  7319. break
  7320. case "25":
  7321. msg = "网上服务大厅挂失"
  7322. break
  7323. case "30":
  7324. msg = "注销"
  7325. break
  7326. case "40":
  7327. msg = "回收"
  7328. break
  7329. case "99":
  7330. msg = "制卡中(无效卡)"
  7331. break
  7332. }
  7333. c.ServeSuccessJSON(map[string]interface{}{
  7334. "failed_code": -10,
  7335. "msg": msg,
  7336. })
  7337. return
  7338. } else {
  7339. c.ServeSuccessJSON(map[string]interface{}{
  7340. "msg": "校验成功",
  7341. })
  7342. return
  7343. }
  7344. }
  7345. } else {
  7346. c.ServeSuccessJSON(map[string]interface{}{
  7347. "msg": "校验成功",
  7348. })
  7349. return
  7350. }
  7351. }
  7352. func (c *HisApiController) CheckCardPWDTwo() {
  7353. //card_pwd := c.GetString("card_pwd")
  7354. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7355. admin_user_id, _ := c.GetInt64("admin_user_id")
  7356. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7357. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7358. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7359. var dat map[string]interface{}
  7360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7361. fmt.Println(dat)
  7362. } else {
  7363. fmt.Println(err)
  7364. }
  7365. userJSONBytes, _ := json.Marshal(dat)
  7366. var res Result90991
  7367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7368. utils.ErrorLog("解析失败:%v", err)
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. if res.Infcode != 0 {
  7373. c.ServeSuccessJSON(map[string]interface{}{
  7374. "failed_code": -10,
  7375. "msg": res.ErrMsg,
  7376. })
  7377. return
  7378. } else {
  7379. if res.Output.Result.SscnoCheckStat == "0" {
  7380. var msg string
  7381. switch res.Output.Result.CardStat {
  7382. case "00":
  7383. msg = "未激活"
  7384. break
  7385. case "10":
  7386. msg = "激活"
  7387. break
  7388. case "20":
  7389. msg = "窗口挂失"
  7390. break
  7391. case "21":
  7392. msg = "电话挂失"
  7393. break
  7394. case "22":
  7395. msg = "单位网上申报挂失"
  7396. break
  7397. case "23":
  7398. msg = "保健办挂失"
  7399. break
  7400. case "24":
  7401. msg = "个人网上挂失"
  7402. break
  7403. case "25":
  7404. msg = "网上服务大厅挂失"
  7405. break
  7406. case "30":
  7407. msg = "注销"
  7408. break
  7409. case "40":
  7410. msg = "回收"
  7411. break
  7412. case "99":
  7413. msg = "制卡中(无效卡)"
  7414. break
  7415. }
  7416. c.ServeSuccessJSON(map[string]interface{}{
  7417. "failed_code": -10,
  7418. "msg": msg,
  7419. })
  7420. return
  7421. } else {
  7422. c.ServeSuccessJSON(map[string]interface{}{
  7423. "msg": "校验成功",
  7424. })
  7425. return
  7426. }
  7427. }
  7428. }
  7429. type ELeCertData struct {
  7430. Data struct {
  7431. Extra string `json:"extra"`
  7432. IDNo string `json:"idNo"`
  7433. IDType string `json:"idType"`
  7434. EcToken string `json:"ecToken"`
  7435. InsuOrg string `json:"insuOrg"`
  7436. UserName string `json:"userName"`
  7437. EcIndexNo string `json:"ecIndexNo"`
  7438. Gender string `json:"gender"`
  7439. Birthday string `json:"birthday"`
  7440. Nationality string `json:"nationality"`
  7441. Email string `json:"email"`
  7442. } `json:"OutData"`
  7443. }
  7444. func (c *HisApiController) ReadCard() {
  7445. id_card_type, _ := c.GetInt64("id_card_type")
  7446. admin_user_id, _ := c.GetInt64("admin_user_id")
  7447. certificates, _ := c.GetInt64("certificates")
  7448. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7449. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7450. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7451. switch id_card_type {
  7452. case 1:
  7453. if miConfig.MdtrtareaAdmvs == "421300" {
  7454. var res ResultTwo
  7455. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7456. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7457. "&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)
  7458. resp, requestErr := http.Get(api)
  7459. if requestErr != nil {
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. body, ioErr := ioutil.ReadAll(resp.Body)
  7464. if ioErr != nil {
  7465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7467. return
  7468. }
  7469. var respJSON map[string]interface{}
  7470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7473. return
  7474. }
  7475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7476. result, _ := json.Marshal(respJSON)
  7477. fmt.Println("log")
  7478. fmt.Println(string(result))
  7479. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7480. utils.ErrorLog("解析失败:%v", err)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. if res.Infcode == 0 {
  7485. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7486. if err == gorm.ErrRecordNotFound {
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7488. return
  7489. } else if err != nil {
  7490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7491. return
  7492. } else {
  7493. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7494. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7495. infoStr := string(Iinfos)
  7496. idetinfoStr := string(Idetinfos)
  7497. var rf []*ResultFive
  7498. json.Unmarshal([]byte(infoStr), &rf)
  7499. var insutypes []*ResultFive
  7500. var insutype string
  7501. var is390 int = 0
  7502. var is310 int = 0
  7503. for _, item := range rf {
  7504. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7505. insutypes = append(insutypes, item)
  7506. }
  7507. }
  7508. if len(insutypes) == 1 {
  7509. insutype = insutypes[0].Insutype
  7510. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7511. } else {
  7512. for _, i := range insutypes {
  7513. if i.Insutype == "390" {
  7514. is390 = 1
  7515. }
  7516. if i.Insutype == "310" {
  7517. is310 = 1
  7518. }
  7519. }
  7520. }
  7521. if is390 == 1 {
  7522. insutype = "390"
  7523. }
  7524. if is310 == 1 {
  7525. insutype = "310"
  7526. }
  7527. if len(insutypes) == 0 {
  7528. insutype = "390"
  7529. }
  7530. var insuplc_admdvs string
  7531. for _, item := range rf {
  7532. if item.Insutype == insutype {
  7533. insuplc_admdvs = item.InsuplcAdmdvs
  7534. }
  7535. }
  7536. if strings.Contains(insuplc_admdvs, "4213") {
  7537. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7538. }
  7539. psn := &models.HisPsn{
  7540. PsnNo: res.Output.Baseinfo.PsnNo,
  7541. PatientId: patient.ID,
  7542. Certno: res.Output.Baseinfo.Certno,
  7543. Gend: res.Output.Baseinfo.Gend,
  7544. Naty: res.Output.Baseinfo.Naty,
  7545. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7546. PsnName: res.Output.Baseinfo.PsnName,
  7547. Idetinfo: idetinfoStr,
  7548. Insuinfo: infoStr,
  7549. InsuplcAdmdvs: insuplc_admdvs,
  7550. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7551. }
  7552. service.CreateHisPsn(psn)
  7553. c.ServeSuccessJSON(map[string]interface{}{
  7554. "patient": patient,
  7555. "number": res.Output.Baseinfo.Certno,
  7556. })
  7557. }
  7558. } else {
  7559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7560. return
  7561. }
  7562. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7563. var res ResultTwo
  7564. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7565. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7566. "&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)
  7567. resp, requestErr := http.Get(api)
  7568. if requestErr != nil {
  7569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7570. return
  7571. }
  7572. body, ioErr := ioutil.ReadAll(resp.Body)
  7573. if ioErr != nil {
  7574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7576. return
  7577. }
  7578. var respJSON map[string]interface{}
  7579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7582. return
  7583. }
  7584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7585. result, _ := json.Marshal(respJSON)
  7586. fmt.Println("log")
  7587. fmt.Println(string(result))
  7588. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7589. utils.ErrorLog("解析失败:%v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. if res.Infcode == 0 {
  7594. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7595. if err == gorm.ErrRecordNotFound {
  7596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7597. return
  7598. } else if err != nil {
  7599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7600. return
  7601. } else {
  7602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7604. infoStr := string(Iinfos)
  7605. idetinfoStr := string(Idetinfos)
  7606. psn := &models.HisPsn{
  7607. PsnNo: res.Output.Baseinfo.PsnNo,
  7608. PatientId: patient.ID,
  7609. Certno: res.Output.Baseinfo.Certno,
  7610. Gend: res.Output.Baseinfo.Gend,
  7611. Naty: res.Output.Baseinfo.Naty,
  7612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7613. PsnName: res.Output.Baseinfo.PsnName,
  7614. Idetinfo: idetinfoStr,
  7615. Insuinfo: infoStr,
  7616. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7617. }
  7618. service.CreateHisPsn(psn)
  7619. var rf []*ResultFive
  7620. json.Unmarshal([]byte(infoStr), &rf)
  7621. var insutypes []*ResultFive
  7622. var insutype string
  7623. var is390 int = 0
  7624. var is310 int = 0
  7625. for _, item := range rf {
  7626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7627. insutypes = append(insutypes, item)
  7628. }
  7629. }
  7630. if len(insutypes) == 1 {
  7631. insutype = insutypes[0].Insutype
  7632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7633. } else {
  7634. for _, i := range insutypes {
  7635. if i.Insutype == "390" {
  7636. is390 = 1
  7637. }
  7638. if i.Insutype == "310" {
  7639. is310 = 1
  7640. }
  7641. }
  7642. }
  7643. if is390 == 1 {
  7644. insutype = "390"
  7645. }
  7646. if is310 == 1 {
  7647. insutype = "310"
  7648. }
  7649. if len(insutypes) == 0 {
  7650. insutype = "310"
  7651. }
  7652. c.ServeSuccessJSON(map[string]interface{}{
  7653. "patient": patient,
  7654. "number": res.Output.Baseinfo.Certno,
  7655. "insutype": insutype,
  7656. })
  7657. }
  7658. } else {
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7660. return
  7661. }
  7662. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7663. var res ResultTwo
  7664. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7665. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7666. "&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)
  7667. resp, requestErr := http.Get(api)
  7668. if requestErr != nil {
  7669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7670. return
  7671. }
  7672. body, ioErr := ioutil.ReadAll(resp.Body)
  7673. if ioErr != nil {
  7674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7676. return
  7677. }
  7678. var respJSON map[string]interface{}
  7679. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. return
  7683. }
  7684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7685. result, _ := json.Marshal(respJSON)
  7686. fmt.Println("log")
  7687. fmt.Println(string(result))
  7688. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7689. utils.ErrorLog("解析失败:%v", err)
  7690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7691. return
  7692. }
  7693. if res.Infcode == 0 {
  7694. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7695. if err == gorm.ErrRecordNotFound {
  7696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7697. return
  7698. } else if err != nil {
  7699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7700. return
  7701. } else {
  7702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7704. infoStr := string(Iinfos)
  7705. idetinfoStr := string(Idetinfos)
  7706. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7707. psn := &models.HisPsn{
  7708. PsnNo: res.Output.Baseinfo.PsnNo,
  7709. PatientId: patient.ID,
  7710. Certno: res.Output.Baseinfo.Certno,
  7711. Brdy: b,
  7712. Age: float64(age),
  7713. Gend: res.Output.Baseinfo.Gend,
  7714. Naty: res.Output.Baseinfo.Naty,
  7715. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7716. PsnName: res.Output.Baseinfo.PsnName,
  7717. Idetinfo: idetinfoStr,
  7718. Insuinfo: infoStr,
  7719. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7720. }
  7721. service.CreateHisPsn(psn)
  7722. var rf []*ResultFive
  7723. json.Unmarshal([]byte(infoStr), &rf)
  7724. var insutypes []*ResultFive
  7725. var insutype string
  7726. var is390 int = 0
  7727. var is310 int = 0
  7728. for _, item := range rf {
  7729. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7730. insutypes = append(insutypes, item)
  7731. }
  7732. }
  7733. if len(insutypes) == 1 {
  7734. insutype = insutypes[0].Insutype
  7735. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7736. } else {
  7737. for _, i := range insutypes {
  7738. if i.Insutype == "390" {
  7739. is390 = 1
  7740. }
  7741. if i.Insutype == "310" {
  7742. is310 = 1
  7743. }
  7744. }
  7745. }
  7746. if is390 == 1 {
  7747. insutype = "390"
  7748. }
  7749. if is310 == 1 {
  7750. insutype = "310"
  7751. }
  7752. if len(insutypes) == 0 {
  7753. insutype = "310"
  7754. }
  7755. c.ServeSuccessJSON(map[string]interface{}{
  7756. "patient": patient,
  7757. "number": res.Output.Baseinfo.Certno,
  7758. "insutype": insutype,
  7759. })
  7760. }
  7761. } else {
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7763. return
  7764. }
  7765. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7766. var api string
  7767. if miConfig.MdtrtareaAdmvs == "320921" {
  7768. 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 +
  7769. "&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
  7770. fmt.Println(api)
  7771. } else {
  7772. 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 +
  7773. "&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)
  7774. }
  7775. resp, requestErr := http.Get(api)
  7776. if requestErr != nil {
  7777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7778. return
  7779. }
  7780. body, ioErr := ioutil.ReadAll(resp.Body)
  7781. if ioErr != nil {
  7782. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7784. return
  7785. }
  7786. var respJSON map[string]interface{}
  7787. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7788. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. return
  7791. }
  7792. var status string
  7793. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7794. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7795. //console.log()
  7796. fmt.Println("type===")
  7797. fmt.Println(card_type)
  7798. var token string
  7799. var res ResultTwo //1101结果
  7800. var res10265 ResultTwo10265 //1101结果
  7801. var card_info string //卡信息
  7802. var busi_card_info string
  7803. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7804. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7805. if status == "0" { //读卡成功
  7806. if card_type == "1" {
  7807. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7808. result, _ := json.Marshal(respJSON)
  7809. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. res.ErrMsg = res10265.ErrMsg
  7815. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7816. res.Infcode = infocode
  7817. res.Output = res10265.Output
  7818. res.InfRefmsgid = res10265.InfRefmsgid
  7819. } else {
  7820. //var card_info string //卡信息
  7821. //var busi_card_info string
  7822. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7823. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7824. //fmt.Println(card_info)
  7825. //fmt.Println(busi_card_info)
  7826. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7827. result, _ := json.Marshal(respJSON)
  7828. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. res.ErrMsg = res10265.ErrMsg
  7834. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7835. res.Infcode = infocode
  7836. res.Output = res10265.Output
  7837. res.InfRefmsgid = res10265.InfRefmsgid
  7838. }
  7839. if res.Infcode == 0 {
  7840. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7841. if err == gorm.ErrRecordNotFound {
  7842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7843. return
  7844. } else if err != nil {
  7845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7846. return
  7847. } else {
  7848. if card_type == "1" {
  7849. bas := strings.Split(card_info, "|")
  7850. basNumber := bas[2]
  7851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7853. infoStr := string(Iinfos)
  7854. idetinfoStr := string(Idetinfos)
  7855. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7856. psn := &models.HisPsn{
  7857. PsnNo: res.Output.Baseinfo.PsnNo,
  7858. PatientId: patient.ID,
  7859. Certno: res.Output.Baseinfo.Certno,
  7860. Brdy: b,
  7861. Age: float64(age),
  7862. Gend: res.Output.Baseinfo.Gend,
  7863. Naty: res.Output.Baseinfo.Naty,
  7864. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7865. PsnName: res.Output.Baseinfo.PsnName,
  7866. Idetinfo: idetinfoStr,
  7867. Insuinfo: infoStr,
  7868. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7869. CardInfo: card_info,
  7870. VerifyNumber: busi_card_info,
  7871. }
  7872. service.CreateHisPsn(psn)
  7873. var rf []*ResultFive
  7874. json.Unmarshal([]byte(infoStr), &rf)
  7875. var insutypes []*ResultFive
  7876. var insutype string
  7877. var is390 int = 0
  7878. var is310 int = 0
  7879. for _, item := range rf {
  7880. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7881. insutypes = append(insutypes, item)
  7882. }
  7883. }
  7884. if len(insutypes) == 1 {
  7885. insutype = insutypes[0].Insutype
  7886. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7887. } else {
  7888. for _, i := range insutypes {
  7889. if i.Insutype == "390" {
  7890. is390 = 1
  7891. }
  7892. if i.Insutype == "310" {
  7893. is310 = 1
  7894. }
  7895. }
  7896. }
  7897. if is390 == 1 {
  7898. insutype = "390"
  7899. }
  7900. if is310 == 1 {
  7901. insutype = "310"
  7902. }
  7903. if len(insutypes) == 0 {
  7904. insutype = "310"
  7905. }
  7906. c.ServeSuccessJSON(map[string]interface{}{
  7907. "patient": patient,
  7908. "number": basNumber,
  7909. "insutype": insutype,
  7910. })
  7911. } else {
  7912. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7913. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7914. infoStr := string(Iinfos)
  7915. idetinfoStr := string(Idetinfos)
  7916. psn := &models.HisPsn{
  7917. PsnNo: res.Output.Baseinfo.PsnNo,
  7918. PatientId: patient.ID,
  7919. Certno: res.Output.Baseinfo.Certno,
  7920. Gend: res.Output.Baseinfo.Gend,
  7921. Naty: res.Output.Baseinfo.Naty,
  7922. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7923. PsnName: res.Output.Baseinfo.PsnName,
  7924. Idetinfo: idetinfoStr,
  7925. Insuinfo: infoStr,
  7926. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7927. CardInfo: card_info,
  7928. VerifyNumber: token,
  7929. }
  7930. service.CreateHisPsn(psn)
  7931. c.ServeSuccessJSON(map[string]interface{}{
  7932. "patient": patient,
  7933. "number": token,
  7934. })
  7935. }
  7936. }
  7937. } else {
  7938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7939. return
  7940. }
  7941. } else { //读卡失败
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7943. return
  7944. }
  7945. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7946. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7947. cardnum = DeleteExtraSpaceTwo(cardnum)
  7948. cardCode = DeleteExtraSpaceTwo(cardCode)
  7949. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7950. name = DeleteExtraSpaceTwo(name)
  7951. errmsg = DeleteExtraSpaceTwo(errmsg)
  7952. cardnum = Remove0000(cardnum)
  7953. cardCode = Remove0000(cardCode)
  7954. id_card_no = Remove0000(id_card_no)
  7955. name = Remove0000(name)
  7956. errmsg = Remove0000(errmsg)
  7957. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7958. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7959. //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)
  7960. //fmt.Println(result2)
  7961. //fmt.Println(requestLog2)
  7962. //fmt.Println(errMsgLog2)
  7963. 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)
  7964. saveLog(result, requestLog, "1101", "获取人员信息")
  7965. fmt.Println(errMsgLog)
  7966. if len(errMsgLog) > 0 {
  7967. } else {
  7968. var dat map[string]interface{}
  7969. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7970. fmt.Println(dat)
  7971. } else {
  7972. fmt.Println(err)
  7973. }
  7974. userJSONBytes, _ := json.Marshal(dat)
  7975. var res ResultTwo
  7976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7977. utils.ErrorLog("解析失败:%v", err)
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. res.ErrMsg = errMsgLog
  7982. if res.Infcode == 0 {
  7983. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7984. if err == gorm.ErrRecordNotFound {
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7986. return
  7987. } else if err != nil {
  7988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7989. return
  7990. } else {
  7991. fmt.Println(res)
  7992. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7993. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7994. infoStr := string(Iinfos)
  7995. idetinfoStr := string(Idetinfos)
  7996. var rf []*ResultFive
  7997. json.Unmarshal([]byte(infoStr), &rf)
  7998. var insutypes []*ResultFive
  7999. var insutype string
  8000. var is390 int = 0
  8001. var is310 int = 0
  8002. for _, item := range rf {
  8003. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8004. insutypes = append(insutypes, item)
  8005. }
  8006. }
  8007. if len(insutypes) == 1 {
  8008. insutype = insutypes[0].Insutype
  8009. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8010. } else {
  8011. for _, i := range insutypes {
  8012. if i.Insutype == "390" {
  8013. is390 = 1
  8014. }
  8015. if i.Insutype == "310" {
  8016. is310 = 1
  8017. }
  8018. }
  8019. }
  8020. if is390 == 1 {
  8021. insutype = "390"
  8022. }
  8023. if is310 == 1 {
  8024. insutype = "310"
  8025. }
  8026. if len(insutypes) == 0 {
  8027. insutype = "390"
  8028. }
  8029. var insuplc_admdvs string
  8030. for _, item := range rf {
  8031. if item.Insutype == insutype {
  8032. insuplc_admdvs = item.InsuplcAdmdvs
  8033. }
  8034. }
  8035. psn := &models.HisPsn{
  8036. PsnNo: res.Output.Baseinfo.PsnNo,
  8037. PatientId: patient.ID,
  8038. Certno: res.Output.Baseinfo.Certno,
  8039. Gend: res.Output.Baseinfo.Gend,
  8040. Naty: res.Output.Baseinfo.Naty,
  8041. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8042. PsnName: res.Output.Baseinfo.PsnName,
  8043. Idetinfo: idetinfoStr,
  8044. Insuinfo: infoStr,
  8045. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8046. CardInfo: basStr,
  8047. VerifyNumber: "",
  8048. InsuplcAdmdvs: insuplc_admdvs,
  8049. }
  8050. service.CreateHisPsn(psn)
  8051. c.ServeSuccessJSON(map[string]interface{}{
  8052. "patient": patient,
  8053. "number": cardnum,
  8054. "insutype": insutype,
  8055. })
  8056. }
  8057. } else {
  8058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8059. return
  8060. }
  8061. }
  8062. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8063. fmt.Println(initFlag)
  8064. fmt.Println("initFlag")
  8065. if initFlag == 0 {
  8066. c.TestGetJiangXiBasBaseInit()
  8067. }
  8068. basStr := c.GetBasBaseInfo()
  8069. if len(basStr) == 0 {
  8070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8071. return
  8072. }
  8073. fmt.Println(basStr)
  8074. bas := strings.Split(basStr, "|")
  8075. basNumber := bas[1]
  8076. fmt.Println(basNumber)
  8077. card_sn := bas[3]
  8078. fmt.Println(card_sn)
  8079. 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, "")
  8080. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8081. var dat map[string]interface{}
  8082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8083. fmt.Println(dat)
  8084. } else {
  8085. fmt.Println(err)
  8086. }
  8087. userJSONBytes, _ := json.Marshal(dat)
  8088. var res ResultTwo
  8089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8090. utils.ErrorLog("解析失败:%v", err)
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8092. return
  8093. }
  8094. if res.Infcode == 0 {
  8095. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8096. if err == gorm.ErrRecordNotFound {
  8097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8098. return
  8099. } else if err != nil {
  8100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8101. return
  8102. } else {
  8103. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8104. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8105. infoStr := string(Iinfos)
  8106. idetinfoStr := string(Idetinfos)
  8107. var rf []*ResultFive
  8108. json.Unmarshal([]byte(infoStr), &rf)
  8109. var insutypes []*ResultFive
  8110. var insutype string
  8111. var is390 int = 0
  8112. var is310 int = 0
  8113. var insuplc_admdvs string
  8114. for _, item := range rf {
  8115. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8116. insutypes = append(insutypes, item)
  8117. }
  8118. }
  8119. if len(insutypes) == 1 {
  8120. insutype = insutypes[0].Insutype
  8121. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8122. } else {
  8123. for _, i := range insutypes {
  8124. if i.Insutype == "390" {
  8125. is390 = 1
  8126. }
  8127. if i.Insutype == "310" {
  8128. is310 = 1
  8129. }
  8130. }
  8131. }
  8132. if is390 == 1 {
  8133. insutype = "390"
  8134. }
  8135. if is310 == 1 {
  8136. insutype = "310"
  8137. }
  8138. if len(insutypes) == 0 {
  8139. insutype = "310"
  8140. }
  8141. for _, item := range rf {
  8142. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8143. insuplc_admdvs = item.InsuplcAdmdvs
  8144. }
  8145. }
  8146. psn := &models.HisPsn{
  8147. PsnNo: res.Output.Baseinfo.PsnNo,
  8148. PatientId: patient.ID,
  8149. Certno: res.Output.Baseinfo.Certno,
  8150. Gend: res.Output.Baseinfo.Gend,
  8151. Naty: res.Output.Baseinfo.Naty,
  8152. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8153. PsnName: res.Output.Baseinfo.PsnName,
  8154. Idetinfo: idetinfoStr,
  8155. Insuinfo: infoStr,
  8156. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8157. CardInfo: basStr,
  8158. InsuplcAdmdvs: insuplc_admdvs,
  8159. VerifyNumber: "",
  8160. }
  8161. service.CreateHisPsn(psn)
  8162. c.ServeSuccessJSON(map[string]interface{}{
  8163. "patient": patient,
  8164. "number": basNumber,
  8165. "insutype": insutype,
  8166. })
  8167. }
  8168. } else {
  8169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8170. return
  8171. }
  8172. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8173. fmt.Println(initFlag)
  8174. fmt.Println("initFlag")
  8175. if initFlag == 0 {
  8176. c.TestGetHnBasBaseInit()
  8177. }
  8178. basStr := c.GetBasBaseInfo()
  8179. if len(basStr) == 0 {
  8180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8181. return
  8182. }
  8183. fmt.Println(basStr)
  8184. bas := strings.Split(basStr, "|")
  8185. basNumber := bas[1]
  8186. fmt.Println(basNumber)
  8187. card_sn := bas[3]
  8188. card_no := bas[2]
  8189. fmt.Println(card_sn)
  8190. name := bas[4]
  8191. name = ConvertToString(name, "gbk", "utf-8")
  8192. 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)
  8193. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8194. var dat map[string]interface{}
  8195. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8196. fmt.Println(dat)
  8197. } else {
  8198. fmt.Println(err)
  8199. }
  8200. userJSONBytes, _ := json.Marshal(dat)
  8201. var res ResultTwo
  8202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8203. utils.ErrorLog("解析失败:%v", err)
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. if res.Infcode == 0 {
  8208. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8209. if err == gorm.ErrRecordNotFound {
  8210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8211. return
  8212. } else if err != nil {
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8214. return
  8215. } else {
  8216. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8217. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8218. infoStr := string(Iinfos)
  8219. idetinfoStr := string(Idetinfos)
  8220. psn := &models.HisPsn{
  8221. PsnNo: res.Output.Baseinfo.PsnNo,
  8222. PatientId: patient.ID,
  8223. Certno: res.Output.Baseinfo.Certno,
  8224. Gend: res.Output.Baseinfo.Gend,
  8225. Naty: res.Output.Baseinfo.Naty,
  8226. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8227. PsnName: res.Output.Baseinfo.PsnName,
  8228. Idetinfo: idetinfoStr,
  8229. Insuinfo: infoStr,
  8230. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8231. CardInfo: basStr,
  8232. VerifyNumber: "",
  8233. }
  8234. service.CreateHisPsn(psn)
  8235. var rf []*ResultFive
  8236. json.Unmarshal([]byte(infoStr), &rf)
  8237. var insutypes []*ResultFive
  8238. var insutype string
  8239. var is390 int = 0
  8240. var is310 int = 0
  8241. for _, item := range rf {
  8242. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8243. insutypes = append(insutypes, item)
  8244. }
  8245. }
  8246. if len(insutypes) == 1 {
  8247. insutype = insutypes[0].Insutype
  8248. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8249. } else {
  8250. for _, i := range insutypes {
  8251. if i.Insutype == "390" {
  8252. is390 = 1
  8253. }
  8254. if i.Insutype == "310" {
  8255. is310 = 1
  8256. }
  8257. }
  8258. }
  8259. if is390 == 1 {
  8260. insutype = "390"
  8261. }
  8262. if is310 == 1 {
  8263. insutype = "310"
  8264. }
  8265. if len(insutypes) == 0 {
  8266. insutype = "310"
  8267. }
  8268. c.ServeSuccessJSON(map[string]interface{}{
  8269. "patient": patient,
  8270. "number": basNumber,
  8271. "insutype": insutype,
  8272. })
  8273. }
  8274. } else {
  8275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8276. return
  8277. }
  8278. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8279. var api string
  8280. 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 +
  8281. "&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
  8282. fmt.Println(api)
  8283. resp, requestErr := http.Get(api)
  8284. if requestErr != nil {
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. body, ioErr := ioutil.ReadAll(resp.Body)
  8289. if ioErr != nil {
  8290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8292. return
  8293. }
  8294. var respJSON map[string]interface{}
  8295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8298. return
  8299. }
  8300. var res ResultTwo //1101结果
  8301. var res10265 ResultTwo10265 //1101结果
  8302. var card_info string //卡信息
  8303. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8304. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8305. result, _ := json.Marshal(respJSON)
  8306. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8307. utils.ErrorLog("解析失败:%v", err)
  8308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8309. return
  8310. }
  8311. res.ErrMsg = res10265.ErrMsg
  8312. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8313. res.Infcode = infocode
  8314. res.Output = res10265.Output
  8315. res.InfRefmsgid = res10265.InfRefmsgid
  8316. if res.Infcode == 0 {
  8317. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8318. if err == gorm.ErrRecordNotFound {
  8319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8320. return
  8321. } else if err != nil {
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8323. return
  8324. } else {
  8325. bas := strings.Split(card_info, "|")
  8326. basNumber := bas[2]
  8327. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8328. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8329. infoStr := string(Iinfos)
  8330. idetinfoStr := string(Idetinfos)
  8331. psn := &models.HisPsn{
  8332. PsnNo: res.Output.Baseinfo.PsnNo,
  8333. PatientId: patient.ID,
  8334. Certno: res.Output.Baseinfo.Certno,
  8335. Gend: res.Output.Baseinfo.Gend,
  8336. Naty: res.Output.Baseinfo.Naty,
  8337. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8338. PsnName: res.Output.Baseinfo.PsnName,
  8339. Idetinfo: idetinfoStr,
  8340. Insuinfo: infoStr,
  8341. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8342. CardInfo: card_info,
  8343. VerifyNumber: token,
  8344. }
  8345. service.CreateHisPsn(psn)
  8346. var rf []*ResultFive
  8347. json.Unmarshal([]byte(infoStr), &rf)
  8348. var insutypes []*ResultFive
  8349. var insutype string
  8350. var is390 int = 0
  8351. var is310 int = 0
  8352. for _, item := range rf {
  8353. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8354. insutypes = append(insutypes, item)
  8355. }
  8356. }
  8357. if len(insutypes) == 1 {
  8358. insutype = insutypes[0].Insutype
  8359. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8360. } else {
  8361. for _, i := range insutypes {
  8362. if i.Insutype == "390" {
  8363. is390 = 1
  8364. }
  8365. if i.Insutype == "310" {
  8366. is310 = 1
  8367. }
  8368. }
  8369. }
  8370. if is390 == 1 {
  8371. insutype = "390"
  8372. }
  8373. if is310 == 1 {
  8374. insutype = "310"
  8375. }
  8376. if len(insutypes) == 0 {
  8377. insutype = "310"
  8378. }
  8379. c.ServeSuccessJSON(map[string]interface{}{
  8380. "patient": patient,
  8381. "number": basNumber,
  8382. "insutype": insutype,
  8383. })
  8384. }
  8385. } else {
  8386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8387. return
  8388. }
  8389. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8390. res := c.GetoleInfo()
  8391. if res.Infcode == 0 {
  8392. var result string
  8393. if res.Output.MdtrtCertType == "01" {
  8394. 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)
  8395. } else if res.Output.MdtrtCertType == "02" {
  8396. 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)
  8397. } else if res.Output.MdtrtCertType == "03" {
  8398. 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)
  8399. }
  8400. var dat map[string]interface{}
  8401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8402. fmt.Println(dat)
  8403. } else {
  8404. fmt.Println(err)
  8405. }
  8406. userJSONBytes, _ := json.Marshal(dat)
  8407. var res2 ResultTwo
  8408. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8409. utils.ErrorLog("解析失败:%v", err)
  8410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8411. return
  8412. }
  8413. if res2.Infcode == 0 {
  8414. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8415. if err == gorm.ErrRecordNotFound {
  8416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8417. return
  8418. } else if err != nil {
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8420. return
  8421. } else {
  8422. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8423. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8424. infoStr := string(Iinfos)
  8425. idetinfoStr := string(Idetinfos)
  8426. var rf []*ResultFive
  8427. json.Unmarshal([]byte(infoStr), &rf)
  8428. var insutypes []*ResultFive
  8429. var insutype string
  8430. var is390 int = 0
  8431. var is310 int = 0
  8432. //var insuplc_admdvs string
  8433. for _, item := range rf {
  8434. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8435. insutypes = append(insutypes, item)
  8436. }
  8437. }
  8438. if len(insutypes) == 1 {
  8439. insutype = insutypes[0].Insutype
  8440. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8441. } else {
  8442. for _, i := range insutypes {
  8443. if i.Insutype == "390" {
  8444. is390 = 1
  8445. }
  8446. if i.Insutype == "310" {
  8447. is310 = 1
  8448. }
  8449. }
  8450. }
  8451. if is390 == 1 {
  8452. insutype = "390"
  8453. }
  8454. if is310 == 1 {
  8455. insutype = "310"
  8456. }
  8457. if len(insutypes) == 0 {
  8458. insutype = "310"
  8459. }
  8460. psn := &models.HisPsn{
  8461. PsnNo: res2.Output.Baseinfo.PsnNo,
  8462. PatientId: patient.ID,
  8463. Certno: res2.Output.Baseinfo.Certno,
  8464. Gend: res2.Output.Baseinfo.Gend,
  8465. Naty: res2.Output.Baseinfo.Naty,
  8466. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8467. PsnName: res2.Output.Baseinfo.PsnName,
  8468. Idetinfo: idetinfoStr,
  8469. Insuinfo: infoStr,
  8470. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8471. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8472. VerifyNumber: res.Output.EcToken,
  8473. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8474. }
  8475. if res.Output.MdtrtCertType == "01" {
  8476. psn.VerifyNumber = res.Output.EcToken
  8477. //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)
  8478. } else if res.Output.MdtrtCertType == "02" {
  8479. psn.VerifyNumber = res.Output.MdtrtCertNo
  8480. //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)
  8481. } else if res.Output.MdtrtCertType == "03" {
  8482. psn.VerifyNumber = res.Output.MdtrtCertNo
  8483. //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)
  8484. }
  8485. var balc float64
  8486. for _, item := range rf {
  8487. if item.Insutype == insutype {
  8488. balc = item.Balc
  8489. }
  8490. }
  8491. service.CreateHisPsn(psn)
  8492. c.ServeSuccessJSON(map[string]interface{}{
  8493. "patient": patient,
  8494. "number": res.Output.CardNo,
  8495. "insutype": insutype,
  8496. "blac": balc,
  8497. "desc": idetinfoStr,
  8498. })
  8499. }
  8500. } else {
  8501. c.ServeSuccessJSON(map[string]interface{}{
  8502. "failed_code": -10,
  8503. "msg": res2.ErrMsg,
  8504. })
  8505. }
  8506. } else {
  8507. c.ServeSuccessJSON(map[string]interface{}{
  8508. "failed_code": -10,
  8509. "msg": res.ErrMsg,
  8510. })
  8511. }
  8512. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8513. var api string
  8514. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8515. "&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
  8516. fmt.Println(api)
  8517. resp, requestErr := http.Get(api)
  8518. if requestErr != nil {
  8519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8520. return
  8521. }
  8522. body, ioErr := ioutil.ReadAll(resp.Body)
  8523. if ioErr != nil {
  8524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. var respJSON map[string]interface{}
  8529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. var status string
  8535. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8536. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8537. //console.log()
  8538. fmt.Println("type===")
  8539. fmt.Println(card_type)
  8540. var token string
  8541. var res ResultTwo //1101结果
  8542. //var res10265 ResultTwoesultTwo10265 //1101结果
  8543. var card_info string //卡信息
  8544. var busi_card_info string
  8545. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8546. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8547. if status == "0" { //读卡成功
  8548. if card_type == "1" {
  8549. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8550. result, _ := json.Marshal(respJSON)
  8551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8552. utils.ErrorLog("解析失败:%v", err)
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8554. return
  8555. }
  8556. } else {
  8557. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8558. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8559. result, _ := json.Marshal(respJSON)
  8560. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8561. utils.ErrorLog("解析失败:%v", err)
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8563. return
  8564. }
  8565. }
  8566. if res.Infcode == 0 {
  8567. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8568. if err == gorm.ErrRecordNotFound {
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8570. return
  8571. } else if err != nil {
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8573. return
  8574. } else {
  8575. if card_type == "1" {
  8576. bas := strings.Split(card_info, "|")
  8577. basNumber := bas[2]
  8578. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8579. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8580. infoStr := string(Iinfos)
  8581. idetinfoStr := string(Idetinfos)
  8582. psn := &models.HisPsn{
  8583. PsnNo: res.Output.Baseinfo.PsnNo,
  8584. PatientId: patient.ID,
  8585. Certno: res.Output.Baseinfo.Certno,
  8586. Gend: res.Output.Baseinfo.Gend,
  8587. Naty: res.Output.Baseinfo.Naty,
  8588. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8589. PsnName: res.Output.Baseinfo.PsnName,
  8590. Idetinfo: idetinfoStr,
  8591. Insuinfo: infoStr,
  8592. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8593. CardInfo: card_info,
  8594. VerifyNumber: busi_card_info,
  8595. }
  8596. service.CreateHisPsn(psn)
  8597. var rf []*ResultFive
  8598. json.Unmarshal([]byte(infoStr), &rf)
  8599. var insutypes []*ResultFive
  8600. var insutype string
  8601. var is390 int = 0
  8602. var is310 int = 0
  8603. for _, item := range rf {
  8604. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8605. insutypes = append(insutypes, item)
  8606. }
  8607. }
  8608. if len(insutypes) == 1 {
  8609. insutype = insutypes[0].Insutype
  8610. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8611. } else {
  8612. for _, i := range insutypes {
  8613. if i.Insutype == "390" {
  8614. is390 = 1
  8615. }
  8616. if i.Insutype == "310" {
  8617. is310 = 1
  8618. }
  8619. }
  8620. }
  8621. if is390 == 1 {
  8622. insutype = "390"
  8623. }
  8624. if is310 == 1 {
  8625. insutype = "310"
  8626. }
  8627. if len(insutypes) == 0 {
  8628. insutype = "310"
  8629. }
  8630. c.ServeSuccessJSON(map[string]interface{}{
  8631. "patient": patient,
  8632. "number": basNumber,
  8633. "insutype": insutype,
  8634. })
  8635. } else {
  8636. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8637. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8638. infoStr := string(Iinfos)
  8639. idetinfoStr := string(Idetinfos)
  8640. psn := &models.HisPsn{
  8641. PsnNo: res.Output.Baseinfo.PsnNo,
  8642. PatientId: patient.ID,
  8643. Certno: res.Output.Baseinfo.Certno,
  8644. Gend: res.Output.Baseinfo.Gend,
  8645. Naty: res.Output.Baseinfo.Naty,
  8646. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8647. PsnName: res.Output.Baseinfo.PsnName,
  8648. Idetinfo: idetinfoStr,
  8649. Insuinfo: infoStr,
  8650. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8651. CardInfo: card_info,
  8652. VerifyNumber: token,
  8653. }
  8654. service.CreateHisPsn(psn)
  8655. c.ServeSuccessJSON(map[string]interface{}{
  8656. "patient": patient,
  8657. "number": token,
  8658. })
  8659. }
  8660. }
  8661. } else {
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8663. return
  8664. }
  8665. } else { //读卡失败
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8667. return
  8668. }
  8669. } else {
  8670. if initFlag == 0 {
  8671. c.TestGetBasBaseInit()
  8672. }
  8673. basStr := c.GetBasBaseInfo()
  8674. if len(basStr) == 0 {
  8675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8676. return
  8677. }
  8678. fmt.Println(basStr)
  8679. bas := strings.Split(basStr, "|")
  8680. basNumber := bas[1]
  8681. fmt.Println(basNumber)
  8682. card_sn := bas[3]
  8683. fmt.Println(card_sn)
  8684. cardNumber := bas[2]
  8685. fmt.Println(cardNumber)
  8686. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8687. var result string
  8688. if bas[0][:2] == "44" {
  8689. 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)
  8690. } else {
  8691. 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)
  8692. }
  8693. var dat map[string]interface{}
  8694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8695. fmt.Println(dat)
  8696. } else {
  8697. fmt.Println(err)
  8698. }
  8699. userJSONBytes, _ := json.Marshal(dat)
  8700. var res ResultTwo
  8701. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8702. utils.ErrorLog("解析失败:%v", err)
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8704. return
  8705. }
  8706. if res.Infcode == 0 {
  8707. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8708. if err == gorm.ErrRecordNotFound {
  8709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8710. return
  8711. } else if err != nil {
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8713. return
  8714. } else {
  8715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8717. infoStr := string(Iinfos)
  8718. idetinfoStr := string(Idetinfos)
  8719. var rf []*ResultFive
  8720. json.Unmarshal([]byte(infoStr), &rf)
  8721. var insutypes []*ResultFive
  8722. var insutype string
  8723. var is390 int = 0
  8724. var is310 int = 0
  8725. var insuplc_admdvs string
  8726. for _, item := range rf {
  8727. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8728. insutypes = append(insutypes, item)
  8729. }
  8730. }
  8731. if len(insutypes) == 1 {
  8732. insutype = insutypes[0].Insutype
  8733. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8734. } else {
  8735. for _, i := range insutypes {
  8736. if i.Insutype == "390" {
  8737. is390 = 1
  8738. }
  8739. if i.Insutype == "310" {
  8740. is310 = 1
  8741. }
  8742. }
  8743. }
  8744. if is390 == 1 {
  8745. insutype = "390"
  8746. }
  8747. if is310 == 1 {
  8748. insutype = "310"
  8749. }
  8750. if len(insutypes) == 0 {
  8751. insutype = "310"
  8752. }
  8753. for _, item := range rf {
  8754. if item.Insutype == insutype {
  8755. insuplc_admdvs = item.InsuplcAdmdvs
  8756. }
  8757. }
  8758. psn := &models.HisPsn{
  8759. PsnNo: res.Output.Baseinfo.PsnNo,
  8760. PatientId: patient.ID,
  8761. Certno: res.Output.Baseinfo.Certno,
  8762. Gend: res.Output.Baseinfo.Gend,
  8763. Naty: res.Output.Baseinfo.Naty,
  8764. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8765. PsnName: res.Output.Baseinfo.PsnName,
  8766. Idetinfo: idetinfoStr,
  8767. Insuinfo: infoStr,
  8768. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8769. CardInfo: basStr,
  8770. VerifyNumber: "",
  8771. InsuplcAdmdvs: insuplc_admdvs,
  8772. }
  8773. service.CreateHisPsn(psn)
  8774. c.ServeSuccessJSON(map[string]interface{}{
  8775. "patient": patient,
  8776. "number": basNumber,
  8777. })
  8778. }
  8779. } else {
  8780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8781. return
  8782. }
  8783. break
  8784. }
  8785. case 2:
  8786. if miConfig.MdtrtareaAdmvs == "430800" {
  8787. if initFlag == 0 {
  8788. c.TestGetHnBasBaseInit()
  8789. }
  8790. SFZStr := c.GetSFZBaseInfo()
  8791. if len(SFZStr) == 0 {
  8792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8793. return
  8794. }
  8795. fmt.Println(SFZStr)
  8796. id_card_str := strings.Split(SFZStr, "^")
  8797. card_no := id_card_str[0]
  8798. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8799. //name := id_card_str[1]
  8800. //name = ConvertToString(name, "gbk", "utf-8")
  8801. 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, "", patient.Name, card_no)
  8802. var dat map[string]interface{}
  8803. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8804. fmt.Println(dat)
  8805. } else {
  8806. fmt.Println(err)
  8807. }
  8808. userJSONBytes, _ := json.Marshal(dat)
  8809. var res ResultTwo
  8810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8811. utils.ErrorLog("解析失败:%v", err)
  8812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8813. return
  8814. }
  8815. if res.Infcode == 0 {
  8816. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8817. if err == gorm.ErrRecordNotFound {
  8818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8819. return
  8820. } else if err != nil {
  8821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8822. return
  8823. } else {
  8824. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8825. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8826. infoStr := string(Iinfos)
  8827. idetinfoStr := string(Idetinfos)
  8828. var rf []*ResultFive
  8829. json.Unmarshal([]byte(infoStr), &rf)
  8830. var insutypes []*ResultFive
  8831. var insutype string
  8832. var is390 int = 0
  8833. var is310 int = 0
  8834. for _, item := range rf {
  8835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8836. insutypes = append(insutypes, item)
  8837. }
  8838. }
  8839. if len(insutypes) == 1 {
  8840. insutype = insutypes[0].Insutype
  8841. } else {
  8842. for _, i := range insutypes {
  8843. if i.Insutype == "390" {
  8844. is390 = 1
  8845. }
  8846. if i.Insutype == "310" {
  8847. is310 = 1
  8848. }
  8849. }
  8850. }
  8851. if is390 == 1 {
  8852. insutype = "390"
  8853. }
  8854. if is310 == 1 {
  8855. insutype = "310"
  8856. }
  8857. if len(insutypes) == 0 {
  8858. insutype = "310"
  8859. }
  8860. var InsuplcAdmdvs string
  8861. for _, item := range rf {
  8862. if item.Insutype == insutype {
  8863. InsuplcAdmdvs = item.InsuplcAdmdvs
  8864. }
  8865. }
  8866. psn := &models.HisPsn{
  8867. PsnNo: res.Output.Baseinfo.PsnNo,
  8868. PatientId: patient.ID,
  8869. Certno: res.Output.Baseinfo.Certno,
  8870. Gend: res.Output.Baseinfo.Gend,
  8871. Naty: res.Output.Baseinfo.Naty,
  8872. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8873. PsnName: res.Output.Baseinfo.PsnName,
  8874. Idetinfo: idetinfoStr,
  8875. Insuinfo: infoStr,
  8876. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8877. CardInfo: SFZStr,
  8878. VerifyNumber: "",
  8879. InsuplcAdmdvs: InsuplcAdmdvs,
  8880. }
  8881. service.CreateHisPsn(psn)
  8882. c.ServeSuccessJSON(map[string]interface{}{
  8883. "patient": patient,
  8884. "number": card_no,
  8885. "insutype": insutype,
  8886. })
  8887. }
  8888. } else {
  8889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8890. return
  8891. }
  8892. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8893. var res ResultTwo
  8894. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8895. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8896. "&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)
  8897. resp, requestErr := http.Get(api)
  8898. if requestErr != nil {
  8899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8900. return
  8901. }
  8902. body, ioErr := ioutil.ReadAll(resp.Body)
  8903. if ioErr != nil {
  8904. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8906. return
  8907. }
  8908. var respJSON map[string]interface{}
  8909. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8910. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8912. return
  8913. }
  8914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8915. result, _ := json.Marshal(respJSON)
  8916. fmt.Println("log")
  8917. fmt.Println(string(result))
  8918. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8919. utils.ErrorLog("解析失败:%v", err)
  8920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8921. return
  8922. }
  8923. if res.Infcode == 0 {
  8924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8925. if err == gorm.ErrRecordNotFound {
  8926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8927. return
  8928. } else if err != nil {
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8930. return
  8931. } else {
  8932. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8933. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8934. infoStr := string(Iinfos)
  8935. idetinfoStr := string(Idetinfos)
  8936. psn := &models.HisPsn{
  8937. PsnNo: res.Output.Baseinfo.PsnNo,
  8938. PatientId: patient.ID,
  8939. Certno: res.Output.Baseinfo.Certno,
  8940. Gend: res.Output.Baseinfo.Gend,
  8941. Naty: res.Output.Baseinfo.Naty,
  8942. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8943. PsnName: res.Output.Baseinfo.PsnName,
  8944. Idetinfo: idetinfoStr,
  8945. Insuinfo: infoStr,
  8946. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8947. }
  8948. service.CreateHisPsn(psn)
  8949. c.ServeSuccessJSON(map[string]interface{}{
  8950. "patient": patient,
  8951. "number": res.Output.Baseinfo.Certno,
  8952. })
  8953. }
  8954. } else {
  8955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8956. return
  8957. }
  8958. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8959. var res ResultTwo
  8960. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8961. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8962. "&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)
  8963. resp, requestErr := http.Get(api)
  8964. if requestErr != nil {
  8965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8966. return
  8967. }
  8968. body, ioErr := ioutil.ReadAll(resp.Body)
  8969. if ioErr != nil {
  8970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8972. return
  8973. }
  8974. var respJSON map[string]interface{}
  8975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8981. result, _ := json.Marshal(respJSON)
  8982. fmt.Println("log")
  8983. fmt.Println(string(result))
  8984. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8985. utils.ErrorLog("解析失败:%v", err)
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8987. return
  8988. }
  8989. if res.Infcode == 0 {
  8990. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8991. if err == gorm.ErrRecordNotFound {
  8992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8993. return
  8994. } else if err != nil {
  8995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8996. return
  8997. } else {
  8998. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8999. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9000. infoStr := string(Iinfos)
  9001. idetinfoStr := string(Idetinfos)
  9002. psn := &models.HisPsn{
  9003. PsnNo: res.Output.Baseinfo.PsnNo,
  9004. PatientId: patient.ID,
  9005. Certno: res.Output.Baseinfo.Certno,
  9006. Gend: res.Output.Baseinfo.Gend,
  9007. Naty: res.Output.Baseinfo.Naty,
  9008. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9009. PsnName: res.Output.Baseinfo.PsnName,
  9010. Idetinfo: idetinfoStr,
  9011. Insuinfo: infoStr,
  9012. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9013. }
  9014. service.CreateHisPsn(psn)
  9015. c.ServeSuccessJSON(map[string]interface{}{
  9016. "patient": patient,
  9017. "number": res.Output.Baseinfo.Certno,
  9018. })
  9019. }
  9020. } else {
  9021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9022. return
  9023. }
  9024. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9025. res := c.GetoleInfo()
  9026. if res.Infcode == 0 {
  9027. var result string
  9028. if res.Output.MdtrtCertType == "01" {
  9029. 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)
  9030. } else if res.Output.MdtrtCertType == "02" {
  9031. 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)
  9032. } else if res.Output.MdtrtCertType == "03" {
  9033. 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)
  9034. }
  9035. var dat map[string]interface{}
  9036. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9037. fmt.Println(dat)
  9038. } else {
  9039. fmt.Println(err)
  9040. }
  9041. userJSONBytes, _ := json.Marshal(dat)
  9042. var res2 ResultTwo
  9043. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9044. utils.ErrorLog("解析失败:%v", err)
  9045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9046. return
  9047. }
  9048. if res2.Infcode == 0 {
  9049. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9050. if err == gorm.ErrRecordNotFound {
  9051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9052. return
  9053. } else if err != nil {
  9054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9055. return
  9056. } else {
  9057. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9058. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9059. infoStr := string(Iinfos)
  9060. idetinfoStr := string(Idetinfos)
  9061. var rf []*ResultFive
  9062. json.Unmarshal([]byte(infoStr), &rf)
  9063. var insutypes []*ResultFive
  9064. var insutype string
  9065. var is390 int = 0
  9066. var is310 int = 0
  9067. //var insuplc_admdvs string
  9068. for _, item := range rf {
  9069. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9070. insutypes = append(insutypes, item)
  9071. }
  9072. }
  9073. if len(insutypes) == 1 {
  9074. insutype = insutypes[0].Insutype
  9075. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9076. } else {
  9077. for _, i := range insutypes {
  9078. if i.Insutype == "390" {
  9079. is390 = 1
  9080. }
  9081. if i.Insutype == "310" {
  9082. is310 = 1
  9083. }
  9084. }
  9085. }
  9086. if is390 == 1 {
  9087. insutype = "390"
  9088. }
  9089. if is310 == 1 {
  9090. insutype = "310"
  9091. }
  9092. if len(insutypes) == 0 {
  9093. insutype = "310"
  9094. }
  9095. psn := &models.HisPsn{
  9096. PsnNo: res2.Output.Baseinfo.PsnNo,
  9097. PatientId: patient.ID,
  9098. //Brdy: res2.Output.Baseinfo.Brdy,
  9099. Certno: res2.Output.Baseinfo.Certno,
  9100. Gend: res2.Output.Baseinfo.Gend,
  9101. Naty: res2.Output.Baseinfo.Naty,
  9102. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9103. PsnName: res2.Output.Baseinfo.PsnName,
  9104. Idetinfo: idetinfoStr,
  9105. Insuinfo: infoStr,
  9106. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9107. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9108. VerifyNumber: res.Output.EcToken,
  9109. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9110. }
  9111. service.CreateHisPsn(psn)
  9112. var balc float64
  9113. for _, item := range rf {
  9114. if item.Insutype == insutype {
  9115. balc = item.Balc
  9116. }
  9117. }
  9118. c.ServeSuccessJSON(map[string]interface{}{
  9119. "patient": patient,
  9120. "number": res.Output.CardNo,
  9121. "insutype": insutype,
  9122. "blac": balc,
  9123. "desc": idetinfoStr,
  9124. })
  9125. }
  9126. } else {
  9127. c.ServeSuccessJSON(map[string]interface{}{
  9128. "failed_code": -10,
  9129. "msg": res2.ErrMsg,
  9130. })
  9131. }
  9132. } else {
  9133. c.ServeSuccessJSON(map[string]interface{}{
  9134. "failed_code": -10,
  9135. "msg": res.ErrMsg,
  9136. })
  9137. }
  9138. } else {
  9139. SFZStr := c.GetSFZBaseInfo()
  9140. id_card_str := strings.Split(SFZStr, "^")
  9141. id_card_number := id_card_str[0]
  9142. card_sn := ""
  9143. 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)
  9144. var dat map[string]interface{}
  9145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9146. fmt.Println(dat)
  9147. } else {
  9148. fmt.Println(err)
  9149. }
  9150. userJSONBytes, _ := json.Marshal(dat)
  9151. var res ResultTwo
  9152. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9153. utils.ErrorLog("解析失败:%v", err)
  9154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. return
  9156. }
  9157. if res.Infcode == 0 {
  9158. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9159. if err == gorm.ErrRecordNotFound {
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9161. return
  9162. } else if err != nil {
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9164. return
  9165. } else {
  9166. c.ServeSuccessJSON(map[string]interface{}{
  9167. "patient": patient,
  9168. "number": id_card_number,
  9169. })
  9170. }
  9171. } else {
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9173. return
  9174. }
  9175. }
  9176. break
  9177. case 3:
  9178. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9179. var api string
  9180. if miConfig.MdtrtareaAdmvs == "320921" {
  9181. 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 +
  9182. "&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
  9183. fmt.Println(api)
  9184. } else {
  9185. 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 +
  9186. "&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)
  9187. }
  9188. resp, requestErr := http.Get(api)
  9189. if requestErr != nil {
  9190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9191. return
  9192. }
  9193. body, ioErr := ioutil.ReadAll(resp.Body)
  9194. if ioErr != nil {
  9195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. var respJSON map[string]interface{}
  9200. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9203. return
  9204. }
  9205. var status string
  9206. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9207. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9208. var token string
  9209. var res ResultTwo //1101结果
  9210. var res10265 ResultTwo10265 //1101结果
  9211. var card_info string //卡信息
  9212. var busi_card_info string
  9213. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9214. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9215. if status == "0" { //读卡成功
  9216. if card_type == "1" {
  9217. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9218. result, _ := json.Marshal(respJSON)
  9219. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9220. utils.ErrorLog("解析失败:%v", err)
  9221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9222. return
  9223. }
  9224. res.ErrMsg = res10265.ErrMsg
  9225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9226. res.Infcode = infocode
  9227. res.Output = res10265.Output
  9228. res.InfRefmsgid = res10265.InfRefmsgid
  9229. } else {
  9230. //var card_info string //卡信息
  9231. //var busi_card_info string
  9232. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9233. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9234. //fmt.Println(card_info)
  9235. //fmt.Println(busi_card_info)
  9236. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9237. result, _ := json.Marshal(respJSON)
  9238. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9239. utils.ErrorLog("解析失败:%v", err)
  9240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9241. return
  9242. }
  9243. res.ErrMsg = res10265.ErrMsg
  9244. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9245. res.Infcode = infocode
  9246. res.Output = res10265.Output
  9247. res.InfRefmsgid = res10265.InfRefmsgid
  9248. }
  9249. if res.Infcode == 0 {
  9250. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9251. if err == gorm.ErrRecordNotFound {
  9252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9253. return
  9254. } else if err != nil {
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9256. return
  9257. } else {
  9258. if card_type == "1" {
  9259. bas := strings.Split(card_info, "|")
  9260. basNumber := bas[2]
  9261. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9262. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9263. infoStr := string(Iinfos)
  9264. idetinfoStr := string(Idetinfos)
  9265. psn := &models.HisPsn{
  9266. PsnNo: res.Output.Baseinfo.PsnNo,
  9267. PatientId: patient.ID,
  9268. Certno: res.Output.Baseinfo.Certno,
  9269. //Brdy: res.Output.Baseinfo.Brdy,
  9270. Gend: res.Output.Baseinfo.Gend,
  9271. Naty: res.Output.Baseinfo.Naty,
  9272. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9273. PsnName: res.Output.Baseinfo.PsnName,
  9274. Idetinfo: idetinfoStr,
  9275. Insuinfo: infoStr,
  9276. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9277. CardInfo: card_info,
  9278. VerifyNumber: busi_card_info,
  9279. }
  9280. service.CreateHisPsn(psn)
  9281. c.ServeSuccessJSON(map[string]interface{}{
  9282. "patient": patient,
  9283. "number": basNumber,
  9284. })
  9285. } else {
  9286. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9287. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9288. infoStr := string(Iinfos)
  9289. idetinfoStr := string(Idetinfos)
  9290. psn := &models.HisPsn{
  9291. PsnNo: res.Output.Baseinfo.PsnNo,
  9292. PatientId: patient.ID,
  9293. Certno: res.Output.Baseinfo.Certno,
  9294. Gend: res.Output.Baseinfo.Gend,
  9295. Naty: res.Output.Baseinfo.Naty,
  9296. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9297. PsnName: res.Output.Baseinfo.PsnName,
  9298. Idetinfo: idetinfoStr,
  9299. Insuinfo: infoStr,
  9300. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9301. CardInfo: card_info,
  9302. VerifyNumber: token,
  9303. }
  9304. service.CreateHisPsn(psn)
  9305. var rf []*ResultFive
  9306. json.Unmarshal([]byte(infoStr), &rf)
  9307. var insutypes []*ResultFive
  9308. var insutype string
  9309. var is390 int = 0
  9310. var is310 int = 0
  9311. for _, item := range rf {
  9312. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9313. insutypes = append(insutypes, item)
  9314. }
  9315. }
  9316. if len(insutypes) == 1 {
  9317. insutype = insutypes[0].Insutype
  9318. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9319. } else {
  9320. for _, i := range insutypes {
  9321. if i.Insutype == "390" {
  9322. is390 = 1
  9323. }
  9324. if i.Insutype == "310" {
  9325. is310 = 1
  9326. }
  9327. }
  9328. }
  9329. if is390 == 1 {
  9330. insutype = "390"
  9331. }
  9332. if is310 == 1 {
  9333. insutype = "310"
  9334. }
  9335. if len(insutypes) == 0 {
  9336. insutype = "310"
  9337. }
  9338. c.ServeSuccessJSON(map[string]interface{}{
  9339. "patient": patient,
  9340. "number": token,
  9341. "insutype": insutype,
  9342. })
  9343. }
  9344. }
  9345. } else {
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9347. return
  9348. }
  9349. } else { //读卡失败
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9351. return
  9352. }
  9353. }
  9354. break
  9355. case 4:
  9356. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9357. var api string
  9358. if miConfig.MdtrtareaAdmvs == "320921" {
  9359. 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 +
  9360. "&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
  9361. fmt.Println(api)
  9362. } else {
  9363. 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 +
  9364. "&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)
  9365. }
  9366. resp, requestErr := http.Get(api)
  9367. if requestErr != nil {
  9368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9369. return
  9370. }
  9371. body, ioErr := ioutil.ReadAll(resp.Body)
  9372. if ioErr != nil {
  9373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9375. return
  9376. }
  9377. var respJSON map[string]interface{}
  9378. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9381. return
  9382. }
  9383. var status string
  9384. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9385. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9386. var token string
  9387. var res ResultTwo //1101结果
  9388. var res10265 ResultTwo10265 //1101结果
  9389. if status == "0" { //读卡成功
  9390. var card_info string //卡信息
  9391. var busi_card_info string
  9392. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9393. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9394. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9395. fmt.Println(card_info)
  9396. fmt.Println(busi_card_info)
  9397. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9398. result, _ := json.Marshal(respJSON)
  9399. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9400. utils.ErrorLog("解析失败:%v", err)
  9401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9402. return
  9403. }
  9404. res.ErrMsg = res10265.ErrMsg
  9405. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9406. res.Infcode = infocode
  9407. res.Output = res10265.Output
  9408. res.InfRefmsgid = res10265.InfRefmsgid
  9409. if res.Infcode == 0 {
  9410. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9411. if err == gorm.ErrRecordNotFound {
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9413. return
  9414. } else if err != nil {
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9416. return
  9417. } else {
  9418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9420. infoStr := string(Iinfos)
  9421. idetinfoStr := string(Idetinfos)
  9422. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9423. psn := &models.HisPsn{
  9424. PsnNo: res.Output.Baseinfo.PsnNo,
  9425. PatientId: patient.ID,
  9426. Certno: res.Output.Baseinfo.Certno,
  9427. Brdy: b,
  9428. Age: float64(age),
  9429. //Brdy: res.Output.Baseinfo.Brdy,
  9430. Gend: res.Output.Baseinfo.Gend,
  9431. Naty: res.Output.Baseinfo.Naty,
  9432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9433. PsnName: res.Output.Baseinfo.PsnName,
  9434. Idetinfo: idetinfoStr,
  9435. Insuinfo: infoStr,
  9436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9437. CardInfo: card_info,
  9438. VerifyNumber: token,
  9439. }
  9440. var rf []*ResultFive
  9441. json.Unmarshal([]byte(infoStr), &rf)
  9442. var insutypes []*ResultFive
  9443. var insutype string
  9444. var is390 int = 0
  9445. var is310 int = 0
  9446. for _, item := range rf {
  9447. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9448. insutypes = append(insutypes, item)
  9449. }
  9450. }
  9451. if len(insutypes) == 1 {
  9452. insutype = insutypes[0].Insutype
  9453. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9454. } else {
  9455. for _, i := range insutypes {
  9456. if i.Insutype == "390" {
  9457. is390 = 1
  9458. }
  9459. if i.Insutype == "310" {
  9460. is310 = 1
  9461. }
  9462. }
  9463. }
  9464. if is390 == 1 {
  9465. insutype = "390"
  9466. }
  9467. if is310 == 1 {
  9468. insutype = "310"
  9469. }
  9470. if len(insutypes) == 0 {
  9471. insutype = "310"
  9472. }
  9473. service.CreateHisPsn(psn)
  9474. c.ServeSuccessJSON(map[string]interface{}{
  9475. "patient": patient,
  9476. "number": token,
  9477. "insutype": insutype,
  9478. })
  9479. }
  9480. } else {
  9481. c.ServeSuccessJSON(map[string]interface{}{
  9482. "failed_code": -10,
  9483. "msg": res.ErrMsg,
  9484. })
  9485. }
  9486. } else { //读卡失败
  9487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9488. return
  9489. }
  9490. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9491. var api string
  9492. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9493. "&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
  9494. resp, requestErr := http.Get(api)
  9495. if requestErr != nil {
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. body, ioErr := ioutil.ReadAll(resp.Body)
  9500. if ioErr != nil {
  9501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. return
  9504. }
  9505. var respJSON map[string]interface{}
  9506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9509. return
  9510. }
  9511. var status string
  9512. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9513. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9514. var token string
  9515. var res ResultTwo //1101结果
  9516. if status == "1" { //读卡成功
  9517. var card_info string //卡信息
  9518. var busi_card_info string
  9519. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9520. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9521. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9522. fmt.Println(card_info)
  9523. fmt.Println(busi_card_info)
  9524. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9525. result, _ := json.Marshal(respJSON)
  9526. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9527. utils.ErrorLog("解析失败:%v", err)
  9528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. return
  9530. }
  9531. if res.Infcode == 0 {
  9532. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9533. if err == gorm.ErrRecordNotFound {
  9534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9535. return
  9536. } else if err != nil {
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9538. return
  9539. } else {
  9540. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9541. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9542. infoStr := string(Iinfos)
  9543. idetinfoStr := string(Idetinfos)
  9544. psn := &models.HisPsn{
  9545. PsnNo: res.Output.Baseinfo.PsnNo,
  9546. PatientId: patient.ID,
  9547. Certno: res.Output.Baseinfo.Certno,
  9548. Gend: res.Output.Baseinfo.Gend,
  9549. Naty: res.Output.Baseinfo.Naty,
  9550. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9551. PsnName: res.Output.Baseinfo.PsnName,
  9552. Idetinfo: idetinfoStr,
  9553. Insuinfo: infoStr,
  9554. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9555. CardInfo: card_info,
  9556. VerifyNumber: token,
  9557. }
  9558. var rf []*ResultFive
  9559. json.Unmarshal([]byte(infoStr), &rf)
  9560. var insutypes []*ResultFive
  9561. var insutype string
  9562. var is390 int = 0
  9563. var is310 int = 0
  9564. for _, item := range rf {
  9565. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9566. insutypes = append(insutypes, item)
  9567. }
  9568. }
  9569. if len(insutypes) == 1 {
  9570. insutype = insutypes[0].Insutype
  9571. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9572. } else {
  9573. for _, i := range insutypes {
  9574. if i.Insutype == "390" {
  9575. is390 = 1
  9576. }
  9577. if i.Insutype == "310" {
  9578. is310 = 1
  9579. }
  9580. }
  9581. }
  9582. if is390 == 1 {
  9583. insutype = "390"
  9584. }
  9585. if is310 == 1 {
  9586. insutype = "310"
  9587. }
  9588. if len(insutypes) == 0 {
  9589. insutype = "310"
  9590. }
  9591. service.CreateHisPsn(psn)
  9592. c.ServeSuccessJSON(map[string]interface{}{
  9593. "patient": patient,
  9594. "number": token,
  9595. "insutype": insutype,
  9596. })
  9597. }
  9598. } else {
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9600. return
  9601. }
  9602. } else { //读卡失败
  9603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9604. return
  9605. }
  9606. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9607. idNo := c.GetString("idNo")
  9608. userName := c.GetString("userName")
  9609. ecToken := c.GetString("ecToken")
  9610. insuOrg := c.GetString("insuOrg")
  9611. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9612. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9613. var res ResultTwo
  9614. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9615. utils.ErrorLog("解析失败:%v", err)
  9616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9617. return
  9618. }
  9619. if res.Infcode == 0 {
  9620. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9621. if err == gorm.ErrRecordNotFound {
  9622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9623. return
  9624. } else if err != nil {
  9625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9626. return
  9627. } else {
  9628. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9629. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9630. infoStr := string(Iinfos)
  9631. idetinfoStr := string(Idetinfos)
  9632. psn := &models.HisPsn{
  9633. PsnNo: res.Output.Baseinfo.PsnNo,
  9634. PatientId: patient.ID,
  9635. Certno: res.Output.Baseinfo.Certno,
  9636. Gend: res.Output.Baseinfo.Gend,
  9637. Naty: res.Output.Baseinfo.Naty,
  9638. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9639. PsnName: res.Output.Baseinfo.PsnName,
  9640. Idetinfo: idetinfoStr,
  9641. Insuinfo: infoStr,
  9642. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9643. CardInfo: "",
  9644. Stage: "1",
  9645. VerifyNumber: ecToken,
  9646. InsuplcAdmdvs: insuOrg,
  9647. }
  9648. service.CreateHisPsn(psn)
  9649. var rf []*ResultFive
  9650. json.Unmarshal([]byte(infoStr), &rf)
  9651. var insutypes []*ResultFive
  9652. var insutype string
  9653. var is390 int = 0
  9654. var is310 int = 0
  9655. for _, item := range rf {
  9656. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9657. insutypes = append(insutypes, item)
  9658. }
  9659. }
  9660. if len(insutypes) == 1 {
  9661. insutype = insutypes[0].Insutype
  9662. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9663. } else {
  9664. for _, i := range insutypes {
  9665. if i.Insutype == "390" {
  9666. is390 = 1
  9667. }
  9668. if i.Insutype == "310" {
  9669. is310 = 1
  9670. }
  9671. }
  9672. }
  9673. if is390 == 1 {
  9674. insutype = "390"
  9675. }
  9676. if is310 == 1 {
  9677. insutype = "310"
  9678. }
  9679. if len(insutypes) == 0 {
  9680. insutype = "310"
  9681. }
  9682. c.ServeSuccessJSON(map[string]interface{}{
  9683. "patient": patient,
  9684. "number": ecToken,
  9685. "insutype": insutype,
  9686. })
  9687. }
  9688. } else {
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9690. return
  9691. }
  9692. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9693. //if initFlag == 0 {
  9694. //c.TestGetJiangXiBasBaseInit()
  9695. //}
  9696. //if initEleFlag == 0 {
  9697. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9698. //}
  9699. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9700. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9701. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9702. type ELeData struct {
  9703. Data struct {
  9704. IdNo string `json:"idNo"`
  9705. IdType string `json:"idType"`
  9706. UserName string `json:"userName"`
  9707. EcToken string `json:"ecToken"`
  9708. InsuOrg string `json:"insuOrg"`
  9709. Gender string `json:"gender"`
  9710. Birthday string `json:"birthday"`
  9711. Nationality string `json:"nationality"`
  9712. Email string `json:"email"`
  9713. Extra string `json:"extra"`
  9714. } `json:"data"`
  9715. Code int `json:"code"`
  9716. Message string `json:"message"`
  9717. }
  9718. var ele ELeData
  9719. err := json.Unmarshal([]byte(result), &ele)
  9720. if err != nil {
  9721. utils.ErrorLog("解析失败:%v", err)
  9722. }
  9723. token := ele.Data.EcToken
  9724. token = Remove0000(token)
  9725. result2, requestLog2 := service.Jxyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, token, "", ele.Data.IdNo, ele.Data.UserName)
  9726. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9727. var res ResultTwo
  9728. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9729. utils.ErrorLog("解析失败:%v", err)
  9730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9731. return
  9732. }
  9733. if res.Infcode == 0 {
  9734. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9735. if err == gorm.ErrRecordNotFound {
  9736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9737. return
  9738. } else if err != nil {
  9739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9740. return
  9741. } else {
  9742. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9743. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9744. infoStr := string(Iinfos)
  9745. idetinfoStr := string(Idetinfos)
  9746. psn := &models.HisPsn{
  9747. PsnNo: res.Output.Baseinfo.PsnNo,
  9748. PatientId: patient.ID,
  9749. Certno: res.Output.Baseinfo.Certno,
  9750. Gend: res.Output.Baseinfo.Gend,
  9751. Naty: res.Output.Baseinfo.Naty,
  9752. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9753. PsnName: res.Output.Baseinfo.PsnName,
  9754. Idetinfo: idetinfoStr,
  9755. Insuinfo: infoStr,
  9756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9757. CardInfo: "",
  9758. VerifyNumber: token,
  9759. }
  9760. service.CreateHisPsn(psn)
  9761. var rf []*ResultFive
  9762. json.Unmarshal([]byte(infoStr), &rf)
  9763. var insutypes []*ResultFive
  9764. var insutype string
  9765. var is390 int = 0
  9766. var is310 int = 0
  9767. for _, item := range rf {
  9768. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9769. insutypes = append(insutypes, item)
  9770. }
  9771. }
  9772. if len(insutypes) == 1 {
  9773. insutype = insutypes[0].Insutype
  9774. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9775. } else {
  9776. for _, i := range insutypes {
  9777. if i.Insutype == "390" {
  9778. is390 = 1
  9779. }
  9780. if i.Insutype == "310" {
  9781. is310 = 1
  9782. }
  9783. }
  9784. }
  9785. if is390 == 1 {
  9786. insutype = "390"
  9787. }
  9788. if is310 == 1 {
  9789. insutype = "310"
  9790. }
  9791. if len(insutypes) == 0 {
  9792. insutype = "310"
  9793. }
  9794. c.ServeSuccessJSON(map[string]interface{}{
  9795. "patient": patient,
  9796. "number": token,
  9797. "insutype": insutype,
  9798. })
  9799. }
  9800. } else {
  9801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9802. return
  9803. }
  9804. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9805. //if initFlag == 0 {
  9806. c.TestGetJiangXiBasBaseInit()
  9807. //}
  9808. //if initEleFlag == 0 {
  9809. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9810. //}
  9811. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9812. type ELeData struct {
  9813. Data struct {
  9814. IdNo string `json:"idNo"`
  9815. IdType string `json:"idType"`
  9816. UserName string `json:"userName"`
  9817. EcToken string `json:"ecToken"`
  9818. InsuOrg string `json:"insuOrg"`
  9819. Gender string `json:"gender"`
  9820. Birthday string `json:"birthday"`
  9821. Nationality string `json:"nationality"`
  9822. Email string `json:"email"`
  9823. Extra string `json:"extra"`
  9824. } `json:"data"`
  9825. Code int `json:"code"`
  9826. Message string `json:"message"`
  9827. }
  9828. var ele ELeData
  9829. err := json.Unmarshal([]byte(json_result), &ele)
  9830. if err != nil {
  9831. utils.ErrorLog("解析失败:%v", err)
  9832. }
  9833. token := ele.Data.EcToken
  9834. token = Remove0000(token)
  9835. 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)
  9836. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9837. var res ResultTwo
  9838. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9839. utils.ErrorLog("解析失败:%v", err)
  9840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9841. return
  9842. }
  9843. if res.Infcode == 0 {
  9844. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9845. if err == gorm.ErrRecordNotFound {
  9846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9847. return
  9848. } else if err != nil {
  9849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9850. return
  9851. } else {
  9852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9854. infoStr := string(Iinfos)
  9855. idetinfoStr := string(Idetinfos)
  9856. psn := &models.HisPsn{
  9857. PsnNo: res.Output.Baseinfo.PsnNo,
  9858. PatientId: patient.ID,
  9859. Certno: res.Output.Baseinfo.Certno,
  9860. Gend: res.Output.Baseinfo.Gend,
  9861. Naty: res.Output.Baseinfo.Naty,
  9862. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9863. PsnName: res.Output.Baseinfo.PsnName,
  9864. Idetinfo: idetinfoStr,
  9865. Insuinfo: infoStr,
  9866. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9867. CardInfo: "",
  9868. VerifyNumber: token,
  9869. }
  9870. service.CreateHisPsn(psn)
  9871. var rf []*ResultFive
  9872. json.Unmarshal([]byte(infoStr), &rf)
  9873. var insutypes []*ResultFive
  9874. var insutype string
  9875. var is390 int = 0
  9876. var is310 int = 0
  9877. for _, item := range rf {
  9878. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9879. insutypes = append(insutypes, item)
  9880. }
  9881. }
  9882. if len(insutypes) == 1 {
  9883. insutype = insutypes[0].Insutype
  9884. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9885. } else {
  9886. for _, i := range insutypes {
  9887. if i.Insutype == "390" {
  9888. is390 = 1
  9889. }
  9890. if i.Insutype == "310" {
  9891. is310 = 1
  9892. }
  9893. }
  9894. }
  9895. if is390 == 1 {
  9896. insutype = "390"
  9897. }
  9898. if is310 == 1 {
  9899. insutype = "310"
  9900. }
  9901. if len(insutypes) == 0 {
  9902. insutype = "310"
  9903. }
  9904. c.ServeSuccessJSON(map[string]interface{}{
  9905. "patient": patient,
  9906. "number": token,
  9907. "insutype": insutype,
  9908. })
  9909. }
  9910. } else {
  9911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9912. return
  9913. }
  9914. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9915. type ELeData struct {
  9916. Code string `json:"code"`
  9917. Data struct {
  9918. Aac002 string `json:"aac002"`
  9919. Aaz500 string `json:"aaz500"`
  9920. ActCardNo string `json:"actCardNo"`
  9921. Bab520 string `json:"bab520"`
  9922. Bkz543 string `json:"bkz543"`
  9923. BusinessType string `json:"businessType"`
  9924. CertfCodg string `json:"certfCodg"`
  9925. EcIndexNo string `json:"ecIndexNo"`
  9926. EcToken string `json:"ecToken"`
  9927. ID0000 string `json:"id0000"`
  9928. IDNo string `json:"idNo"`
  9929. IDType string `json:"idType"`
  9930. Idcode string `json:"idcode"`
  9931. IdentityToken string `json:"identity_token"`
  9932. InsuOrg string `json:"insuOrg"`
  9933. OfficeID string `json:"officeId"`
  9934. OfficeName string `json:"officeName"`
  9935. OperatorID string `json:"operatorId"`
  9936. OperatorName string `json:"operatorName"`
  9937. OrgID string `json:"orgId"`
  9938. UserName string `json:"userName"`
  9939. } `json:"data"`
  9940. Infno interface{} `json:"infno"`
  9941. Message string `json:"message"`
  9942. OrgID string `json:"orgId"`
  9943. TransType string `json:"transType"`
  9944. }
  9945. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9946. outPutInfo = Remove0000(outPutInfo)
  9947. if len(outPutInfo) > 0 {
  9948. var ele ELeData
  9949. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9950. if err != nil {
  9951. utils.ErrorLog("解析失败:%v", err)
  9952. }
  9953. token := ele.Data.EcToken
  9954. fmt.Println(inputInfo)
  9955. fmt.Println(outPutInfo)
  9956. 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)
  9957. saveLog(result, requestLog, "1101", "获取人员信息")
  9958. var dat map[string]interface{}
  9959. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9960. fmt.Println(dat)
  9961. } else {
  9962. fmt.Println(err)
  9963. }
  9964. userJSONBytes, _ := json.Marshal(dat)
  9965. var res ResultTwo
  9966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9967. utils.ErrorLog("解析失败:%v", err)
  9968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9969. return
  9970. }
  9971. res.ErrMsg = errMsgLog
  9972. if res.Infcode == 0 {
  9973. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9974. if err == gorm.ErrRecordNotFound {
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9976. return
  9977. } else if err != nil {
  9978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9979. return
  9980. } else {
  9981. fmt.Println(res)
  9982. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9983. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9984. infoStr := string(Iinfos)
  9985. idetinfoStr := string(Idetinfos)
  9986. psn := &models.HisPsn{
  9987. PsnNo: res.Output.Baseinfo.PsnNo,
  9988. PatientId: patient.ID,
  9989. Certno: res.Output.Baseinfo.Certno,
  9990. Gend: res.Output.Baseinfo.Gend,
  9991. Naty: res.Output.Baseinfo.Naty,
  9992. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9993. PsnName: res.Output.Baseinfo.PsnName,
  9994. Idetinfo: idetinfoStr,
  9995. Insuinfo: infoStr,
  9996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9997. CardInfo: outPutInfo,
  9998. VerifyNumber: token,
  9999. InsuplcAdmdvs: ele.Data.InsuOrg,
  10000. }
  10001. service.CreateHisPsn(psn)
  10002. var rf []*ResultFive
  10003. json.Unmarshal([]byte(infoStr), &rf)
  10004. var insutypes []*ResultFive
  10005. var insutype string
  10006. var is390 int = 0
  10007. var is310 int = 0
  10008. for _, item := range rf {
  10009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10010. insutypes = append(insutypes, item)
  10011. }
  10012. }
  10013. if len(insutypes) == 1 {
  10014. insutype = insutypes[0].Insutype
  10015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10016. } else {
  10017. for _, i := range insutypes {
  10018. if i.Insutype == "390" {
  10019. is390 = 1
  10020. }
  10021. if i.Insutype == "310" {
  10022. is310 = 1
  10023. }
  10024. }
  10025. }
  10026. if is390 == 1 {
  10027. insutype = "390"
  10028. }
  10029. if is310 == 1 {
  10030. insutype = "310"
  10031. }
  10032. if len(insutypes) == 0 {
  10033. insutype = "310"
  10034. }
  10035. c.ServeSuccessJSON(map[string]interface{}{
  10036. "patient": patient,
  10037. "number": token,
  10038. "insutype": insutype,
  10039. })
  10040. }
  10041. } else {
  10042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10043. return
  10044. }
  10045. }
  10046. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10047. var api string
  10048. 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 +
  10049. "&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
  10050. resp, requestErr := http.Get(api)
  10051. if requestErr != nil {
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10053. return
  10054. }
  10055. body, ioErr := ioutil.ReadAll(resp.Body)
  10056. if ioErr != nil {
  10057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10059. return
  10060. }
  10061. var respJSON map[string]interface{}
  10062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10065. return
  10066. }
  10067. var status string
  10068. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10069. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10070. var token string
  10071. var res ResultTwo //1101结果
  10072. var res10265 ResultTwo10265 //1101结果
  10073. if status == "0" { //读卡成功
  10074. var card_info string //卡信息
  10075. var busi_card_info string
  10076. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10077. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10078. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10079. fmt.Println(card_info)
  10080. fmt.Println(busi_card_info)
  10081. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10082. result, _ := json.Marshal(respJSON)
  10083. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10084. utils.ErrorLog("解析失败:%v", err)
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10086. return
  10087. }
  10088. res.ErrMsg = res10265.ErrMsg
  10089. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10090. res.Infcode = infocode
  10091. res.Output = res10265.Output
  10092. res.InfRefmsgid = res10265.InfRefmsgid
  10093. if res.Infcode == 0 {
  10094. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10095. if err == gorm.ErrRecordNotFound {
  10096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10097. return
  10098. } else if err != nil {
  10099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10100. return
  10101. } else {
  10102. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10103. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10104. infoStr := string(Iinfos)
  10105. idetinfoStr := string(Idetinfos)
  10106. psn := &models.HisPsn{
  10107. PsnNo: res.Output.Baseinfo.PsnNo,
  10108. PatientId: patient.ID,
  10109. Certno: res.Output.Baseinfo.Certno,
  10110. Gend: res.Output.Baseinfo.Gend,
  10111. Naty: res.Output.Baseinfo.Naty,
  10112. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10113. PsnName: res.Output.Baseinfo.PsnName,
  10114. Idetinfo: idetinfoStr,
  10115. Insuinfo: infoStr,
  10116. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10117. CardInfo: card_info,
  10118. VerifyNumber: token,
  10119. }
  10120. var rf []*ResultFive
  10121. json.Unmarshal([]byte(infoStr), &rf)
  10122. var insutypes []*ResultFive
  10123. var insutype string
  10124. var is390 int = 0
  10125. var is310 int = 0
  10126. for _, item := range rf {
  10127. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10128. insutypes = append(insutypes, item)
  10129. }
  10130. }
  10131. if len(insutypes) == 1 {
  10132. insutype = insutypes[0].Insutype
  10133. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10134. } else {
  10135. for _, i := range insutypes {
  10136. if i.Insutype == "390" {
  10137. is390 = 1
  10138. }
  10139. if i.Insutype == "310" {
  10140. is310 = 1
  10141. }
  10142. }
  10143. }
  10144. if is390 == 1 {
  10145. insutype = "390"
  10146. }
  10147. if is310 == 1 {
  10148. insutype = "310"
  10149. }
  10150. if len(insutypes) == 0 {
  10151. insutype = "310"
  10152. }
  10153. service.CreateHisPsn(psn)
  10154. c.ServeSuccessJSON(map[string]interface{}{
  10155. "patient": patient,
  10156. "number": token,
  10157. "insutype": insutype,
  10158. })
  10159. }
  10160. } else {
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10162. return
  10163. }
  10164. } else { //读卡失败
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10166. return
  10167. }
  10168. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10169. res := c.GetoleInfo()
  10170. if res.Infcode == 0 {
  10171. var result string
  10172. if res.Output.MdtrtCertType == "01" {
  10173. 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)
  10174. } else if res.Output.MdtrtCertType == "02" {
  10175. 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)
  10176. } else if res.Output.MdtrtCertType == "03" {
  10177. 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)
  10178. }
  10179. var dat map[string]interface{}
  10180. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10181. fmt.Println(dat)
  10182. } else {
  10183. fmt.Println(err)
  10184. }
  10185. userJSONBytes, _ := json.Marshal(dat)
  10186. var res2 ResultTwo
  10187. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10188. utils.ErrorLog("解析失败:%v", err)
  10189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10190. return
  10191. }
  10192. if res2.Infcode == 0 {
  10193. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10194. if err == gorm.ErrRecordNotFound {
  10195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10196. return
  10197. } else if err != nil {
  10198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10199. return
  10200. } else {
  10201. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10202. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10203. infoStr := string(Iinfos)
  10204. idetinfoStr := string(Idetinfos)
  10205. var rf []*ResultFive
  10206. json.Unmarshal([]byte(infoStr), &rf)
  10207. var insutypes []*ResultFive
  10208. var insutype string
  10209. var is390 int = 0
  10210. var is310 int = 0
  10211. //var insuplc_admdvs string
  10212. for _, item := range rf {
  10213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10214. insutypes = append(insutypes, item)
  10215. }
  10216. }
  10217. if len(insutypes) == 1 {
  10218. insutype = insutypes[0].Insutype
  10219. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10220. } else {
  10221. for _, i := range insutypes {
  10222. if i.Insutype == "390" {
  10223. is390 = 1
  10224. }
  10225. if i.Insutype == "310" {
  10226. is310 = 1
  10227. }
  10228. }
  10229. }
  10230. if is390 == 1 {
  10231. insutype = "390"
  10232. }
  10233. if is310 == 1 {
  10234. insutype = "310"
  10235. }
  10236. if len(insutypes) == 0 {
  10237. insutype = "310"
  10238. }
  10239. psn := &models.HisPsn{
  10240. PsnNo: res2.Output.Baseinfo.PsnNo,
  10241. PatientId: patient.ID,
  10242. Certno: res2.Output.Baseinfo.Certno,
  10243. Gend: res2.Output.Baseinfo.Gend,
  10244. Naty: res2.Output.Baseinfo.Naty,
  10245. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10246. PsnName: res2.Output.Baseinfo.PsnName,
  10247. Idetinfo: idetinfoStr,
  10248. Insuinfo: infoStr,
  10249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10250. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10251. VerifyNumber: res.Output.EcToken,
  10252. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10253. }
  10254. if res.Output.MdtrtCertType == "01" {
  10255. psn.VerifyNumber = res.Output.EcToken
  10256. //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)
  10257. } else if res.Output.MdtrtCertType == "02" {
  10258. psn.VerifyNumber = res.Output.CardNo
  10259. //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)
  10260. } else if res.Output.MdtrtCertType == "03" {
  10261. psn.VerifyNumber = res.Output.MdtrtCertNo
  10262. //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)
  10263. }
  10264. service.CreateHisPsn(psn)
  10265. var balc float64
  10266. for _, item := range rf {
  10267. if item.Insutype == insutype {
  10268. balc = item.Balc
  10269. }
  10270. }
  10271. c.ServeSuccessJSON(map[string]interface{}{
  10272. "patient": patient,
  10273. "number": res.Output.CardNo,
  10274. "insutype": insutype,
  10275. "blac": balc,
  10276. "desc": idetinfoStr,
  10277. })
  10278. }
  10279. } else {
  10280. c.ServeSuccessJSON(map[string]interface{}{
  10281. "failed_code": -10,
  10282. "msg": res2.ErrMsg,
  10283. })
  10284. }
  10285. } else {
  10286. c.ServeSuccessJSON(map[string]interface{}{
  10287. "failed_code": -10,
  10288. "msg": res.ErrMsg,
  10289. })
  10290. }
  10291. } else {
  10292. type ELeData struct {
  10293. Code string `json:"code"`
  10294. Data struct {
  10295. Aac002 string `json:"aac002"`
  10296. Aaz500 string `json:"aaz500"`
  10297. ActCardNo string `json:"actCardNo"`
  10298. Bab520 string `json:"bab520"`
  10299. Bkz543 string `json:"bkz543"`
  10300. BusinessType string `json:"businessType"`
  10301. CertfCodg string `json:"certfCodg"`
  10302. EcIndexNo string `json:"ecIndexNo"`
  10303. EcToken string `json:"ecToken"`
  10304. ID0000 string `json:"id0000"`
  10305. IDNo string `json:"idNo"`
  10306. IDType string `json:"idType"`
  10307. Idcode string `json:"idcode"`
  10308. IdentityToken string `json:"identity_token"`
  10309. InsuOrg string `json:"insuOrg"`
  10310. OfficeID string `json:"officeId"`
  10311. OfficeName string `json:"officeName"`
  10312. OperatorID string `json:"operatorId"`
  10313. OperatorName string `json:"operatorName"`
  10314. OrgID string `json:"orgId"`
  10315. UserName string `json:"userName"`
  10316. } `json:"data"`
  10317. Infno interface{} `json:"infno"`
  10318. Message string `json:"message"`
  10319. OrgID string `json:"orgId"`
  10320. TransType string `json:"transType"`
  10321. }
  10322. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10323. fmt.Println(result)
  10324. outPutInfo := Remove0000(result)
  10325. fmt.Println(outPutInfo)
  10326. if len(outPutInfo) > 0 {
  10327. var ele ELeData
  10328. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10329. if err != nil {
  10330. utils.ErrorLog("解析失败:%v", err)
  10331. }
  10332. token := ele.Data.EcToken
  10333. fmt.Println(outPutInfo)
  10334. 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)
  10335. saveLog(result, requestLog, "1101", "获取人员信息")
  10336. var dat map[string]interface{}
  10337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10338. fmt.Println(dat)
  10339. } else {
  10340. fmt.Println(err)
  10341. }
  10342. userJSONBytes, _ := json.Marshal(dat)
  10343. var res ResultTwo
  10344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10345. utils.ErrorLog("解析失败:%v", err)
  10346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10347. return
  10348. }
  10349. if res.Infcode == 0 {
  10350. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10351. if err == gorm.ErrRecordNotFound {
  10352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10353. return
  10354. } else if err != nil {
  10355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10356. return
  10357. } else {
  10358. fmt.Println(res)
  10359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10361. infoStr := string(Iinfos)
  10362. idetinfoStr := string(Idetinfos)
  10363. psn := &models.HisPsn{
  10364. PsnNo: res.Output.Baseinfo.PsnNo,
  10365. PatientId: patient.ID,
  10366. Certno: res.Output.Baseinfo.Certno,
  10367. Gend: res.Output.Baseinfo.Gend,
  10368. Naty: res.Output.Baseinfo.Naty,
  10369. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10370. PsnName: res.Output.Baseinfo.PsnName,
  10371. Idetinfo: idetinfoStr,
  10372. Insuinfo: infoStr,
  10373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10374. CardInfo: outPutInfo,
  10375. VerifyNumber: token,
  10376. InsuplcAdmdvs: ele.Data.InsuOrg,
  10377. }
  10378. service.CreateHisPsn(psn)
  10379. var rf []*ResultFive
  10380. json.Unmarshal([]byte(infoStr), &rf)
  10381. var insutypes []*ResultFive
  10382. var insutype string
  10383. var is390 int = 0
  10384. var is310 int = 0
  10385. for _, item := range rf {
  10386. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10387. insutypes = append(insutypes, item)
  10388. }
  10389. }
  10390. if len(insutypes) == 1 {
  10391. insutype = insutypes[0].Insutype
  10392. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10393. } else {
  10394. for _, i := range insutypes {
  10395. if i.Insutype == "390" {
  10396. is390 = 1
  10397. }
  10398. if i.Insutype == "310" {
  10399. is310 = 1
  10400. }
  10401. }
  10402. }
  10403. if is390 == 1 {
  10404. insutype = "390"
  10405. }
  10406. if is310 == 1 {
  10407. insutype = "310"
  10408. }
  10409. if len(insutypes) == 0 {
  10410. insutype = "310"
  10411. }
  10412. c.ServeSuccessJSON(map[string]interface{}{
  10413. "patient": patient,
  10414. "number": token,
  10415. "insutype": insutype,
  10416. })
  10417. }
  10418. } else {
  10419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10420. return
  10421. }
  10422. }
  10423. //fmt.Println(result)
  10424. //
  10425. //if initFlag == 0 {
  10426. // c.TestGetBasBaseInit()
  10427. //}
  10428. //token := c.GetEleBaseInfo()
  10429. //
  10430. //token = Remove0000(token)
  10431. //
  10432. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10433. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10434. ////
  10435. //var res ResultTwo
  10436. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10437. // utils.ErrorLog("解析失败:%v", err)
  10438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10439. // return
  10440. //}
  10441. //
  10442. //if res.Infcode == 0 {
  10443. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10444. // if err == gorm.ErrRecordNotFound {
  10445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10446. // return
  10447. // } else if err != nil {
  10448. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10449. // return
  10450. //
  10451. // } else {
  10452. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10453. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10454. // infoStr := string(Iinfos)
  10455. // idetinfoStr := string(Idetinfos)
  10456. //
  10457. //
  10458. //
  10459. //
  10460. // var rf []*ResultFive
  10461. // json.Unmarshal([]byte(infoStr), &rf)
  10462. //
  10463. // var insutypes []*ResultFive
  10464. // var insutype string
  10465. // var is390 int = 0
  10466. // var is310 int = 0
  10467. // var insuplc_admdvs string
  10468. //
  10469. // for _, item := range rf {
  10470. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10471. // insutypes = append(insutypes, item)
  10472. // }
  10473. // }
  10474. //
  10475. // if len(insutypes) == 1 {
  10476. // insutype = insutypes[0].Insutype
  10477. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10478. // } else {
  10479. // for _, i := range insutypes {
  10480. // if i.Insutype == "390" {
  10481. // is390 = 1
  10482. // }
  10483. //
  10484. // if i.Insutype == "310" {
  10485. // is310 = 1
  10486. // }
  10487. // }
  10488. // }
  10489. // if is390 == 1 {
  10490. // insutype = "390"
  10491. // }
  10492. //
  10493. // if is310 == 1 {
  10494. // insutype = "310"
  10495. // }
  10496. // if len(insutypes) == 0 {
  10497. // insutype = "310"
  10498. // }
  10499. // for _, item := range rf {
  10500. // if item.Insutype == insutype {
  10501. // insuplc_admdvs = item.InsuplcAdmdvs
  10502. // }
  10503. // }
  10504. // psn := &models.HisPsn{
  10505. // PsnNo: res.Output.Baseinfo.PsnNo,
  10506. // Age: res.Output.Baseinfo.Age,
  10507. // PatientId: patient.ID,
  10508. // Certno: res.Output.Baseinfo.Certno,
  10509. // Brdy: res.Output.Baseinfo.Brdy,
  10510. // Gend: res.Output.Baseinfo.Gend,
  10511. // Naty: res.Output.Baseinfo.Naty,
  10512. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10513. // PsnName: res.Output.Baseinfo.PsnName,
  10514. // Idetinfo: idetinfoStr,
  10515. // Insuinfo: infoStr,
  10516. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10517. // CardInfo: "",
  10518. // VerifyNumber: token,
  10519. // InsuplcAdmdvs: insuplc_admdvs,
  10520. // }
  10521. // service.CreateHisPsn(psn)
  10522. //
  10523. // c.ServeSuccessJSON(map[string]interface{}{
  10524. // "patient": patient,
  10525. // "number": token,
  10526. // })
  10527. // }
  10528. //} else {
  10529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10530. // return
  10531. //}
  10532. }
  10533. break
  10534. case 5:
  10535. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10536. var api string
  10537. if miConfig.MdtrtareaAdmvs == "320921" {
  10538. 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 +
  10539. "&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
  10540. fmt.Println(api)
  10541. } else {
  10542. 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 +
  10543. "&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)
  10544. }
  10545. resp, requestErr := http.Get(api)
  10546. if requestErr != nil {
  10547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10548. return
  10549. }
  10550. body, ioErr := ioutil.ReadAll(resp.Body)
  10551. if ioErr != nil {
  10552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10554. return
  10555. }
  10556. var respJSON map[string]interface{}
  10557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10560. return
  10561. }
  10562. var status string
  10563. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10564. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10565. var token string
  10566. var res ResultTwo //1101结果
  10567. var res10265 ResultTwo10265 //1101结果
  10568. if status == "0" { //读卡成功
  10569. var card_info string //卡信息
  10570. //var busi_card_info string
  10571. var auth_info string
  10572. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10573. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10574. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10575. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10576. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10577. result, _ := json.Marshal(respJSON)
  10578. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10579. utils.ErrorLog("解析失败:%v", err)
  10580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10581. return
  10582. }
  10583. res.ErrMsg = res10265.ErrMsg
  10584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10585. res.Infcode = infocode
  10586. res.Output = res10265.Output
  10587. res.InfRefmsgid = res10265.InfRefmsgid
  10588. if res.Infcode == 0 {
  10589. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10590. if err == gorm.ErrRecordNotFound {
  10591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10592. return
  10593. } else if err != nil {
  10594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10595. return
  10596. } else {
  10597. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10598. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10599. infoStr := string(Iinfos)
  10600. idetinfoStr := string(Idetinfos)
  10601. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10602. psn := &models.HisPsn{
  10603. PsnNo: res.Output.Baseinfo.PsnNo,
  10604. PatientId: patient.ID,
  10605. Certno: res.Output.Baseinfo.Certno,
  10606. Gend: res.Output.Baseinfo.Gend,
  10607. Brdy: b,
  10608. Age: float64(age),
  10609. Naty: res.Output.Baseinfo.Naty,
  10610. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10611. PsnName: res.Output.Baseinfo.PsnName,
  10612. Idetinfo: idetinfoStr,
  10613. Insuinfo: infoStr,
  10614. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10615. CardInfo: card_info,
  10616. VerifyNumber: token,
  10617. AuthInfo: auth_info,
  10618. }
  10619. var rf []*ResultFive
  10620. json.Unmarshal([]byte(infoStr), &rf)
  10621. var insutypes []*ResultFive
  10622. var insutype string
  10623. var is390 int = 0
  10624. var is310 int = 0
  10625. for _, item := range rf {
  10626. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10627. insutypes = append(insutypes, item)
  10628. }
  10629. }
  10630. if len(insutypes) == 1 {
  10631. insutype = insutypes[0].Insutype
  10632. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10633. } else {
  10634. for _, i := range insutypes {
  10635. if i.Insutype == "390" {
  10636. is390 = 1
  10637. }
  10638. if i.Insutype == "310" {
  10639. is310 = 1
  10640. }
  10641. }
  10642. }
  10643. if is390 == 1 {
  10644. insutype = "390"
  10645. }
  10646. if is310 == 1 {
  10647. insutype = "310"
  10648. }
  10649. if len(insutypes) == 0 {
  10650. insutype = "310"
  10651. }
  10652. service.CreateHisPsn(psn)
  10653. c.ServeSuccessJSON(map[string]interface{}{
  10654. "patient": patient,
  10655. "number": token,
  10656. "insutype": insutype,
  10657. })
  10658. }
  10659. } else {
  10660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10661. return
  10662. }
  10663. } else { //读卡失败
  10664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10665. return
  10666. }
  10667. }
  10668. break
  10669. }
  10670. }
  10671. var initFlag int64 = 0
  10672. var initEleFlag int64 = 0
  10673. func (c *HisApiController) TestGetBasBaseInit() {
  10674. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10675. Iinit := DllDef.MustFindProc("Init")
  10676. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10677. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10678. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10679. if ret != 0 {
  10680. fmt.Println("SSCard的报错原因:", err)
  10681. fmt.Println("SSCard的运算结果为:", ret)
  10682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10683. return
  10684. }
  10685. result := int(ret)
  10686. fmt.Println("SSCard的运算结果为1:", result)
  10687. initFlag = 1
  10688. return
  10689. }
  10690. func (c *HisApiController) HandleJiangXiReadCard() {
  10691. fmt.Println("~~~~~~")
  10692. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10693. admin_user_id, _ := c.GetInt64("admin_user_id")
  10694. id_card_type, _ := c.GetInt64("id_card_type")
  10695. //certificates, _ := c.GetInt64("certificates")
  10696. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10697. if initFlag == 0 {
  10698. c.TestGetJiangXiBasBaseInit()
  10699. }
  10700. basStr := c.GetBasBaseInfo()
  10701. if len(basStr) == 0 {
  10702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10703. return
  10704. }
  10705. fmt.Println(basStr)
  10706. bas := strings.Split(basStr, "|")
  10707. basNumber := bas[1]
  10708. fmt.Println(basNumber)
  10709. card_sn := bas[3]
  10710. fmt.Println(card_sn)
  10711. 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, "")
  10712. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10713. var dat map[string]interface{}
  10714. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10715. fmt.Println(dat)
  10716. } else {
  10717. fmt.Println(err)
  10718. }
  10719. userJSONBytes, _ := json.Marshal(dat)
  10720. var res ResultTwo
  10721. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10722. utils.ErrorLog("解析失败:%v", err)
  10723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10724. return
  10725. }
  10726. if res.Infcode == 0 {
  10727. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10728. if err == gorm.ErrRecordNotFound {
  10729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10730. return
  10731. } else if err != nil {
  10732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10733. return
  10734. } else {
  10735. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10736. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10737. infoStr := string(Iinfos)
  10738. idetinfoStr := string(Idetinfos)
  10739. psn := &models.HisPsn{
  10740. PsnNo: res.Output.Baseinfo.PsnNo,
  10741. PatientId: patient.ID,
  10742. Certno: res.Output.Baseinfo.Certno,
  10743. Gend: res.Output.Baseinfo.Gend,
  10744. Naty: res.Output.Baseinfo.Naty,
  10745. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10746. PsnName: res.Output.Baseinfo.PsnName,
  10747. Idetinfo: idetinfoStr,
  10748. Insuinfo: infoStr,
  10749. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10750. CardInfo: basStr,
  10751. VerifyNumber: "",
  10752. }
  10753. service.CreateHisPsn(psn)
  10754. c.ServeSuccessJSON(map[string]interface{}{
  10755. "patient": patient,
  10756. "number": basNumber,
  10757. })
  10758. }
  10759. } else {
  10760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10761. return
  10762. }
  10763. }
  10764. func (c *HisApiController) TestGetHnBasBaseInit() {
  10765. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10766. Iinit := DllDef.MustFindProc("Init")
  10767. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10768. //http://10.77.211.236/CSB/hsa-fsi-1303
  10769. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10770. if ret != 0 {
  10771. fmt.Println("SSCard的报错原因:", err)
  10772. fmt.Println("SSCard的运算结果为:", ret)
  10773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10774. return
  10775. }
  10776. result := int(ret)
  10777. fmt.Println("SSCard的运算结果为1:", result)
  10778. initFlag = 1
  10779. return
  10780. }
  10781. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10782. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10783. Iinit := DllDef.MustFindProc("Init")
  10784. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10785. //http://10.77.211.236/CSB/hsa-fsi-1303
  10786. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10787. if ret != 0 {
  10788. fmt.Println("SSCard的报错原因:", err)
  10789. fmt.Println("SSCard的运算结果为:", ret)
  10790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10791. return
  10792. }
  10793. result := int(ret)
  10794. fmt.Println("SSCard的运算结果为1:", result)
  10795. initFlag = 1
  10796. return
  10797. }
  10798. func (c *HisApiController) GetSFZBaseInfo() string {
  10799. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10800. readCard := DllDef.MustFindProc("ReadSFZ")
  10801. if readCard == nil {
  10802. fmt.Println("readcard is nil")
  10803. readCard = DllDef.MustFindProc("ReadSFZ")
  10804. }
  10805. str := make([]byte, 8096)
  10806. str1 := make([]byte, 8096)
  10807. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10808. fmt.Println(r)
  10809. return Remove0000(string(str))
  10810. }
  10811. func (c *HisApiController) GetEleBaseInfo() string {
  10812. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10813. readCard := DllDef.MustFindProc("GetQRBase")
  10814. fmt.Println(readCard)
  10815. if readCard == nil {
  10816. fmt.Println("readcard is nil")
  10817. readCard = DllDef.MustFindProc("GetQRBase")
  10818. }
  10819. str := make([]byte, 1024)
  10820. str1 := make([]byte, 1024)
  10821. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10822. fmt.Println(ret2)
  10823. fmt.Println(string(str1))
  10824. fmt.Println(string(str))
  10825. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10826. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10827. if ret2 != 0 {
  10828. return ""
  10829. }
  10830. return string(str)
  10831. }
  10832. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10833. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10834. readCard := DllDef.MustFindProc("NationEcTrans")
  10835. fmt.Println(readCard)
  10836. fmt.Println("!!!!!")
  10837. pBusiCardInfo := make([]byte, 2048)
  10838. input := make(map[string]interface{})
  10839. inputData := make(map[string]interface{})
  10840. inputData["orgId"] = code
  10841. inputData["businessType"] = "01101"
  10842. inputData["operatorId"] = "1"
  10843. inputData["operatorName"] = "admin"
  10844. inputData["officeId"] = "001"
  10845. inputData["officeName"] = "血透室"
  10846. inputData["deviceType"] = ""
  10847. input["data"] = inputData
  10848. input["orgId"] = code
  10849. input["transType"] = "ec.query"
  10850. bytesData, _ := json.Marshal(input)
  10851. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10852. fmt.Println(ret2)
  10853. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10854. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10855. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10856. }
  10857. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10858. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10859. readCard := DllDef.MustFindProc("NationEcTrans")
  10860. fmt.Println(readCard)
  10861. fmt.Println("!!!!!")
  10862. pBusiCardInfo := make([]byte, 2048)
  10863. input := make(map[string]interface{})
  10864. inputData := make(map[string]interface{})
  10865. inputData["orgId"] = code
  10866. inputData["businessType"] = "01101"
  10867. inputData["operatorId"] = "9"
  10868. inputData["operatorName"] = "admin"
  10869. inputData["officeId"] = "001"
  10870. inputData["officeName"] = "血透室"
  10871. inputData["deviceType"] = ""
  10872. input["data"] = inputData
  10873. input["orgId"] = code
  10874. input["transType"] = "ec.query"
  10875. bytesData, _ := json.Marshal(input)
  10876. 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])))
  10877. fmt.Println(ret2)
  10878. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10879. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10880. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10881. }
  10882. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10883. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10884. readCard := DllDef.MustFindProc("NationEcTrans")
  10885. fmt.Println(readCard)
  10886. fmt.Println("!!!!!")
  10887. pBusiCardInfo := make([]byte, 2048)
  10888. input := make(map[string]interface{})
  10889. inputData := make(map[string]interface{})
  10890. inputData["orgId"] = code
  10891. inputData["businessType"] = "01301"
  10892. inputData["operatorId"] = "9"
  10893. inputData["operatorName"] = "admin"
  10894. inputData["officeId"] = "001"
  10895. inputData["officeName"] = "血透室"
  10896. inputData["deviceType"] = ""
  10897. input["data"] = inputData
  10898. input["orgId"] = code
  10899. input["transType"] = "ec.query"
  10900. bytesData, _ := json.Marshal(input)
  10901. 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])))
  10902. fmt.Println(ret2)
  10903. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10904. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10905. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10906. }
  10907. func GetJxEleBaseInfo(org_id int64) string {
  10908. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10909. readCard := DllDef.MustFindProc("NationEcTrans")
  10910. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10911. if readCard == nil {
  10912. fmt.Println("readcard is nil")
  10913. readCard = DllDef.MustFindProc("NationEcTrans")
  10914. }
  10915. str1 := make([]byte, 1024)
  10916. data := make(map[string]interface{})
  10917. inputData := make(map[string]interface{})
  10918. inputData["orgId"] = miConfig.Code
  10919. inputData["businessType"] = "01101"
  10920. inputData["operatorId"] = "test001"
  10921. inputData["operatorName"] = "cn"
  10922. inputData["officeId"] = "32760"
  10923. inputData["officeName"] = "waike"
  10924. inputData["deviceType"] = ""
  10925. data["data"] = inputData
  10926. data["transType"] = "ec.query"
  10927. data["extra "] = ""
  10928. data["orgId"] = miConfig.Code
  10929. bytesData, _ := json.Marshal(data)
  10930. //bytesData, _ := json.Marshal(data)
  10931. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10932. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10933. fmt.Println(ret2)
  10934. fmt.Println(string(str1))
  10935. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10936. if ret2 != 0 {
  10937. return ""
  10938. }
  10939. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10940. }
  10941. func GetJxEleBaseInitInfo(org_id int64) string {
  10942. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10943. readCard := DllDef.MustFindProc("NationEcTrans")
  10944. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10945. if readCard == nil {
  10946. fmt.Println("readcard is nil")
  10947. readCard = DllDef.MustFindProc("NationEcTrans")
  10948. }
  10949. str1 := make([]byte, 2048)
  10950. data := make(map[string]interface{})
  10951. inputData := make(map[string]interface{})
  10952. inputData["orgId"] = miConfig.Code
  10953. inputData["businessType"] = "01101"
  10954. inputData["operatorId"] = "1"
  10955. inputData["operatorName"] = "huangchuang"
  10956. inputData["officeId"] = "101"
  10957. inputData["officeName"] = "xuetou"
  10958. inputData["deviceType"] = ""
  10959. data["data"] = inputData
  10960. data["transType"] = "ec.query"
  10961. data["orgId"] = miConfig.Code
  10962. bytesData, _ := json.Marshal(data)
  10963. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10964. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10965. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10966. fmt.Println(ret2)
  10967. fmt.Println(string(str1))
  10968. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10969. if ret2 != 0 {
  10970. return ""
  10971. }
  10972. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10973. initEleFlag = 1
  10974. }
  10975. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10976. }
  10977. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10978. // // 构建命令
  10979. // cmd := exec.Command("python", "b.py")
  10980. //
  10981. // // 执行命令并等待完成
  10982. // output, err := cmd.CombinedOutput()
  10983. // if err != nil {
  10984. // fmt.Println("Error executing Python script:", err)
  10985. // return
  10986. // }
  10987. //
  10988. // // 打印Python脚本的输出
  10989. // fmt.Println(string(output))
  10990. //}
  10991. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10992. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  10993. readCard := DllDef.MustFindProc("gxyb_call")
  10994. if readCard == nil {
  10995. fmt.Println("readcard is nil")
  10996. readCard = DllDef.MustFindProc("gxyb_call")
  10997. }
  10998. str := make([]byte, 1024)
  10999. str1 := make([]byte, 1024)
  11000. //data := make(map[string]interface{})
  11001. currentTime := time.Now()
  11002. // 格式化时间为 "YYYYMMDDHH24MISS"
  11003. formattedTime := currentTime.Format("20060102150405")
  11004. inputData := make(map[string]interface{})
  11005. inputData2 := make(map[string]interface{})
  11006. inputData["transNo"] = "1401"
  11007. inputData["transType"] = "passwordCheck"
  11008. inputData["timestamp"] = formattedTime
  11009. inputData2["fixmedinsCode"] = code
  11010. inputData2["psnNo"] = ""
  11011. inputData["data"] = inputData2
  11012. jsonBytes, err := json.Marshal(inputData)
  11013. if err != nil {
  11014. fmt.Println("Error encoding map to JSON:", err)
  11015. }
  11016. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11017. fmt.Println(string(str1))
  11018. fmt.Println(string(str))
  11019. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11020. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11021. if ret2 != 0 {
  11022. return ""
  11023. }
  11024. return string(str)
  11025. }
  11026. func (c *HisApiController) GetoleInfo() Response {
  11027. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11028. defer ole.CoUninitialize()
  11029. // Replace with the ProgID or CLSID of your COM object
  11030. progID := "YinHai.XJ.Actual.Interface.New"
  11031. // Create COM object
  11032. unknown, err := oleutil.CreateObject(progID)
  11033. if err != nil {
  11034. fmt.Println("Unable to create COM object:", err)
  11035. }
  11036. defer unknown.Release()
  11037. // Query for the IDispatch interface
  11038. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11039. if err != nil {
  11040. fmt.Println("Unable to get IDispatch interface:", err)
  11041. }
  11042. defer dispatch.Release()
  11043. // Prepare parameters
  11044. transNo := "1401"
  11045. transType := "passwordCheck"
  11046. timestamp := time.Now().Unix()
  11047. fixmedinsCode := "H45072101171"
  11048. psnNo := ""
  11049. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11050. result2 := ""
  11051. // Call COM object's method using the IDispatch interface
  11052. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11053. fmt.Println(resulr)
  11054. fmt.Println(result2)
  11055. if err != nil {
  11056. fmt.Println("调用COM对象方法失败:", err)
  11057. }
  11058. var response Response
  11059. err2 := json.Unmarshal([]byte(result2), &response)
  11060. if err2 != nil {
  11061. fmt.Println("解析JSON失败:", err)
  11062. }
  11063. return response
  11064. }
  11065. func (c *HisApiController) GetBasBaseInfo() string {
  11066. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11067. readCard := DllDef.MustFindProc("ReadCardBas")
  11068. if readCard == nil {
  11069. fmt.Println("readcard is nil")
  11070. readCard = DllDef.MustFindProc("ReadCardBas")
  11071. }
  11072. str := make([]byte, 1024)
  11073. str1 := make([]byte, 1024)
  11074. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11075. fmt.Println(string(str1))
  11076. fmt.Println(string(str))
  11077. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11078. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11079. if ret2 != 0 {
  11080. return ""
  11081. }
  11082. return string(str)
  11083. }
  11084. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11085. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11086. readCard := DllDef.MustFindProc("read_cardinfo")
  11087. if readCard == nil {
  11088. fmt.Println("readcard is nil")
  11089. readCard = DllDef.MustFindProc("read_cardinfo")
  11090. }
  11091. str := make([]byte, 1024) //卡号
  11092. str1 := make([]byte, 1024) //卡识别码
  11093. str2 := make([]byte, 1024) //身份证号
  11094. str3 := make([]byte, 1024) //姓名
  11095. str4 := make([]byte, 1024) //错误信息
  11096. 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])))
  11097. fmt.Println(string(str1))
  11098. fmt.Println(string(str))
  11099. fmt.Println(string(str2))
  11100. fmt.Println(string(str3))
  11101. fmt.Println(string(str4))
  11102. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11103. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11104. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11105. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11106. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11107. if ret2 != 0 {
  11108. return "", "", "", "", ""
  11109. }
  11110. return string(str), string(str1), string(str2), string(str3), string(str4)
  11111. }
  11112. type CustomFundPay struct {
  11113. FundPayType string `json:"fund_pay_type"`
  11114. FundPayamt float64 `json:"fund_payamt"`
  11115. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11116. }
  11117. //func (c *HisApiController) GetBatchSettleList() {
  11118. // start_time_str := c.GetString("start_time")
  11119. // //end_time_str := c.GetString("end_time")
  11120. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11121. //
  11122. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11123. //
  11124. // for _, item := range orders {
  11125. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11126. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11127. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11128. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11129. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11130. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11131. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11132. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11133. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11134. //
  11135. // if order.ID == 0 {
  11136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11137. // return
  11138. // }
  11139. //
  11140. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11141. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11142. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11143. // //fmt.Println(count)
  11144. // //var zero string
  11145. // //number := count + 1
  11146. // //if number >= 1000 {
  11147. // // zero = "0000" + strconv.FormatInt(number, 10)
  11148. // //} else if number >= 10000 {
  11149. // // zero = "000" + strconv.FormatInt(number, 10)
  11150. // //} else if number >= 100000 {
  11151. // // zero = "00" + strconv.FormatInt(number, 10)
  11152. // //} else if number >= 1000000 {
  11153. // // zero = "0" + strconv.FormatInt(number, 10)
  11154. // //} else {
  11155. // // zero = strconv.FormatInt(number, 10)
  11156. // //}
  11157. // //fmt.Println(zero)
  11158. //
  11159. // struct4101 := service.Struct4101{
  11160. // PsnNo: order.PsnNo,
  11161. // MdtrtId: order.MdtrtId,
  11162. // SetlId: order.SetlId,
  11163. // PsnName: order.PsnName,
  11164. // Gend: order.Gend,
  11165. // Brdy: his.Brdy,
  11166. // Age: his.Age,
  11167. // Naty: order.Naty,
  11168. // PatnCertType: "01",
  11169. // Certno: order.Certno,
  11170. // Prfs: "90",
  11171. // ConerName: roles[0].UserName,
  11172. // PatnRlts: "99",
  11173. // ConerAddr: miConfig.OrgName,
  11174. // ConerTel: admin.Mobile,
  11175. // HiType: order.Insutype,
  11176. // Insuplc: miConfig.InsuplcAdmdvs,
  11177. // MaindiagFlag: "1",
  11178. // BillCode: order.SetlId,
  11179. // BillNo: order.SetlId,
  11180. // BizSn: order.Number,
  11181. // PsnSelfPay: order.PsnPartAmt,
  11182. // PsnOwnPay: order.PsnPartAmt,
  11183. // AcctPay: order.AcctPay,
  11184. // PsnCashpay: order.PsnCashPay,
  11185. // HiPaymtd: "1",
  11186. // Hsorg: miConfig.InsuplcAdmdvs,
  11187. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11188. // MedinsFillPsn: curRoles.UserName,
  11189. // MedinsFillDept: miConfig.OrgName,
  11190. // IptMedType: "2",
  11191. // }
  11192. // struct4101.SetlBegnDate = order.SetlTime
  11193. // struct4101.SetlEndDate = order.SetlTime
  11194. // time_arr := strings.Split(order.SetlTime, " ")
  11195. // struct4101.AdmTime = time_arr[0]
  11196. // struct4101.AdmEndTime = time_arr[0]
  11197. //
  11198. // var rf []CustomFundPay
  11199. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11200. //
  11201. // var tempFunPays []service.CustomStruct
  11202. // for _, item := range rf {
  11203. // var tempFunPay service.CustomStruct
  11204. // tempFunPay.FundPayamt = item.FundPayamt
  11205. // tempFunPay.FundPayType = item.FundPayType
  11206. // tempFunPays = append(tempFunPays, tempFunPay)
  11207. // }
  11208. // struct4101.CustomStruct = tempFunPays
  11209. //
  11210. // var tempDiaginfos []service.DiaginfoStructTwo
  11211. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11212. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11213. //
  11214. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11215. // var config []*models.HisXtDiagnoseConfig
  11216. // for _, item := range diagnosis_ids {
  11217. // id, _ := strconv.ParseInt(item, 10, 64)
  11218. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11219. // config = append(config, &diagnosisConfig)
  11220. // }
  11221. //
  11222. // for index, item := range config {
  11223. // if index == 0 {
  11224. // var tempDiaginfo service.DiaginfoStructTwo
  11225. // tempDiaginfo.DiagCode = item.CountryCode
  11226. // tempDiaginfo.DiagName = item.CountryContentName
  11227. // tempDiaginfo.DiagType = "1"
  11228. // tempDiaginfo.MaindiagFlag = "1"
  11229. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11230. // } else {
  11231. // var tempDiaginfo service.DiaginfoStructTwo
  11232. // tempDiaginfo.DiagCode = item.CountryCode
  11233. // tempDiaginfo.DiagName = item.CountryContentName
  11234. // tempDiaginfo.DiagType = "1"
  11235. // tempDiaginfo.MaindiagFlag = "0"
  11236. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11237. // }
  11238. // }
  11239. // struct4101.Diseinfo = tempDiaginfos
  11240. //
  11241. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11242. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11243. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11244. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11245. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11246. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11247. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11248. //
  11249. // var iteminfo service.IteminfoStruct
  11250. //
  11251. // var bedCostTotal float64 = 0 //床位总费
  11252. // var bedCostSelfTotal float64 = 0 //床位自费
  11253. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11254. //
  11255. // var operationCostTotal float64 = 0 //手术费
  11256. // var operationCostSelfTotal float64 = 0 //手术费
  11257. // var operationCostPartSelfTotal float64 = 0 //手术费
  11258. //
  11259. // var otherCostTotal float64 = 0 //其他费用
  11260. // var otherCostSelfTotal float64 = 0 //其他费用
  11261. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11262. //
  11263. // var materialCostTotal float64 = 0 //材料费
  11264. // var materialCostSelfTotal float64 = 0 //材料费
  11265. // var materialCostPartSelfTotal float64 = 0 //材料费
  11266. //
  11267. // var westernMedicineCostTotal float64 = 0 //西药费
  11268. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11269. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11270. //
  11271. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11272. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11273. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11274. //
  11275. // var checkCostTotal float64 = 0 //检查费
  11276. // var checkCostSelfTotal float64 = 0 //检查费
  11277. // var checkCostPartSelfTotal float64 = 0 //检查费
  11278. //
  11279. // var laboratoryCostTotal float64 = 0 //化验费
  11280. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11281. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11282. //
  11283. // var treatCostTotal float64 = 0 //治疗费用
  11284. // var treatCostSelfTotal float64 = 0 //治疗费用
  11285. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11286. //
  11287. // decimal.DivisionPrecision = 2
  11288. //
  11289. // var bed_fulamt_ownpay_amt float64 = 0
  11290. // var operation_fulamt_ownpay_amt float64 = 0
  11291. // var other_fulamt_ownpay_amt float64 = 0
  11292. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11293. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11294. // var check_fulamt_ownpay_amt float64 = 0
  11295. // var material_fulamt_ownpay_amt float64 = 0
  11296. // var laboratory_fulamt_ownpay_amt float64 = 0
  11297. // var treat_fulamt_ownpay_amt float64 = 0
  11298. //
  11299. // var bed_claa_sunmfee float64 = 0
  11300. // var bed_clab_amt float64 = 0
  11301. // var bed_other_amt float64 = 0
  11302. //
  11303. // var operation_claa_sunmfee float64 = 0
  11304. // var operation_clab_amt float64 = 0
  11305. // var operation_other_amt float64 = 0
  11306. //
  11307. // var other_claa_sunmfee float64 = 0
  11308. // var other_clab_amt float64 = 0
  11309. // var other_other_amt float64 = 0
  11310. //
  11311. // var westernMedicine_claa_sunmfee float64 = 0
  11312. // var westernMedicine_clab_amt float64 = 0
  11313. // var westernMedicine_other_amt float64 = 0
  11314. //
  11315. // var chineseTraditional_claa_sunmfee float64 = 0
  11316. // var chineseTraditional_clab_amt float64 = 0
  11317. // var chineseTraditional_other_amt float64 = 0
  11318. //
  11319. // var check_claa_sunmfee float64 = 0
  11320. // var check_clab_amt float64 = 0
  11321. // var check_other_amt float64 = 0
  11322. //
  11323. // var material_claa_sunmfee float64 = 0
  11324. // var material_clab_amt float64 = 0
  11325. // var material_other_amt float64 = 0
  11326. //
  11327. // var laboratory_claa_sunmfee float64 = 0
  11328. // var laboratory_clab_amt float64 = 0
  11329. // var laboratory_other_amt float64 = 0
  11330. //
  11331. // var treat_claa_sunmfee float64 = 0
  11332. // var treat_clab_amt float64 = 0
  11333. // var treat_other_amt float64 = 0
  11334. //
  11335. // for _, item := range order.HisOrderInfo {
  11336. // if item.MedChrgitmType == "01" { //床位费
  11337. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11338. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11339. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11340. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11341. // if item.ChrgitmLv == "1" {
  11342. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11343. // }
  11344. // if item.ChrgitmLv == "2" {
  11345. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11346. //
  11347. // }
  11348. // if item.ChrgitmLv == "3" {
  11349. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11350. // }
  11351. //
  11352. // }
  11353. //
  11354. // if item.MedChrgitmType == "03" { //检查费
  11355. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11356. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11357. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11358. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11359. // if item.ChrgitmLv == "1" {
  11360. //
  11361. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11362. //
  11363. // }
  11364. // if item.ChrgitmLv == "2" {
  11365. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11366. //
  11367. // }
  11368. // if item.ChrgitmLv == "3" {
  11369. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11370. // }
  11371. // }
  11372. //
  11373. // if item.MedChrgitmType == "04" { //化验费
  11374. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11375. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11376. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11377. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11378. // if item.ChrgitmLv == "1" {
  11379. //
  11380. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11381. //
  11382. // }
  11383. // if item.ChrgitmLv == "2" {
  11384. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11385. //
  11386. // }
  11387. // if item.ChrgitmLv == "3" {
  11388. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11389. // }
  11390. // }
  11391. //
  11392. // if item.MedChrgitmType == "05" { //治疗费
  11393. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11394. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11395. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11396. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11397. // if item.ChrgitmLv == "1" {
  11398. //
  11399. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11400. //
  11401. // }
  11402. // if item.ChrgitmLv == "2" {
  11403. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11404. //
  11405. // }
  11406. // if item.ChrgitmLv == "3" {
  11407. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11408. // }
  11409. // }
  11410. //
  11411. // if item.MedChrgitmType == "06" { //手术费
  11412. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11413. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11414. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11415. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11416. //
  11417. // if item.ChrgitmLv == "1" {
  11418. //
  11419. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11420. //
  11421. // }
  11422. // if item.ChrgitmLv == "2" {
  11423. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11424. //
  11425. // }
  11426. // if item.ChrgitmLv == "3" {
  11427. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11428. // }
  11429. // }
  11430. //
  11431. // if item.MedChrgitmType == "08" { //材料费
  11432. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11433. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11434. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11435. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11436. // if item.ChrgitmLv == "1" {
  11437. //
  11438. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11439. //
  11440. // }
  11441. // if item.ChrgitmLv == "2" {
  11442. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11443. //
  11444. // }
  11445. // if item.ChrgitmLv == "3" {
  11446. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11447. // }
  11448. // }
  11449. //
  11450. // if item.MedChrgitmType == "09" { //西药费
  11451. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11452. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11453. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11454. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11455. // if item.ChrgitmLv == "1" {
  11456. //
  11457. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11458. //
  11459. // }
  11460. // if item.ChrgitmLv == "2" {
  11461. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11462. //
  11463. // }
  11464. // if item.ChrgitmLv == "3" {
  11465. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11466. // }
  11467. // }
  11468. //
  11469. // if item.MedChrgitmType == "11" { //中成费
  11470. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11471. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11472. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11473. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11474. // if item.ChrgitmLv == "1" {
  11475. //
  11476. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11477. //
  11478. // }
  11479. // if item.ChrgitmLv == "2" {
  11480. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11481. //
  11482. // }
  11483. // if item.ChrgitmLv == "3" {
  11484. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11485. // }
  11486. // }
  11487. //
  11488. // if item.MedChrgitmType == "14" { //其他费
  11489. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11490. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11491. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11492. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11493. // if item.ChrgitmLv == "1" {
  11494. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11495. //
  11496. // }
  11497. // if item.ChrgitmLv == "2" {
  11498. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11499. //
  11500. // }
  11501. // if item.ChrgitmLv == "3" {
  11502. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11503. // }
  11504. // }
  11505. //
  11506. // }
  11507. //
  11508. // var iteminfoStructs []service.IteminfoStruct
  11509. //
  11510. // if bedCostTotal != 0 {
  11511. // iteminfo.MedChrgitm = "01"
  11512. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11513. // iteminfo.Amt = bedCostTotal
  11514. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11515. // iteminfo.ClabAmt = bed_clab_amt
  11516. // iteminfo.OthAmt = bed_other_amt
  11517. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11518. // }
  11519. //
  11520. // if checkCostTotal != 0 {
  11521. // iteminfo.MedChrgitm = "03"
  11522. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11523. // iteminfo.Amt = checkCostTotal
  11524. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11525. // iteminfo.ClabAmt = check_clab_amt
  11526. // iteminfo.OthAmt = check_other_amt
  11527. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11528. //
  11529. // }
  11530. //
  11531. // if laboratoryCostTotal != 0 {
  11532. // iteminfo.MedChrgitm = "04"
  11533. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11534. // iteminfo.Amt = laboratoryCostTotal
  11535. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11536. // iteminfo.ClabAmt = laboratory_clab_amt
  11537. // iteminfo.OthAmt = laboratory_other_amt
  11538. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11539. //
  11540. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11541. //
  11542. // }
  11543. //
  11544. // if treatCostTotal != 0 {
  11545. // iteminfo.MedChrgitm = "05"
  11546. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11547. // iteminfo.Amt = treatCostTotal
  11548. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11549. // iteminfo.ClabAmt = treat_clab_amt
  11550. // iteminfo.OthAmt = treat_other_amt
  11551. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11552. // //(struct4101.IteminfoStruct, iteminfo)
  11553. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11554. // }
  11555. //
  11556. // if operationCostTotal != 0 {
  11557. // iteminfo.MedChrgitm = "06"
  11558. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11559. // iteminfo.Amt = operationCostTotal
  11560. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11561. // iteminfo.ClabAmt = operation_clab_amt
  11562. // iteminfo.OthAmt = operation_other_amt
  11563. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11564. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11565. // }
  11566. //
  11567. // if materialCostTotal != 0 {
  11568. // iteminfo.MedChrgitm = "08"
  11569. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11570. // iteminfo.Amt = materialCostTotal
  11571. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11572. // iteminfo.ClabAmt = material_clab_amt
  11573. // iteminfo.OthAmt = material_other_amt
  11574. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11575. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11576. // }
  11577. //
  11578. // if westernMedicineCostTotal != 0 {
  11579. // iteminfo.MedChrgitm = "09"
  11580. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11581. // iteminfo.Amt = westernMedicineCostTotal
  11582. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11583. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11584. // iteminfo.OthAmt = westernMedicine_other_amt
  11585. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11586. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11587. //
  11588. // }
  11589. // if chineseTraditionalMedicineCostTotal != 0 {
  11590. // iteminfo.MedChrgitm = "11"
  11591. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11592. // iteminfo.Amt = westernMedicineCostTotal
  11593. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11594. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11595. // iteminfo.OthAmt = westernMedicine_other_amt
  11596. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11597. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11598. //
  11599. // }
  11600. // if otherCostTotal != 0 {
  11601. // iteminfo.MedChrgitm = "14"
  11602. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11603. // iteminfo.Amt = otherCostTotal
  11604. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11605. // iteminfo.ClabAmt = other_clab_amt
  11606. // iteminfo.OthAmt = other_other_amt
  11607. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11608. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11609. //
  11610. // }
  11611. // struct4101.IteminfoStruct = iteminfoStructs
  11612. // struct4101.Ntly = "中国"
  11613. // struct4101.AdmCaty = "A03.06"
  11614. //
  11615. // struct4101.DoctorName = doctor.UserName
  11616. // struct4101.DoctorCode = doctor.DoctorNumber
  11617. //
  11618. // var res ResultSeventeen
  11619. //
  11620. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11621. // struct4101.BillCode = order.Number
  11622. // struct4101.BillNo = order.SetlId
  11623. // var resOther ResultSeventeenOther
  11624. // var pp models.PublicParams
  11625. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11626. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11627. // pp.FixmedinsName = miConfig.OrgName
  11628. // pp.FixmedinsCode = miConfig.Code
  11629. // pp.RequestUrl = miConfig.Url
  11630. // pp.Cainfo = miConfig.Cainfo
  11631. // pp.SecretKey = miConfig.SecretKey
  11632. // pp.AccessKey = miConfig.AccessKey
  11633. // pp.OpterName = curRoles.UserName
  11634. //
  11635. // client := &http.Client{}
  11636. // var req *http.Request
  11637. // data := make(map[string]interface{})
  11638. // data["struct4101"] = struct4101
  11639. // data["pp"] = pp
  11640. // bytesData, _ := json.Marshal(data)
  11641. // if miConfig.MdtrtareaAdmvs == "320921" {
  11642. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11643. // } else {
  11644. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11645. // }
  11646. // resp, _ := client.Do(req)
  11647. // defer resp.Body.Close()
  11648. // body, ioErr := ioutil.ReadAll(resp.Body)
  11649. // if ioErr != nil {
  11650. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11652. // return
  11653. // }
  11654. // var respJSON map[string]interface{}
  11655. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11656. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11657. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11658. // return
  11659. // }
  11660. //
  11661. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11662. // userJSONBytes, _ := json.Marshal(respJSON)
  11663. // fmt.Println("log")
  11664. // fmt.Println(string(userJSONBytes))
  11665. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11666. // utils.ErrorLog("解析失败:%v", err)
  11667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11668. // return
  11669. // }
  11670. // res.InfRefmsgid = resOther.InfRefmsgid
  11671. // res.Output = resOther.Output
  11672. // res.ErrMsg = resOther.ErrMsg
  11673. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11674. // res.Infcode = infocode
  11675. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11676. //
  11677. // var pp models.PublicParams
  11678. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11679. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11680. // pp.FixmedinsName = miConfig.OrgName
  11681. // pp.FixmedinsCode = miConfig.Code
  11682. // pp.RequestUrl = miConfig.Url
  11683. // pp.Cainfo = miConfig.Cainfo
  11684. // pp.SecretKey = miConfig.SecretKey
  11685. // pp.AccessKey = miConfig.AccessKey
  11686. // pp.OpterName = curRoles.UserName
  11687. // result, _ := service.Jxyb4101(struct4101, pp)
  11688. // var dat map[string]interface{}
  11689. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11690. // fmt.Println(dat)
  11691. // } else {
  11692. // fmt.Println(err)
  11693. // }
  11694. // userJSONBytes, _ := json.Marshal(dat)
  11695. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11696. // utils.ErrorLog("解析失败:%v", err)
  11697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11698. // return
  11699. // }
  11700. //
  11701. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11702. // var pp models.PublicParams
  11703. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11704. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11705. // pp.FixmedinsName = miConfig.OrgName
  11706. // pp.FixmedinsCode = miConfig.Code
  11707. // pp.RequestUrl = miConfig.Url
  11708. // pp.Cainfo = miConfig.Cainfo
  11709. // pp.SecretKey = miConfig.SecretKey
  11710. // pp.AccessKey = miConfig.AccessKey
  11711. // pp.OpterName = curRoles.UserName
  11712. // result, _ := service.Hnyb4101(struct4101, pp)
  11713. // var dat map[string]interface{}
  11714. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11715. // fmt.Println(dat)
  11716. // } else {
  11717. // fmt.Println(err)
  11718. // }
  11719. // userJSONBytes, _ := json.Marshal(dat)
  11720. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11721. // utils.ErrorLog("解析失败:%v", err)
  11722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11723. // return
  11724. // }
  11725. //
  11726. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11727. // var resOther ResultSeventeenOther
  11728. //
  11729. // var pp models.PublicParams
  11730. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11731. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11732. // pp.FixmedinsName = miConfig.OrgName
  11733. // pp.FixmedinsCode = miConfig.Code
  11734. // pp.RequestUrl = miConfig.Url
  11735. // pp.Cainfo = miConfig.Cainfo
  11736. // pp.SecretKey = miConfig.SecretKey
  11737. // pp.AccessKey = miConfig.AccessKey
  11738. // pp.OpterName = curRoles.UserName
  11739. // client := &http.Client{}
  11740. // var req *http.Request
  11741. // data := make(map[string]interface{})
  11742. // data["struct4101"] = struct4101
  11743. // data["pp"] = pp
  11744. // bytesData, _ := json.Marshal(data)
  11745. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11746. // resp, _ := client.Do(req)
  11747. // defer resp.Body.Close()
  11748. // body, ioErr := ioutil.ReadAll(resp.Body)
  11749. // if ioErr != nil {
  11750. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11751. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11752. // return
  11753. // }
  11754. // var respJSON map[string]interface{}
  11755. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11756. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11757. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11758. // return
  11759. // }
  11760. //
  11761. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11762. // userJSONBytes, _ := json.Marshal(respJSON)
  11763. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11764. // utils.ErrorLog("解析失败:%v", err)
  11765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11766. // return
  11767. // }
  11768. // res.InfRefmsgid = resOther.InfRefmsgid
  11769. // res.Output = resOther.Output
  11770. // res.ErrMsg = resOther.ErrMsg
  11771. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11772. // res.Infcode = infocode
  11773. //
  11774. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11775. // var pp models.PublicParams
  11776. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11777. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11778. // pp.FixmedinsName = miConfig.OrgName
  11779. // pp.FixmedinsCode = miConfig.Code
  11780. // pp.RequestUrl = miConfig.Url
  11781. // pp.Cainfo = miConfig.Cainfo
  11782. // pp.SecretKey = miConfig.SecretKey
  11783. // pp.AccessKey = miConfig.AccessKey
  11784. // pp.OpterName = curRoles.UserName
  11785. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11786. // fmt.Println(requestLog)
  11787. // fmt.Println(errMsgLog)
  11788. //
  11789. // saveLog(result, requestLog, "4101a", "上传清单")
  11790. //
  11791. // var dat map[string]interface{}
  11792. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11793. // fmt.Println(dat)
  11794. // } else {
  11795. // fmt.Println(err)
  11796. // }
  11797. // userJSONBytes, _ := json.Marshal(dat)
  11798. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11799. // utils.ErrorLog("解析失败:%v", err)
  11800. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11801. // return
  11802. // }
  11803. //
  11804. // } else {
  11805. //
  11806. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11807. // var dat map[string]interface{}
  11808. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11809. // fmt.Println(dat)
  11810. // } else {
  11811. // fmt.Println(err)
  11812. // }
  11813. // userJSONBytes, _ := json.Marshal(dat)
  11814. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11815. // utils.ErrorLog("解析失败:%v", err)
  11816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11817. // return
  11818. // }
  11819. // }
  11820. //
  11821. // if res.Infcode != 0 {
  11822. // adminUser := c.GetAdminUserInfo()
  11823. // errlog := &models.HisOrderError{
  11824. // UserOrgId: adminUser.CurrentOrgId,
  11825. // Ctime: time.Now().Unix(),
  11826. // Mtime: time.Now().Unix(),
  11827. // ErrMsg: res.ErrMsg,
  11828. // Status: 1,
  11829. // PatientId: order.ID,
  11830. // Stage: 10265,
  11831. // }
  11832. // service.CreateErrMsgLog(errlog)
  11833. // continue
  11834. // } else {
  11835. // //order.FaPiaoNumber = zero
  11836. // //order.FaPiaoCode = last_order.FaPiaoCode
  11837. // //service.UpdateOrder(order)
  11838. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11839. // Number: res.Output.SetlListId,
  11840. // Status: 1,
  11841. // Ctime: time.Now().Unix(),
  11842. // Mtime: time.Now().Unix(),
  11843. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11844. // IsUpload: 1,
  11845. // OrderId: order.ID,
  11846. // }
  11847. // service.CreateUploadRecord(hisFundSettleListResult)
  11848. // c.ServeSuccessJSON(map[string]interface{}{
  11849. // "msg": "上传成功",
  11850. // "result": hisFundSettleListResult,
  11851. // })
  11852. // continue
  11853. // }
  11854. // }
  11855. //}
  11856. func (c *HisApiController) GetbatchSettleList() {
  11857. //order_id, _ := c.GetInt64("order_id")
  11858. admin_user_id, _ := c.GetInt64("admin_user_id")
  11859. orders, _ := service.GetAllHisOrderTwo10485()
  11860. for _, item := range orders {
  11861. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11862. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11863. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11864. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11865. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11866. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11867. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11868. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11869. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11870. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11871. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11872. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11873. //fmt.Println(count)
  11874. //var zero string
  11875. //number := count + 1
  11876. //if number >= 1000 {
  11877. // zero = "0000" + strconv.FormatInt(number, 10)
  11878. //} else if number >= 10000 {
  11879. // zero = "000" + strconv.FormatInt(number, 10)
  11880. //} else if number >= 100000 {
  11881. // zero = "00" + strconv.FormatInt(number, 10)
  11882. //} else if number >= 1000000 {
  11883. // zero = "0" + strconv.FormatInt(number, 10)
  11884. //} else {
  11885. // zero = strconv.FormatInt(number, 10)
  11886. //}
  11887. //fmt.Println(zero)
  11888. struct4101 := service.Struct4101{
  11889. PsnNo: order.PsnNo,
  11890. MdtrtId: order.MdtrtId,
  11891. SetlId: order.SetlId,
  11892. PsnName: order.PsnName,
  11893. Gend: order.Gend,
  11894. Brdy: his.Brdy,
  11895. Age: his.Age,
  11896. Naty: order.Naty,
  11897. PatnCertType: "01",
  11898. Certno: order.Certno,
  11899. Prfs: "90",
  11900. ConerName: roles[0].UserName,
  11901. PatnRlts: "99",
  11902. ConerAddr: miConfig.OrgName,
  11903. ConerTel: admin.Mobile,
  11904. HiType: order.Insutype,
  11905. Insuplc: miConfig.InsuplcAdmdvs,
  11906. MaindiagFlag: "1",
  11907. BillCode: order.SetlId,
  11908. BillNo: order.SetlId,
  11909. BizSn: order.Number,
  11910. PsnSelfPay: order.PsnPartAmt,
  11911. PsnOwnPay: order.PsnPartAmt,
  11912. AcctPay: order.AcctPay,
  11913. PsnCashpay: order.PsnCashPay,
  11914. HiPaymtd: "1",
  11915. Hsorg: miConfig.InsuplcAdmdvs,
  11916. HsorgOpter: miConfig.InsuplcAdmdvs,
  11917. MedinsFillPsn: curRoles.UserName,
  11918. MedinsFillDept: miConfig.OrgName,
  11919. IptMedType: "2",
  11920. }
  11921. struct4101.SetlBegnDate = order.SetlTime
  11922. struct4101.SetlEndDate = order.SetlTime
  11923. time_arr := strings.Split(order.SetlTime, " ")
  11924. struct4101.AdmTime = time_arr[0]
  11925. struct4101.AdmEndTime = time_arr[0]
  11926. //var rf []CustomFundPay
  11927. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11928. //
  11929. //var tempFunPays []service.CustomStruct
  11930. //for _, item := range rf {
  11931. // var tempFunPay service.CustomStruct
  11932. // tempFunPay.FundPayamt = item.FundPayamt
  11933. // tempFunPay.FundPayType = item.FundPayType
  11934. // tempFunPays = append(tempFunPays, tempFunPay)
  11935. //}
  11936. //struct4101.CustomStruct = tempFunPays
  11937. var tempDiaginfos []service.DiaginfoStructTwo
  11938. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11939. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11940. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11941. var config []*models.HisXtDiagnoseConfig
  11942. for _, item := range diagnosis_ids {
  11943. id, _ := strconv.ParseInt(item, 10, 64)
  11944. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11945. config = append(config, &diagnosisConfig)
  11946. }
  11947. for index, item := range config {
  11948. if index == 0 {
  11949. var tempDiaginfo service.DiaginfoStructTwo
  11950. tempDiaginfo.DiagCode = item.CountryCode
  11951. tempDiaginfo.DiagName = item.CountryContentName
  11952. tempDiaginfo.DiagType = "1"
  11953. tempDiaginfo.MaindiagFlag = "1"
  11954. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11955. } else {
  11956. var tempDiaginfo service.DiaginfoStructTwo
  11957. tempDiaginfo.DiagCode = item.CountryCode
  11958. tempDiaginfo.DiagName = item.CountryContentName
  11959. tempDiaginfo.DiagType = "1"
  11960. tempDiaginfo.MaindiagFlag = "0"
  11961. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11962. }
  11963. }
  11964. struct4101.Diseinfo = tempDiaginfos
  11965. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11966. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11967. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11968. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11969. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11970. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11971. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11972. var iteminfo service.IteminfoStruct
  11973. var bedCostTotal float64 = 0 //床位总费
  11974. var bedCostSelfTotal float64 = 0 //床位自费
  11975. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11976. var operationCostTotal float64 = 0 //手术费
  11977. var operationCostSelfTotal float64 = 0 //手术费
  11978. var operationCostPartSelfTotal float64 = 0 //手术费
  11979. var otherCostTotal float64 = 0 //其他费用
  11980. var otherCostSelfTotal float64 = 0 //其他费用
  11981. var otherCostPartSelfTotal float64 = 0 //其他费用
  11982. var materialCostTotal float64 = 0 //材料费
  11983. var materialCostSelfTotal float64 = 0 //材料费
  11984. var materialCostPartSelfTotal float64 = 0 //材料费
  11985. var westernMedicineCostTotal float64 = 0 //西药费
  11986. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11987. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11988. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11989. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11990. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11991. var checkCostTotal float64 = 0 //检查费
  11992. var checkCostSelfTotal float64 = 0 //检查费
  11993. var checkCostPartSelfTotal float64 = 0 //检查费
  11994. var laboratoryCostTotal float64 = 0 //化验费
  11995. var laboratoryCostSelfTotal float64 = 0 //化验费
  11996. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11997. var treatCostTotal float64 = 0 //治疗费用
  11998. var treatCostSelfTotal float64 = 0 //治疗费用
  11999. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12000. decimal.DivisionPrecision = 2
  12001. var bed_fulamt_ownpay_amt float64 = 0
  12002. var operation_fulamt_ownpay_amt float64 = 0
  12003. var other_fulamt_ownpay_amt float64 = 0
  12004. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12005. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12006. var check_fulamt_ownpay_amt float64 = 0
  12007. var material_fulamt_ownpay_amt float64 = 0
  12008. var laboratory_fulamt_ownpay_amt float64 = 0
  12009. var treat_fulamt_ownpay_amt float64 = 0
  12010. var bed_claa_sunmfee float64 = 0
  12011. var bed_clab_amt float64 = 0
  12012. var bed_other_amt float64 = 0
  12013. var operation_claa_sunmfee float64 = 0
  12014. var operation_clab_amt float64 = 0
  12015. var operation_other_amt float64 = 0
  12016. var other_claa_sunmfee float64 = 0
  12017. var other_clab_amt float64 = 0
  12018. var other_other_amt float64 = 0
  12019. var westernMedicine_claa_sunmfee float64 = 0
  12020. var westernMedicine_clab_amt float64 = 0
  12021. var westernMedicine_other_amt float64 = 0
  12022. var chineseTraditional_claa_sunmfee float64 = 0
  12023. var chineseTraditional_clab_amt float64 = 0
  12024. var chineseTraditional_other_amt float64 = 0
  12025. var check_claa_sunmfee float64 = 0
  12026. var check_clab_amt float64 = 0
  12027. var check_other_amt float64 = 0
  12028. var material_claa_sunmfee float64 = 0
  12029. var material_clab_amt float64 = 0
  12030. var material_other_amt float64 = 0
  12031. var laboratory_claa_sunmfee float64 = 0
  12032. var laboratory_clab_amt float64 = 0
  12033. var laboratory_other_amt float64 = 0
  12034. var treat_claa_sunmfee float64 = 0
  12035. var treat_clab_amt float64 = 0
  12036. var treat_other_amt float64 = 0
  12037. for _, item := range order.HisOrderInfo {
  12038. if item.MedChrgitmType == "01" { //床位费
  12039. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12040. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12041. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12042. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12043. if item.ChrgitmLv == "1" {
  12044. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12045. }
  12046. if item.ChrgitmLv == "2" {
  12047. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12048. }
  12049. if item.ChrgitmLv == "3" {
  12050. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12051. }
  12052. }
  12053. if item.MedChrgitmType == "03" { //检查费
  12054. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12055. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12056. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12057. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12058. if item.ChrgitmLv == "1" {
  12059. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12060. }
  12061. if item.ChrgitmLv == "2" {
  12062. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12063. }
  12064. if item.ChrgitmLv == "3" {
  12065. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12066. }
  12067. }
  12068. if item.MedChrgitmType == "04" { //化验费
  12069. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12070. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12071. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12072. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12073. if item.ChrgitmLv == "1" {
  12074. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12075. }
  12076. if item.ChrgitmLv == "2" {
  12077. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12078. }
  12079. if item.ChrgitmLv == "3" {
  12080. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12081. }
  12082. }
  12083. if item.MedChrgitmType == "05" { //治疗费
  12084. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12085. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12086. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12087. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12088. if item.ChrgitmLv == "1" {
  12089. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12090. }
  12091. if item.ChrgitmLv == "2" {
  12092. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12093. }
  12094. if item.ChrgitmLv == "3" {
  12095. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12096. }
  12097. }
  12098. if item.MedChrgitmType == "06" { //手术费
  12099. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12100. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12101. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12102. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12103. if item.ChrgitmLv == "1" {
  12104. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12105. }
  12106. if item.ChrgitmLv == "2" {
  12107. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12108. }
  12109. if item.ChrgitmLv == "3" {
  12110. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12111. }
  12112. }
  12113. if item.MedChrgitmType == "08" { //材料费
  12114. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12115. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12116. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12117. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12118. if item.ChrgitmLv == "1" {
  12119. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12120. }
  12121. if item.ChrgitmLv == "2" {
  12122. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12123. }
  12124. if item.ChrgitmLv == "3" {
  12125. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12126. }
  12127. }
  12128. if item.MedChrgitmType == "09" { //西药费
  12129. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12130. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12131. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12132. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12133. if item.ChrgitmLv == "1" {
  12134. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12135. }
  12136. if item.ChrgitmLv == "2" {
  12137. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12138. }
  12139. if item.ChrgitmLv == "3" {
  12140. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12141. }
  12142. }
  12143. if item.MedChrgitmType == "11" { //中成费
  12144. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12145. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12146. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12147. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12148. if item.ChrgitmLv == "1" {
  12149. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12150. }
  12151. if item.ChrgitmLv == "2" {
  12152. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12153. }
  12154. if item.ChrgitmLv == "3" {
  12155. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12156. }
  12157. }
  12158. if item.MedChrgitmType == "14" { //其他费
  12159. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12160. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12161. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12162. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12163. if item.ChrgitmLv == "1" {
  12164. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12165. }
  12166. if item.ChrgitmLv == "2" {
  12167. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12168. }
  12169. if item.ChrgitmLv == "3" {
  12170. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12171. }
  12172. }
  12173. }
  12174. var iteminfoStructs []service.IteminfoStruct
  12175. if bedCostTotal != 0 {
  12176. iteminfo.MedChrgitm = "01"
  12177. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12178. iteminfo.Amt = bedCostTotal
  12179. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12180. iteminfo.ClabAmt = bed_clab_amt
  12181. iteminfo.OthAmt = bed_other_amt
  12182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12183. }
  12184. if checkCostTotal != 0 {
  12185. iteminfo.MedChrgitm = "03"
  12186. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12187. iteminfo.Amt = checkCostTotal
  12188. iteminfo.ClaaSumfee = check_claa_sunmfee
  12189. iteminfo.ClabAmt = check_clab_amt
  12190. iteminfo.OthAmt = check_other_amt
  12191. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12192. }
  12193. if laboratoryCostTotal != 0 {
  12194. iteminfo.MedChrgitm = "04"
  12195. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12196. iteminfo.Amt = laboratoryCostTotal
  12197. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12198. iteminfo.ClabAmt = laboratory_clab_amt
  12199. iteminfo.OthAmt = laboratory_other_amt
  12200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12201. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12202. }
  12203. if treatCostTotal != 0 {
  12204. iteminfo.MedChrgitm = "05"
  12205. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12206. iteminfo.Amt = treatCostTotal
  12207. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12208. iteminfo.ClabAmt = treat_clab_amt
  12209. iteminfo.OthAmt = treat_other_amt
  12210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12211. //(struct4101.IteminfoStruct, iteminfo)
  12212. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12213. }
  12214. if operationCostTotal != 0 {
  12215. iteminfo.MedChrgitm = "06"
  12216. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12217. iteminfo.Amt = operationCostTotal
  12218. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12219. iteminfo.ClabAmt = operation_clab_amt
  12220. iteminfo.OthAmt = operation_other_amt
  12221. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12222. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12223. }
  12224. if materialCostTotal != 0 {
  12225. iteminfo.MedChrgitm = "08"
  12226. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12227. iteminfo.Amt = materialCostTotal
  12228. iteminfo.ClaaSumfee = material_claa_sunmfee
  12229. iteminfo.ClabAmt = material_clab_amt
  12230. iteminfo.OthAmt = material_other_amt
  12231. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12233. }
  12234. if westernMedicineCostTotal != 0 {
  12235. iteminfo.MedChrgitm = "09"
  12236. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12237. iteminfo.Amt = westernMedicineCostTotal
  12238. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12239. iteminfo.ClabAmt = westernMedicine_clab_amt
  12240. iteminfo.OthAmt = westernMedicine_other_amt
  12241. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12243. }
  12244. if chineseTraditionalMedicineCostTotal != 0 {
  12245. iteminfo.MedChrgitm = "11"
  12246. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12247. iteminfo.Amt = westernMedicineCostTotal
  12248. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12249. iteminfo.ClabAmt = westernMedicine_clab_amt
  12250. iteminfo.OthAmt = westernMedicine_other_amt
  12251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12253. }
  12254. if otherCostTotal != 0 {
  12255. iteminfo.MedChrgitm = "14"
  12256. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12257. iteminfo.Amt = otherCostTotal
  12258. iteminfo.ClaaSumfee = other_claa_sunmfee
  12259. iteminfo.ClabAmt = other_clab_amt
  12260. iteminfo.OthAmt = other_other_amt
  12261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12263. }
  12264. struct4101.IteminfoStruct = iteminfoStructs
  12265. struct4101.Ntly = "中国"
  12266. struct4101.AdmCaty = "A03.06"
  12267. struct4101.DoctorName = doctor.UserName
  12268. struct4101.DoctorCode = doctor.DoctorNumber
  12269. var res ResultSeventeen
  12270. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12271. struct4101.BillCode = order.Number
  12272. struct4101.BillNo = order.SetlId
  12273. var resOther ResultSeventeenOther
  12274. var pp models.PublicParams
  12275. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12276. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12277. pp.FixmedinsName = miConfig.OrgName
  12278. pp.FixmedinsCode = miConfig.Code
  12279. pp.RequestUrl = miConfig.Url
  12280. pp.Cainfo = miConfig.Cainfo
  12281. pp.SecretKey = miConfig.SecretKey
  12282. pp.AccessKey = miConfig.AccessKey
  12283. pp.OpterName = curRoles.UserName
  12284. client := &http.Client{}
  12285. var req *http.Request
  12286. data := make(map[string]interface{})
  12287. data["struct4101"] = struct4101
  12288. data["pp"] = pp
  12289. bytesData, _ := json.Marshal(data)
  12290. if miConfig.MdtrtareaAdmvs == "320921" {
  12291. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12292. } else {
  12293. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12294. }
  12295. resp, _ := client.Do(req)
  12296. defer resp.Body.Close()
  12297. body, ioErr := ioutil.ReadAll(resp.Body)
  12298. if ioErr != nil {
  12299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12301. return
  12302. }
  12303. var respJSON map[string]interface{}
  12304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12307. return
  12308. }
  12309. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12310. userJSONBytes, _ := json.Marshal(respJSON)
  12311. fmt.Println("log")
  12312. fmt.Println(string(userJSONBytes))
  12313. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12314. utils.ErrorLog("解析失败:%v", err)
  12315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12316. return
  12317. }
  12318. res.InfRefmsgid = resOther.InfRefmsgid
  12319. res.Output = resOther.Output
  12320. res.ErrMsg = resOther.ErrMsg
  12321. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12322. res.Infcode = infocode
  12323. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12324. var pp models.PublicParams
  12325. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12326. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12327. pp.FixmedinsName = miConfig.OrgName
  12328. pp.FixmedinsCode = miConfig.Code
  12329. pp.RequestUrl = miConfig.Url
  12330. pp.Cainfo = miConfig.Cainfo
  12331. pp.SecretKey = miConfig.SecretKey
  12332. pp.AccessKey = miConfig.AccessKey
  12333. pp.OpterName = curRoles.UserName
  12334. result, _ := service.Jxyb4101(struct4101, pp)
  12335. var dat map[string]interface{}
  12336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12337. fmt.Println(dat)
  12338. } else {
  12339. fmt.Println(err)
  12340. }
  12341. userJSONBytes, _ := json.Marshal(dat)
  12342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12343. utils.ErrorLog("解析失败:%v", err)
  12344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12345. return
  12346. }
  12347. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12348. var pp models.PublicParams
  12349. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12350. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12351. pp.FixmedinsName = miConfig.OrgName
  12352. pp.FixmedinsCode = miConfig.Code
  12353. pp.RequestUrl = miConfig.Url
  12354. pp.Cainfo = miConfig.Cainfo
  12355. pp.SecretKey = miConfig.SecretKey
  12356. pp.AccessKey = miConfig.AccessKey
  12357. pp.OpterName = curRoles.UserName
  12358. result, _ := service.Hnyb4101(struct4101, pp)
  12359. var dat map[string]interface{}
  12360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12361. fmt.Println(dat)
  12362. } else {
  12363. fmt.Println(err)
  12364. }
  12365. userJSONBytes, _ := json.Marshal(dat)
  12366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12367. utils.ErrorLog("解析失败:%v", err)
  12368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12369. return
  12370. }
  12371. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12372. var resOther ResultSeventeenOther
  12373. var pp models.PublicParams
  12374. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12375. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12376. pp.FixmedinsName = miConfig.OrgName
  12377. pp.FixmedinsCode = miConfig.Code
  12378. pp.RequestUrl = miConfig.Url
  12379. pp.Cainfo = miConfig.Cainfo
  12380. pp.SecretKey = miConfig.SecretKey
  12381. pp.AccessKey = miConfig.AccessKey
  12382. pp.OpterName = curRoles.UserName
  12383. client := &http.Client{}
  12384. var req *http.Request
  12385. data := make(map[string]interface{})
  12386. data["struct4101"] = struct4101
  12387. data["pp"] = pp
  12388. bytesData, _ := json.Marshal(data)
  12389. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12390. resp, _ := client.Do(req)
  12391. defer resp.Body.Close()
  12392. body, ioErr := ioutil.ReadAll(resp.Body)
  12393. if ioErr != nil {
  12394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12396. return
  12397. }
  12398. var respJSON map[string]interface{}
  12399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12402. return
  12403. }
  12404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12405. userJSONBytes, _ := json.Marshal(respJSON)
  12406. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12407. utils.ErrorLog("解析失败:%v", err)
  12408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12409. return
  12410. }
  12411. res.InfRefmsgid = resOther.InfRefmsgid
  12412. res.Output = resOther.Output
  12413. res.ErrMsg = resOther.ErrMsg
  12414. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12415. res.Infcode = infocode
  12416. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12417. var pp models.PublicParams
  12418. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12419. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12420. pp.FixmedinsName = miConfig.OrgName
  12421. pp.FixmedinsCode = miConfig.Code
  12422. pp.RequestUrl = miConfig.Url
  12423. pp.Cainfo = miConfig.Cainfo
  12424. pp.SecretKey = miConfig.SecretKey
  12425. pp.AccessKey = miConfig.AccessKey
  12426. pp.OpterName = curRoles.UserName
  12427. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12428. fmt.Println(requestLog)
  12429. fmt.Println(errMsgLog)
  12430. saveLog(result, requestLog, "4101a", "上传清单")
  12431. var dat map[string]interface{}
  12432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12433. fmt.Println(dat)
  12434. } else {
  12435. fmt.Println(err)
  12436. }
  12437. userJSONBytes, _ := json.Marshal(dat)
  12438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12439. utils.ErrorLog("解析失败:%v", err)
  12440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12441. return
  12442. }
  12443. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12444. var pp models.PublicParams
  12445. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12446. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12447. pp.FixmedinsName = miConfig.OrgName
  12448. pp.FixmedinsCode = miConfig.Code
  12449. pp.RequestUrl = miConfig.Url
  12450. pp.Cainfo = miConfig.Cainfo
  12451. pp.SecretKey = miConfig.SecretKey
  12452. pp.AccessKey = miConfig.AccessKey
  12453. pp.OpterName = curRoles.UserName
  12454. client := &http.Client{}
  12455. var req *http.Request
  12456. data := make(map[string]interface{})
  12457. data["struct4101"] = struct4101
  12458. data["pp"] = pp
  12459. bytesData, _ := json.Marshal(data)
  12460. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12461. resp, _ := client.Do(req)
  12462. defer resp.Body.Close()
  12463. body, ioErr := ioutil.ReadAll(resp.Body)
  12464. if ioErr != nil {
  12465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12467. return
  12468. }
  12469. var respJSON map[string]interface{}
  12470. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12473. return
  12474. }
  12475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12476. userJSONBytes, _ := json.Marshal(respJSON)
  12477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12478. utils.ErrorLog("解析失败:%v", err)
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12480. return
  12481. }
  12482. } else {
  12483. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12484. var dat map[string]interface{}
  12485. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12486. fmt.Println(dat)
  12487. } else {
  12488. fmt.Println(err)
  12489. }
  12490. userJSONBytes, _ := json.Marshal(dat)
  12491. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12492. utils.ErrorLog("解析失败:%v", err)
  12493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12494. return
  12495. }
  12496. }
  12497. if res.Infcode != 0 {
  12498. errlog := &models.HisOrderError{
  12499. UserOrgId: order.UserOrgId,
  12500. Ctime: time.Now().Unix(),
  12501. Mtime: time.Now().Unix(),
  12502. ErrMsg: res.ErrMsg + "解析失败",
  12503. Status: 1,
  12504. PatientId: order.ID,
  12505. Stage: 10485,
  12506. }
  12507. service.CreateErrMsgLog(errlog)
  12508. continue
  12509. //c.ServeSuccessJSON(map[string]interface{}{
  12510. // "failed_code": -10,
  12511. // "msg": res.ErrMsg,
  12512. //})
  12513. } else {
  12514. //order.FaPiaoNumber = zero
  12515. //order.FaPiaoCode = last_order.FaPiaoCode
  12516. //service.UpdateOrder(order)
  12517. hisFundSettleListResult := &models.HisFundSettleListResult{
  12518. Number: res.Output.SetlListId,
  12519. Status: 1,
  12520. Ctime: time.Now().Unix(),
  12521. Mtime: time.Now().Unix(),
  12522. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12523. IsUpload: 1,
  12524. OrderId: order.ID,
  12525. }
  12526. service.CreateUploadRecord(hisFundSettleListResult)
  12527. continue
  12528. }
  12529. }
  12530. }
  12531. func (c *HisApiController) GetSettleList() {
  12532. order_id, _ := c.GetInt64("order_id")
  12533. admin_user_id, _ := c.GetInt64("admin_user_id")
  12534. order, _ := service.GetHisOrderByIDTwo(order_id)
  12535. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12536. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12537. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12538. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12539. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12540. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12541. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12542. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12543. if order.ID == 0 {
  12544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12545. return
  12546. }
  12547. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12548. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12549. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12550. //fmt.Println(count)
  12551. //var zero string
  12552. //number := count + 1
  12553. //if number >= 1000 {
  12554. // zero = "0000" + strconv.FormatInt(number, 10)
  12555. //} else if number >= 10000 {
  12556. // zero = "000" + strconv.FormatInt(number, 10)
  12557. //} else if number >= 100000 {
  12558. // zero = "00" + strconv.FormatInt(number, 10)
  12559. //} else if number >= 1000000 {
  12560. // zero = "0" + strconv.FormatInt(number, 10)
  12561. //} else {
  12562. // zero = strconv.FormatInt(number, 10)
  12563. //}
  12564. //fmt.Println(zero)
  12565. struct4101 := service.Struct4101{
  12566. PsnNo: order.PsnNo,
  12567. MdtrtId: order.MdtrtId,
  12568. SetlId: order.SetlId,
  12569. PsnName: order.PsnName,
  12570. Gend: order.Gend,
  12571. Brdy: his.Brdy,
  12572. Age: his.Age,
  12573. Naty: order.Naty,
  12574. PatnCertType: "01",
  12575. Certno: order.Certno,
  12576. Prfs: "90",
  12577. ConerName: roles[0].UserName,
  12578. PatnRlts: "99",
  12579. ConerAddr: miConfig.OrgName,
  12580. ConerTel: admin.Mobile,
  12581. HiType: order.Insutype,
  12582. Insuplc: miConfig.InsuplcAdmdvs,
  12583. MaindiagFlag: "1",
  12584. BillCode: order.SetlId,
  12585. BillNo: order.SetlId,
  12586. BizSn: order.Number,
  12587. PsnSelfPay: order.PsnPartAmt,
  12588. PsnOwnPay: order.PsnPartAmt,
  12589. AcctPay: order.AcctPay,
  12590. PsnCashpay: order.PsnCashPay,
  12591. HiPaymtd: "1",
  12592. Hsorg: miConfig.InsuplcAdmdvs,
  12593. HsorgOpter: miConfig.InsuplcAdmdvs,
  12594. MedinsFillPsn: curRoles.UserName,
  12595. MedinsFillDept: miConfig.OrgName,
  12596. IptMedType: "2",
  12597. }
  12598. struct4101.SetlBegnDate = order.SetlTime
  12599. struct4101.SetlEndDate = order.SetlTime
  12600. time_arr := strings.Split(order.SetlTime, " ")
  12601. struct4101.AdmTime = time_arr[0]
  12602. struct4101.AdmEndTime = time_arr[0]
  12603. //
  12604. //var rf []CustomFundPay
  12605. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12606. //
  12607. //var tempFunPays []service.CustomStruct
  12608. //for _, item := range rf {
  12609. // var tempFunPay service.CustomStruct
  12610. // tempFunPay.FundPayamt = item.FundPayamt
  12611. // tempFunPay.FundPayType = item.FundPayType
  12612. // tempFunPays = append(tempFunPays, tempFunPay)
  12613. //}
  12614. //struct4101.CustomStruct = tempFunPays
  12615. var tempDiaginfos []service.DiaginfoStructTwo
  12616. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12617. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12618. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12619. var config []*models.HisXtDiagnoseConfig
  12620. for _, item := range diagnosis_ids {
  12621. id, _ := strconv.ParseInt(item, 10, 64)
  12622. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12623. config = append(config, &diagnosisConfig)
  12624. }
  12625. if miConfig.Code == "H15049901371" {
  12626. //for _, item := range config {
  12627. // if item.ID == 138 {
  12628. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12629. var tempDiaginfo service.DiaginfoStructTwo
  12630. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12631. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12632. tempDiaginfo.DiagType = "1"
  12633. tempDiaginfo.MaindiagFlag = "1"
  12634. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12635. //}
  12636. //}
  12637. for _, item := range config {
  12638. if item.ID != 138 {
  12639. var tempDiaginfo service.DiaginfoStructTwo
  12640. tempDiaginfo.DiagCode = item.CountryCode
  12641. tempDiaginfo.DiagName = item.CountryContentName
  12642. tempDiaginfo.DiagType = "1"
  12643. tempDiaginfo.MaindiagFlag = "0"
  12644. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12645. }
  12646. }
  12647. } else {
  12648. for index, item := range config {
  12649. if index == 0 {
  12650. var tempDiaginfo service.DiaginfoStructTwo
  12651. tempDiaginfo.DiagCode = item.CountryCode
  12652. tempDiaginfo.DiagName = item.CountryContentName
  12653. tempDiaginfo.DiagType = "1"
  12654. tempDiaginfo.MaindiagFlag = "1"
  12655. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12656. } else {
  12657. var tempDiaginfo service.DiaginfoStructTwo
  12658. tempDiaginfo.DiagCode = item.CountryCode
  12659. tempDiaginfo.DiagName = item.CountryContentName
  12660. tempDiaginfo.DiagType = "1"
  12661. tempDiaginfo.MaindiagFlag = "0"
  12662. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12663. }
  12664. }
  12665. }
  12666. struct4101.Diseinfo = tempDiaginfos
  12667. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12668. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12669. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12670. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12671. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12672. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12673. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12674. var iteminfo service.IteminfoStruct
  12675. var bedCostTotal float64 = 0 //床位总费
  12676. var bedCostSelfTotal float64 = 0 //床位自费
  12677. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12678. var operationCostTotal float64 = 0 //手术费
  12679. var operationCostSelfTotal float64 = 0 //手术费
  12680. var operationCostPartSelfTotal float64 = 0 //手术费
  12681. var otherCostTotal float64 = 0 //其他费用
  12682. var otherCostSelfTotal float64 = 0 //其他费用
  12683. var otherCostPartSelfTotal float64 = 0 //其他费用
  12684. var materialCostTotal float64 = 0 //材料费
  12685. var materialCostSelfTotal float64 = 0 //材料费
  12686. var materialCostPartSelfTotal float64 = 0 //材料费
  12687. var westernMedicineCostTotal float64 = 0 //西药费
  12688. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12689. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12690. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12691. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12692. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12693. var checkCostTotal float64 = 0 //检查费
  12694. var checkCostSelfTotal float64 = 0 //检查费
  12695. var checkCostPartSelfTotal float64 = 0 //检查费
  12696. var laboratoryCostTotal float64 = 0 //化验费
  12697. var laboratoryCostSelfTotal float64 = 0 //化验费
  12698. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12699. var treatCostTotal float64 = 0 //治疗费用
  12700. var treatCostSelfTotal float64 = 0 //治疗费用
  12701. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12702. decimal.DivisionPrecision = 2
  12703. var bed_fulamt_ownpay_amt float64 = 0
  12704. var operation_fulamt_ownpay_amt float64 = 0
  12705. var other_fulamt_ownpay_amt float64 = 0
  12706. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12707. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12708. var check_fulamt_ownpay_amt float64 = 0
  12709. var material_fulamt_ownpay_amt float64 = 0
  12710. var laboratory_fulamt_ownpay_amt float64 = 0
  12711. var treat_fulamt_ownpay_amt float64 = 0
  12712. var bed_claa_sunmfee float64 = 0
  12713. var bed_clab_amt float64 = 0
  12714. var bed_other_amt float64 = 0
  12715. var operation_claa_sunmfee float64 = 0
  12716. var operation_clab_amt float64 = 0
  12717. var operation_other_amt float64 = 0
  12718. var other_claa_sunmfee float64 = 0
  12719. var other_clab_amt float64 = 0
  12720. var other_other_amt float64 = 0
  12721. var westernMedicine_claa_sunmfee float64 = 0
  12722. var westernMedicine_clab_amt float64 = 0
  12723. var westernMedicine_other_amt float64 = 0
  12724. var chineseTraditional_claa_sunmfee float64 = 0
  12725. var chineseTraditional_clab_amt float64 = 0
  12726. var chineseTraditional_other_amt float64 = 0
  12727. var check_claa_sunmfee float64 = 0
  12728. var check_clab_amt float64 = 0
  12729. var check_other_amt float64 = 0
  12730. var material_claa_sunmfee float64 = 0
  12731. var material_clab_amt float64 = 0
  12732. var material_other_amt float64 = 0
  12733. var laboratory_claa_sunmfee float64 = 0
  12734. var laboratory_clab_amt float64 = 0
  12735. var laboratory_other_amt float64 = 0
  12736. var treat_claa_sunmfee float64 = 0
  12737. var treat_clab_amt float64 = 0
  12738. var treat_other_amt float64 = 0
  12739. for _, item := range order.HisOrderInfo {
  12740. if item.MedChrgitmType == "01" { //床位费
  12741. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12742. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12743. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12744. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12745. if item.ChrgitmLv == "1" {
  12746. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12747. }
  12748. if item.ChrgitmLv == "2" {
  12749. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12750. }
  12751. if item.ChrgitmLv == "3" {
  12752. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12753. }
  12754. }
  12755. if item.MedChrgitmType == "03" { //检查费
  12756. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12757. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12758. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12759. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12760. if item.ChrgitmLv == "1" {
  12761. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12762. }
  12763. if item.ChrgitmLv == "2" {
  12764. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12765. }
  12766. if item.ChrgitmLv == "3" {
  12767. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12768. }
  12769. }
  12770. if item.MedChrgitmType == "04" { //化验费
  12771. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12772. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12773. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12774. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12775. if item.ChrgitmLv == "1" {
  12776. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12777. }
  12778. if item.ChrgitmLv == "2" {
  12779. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12780. }
  12781. if item.ChrgitmLv == "3" {
  12782. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12783. }
  12784. }
  12785. if item.MedChrgitmType == "05" { //治疗费
  12786. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12787. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12788. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12789. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12790. if item.ChrgitmLv == "1" {
  12791. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12792. }
  12793. if item.ChrgitmLv == "2" {
  12794. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12795. }
  12796. if item.ChrgitmLv == "3" {
  12797. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12798. }
  12799. }
  12800. if item.MedChrgitmType == "06" { //手术费
  12801. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12802. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12803. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12804. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12805. if item.ChrgitmLv == "1" {
  12806. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12807. }
  12808. if item.ChrgitmLv == "2" {
  12809. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12810. }
  12811. if item.ChrgitmLv == "3" {
  12812. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12813. }
  12814. }
  12815. if item.MedChrgitmType == "08" { //材料费
  12816. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12817. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12818. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12819. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12820. if item.ChrgitmLv == "1" {
  12821. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12822. }
  12823. if item.ChrgitmLv == "2" {
  12824. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12825. }
  12826. if item.ChrgitmLv == "3" {
  12827. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12828. }
  12829. }
  12830. if item.MedChrgitmType == "09" { //西药费
  12831. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12832. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12833. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12834. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12835. if item.ChrgitmLv == "1" {
  12836. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12837. }
  12838. if item.ChrgitmLv == "2" {
  12839. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12840. }
  12841. if item.ChrgitmLv == "3" {
  12842. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12843. }
  12844. }
  12845. if item.MedChrgitmType == "11" { //中成费
  12846. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12847. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12848. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12849. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12850. if item.ChrgitmLv == "1" {
  12851. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12852. }
  12853. if item.ChrgitmLv == "2" {
  12854. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12855. }
  12856. if item.ChrgitmLv == "3" {
  12857. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12858. }
  12859. }
  12860. if item.MedChrgitmType == "14" { //其他费
  12861. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12862. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12863. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12864. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12865. if item.ChrgitmLv == "1" {
  12866. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12867. }
  12868. if item.ChrgitmLv == "2" {
  12869. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12870. }
  12871. if item.ChrgitmLv == "3" {
  12872. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12873. }
  12874. }
  12875. }
  12876. var iteminfoStructs []service.IteminfoStruct
  12877. if bedCostTotal != 0 {
  12878. iteminfo.MedChrgitm = "01"
  12879. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12880. iteminfo.Amt = bedCostTotal
  12881. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12882. iteminfo.ClabAmt = bed_clab_amt
  12883. iteminfo.OthAmt = bed_other_amt
  12884. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12885. }
  12886. if checkCostTotal != 0 {
  12887. iteminfo.MedChrgitm = "03"
  12888. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12889. iteminfo.Amt = checkCostTotal
  12890. iteminfo.ClaaSumfee = check_claa_sunmfee
  12891. iteminfo.ClabAmt = check_clab_amt
  12892. iteminfo.OthAmt = check_other_amt
  12893. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12894. }
  12895. if laboratoryCostTotal != 0 {
  12896. iteminfo.MedChrgitm = "04"
  12897. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12898. iteminfo.Amt = laboratoryCostTotal
  12899. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12900. iteminfo.ClabAmt = laboratory_clab_amt
  12901. iteminfo.OthAmt = laboratory_other_amt
  12902. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12903. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12904. }
  12905. if treatCostTotal != 0 {
  12906. iteminfo.MedChrgitm = "05"
  12907. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12908. iteminfo.Amt = treatCostTotal
  12909. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12910. iteminfo.ClabAmt = treat_clab_amt
  12911. iteminfo.OthAmt = treat_other_amt
  12912. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12913. //(struct4101.IteminfoStruct, iteminfo)
  12914. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12915. }
  12916. if operationCostTotal != 0 {
  12917. iteminfo.MedChrgitm = "06"
  12918. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12919. iteminfo.Amt = operationCostTotal
  12920. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12921. iteminfo.ClabAmt = operation_clab_amt
  12922. iteminfo.OthAmt = operation_other_amt
  12923. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12925. }
  12926. if materialCostTotal != 0 {
  12927. iteminfo.MedChrgitm = "08"
  12928. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12929. iteminfo.Amt = materialCostTotal
  12930. iteminfo.ClaaSumfee = material_claa_sunmfee
  12931. iteminfo.ClabAmt = material_clab_amt
  12932. iteminfo.OthAmt = material_other_amt
  12933. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12934. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12935. }
  12936. if westernMedicineCostTotal != 0 {
  12937. iteminfo.MedChrgitm = "09"
  12938. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12939. iteminfo.Amt = westernMedicineCostTotal
  12940. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12941. iteminfo.ClabAmt = westernMedicine_clab_amt
  12942. iteminfo.OthAmt = westernMedicine_other_amt
  12943. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12944. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12945. }
  12946. if chineseTraditionalMedicineCostTotal != 0 {
  12947. iteminfo.MedChrgitm = "11"
  12948. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12949. iteminfo.Amt = westernMedicineCostTotal
  12950. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12951. iteminfo.ClabAmt = westernMedicine_clab_amt
  12952. iteminfo.OthAmt = westernMedicine_other_amt
  12953. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12954. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12955. }
  12956. if otherCostTotal != 0 {
  12957. iteminfo.MedChrgitm = "14"
  12958. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12959. iteminfo.Amt = otherCostTotal
  12960. iteminfo.ClaaSumfee = other_claa_sunmfee
  12961. iteminfo.ClabAmt = other_clab_amt
  12962. iteminfo.OthAmt = other_other_amt
  12963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12965. }
  12966. struct4101.IteminfoStruct = iteminfoStructs
  12967. struct4101.Ntly = "中国"
  12968. struct4101.AdmCaty = "A03.06"
  12969. struct4101.DoctorName = doctor.UserName
  12970. struct4101.DoctorCode = doctor.DoctorNumber
  12971. var res ResultSeventeen
  12972. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12973. struct4101.BillCode = order.Number
  12974. struct4101.BillNo = order.SetlId
  12975. var resOther ResultSeventeenOther
  12976. var pp models.PublicParams
  12977. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12978. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12979. pp.FixmedinsName = miConfig.OrgName
  12980. pp.FixmedinsCode = miConfig.Code
  12981. pp.RequestUrl = miConfig.Url
  12982. pp.Cainfo = miConfig.Cainfo
  12983. pp.SecretKey = miConfig.SecretKey
  12984. pp.AccessKey = miConfig.AccessKey
  12985. pp.OpterName = curRoles.UserName
  12986. client := &http.Client{}
  12987. var req *http.Request
  12988. data := make(map[string]interface{})
  12989. data["struct4101"] = struct4101
  12990. data["pp"] = pp
  12991. bytesData, _ := json.Marshal(data)
  12992. if miConfig.MdtrtareaAdmvs == "320921" {
  12993. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12994. } else {
  12995. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12996. }
  12997. resp, _ := client.Do(req)
  12998. defer resp.Body.Close()
  12999. body, ioErr := ioutil.ReadAll(resp.Body)
  13000. if ioErr != nil {
  13001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13003. return
  13004. }
  13005. var respJSON map[string]interface{}
  13006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13009. return
  13010. }
  13011. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13012. userJSONBytes, _ := json.Marshal(respJSON)
  13013. fmt.Println("log")
  13014. fmt.Println(string(userJSONBytes))
  13015. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13016. utils.ErrorLog("解析失败:%v", err)
  13017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13018. return
  13019. }
  13020. res.InfRefmsgid = resOther.InfRefmsgid
  13021. res.Output = resOther.Output
  13022. res.ErrMsg = resOther.ErrMsg
  13023. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13024. res.Infcode = infocode
  13025. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13026. var pp models.PublicParams
  13027. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13028. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13029. pp.FixmedinsName = miConfig.OrgName
  13030. pp.FixmedinsCode = miConfig.Code
  13031. pp.RequestUrl = miConfig.Url
  13032. pp.Cainfo = miConfig.Cainfo
  13033. pp.SecretKey = miConfig.SecretKey
  13034. pp.AccessKey = miConfig.AccessKey
  13035. pp.OpterName = curRoles.UserName
  13036. result, _ := service.Jxyb4101(struct4101, pp)
  13037. var dat map[string]interface{}
  13038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13039. fmt.Println(dat)
  13040. } else {
  13041. fmt.Println(err)
  13042. }
  13043. userJSONBytes, _ := json.Marshal(dat)
  13044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13045. utils.ErrorLog("解析失败:%v", err)
  13046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13047. return
  13048. }
  13049. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13050. var pp models.PublicParams
  13051. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13052. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13053. pp.FixmedinsName = miConfig.OrgName
  13054. pp.FixmedinsCode = miConfig.Code
  13055. pp.RequestUrl = miConfig.Url
  13056. pp.Cainfo = miConfig.Cainfo
  13057. pp.SecretKey = miConfig.SecretKey
  13058. pp.AccessKey = miConfig.AccessKey
  13059. pp.OpterName = curRoles.UserName
  13060. result, _ := service.Hnyb4101(struct4101, pp)
  13061. var dat map[string]interface{}
  13062. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13063. fmt.Println(dat)
  13064. } else {
  13065. fmt.Println(err)
  13066. }
  13067. userJSONBytes, _ := json.Marshal(dat)
  13068. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13069. utils.ErrorLog("解析失败:%v", err)
  13070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13071. return
  13072. }
  13073. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13074. var resOther ResultSeventeenOther
  13075. var pp models.PublicParams
  13076. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13077. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13078. pp.FixmedinsName = miConfig.OrgName
  13079. pp.FixmedinsCode = miConfig.Code
  13080. pp.RequestUrl = miConfig.Url
  13081. pp.Cainfo = miConfig.Cainfo
  13082. pp.SecretKey = miConfig.SecretKey
  13083. pp.AccessKey = miConfig.AccessKey
  13084. pp.OpterName = curRoles.UserName
  13085. client := &http.Client{}
  13086. var req *http.Request
  13087. data := make(map[string]interface{})
  13088. data["struct4101"] = struct4101
  13089. data["pp"] = pp
  13090. bytesData, _ := json.Marshal(data)
  13091. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13092. resp, _ := client.Do(req)
  13093. defer resp.Body.Close()
  13094. body, ioErr := ioutil.ReadAll(resp.Body)
  13095. if ioErr != nil {
  13096. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13098. return
  13099. }
  13100. var respJSON map[string]interface{}
  13101. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13102. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13104. return
  13105. }
  13106. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13107. userJSONBytes, _ := json.Marshal(respJSON)
  13108. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13109. utils.ErrorLog("解析失败:%v", err)
  13110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13111. return
  13112. }
  13113. res.InfRefmsgid = resOther.InfRefmsgid
  13114. res.Output = resOther.Output
  13115. res.ErrMsg = resOther.ErrMsg
  13116. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13117. res.Infcode = infocode
  13118. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13119. var pp models.PublicParams
  13120. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13121. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13122. pp.FixmedinsName = miConfig.OrgName
  13123. pp.FixmedinsCode = miConfig.Code
  13124. pp.RequestUrl = miConfig.Url
  13125. pp.Cainfo = miConfig.Cainfo
  13126. pp.SecretKey = miConfig.SecretKey
  13127. pp.AccessKey = miConfig.AccessKey
  13128. pp.OpterName = curRoles.UserName
  13129. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13130. fmt.Println(requestLog)
  13131. fmt.Println(errMsgLog)
  13132. saveLog(result, requestLog, "4101a", "上传清单")
  13133. var dat map[string]interface{}
  13134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13135. fmt.Println(dat)
  13136. } else {
  13137. fmt.Println(err)
  13138. }
  13139. userJSONBytes, _ := json.Marshal(dat)
  13140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13141. utils.ErrorLog("解析失败:%v", err)
  13142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13143. return
  13144. }
  13145. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13146. var pp models.PublicParams
  13147. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13148. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13149. pp.FixmedinsName = miConfig.OrgName
  13150. pp.FixmedinsCode = miConfig.Code
  13151. pp.RequestUrl = miConfig.Url
  13152. pp.Cainfo = miConfig.Cainfo
  13153. pp.SecretKey = miConfig.SecretKey
  13154. pp.AccessKey = miConfig.AccessKey
  13155. pp.OpterName = curRoles.UserName
  13156. client := &http.Client{}
  13157. var req *http.Request
  13158. data := make(map[string]interface{})
  13159. data["struct4101"] = struct4101
  13160. data["pp"] = pp
  13161. bytesData, _ := json.Marshal(data)
  13162. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13163. resp, _ := client.Do(req)
  13164. defer resp.Body.Close()
  13165. body, ioErr := ioutil.ReadAll(resp.Body)
  13166. if ioErr != nil {
  13167. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13169. return
  13170. }
  13171. var respJSON map[string]interface{}
  13172. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13173. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13175. return
  13176. }
  13177. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13178. userJSONBytes, _ := json.Marshal(respJSON)
  13179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13180. utils.ErrorLog("解析失败:%v", err)
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. return
  13183. }
  13184. } else {
  13185. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13186. var dat map[string]interface{}
  13187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13188. fmt.Println(dat)
  13189. } else {
  13190. fmt.Println(err)
  13191. }
  13192. userJSONBytes, _ := json.Marshal(dat)
  13193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13194. utils.ErrorLog("解析失败:%v", err)
  13195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13196. return
  13197. }
  13198. }
  13199. if res.Infcode != 0 {
  13200. c.ServeSuccessJSON(map[string]interface{}{
  13201. "failed_code": -10,
  13202. "msg": res.ErrMsg,
  13203. })
  13204. return
  13205. } else {
  13206. //order.FaPiaoNumber = zero
  13207. //order.FaPiaoCode = last_order.FaPiaoCode
  13208. //service.UpdateOrder(order)
  13209. hisFundSettleListResult := &models.HisFundSettleListResult{
  13210. Number: res.Output.SetlListId,
  13211. Status: 1,
  13212. Ctime: time.Now().Unix(),
  13213. Mtime: time.Now().Unix(),
  13214. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13215. IsUpload: 1,
  13216. OrderId: order_id,
  13217. }
  13218. service.CreateUploadRecord(hisFundSettleListResult)
  13219. c.ServeSuccessJSON(map[string]interface{}{
  13220. "msg": "上传成功",
  13221. "result": hisFundSettleListResult,
  13222. })
  13223. return
  13224. }
  13225. }
  13226. func (c *HisApiController) GetSettleListHospital() {
  13227. order_id, _ := c.GetInt64("order_id")
  13228. admin_user_id, _ := c.GetInt64("admin_user_id")
  13229. order, _ := service.GetHisOrderByIDTwo(order_id)
  13230. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13231. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13232. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13233. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13234. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13235. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13236. if order.ID == 0 {
  13237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13238. return
  13239. }
  13240. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13241. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13242. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13243. fmt.Println(count)
  13244. var zero string
  13245. number := count + 1
  13246. if number >= 1000 {
  13247. zero = "0000" + strconv.FormatInt(number, 10)
  13248. } else if number >= 10000 {
  13249. zero = "000" + strconv.FormatInt(number, 10)
  13250. } else if number >= 100000 {
  13251. zero = "00" + strconv.FormatInt(number, 10)
  13252. } else if number >= 1000000 {
  13253. zero = "0" + strconv.FormatInt(number, 10)
  13254. } else {
  13255. zero = strconv.FormatInt(number, 10)
  13256. }
  13257. fmt.Println(zero)
  13258. struct4101 := service.Struct4101{
  13259. PsnNo: order.PsnNo,
  13260. MdtrtId: order.MdtrtId,
  13261. SetlId: order.SetlId,
  13262. PsnName: order.PsnName,
  13263. Gend: order.Gend,
  13264. Brdy: his.Brdy,
  13265. Age: int64(order.Age),
  13266. Naty: order.Naty,
  13267. PatnCertType: "01",
  13268. Certno: order.Certno,
  13269. Prfs: "90",
  13270. ConerName: roles[0].UserName,
  13271. PatnRlts: "99",
  13272. ConerAddr: miConfig.OrgName,
  13273. ConerTel: admin.Mobile,
  13274. HiType: order.Insutype,
  13275. Insuplc: miConfig.InsuplcAdmdvs,
  13276. MaindiagFlag: "1",
  13277. BillCode: order.SetlId,
  13278. BillNo: order.SetlId,
  13279. BizSn: order.Number,
  13280. PsnSelfPay: order.PsnPartAmt,
  13281. PsnOwnPay: order.PsnPartAmt,
  13282. AcctPay: order.AcctPay,
  13283. PsnCashpay: order.PsnCashPay,
  13284. HiPaymtd: "1",
  13285. Hsorg: miConfig.InsuplcAdmdvs,
  13286. HsorgOpter: miConfig.InsuplcAdmdvs,
  13287. MedinsFillPsn: curRoles.UserName,
  13288. MedinsFillDept: depart.Name,
  13289. IptMedType: "2",
  13290. AdmTime: his.InHosptialTime,
  13291. AdmEndTime: his.OutHosptialTime,
  13292. }
  13293. struct4101.SetlBegnDate = order.SetlTime
  13294. struct4101.SetlEndDate = order.SetlTime
  13295. //var rf []CustomFundPay
  13296. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13297. //
  13298. //var tempFunPays []service.CustomStruct
  13299. //for _, item := range rf {
  13300. // var tempFunPay service.CustomStruct
  13301. // tempFunPay.FundPayamt = item.FundPayamt
  13302. // tempFunPay.FundPayType = item.FundPayType
  13303. // tempFunPays = append(tempFunPays, tempFunPay)
  13304. //}
  13305. //struct4101.CustomStruct = tempFunPays
  13306. var tempDiaginfos []service.DiaginfoStructTwo
  13307. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13308. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13309. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13310. //for _, item := range infos {
  13311. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13312. //}
  13313. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13314. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13315. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13316. fmt.Println(diagnosis_ids_arr)
  13317. if order.UserOrgId == 10210 {
  13318. var diagnosis_ids_arr_two []int64
  13319. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13320. var config []*models.HisXtDiagnoseConfig
  13321. for _, id := range diagnosis_ids_arr_two {
  13322. //id, _ := strconv.ParseInt(item, 10, 64)
  13323. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13324. if diagnosisConfig.ID > 0 {
  13325. config = append(config, &diagnosisConfig)
  13326. }
  13327. }
  13328. for index, item := range config {
  13329. if item.ID > 0 {
  13330. if index == 0 {
  13331. var tempDiaginfo service.DiaginfoStructTwo
  13332. tempDiaginfo.DiagCode = item.CountryCode
  13333. tempDiaginfo.DiagName = item.CountryContentName
  13334. tempDiaginfo.DiagType = "1"
  13335. tempDiaginfo.MaindiagFlag = "1"
  13336. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13337. } else {
  13338. var tempDiaginfo service.DiaginfoStructTwo
  13339. tempDiaginfo.DiagCode = item.CountryCode
  13340. tempDiaginfo.DiagName = item.CountryContentName
  13341. tempDiaginfo.DiagType = "1"
  13342. tempDiaginfo.MaindiagFlag = "0"
  13343. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13344. }
  13345. }
  13346. }
  13347. struct4101.Diseinfo = tempDiaginfos
  13348. } else {
  13349. var config []*models.HisXtDiagnoseConfig
  13350. for _, item := range diagnosis_ids_arr {
  13351. id, _ := strconv.ParseInt(item, 10, 64)
  13352. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13353. if diagnosisConfig.ID > 0 {
  13354. config = append(config, &diagnosisConfig)
  13355. }
  13356. }
  13357. for index, item := range config {
  13358. if item.ID > 0 {
  13359. if index == 0 {
  13360. var tempDiaginfo service.DiaginfoStructTwo
  13361. tempDiaginfo.DiagCode = item.CountryCode
  13362. tempDiaginfo.DiagName = item.CountryContentName
  13363. tempDiaginfo.DiagType = "1"
  13364. tempDiaginfo.MaindiagFlag = "1"
  13365. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13366. } else {
  13367. var tempDiaginfo service.DiaginfoStructTwo
  13368. tempDiaginfo.DiagCode = item.CountryCode
  13369. tempDiaginfo.DiagName = item.CountryContentName
  13370. tempDiaginfo.DiagType = "1"
  13371. tempDiaginfo.MaindiagFlag = "0"
  13372. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13373. }
  13374. }
  13375. }
  13376. struct4101.Diseinfo = tempDiaginfos
  13377. }
  13378. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13379. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13380. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13381. tempOpspdiseinfo2.OprnOprtCode = ""
  13382. tempOpspdiseinfo2.OprnOprtName = ""
  13383. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13384. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13385. var iteminfo service.IteminfoStruct
  13386. var bedCostTotal float64 = 0 //床位总费
  13387. var bedCostSelfTotal float64 = 0 //床位自费
  13388. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13389. var operationCostTotal float64 = 0 //手术费
  13390. var operationCostSelfTotal float64 = 0 //手术费
  13391. var operationCostPartSelfTotal float64 = 0 //手术费
  13392. var otherCostTotal float64 = 0 //其他费用
  13393. var otherCostSelfTotal float64 = 0 //其他费用
  13394. var otherCostPartSelfTotal float64 = 0 //其他费用
  13395. var materialCostTotal float64 = 0 //材料费
  13396. var materialCostSelfTotal float64 = 0 //材料费
  13397. var materialCostPartSelfTotal float64 = 0 //材料费
  13398. var westernMedicineCostTotal float64 = 0 //西药费
  13399. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13400. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13401. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13402. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13403. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13404. var checkCostTotal float64 = 0 //检查费
  13405. var checkCostSelfTotal float64 = 0 //检查费
  13406. var checkCostPartSelfTotal float64 = 0 //检查费
  13407. var laboratoryCostTotal float64 = 0 //化验费
  13408. var laboratoryCostSelfTotal float64 = 0 //化验费
  13409. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13410. var treatCostTotal float64 = 0 //治疗费用
  13411. var treatCostSelfTotal float64 = 0 //治疗费用
  13412. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13413. decimal.DivisionPrecision = 2
  13414. var bed_fulamt_ownpay_amt float64 = 0
  13415. var operation_fulamt_ownpay_amt float64 = 0
  13416. var other_fulamt_ownpay_amt float64 = 0
  13417. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13418. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13419. var check_fulamt_ownpay_amt float64 = 0
  13420. var material_fulamt_ownpay_amt float64 = 0
  13421. var laboratory_fulamt_ownpay_amt float64 = 0
  13422. var treat_fulamt_ownpay_amt float64 = 0
  13423. var bed_claa_sunmfee float64 = 0
  13424. var bed_clab_amt float64 = 0
  13425. var bed_other_amt float64 = 0
  13426. var operation_claa_sunmfee float64 = 0
  13427. var operation_clab_amt float64 = 0
  13428. var operation_other_amt float64 = 0
  13429. var other_claa_sunmfee float64 = 0
  13430. var other_clab_amt float64 = 0
  13431. var other_other_amt float64 = 0
  13432. var westernMedicine_claa_sunmfee float64 = 0
  13433. var westernMedicine_clab_amt float64 = 0
  13434. var westernMedicine_other_amt float64 = 0
  13435. var chineseTraditional_claa_sunmfee float64 = 0
  13436. var chineseTraditional_clab_amt float64 = 0
  13437. var chineseTraditional_other_amt float64 = 0
  13438. var check_claa_sunmfee float64 = 0
  13439. var check_clab_amt float64 = 0
  13440. var check_other_amt float64 = 0
  13441. var material_claa_sunmfee float64 = 0
  13442. var material_clab_amt float64 = 0
  13443. var material_other_amt float64 = 0
  13444. var laboratory_claa_sunmfee float64 = 0
  13445. var laboratory_clab_amt float64 = 0
  13446. var laboratory_other_amt float64 = 0
  13447. var treat_claa_sunmfee float64 = 0
  13448. var treat_clab_amt float64 = 0
  13449. var treat_other_amt float64 = 0
  13450. for _, item := range order.HisOrderInfo {
  13451. if item.MedChrgitmType == "01" { //床位费
  13452. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13453. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13454. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13455. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13456. if item.ChrgitmLv == "1" {
  13457. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13458. }
  13459. if item.ChrgitmLv == "2" {
  13460. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13461. }
  13462. if item.ChrgitmLv == "3" {
  13463. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13464. }
  13465. }
  13466. if item.MedChrgitmType == "03" { //检查费
  13467. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13468. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13469. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13470. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13471. if item.ChrgitmLv == "1" {
  13472. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13473. }
  13474. if item.ChrgitmLv == "2" {
  13475. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13476. }
  13477. if item.ChrgitmLv == "3" {
  13478. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13479. }
  13480. }
  13481. if item.MedChrgitmType == "04" { //化验费
  13482. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13483. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13484. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13485. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13486. if item.ChrgitmLv == "1" {
  13487. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13488. }
  13489. if item.ChrgitmLv == "2" {
  13490. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13491. }
  13492. if item.ChrgitmLv == "3" {
  13493. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13494. }
  13495. }
  13496. if item.MedChrgitmType == "05" { //治疗费
  13497. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13498. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13499. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13500. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13501. if item.ChrgitmLv == "1" {
  13502. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13503. }
  13504. if item.ChrgitmLv == "2" {
  13505. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13506. }
  13507. if item.ChrgitmLv == "3" {
  13508. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13509. }
  13510. }
  13511. if item.MedChrgitmType == "06" { //手术费
  13512. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13513. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13514. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13515. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13516. if item.ChrgitmLv == "1" {
  13517. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13518. }
  13519. if item.ChrgitmLv == "2" {
  13520. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13521. }
  13522. if item.ChrgitmLv == "3" {
  13523. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13524. }
  13525. }
  13526. if item.MedChrgitmType == "08" { //材料费
  13527. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13528. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13529. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13530. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13531. if item.ChrgitmLv == "1" {
  13532. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13533. }
  13534. if item.ChrgitmLv == "2" {
  13535. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13536. }
  13537. if item.ChrgitmLv == "3" {
  13538. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13539. }
  13540. }
  13541. if item.MedChrgitmType == "09" { //西药费
  13542. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13543. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13544. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13545. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13546. if item.ChrgitmLv == "1" {
  13547. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13548. }
  13549. if item.ChrgitmLv == "2" {
  13550. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13551. }
  13552. if item.ChrgitmLv == "3" {
  13553. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13554. }
  13555. }
  13556. if item.MedChrgitmType == "11" { //中成费
  13557. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13558. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13559. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13560. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13561. if item.ChrgitmLv == "1" {
  13562. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13563. }
  13564. if item.ChrgitmLv == "2" {
  13565. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13566. }
  13567. if item.ChrgitmLv == "3" {
  13568. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13569. }
  13570. }
  13571. if item.MedChrgitmType == "14" { //其他费
  13572. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13573. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13574. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13575. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13576. if item.ChrgitmLv == "1" {
  13577. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13578. }
  13579. if item.ChrgitmLv == "2" {
  13580. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13581. }
  13582. if item.ChrgitmLv == "3" {
  13583. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13584. }
  13585. }
  13586. }
  13587. var iteminfoStructs []service.IteminfoStruct
  13588. if bedCostTotal != 0 {
  13589. iteminfo.MedChrgitm = "01"
  13590. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13591. iteminfo.Amt = bedCostTotal
  13592. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13593. iteminfo.ClabAmt = bed_clab_amt
  13594. iteminfo.OthAmt = bed_other_amt
  13595. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13596. }
  13597. if checkCostTotal != 0 {
  13598. iteminfo.MedChrgitm = "03"
  13599. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13600. iteminfo.Amt = checkCostTotal
  13601. iteminfo.ClaaSumfee = check_claa_sunmfee
  13602. iteminfo.ClabAmt = check_clab_amt
  13603. iteminfo.OthAmt = check_other_amt
  13604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13605. }
  13606. if laboratoryCostTotal != 0 {
  13607. iteminfo.MedChrgitm = "04"
  13608. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13609. iteminfo.Amt = laboratoryCostTotal
  13610. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13611. iteminfo.ClabAmt = laboratory_clab_amt
  13612. iteminfo.OthAmt = laboratory_other_amt
  13613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13614. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13615. }
  13616. if treatCostTotal != 0 {
  13617. iteminfo.MedChrgitm = "05"
  13618. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13619. iteminfo.Amt = treatCostTotal
  13620. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13621. iteminfo.ClabAmt = treat_clab_amt
  13622. iteminfo.OthAmt = treat_other_amt
  13623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13624. //(struct4101.IteminfoStruct, iteminfo)
  13625. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13626. }
  13627. if operationCostTotal != 0 {
  13628. iteminfo.MedChrgitm = "06"
  13629. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13630. iteminfo.Amt = operationCostTotal
  13631. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13632. iteminfo.ClabAmt = operation_clab_amt
  13633. iteminfo.OthAmt = operation_other_amt
  13634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13635. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13636. }
  13637. if materialCostTotal != 0 {
  13638. iteminfo.MedChrgitm = "08"
  13639. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13640. iteminfo.Amt = materialCostTotal
  13641. iteminfo.ClaaSumfee = material_claa_sunmfee
  13642. iteminfo.ClabAmt = material_clab_amt
  13643. iteminfo.OthAmt = material_other_amt
  13644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13645. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13646. }
  13647. if westernMedicineCostTotal != 0 {
  13648. iteminfo.MedChrgitm = "09"
  13649. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13650. iteminfo.Amt = westernMedicineCostTotal
  13651. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13652. iteminfo.ClabAmt = westernMedicine_clab_amt
  13653. iteminfo.OthAmt = westernMedicine_other_amt
  13654. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13655. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13656. }
  13657. if chineseTraditionalMedicineCostTotal != 0 {
  13658. iteminfo.MedChrgitm = "11"
  13659. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13660. iteminfo.Amt = westernMedicineCostTotal
  13661. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13662. iteminfo.ClabAmt = westernMedicine_clab_amt
  13663. iteminfo.OthAmt = westernMedicine_other_amt
  13664. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13665. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13666. }
  13667. if otherCostTotal != 0 {
  13668. iteminfo.MedChrgitm = "14"
  13669. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13670. iteminfo.Amt = otherCostTotal
  13671. iteminfo.ClaaSumfee = other_claa_sunmfee
  13672. iteminfo.ClabAmt = other_clab_amt
  13673. iteminfo.OthAmt = other_other_amt
  13674. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13675. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13676. }
  13677. struct4101.IteminfoStruct = iteminfoStructs
  13678. struct4101.Ntly = "中国"
  13679. struct4101.AdmCaty = "A03.06"
  13680. var resOther ResultSeventeenOther
  13681. var res ResultSeventeen
  13682. if miConfig.MdtrtareaAdmvs == "150499" {
  13683. var pp models.PublicParams
  13684. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13685. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13686. pp.FixmedinsName = miConfig.OrgName
  13687. pp.FixmedinsCode = miConfig.Code
  13688. pp.RequestUrl = miConfig.Url
  13689. pp.Cainfo = miConfig.Cainfo
  13690. pp.SecretKey = miConfig.SecretKey
  13691. pp.AccessKey = miConfig.AccessKey
  13692. pp.OpterName = curRoles.UserName
  13693. client := &http.Client{}
  13694. var req *http.Request
  13695. data := make(map[string]interface{})
  13696. data["struct4101"] = struct4101
  13697. data["pp"] = pp
  13698. bytesData, _ := json.Marshal(data)
  13699. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13700. resp, _ := client.Do(req)
  13701. defer resp.Body.Close()
  13702. body, ioErr := ioutil.ReadAll(resp.Body)
  13703. if ioErr != nil {
  13704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13706. return
  13707. }
  13708. var respJSON map[string]interface{}
  13709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13712. return
  13713. }
  13714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13715. userJSONBytes, _ := json.Marshal(respJSON)
  13716. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13717. utils.ErrorLog("解析失败:%v", err)
  13718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13719. return
  13720. }
  13721. res.InfRefmsgid = resOther.InfRefmsgid
  13722. res.Output = resOther.Output
  13723. res.ErrMsg = resOther.ErrMsg
  13724. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13725. res.Infcode = infocode
  13726. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13727. var pp models.PublicParams
  13728. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13729. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13730. pp.FixmedinsName = miConfig.OrgName
  13731. pp.FixmedinsCode = miConfig.Code
  13732. pp.RequestUrl = miConfig.Url
  13733. pp.Cainfo = miConfig.Cainfo
  13734. pp.SecretKey = miConfig.SecretKey
  13735. pp.AccessKey = miConfig.AccessKey
  13736. pp.OpterName = curRoles.UserName
  13737. result, _ := service.Jxyb4101(struct4101, pp)
  13738. var dat map[string]interface{}
  13739. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13740. fmt.Println(dat)
  13741. } else {
  13742. fmt.Println(err)
  13743. }
  13744. userJSONBytes, _ := json.Marshal(dat)
  13745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13746. utils.ErrorLog("解析失败:%v", err)
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13748. return
  13749. }
  13750. } else {
  13751. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13752. var dat map[string]interface{}
  13753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13754. fmt.Println(dat)
  13755. } else {
  13756. fmt.Println(err)
  13757. }
  13758. userJSONBytes, _ := json.Marshal(dat)
  13759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13760. utils.ErrorLog("解析失败:%v", err)
  13761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13762. return
  13763. }
  13764. }
  13765. if res.Infcode != 0 {
  13766. c.ServeSuccessJSON(map[string]interface{}{
  13767. "failed_code": -10,
  13768. "msg": res.ErrMsg,
  13769. })
  13770. return
  13771. } else {
  13772. if miConfig.MdtrtareaAdmvs != "150499" {
  13773. order.FaPiaoNumber = zero
  13774. order.FaPiaoCode = last_order.FaPiaoCode
  13775. service.UpdateOrder(order)
  13776. }
  13777. hisFundSettleListResult := &models.HisFundSettleListResult{
  13778. Number: res.Output.SetlListId,
  13779. Status: 1,
  13780. Ctime: time.Now().Unix(),
  13781. Mtime: time.Now().Unix(),
  13782. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13783. IsUpload: 1,
  13784. OrderId: order_id,
  13785. }
  13786. service.CreateUploadRecord(hisFundSettleListResult)
  13787. c.ServeSuccessJSON(map[string]interface{}{
  13788. "msg": "上传成功",
  13789. "result": hisFundSettleListResult,
  13790. })
  13791. return
  13792. }
  13793. }
  13794. //func (c *HisApiController) GetBatchSettleList() {
  13795. // orders, _ := service.GetAllHisOrder(10106)
  13796. // for _, item := range orders {
  13797. // order_id := item.ID
  13798. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13799. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13800. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13801. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13802. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13803. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13804. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13805. //
  13806. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13807. //
  13808. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13809. //
  13810. // if order.ID == 0 {
  13811. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13812. // return
  13813. // }
  13814. // if his.BalanceAccountsType == 2 {
  13815. // continue
  13816. // }
  13817. // struct4101 := service.Struct4101{
  13818. // PsnNo: order.PsnNo,
  13819. // MdtrtId: order.MdtrtId,
  13820. // SetlId: order.SetlId,
  13821. // PsnName: order.PsnName,
  13822. // Gend: order.Gend,
  13823. // Brdy: his.Brdy,
  13824. // Age: his.Age,
  13825. // Naty: order.Naty,
  13826. // PatnCertType: "01",
  13827. // Certno: order.Certno,
  13828. // Prfs: "90",
  13829. // ConerName: roles[0].UserName,
  13830. // PatnRlts: "99",
  13831. // ConerAddr: miConfig.OrgName,
  13832. // ConerTel: admin.Mobile,
  13833. // HiType: order.Insutype,
  13834. // Insuplc: his.InsuplcAdmdvs,
  13835. // MaindiagFlag: "1",
  13836. // BillCode: order.SetlId,
  13837. // BillNo: order.SetlId,
  13838. // BizSn: order.Number,
  13839. // PsnSelfPay: order.PsnPartAmt,
  13840. // PsnOwnPay: order.PsnPartAmt,
  13841. // AcctPay: order.AcctPay,
  13842. // PsnCashpay: order.PsnCashPay,
  13843. // HiPaymtd: "1",
  13844. // Hsorg: his.InsuplcAdmdvs,
  13845. // HsorgOpter: his.InsuplcAdmdvs,
  13846. // MedinsFillPsn: curRoles.UserName,
  13847. // MedinsFillDept: depart.Name,
  13848. // IptMedType: "2",
  13849. // }
  13850. // struct4101.SetlBegnDate = order.SetlTime
  13851. // struct4101.SetlEndDate = order.SetlTime
  13852. // //if order.SettleType == 1 {
  13853. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13854. // // dateStr := t.Format("2006-01-02")
  13855. // // struct4101.SetlBegnDate = dateStr
  13856. // // struct4101.SetlEndDate = dateStr
  13857. // //} else {
  13858. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13859. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13860. // // dateStartStr := t.Format("2006-01-02")
  13861. // // dateEndStr := t2.Format("2006-01-02")
  13862. // // struct4101.SetlBegnDate = dateStartStr
  13863. // // struct4101.SetlEndDate = dateEndStr
  13864. // //}
  13865. //
  13866. // var rf []CustomFundPay
  13867. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13868. //
  13869. // var tempFunPays []service.CustomStruct
  13870. // var tempFunPay610100 service.CustomStruct
  13871. //
  13872. // for _, item := range rf {
  13873. // if item.FundPayType == "610100" {
  13874. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13875. // tempFunPay610100.FundPayType = item.FundPayType
  13876. // } else {
  13877. // var tempFunPay service.CustomStruct
  13878. // tempFunPay.FundPayamt = item.FundPayamt
  13879. // tempFunPay.FundPayType = item.FundPayType
  13880. // tempFunPays = append(tempFunPays, tempFunPay)
  13881. // }
  13882. // }
  13883. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13884. // struct4101.CustomStruct = tempFunPays
  13885. //
  13886. // var tempDiaginfos []service.DiaginfoStructTwo
  13887. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13888. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13889. //
  13890. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13891. // var config []*models.HisXtDiagnoseConfig
  13892. // for _, item := range diagnosis_ids {
  13893. // id, _ := strconv.ParseInt(item, 10, 64)
  13894. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13895. // config = append(config, &diagnosisConfig)
  13896. // }
  13897. //
  13898. // for index, item := range config {
  13899. // if index == 0 {
  13900. // var tempDiaginfo service.DiaginfoStructTwo
  13901. // tempDiaginfo.DiagCode = item.CountryCode
  13902. // tempDiaginfo.DiagName = item.CountryContentName
  13903. // tempDiaginfo.DiagType = "1"
  13904. // tempDiaginfo.MaindiagFlag = "1"
  13905. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13906. // } else {
  13907. //
  13908. // var tempDiaginfo service.DiaginfoStructTwo
  13909. // tempDiaginfo.DiagCode = item.CountryCode
  13910. // tempDiaginfo.DiagName = item.CountryContentName
  13911. // tempDiaginfo.DiagType = "2"
  13912. // tempDiaginfo.MaindiagFlag = "0"
  13913. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13914. // }
  13915. // }
  13916. // struct4101.Diseinfo = tempDiaginfos
  13917. //
  13918. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13919. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13920. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13921. // tempOpspdiseinfo2.OprnOprtCode = ""
  13922. // tempOpspdiseinfo2.OprnOprtName = ""
  13923. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13924. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13925. //
  13926. // var iteminfo service.IteminfoStruct
  13927. //
  13928. // var bedCostTotal float64 = 0 //床位总费
  13929. // var bedCostSelfTotal float64 = 0 //床位自费
  13930. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13931. //
  13932. // var examineCostTotal float64 = 0 //诊查总费
  13933. // var examineCostSelfTotal float64 = 0 //诊查自费
  13934. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13935. //
  13936. // var nursingCostTotal float64 = 0 //护理总费
  13937. // var nursingCostSelfTotal float64 = 0 //护理自费
  13938. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13939. //
  13940. // var chineseMedicineCostTotal float64 = 0 //中成药
  13941. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13942. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13943. //
  13944. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13945. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13946. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13947. //
  13948. // var registerCostTotal float64 = 0 //一般诊疗费
  13949. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13950. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13951. //
  13952. // var operationCostTotal float64 = 0 //手术费
  13953. // var operationCostSelfTotal float64 = 0 //手术费
  13954. // var operationCostPartSelfTotal float64 = 0 //手术费
  13955. //
  13956. // var otherCostTotal float64 = 0 //其他费用
  13957. // var otherCostSelfTotal float64 = 0 //其他费用
  13958. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13959. //
  13960. // var materialCostTotal float64 = 0 //材料费
  13961. // var materialCostSelfTotal float64 = 0 //材料费
  13962. // var materialCostPartSelfTotal float64 = 0 //材料费
  13963. //
  13964. // var westernMedicineCostTotal float64 = 0 //西药费
  13965. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13966. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13967. //
  13968. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13969. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13970. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13971. //
  13972. // var checkCostTotal float64 = 0 //检查费
  13973. // var checkCostSelfTotal float64 = 0 //检查费
  13974. // var checkCostPartSelfTotal float64 = 0 //检查费
  13975. //
  13976. // var laboratoryCostTotal float64 = 0 //化验费
  13977. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13978. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13979. //
  13980. // var treatCostTotal float64 = 0 //治疗费用
  13981. // var treatCostSelfTotal float64 = 0 //治疗费用
  13982. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13983. //
  13984. // decimal.DivisionPrecision = 2
  13985. //
  13986. // var bed_fulamt_ownpay_amt float64 = 0
  13987. //
  13988. // var examine_fulamt_ownpay_amt float64 = 0
  13989. //
  13990. // var nursing_fulamt_ownpay_amt float64 = 0
  13991. //
  13992. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  13993. //
  13994. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  13995. //
  13996. // var register_fulamt_ownpay_amt float64 = 0
  13997. //
  13998. // var operation_fulamt_ownpay_amt float64 = 0
  13999. // var other_fulamt_ownpay_amt float64 = 0
  14000. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14001. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14002. // var check_fulamt_ownpay_amt float64 = 0
  14003. // var material_fulamt_ownpay_amt float64 = 0
  14004. // var laboratory_fulamt_ownpay_amt float64 = 0
  14005. // var treat_fulamt_ownpay_amt float64 = 0
  14006. //
  14007. // var bed_claa_sunmfee float64 = 0
  14008. // var bed_clab_amt float64 = 0
  14009. // var bed_other_amt float64 = 0
  14010. //
  14011. // var examine_claa_sunmfee float64 = 0
  14012. // var examine_clab_amt float64 = 0
  14013. // var examine_other_amt float64 = 0
  14014. //
  14015. // var nursing_claa_sunmfee float64 = 0
  14016. // var nursing_clab_amt float64 = 0
  14017. // var nursing_other_amt float64 = 0
  14018. //
  14019. // var chinese_medicine_claa_sunmfee float64 = 0
  14020. // var chinese_medicine_clab_amt float64 = 0
  14021. // var chinese_medicine_other_amt float64 = 0
  14022. //
  14023. // var commonly_treatment_claa_sunmfee float64 = 0
  14024. // var commonly_treatment_clab_amt float64 = 0
  14025. // var commonly_treatment_other_amt float64 = 0
  14026. //
  14027. // var operation_claa_sunmfee float64 = 0
  14028. // var operation_clab_amt float64 = 0
  14029. // var operation_other_amt float64 = 0
  14030. //
  14031. // var other_claa_sunmfee float64 = 0
  14032. // var other_clab_amt float64 = 0
  14033. // var other_other_amt float64 = 0
  14034. //
  14035. // var westernMedicine_claa_sunmfee float64 = 0
  14036. // var westernMedicine_clab_amt float64 = 0
  14037. // var westernMedicine_other_amt float64 = 0
  14038. //
  14039. // var chineseTraditional_claa_sunmfee float64 = 0
  14040. // var chineseTraditional_clab_amt float64 = 0
  14041. // var chineseTraditional_other_amt float64 = 0
  14042. //
  14043. // var check_claa_sunmfee float64 = 0
  14044. // var check_clab_amt float64 = 0
  14045. // var check_other_amt float64 = 0
  14046. //
  14047. // var material_claa_sunmfee float64 = 0
  14048. // var material_clab_amt float64 = 0
  14049. // var material_other_amt float64 = 0
  14050. //
  14051. // var laboratory_claa_sunmfee float64 = 0
  14052. // var laboratory_clab_amt float64 = 0
  14053. // var laboratory_other_amt float64 = 0
  14054. //
  14055. // var treat_claa_sunmfee float64 = 0
  14056. // var treat_clab_amt float64 = 0
  14057. // var treat_other_amt float64 = 0
  14058. //
  14059. // var register_claa_sunmfee float64 = 0
  14060. // var register_clab_amt float64 = 0
  14061. // var register_other_amt float64 = 0
  14062. //
  14063. // for _, item := range order.HisOrderInfo {
  14064. // if item.MedChrgitmType == "01" { //床位费
  14065. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14066. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14067. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14068. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14069. // if item.ChrgitmLv == "1" {
  14070. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14071. // }
  14072. // if item.ChrgitmLv == "2" {
  14073. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14074. //
  14075. // }
  14076. // if item.ChrgitmLv == "3" {
  14077. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14078. // }
  14079. //
  14080. // }
  14081. //
  14082. // if item.MedChrgitmType == "02" { //诊查
  14083. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14084. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14085. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14086. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14087. // if item.ChrgitmLv == "1" {
  14088. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14089. // }
  14090. // if item.ChrgitmLv == "2" {
  14091. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14092. //
  14093. // }
  14094. // if item.ChrgitmLv == "3" {
  14095. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14096. // }
  14097. //
  14098. // }
  14099. //
  14100. // if item.MedChrgitmType == "03" { //检查费
  14101. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14102. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14103. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14104. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14105. // if item.ChrgitmLv == "1" {
  14106. //
  14107. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14108. //
  14109. // }
  14110. // if item.ChrgitmLv == "2" {
  14111. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14112. //
  14113. // }
  14114. // if item.ChrgitmLv == "3" {
  14115. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14116. // }
  14117. // }
  14118. //
  14119. // if item.MedChrgitmType == "04" { //化验费
  14120. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14121. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14122. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14123. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14124. // if item.ChrgitmLv == "1" {
  14125. //
  14126. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14127. //
  14128. // }
  14129. // if item.ChrgitmLv == "2" {
  14130. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14131. //
  14132. // }
  14133. // if item.ChrgitmLv == "3" {
  14134. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14135. // }
  14136. // }
  14137. //
  14138. // if item.MedChrgitmType == "05" { //治疗费
  14139. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14140. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14141. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14142. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14143. // if item.ChrgitmLv == "1" {
  14144. //
  14145. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14146. //
  14147. // }
  14148. // if item.ChrgitmLv == "2" {
  14149. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14150. //
  14151. // }
  14152. // if item.ChrgitmLv == "3" {
  14153. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14154. // }
  14155. // }
  14156. //
  14157. // if item.MedChrgitmType == "06" { //手术费
  14158. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14159. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14160. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14161. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14162. //
  14163. // if item.ChrgitmLv == "1" {
  14164. //
  14165. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14166. //
  14167. // }
  14168. // if item.ChrgitmLv == "2" {
  14169. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14170. //
  14171. // }
  14172. // if item.ChrgitmLv == "3" {
  14173. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14174. // }
  14175. // }
  14176. //
  14177. // if item.MedChrgitmType == "07" { //手术费
  14178. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14179. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14180. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14181. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14182. //
  14183. // if item.ChrgitmLv == "1" {
  14184. //
  14185. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14186. //
  14187. // }
  14188. // if item.ChrgitmLv == "2" {
  14189. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14190. //
  14191. // }
  14192. // if item.ChrgitmLv == "3" {
  14193. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14194. // }
  14195. // }
  14196. //
  14197. // if item.MedChrgitmType == "08" { //材料费
  14198. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14199. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14200. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14201. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14202. // if item.ChrgitmLv == "1" {
  14203. //
  14204. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14205. //
  14206. // }
  14207. // if item.ChrgitmLv == "2" {
  14208. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14209. //
  14210. // }
  14211. // if item.ChrgitmLv == "3" {
  14212. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14213. // }
  14214. // }
  14215. // if item.MedChrgitmType == "09" { //西药费
  14216. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14217. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14218. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14219. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14220. // if item.ChrgitmLv == "1" {
  14221. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14222. // }
  14223. // if item.ChrgitmLv == "2" {
  14224. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14225. // }
  14226. // if item.ChrgitmLv == "3" {
  14227. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14228. // }
  14229. // }
  14230. // if item.MedChrgitmType == "10" { //中药饮片
  14231. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14232. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14233. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14234. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14235. // if item.ChrgitmLv == "1" {
  14236. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14237. // }
  14238. // if item.ChrgitmLv == "2" {
  14239. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14240. // }
  14241. // if item.ChrgitmLv == "3" {
  14242. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14243. // }
  14244. // }
  14245. //
  14246. // if item.MedChrgitmType == "11" { //中成费
  14247. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14248. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14249. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14250. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14251. // if item.ChrgitmLv == "1" {
  14252. //
  14253. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14254. //
  14255. // }
  14256. // if item.ChrgitmLv == "2" {
  14257. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14258. //
  14259. // }
  14260. // if item.ChrgitmLv == "3" {
  14261. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14262. // }
  14263. // }
  14264. //
  14265. // if item.MedChrgitmType == "12" { //中成费
  14266. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14267. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14268. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14269. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14270. // if item.ChrgitmLv == "1" {
  14271. //
  14272. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14273. //
  14274. // }
  14275. // if item.ChrgitmLv == "2" {
  14276. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14277. //
  14278. // }
  14279. // if item.ChrgitmLv == "3" {
  14280. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14281. // }
  14282. // }
  14283. //
  14284. // if item.MedChrgitmType == "13" { //中成费
  14285. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14286. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14287. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14288. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14289. // if item.ChrgitmLv == "1" {
  14290. //
  14291. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14292. //
  14293. // }
  14294. // if item.ChrgitmLv == "2" {
  14295. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14296. //
  14297. // }
  14298. // if item.ChrgitmLv == "3" {
  14299. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14300. // }
  14301. // }
  14302. //
  14303. // if item.MedChrgitmType == "14" { //其他费
  14304. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14305. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14306. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14307. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14308. // if item.ChrgitmLv == "1" {
  14309. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14310. //
  14311. // }
  14312. // if item.ChrgitmLv == "2" {
  14313. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14314. //
  14315. // }
  14316. // if item.ChrgitmLv == "3" {
  14317. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14318. // }
  14319. // }
  14320. //
  14321. // }
  14322. //
  14323. // var iteminfoStructs []service.IteminfoStruct
  14324. //
  14325. // if bedCostTotal != 0 {
  14326. // iteminfo.MedChrgitm = "01"
  14327. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14328. // iteminfo.Amt = bedCostTotal
  14329. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14330. // iteminfo.ClabAmt = bed_clab_amt
  14331. // iteminfo.OthAmt = bed_other_amt
  14332. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14333. // }
  14334. //
  14335. // if examineCostTotal != 0 {
  14336. // iteminfo.MedChrgitm = "02"
  14337. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14338. // iteminfo.Amt = examineCostTotal
  14339. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14340. // iteminfo.ClabAmt = examine_clab_amt
  14341. // iteminfo.OthAmt = examine_other_amt
  14342. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14343. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14344. // }
  14345. //
  14346. // if checkCostTotal != 0 {
  14347. // iteminfo.MedChrgitm = "03"
  14348. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14349. // iteminfo.Amt = checkCostTotal
  14350. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14351. // iteminfo.ClabAmt = check_clab_amt
  14352. // iteminfo.OthAmt = check_other_amt
  14353. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14354. //
  14355. // }
  14356. //
  14357. // if laboratoryCostTotal != 0 {
  14358. // iteminfo.MedChrgitm = "04"
  14359. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14360. // iteminfo.Amt = laboratoryCostTotal
  14361. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14362. // iteminfo.ClabAmt = laboratory_clab_amt
  14363. // iteminfo.OthAmt = laboratory_other_amt
  14364. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14365. //
  14366. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14367. //
  14368. // }
  14369. //
  14370. // if treatCostTotal != 0 {
  14371. // iteminfo.MedChrgitm = "05"
  14372. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14373. // iteminfo.Amt = treatCostTotal
  14374. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14375. // iteminfo.ClabAmt = treat_clab_amt
  14376. // iteminfo.OthAmt = treat_other_amt
  14377. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14378. // //(struct4101.IteminfoStruct, iteminfo)
  14379. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14380. // }
  14381. //
  14382. // if operationCostTotal != 0 {
  14383. // iteminfo.MedChrgitm = "06"
  14384. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14385. // iteminfo.Amt = operationCostTotal
  14386. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14387. // iteminfo.ClabAmt = operation_clab_amt
  14388. // iteminfo.OthAmt = operation_other_amt
  14389. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14390. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14391. // }
  14392. //
  14393. // if nursingCostTotal != 0 {
  14394. // iteminfo.MedChrgitm = "07"
  14395. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14396. // iteminfo.Amt = nursingCostTotal
  14397. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14398. // iteminfo.ClabAmt = nursing_clab_amt
  14399. // iteminfo.OthAmt = nursing_other_amt
  14400. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14401. // }
  14402. //
  14403. // if materialCostTotal != 0 {
  14404. // iteminfo.MedChrgitm = "08"
  14405. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14406. // iteminfo.Amt = materialCostTotal
  14407. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14408. // iteminfo.ClabAmt = material_clab_amt
  14409. // iteminfo.OthAmt = material_other_amt
  14410. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14411. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14412. // }
  14413. //
  14414. // if westernMedicineCostTotal != 0 {
  14415. // iteminfo.MedChrgitm = "09"
  14416. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14417. // iteminfo.Amt = westernMedicineCostTotal
  14418. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14419. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14420. // iteminfo.OthAmt = westernMedicine_other_amt
  14421. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14422. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14423. //
  14424. // }
  14425. //
  14426. // if chineseMedicineCostTotal != 0 {
  14427. // iteminfo.MedChrgitm = "10"
  14428. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14429. // iteminfo.Amt = chineseMedicineCostTotal
  14430. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14431. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14432. // iteminfo.OthAmt = chinese_medicine_other_amt
  14433. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14434. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14435. //
  14436. // }
  14437. //
  14438. // if chineseTraditionalMedicineCostTotal != 0 {
  14439. // iteminfo.MedChrgitm = "11"
  14440. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14441. // iteminfo.Amt = westernMedicineCostTotal
  14442. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14443. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14444. // iteminfo.OthAmt = westernMedicine_other_amt
  14445. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14446. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14447. //
  14448. // }
  14449. //
  14450. // if commonlyTreatmentCostTotal != 0 {
  14451. // iteminfo.MedChrgitm = "12"
  14452. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14453. // iteminfo.Amt = commonlyTreatmentCostTotal
  14454. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14455. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14456. // iteminfo.OthAmt = commonly_treatment_other_amt
  14457. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14458. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14459. //
  14460. // }
  14461. //
  14462. // if registerCostTotal != 0 {
  14463. // iteminfo.MedChrgitm = "13"
  14464. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14465. // iteminfo.Amt = registerCostTotal
  14466. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14467. // iteminfo.ClabAmt = register_clab_amt
  14468. // iteminfo.OthAmt = register_other_amt
  14469. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14470. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14471. //
  14472. // }
  14473. //
  14474. // if otherCostTotal != 0 {
  14475. // iteminfo.MedChrgitm = "14"
  14476. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14477. // iteminfo.Amt = otherCostTotal
  14478. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14479. // iteminfo.ClabAmt = other_clab_amt
  14480. // iteminfo.OthAmt = other_other_amt
  14481. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14482. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14483. //
  14484. // }
  14485. // struct4101.IteminfoStruct = iteminfoStructs
  14486. // time_arr := strings.Split(order.SetlTime, " ")
  14487. // struct4101.AdmTime = time_arr[0]
  14488. // struct4101.AdmEndTime = time_arr[0]
  14489. //
  14490. // struct4101.DoctorName = doctor.UserName
  14491. // struct4101.DoctorCode = doctor.DoctorNumber
  14492. //
  14493. // struct4101.Ntly = "中国"
  14494. // struct4101.AdmCaty = "A03.06"
  14495. // var res ResultSeventeen
  14496. // if miConfig.MdtrtareaAdmvs == "421300" {
  14497. // data := make(map[string]interface{})
  14498. // data["struct4101"] = struct4101
  14499. // data["secret_key"] = miConfig.SecretKey
  14500. // data["org_name"] = miConfig.OrgName
  14501. // data["opera"] = curRoles.UserName
  14502. // data["code"] = miConfig.Code
  14503. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14504. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14505. //
  14506. // client := &http.Client{}
  14507. // bytesData, _ := json.Marshal(data)
  14508. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14509. // resp, _ := client.Do(req)
  14510. // defer resp.Body.Close()
  14511. // body, ioErr := ioutil.ReadAll(resp.Body)
  14512. // if ioErr != nil {
  14513. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14515. // return
  14516. // }
  14517. // var respJSON map[string]interface{}
  14518. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14519. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14521. // return
  14522. // }
  14523. //
  14524. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14525. // userJSONBytes, _ := json.Marshal(respJSON)
  14526. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14527. // utils.ErrorLog("解析失败:%v", err)
  14528. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14529. // adminUser := c.GetAdminUserInfo()
  14530. // errlog := &models.HisOrderError{
  14531. // UserOrgId: adminUser.CurrentOrgId,
  14532. // Ctime: time.Now().Unix(),
  14533. // Mtime: time.Now().Unix(),
  14534. // ErrMsg: res.ErrMsg + "解析失败",
  14535. // Status: 1,
  14536. // PatientId: order_id,
  14537. // Stage: 10088,
  14538. // }
  14539. // service.CreateErrMsgLog(errlog)
  14540. // continue
  14541. // }
  14542. //
  14543. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14544. // data := make(map[string]interface{})
  14545. // data["struct4101"] = struct4101
  14546. // data["secret_key"] = miConfig.SecretKey
  14547. // data["org_name"] = miConfig.OrgName
  14548. // data["opera"] = curRoles.UserName
  14549. // data["code"] = miConfig.Code
  14550. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14551. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14552. //
  14553. // client := &http.Client{}
  14554. // bytesData, _ := json.Marshal(data)
  14555. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14556. // resp, _ := client.Do(req)
  14557. // defer resp.Body.Close()
  14558. // body, ioErr := ioutil.ReadAll(resp.Body)
  14559. // if ioErr != nil {
  14560. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14562. // return
  14563. // }
  14564. // var respJSON map[string]interface{}
  14565. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14566. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14567. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14568. // return
  14569. // }
  14570. //
  14571. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14572. // userJSONBytes, _ := json.Marshal(respJSON)
  14573. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14574. // utils.ErrorLog("解析失败:%v", err)
  14575. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14576. // adminUser := c.GetAdminUserInfo()
  14577. // errlog := &models.HisOrderError{
  14578. // UserOrgId: adminUser.CurrentOrgId,
  14579. // Ctime: time.Now().Unix(),
  14580. // Mtime: time.Now().Unix(),
  14581. // ErrMsg: res.ErrMsg + "解析失败",
  14582. // Status: 1,
  14583. // PatientId: order_id,
  14584. // Stage: 10088,
  14585. // }
  14586. // service.CreateErrMsgLog(errlog)
  14587. // continue
  14588. // }
  14589. //
  14590. // } else {
  14591. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14592. // fmt.Println(result)
  14593. //
  14594. // var dat map[string]interface{}
  14595. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14596. // fmt.Println(dat)
  14597. // } else {
  14598. // fmt.Println(err)
  14599. // }
  14600. // userJSONBytes, _ := json.Marshal(dat)
  14601. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14602. // utils.ErrorLog("解析失败:%v", err)
  14603. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14604. // adminUser := c.GetAdminUserInfo()
  14605. // errlog := &models.HisOrderError{
  14606. // UserOrgId: adminUser.CurrentOrgId,
  14607. // Ctime: time.Now().Unix(),
  14608. // Mtime: time.Now().Unix(),
  14609. // ErrMsg: res.ErrMsg + "解析失败",
  14610. // Status: 1,
  14611. // PatientId: order_id,
  14612. // Stage: 10106,
  14613. // }
  14614. // service.CreateErrMsgLog(errlog)
  14615. // continue
  14616. // }
  14617. // }
  14618. //
  14619. // if res.Infcode != 0 {
  14620. // adminUser := c.GetAdminUserInfo()
  14621. // errlog := &models.HisOrderError{
  14622. // UserOrgId: adminUser.CurrentOrgId,
  14623. // Ctime: time.Now().Unix(),
  14624. // Mtime: time.Now().Unix(),
  14625. // ErrMsg: res.ErrMsg,
  14626. // Status: 1,
  14627. // PatientId: order_id,
  14628. // Stage: 10106,
  14629. // }
  14630. // service.CreateErrMsgLog(errlog)
  14631. // continue
  14632. // } else {
  14633. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14634. // Number: res.Output.SetlListId,
  14635. // Status: 1,
  14636. // Ctime: time.Now().Unix(),
  14637. // Mtime: time.Now().Unix(),
  14638. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14639. // IsUpload: 1,
  14640. // OrderId: order_id,
  14641. // }
  14642. // service.CreateUploadRecord(hisFundSettleListResult)
  14643. // continue
  14644. // }
  14645. // }
  14646. //}
  14647. func (c *HisApiController) GetOrgInfo() {
  14648. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14649. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14650. }
  14651. func (c *HisApiController) GetHisPatientInfo() {
  14652. medical_insurance_card := c.GetString("medical_insurance_card")
  14653. id_card_type, _ := c.GetInt64("id_card_type")
  14654. id_card := c.GetString("id_card")
  14655. adminInfo := c.GetAdminUserInfo()
  14656. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14657. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14658. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14659. IdCardNo := ""
  14660. if id_card_type == 1 {
  14661. IdCardNo = medical_insurance_card
  14662. } else if id_card_type == 2 {
  14663. IdCardNo = id_card
  14664. }
  14665. if config.IsOpen == 1 {
  14666. 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
  14667. resp, requestErr := http.Get(api)
  14668. if requestErr != nil {
  14669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14670. return
  14671. }
  14672. defer resp.Body.Close()
  14673. body, ioErr := ioutil.ReadAll(resp.Body)
  14674. if ioErr != nil {
  14675. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14677. return
  14678. }
  14679. var respJSON map[string]interface{}
  14680. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14681. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14683. return
  14684. }
  14685. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14686. userJSONBytes, _ := json.Marshal(userJSON)
  14687. var res ResultTwo
  14688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14689. utils.ErrorLog("解析失败:%v", err)
  14690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14691. return
  14692. }
  14693. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14694. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14695. infoStr := string(Iinfos)
  14696. idetinfoStr := string(Idetinfos)
  14697. if res.Infcode == 0 {
  14698. his := models.VMHisPatient{
  14699. Status: 1,
  14700. Ctime: time.Now().Unix(),
  14701. Mtime: time.Now().Unix(),
  14702. PsnNo: res.Output.Baseinfo.PsnNo,
  14703. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14704. Certno: res.Output.Baseinfo.Certno,
  14705. PsnName: res.Output.Baseinfo.PsnName,
  14706. Gend: res.Output.Baseinfo.Gend,
  14707. Naty: res.Output.Baseinfo.Naty,
  14708. Iinfo: infoStr,
  14709. Idetinfo: idetinfoStr,
  14710. UserOrgId: adminInfo.CurrentOrgId,
  14711. IsReturn: 1,
  14712. IdCardType: id_card_type,
  14713. }
  14714. c.ServeSuccessJSON(map[string]interface{}{
  14715. "info": his,
  14716. })
  14717. } else {
  14718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14719. return
  14720. }
  14721. }
  14722. }
  14723. //func GetBasBaseInfo() (jsonStr string, err error) {
  14724. //
  14725. // handle := syscall.NewLazyDLL("SSCard.dll")
  14726. // add := handle.NewProc("ReadCardBas")
  14727. // str := make([]byte, 1024)
  14728. // str1 := make([]byte, 1024)
  14729. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14730. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14731. //
  14732. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14733. //
  14734. // fmt.Println("> Add(4,5)的结果为:", ret)
  14735. // handle.Release()
  14736. //
  14737. // return "", nil
  14738. //
  14739. //}
  14740. //func GetQRBaseInfo() (jsonStr string, err error) {
  14741. // handle := syscall.LoadDLL("SSCard.dll")
  14742. // ReadCardBas := handle.FindProc("GetQRBase")
  14743. //
  14744. // str := make([]byte, 256)
  14745. // str1 := make([]byte, 256)
  14746. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14747. //
  14748. // fmt.Println(string(str))
  14749. // fmt.Println(r)
  14750. // return string(str), nil
  14751. //}
  14752. //func CardInit() int {
  14753. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14754. // add := DllTestDef.MustFindProc("Init")
  14755. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14756. // if err != nil {
  14757. // fmt.Println("SSCard的运算结果为:", ret)
  14758. // }
  14759. // result := int(ret)
  14760. // return result
  14761. //}
  14762. //func CardInit() int {
  14763. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14764. // if err != nil {
  14765. // fmt.Println("SSCard的运算结果为:", ret)
  14766. // }
  14767. // fmt.Println(err)
  14768. // result := int(ret)
  14769. // return result
  14770. //}
  14771. func IntPtr(n int) uintptr {
  14772. return uintptr(n)
  14773. }
  14774. func StrPtr(s string) uintptr {
  14775. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14776. }
  14777. type Result2001 struct {
  14778. Cainfo interface{} `json:"cainfo"`
  14779. ErrMsg string `json:"err_msg"`
  14780. InfRefmsgid string `json:"inf_refmsgid"`
  14781. Infcode int64 `json:"infcode"`
  14782. Output struct {
  14783. Trtinfo struct {
  14784. PsnNo string `json:"psn_no"`
  14785. TrtChkType string `json:"trt_chk_type"`
  14786. FundPayType string `json:"fund_pay_type"`
  14787. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14788. Begndate string `json:"begndate"`
  14789. Enddate string `json:"enddate"`
  14790. TrtChkRslt string `json:"trt_chk_rslt"`
  14791. } `json:"trtinfo"`
  14792. } `json:"output"`
  14793. RefmsgTime string `json:"refmsg_time"`
  14794. RespondTime string `json:"respond_time"`
  14795. Signtype interface{} `json:"signtype"`
  14796. WarnMsg interface{} `json:"warn_msg"`
  14797. }
  14798. type Result2001Org10265 struct {
  14799. Cainfo interface{} `json:"cainfo"`
  14800. ErrMsg string `json:"err_msg"`
  14801. InfRefmsgid string `json:"inf_refmsgid"`
  14802. Infcode string `json:"infcode"`
  14803. Output struct {
  14804. Trtinfo struct {
  14805. PsnNo string `json:"psn_no"`
  14806. TrtChkType string `json:"trt_chk_type"`
  14807. FundPayType string `json:"fund_pay_type"`
  14808. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14809. Begndate string `json:"begndate"`
  14810. Enddate string `json:"enddate"`
  14811. TrtChkRslt string `json:"trt_chk_rslt"`
  14812. } `json:"trtinfo"`
  14813. } `json:"output"`
  14814. RefmsgTime string `json:"refmsg_time"`
  14815. RespondTime string `json:"respond_time"`
  14816. Signtype interface{} `json:"signtype"`
  14817. WarnMsg interface{} `json:"warn_msg"`
  14818. }
  14819. type ResultTwo struct {
  14820. ErrMsg string `json:"err_msg"`
  14821. InfRefmsgid string `json:"inf_refmsgid"`
  14822. Infcode int64 `json:"infcode"`
  14823. Output struct {
  14824. Baseinfo struct {
  14825. //Brdy string `json:"brdy"`
  14826. Certno string `json:"certno"`
  14827. Gend string `json:"gend"`
  14828. Naty string `json:"naty"`
  14829. PsnCertType string `json:"psn_cert_type"`
  14830. PsnName string `json:"psn_name"`
  14831. PsnNo string `json:"psn_no"`
  14832. } `json:"baseinfo"`
  14833. Idetinfo []interface{} `json:"idetinfo"`
  14834. Iinfo []struct {
  14835. Balc float64 `json:"balc"`
  14836. CvlservFlag string `json:"cvlserv_flag"`
  14837. EmpName string `json:"emp_name"`
  14838. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14839. Insutype string `json:"insutype"`
  14840. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14841. //PausInsuDate string `json:"paus_insu_date"`
  14842. //PsnInsuDate string `json:"psn_insu_date"`
  14843. PsnInsuStas string `json:"psn_insu_stas"`
  14844. PsnType string `json:"psn_type"`
  14845. } `json:"insuinfo"`
  14846. } `json:"output"`
  14847. RefmsgTime string `json:"refmsg_time"`
  14848. RespondTime string `json:"respond_time"`
  14849. Signtype interface{} `json:"signtype"`
  14850. WarnInfo interface{} `json:"warn_info"`
  14851. }
  14852. type ResultTwo10265 struct {
  14853. ErrMsg string `json:"err_msg"`
  14854. InfRefmsgid string `json:"inf_refmsgid"`
  14855. Infcode string `json:"infcode"`
  14856. Output struct {
  14857. Baseinfo struct {
  14858. //Brdy string `json:"brdy"`
  14859. Certno string `json:"certno"`
  14860. Gend string `json:"gend"`
  14861. Naty string `json:"naty"`
  14862. PsnCertType string `json:"psn_cert_type"`
  14863. PsnName string `json:"psn_name"`
  14864. PsnNo string `json:"psn_no"`
  14865. } `json:"baseinfo"`
  14866. Idetinfo []interface{} `json:"idetinfo"`
  14867. Iinfo []struct {
  14868. Balc float64 `json:"balc"`
  14869. CvlservFlag string `json:"cvlserv_flag"`
  14870. EmpName string `json:"emp_name"`
  14871. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14872. Insutype string `json:"insutype"`
  14873. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14874. PsnInsuStas string `json:"psn_insu_stas"`
  14875. PsnType string `json:"psn_type"`
  14876. } `json:"insuinfo"`
  14877. } `json:"output"`
  14878. RefmsgTime string `json:"refmsg_time"`
  14879. RespondTime string `json:"respond_time"`
  14880. Signtype interface{} `json:"signtype"`
  14881. WarnInfo interface{} `json:"warn_info"`
  14882. }
  14883. type ResultThree struct {
  14884. Cainfo interface{} `json:"cainfo"`
  14885. ErrMsg string `json:"err_msg"`
  14886. InfRefmsgid string `json:"inf_refmsgid"`
  14887. Infcode int64 `json:"infcode"`
  14888. Output struct {
  14889. Data struct {
  14890. IptOtpNo string `json:"ipt_otp_no"`
  14891. MdtrtID string `json:"mdtrt_id"`
  14892. PsnNo string `json:"psn_no"`
  14893. } `json:"data"`
  14894. } `json:"output"`
  14895. RefmsgTime string `json:"refmsg_time"`
  14896. RespondTime string `json:"respond_time"`
  14897. Signtype interface{} `json:"signtype"`
  14898. WarnMsg interface{} `json:"warn_msg"`
  14899. }
  14900. type ResultThree10265 struct {
  14901. Cainfo interface{} `json:"cainfo"`
  14902. ErrMsg string `json:"err_msg"`
  14903. InfRefmsgid string `json:"inf_refmsgid"`
  14904. Infcode string `json:"infcode"`
  14905. Output struct {
  14906. Data struct {
  14907. IptOtpNo string `json:"ipt_otp_no"`
  14908. MdtrtID string `json:"mdtrt_id"`
  14909. PsnNo string `json:"psn_no"`
  14910. } `json:"data"`
  14911. } `json:"output"`
  14912. RefmsgTime string `json:"refmsg_time"`
  14913. RespondTime string `json:"respond_time"`
  14914. Signtype interface{} `json:"signtype"`
  14915. WarnMsg interface{} `json:"warn_msg"`
  14916. }
  14917. type ResultFour struct {
  14918. Cainfo string `json:"cainfo"`
  14919. ErrMsg string `json:"err_msg"`
  14920. InfRefmsgid string `json:"inf_refmsgid"`
  14921. Infcode int64 `json:"infcode"`
  14922. Output struct {
  14923. Result []struct {
  14924. BasMednFlag string `json:"bas_medn_flag"`
  14925. ChldMedcFlag string `json:"chld_medc_flag"`
  14926. ChrgitmLv string `json:"chrgitm_lv"`
  14927. Cnt float64 `json:"cnt"`
  14928. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14929. DrtReimFlag string `json:"drt_reim_flag"`
  14930. FeedetlSn string `json:"feedetl_sn"`
  14931. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14932. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14933. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14934. ListSpItemFlag string `json:"list_sp_item_flag"`
  14935. LmtUsedFlag string `json:"lmt_used_flag"`
  14936. MedChrgitmType string `json:"med_chrgitm_type"`
  14937. Memo string `json:"memo"`
  14938. OverlmtAmt float64 `json:"overlmt_amt"`
  14939. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14940. Pric float64 `json:"pric"`
  14941. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14942. SelfpayProp float64 `json:"selfpay_prop"`
  14943. } `json:"result"`
  14944. } `json:"output"`
  14945. RefmsgTime string `json:"refmsg_time"`
  14946. RespondTime string `json:"respond_time"`
  14947. Signtype string `json:"signtype"`
  14948. WarnMsg string `json:"warn_msg"`
  14949. }
  14950. type ResultFour10265 struct {
  14951. Cainfo string `json:"cainfo"`
  14952. ErrMsg string `json:"err_msg"`
  14953. InfRefmsgid string `json:"inf_refmsgid"`
  14954. Infcode string `json:"infcode"`
  14955. Output struct {
  14956. Result []struct {
  14957. BasMednFlag string `json:"bas_medn_flag"`
  14958. ChldMedcFlag string `json:"chld_medc_flag"`
  14959. ChrgitmLv string `json:"chrgitm_lv"`
  14960. Cnt float64 `json:"cnt"`
  14961. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14962. DrtReimFlag string `json:"drt_reim_flag"`
  14963. FeedetlSn string `json:"feedetl_sn"`
  14964. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14965. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14966. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14967. ListSpItemFlag string `json:"list_sp_item_flag"`
  14968. LmtUsedFlag string `json:"lmt_used_flag"`
  14969. MedChrgitmType string `json:"med_chrgitm_type"`
  14970. Memo string `json:"memo"`
  14971. OverlmtAmt float64 `json:"overlmt_amt"`
  14972. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14973. Pric float64 `json:"pric"`
  14974. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14975. SelfpayProp float64 `json:"selfpay_prop"`
  14976. } `json:"result"`
  14977. } `json:"output"`
  14978. RefmsgTime string `json:"refmsg_time"`
  14979. RespondTime string `json:"respond_time"`
  14980. Signtype string `json:"signtype"`
  14981. WarnMsg string `json:"warn_msg"`
  14982. }
  14983. type ResultMemo struct {
  14984. InsuAdmdvs string `json:"insuAdmdvs"`
  14985. }
  14986. // [{"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}]
  14987. type ResultIDInfo struct {
  14988. Begntime string `json:"begntime"`
  14989. Endtime string `json:"endtime"`
  14990. Memo string `json:"memo"`
  14991. }
  14992. type ResultFive struct {
  14993. Balc float64 `json:"balc"`
  14994. CvlservFlag string `json:"cvlserv_flag"`
  14995. EmpName string `json:"emp_name"`
  14996. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14997. Insutype string `json:"insutype"`
  14998. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14999. PausInsuDate string `json:"paus_insu_date"`
  15000. PsnInsuDate string `json:"psn_insu_date"`
  15001. PsnInsuStas string `json:"psn_insu_stas"`
  15002. PsnType string `json:"psn_type"`
  15003. }
  15004. type ResultSix struct {
  15005. Cainfo interface{} `json:"cainfo"`
  15006. ErrMsg string `json:"err_msg"`
  15007. InfRefmsgid string `json:"inf_refmsgid"`
  15008. Infcode int64 `json:"infcode"`
  15009. Output struct {
  15010. } `json:"output"`
  15011. RefmsgTime string `json:"refmsg_time"`
  15012. RespondTime string `json:"respond_time"`
  15013. Signtype interface{} `json:"signtype"`
  15014. WarnMsg interface{} `json:"warn_msg"`
  15015. }
  15016. type Result2406 struct {
  15017. Cainfo interface{} `json:"cainfo"`
  15018. ErrMsg string `json:"err_msg"`
  15019. InfRefmsgid string `json:"inf_refmsgid"`
  15020. Infcode int64 `json:"infcode"`
  15021. Output struct {
  15022. Result struct {
  15023. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15024. } `json:"result"`
  15025. } `json:"output"`
  15026. RefmsgTime string `json:"refmsg_time"`
  15027. RespondTime string `json:"respond_time"`
  15028. Signtype interface{} `json:"signtype"`
  15029. WarnMsg interface{} `json:"warn_msg"`
  15030. }
  15031. type GZResultSix struct {
  15032. Cainfo interface{} `json:"cainfo"`
  15033. ErrMsg string `json:"err_msg"`
  15034. InfRefmsgid string `json:"inf_refmsgid"`
  15035. Infcode int64 `json:"infcode"`
  15036. Output string `json:"output"`
  15037. RefmsgTime string `json:"refmsg_time"`
  15038. RespondTime string `json:"respond_time"`
  15039. Signtype interface{} `json:"signtype"`
  15040. WarnMsg interface{} `json:"warn_msg"`
  15041. }
  15042. type ResultSix10265 struct {
  15043. Cainfo interface{} `json:"cainfo"`
  15044. ErrMsg string `json:"err_msg"`
  15045. InfRefmsgid string `json:"inf_refmsgid"`
  15046. Infcode string `json:"infcode"`
  15047. Output struct {
  15048. } `json:"output"`
  15049. RefmsgTime string `json:"refmsg_time"`
  15050. RespondTime string `json:"respond_time"`
  15051. Signtype interface{} `json:"signtype"`
  15052. WarnMsg interface{} `json:"warn_msg"`
  15053. }
  15054. type ResultSeven struct {
  15055. Cainfo string `json:"cainfo"`
  15056. ErrMsg string `json:"err_msg"`
  15057. InfRefmsgid string `json:"inf_refmsgid"`
  15058. Infcode int64 `json:"infcode"`
  15059. Output struct {
  15060. Setlinfo struct {
  15061. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15062. AcctPay float64 `json:"acct_pay"`
  15063. ActPayDedc float64 `json:"act_pay_dedc"`
  15064. Age float64 `json:"age"`
  15065. Balc float64 `json:"balc"`
  15066. Certno string `json:"certno"`
  15067. ClrOptins string `json:"clr_optins"`
  15068. ClrType string `json:"clr_type"`
  15069. ClrWay string `json:"clr_way"`
  15070. CvlservFlag string `json:"cvlserv_flag"`
  15071. CvlservPay float64 `json:"cvlserv_pay"`
  15072. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15073. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15074. Gend string `json:"gend"`
  15075. HifesPay float64 `json:"hifes_pay"`
  15076. HifmiPay float64 `json:"hifmi_pay"`
  15077. HifpPay float64 `json:"hifp_pay"`
  15078. HospPartAmt float64 `json:"hosp_part_amt"`
  15079. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15080. Insutype string `json:"insutype"`
  15081. MafPay float64 `json:"maf_pay"`
  15082. MdtrtCertType string `json:"mdtrt_cert_type"`
  15083. HifobPay float64 `json:"hifob_pay"`
  15084. MdtrtID string `json:"mdtrt_id"`
  15085. MedType string `json:"med_type"`
  15086. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15087. MedinsSetlID string `json:"medins_setl_id"`
  15088. Naty string `json:"naty"`
  15089. OthPay float64 `json:"oth_pay"`
  15090. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15091. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15092. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15093. PsnCashPay float64 `json:"psn_cash_pay"`
  15094. PsnCertType string `json:"psn_cert_type"`
  15095. PsnName string `json:"psn_name"`
  15096. PsnNo string `json:"psn_no"`
  15097. PsnPartAmt float64 `json:"psn_part_amt"`
  15098. PsnType string `json:"psn_type"`
  15099. SetlID string `json:"setl_id"`
  15100. SetlTime string `json:"setl_time"`
  15101. } `json:"setlinfo"`
  15102. Setldetail interface{} `json:"setldetail"`
  15103. } `json:"output"`
  15104. RefmsgTime string `json:"refmsg_time"`
  15105. RespondTime string `json:"respond_time"`
  15106. Signtype interface{} `json:"signtype"`
  15107. WarnMsg interface{} `json:"warn_msg"`
  15108. }
  15109. type ResultSevenAH struct {
  15110. Cainfo string `json:"cainfo"`
  15111. ErrMsg string `json:"err_msg"`
  15112. InfRefmsgid string `json:"inf_refmsgid"`
  15113. Infcode int64 `json:"infcode"`
  15114. Output struct {
  15115. Setlinfo struct {
  15116. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15117. AcctPay float64 `json:"acct_pay"`
  15118. ActPayDedc float64 `json:"act_pay_dedc"`
  15119. Age float64 `json:"age"`
  15120. Balc float64 `json:"balc"`
  15121. Certno string `json:"certno"`
  15122. ClrOptins string `json:"clr_optins"`
  15123. ClrType string `json:"clr_type"`
  15124. ClrWay string `json:"clr_way"`
  15125. CvlservFlag string `json:"cvlserv_flag"`
  15126. CvlservPay float64 `json:"cvlserv_pay"`
  15127. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15128. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15129. Gend string `json:"gend"`
  15130. HifesPay float64 `json:"hifes_pay"`
  15131. HifmiPay float64 `json:"hifmi_pay"`
  15132. HifpPay float64 `json:"hifp_pay"`
  15133. HospPartAmt float64 `json:"hosp_part_amt"`
  15134. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15135. Insutype string `json:"insutype"`
  15136. MafPay float64 `json:"maf_pay"`
  15137. MdtrtCertType string `json:"mdtrt_cert_type"`
  15138. HifobPay float64 `json:"hifob_pay"`
  15139. MdtrtID string `json:"mdtrt_id"`
  15140. MedType string `json:"med_type"`
  15141. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15142. MedinsSetlID string `json:"medins_setl_id"`
  15143. Naty string `json:"naty"`
  15144. OthPay float64 `json:"oth_pay"`
  15145. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15146. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15147. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15148. PsnCashPay float64 `json:"psn_cash_pay"`
  15149. PsnCertType string `json:"psn_cert_type"`
  15150. PsnName string `json:"psn_name"`
  15151. PsnNo string `json:"psn_no"`
  15152. PsnPartAmt float64 `json:"psn_part_amt"`
  15153. PsnType string `json:"psn_type"`
  15154. SetlID string `json:"setl_id"`
  15155. SetlTime int64 `json:"setl_time"`
  15156. } `json:"setlinfo"`
  15157. Setldetail interface{} `json:"setldetail"`
  15158. } `json:"output"`
  15159. RefmsgTime string `json:"refmsg_time"`
  15160. RespondTime string `json:"respond_time"`
  15161. Signtype interface{} `json:"signtype"`
  15162. WarnMsg interface{} `json:"warn_msg"`
  15163. }
  15164. type ResultSeven10265 struct {
  15165. Cainfo string `json:"cainfo"`
  15166. ErrMsg string `json:"err_msg"`
  15167. InfRefmsgid string `json:"inf_refmsgid"`
  15168. Infcode string `json:"infcode"`
  15169. Output struct {
  15170. Setlinfo struct {
  15171. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15172. AcctPay float64 `json:"acct_pay"`
  15173. ActPayDedc float64 `json:"act_pay_dedc"`
  15174. Age float64 `json:"age"`
  15175. Balc float64 `json:"balc"`
  15176. Certno string `json:"certno"`
  15177. ClrOptins string `json:"clr_optins"`
  15178. ClrType string `json:"clr_type"`
  15179. ClrWay string `json:"clr_way"`
  15180. CvlservFlag string `json:"cvlserv_flag"`
  15181. CvlservPay float64 `json:"cvlserv_pay"`
  15182. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15183. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15184. Gend string `json:"gend"`
  15185. HifesPay float64 `json:"hifes_pay"`
  15186. HifmiPay float64 `json:"hifmi_pay"`
  15187. HifpPay float64 `json:"hifp_pay"`
  15188. HospPartAmt float64 `json:"hosp_part_amt"`
  15189. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15190. Insutype string `json:"insutype"`
  15191. MafPay float64 `json:"maf_pay"`
  15192. MdtrtCertType string `json:"mdtrt_cert_type"`
  15193. HifobPay float64 `json:"hifob_pay"`
  15194. MdtrtID string `json:"mdtrt_id"`
  15195. MedType string `json:"med_type"`
  15196. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15197. MedinsSetlID string `json:"medins_setl_id"`
  15198. Naty string `json:"naty"`
  15199. OthPay float64 `json:"oth_pay"`
  15200. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15201. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15202. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15203. PsnCashPay float64 `json:"psn_cash_pay"`
  15204. PsnCertType string `json:"psn_cert_type"`
  15205. PsnName string `json:"psn_name"`
  15206. PsnNo string `json:"psn_no"`
  15207. PsnPartAmt float64 `json:"psn_part_amt"`
  15208. PsnType string `json:"psn_type"`
  15209. SetlID string `json:"setl_id"`
  15210. SetlTime string `json:"setl_time"`
  15211. } `json:"setlinfo"`
  15212. Setldetail interface{} `json:"setldetail"`
  15213. } `json:"output"`
  15214. RefmsgTime string `json:"refmsg_time"`
  15215. RespondTime string `json:"respond_time"`
  15216. Signtype interface{} `json:"signtype"`
  15217. WarnMsg interface{} `json:"warn_msg"`
  15218. }
  15219. type ResultSeven10265Two struct {
  15220. Cainfo string `json:"cainfo"`
  15221. ErrMsg string `json:"err_msg"`
  15222. InfRefmsgid string `json:"inf_refmsgid"`
  15223. Infcode string `json:"infcode"`
  15224. Output struct {
  15225. Setlinfo struct {
  15226. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15227. AcctPay float64 `json:"acct_pay"`
  15228. ActPayDedc float64 `json:"act_pay_dedc"`
  15229. Age float64 `json:"age"`
  15230. Balc float64 `json:"balc"`
  15231. Certno string `json:"certno"`
  15232. ClrOptins string `json:"clr_optins"`
  15233. ClrType string `json:"clr_type"`
  15234. ClrWay string `json:"clr_way"`
  15235. CvlservFlag string `json:"cvlserv_flag"`
  15236. CvlservPay float64 `json:"cvlserv_pay"`
  15237. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15238. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15239. Gend string `json:"gend"`
  15240. HifesPay float64 `json:"hifes_pay"`
  15241. HifmiPay float64 `json:"hifmi_pay"`
  15242. HifpPay float64 `json:"hifp_pay"`
  15243. HospPartAmt string `json:"hosp_part_amt"`
  15244. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15245. Insutype string `json:"insutype"`
  15246. MafPay float64 `json:"maf_pay"`
  15247. MdtrtCertType string `json:"mdtrt_cert_type"`
  15248. HifobPay float64 `json:"hifob_pay"`
  15249. MdtrtID string `json:"mdtrt_id"`
  15250. MedType string `json:"med_type"`
  15251. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15252. MedinsSetlID string `json:"medins_setl_id"`
  15253. Naty string `json:"naty"`
  15254. OthPay float64 `json:"oth_pay"`
  15255. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15256. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15257. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15258. PsnCashPay float64 `json:"psn_cash_pay"`
  15259. PsnCertType string `json:"psn_cert_type"`
  15260. PsnName string `json:"psn_name"`
  15261. PsnNo string `json:"psn_no"`
  15262. PsnPartAmt float64 `json:"psn_part_amt"`
  15263. PsnType string `json:"psn_type"`
  15264. SetlID string `json:"setl_id"`
  15265. SetlTime string `json:"setl_time"`
  15266. } `json:"setlinfo"`
  15267. Setldetail interface{} `json:"setldetail"`
  15268. } `json:"output"`
  15269. RefmsgTime string `json:"refmsg_time"`
  15270. RespondTime string `json:"respond_time"`
  15271. Signtype interface{} `json:"signtype"`
  15272. WarnMsg interface{} `json:"warn_msg"`
  15273. }
  15274. type GZResultSeven10265Two struct {
  15275. Cainfo string `json:"cainfo"`
  15276. ErrMsg string `json:"err_msg"`
  15277. InfRefmsgid string `json:"inf_refmsgid"`
  15278. Infcode int64 `json:"infcode"`
  15279. Output struct {
  15280. Setlinfo struct {
  15281. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15282. AcctPay float64 `json:"acct_pay"`
  15283. ActPayDedc float64 `json:"act_pay_dedc"`
  15284. Age float64 `json:"age"`
  15285. Balc float64 `json:"balc"`
  15286. Certno string `json:"certno"`
  15287. ClrOptins string `json:"clr_optins"`
  15288. ClrType string `json:"clr_type"`
  15289. ClrWay string `json:"clr_way"`
  15290. CvlservFlag string `json:"cvlserv_flag"`
  15291. CvlservPay float64 `json:"cvlserv_pay"`
  15292. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15293. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15294. Gend string `json:"gend"`
  15295. HifesPay float64 `json:"hifes_pay"`
  15296. HifmiPay float64 `json:"hifmi_pay"`
  15297. HifpPay float64 `json:"hifp_pay"`
  15298. HospPartAmt float64 `json:"hosp_part_amt"`
  15299. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15300. Insutype string `json:"insutype"`
  15301. MafPay float64 `json:"maf_pay"`
  15302. MdtrtCertType string `json:"mdtrt_cert_type"`
  15303. HifobPay float64 `json:"hifob_pay"`
  15304. MdtrtID string `json:"mdtrt_id"`
  15305. MedType string `json:"med_type"`
  15306. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15307. MedinsSetlID string `json:"medins_setl_id"`
  15308. Naty string `json:"naty"`
  15309. OthPay float64 `json:"oth_pay"`
  15310. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15311. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15312. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15313. PsnCashPay float64 `json:"psn_cash_pay"`
  15314. PsnCertType string `json:"psn_cert_type"`
  15315. PsnName string `json:"psn_name"`
  15316. PsnNo string `json:"psn_no"`
  15317. PsnPartAmt float64 `json:"psn_part_amt"`
  15318. PsnType string `json:"psn_type"`
  15319. SetlID string `json:"setl_id"`
  15320. SetlTime string `json:"setl_time"`
  15321. } `json:"setlinfo"`
  15322. Setldetail interface{} `json:"setldetail"`
  15323. } `json:"output"`
  15324. RefmsgTime string `json:"refmsg_time"`
  15325. RespondTime string `json:"respond_time"`
  15326. Signtype interface{} `json:"signtype"`
  15327. WarnMsg interface{} `json:"warn_msg"`
  15328. }
  15329. type ResultEight struct {
  15330. Cainfo string `json:"cainfo"`
  15331. ErrMsg string `json:"err_msg"`
  15332. InfRefmsgid string `json:"inf_refmsgid"`
  15333. Infcode int64 `json:"infcode"`
  15334. Output struct {
  15335. Stmtinfo struct {
  15336. SetlOptins string `json:"setl_optins"`
  15337. StmtRslt string `json:"stmt_rslt"`
  15338. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15339. } `json:"stmtinfo"`
  15340. } `json:"output"`
  15341. RefmsgTime string `json:"refmsg_time"`
  15342. RespondTime string `json:"respond_time"`
  15343. Signtype interface{} `json:"signtype"`
  15344. WarnMsg interface{} `json:"warn_msg"`
  15345. }
  15346. type ResultEightFor10188 struct {
  15347. Cainfo string `json:"cainfo"`
  15348. ErrMsg string `json:"err_msg"`
  15349. InfRefmsgid string `json:"inf_refmsgid"`
  15350. Infcode string `json:"infcode"`
  15351. Output struct {
  15352. Stmtinfo struct {
  15353. SetlOptins string `json:"setl_optins"`
  15354. StmtRslt string `json:"stmt_rslt"`
  15355. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15356. } `json:"stmtinfo"`
  15357. } `json:"output"`
  15358. RefmsgTime string `json:"refmsg_time"`
  15359. RespondTime string `json:"respond_time"`
  15360. Signtype interface{} `json:"signtype"`
  15361. WarnMsg interface{} `json:"warn_msg"`
  15362. }
  15363. type ResultNine struct {
  15364. Cainfo string `json:"cainfo"`
  15365. ErrMsg string `json:"err_msg"`
  15366. InfRefmsgid string `json:"inf_refmsgid"`
  15367. Infcode int64 `json:"infcode"`
  15368. Output struct {
  15369. FileQuryNo string `json:"file_qury_no"`
  15370. } `json:"output"`
  15371. RefmsgTime string `json:"refmsg_time"`
  15372. RespondTime string `json:"respond_time"`
  15373. Signtype interface{} `json:"signtype"`
  15374. WarnMsg interface{} `json:"warn_msg"`
  15375. }
  15376. type ResultTen struct {
  15377. Cainfo string `json:"cainfo"`
  15378. ErrMsg string `json:"err_msg"`
  15379. InfRefmsgid string `json:"inf_refmsgid"`
  15380. Infcode int64 `json:"infcode"`
  15381. Output struct {
  15382. Fileinfo struct {
  15383. DldEndtime string `json:"dld_endtime"`
  15384. FileQuryNo string `json:"file_qury_no"`
  15385. Filename string `json:"filename"`
  15386. } `json:"fileinfo"`
  15387. } `json:"output"`
  15388. RefmsgTime string `json:"refmsg_time"`
  15389. RespondTime string `json:"respond_time"`
  15390. Signtype interface{} `json:"signtype"`
  15391. WarnMsg interface{} `json:"warn_msg"`
  15392. }
  15393. type Result5262 struct {
  15394. ErrMsg string `json:"err_msg"`
  15395. InfRefmsgid string `json:"inf_refmsgid"`
  15396. Infcode int64 `json:"infcode"`
  15397. Output struct {
  15398. PageInfo struct {
  15399. Size int `json:"size"`
  15400. RecordCounts int `json:"record_counts"`
  15401. } `json:"page_info"`
  15402. Idetinfo []interface{} `json:"idetinfo"`
  15403. Result []struct {
  15404. SetlID string `json:"setl_id"`
  15405. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15406. MdtrtID string `json:"mdtrt_id"`
  15407. InitSetlID string `json:"init_setl_id,omitempty"`
  15408. PsnNo string `json:"psn_no"`
  15409. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15410. PsnName string `json:"psn_name"`
  15411. PsnCertType string `json:"psn_cert_type"`
  15412. Certno string `json:"certno"`
  15413. Gend string `json:"gend,omitempty"`
  15414. Naty string `json:"naty,omitempty"`
  15415. Brdy string `json:"brdy,omitempty"`
  15416. Age float64 `json:"age,omitempty"`
  15417. Insutype string `json:"insutype,omitempty"`
  15418. PsnType string `json:"psn_type"`
  15419. CvlservFlag string `json:"cvlserv_flag"`
  15420. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15421. SpPsnType string `json:"sp_psn_type,omitempty"`
  15422. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15423. ClctGrde string `json:"clct_grde,omitempty"`
  15424. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15425. NwbFlag string `json:"nwb_flag,omitempty"`
  15426. InsuAdmdvs string `json:"insu_admdvs"`
  15427. EmpNo string `json:"emp_no,omitempty"`
  15428. EmpName string `json:"emp_name,omitempty"`
  15429. EmpType string `json:"emp_type,omitempty"`
  15430. EconType string `json:"econ_type,omitempty"`
  15431. AfilIndu string `json:"afil_indu,omitempty"`
  15432. AfilRlts string `json:"afil_rlts,omitempty"`
  15433. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15434. PayLoc string `json:"pay_loc,omitempty"`
  15435. FixmedinsCode string `json:"fixmedins_code"`
  15436. FixmedinsName string `json:"fixmedins_name"`
  15437. HospLv string `json:"hosp_lv,omitempty"`
  15438. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15439. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15440. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15441. Begndate string `json:"begndate"`
  15442. Enddate string `json:"enddate"`
  15443. SetlTime string `json:"setl_time"`
  15444. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15445. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15446. MedType string `json:"med_type"`
  15447. SetlType string `json:"setl_type,omitempty"`
  15448. ClrType string `json:"clr_type,omitempty"`
  15449. ClrWay string `json:"clr_way,omitempty"`
  15450. PsnSetlway string `json:"psn_setlway,omitempty"`
  15451. ClrOptins string `json:"clr_optins,omitempty"`
  15452. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15453. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15454. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15455. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15456. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15457. DedcStd float64 `json:"dedc_std,omitempty"`
  15458. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15459. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15460. HifpPay float64 `json:"hifp_pay,omitempty"`
  15461. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15462. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15463. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15464. HifesPay float64 `json:"hifes_pay,omitempty"`
  15465. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15466. HifobPay float64 `json:"hifob_pay,omitempty"`
  15467. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15468. MafPay float64 `json:"maf_pay,omitempty"`
  15469. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15470. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15471. PsnPay float64 `json:"psn_pay,omitempty"`
  15472. AcctPay float64 `json:"acct_pay,omitempty"`
  15473. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15474. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15475. Balc float64 `json:"balc,omitempty"`
  15476. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15477. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15478. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15479. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15480. Year string `json:"year,omitempty"`
  15481. DiseNo string `json:"dise_no,omitempty"`
  15482. DiseName string `json:"dise_name,omitempty"`
  15483. Invono string `json:"invono,omitempty"`
  15484. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15485. ValiFlag string `json:"vali_flag,omitempty"`
  15486. Memo string `json:"memo,omitempty"`
  15487. Rid string `json:"rid"`
  15488. UpdtTime string `json:"updt_time,omitempty"`
  15489. CrterID string `json:"crter_id,omitempty"`
  15490. CrterName string `json:"crter_name,omitempty"`
  15491. CrteTime string `json:"crte_time,omitempty"`
  15492. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15493. OpterID string `json:"opter_id,omitempty"`
  15494. OpterName string `json:"opter_name,omitempty"`
  15495. OptTime string `json:"opt_time,omitempty"`
  15496. OptinsNo string `json:"optins_no,omitempty"`
  15497. PoolareaNo string `json:"poolarea_no,omitempty"`
  15498. } `json:"result"`
  15499. } `json:"output"`
  15500. RefmsgTime string `json:"refmsg_time"`
  15501. RespondTime string `json:"respond_time"`
  15502. Signtype interface{} `json:"signtype"`
  15503. WarnInfo interface{} `json:"warn_info"`
  15504. }
  15505. type Result5267 struct {
  15506. ErrMsg string `json:"err_msg"`
  15507. InfRefmsgid string `json:"inf_refmsgid"`
  15508. Infcode int64 `json:"infcode"`
  15509. Output struct {
  15510. PageInfo struct {
  15511. Size int `json:"size"`
  15512. RecordCounts int `json:"record_counts"`
  15513. } `json:"pageinfo"`
  15514. Result []struct {
  15515. SetlID string `json:"setl_id"`
  15516. ClrOptins string `json:"clr_optins"`
  15517. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15518. MdtrtID string `json:"mdtrt_id"`
  15519. InitSetlID string `json:"init_setl_id,omitempty"`
  15520. PsnNo string `json:"psn_no"`
  15521. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15522. PsnName string `json:"psn_name"`
  15523. PsnCertType string `json:"psn_cert_type"`
  15524. Certno string `json:"certno"`
  15525. Gend string `json:"gend,omitempty"`
  15526. Naty string `json:"naty,omitempty"`
  15527. Brdy string `json:"brdy,omitempty"`
  15528. Age float64 `json:"age,omitempty"`
  15529. Insutype string `json:"insutype,omitempty"`
  15530. PsnType string `json:"psn_type"`
  15531. CvlservFlag string `json:"cvlserv_flag"`
  15532. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15533. SpPsnType string `json:"sp_psn_type,omitempty"`
  15534. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15535. ClctGrde string `json:"clct_grde,omitempty"`
  15536. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15537. NwbFlag string `json:"nwb_flag,omitempty"`
  15538. InsuAdmdvs string `json:"insu_admdvs"`
  15539. EmpNo string `json:"emp_no,omitempty"`
  15540. EmpName string `json:"emp_name,omitempty"`
  15541. EmpType string `json:"emp_type,omitempty"`
  15542. EconType string `json:"econ_type,omitempty"`
  15543. AfilIndu string `json:"afil_indu,omitempty"`
  15544. AfilRlts string `json:"afil_rlts,omitempty"`
  15545. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15546. PayLoc string `json:"pay_loc,omitempty"`
  15547. FixmedinsCode string `json:"fixmedins_code"`
  15548. FixmedinsName string `json:"fixmedins_name"`
  15549. HospLv string `json:"hosp_lv,omitempty"`
  15550. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15551. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15552. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15553. Begndate string `json:"begndate,omitempty"`
  15554. Enddate string `json:"enddate,omitempty"`
  15555. SetlTime string `json:"setl_time,omitempty"`
  15556. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15557. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15558. MedType string `json:"med_type"`
  15559. SetlType string `json:"setl_type,omitempty"`
  15560. ClrType string `json:"clr_type,omitempty"`
  15561. ClrWay string `json:"clr_way,omitempty"`
  15562. PsnSetlway string `json:"psn_setlway,omitempty"`
  15563. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15564. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15565. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15566. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15567. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15568. DedcStd float64 `json:"dedc_std,omitempty"`
  15569. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15570. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15571. HifpPay float64 `json:"hifp_pay,omitempty"`
  15572. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15573. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15574. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15575. HifesPay float64 `json:"hifes_pay,omitempty"`
  15576. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15577. HifobPay float64 `json:"hifob_pay,omitempty"`
  15578. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15579. MafPay float64 `json:"maf_pay,omitempty"`
  15580. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15581. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15582. PsnPay float64 `json:"psn_pay,omitempty"`
  15583. AcctPay float64 `json:"acct_pay,omitempty"`
  15584. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15585. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15586. Balc float64 `json:"balc,omitempty"`
  15587. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15588. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15589. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15590. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15591. Year string `json:"year,omitempty"`
  15592. DiseNo string `json:"dise_no,omitempty"`
  15593. DiseName string `json:"dise_name,omitempty"`
  15594. Invono string `json:"invono,omitempty"`
  15595. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15596. Memo string `json:"memo,omitempty"`
  15597. UpdtTime string `json:"updt_time,omitempty"`
  15598. OpterID string `json:"opter_id,omitempty"`
  15599. OpterName string `json:"opter_name,omitempty"`
  15600. OptTime string `json:"opt_time,omitempty"`
  15601. OptinsNo string `json:"optins_no,omitempty"`
  15602. PoolareaNo string `json:"poolarea_no,omitempty"`
  15603. } `json:"result"`
  15604. } `json:"output"`
  15605. RefmsgTime string `json:"refmsg_time"`
  15606. RespondTime string `json:"respond_time"`
  15607. Signtype interface{} `json:"signtype"`
  15608. WarnInfo interface{} `json:"warn_info"`
  15609. }
  15610. // type Autogenerated struct {
  15611. // Output struct {
  15612. // Setlinfo struct {
  15613. // SetlTime string `json:"setl_time"`
  15614. // CvlservPay float64 `json:"cvlserv_pay"`
  15615. // Year string `json:"year"`
  15616. // MedType string `json:"med_type"`
  15617. // PsnPay float64 `json:"psn_pay"`
  15618. // OpterID string `json:"opter_id"`
  15619. // Begndate string `json:"begndate"`
  15620. // FlxempeFlag string `json:"flxempe_flag"`
  15621. // HifmiPay float64 `json:"hifmi_pay"`
  15622. // PsnNo string `json:"psn_no"`
  15623. // ActPayDedc float64 `json:"act_pay_dedc"`
  15624. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15625. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15626. // ClrWay string `json:"clr_way"`
  15627. // OthPay float64 `json:"oth_pay"`
  15628. // Gend string `json:"gend"`
  15629. // MdtrtID string `json:"mdtrt_id"`
  15630. // AcctPay float64 `json:"acct_pay"`
  15631. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15632. // Insutype string `json:"insutype"`
  15633. // Invono interface{} `json:"invono"`
  15634. // Enddate string `json:"enddate"`
  15635. // CashPayamt float64 `json:"cash_payamt"`
  15636. // PsnType string `json:"psn_type"`
  15637. // FixmedinsName string `json:"fixmedins_name"`
  15638. // HifpPay float64 `json:"hifp_pay"`
  15639. // NewFlag interface{} `json:"new_flag"`
  15640. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15641. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15642. // PayLoc string `json:"pay_loc"`
  15643. // ClrType string `json:"clr_type"`
  15644. // RefdSetlFlag string `json:"refd_setl_flag"`
  15645. // CvlservFlag string `json:"cvlserv_flag"`
  15646. // EmpName string `json:"emp_name"`
  15647. // Brdy string `json:"brdy"`
  15648. // Naty string `json:"naty"`
  15649. // Certno string `json:"certno"`
  15650. // DiseCode string `json:"dise_code"`
  15651. // FixmedinsCode string `json:"fixmedins_code"`
  15652. // DedcHospLv string `json:"dedc_hosp_lv"`
  15653. // OpterName string `json:"opter_name"`
  15654. // Balc float64 `json:"balc"`
  15655. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15656. // PsnCertType string `json:"psn_cert_type"`
  15657. // HifobPay float64 `json:"hifob_pay"`
  15658. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15659. // HifesPay float64 `json:"hifes_pay"`
  15660. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15661. // OptTime string `json:"opt_time"`
  15662. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15663. // SetlID string `json:"setl_id"`
  15664. // MafPay float64 `json:"maf_pay"`
  15665. // PsnName string `json:"psn_name"`
  15666. // InsuOptins interface{} `json:"insu_optins"`
  15667. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15668. // ClrOptins string `json:"clr_optins"`
  15669. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15670. // DiseName string `json:"dise_name"`
  15671. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15672. // Age float64 `json:"age"`
  15673. // DtrtCertType string `json:"dtrt_cert_type"`
  15674. // HospLv string `json:"hosp_lv"`
  15675. // } `json:"setlinfo"`
  15676. // Setldetail []struct {
  15677. // FundPayType string `json:"fund_pay_type"`
  15678. // FundPayamt float64 `json:"fund_payamt"`
  15679. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15680. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15681. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15682. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15683. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15684. // } `json:"setldetail"`
  15685. // } `json:"output"`
  15686. // Infcode int `json:"infcode"`
  15687. // WarnMsg interface{} `json:"warn_msg"`
  15688. // Cainfo interface{} `json:"cainfo"`
  15689. // ErrMsg interface{} `json:"err_msg"`
  15690. // RefmsgTime string `json:"refmsg_time"`
  15691. // Signtype interface{} `json:"signtype"`
  15692. // RespondTime string `json:"respond_time"`
  15693. // InfRefmsgid string `json:"inf_refmsgid"`
  15694. // }
  15695. type Result002 struct {
  15696. Cainfo interface{} `json:"cainfo"`
  15697. ErrMsg string `json:"err_msg"`
  15698. InfRefmsgid string `json:"inf_refmsgid"`
  15699. Infcode int64 `json:"infcode"`
  15700. Output struct {
  15701. RxFile string `json:"rx_file"`
  15702. SignDigest string `json:"sign_digest"`
  15703. SignCertSn string `json:"sign_cert_sn"`
  15704. SignCertDn string `json:"sign_cert_dn"`
  15705. } `json:"output"`
  15706. RefmsgTime string `json:"refmsg_time"`
  15707. RespondTime string `json:"respond_time"`
  15708. Signtype interface{} `json:"signtype"`
  15709. WarnMsg interface{} `json:"warn_msg"`
  15710. }
  15711. type Result003 struct {
  15712. Cainfo interface{} `json:"cainfo"`
  15713. ErrMsg string `json:"err_msg"`
  15714. InfRefmsgid string `json:"inf_refmsgid"`
  15715. Infcode int64 `json:"infcode"`
  15716. Output struct {
  15717. HiRxno string `json:"hi_rxno"`
  15718. RxStasCodg string `json:"rx_stas_codg"`
  15719. RxStasName string `json:"rx_stas_name"`
  15720. } `json:"output"`
  15721. RefmsgTime string `json:"refmsg_time"`
  15722. RespondTime string `json:"respond_time"`
  15723. Signtype interface{} `json:"signtype"`
  15724. WarnMsg interface{} `json:"warn_msg"`
  15725. }
  15726. type ResultEleven struct {
  15727. Cainfo string `json:"cainfo"`
  15728. ErrMsg string `json:"err_msg"`
  15729. InfRefmsgid string `json:"inf_refmsgid"`
  15730. Infcode int64 `json:"infcode"`
  15731. Output struct {
  15732. Setlinfo struct {
  15733. SetlTime string `json:"setl_time"`
  15734. CvlservPay float64 `json:"cvlserv_pay"`
  15735. Year string `json:"year"`
  15736. MedType string `json:"med_type"`
  15737. PsnPay float64 `json:"psn_pay"`
  15738. OpterID string `json:"opter_id"`
  15739. Begndate string `json:"begndate"`
  15740. FlxempeFlag string `json:"flxempe_flag"`
  15741. HifmiPay float64 `json:"hifmi_pay"`
  15742. PsnNo string `json:"psn_no"`
  15743. ActPayDedc float64 `json:"act_pay_dedc"`
  15744. MedinsSetlID interface{} `json:"medins_setl_id"`
  15745. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15746. ClrWay string `json:"clr_way"`
  15747. OthPay float64 `json:"oth_pay"`
  15748. Gend string `json:"gend"`
  15749. MdtrtID string `json:"mdtrt_id"`
  15750. AcctPay float64 `json:"acct_pay"`
  15751. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15752. Insutype string `json:"insutype"`
  15753. Invono interface{} `json:"invono"`
  15754. Enddate string `json:"enddate"`
  15755. CashPayamt float64 `json:"cash_payamt"`
  15756. PsnType string `json:"psn_type"`
  15757. FixmedinsName string `json:"fixmedins_name"`
  15758. HifpPay float64 `json:"hifp_pay"`
  15759. NewFlag interface{} `json:"new_flag"`
  15760. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15761. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15762. PayLoc string `json:"pay_loc"`
  15763. ClrType string `json:"clr_type"`
  15764. RefdSetlFlag string `json:"refd_setl_flag"`
  15765. CvlservFlag string `json:"cvlserv_flag"`
  15766. EmpName string `json:"emp_name"`
  15767. Brdy string `json:"brdy"`
  15768. Naty string `json:"naty"`
  15769. Certno string `json:"certno"`
  15770. DiseCode string `json:"dise_code"`
  15771. FixmedinsCode string `json:"fixmedins_code"`
  15772. DedcHospLv string `json:"dedc_hosp_lv"`
  15773. OpterName string `json:"opter_name"`
  15774. Balc float64 `json:"balc"`
  15775. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15776. PsnCertType string `json:"psn_cert_type"`
  15777. HifobPay float64 `json:"hifob_pay"`
  15778. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15779. HifesPay float64 `json:"hifes_pay"`
  15780. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15781. OptTime string `json:"opt_time"`
  15782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15783. SetlID string `json:"setl_id"`
  15784. MafPay float64 `json:"maf_pay"`
  15785. PsnName string `json:"psn_name"`
  15786. InsuOptins interface{} `json:"insu_optins"`
  15787. PrefFundPay interface{} `json:"pref_fund_pay"`
  15788. ClrOptins string `json:"clr_optins"`
  15789. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15790. DiseName string `json:"dise_name"`
  15791. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15792. Age float64 `json:"age"`
  15793. DtrtCertType string `json:"dtrt_cert_type"`
  15794. HospLv string `json:"hosp_lv"`
  15795. PsnCashPay float64 `json:"psn_cash_pay"`
  15796. } `json:"setlinfo"`
  15797. } `json:"output"`
  15798. RefmsgTime string `json:"refmsg_time"`
  15799. RespondTime string `json:"respond_time"`
  15800. Signtype interface{} `json:"signtype"`
  15801. WarnMsg interface{} `json:"warn_msg"`
  15802. }
  15803. type ResultElevenah struct {
  15804. Cainfo string `json:"cainfo"`
  15805. ErrMsg string `json:"err_msg"`
  15806. InfRefmsgid string `json:"inf_refmsgid"`
  15807. Infcode int64 `json:"infcode"`
  15808. Output struct {
  15809. Setlinfo struct {
  15810. SetlTime int64 `json:"setl_time"`
  15811. CvlservPay float64 `json:"cvlserv_pay"`
  15812. Year string `json:"year"`
  15813. MedType string `json:"med_type"`
  15814. PsnPay float64 `json:"psn_pay"`
  15815. OpterID string `json:"opter_id"`
  15816. Begndate int64 `json:"begndate"`
  15817. FlxempeFlag string `json:"flxempe_flag"`
  15818. HifmiPay float64 `json:"hifmi_pay"`
  15819. PsnNo string `json:"psn_no"`
  15820. ActPayDedc float64 `json:"act_pay_dedc"`
  15821. MedinsSetlID interface{} `json:"medins_setl_id"`
  15822. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15823. ClrWay string `json:"clr_way"`
  15824. OthPay float64 `json:"oth_pay"`
  15825. Gend string `json:"gend"`
  15826. MdtrtID string `json:"mdtrt_id"`
  15827. AcctPay float64 `json:"acct_pay"`
  15828. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15829. Insutype string `json:"insutype"`
  15830. Invono interface{} `json:"invono"`
  15831. Enddate int64 `json:"enddate"`
  15832. CashPayamt float64 `json:"cash_payamt"`
  15833. PsnType string `json:"psn_type"`
  15834. FixmedinsName string `json:"fixmedins_name"`
  15835. HifpPay float64 `json:"hifp_pay"`
  15836. NewFlag interface{} `json:"new_flag"`
  15837. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15838. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15839. PayLoc string `json:"pay_loc"`
  15840. ClrType string `json:"clr_type"`
  15841. RefdSetlFlag string `json:"refd_setl_flag"`
  15842. CvlservFlag string `json:"cvlserv_flag"`
  15843. EmpName string `json:"emp_name"`
  15844. Brdy int64 `json:"brdy"`
  15845. Naty string `json:"naty"`
  15846. Certno string `json:"certno"`
  15847. DiseCode string `json:"dise_code"`
  15848. FixmedinsCode string `json:"fixmedins_code"`
  15849. DedcHospLv string `json:"dedc_hosp_lv"`
  15850. OpterName string `json:"opter_name"`
  15851. Balc float64 `json:"balc"`
  15852. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15853. PsnCertType string `json:"psn_cert_type"`
  15854. HifobPay float64 `json:"hifob_pay"`
  15855. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15856. HifesPay float64 `json:"hifes_pay"`
  15857. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15858. OptTime int64 `json:"opt_time"`
  15859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15860. SetlID string `json:"setl_id"`
  15861. MafPay float64 `json:"maf_pay"`
  15862. PsnName string `json:"psn_name"`
  15863. InsuOptins interface{} `json:"insu_optins"`
  15864. PrefFundPay interface{} `json:"pref_fund_pay"`
  15865. ClrOptins string `json:"clr_optins"`
  15866. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15867. DiseName string `json:"dise_name"`
  15868. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15869. Age float64 `json:"age"`
  15870. DtrtCertType string `json:"dtrt_cert_type"`
  15871. HospLv string `json:"hosp_lv"`
  15872. PsnCashPay float64 `json:"psn_cash_pay"`
  15873. } `json:"setlinfo"`
  15874. } `json:"output"`
  15875. RefmsgTime string `json:"refmsg_time"`
  15876. RespondTime string `json:"respond_time"`
  15877. Signtype interface{} `json:"signtype"`
  15878. WarnMsg interface{} `json:"warn_msg"`
  15879. }
  15880. type ResultEleven10265 struct {
  15881. Cainfo string `json:"cainfo"`
  15882. ErrMsg string `json:"err_msg"`
  15883. InfRefmsgid string `json:"inf_refmsgid"`
  15884. Infcode string `json:"infcode"`
  15885. Output struct {
  15886. Setlinfo struct {
  15887. SetlTime string `json:"setl_time"`
  15888. CvlservPay float64 `json:"cvlserv_pay"`
  15889. Year string `json:"year"`
  15890. MedType string `json:"med_type"`
  15891. PsnPay float64 `json:"psn_pay"`
  15892. OpterID string `json:"opter_id"`
  15893. Begndate string `json:"begndate"`
  15894. FlxempeFlag string `json:"flxempe_flag"`
  15895. HifmiPay float64 `json:"hifmi_pay"`
  15896. PsnNo string `json:"psn_no"`
  15897. ActPayDedc float64 `json:"act_pay_dedc"`
  15898. MedinsSetlID interface{} `json:"medins_setl_id"`
  15899. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15900. ClrWay string `json:"clr_way"`
  15901. OthPay float64 `json:"oth_pay"`
  15902. Gend string `json:"gend"`
  15903. MdtrtID string `json:"mdtrt_id"`
  15904. AcctPay float64 `json:"acct_pay"`
  15905. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15906. Insutype string `json:"insutype"`
  15907. Invono interface{} `json:"invono"`
  15908. Enddate string `json:"enddate"`
  15909. CashPayamt float64 `json:"cash_payamt"`
  15910. PsnType string `json:"psn_type"`
  15911. FixmedinsName string `json:"fixmedins_name"`
  15912. HifpPay float64 `json:"hifp_pay"`
  15913. NewFlag interface{} `json:"new_flag"`
  15914. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15915. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15916. PayLoc string `json:"pay_loc"`
  15917. ClrType string `json:"clr_type"`
  15918. RefdSetlFlag string `json:"refd_setl_flag"`
  15919. CvlservFlag string `json:"cvlserv_flag"`
  15920. EmpName string `json:"emp_name"`
  15921. Brdy string `json:"brdy"`
  15922. Naty string `json:"naty"`
  15923. Certno string `json:"certno"`
  15924. DiseCode string `json:"dise_code"`
  15925. FixmedinsCode string `json:"fixmedins_code"`
  15926. DedcHospLv string `json:"dedc_hosp_lv"`
  15927. OpterName string `json:"opter_name"`
  15928. Balc float64 `json:"balc"`
  15929. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15930. PsnCertType string `json:"psn_cert_type"`
  15931. HifobPay float64 `json:"hifob_pay"`
  15932. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15933. HifesPay float64 `json:"hifes_pay"`
  15934. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15935. OptTime string `json:"opt_time"`
  15936. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15937. SetlID string `json:"setl_id"`
  15938. MafPay float64 `json:"maf_pay"`
  15939. PsnName string `json:"psn_name"`
  15940. InsuOptins interface{} `json:"insu_optins"`
  15941. PrefFundPay interface{} `json:"pref_fund_pay"`
  15942. ClrOptins string `json:"clr_optins"`
  15943. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15944. DiseName string `json:"dise_name"`
  15945. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15946. Age float64 `json:"age"`
  15947. DtrtCertType string `json:"dtrt_cert_type"`
  15948. HospLv string `json:"hosp_lv"`
  15949. PsnCashPay float64 `json:"psn_cash_pay"`
  15950. } `json:"setlinfo"`
  15951. } `json:"output"`
  15952. RefmsgTime string `json:"refmsg_time"`
  15953. RespondTime string `json:"respond_time"`
  15954. Signtype interface{} `json:"signtype"`
  15955. WarnMsg interface{} `json:"warn_msg"`
  15956. }
  15957. type ResultTwelve struct {
  15958. Cainfo string `json:"cainfo"`
  15959. ErrMsg string `json:"err_msg"`
  15960. InfRefmsgid string `json:"inf_refmsgid"`
  15961. Infcode int64 `json:"infcode"`
  15962. Output struct {
  15963. MdtrtId string `json:"mdtrt_id"`
  15964. ChrgBchno string `json:"chrg_bchno"`
  15965. PsnNo string `json:"psn_no"`
  15966. } `json:"output"`
  15967. RefmsgTime string `json:"refmsg_time"`
  15968. RespondTime string `json:"respond_time"`
  15969. Signtype interface{} `json:"signtype"`
  15970. WarnMsg interface{} `json:"warn_msg"`
  15971. }
  15972. type ResultThirteen struct {
  15973. ErrMsg string `json:"err_msg"`
  15974. InfRefmsgid string `json:"inf_refmsgid"`
  15975. Infcode int64 `json:"infcode"`
  15976. Output struct {
  15977. Result struct {
  15978. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15979. } `json:"result"`
  15980. } `json:"output"`
  15981. RefmsgTime string `json:"refmsg_time"`
  15982. RespondTime string `json:"respond_time"`
  15983. Signtype interface{} `json:"signtype"`
  15984. WarnInfo interface{} `json:"warn_info"`
  15985. }
  15986. type ResultThirteen10265 struct {
  15987. ErrMsg string `json:"err_msg"`
  15988. InfRefmsgid string `json:"inf_refmsgid"`
  15989. Infcode string `json:"infcode"`
  15990. Output struct {
  15991. Result struct {
  15992. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15993. } `json:"result"`
  15994. } `json:"output"`
  15995. RefmsgTime string `json:"refmsg_time"`
  15996. RespondTime string `json:"respond_time"`
  15997. Signtype interface{} `json:"signtype"`
  15998. WarnInfo interface{} `json:"warn_info"`
  15999. }
  16000. type ResultFourteen struct {
  16001. ErrMsg string `json:"err_msg"`
  16002. InfRefmsgid string `json:"inf_refmsgid"`
  16003. Infcode int64 `json:"infcode"`
  16004. Output struct {
  16005. } `json:"output"`
  16006. RefmsgTime string `json:"refmsg_time"`
  16007. RespondTime string `json:"respond_time"`
  16008. Signtype interface{} `json:"signtype"`
  16009. WarnInfo interface{} `json:"warn_info"`
  16010. }
  16011. type ResultCFYLJG001 struct {
  16012. ErrMsg string `json:"err_msg"`
  16013. InfRefmsgid string `json:"inf_refmsgid"`
  16014. Infcode int64 `json:"infcode"`
  16015. Output struct {
  16016. RxTraceCode string `json:"rx_trace_code"`
  16017. HiRxno string `json:"hi_rxno"`
  16018. } `json:"output"`
  16019. RefmsgTime string `json:"refmsg_time"`
  16020. RespondTime string `json:"respond_time"`
  16021. Signtype interface{} `json:"signtype"`
  16022. WarnInfo interface{} `json:"warn_info"`
  16023. }
  16024. type ResultCFYLJG007 struct {
  16025. ErrMsg string `json:"err_msg"`
  16026. InfRefmsgid string `json:"inf_refmsgid"`
  16027. Infcode int64 `json:"infcode"`
  16028. Output struct {
  16029. HiRxno string `json:"hi_rxno"`
  16030. RxStasName string `json:"rx_stas_name"`
  16031. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16032. Seltdelts []interface{} `json:"seltdelts"`
  16033. RxUsedStasName string `json:"rx_used_stas_name"`
  16034. RxStasCodg string `json:"rx_stas_codg"`
  16035. } `json:"output"`
  16036. RefmsgTime string `json:"refmsg_time"`
  16037. RespondTime string `json:"respond_time"`
  16038. Signtype interface{} `json:"signtype"`
  16039. WarnInfo interface{} `json:"warn_info"`
  16040. }
  16041. type ResultCFYLJG002 struct {
  16042. ErrMsg string `json:"err_msg"`
  16043. InfRefmsgid string `json:"inf_refmsgid"`
  16044. Infcode int64 `json:"infcode"`
  16045. Output struct {
  16046. RxFile string `json:"rx_file"`
  16047. SignDigest string `json:"sign_digest"`
  16048. SignCertSn string `json:"sign_cert_sn"`
  16049. SignCertDn string `json:"sign_cert_dn"`
  16050. } `json:"output"`
  16051. RefmsgTime string `json:"refmsg_time"`
  16052. RespondTime string `json:"respond_time"`
  16053. Signtype interface{} `json:"signtype"`
  16054. WarnInfo interface{} `json:"warn_info"`
  16055. }
  16056. type ResultCFYLJG003 struct {
  16057. ErrMsg string `json:"err_msg"`
  16058. InfRefmsgid string `json:"inf_refmsgid"`
  16059. Infcode int64 `json:"infcode"`
  16060. Output struct {
  16061. HiRxno string `json:"hi_rxno"`
  16062. RxStasCodg string `json:"rx_stas_codg"`
  16063. RxStasName string `json:"rx_stas_name"`
  16064. } `json:"output"`
  16065. RefmsgTime string `json:"refmsg_time"`
  16066. RespondTime string `json:"respond_time"`
  16067. Signtype interface{} `json:"signtype"`
  16068. WarnInfo interface{} `json:"warn_info"`
  16069. }
  16070. type ResultCFYLJG004 struct {
  16071. ErrMsg string `json:"err_msg"`
  16072. InfRefmsgid string `json:"inf_refmsgid"`
  16073. Infcode int64 `json:"infcode"`
  16074. Output struct {
  16075. HiRxno string `json:"hi_rxno"`
  16076. RxStasCodg string `json:"rx_stas_codg"`
  16077. RxStasName string `json:"rx_stas_name"`
  16078. } `json:"output"`
  16079. RefmsgTime string `json:"refmsg_time"`
  16080. RespondTime string `json:"respond_time"`
  16081. Signtype interface{} `json:"signtype"`
  16082. WarnInfo interface{} `json:"warn_info"`
  16083. }
  16084. type ResultCFYLJG008 struct {
  16085. ErrMsg string `json:"err_msg"`
  16086. InfRefmsgid string `json:"inf_refmsgid"`
  16087. Infcode int64 `json:"infcode"`
  16088. Output struct {
  16089. PoolareaNo string `json:"poolareaNo"`
  16090. AdmdvsName string `json:"admdvsName"`
  16091. Count string `json:"count"`
  16092. } `json:"output"`
  16093. RefmsgTime string `json:"refmsg_time"`
  16094. RespondTime string `json:"respond_time"`
  16095. Signtype interface{} `json:"signtype"`
  16096. WarnInfo interface{} `json:"warn_info"`
  16097. }
  16098. type ResultCFYLJG005 struct {
  16099. ErrMsg string `json:"err_msg"`
  16100. InfRefmsgid string `json:"inf_refmsgid"`
  16101. Infcode int64 `json:"infcode"`
  16102. Output struct {
  16103. HiRxNo string `json:"hi_rxno"`
  16104. FixMedinsCode string `json:"fixmedins_code"`
  16105. FixMedinsName string `json:"fixmedins_name"`
  16106. RxStasCodg string `json:"rx_stas_codg"`
  16107. RxStasName string `json:"rx_stas_name"`
  16108. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16109. RxUserdStasName string `json:"rx_userd_stas_name"`
  16110. PrscTime string `json:"prsc_time"`
  16111. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16112. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16113. RxUsedWayName string `json:"rx_used_way_name"`
  16114. RxFrquCodg string `json:"rx_frqu_codg"`
  16115. RxFrquName string `json:"rx_frqu_name"`
  16116. RxDosunt string `json:"rx_dosunt"`
  16117. RxDoscnt float64 `json:"rx_doscnt"`
  16118. RxDrordDscr string `json:"rx_drord_dscr"`
  16119. ValiDays int64 `json:"vali_days"`
  16120. ValiEndTime string `json:"vali_end_time"`
  16121. ReptFlag string `json:"rept_flag"`
  16122. MaxReptCnt int64 `json:"max_rept_cnt"`
  16123. ReptdCnt int64 `json:"reptd_cnt"`
  16124. MinInrvDays int64 `json:"min_inrv_days"`
  16125. RxTypeCode string `json:"rx_type_code"`
  16126. RxTypeName string `json:"rx_type_name"`
  16127. LongRxFlag string `json:"long_rx_flag"`
  16128. RxDetlList []struct {
  16129. MedListCodg string `json:"med_list_codg"`
  16130. MedinsListCodg string `json:"medins_list_codg"`
  16131. HospPrepFlag string `json:"hosp_prep_flag"`
  16132. RxItemTypeCode string `json:"rx_item_type_code"`
  16133. RxItemTypeName string `json:"rx_item_type_name"`
  16134. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16135. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16136. TcmHerbFoote string `json:"tcmherb_foote"`
  16137. MednTypeCode string `json:"medn_type_code"`
  16138. MednTypeName string `json:"medn_type_name"`
  16139. MainMedcFlag string `json:"main_medc_flag"`
  16140. UrgtFlag string `json:"urgt_flag"`
  16141. BasMednFlag string `json:"bas_medn_flag"`
  16142. ImpDrugFlag string `json:"imp_drug_flag"`
  16143. ProdBarc string `json:"prod_barc"`
  16144. DrugProdname string `json:"drug_prodname"`
  16145. GennameCodg string `json:"genname_codg"`
  16146. DrugGenname string `json:"drug_genname"`
  16147. DrugDosform string `json:"drug_dosform"`
  16148. DrugSpec string `json:"drug_spec"`
  16149. PrdrName string `json:"prdr_name"`
  16150. MedcWayCodg string `json:"medc_way_codg"`
  16151. MedcWayDscr string `json:"medc_way_dscr"`
  16152. MedcBegntime string `json:"medc_begntime"`
  16153. MedcEndtime string `json:"medc_endtime"`
  16154. MedcDays float64 `json:"medc_days"`
  16155. DrugPric float64 `json:"drug_pric"`
  16156. DrugSumamt float64 `json:"drug_sumamt"`
  16157. DrugCnt float64 `json:"drug_cnt"`
  16158. DrugDosunt string `json:"drug_dosunt"`
  16159. SinDoscnt float64 `json:"sin_doscnt"`
  16160. SinDosunt string `json:"sin_dosunt"`
  16161. UsedFrquCodg string `json:"used_frqu_codg"`
  16162. UsedFrquName string `json:"used_frqu_name"`
  16163. DrugTotlcnt string `json:"drug_totlcnt"`
  16164. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16165. DiseCodg string `json:"dise_codg"`
  16166. HospApprFlag string `json:"hosp_appr_flag"`
  16167. } `json:"rx_detl_list"`
  16168. RxOtpinfo struct {
  16169. MedType string `json:"med_type"`
  16170. IptOtpNo string `json:"ipt_otp_no"`
  16171. OtpIptFlag string `json:"otp_ipt_flag"`
  16172. PatnName string `json:"patn_name"`
  16173. PatnAge float64 `json:"patn_age"`
  16174. PatnHgt float64 `json:"patn_hgt"`
  16175. PatnWt float64 `json:"patn_wt"`
  16176. Gend string `json:"gend"`
  16177. GesoVal float64 `json:"geso_val"`
  16178. NwbFlag string `json:"nwb_flag"`
  16179. NwbAge string `json:"nwb_age"`
  16180. SuckPrdFlag string `json:"suck_prd_flag"`
  16181. AlgsHis string `json:"algs_his"`
  16182. Insutype string `json:"insutype"`
  16183. PrscDeptName string `json:"prsc_dept_name"`
  16184. PrscDrName string `json:"prsc_dr_name"`
  16185. PharName string `json:"phar_name"`
  16186. PharChkTime string `json:"phar_chk_time"`
  16187. MdtrtTime string `json:"mdtrt_time"`
  16188. DiseCodg string `json:"dise_codg"`
  16189. DiseName string `json:"dise_name"`
  16190. SpDiseFlag string `json:"sp_dise_flag"`
  16191. MaindiagCode string `json:"maindiag_code"`
  16192. MaindiagName string `json:"maindiag_name"`
  16193. DiseCondDscr string `json:"dise_cond_dscr"`
  16194. FstdiagFlag string `json:"fstdiag_flag"`
  16195. } `json:"rx_otpinfo"`
  16196. RxDiseList []struct {
  16197. DiagType string `json:"diag_type"`
  16198. MaindiagFlag string `json:"maindiag_flag"`
  16199. DiagSrtNo string `json:"diag_srt_no"`
  16200. DiagCode string `json:"diag_code"`
  16201. DiagName string `json:"diag_name"`
  16202. DiagDept string `json:"diag_dept"`
  16203. DiagDrNo string `json:"diag_dr_no"`
  16204. DiagDrName string `json:"diag_dr_name"`
  16205. DiagTime string `json:"diag_time"`
  16206. TcmDiseCode string `json:"tcm_dise_code"`
  16207. TcmDiseName string `json:"tcm_dise_name"`
  16208. TcmSympCode string `json:"tcmsymp_code"`
  16209. TcmSymp string `json:"tcmsymp"`
  16210. } `json:"rx_dise_list"`
  16211. } `json:"output"`
  16212. RefmsgTime string `json:"refmsg_time"`
  16213. RespondTime string `json:"respond_time"`
  16214. Signtype interface{} `json:"signtype"`
  16215. WarnInfo interface{} `json:"warn_info"`
  16216. }
  16217. type ResultCFYLJG006 struct {
  16218. ErrMsg string `json:"err_msg"`
  16219. InfRefmsgid string `json:"inf_refmsgid"`
  16220. Infcode int64 `json:"infcode"`
  16221. Output struct {
  16222. HiRxNo string `json:"hi_rxno"`
  16223. PharCode string `json:"phar_code"`
  16224. PharName string `json:"phar_name"`
  16225. RxChkOpnn string `json:"rx_chk_opnn"`
  16226. RxChkTime string `json:"rx_chk_time"`
  16227. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16228. RxChkStasName string `json:"rx_chk_stas_name"`
  16229. RxStasCodg string `json:"rx_stas_codg"`
  16230. RxStasName string `json:"rx_stas_name"`
  16231. } `json:"output"`
  16232. RefmsgTime string `json:"refmsg_time"`
  16233. RespondTime string `json:"respond_time"`
  16234. Signtype interface{} `json:"signtype"`
  16235. WarnInfo interface{} `json:"warn_info"`
  16236. }
  16237. type ResultFourteen10265 struct {
  16238. ErrMsg string `json:"err_msg"`
  16239. InfRefmsgid string `json:"inf_refmsgid"`
  16240. Infcode string `json:"infcode"`
  16241. Output struct {
  16242. } `json:"output"`
  16243. RefmsgTime string `json:"refmsg_time"`
  16244. RespondTime string `json:"respond_time"`
  16245. Signtype interface{} `json:"signtype"`
  16246. WarnInfo interface{} `json:"warn_info"`
  16247. }
  16248. type ResultSixteen struct {
  16249. Cainfo string `json:"cainfo"`
  16250. ErrMsg string `json:"err_msg"`
  16251. InfRefmsgid string `json:"inf_refmsgid"`
  16252. Infcode int64 `json:"infcode"`
  16253. Output struct {
  16254. Setlinfo struct {
  16255. MdtrtID string `json:"mdtrt_id"`
  16256. SetlID string `json:"setl_id"`
  16257. ClrOptins string `json:"clr_optins"`
  16258. SetlTime string `json:"setl_time"`
  16259. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16260. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16261. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16262. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16263. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16264. ActPayDedc float64 `json:"act_pay_dedc"`
  16265. HifpPay float64 `json:"hifp_pay"`
  16266. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16267. Lfpay float64 `json:"selfpay"`
  16268. CvlservPay float64 `json:"cvlserv_pay"`
  16269. HifesPay float64 `json:"hifes_pay"`
  16270. HifmiPay float64 `json:"hifmi_pay"`
  16271. HifobPay float64 `json:"hifob_pay"`
  16272. MafPay float64 `json:"maf_pay"`
  16273. OthPay float64 `json:"oth_pay"`
  16274. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16275. PsnPartAmt float64 `json:"psn_part_amt"`
  16276. AcctPay float64 `json:"acct_pay"`
  16277. Balc float64 `json:"balc"`
  16278. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16279. HospPartAmt float64 `json:"hosp_part_amt"`
  16280. MedinsSetlID string `json:"medins_setl_id"`
  16281. PdnCashPay string `json:"pdn_cash_pay"`
  16282. } `json:"setlinfo"`
  16283. } `json:"output"`
  16284. RefmsgTime string `json:"refmsg_time"`
  16285. RespondTime string `json:"respond_time"`
  16286. Signtype interface{} `json:"signtype"`
  16287. WarnMsg interface{} `json:"warn_msg"`
  16288. }
  16289. type ResultSixteen10265 struct {
  16290. Cainfo string `json:"cainfo"`
  16291. ErrMsg string `json:"err_msg"`
  16292. InfRefmsgid string `json:"inf_refmsgid"`
  16293. Infcode string `json:"infcode"`
  16294. Output struct {
  16295. Setlinfo struct {
  16296. MdtrtID string `json:"mdtrt_id"`
  16297. SetlID string `json:"setl_id"`
  16298. ClrOptins string `json:"clr_optins"`
  16299. SetlTime string `json:"setl_time"`
  16300. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16301. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16302. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16303. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16304. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16305. ActPayDedc float64 `json:"act_pay_dedc"`
  16306. HifpPay float64 `json:"hifp_pay"`
  16307. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16308. Lfpay float64 `json:"selfpay"`
  16309. CvlservPay float64 `json:"cvlserv_pay"`
  16310. HifesPay float64 `json:"hifes_pay"`
  16311. HifmiPay float64 `json:"hifmi_pay"`
  16312. HifobPay float64 `json:"hifob_pay"`
  16313. MafPay float64 `json:"maf_pay"`
  16314. OthPay float64 `json:"oth_pay"`
  16315. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16316. PsnPartAmt float64 `json:"psn_part_amt"`
  16317. AcctPay float64 `json:"acct_pay"`
  16318. Balc float64 `json:"balc"`
  16319. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16320. HospPartAmt float64 `json:"hosp_part_amt"`
  16321. MedinsSetlID string `json:"medins_setl_id"`
  16322. PdnCashPay string `json:"pdn_cash_pay"`
  16323. } `json:"setlinfo"`
  16324. } `json:"output"`
  16325. RefmsgTime string `json:"refmsg_time"`
  16326. RespondTime string `json:"respond_time"`
  16327. Signtype interface{} `json:"signtype"`
  16328. WarnMsg interface{} `json:"warn_msg"`
  16329. }
  16330. type ResultSixteen10265Two struct {
  16331. Cainfo string `json:"cainfo"`
  16332. ErrMsg string `json:"err_msg"`
  16333. InfRefmsgid string `json:"inf_refmsgid"`
  16334. Infcode string `json:"infcode"`
  16335. Output struct {
  16336. Setlinfo interface{} `json:"setlinfo"`
  16337. } `json:"output"`
  16338. RefmsgTime string `json:"refmsg_time"`
  16339. RespondTime string `json:"respond_time"`
  16340. Signtype interface{} `json:"signtype"`
  16341. WarnMsg interface{} `json:"warn_msg"`
  16342. }
  16343. type ResultgzSixteen10265Two struct {
  16344. Cainfo string `json:"cainfo"`
  16345. ErrMsg string `json:"err_msg"`
  16346. InfRefmsgid string `json:"inf_refmsgid"`
  16347. Infcode int64 `json:"infcode"`
  16348. Output struct {
  16349. Setlinfo interface{} `json:"setlinfo"`
  16350. } `json:"output"`
  16351. RefmsgTime string `json:"refmsg_time"`
  16352. RespondTime string `json:"respond_time"`
  16353. Signtype interface{} `json:"signtype"`
  16354. WarnMsg interface{} `json:"warn_msg"`
  16355. }
  16356. type ResultSeventeen struct {
  16357. ErrMsg string `json:"err_msg"`
  16358. InfRefmsgid string `json:"inf_refmsgid"`
  16359. Infcode int64 `json:"infcode"`
  16360. Output struct {
  16361. SetlListId string `json:"setl_list_id"`
  16362. } `json:"output"`
  16363. RefmsgTime string `json:"refmsg_time"`
  16364. RespondTime string `json:"respond_time"`
  16365. Signtype string `json:"signtype"`
  16366. WarnInfo string `json:"warn_info"`
  16367. }
  16368. type ResultSeventeenOther struct {
  16369. ErrMsg string `json:"err_msg"`
  16370. InfRefmsgid string `json:"inf_refmsgid"`
  16371. Infcode string `json:"infcode"`
  16372. Output struct {
  16373. SetlListId string `json:"setl_list_id"`
  16374. } `json:"output"`
  16375. RefmsgTime string `json:"refmsg_time"`
  16376. RespondTime string `json:"respond_time"`
  16377. Signtype string `json:"signtype"`
  16378. WarnInfo string `json:"warn_info"`
  16379. }
  16380. type Result90991 struct {
  16381. ErrMsg string `json:"err_msg"`
  16382. InfRefmsgid string `json:"inf_refmsgid"`
  16383. Infcode int64 `json:"infcode"`
  16384. Output struct {
  16385. Result struct {
  16386. PsnNo string `json:"psn_no"`
  16387. CardStat string `json:"card_stat"`
  16388. Certno string `json:"certno"`
  16389. PsnName string `json:"psn_name"`
  16390. CheckStat string `json:"check_stat"`
  16391. SscnoCheckStat string `json:"sscno_check_stat"`
  16392. } `json:"result"`
  16393. } `json:"output"`
  16394. RefmsgTime string `json:"refmsg_time"`
  16395. RespondTime string `json:"respond_time"`
  16396. Signtype interface{} `json:"signtype"`
  16397. WarnInfo interface{} `json:"warn_info"`
  16398. }
  16399. type Result90100 struct {
  16400. ErrMsg string `json:"err_msg"`
  16401. InfRefmsgid string `json:"inf_refmsgid"`
  16402. Infcode int64 `json:"infcode"`
  16403. Output struct {
  16404. PoolareaNo string `json:"poolarea_no"`
  16405. PoolareaNoName string `json:"poolarea_no_name"`
  16406. Insutype string `json:"insutype"`
  16407. InsutypeName string `json:"insutype_name"`
  16408. ClctType string `json:"clct_type"`
  16409. ClctTypeName string `json:"clct_type_name"`
  16410. ClctFlag string `json:"clct_flag"`
  16411. ClctFlagName string `json:"clct_flag_name"`
  16412. AccrymBegn string `json:"accrym_begn"`
  16413. AccrymEnd string `json:"accrym_end"`
  16414. ClctTime string `json:"clct_time"`
  16415. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16416. } `json:"output"`
  16417. RefmsgTime string `json:"refmsg_time"`
  16418. RespondTime string `json:"respond_time"`
  16419. Signtype interface{} `json:"signtype"`
  16420. WarnInfo interface{} `json:"warn_info"`
  16421. }
  16422. type Custom struct {
  16423. DetItemFeeSumamt string
  16424. Cut string
  16425. FeedetlSn string
  16426. Price string
  16427. MedListCodg string
  16428. Type int64
  16429. AdviceId int64
  16430. ProjectId int64
  16431. ItemId int64
  16432. }
  16433. type Result5301 struct {
  16434. ErrMsg string `json:"err_msg"`
  16435. InfRefmsgid string `json:"inf_refmsgid"`
  16436. Infcode int64 `json:"infcode"`
  16437. Output struct {
  16438. Result []struct {
  16439. OpspDiseCode string `json:"opsp_dise_code"`
  16440. OpspDiseName string `json:"opsp_dise_name"`
  16441. Begndate string `json:"begndate"`
  16442. Enddate string `json:"enddate"`
  16443. } `json:"feedetail"`
  16444. } `json:"output"`
  16445. RefmsgTime string `json:"refmsg_time"`
  16446. RespondTime string `json:"respond_time"`
  16447. Signtype interface{} `json:"signtype"`
  16448. WarnInfo interface{} `json:"warn_info"`
  16449. }
  16450. type Result5301For10265 struct {
  16451. ErrMsg string `json:"err_msg"`
  16452. InfRefmsgid string `json:"inf_refmsgid"`
  16453. Infcode string `json:"infcode"`
  16454. Output struct {
  16455. Result []struct {
  16456. OpspDiseCode string `json:"opsp_dise_code"`
  16457. OpspDiseName string `json:"opsp_dise_name"`
  16458. Begndate string `json:"begndate"`
  16459. Enddate string `json:"enddate"`
  16460. } `json:"feedetail"`
  16461. } `json:"output"`
  16462. RefmsgTime string `json:"refmsg_time"`
  16463. RespondTime string `json:"respond_time"`
  16464. Signtype interface{} `json:"signtype"`
  16465. WarnInfo interface{} `json:"warn_info"`
  16466. }
  16467. //获取个人信息----挂号-----上传就诊信息
  16468. func (c *HisApiController) GetRegisterInfo() {
  16469. id, _ := c.GetInt64("id")
  16470. record_time := c.GetString("record_time")
  16471. settlementValue, _ := c.GetInt64("settlement_value")
  16472. medical_insurance_card := c.GetString("medical_insurance_card")
  16473. name := c.GetString("name")
  16474. id_card_type, _ := c.GetInt64("id_card_type")
  16475. certificates, _ := c.GetInt64("certificates")
  16476. medical_care, _ := c.GetInt64("medical_care")
  16477. birthday := c.GetString("birthday")
  16478. id_card := c.GetString("id_card")
  16479. register_type, _ := c.GetInt64("register")
  16480. doctor, _ := c.GetInt64("doctor")
  16481. department, _ := c.GetInt64("department")
  16482. gender, _ := c.GetInt64("sex")
  16483. registration_fee, _ := c.GetFloat("registration_fee")
  16484. medical_expenses, _ := c.GetFloat("medical_expenses")
  16485. social_type, _ := c.GetInt64("social_type")
  16486. admin_user_id, _ := c.GetInt64("admin_user_id")
  16487. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16488. mdtrt_type := c.GetString("mdtrt_type")
  16489. if id_card_type == 5 {
  16490. id_card_type = 4
  16491. }
  16492. timeLayout := "2006-01-02"
  16493. loc, _ := time.LoadLocation("Local")
  16494. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16495. birthUnix := birthdays.Unix()
  16496. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16497. if err != nil {
  16498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16499. return
  16500. }
  16501. recordDateTime := theTime.Unix()
  16502. adminInfo := c.GetAdminUserInfo()
  16503. var patient service.Patients
  16504. if id == 0 {
  16505. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16506. } else {
  16507. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16508. }
  16509. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16510. if patientPrescription.ID == 0 {
  16511. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16512. }
  16513. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16514. if patient.ID == 0 {
  16515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16516. return
  16517. }
  16518. if len(patient.IdCardNo) == 0 {
  16519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16520. return
  16521. }
  16522. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16523. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16524. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16525. //就诊结算未完成,不能进行二次挂号
  16526. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16527. //if len(his) >= 1 {
  16528. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16529. // if len(his) >= 1 && order.ID == 0 {
  16530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16531. // return
  16532. // }
  16533. //}
  16534. //var register_log string
  16535. if config.IsOpen == 1 {
  16536. var res ResultTwo
  16537. var res10265 ResultTwo10265
  16538. var PsnNo string
  16539. var PsnCertType string
  16540. var Certno string
  16541. var PsnName string
  16542. var Gend string
  16543. var Naty string
  16544. var Brdy string
  16545. var Age float64
  16546. var infoStr string
  16547. var idetinfoStr string
  16548. var infocode int64
  16549. var verify_number string
  16550. fmt.Println(verify_number)
  16551. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  16552. psn_info, _ := service.GetPsnByPatientId(id)
  16553. PsnNo = psn_info.PsnNo
  16554. PsnCertType = psn_info.PsnCertType
  16555. Certno = psn_info.Certno
  16556. PsnName = psn_info.PsnName
  16557. Gend = psn_info.Gend
  16558. Naty = psn_info.Naty
  16559. Brdy = psn_info.Brdy
  16560. Age = psn_info.Age
  16561. infoStr = psn_info.Insuinfo
  16562. idetinfoStr = psn_info.Idetinfo
  16563. infocode = 0
  16564. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16565. psn_info, _ := service.GetPsnByPatientId(id)
  16566. PsnNo = psn_info.PsnNo
  16567. PsnCertType = psn_info.PsnCertType
  16568. Certno = psn_info.Certno
  16569. PsnName = psn_info.PsnName
  16570. Gend = psn_info.Gend
  16571. Naty = psn_info.Naty
  16572. Brdy = psn_info.Brdy
  16573. Age = psn_info.Age
  16574. infoStr = psn_info.Insuinfo
  16575. idetinfoStr = psn_info.Idetinfo
  16576. infocode = 0
  16577. verify_number = psn_info.VerifyNumber
  16578. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16579. if id_card_type == 2 {
  16580. //请求内网数据
  16581. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16582. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16583. "&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
  16584. resp, requestErr := http.Get(api)
  16585. if requestErr != nil {
  16586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16587. return
  16588. }
  16589. body, ioErr := ioutil.ReadAll(resp.Body)
  16590. if ioErr != nil {
  16591. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16593. return
  16594. }
  16595. var respJSON map[string]interface{}
  16596. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16597. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16599. return
  16600. }
  16601. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16602. result_byte, _ := json.Marshal(respJSON)
  16603. result := string(result_byte)
  16604. var dat map[string]interface{}
  16605. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16606. fmt.Println(dat)
  16607. } else {
  16608. fmt.Println(err)
  16609. }
  16610. userJSONBytes, _ := json.Marshal(dat)
  16611. var res ResultTwo
  16612. var resTwo10265 ResultTwo10265
  16613. if miConfig.Code == "H15049901371" {
  16614. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16615. utils.ErrorLog("解析失败:%v", err)
  16616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16617. return
  16618. }
  16619. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16620. res.Infcode = Infcode
  16621. res.ErrMsg = resTwo10265.ErrMsg
  16622. res.Output = resTwo10265.Output
  16623. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16624. res.RespondTime = resTwo10265.RespondTime
  16625. res.WarnInfo = resTwo10265.WarnInfo
  16626. } else {
  16627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16628. utils.ErrorLog("解析失败:%v", err)
  16629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16630. return
  16631. }
  16632. }
  16633. //var insutypes []string
  16634. //var insutype string
  16635. //var is390 int = 0
  16636. //var is310 int = 0
  16637. //for _, item := range res.Output.Iinfo {
  16638. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16639. // insutypes = append(insutypes, item.Insutype)
  16640. // }
  16641. //}
  16642. //if len(insutypes) == 1 {
  16643. // insutype = insutypes[0]
  16644. //} else {
  16645. // for _, i := range insutypes {
  16646. // if i == "390" {
  16647. // is390 = 1
  16648. // }
  16649. //
  16650. // if i == "310" {
  16651. // is310 = 1
  16652. // }
  16653. // }
  16654. //}
  16655. //if is390 == 1 {
  16656. // insutype = "390"
  16657. //}
  16658. //if is310 == 1 {
  16659. // insutype = "310"
  16660. //}
  16661. //if len(insutypes) == 0 {
  16662. // insutype = "310"
  16663. //}
  16664. PsnNo = res.Output.Baseinfo.PsnNo
  16665. PsnCertType = res.Output.Baseinfo.PsnCertType
  16666. Certno = res.Output.Baseinfo.Certno
  16667. PsnName = res.Output.Baseinfo.PsnName
  16668. Gend = res.Output.Baseinfo.Gend
  16669. Naty = res.Output.Baseinfo.Naty
  16670. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16671. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16672. infoStr = string(Iinfos)
  16673. idetinfoStr = string(Idetinfos)
  16674. infocode = res.Infcode
  16675. //infocode = 0
  16676. //verify_number = psn_info.VerifyNumber
  16677. } else {
  16678. psn_info, _ := service.GetPsnByPatientId(id)
  16679. PsnNo = psn_info.PsnNo
  16680. PsnCertType = psn_info.PsnCertType
  16681. Certno = psn_info.Certno
  16682. PsnName = psn_info.PsnName
  16683. Gend = psn_info.Gend
  16684. Naty = psn_info.Naty
  16685. Brdy = psn_info.Brdy
  16686. Age = psn_info.Age
  16687. infoStr = psn_info.Insuinfo
  16688. idetinfoStr = psn_info.Idetinfo
  16689. infocode = 0
  16690. verify_number = psn_info.VerifyNumber
  16691. }
  16692. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16693. if id_card_type == 1 {
  16694. psn_info, _ := service.GetPsnByPatientId(id)
  16695. PsnNo = psn_info.PsnNo
  16696. PsnCertType = psn_info.PsnCertType
  16697. Certno = psn_info.Certno
  16698. PsnName = psn_info.PsnName
  16699. Gend = psn_info.Gend
  16700. Naty = psn_info.Naty
  16701. Brdy = psn_info.Brdy
  16702. Age = psn_info.Age
  16703. infoStr = psn_info.Insuinfo
  16704. idetinfoStr = psn_info.Idetinfo
  16705. infocode = 0
  16706. verify_number = psn_info.VerifyNumber
  16707. } else if id_card_type == 2 {
  16708. 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)
  16709. fmt.Println(errMsgLog)
  16710. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16711. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16712. utils.ErrorLog("解析失败:%v", err)
  16713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16714. return
  16715. }
  16716. PsnNo = res.Output.Baseinfo.PsnNo
  16717. PsnCertType = res.Output.Baseinfo.PsnCertType
  16718. Certno = res.Output.Baseinfo.Certno
  16719. PsnName = res.Output.Baseinfo.PsnName
  16720. Gend = res.Output.Baseinfo.Gend
  16721. Naty = res.Output.Baseinfo.Naty
  16722. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16723. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16724. infoStr = string(Iinfos)
  16725. idetinfoStr = string(Idetinfos)
  16726. infocode = res.Infcode
  16727. }
  16728. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16729. if id_card_type == 1 {
  16730. psn_info, _ := service.GetPsnByPatientId(id)
  16731. PsnNo = psn_info.PsnNo
  16732. PsnCertType = psn_info.PsnCertType
  16733. Certno = psn_info.Certno
  16734. PsnName = psn_info.PsnName
  16735. Gend = psn_info.Gend
  16736. Naty = psn_info.Naty
  16737. Brdy = psn_info.Brdy
  16738. Age = psn_info.Age
  16739. infoStr = psn_info.Insuinfo
  16740. idetinfoStr = psn_info.Idetinfo
  16741. infocode = 0
  16742. verify_number = psn_info.VerifyNumber
  16743. } else if id_card_type == 2 {
  16744. 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, "")
  16745. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16746. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16747. utils.ErrorLog("解析失败:%v", err)
  16748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16749. return
  16750. }
  16751. PsnNo = res.Output.Baseinfo.PsnNo
  16752. PsnCertType = res.Output.Baseinfo.PsnCertType
  16753. Certno = res.Output.Baseinfo.Certno
  16754. PsnName = res.Output.Baseinfo.PsnName
  16755. Gend = res.Output.Baseinfo.Gend
  16756. Naty = res.Output.Baseinfo.Naty
  16757. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16758. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16759. infoStr = string(Iinfos)
  16760. idetinfoStr = string(Idetinfos)
  16761. infocode = res.Infcode
  16762. } else {
  16763. psn_info, _ := service.GetPsnByPatientId(id)
  16764. PsnNo = psn_info.PsnNo
  16765. PsnCertType = psn_info.PsnCertType
  16766. Certno = psn_info.Certno
  16767. PsnName = psn_info.PsnName
  16768. Gend = psn_info.Gend
  16769. Naty = psn_info.Naty
  16770. Brdy = psn_info.Brdy
  16771. Age = psn_info.Age
  16772. infoStr = psn_info.Insuinfo
  16773. idetinfoStr = psn_info.Idetinfo
  16774. infocode = 0
  16775. verify_number = psn_info.VerifyNumber
  16776. }
  16777. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16778. psn_info, _ := service.GetPsnByPatientId(id)
  16779. PsnNo = psn_info.PsnNo
  16780. PsnCertType = psn_info.PsnCertType
  16781. Certno = psn_info.Certno
  16782. PsnName = psn_info.PsnName
  16783. Gend = psn_info.Gend
  16784. Naty = psn_info.Naty
  16785. Brdy = psn_info.Brdy
  16786. Age = psn_info.Age
  16787. infoStr = psn_info.Insuinfo
  16788. idetinfoStr = psn_info.Idetinfo
  16789. infocode = 0
  16790. verify_number = psn_info.VerifyNumber
  16791. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16792. if id_card_type == 1 {
  16793. psn_info, _ := service.GetPsnByPatientId(id)
  16794. PsnNo = psn_info.PsnNo
  16795. PsnCertType = psn_info.PsnCertType
  16796. Certno = psn_info.Certno
  16797. PsnName = psn_info.PsnName
  16798. Gend = psn_info.Gend
  16799. Naty = psn_info.Naty
  16800. Brdy = psn_info.Brdy
  16801. Age = psn_info.Age
  16802. infoStr = psn_info.Insuinfo
  16803. idetinfoStr = psn_info.Idetinfo
  16804. infocode = 0
  16805. verify_number = psn_info.VerifyNumber
  16806. } else if id_card_type == 2 {
  16807. 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)
  16808. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16810. utils.ErrorLog("解析失败:%v", err)
  16811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16812. return
  16813. }
  16814. PsnNo = res.Output.Baseinfo.PsnNo
  16815. PsnCertType = res.Output.Baseinfo.PsnCertType
  16816. Certno = res.Output.Baseinfo.Certno
  16817. PsnName = res.Output.Baseinfo.PsnName
  16818. Gend = res.Output.Baseinfo.Gend
  16819. Naty = res.Output.Baseinfo.Naty
  16820. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16821. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16822. infoStr = string(Iinfos)
  16823. idetinfoStr = string(Idetinfos)
  16824. infocode = res.Infcode
  16825. } else if id_card_type == 4 {
  16826. psn_info, _ := service.GetPsnByPatientId(id)
  16827. PsnNo = psn_info.PsnNo
  16828. PsnCertType = psn_info.PsnCertType
  16829. Certno = psn_info.Certno
  16830. PsnName = psn_info.PsnName
  16831. Gend = psn_info.Gend
  16832. Naty = psn_info.Naty
  16833. Brdy = psn_info.Brdy
  16834. Age = psn_info.Age
  16835. infoStr = psn_info.Insuinfo
  16836. idetinfoStr = psn_info.Idetinfo
  16837. infocode = 0
  16838. verify_number = psn_info.VerifyNumber
  16839. }
  16840. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16841. var result string
  16842. var requestLog string
  16843. 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), "")
  16844. if id_card_type == 4 {
  16845. psn_info, _ := service.GetPsnByPatientId(id)
  16846. PsnNo = psn_info.PsnNo
  16847. PsnCertType = psn_info.PsnCertType
  16848. Certno = psn_info.Certno
  16849. PsnName = psn_info.PsnName
  16850. Gend = psn_info.Gend
  16851. Naty = psn_info.Naty
  16852. Brdy = psn_info.Brdy
  16853. Age = psn_info.Age
  16854. infoStr = psn_info.Insuinfo
  16855. idetinfoStr = psn_info.Idetinfo
  16856. infocode = 0
  16857. verify_number = psn_info.VerifyNumber
  16858. } else {
  16859. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16860. if miConfig.Code == "H15049901371" {
  16861. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16862. utils.ErrorLog("解析失败:%v", err)
  16863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16864. return
  16865. }
  16866. res.ErrMsg = res10265.ErrMsg
  16867. res.Output = res10265.Output
  16868. res.InfRefmsgid = res10265.InfRefmsgid
  16869. } else {
  16870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16871. utils.ErrorLog("解析失败:%v", err)
  16872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16873. return
  16874. }
  16875. }
  16876. PsnNo = res.Output.Baseinfo.PsnNo
  16877. PsnCertType = res.Output.Baseinfo.PsnCertType
  16878. Certno = res.Output.Baseinfo.Certno
  16879. PsnName = res.Output.Baseinfo.PsnName
  16880. Gend = res.Output.Baseinfo.Gend
  16881. Naty = res.Output.Baseinfo.Naty
  16882. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16883. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16884. infoStr = string(Iinfos)
  16885. idetinfoStr = string(Idetinfos)
  16886. if miConfig.Code == "H15049901371" {
  16887. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16888. } else {
  16889. infocode = res.Infcode
  16890. }
  16891. }
  16892. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16893. psn_info, _ := service.GetPsnByPatientId(id)
  16894. PsnNo = psn_info.PsnNo
  16895. PsnCertType = psn_info.PsnCertType
  16896. Certno = psn_info.Certno
  16897. PsnName = psn_info.PsnName
  16898. Gend = psn_info.Gend
  16899. Naty = psn_info.Naty
  16900. Brdy = psn_info.Brdy
  16901. Age = psn_info.Age
  16902. infoStr = psn_info.Insuinfo
  16903. idetinfoStr = psn_info.Idetinfo
  16904. infocode = 0
  16905. verify_number = psn_info.VerifyNumber
  16906. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16907. psn_info, _ := service.GetPsnByPatientId(id)
  16908. PsnNo = psn_info.PsnNo
  16909. PsnCertType = psn_info.PsnCertType
  16910. Certno = psn_info.Certno
  16911. PsnName = psn_info.PsnName
  16912. Gend = psn_info.Gend
  16913. Naty = psn_info.Naty
  16914. Brdy = psn_info.Brdy
  16915. Age = psn_info.Age
  16916. infoStr = psn_info.Insuinfo
  16917. idetinfoStr = psn_info.Idetinfo
  16918. infocode = 0
  16919. verify_number = psn_info.VerifyNumber
  16920. } else {
  16921. var result string
  16922. var requestLog string
  16923. //if miConfig.UserOrgId == 10138 {
  16924. if id_card_type != 4 || id_card_type != 1 {
  16925. var insa string
  16926. if len(patient.InsuplcAdmdvs) > 0 {
  16927. insa = patient.InsuplcAdmdvs
  16928. } else {
  16929. insa = miConfig.InsuplcAdmdvs
  16930. }
  16931. //psn_info, _ := service.GetPsnByPatientId(id)
  16932. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16933. 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)
  16934. }
  16935. //}
  16936. //else {
  16937. // var insa string
  16938. // if len(patient.InsuplcAdmdvs) > 0 {
  16939. // insa = patient.InsuplcAdmdvs
  16940. // } else {
  16941. // insa = miConfig.InsuplcAdmdvs
  16942. // }
  16943. // 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)
  16944. //}
  16945. if id_card_type == 4 || id_card_type == 1 {
  16946. psn_info, _ := service.GetPsnByPatientId(id)
  16947. PsnNo = psn_info.PsnNo
  16948. PsnCertType = psn_info.PsnCertType
  16949. Certno = psn_info.Certno
  16950. PsnName = psn_info.PsnName
  16951. Gend = psn_info.Gend
  16952. Naty = psn_info.Naty
  16953. Brdy = psn_info.Brdy
  16954. Age = psn_info.Age
  16955. infoStr = psn_info.Insuinfo
  16956. idetinfoStr = psn_info.Idetinfo
  16957. infocode = 0
  16958. verify_number = psn_info.VerifyNumber
  16959. } else {
  16960. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16961. if miConfig.Code == "H15049901371" {
  16962. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16963. utils.ErrorLog("解析失败:%v", err)
  16964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16965. return
  16966. }
  16967. res.ErrMsg = res10265.ErrMsg
  16968. res.Output = res10265.Output
  16969. res.InfRefmsgid = res10265.InfRefmsgid
  16970. } else {
  16971. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16972. utils.ErrorLog("解析失败:%v", err)
  16973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16974. return
  16975. }
  16976. }
  16977. PsnNo = res.Output.Baseinfo.PsnNo
  16978. PsnCertType = res.Output.Baseinfo.PsnCertType
  16979. Certno = res.Output.Baseinfo.Certno
  16980. PsnName = res.Output.Baseinfo.PsnName
  16981. Gend = res.Output.Baseinfo.Gend
  16982. Naty = res.Output.Baseinfo.Naty
  16983. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16984. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16985. infoStr = string(Iinfos)
  16986. idetinfoStr = string(Idetinfos)
  16987. if miConfig.Code == "H15049901371" {
  16988. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16989. } else {
  16990. infocode = res.Infcode
  16991. }
  16992. }
  16993. }
  16994. if infocode == 0 {
  16995. his := models.VMHisPatient{
  16996. Name: name,
  16997. Gender: gender,
  16998. Birthday: birthUnix,
  16999. MedicalTreatmentType: medical_care,
  17000. IdType: certificates,
  17001. IdCardNo: id_card,
  17002. BalanceAccountsType: settlementValue,
  17003. SocialType: social_type,
  17004. MedicalInsuranceNumber: medical_insurance_card,
  17005. RegisterType: register_type,
  17006. RegisterCost: registration_fee,
  17007. TreatmentCost: medical_expenses,
  17008. Status: 1,
  17009. Ctime: time.Now().Unix(),
  17010. Mtime: time.Now().Unix(),
  17011. PsnNo: PsnNo,
  17012. PsnCertType: PsnCertType,
  17013. Certno: Certno,
  17014. PsnName: PsnName,
  17015. Gend: Gend,
  17016. Naty: Naty,
  17017. Brdy: Brdy,
  17018. Age: Age,
  17019. Iinfo: infoStr,
  17020. Idetinfo: idetinfoStr,
  17021. PatientId: patient.ID,
  17022. RecordDate: theTime.Unix(),
  17023. UserOrgId: adminInfo.CurrentOrgId,
  17024. AdminUserId: admin_user_id,
  17025. IsReturn: 1,
  17026. IdCardType: id_card_type,
  17027. Doctor: doctor,
  17028. Departments: department,
  17029. MdtrtGrpType: mdtrt_type,
  17030. }
  17031. timestamp := time.Now().Unix()
  17032. tempTime := time.Unix(timestamp, 0)
  17033. timeFormat := tempTime.Format("20060102150405")
  17034. chrgBchno := rand.Intn(100000) + 10000
  17035. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17036. his.Number = ipt_otp_no
  17037. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17038. department, _ := service.GetDepartMentDetail(department)
  17039. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17040. IdCardNo := ""
  17041. if id_card_type == 1 {
  17042. // IdCardNo = medical_insurance_card
  17043. IdCardNo = patient.IdCardNo
  17044. } else {
  17045. IdCardNo = patient.IdCardNo
  17046. }
  17047. var rf []*ResultFive
  17048. json.Unmarshal([]byte(his.Iinfo), &rf)
  17049. var insutypes []*ResultFive
  17050. var insutype string
  17051. var insuplc_admdvs_temp string
  17052. var is390 int = 0
  17053. var is310 int = 0
  17054. for _, item := range rf {
  17055. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17056. insutypes = append(insutypes, item)
  17057. }
  17058. }
  17059. if len(insutypes) == 1 {
  17060. insutype = insutypes[0].Insutype
  17061. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17062. if insutype == "390" {
  17063. is390 = 1
  17064. }
  17065. if insutype == "310" {
  17066. is310 = 1
  17067. }
  17068. } else {
  17069. for _, i := range insutypes {
  17070. if i.Insutype == "390" {
  17071. is390 = 1
  17072. }
  17073. if i.Insutype == "310" {
  17074. is310 = 1
  17075. }
  17076. }
  17077. }
  17078. if is390 == 1 {
  17079. insutype = "390"
  17080. }
  17081. if is310 == 1 {
  17082. insutype = "310"
  17083. }
  17084. fmt.Println(social_type)
  17085. if social_type > 0 {
  17086. insutype = strconv.FormatInt(social_type, 10)
  17087. }
  17088. var infocode int64
  17089. var resThree ResultThree
  17090. var resThree10265 ResultThree10265
  17091. if len(insuplc_admdvs) == 0 {
  17092. psn_info, _ := service.GetPsnByPatientId(id)
  17093. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17094. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17095. //}
  17096. } else {
  17097. insuplc_admdvs_temp = insuplc_admdvs
  17098. }
  17099. if miConfig.MdtrtareaAdmvs == "421300" {
  17100. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17101. psn_info, _ := service.GetPsnByPatientId(id)
  17102. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17103. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17104. "&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
  17105. resp, requestErr := http.Get(api)
  17106. if requestErr != nil {
  17107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17108. return
  17109. }
  17110. body, ioErr := ioutil.ReadAll(resp.Body)
  17111. if ioErr != nil {
  17112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17114. return
  17115. }
  17116. var respJSON map[string]interface{}
  17117. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17120. return
  17121. }
  17122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17123. result, _ := json.Marshal(respJSON)
  17124. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17125. utils.ErrorLog("解析失败:%v", err)
  17126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17127. return
  17128. }
  17129. infocode = resThree.Infcode
  17130. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17131. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17132. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17133. // insuplc_admdvs_temp =
  17134. //}
  17135. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17136. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17137. //}
  17138. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17139. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17140. "&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
  17141. resp, requestErr := http.Get(api)
  17142. if requestErr != nil {
  17143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17144. return
  17145. }
  17146. body, ioErr := ioutil.ReadAll(resp.Body)
  17147. if ioErr != nil {
  17148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17150. return
  17151. }
  17152. var respJSON map[string]interface{}
  17153. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17156. return
  17157. }
  17158. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17159. result, _ := json.Marshal(respJSON)
  17160. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17161. utils.ErrorLog("解析失败:%v", err)
  17162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17163. return
  17164. }
  17165. infocode = resThree.Infcode
  17166. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17167. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17168. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17169. // insuplc_admdvs_temp =
  17170. //}
  17171. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17172. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17173. //}
  17174. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17175. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17176. "&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
  17177. resp, requestErr := http.Get(api)
  17178. if requestErr != nil {
  17179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17180. return
  17181. }
  17182. body, ioErr := ioutil.ReadAll(resp.Body)
  17183. if ioErr != nil {
  17184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17186. return
  17187. }
  17188. var respJSON map[string]interface{}
  17189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17192. return
  17193. }
  17194. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17195. result, _ := json.Marshal(respJSON)
  17196. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17197. utils.ErrorLog("解析失败:%v", err)
  17198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17199. return
  17200. }
  17201. infocode = resThree.Infcode
  17202. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17203. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17204. psn_info, _ := service.GetPsnByPatientId(id)
  17205. var verify_number string
  17206. if id_card_type == 4 {
  17207. verify_number = psn_info.VerifyNumber
  17208. } else if id_card_type == 1 {
  17209. bas := strings.Split(psn_info.CardInfo, "|")
  17210. cardNumber := bas[2]
  17211. verify_number = cardNumber
  17212. }
  17213. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17214. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17215. "&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
  17216. resp, requestErr := http.Get(api)
  17217. if requestErr != nil {
  17218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17219. return
  17220. }
  17221. body, ioErr := ioutil.ReadAll(resp.Body)
  17222. if ioErr != nil {
  17223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17225. return
  17226. }
  17227. var respJSON map[string]interface{}
  17228. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17231. return
  17232. }
  17233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17234. result, _ := json.Marshal(respJSON)
  17235. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17236. // utils.ErrorLog("解析失败:%v", err)
  17237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17238. // return
  17239. //}
  17240. //infocode = resThree.Infcode
  17241. //result, _ := json.Marshal(respJSON)
  17242. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17243. utils.ErrorLog("解析失败:%v", err)
  17244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17245. return
  17246. }
  17247. resThree.ErrMsg = resThree10265.ErrMsg
  17248. resThree.Output = resThree10265.Output
  17249. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17250. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17251. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17252. psn_info, _ := service.GetPsnByPatientId(id)
  17253. his.PsnNo = psn_info.PsnNo
  17254. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17255. var cert_no string
  17256. if id_card_type == 3 {
  17257. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17258. cert_no = IdCardNo
  17259. } else if id_card_type == 4 {
  17260. cert_no = IdCardNo
  17261. psn_info.VerifyNumber = psn_info.VerifyNumber
  17262. } else {
  17263. bas := strings.Split(psn_info.CardInfo, "|")
  17264. cert_no = bas[2]
  17265. }
  17266. var hisPrescription []*models.HisPrescription
  17267. for _, item := range rf {
  17268. if item.Insutype == insutype {
  17269. //insuplc_admdvs = item.InsuplcAdmdvs
  17270. his.InsuplcAdmdvs = insuplc_admdvs
  17271. }
  17272. }
  17273. his.Insutype = insutype
  17274. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17275. fmt.Println(res3101)
  17276. fmt.Println(res3101.Infcode)
  17277. if res3101.Infcode == "0" {
  17278. fmt.Println("33333333")
  17279. if len(res3101.Output.Result) > 0 {
  17280. fmt.Println("222222")
  17281. for _, item := range res3101.Output.Result {
  17282. if len(res3101.ErrMsg) == 0 {
  17283. res3101.ErrMsg = item.VolaCont
  17284. } else {
  17285. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17286. }
  17287. }
  17288. c.ServeSuccessJSON(map[string]interface{}{
  17289. "failed_code": -10,
  17290. "msg": res3101.ErrMsg,
  17291. })
  17292. return
  17293. } else {
  17294. fmt.Println("11111")
  17295. var api string
  17296. if miConfig.MdtrtareaAdmvs == "320921" {
  17297. ipt_otp_no = timeFormat
  17298. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17299. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17300. "&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
  17301. } else {
  17302. ipt_otp_no = timeFormat
  17303. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17304. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17305. "&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
  17306. }
  17307. resp, requestErr := http.Get(api)
  17308. if requestErr != nil {
  17309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17310. return
  17311. }
  17312. body, ioErr := ioutil.ReadAll(resp.Body)
  17313. if ioErr != nil {
  17314. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17316. return
  17317. }
  17318. var respJSON map[string]interface{}
  17319. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17322. return
  17323. }
  17324. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17325. result, _ := json.Marshal(respJSON)
  17326. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17327. utils.ErrorLog("解析失败:%v", err)
  17328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17329. return
  17330. }
  17331. resThree.ErrMsg = resThree10265.ErrMsg
  17332. resThree.Output = resThree10265.Output
  17333. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17334. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17335. }
  17336. } else if res3101.Infcode != "0" {
  17337. c.ServeSuccessJSON(map[string]interface{}{
  17338. "failed_code": -10,
  17339. "msg": res3101.ErrMsg,
  17340. })
  17341. return
  17342. }
  17343. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17344. psn_info, _ := service.GetPsnByPatientId(id)
  17345. var cert_no string
  17346. if id_card_type == 1 {
  17347. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17348. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17349. } else if id_card_type == 4 {
  17350. cert_no = psn_info.VerifyNumber
  17351. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17352. } else {
  17353. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17354. cert_no = psn_info.VerifyNumber
  17355. }
  17356. 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)
  17357. saveLog(result, requestLog, "2201", "挂号")
  17358. if miConfig.Code == "H15049901371" {
  17359. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17360. utils.ErrorLog("解析失败:%v", err)
  17361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17362. return
  17363. }
  17364. resThree.ErrMsg = resThree10265.ErrMsg
  17365. resThree.Output = resThree10265.Output
  17366. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17367. } else {
  17368. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17369. utils.ErrorLog("解析失败:%v", err)
  17370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17371. return
  17372. }
  17373. }
  17374. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17375. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17376. psn_info, _ := service.GetPsnByPatientId(id)
  17377. var result string
  17378. var requestLog string
  17379. if id_card_type == 1 {
  17380. bas := strings.Split(psn_info.CardInfo, "|")
  17381. basNumber := bas[2]
  17382. card_sn := bas[3]
  17383. 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)
  17384. saveLog(result, requestLog, "2201A", "挂号")
  17385. } else if id_card_type == 2 {
  17386. 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, "", "", "", "", "", "")
  17387. saveLog(result, requestLog, "2201A", "挂号")
  17388. } else {
  17389. 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, psn_info.VerifyNumber, "", "", "01", IdCardNo, "15", psn_info.PsnName)
  17390. saveLog(result, requestLog, "2201A", "挂号")
  17391. }
  17392. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17393. utils.ErrorLog("解析失败:%v", err)
  17394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17395. return
  17396. }
  17397. infocode = resThree.Infcode
  17398. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17399. psn_info, _ := service.GetPsnByPatientId(id)
  17400. his.PsnNo = psn_info.PsnNo
  17401. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17402. var cert_no string
  17403. if id_card_type == 1 {
  17404. bas := strings.Split(psn_info.CardInfo, "|")
  17405. cert_no = bas[2]
  17406. } else if id_card_type == 4 {
  17407. cert_no = IdCardNo
  17408. psn_info.VerifyNumber = psn_info.VerifyNumber
  17409. } else {
  17410. cert_no = IdCardNo
  17411. psn_info.VerifyNumber = cert_no
  17412. }
  17413. for _, item := range rf {
  17414. if item.Insutype == insutype {
  17415. his.InsuplcAdmdvs = insuplc_admdvs
  17416. }
  17417. }
  17418. his.Insutype = insutype
  17419. var api string
  17420. ipt_otp_no = timeFormat
  17421. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17422. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17423. "&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
  17424. resp, requestErr := http.Get(api)
  17425. if requestErr != nil {
  17426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17427. return
  17428. }
  17429. body, ioErr := ioutil.ReadAll(resp.Body)
  17430. if ioErr != nil {
  17431. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17433. return
  17434. }
  17435. var respJSON map[string]interface{}
  17436. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17439. return
  17440. }
  17441. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17442. if status == "0" {
  17443. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17444. c.ServeSuccessJSON(map[string]interface{}{
  17445. "failed_code": -10,
  17446. "msg": err_msg,
  17447. })
  17448. return
  17449. }
  17450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17451. result, _ := json.Marshal(respJSON)
  17452. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17453. utils.ErrorLog("解析失败:%v", err)
  17454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17455. return
  17456. }
  17457. infocode = resThree.Infcode
  17458. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17459. psn_info, _ := service.GetPsnByPatientId(id)
  17460. var result string
  17461. var requestLog string
  17462. if id_card_type == 1 {
  17463. bas := strings.Split(psn_info.CardInfo, "|")
  17464. basNumber := bas[2]
  17465. card_sn := bas[3]
  17466. 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)
  17467. saveLog(result, requestLog, "2201A", "挂号")
  17468. } else if id_card_type == 2 {
  17469. 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, "", "")
  17470. saveLog(result, requestLog, "2201A", "挂号")
  17471. } else {
  17472. 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, "", "")
  17473. saveLog(result, requestLog, "2201A", "挂号")
  17474. }
  17475. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17476. utils.ErrorLog("解析失败:%v", err)
  17477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17478. return
  17479. }
  17480. infocode = resThree.Infcode
  17481. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17482. psn_info, _ := service.GetPsnByPatientId(id)
  17483. 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)
  17484. saveLog(result, requestLog, "2201A", "挂号")
  17485. if miConfig.Code == "H15049901371" {
  17486. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17487. utils.ErrorLog("解析失败:%v", err)
  17488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17489. return
  17490. }
  17491. resThree.ErrMsg = resThree10265.ErrMsg
  17492. resThree.Output = resThree10265.Output
  17493. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17494. } else {
  17495. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17496. utils.ErrorLog("解析失败:%v", err)
  17497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17498. return
  17499. }
  17500. }
  17501. if miConfig.Code == "H15049901371" {
  17502. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17503. } else {
  17504. infocode = resThree.Infcode
  17505. }
  17506. } else {
  17507. psn_info, _ := service.GetPsnByPatientId(id)
  17508. if id_card_type == 4 || id_card_type == 1 {
  17509. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17510. }
  17511. var rf []*ResultFive
  17512. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17513. var insutypes []*ResultFive
  17514. var insutype string
  17515. var is390 int = 0
  17516. var is310 int = 0
  17517. for _, item := range rf {
  17518. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17519. insutypes = append(insutypes, item)
  17520. }
  17521. }
  17522. if len(insutypes) == 1 {
  17523. insutype = insutypes[0].Insutype
  17524. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17525. } else {
  17526. for _, i := range insutypes {
  17527. if i.Insutype == "390" {
  17528. is390 = 1
  17529. }
  17530. if i.Insutype == "310" {
  17531. is310 = 1
  17532. }
  17533. }
  17534. }
  17535. if is390 == 1 {
  17536. insutype = "390"
  17537. }
  17538. if is310 == 1 {
  17539. insutype = "310"
  17540. }
  17541. fmt.Println(len(insutypes))
  17542. if len(insutypes) == 0 {
  17543. for index, item := range rf {
  17544. if index == 0 {
  17545. insutype = item.Insutype
  17546. insuplc_admdvs = item.InsuplcAdmdvs
  17547. }
  17548. }
  17549. fmt.Println(insutype)
  17550. fmt.Println(insuplc_admdvs)
  17551. }
  17552. if social_type > 0 {
  17553. insutype = strconv.FormatInt(social_type, 10)
  17554. }
  17555. fmt.Println("--------")
  17556. fmt.Println(psn_info)
  17557. fmt.Println(psn_info.PsnNo)
  17558. if miConfig.MdtrtareaAdmvs == "441202" {
  17559. var hisPrescription []*models.HisPrescription
  17560. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17561. if res3101.Infcode == 0 {
  17562. fmt.Println("33333333")
  17563. if len(res3101.Output.Result) > 0 {
  17564. fmt.Println("222222")
  17565. for _, item := range res3101.Output.Result {
  17566. if len(res3101.ErrMsg) == 0 {
  17567. res3101.ErrMsg = item.VolaCont
  17568. } else {
  17569. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17570. }
  17571. }
  17572. c.ServeSuccessJSON(map[string]interface{}{
  17573. "failed_code": -10,
  17574. "msg": res3101.ErrMsg,
  17575. })
  17576. return
  17577. } else {
  17578. hour := time.Now().Format("15")
  17579. min := time.Now().Format("04")
  17580. sec := time.Now().Format("05")
  17581. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17582. fmt.Println(record_time_two)
  17583. 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)
  17584. saveLog(result, requestLog, "2201A", "挂号")
  17585. if miConfig.Code == "H15049901371" {
  17586. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17587. utils.ErrorLog("解析失败:%v", err)
  17588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17589. return
  17590. }
  17591. resThree.ErrMsg = resThree10265.ErrMsg
  17592. resThree.Output = resThree10265.Output
  17593. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17594. } else {
  17595. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17596. utils.ErrorLog("解析失败:%v", err)
  17597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17598. return
  17599. }
  17600. }
  17601. if miConfig.Code == "H15049901371" {
  17602. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17603. } else {
  17604. infocode = resThree.Infcode
  17605. }
  17606. }
  17607. } else if res3101.Infcode != 0 {
  17608. c.ServeSuccessJSON(map[string]interface{}{
  17609. "failed_code": -10,
  17610. "msg": res3101.ErrMsg,
  17611. })
  17612. return
  17613. }
  17614. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17615. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17616. psn_info, _ := service.GetPsnByPatientId(id)
  17617. var verify_number string
  17618. if id_card_type == 4 {
  17619. verify_number = psn_info.VerifyNumber
  17620. } else if id_card_type == 1 {
  17621. bas := strings.Split(psn_info.CardInfo, "|")
  17622. cardNumber := bas[2]
  17623. verify_number = cardNumber
  17624. } else {
  17625. verify_number = psn_info.Certno
  17626. }
  17627. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17628. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17629. "&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
  17630. resp, requestErr := http.Get(api)
  17631. if requestErr != nil {
  17632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17633. return
  17634. }
  17635. body, ioErr := ioutil.ReadAll(resp.Body)
  17636. if ioErr != nil {
  17637. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17639. return
  17640. }
  17641. var respJSON map[string]interface{}
  17642. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17643. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17645. return
  17646. }
  17647. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17648. result, _ := json.Marshal(respJSON)
  17649. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17650. utils.ErrorLog("解析失败:%v", err)
  17651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17652. return
  17653. }
  17654. infocode = resThree.Infcode
  17655. } else {
  17656. hour := time.Now().Format("15")
  17657. min := time.Now().Format("04")
  17658. sec := time.Now().Format("05")
  17659. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17660. if id_card_type == 1 {
  17661. for _, item := range rf {
  17662. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17663. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17664. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17665. } else if strconv.FormatInt(social_type, 10) == "390" {
  17666. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17667. } else {
  17668. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17669. }
  17670. }
  17671. }
  17672. }
  17673. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17674. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17675. }
  17676. if id_card_type == 1 {
  17677. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17678. bas := strings.Split(psn_info.CardInfo, "|")
  17679. basNumber := bas[1]
  17680. IdCardNo = basNumber
  17681. }
  17682. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17683. IdCardNo = psn_info.VerifyNumber
  17684. }
  17685. 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)
  17686. saveLog(result, requestLog, "2201A", "挂号")
  17687. if miConfig.Code == "H15049901371" {
  17688. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17689. utils.ErrorLog("解析失败:%v", err)
  17690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17691. return
  17692. }
  17693. resThree.ErrMsg = resThree10265.ErrMsg
  17694. resThree.Output = resThree10265.Output
  17695. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17696. } else {
  17697. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17698. utils.ErrorLog("解析失败:%v", err)
  17699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17700. return
  17701. }
  17702. }
  17703. if miConfig.Code == "H15049901371" {
  17704. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17705. } else {
  17706. infocode = resThree.Infcode
  17707. }
  17708. }
  17709. }
  17710. if infocode != 0 {
  17711. adminUser := c.GetAdminUserInfo()
  17712. errlog := &models.HisOrderError{
  17713. UserOrgId: adminUser.CurrentOrgId,
  17714. Ctime: time.Now().Unix(),
  17715. Mtime: time.Now().Unix(),
  17716. ErrMsg: resThree.ErrMsg,
  17717. Status: 1,
  17718. PatientId: id,
  17719. RecordTime: recordDateTime,
  17720. Stage: 2,
  17721. }
  17722. service.CreateErrMsgLog(errlog)
  17723. c.ServeSuccessJSON(map[string]interface{}{
  17724. "failed_code": -10,
  17725. "msg": resThree.ErrMsg,
  17726. })
  17727. return
  17728. }
  17729. his.Number = resThree.Output.Data.MdtrtID
  17730. his.PsnNo = resThree.Output.Data.PsnNo
  17731. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17732. his.IdCardNo = patient.IdCardNo
  17733. his.PhoneNumber = patient.Phone
  17734. his.UserOrgId = adminInfo.CurrentOrgId
  17735. his.Insutype = insutype
  17736. his.Ctime = time.Now().Unix()
  17737. his.Mtime = time.Now().Unix()
  17738. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17739. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17740. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17741. }
  17742. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17743. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17744. }
  17745. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17746. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17747. }
  17748. his.Status = 1
  17749. his.MdtrtGrpType = mdtrt_type
  17750. service.UpdateHisPatientStatus(&his)
  17751. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17752. c.ServeSuccessJSON(map[string]interface{}{
  17753. "his_info": his,
  17754. })
  17755. } else {
  17756. adminUser := c.GetAdminUserInfo()
  17757. errlog := &models.HisOrderError{
  17758. UserOrgId: adminUser.CurrentOrgId,
  17759. Ctime: time.Now().Unix(),
  17760. Mtime: time.Now().Unix(),
  17761. ErrMsg: res.ErrMsg,
  17762. Status: 1,
  17763. PatientId: id,
  17764. RecordTime: recordDateTime,
  17765. Stage: 1,
  17766. }
  17767. service.CreateErrMsgLog(errlog)
  17768. c.ServeSuccessJSON(map[string]interface{}{
  17769. "failed_code": -10,
  17770. "msg": res.ErrMsg,
  17771. })
  17772. return
  17773. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17774. }
  17775. }
  17776. }
  17777. func (c *HisApiController) GetUploadInfo() {
  17778. id, _ := c.GetInt64("id")
  17779. record_time := c.GetString("record_time")
  17780. his_patient_id, _ := c.GetInt64("his_patient_id")
  17781. order_id, _ := c.GetInt64("order_id")
  17782. pay_way, _ := c.GetInt64("pay_way")
  17783. pay_ways := c.GetString("pay_ways")
  17784. oth_desc := c.GetString("oth_desc")
  17785. pay_price, _ := c.GetFloat("pay_price")
  17786. pay_card_no := c.GetString("pay_card_no")
  17787. discount_price, _ := c.GetFloat("discount_price")
  17788. preferential_price, _ := c.GetFloat("preferential_price")
  17789. reality_price, _ := c.GetFloat("reality_price")
  17790. found_price, _ := c.GetFloat("found_price")
  17791. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17792. private_price, _ := c.GetFloat("private_price")
  17793. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17794. admin_user_id, _ := c.GetInt64("admin_user_id")
  17795. fapiao_code := c.GetString("fapiao_code")
  17796. fapiao_number := c.GetString("fapiao_number")
  17797. diagnosis_id := c.GetString("diagnosis")
  17798. sick_type, _ := c.GetInt64("sick_type")
  17799. reg_type, _ := c.GetInt64("p_type")
  17800. begin_time := c.GetString("begin_time")
  17801. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17802. cash_pay := c.GetString("cash_pay")
  17803. band_card_pay := c.GetString("band_card_pay")
  17804. wechat_pay := c.GetString("wechat_pay")
  17805. ali_pay := c.GetString("ali_pay")
  17806. jifen_pay := c.GetString("jifen_pay")
  17807. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17808. fmt.Println(acct_used_flag)
  17809. id_str := c.GetString("ids")
  17810. ids_arr := strings.Split(id_str, ",")
  17811. timeLayout := "2006-01-02"
  17812. loc, _ := time.LoadLocation("Local")
  17813. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17814. if err != nil {
  17815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17816. return
  17817. }
  17818. recordDateTime := theTime.Unix()
  17819. adminUser := c.GetAdminUserInfo()
  17820. var tempOrder models.HisOrder
  17821. tempOrder, _ = service.GetHisOrderByID(order_id)
  17822. var prescriptions []*models.HisPrescription
  17823. var start_time int64
  17824. var end_time int64
  17825. //押金模块
  17826. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17827. tmp_decimal := c.GetString("tmp_decimal")
  17828. var decimal float64 //本次使用的押金
  17829. var errmsg error
  17830. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17831. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17832. return
  17833. }
  17834. if len(tmp_decimal) > 0 {
  17835. if tmp_decimal[0] == 45 {
  17836. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17837. return
  17838. }
  17839. }
  17840. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17841. fmt.Println(errs)
  17842. decimal = tt
  17843. //if adminUser.CurrentOrgId == 10106{
  17844. // if len(fapiao_code) == 0{
  17845. // fapiao_code = "144072080589"
  17846. // }
  17847. // if len(fapiao_number) == 0{
  17848. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17849. // if order.ID == 0{
  17850. // fapiao_number = "00001520"
  17851. // }else{
  17852. // //fapiao_code = "00001520"
  17853. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17854. // var zero string
  17855. // if fpNumber >= 1000{
  17856. // zero = "0000" + strconv.Itoa(fpNumber)
  17857. // }else if fpNumber >= 10000{
  17858. // zero = "000" + strconv.Itoa(fpNumber)
  17859. // } else if fpNumber >= 100000{
  17860. // zero = "00" + strconv.Itoa(fpNumber)
  17861. // } else if fpNumber >= 1000000{
  17862. // zero = "0" + strconv.Itoa(fpNumber)
  17863. // }else {
  17864. // zero = strconv.Itoa(fpNumber)
  17865. // }
  17866. // fapiao_number = zero
  17867. // }
  17868. // }
  17869. //}
  17870. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17871. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17872. var patientPrescription models.HisPrescriptionInfo
  17873. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17874. if patientPrescription.ID == 0 {
  17875. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17876. }
  17877. //if patientPrescription.Do
  17878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17879. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17880. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17881. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17882. var config []*models.HisXtDiagnoseConfig
  17883. for _, item := range diagnosis_ids {
  17884. id, _ := strconv.ParseInt(item, 10, 64)
  17885. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17886. config = append(config, &diagnosisConfig)
  17887. }
  17888. sickConfig, _ := service.FindSickById(sick_type)
  17889. //if tempOrder.ID == 0 {
  17890. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17891. //}
  17892. if tempOrder.ID == 0 {
  17893. var result string
  17894. var requestLog string
  17895. var res2 ResultSix
  17896. var res3 GZResultSix
  17897. var ressix10265 ResultSix10265
  17898. if miConfig.MdtrtareaAdmvs == "421300" {
  17899. data := make(map[string]interface{})
  17900. client := &http.Client{}
  17901. data["psn_no"] = his.PsnNo
  17902. data["mdtrt_id"] = his.Number
  17903. data["opter"] = roles.UserName
  17904. data["org_name"] = miConfig.OrgName
  17905. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17906. data["doctor_id"] = doctor_info.DoctorNumber
  17907. data["doctor_name"] = doctor_info.UserName
  17908. data["department"] = department.Name
  17909. data["fixmedins_code"] = miConfig.Code
  17910. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17911. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17912. data["secret_key"] = miConfig.SecretKey
  17913. data["sick_code"] = sickConfig.CountryCode
  17914. data["sick_name"] = sickConfig.ClassName
  17915. data["dept"] = strconv.FormatInt(department.ID, 10)
  17916. data["config"] = config
  17917. data["begin_time"] = begin_time
  17918. bytesData, _ := json.Marshal(data)
  17919. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17920. resp, _ := client.Do(req)
  17921. defer resp.Body.Close()
  17922. body, ioErr := ioutil.ReadAll(resp.Body)
  17923. if ioErr != nil {
  17924. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17926. return
  17927. }
  17928. var respJSON map[string]interface{}
  17929. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17930. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17932. return
  17933. }
  17934. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17935. userJSONBytes, _ := json.Marshal(respJSON)
  17936. fmt.Println("log")
  17937. fmt.Println(string(userJSONBytes))
  17938. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17939. utils.ErrorLog("解析失败:%v", err)
  17940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17941. return
  17942. }
  17943. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17944. data := make(map[string]interface{})
  17945. client := &http.Client{}
  17946. data["psn_no"] = his.PsnNo
  17947. data["mdtrt_id"] = his.Number
  17948. data["opter"] = roles.UserName
  17949. data["org_name"] = miConfig.OrgName
  17950. if reg_type == 11 && his.Insutype == "390" {
  17951. data["med_type"] = "110104"
  17952. } else {
  17953. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17954. }
  17955. data["doctor_id"] = doctor_info.DoctorNumber
  17956. data["doctor_name"] = doctor_info.UserName
  17957. data["department"] = department.Name
  17958. data["fixmedins_code"] = miConfig.Code
  17959. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17960. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17961. data["secret_key"] = miConfig.SecretKey
  17962. data["sick_code"] = sickConfig.CountryCode
  17963. data["sick_name"] = sickConfig.ClassName
  17964. data["dept"] = strconv.FormatInt(department.ID, 10)
  17965. data["config"] = config
  17966. data["begin_time"] = begin_time
  17967. bytesData, _ := json.Marshal(data)
  17968. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17969. resp, _ := client.Do(req)
  17970. defer resp.Body.Close()
  17971. body, ioErr := ioutil.ReadAll(resp.Body)
  17972. if ioErr != nil {
  17973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17975. return
  17976. }
  17977. var respJSON map[string]interface{}
  17978. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17981. return
  17982. }
  17983. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17984. userJSONBytes, _ := json.Marshal(respJSON)
  17985. fmt.Println("log")
  17986. fmt.Println(string(userJSONBytes))
  17987. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17988. utils.ErrorLog("解析失败:%v", err)
  17989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17990. return
  17991. }
  17992. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17993. data := make(map[string]interface{})
  17994. client := &http.Client{}
  17995. data["psn_no"] = his.PsnNo
  17996. data["mdtrt_id"] = his.Number
  17997. data["opter"] = roles.UserName
  17998. data["org_name"] = miConfig.OrgName
  17999. if reg_type == 11 && his.Insutype == "390" {
  18000. data["med_type"] = "110104"
  18001. } else {
  18002. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18003. }
  18004. data["doctor_id"] = doctor_info.DoctorNumber
  18005. data["doctor_name"] = doctor_info.UserName
  18006. data["department"] = department.Name
  18007. data["fixmedins_code"] = miConfig.Code
  18008. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18009. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18010. data["secret_key"] = miConfig.SecretKey
  18011. data["sick_code"] = sickConfig.CountryCode
  18012. data["sick_name"] = sickConfig.ClassName
  18013. data["dept"] = strconv.FormatInt(department.ID, 10)
  18014. data["config"] = config
  18015. data["begin_time"] = begin_time
  18016. bytesData, _ := json.Marshal(data)
  18017. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18018. resp, _ := client.Do(req)
  18019. defer resp.Body.Close()
  18020. body, ioErr := ioutil.ReadAll(resp.Body)
  18021. if ioErr != nil {
  18022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18024. return
  18025. }
  18026. var respJSON map[string]interface{}
  18027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18030. return
  18031. }
  18032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18033. userJSONBytes, _ := json.Marshal(respJSON)
  18034. fmt.Println("log")
  18035. fmt.Println(string(userJSONBytes))
  18036. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18037. utils.ErrorLog("解析失败:%v", err)
  18038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18039. return
  18040. }
  18041. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18042. data := make(map[string]interface{})
  18043. client := &http.Client{}
  18044. data["psn_no"] = his.PsnNo
  18045. data["mdtrt_id"] = his.Number
  18046. data["doctor"] = roles.UserName
  18047. data["department"] = department.Name
  18048. data["org_name"] = miConfig.OrgName
  18049. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18050. data["doctor_id"] = doctor_info.DoctorNumber
  18051. data["new_doctor_name"] = doctor_info.UserName
  18052. data["fixmedins_code"] = miConfig.Code
  18053. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18055. data["secret_key"] = miConfig.SecretKey
  18056. data["sick_code"] = sickConfig.CountryCode
  18057. data["sick_name"] = sickConfig.ClassName
  18058. data["url"] = miConfig.Url
  18059. data["ak"] = miConfig.AccessKey
  18060. data["begin_time"] = begin_time
  18061. data["cainfo"] = miConfig.Cainfo
  18062. data["dept"] = strconv.FormatInt(department.ID, 10)
  18063. data["config"] = config
  18064. bytesData, _ := json.Marshal(data)
  18065. var req *http.Request
  18066. if miConfig.MdtrtareaAdmvs == "320921" {
  18067. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18068. //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 +
  18069. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18070. } else {
  18071. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18072. }
  18073. resp, _ := client.Do(req)
  18074. defer resp.Body.Close()
  18075. body, ioErr := ioutil.ReadAll(resp.Body)
  18076. if ioErr != nil {
  18077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18079. return
  18080. }
  18081. var respJSON map[string]interface{}
  18082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18085. return
  18086. }
  18087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18088. userJSONBytes, _ := json.Marshal(respJSON)
  18089. fmt.Println("log")
  18090. fmt.Println(string(userJSONBytes))
  18091. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18092. utils.ErrorLog("解析失败:%v", err)
  18093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18094. return
  18095. }
  18096. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18097. res2.Output = ressix10265.Output
  18098. res2.ErrMsg = ressix10265.ErrMsg
  18099. res2.Cainfo = ressix10265.Cainfo
  18100. res2.WarnMsg = ressix10265.WarnMsg
  18101. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18102. res2.Infcode = infocode
  18103. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18104. data := make(map[string]interface{})
  18105. client := &http.Client{}
  18106. data["psn_no"] = his.PsnNo
  18107. data["mdtrt_id"] = his.Number
  18108. data["doctor"] = roles.UserName
  18109. data["department"] = department.Name
  18110. data["org_name"] = miConfig.OrgName
  18111. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18112. data["doctor_id"] = doctor_info.DoctorNumber
  18113. data["new_doctor_name"] = doctor_info.UserName
  18114. data["fixmedins_code"] = miConfig.Code
  18115. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18116. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18117. data["secret_key"] = miConfig.SecretKey
  18118. data["sick_code"] = sickConfig.CountryCode
  18119. data["sick_name"] = sickConfig.ClassName
  18120. data["url"] = miConfig.Url
  18121. data["ak"] = miConfig.AccessKey
  18122. data["begin_time"] = begin_time
  18123. data["cainfo"] = miConfig.Cainfo
  18124. data["dept"] = strconv.FormatInt(department.ID, 10)
  18125. data["config"] = config
  18126. bytesData, _ := json.Marshal(data)
  18127. var req *http.Request
  18128. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18129. resp, _ := client.Do(req)
  18130. defer resp.Body.Close()
  18131. body, ioErr := ioutil.ReadAll(resp.Body)
  18132. if ioErr != nil {
  18133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18135. return
  18136. }
  18137. var respJSON map[string]interface{}
  18138. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18141. return
  18142. }
  18143. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18144. userJSONBytes, _ := json.Marshal(respJSON)
  18145. fmt.Println("log")
  18146. fmt.Println(string(userJSONBytes))
  18147. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18148. utils.ErrorLog("解析失败:%v", err)
  18149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18150. return
  18151. }
  18152. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18153. res2.Output = ressix10265.Output
  18154. res2.ErrMsg = ressix10265.ErrMsg
  18155. res2.Cainfo = ressix10265.Cainfo
  18156. res2.WarnMsg = ressix10265.WarnMsg
  18157. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18158. res2.Infcode = infocode
  18159. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18160. 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)
  18161. saveLog(result, requestLog, "2203", "上传就诊信息")
  18162. var respJSON2 map[string]interface{}
  18163. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18166. return
  18167. }
  18168. userJSONBytes2, _ := json.Marshal(respJSON2)
  18169. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18170. utils.ErrorLog("解析失败:%v", err)
  18171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18172. return
  18173. }
  18174. 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)
  18175. fmt.Println(result2)
  18176. fmt.Println(src_request)
  18177. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18178. data := make(map[string]interface{})
  18179. client := &http.Client{}
  18180. data["psn_no"] = his.PsnNo
  18181. data["mdtrt_id"] = his.Number
  18182. data["doctor"] = roles.UserName
  18183. data["department"] = department.Name
  18184. data["org_name"] = miConfig.OrgName
  18185. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18186. data["doctor_id"] = doctor_info.DoctorNumber
  18187. data["new_doctor_name"] = doctor_info.UserName
  18188. data["fixmedins_code"] = miConfig.Code
  18189. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18190. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18191. data["secret_key"] = miConfig.SecretKey
  18192. data["sick_code"] = sickConfig.CountryCode
  18193. data["sick_name"] = sickConfig.ClassName
  18194. data["url"] = miConfig.Url
  18195. data["ak"] = miConfig.AccessKey
  18196. data["begin_time"] = begin_time
  18197. data["cainfo"] = miConfig.Cainfo
  18198. data["dept"] = strconv.FormatInt(department.ID, 10)
  18199. data["config"] = config
  18200. bytesData, _ := json.Marshal(data)
  18201. var req *http.Request
  18202. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18203. resp, _ := client.Do(req)
  18204. defer resp.Body.Close()
  18205. body, ioErr := ioutil.ReadAll(resp.Body)
  18206. if ioErr != nil {
  18207. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18209. return
  18210. }
  18211. var respJSON map[string]interface{}
  18212. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18213. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18215. return
  18216. }
  18217. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18218. userJSONBytes, _ := json.Marshal(respJSON)
  18219. fmt.Println("log")
  18220. fmt.Println(string(userJSONBytes))
  18221. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18222. utils.ErrorLog("解析失败:%v", err)
  18223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18224. return
  18225. }
  18226. } else {
  18227. if miConfig.MdtrtareaAdmvs == "440781" { //
  18228. 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)
  18229. } else {
  18230. if miConfig.Code == "H15049901371" {
  18231. //赤峰地区国家医保医疗类别
  18232. //职工透析:医疗类别选特殊情况门诊990502
  18233. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18234. var med_type string
  18235. if his.Insutype == "390" {
  18236. if reg_type == 14 {
  18237. med_type = "9933"
  18238. } else if reg_type == 11 {
  18239. med_type = "11"
  18240. }
  18241. } else if his.Insutype == "310" {
  18242. if reg_type == 14 {
  18243. med_type = "990502"
  18244. } else if reg_type == 11 {
  18245. med_type = "11"
  18246. }
  18247. }
  18248. 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)
  18249. } else {
  18250. 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)
  18251. }
  18252. }
  18253. saveLog(result, requestLog, "2203", "上传就诊信息")
  18254. var respJSON2 map[string]interface{}
  18255. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18258. return
  18259. }
  18260. userJSONBytes2, _ := json.Marshal(respJSON2)
  18261. if miConfig.Code == "H15049901371" {
  18262. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18263. utils.ErrorLog("解析失败:%v", err)
  18264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18265. return
  18266. }
  18267. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18268. res2.Output = ressix10265.Output
  18269. res2.ErrMsg = ressix10265.ErrMsg
  18270. res2.Cainfo = ressix10265.Cainfo
  18271. res2.WarnMsg = ressix10265.WarnMsg
  18272. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18273. res2.Infcode = infocode
  18274. } else {
  18275. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18276. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18277. utils.ErrorLog("解析失败:%v", err)
  18278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18279. return
  18280. }
  18281. res2.Infcode = res3.Infcode
  18282. } else {
  18283. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18284. utils.ErrorLog("解析失败:%v", err)
  18285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18286. return
  18287. }
  18288. }
  18289. }
  18290. }
  18291. if res2.Infcode != 0 {
  18292. adminUser := c.GetAdminUserInfo()
  18293. errlog := &models.HisOrderError{
  18294. UserOrgId: adminUser.CurrentOrgId,
  18295. Ctime: time.Now().Unix(),
  18296. Mtime: time.Now().Unix(),
  18297. ErrMsg: res2.ErrMsg,
  18298. Status: 1,
  18299. PatientId: id,
  18300. RecordTime: recordDateTime,
  18301. Stage: 3,
  18302. }
  18303. service.CreateErrMsgLog(errlog)
  18304. c.ServeSuccessJSON(map[string]interface{}{
  18305. "failed_code": -10,
  18306. "msg": res2.ErrMsg,
  18307. })
  18308. return
  18309. } else {
  18310. his.Diagnosis = diagnosis_id
  18311. his.SickType = sickConfig.ID
  18312. //var p_type int64
  18313. //if reg_type == 1111 || reg_type == 1112 {
  18314. // p_type = 11
  18315. //
  18316. //}
  18317. his.PType = fmt.Sprintf("%d", reg_type)
  18318. service.UpdateHisPatientThree(&his)
  18319. data := make(map[string]interface{})
  18320. if settle_accounts_type == 1 { //日结
  18321. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18322. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18323. } else {
  18324. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18325. }
  18326. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18327. data["pre"] = prescriptions
  18328. } else { //月结
  18329. start_time_str := c.GetString("start_time")
  18330. end_time_str := c.GetString("end_time")
  18331. timeLayout := "2006-01-02"
  18332. loc, _ := time.LoadLocation("Local")
  18333. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18334. if err != nil {
  18335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18336. return
  18337. }
  18338. recordStartTime := theStartTime.Unix()
  18339. start_time = recordStartTime
  18340. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18341. if err != nil {
  18342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18343. return
  18344. }
  18345. recordEndTime := theEndTime.Unix()
  18346. end_time = recordEndTime
  18347. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18348. data["pre"] = prescriptions
  18349. }
  18350. timestamp := time.Now().Unix()
  18351. tempTime := time.Unix(timestamp, 0)
  18352. timeFormat := tempTime.Format("20060102150405")
  18353. chrgBchno := rand.Intn(100000) + 10000
  18354. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18355. strconv.FormatInt(his.PatientId, 10)
  18356. client := &http.Client{}
  18357. data["psn_no"] = his.PsnNo
  18358. data["mdtrt_id"] = his.Number
  18359. data["chrg_bchno"] = chrg_bchno
  18360. data["org_name"] = miConfig.OrgName
  18361. data["doctor"] = doctor_info.UserName
  18362. data["doctor_id"] = doctor_info.DoctorNumber
  18363. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18364. data["fixmedins_code"] = miConfig.Code
  18365. data["dept_code"] = department.Number
  18366. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18367. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18368. data["secret_key"] = miConfig.SecretKey
  18369. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18370. data["url"] = miConfig.Url
  18371. data["ak"] = miConfig.AccessKey
  18372. data["new_doctor_name"] = patientPrescription.Doctor
  18373. data["diag_code"] = sickConfig.CountryCode
  18374. data["cainfo"] = miConfig.Cainfo
  18375. data["opter"] = roles.UserName
  18376. var ids []int64
  18377. for _, item := range prescriptions {
  18378. ids = append(ids, item.ID)
  18379. }
  18380. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18381. if config.IsOpen == 1 { //对接了医保,走医保流程
  18382. var res ResultFour
  18383. var resFour10265 ResultFour10265
  18384. if miConfig.MdtrtareaAdmvs == "421300" {
  18385. bytesData, _ := json.Marshal(data)
  18386. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18387. resp, _ := client.Do(req)
  18388. defer resp.Body.Close()
  18389. body, ioErr := ioutil.ReadAll(resp.Body)
  18390. if ioErr != nil {
  18391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18393. return
  18394. }
  18395. var respJSON map[string]interface{}
  18396. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18399. return
  18400. }
  18401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18402. userJSONBytes, _ := json.Marshal(respJSON)
  18403. fmt.Println("log")
  18404. fmt.Println(string(userJSONBytes))
  18405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18406. utils.ErrorLog("解析失败:%v", err)
  18407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18408. return
  18409. }
  18410. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18411. bytesData, _ := json.Marshal(data)
  18412. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", 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. fmt.Println("log")
  18430. fmt.Println(string(userJSONBytes))
  18431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18432. utils.ErrorLog("解析失败:%v", err)
  18433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18434. return
  18435. }
  18436. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18437. bytesData, _ := json.Marshal(data)
  18438. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18439. resp, _ := client.Do(req)
  18440. defer resp.Body.Close()
  18441. body, ioErr := ioutil.ReadAll(resp.Body)
  18442. if ioErr != nil {
  18443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18445. return
  18446. }
  18447. var respJSON map[string]interface{}
  18448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18451. return
  18452. }
  18453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18454. userJSONBytes, _ := json.Marshal(respJSON)
  18455. fmt.Println("log")
  18456. fmt.Println(string(userJSONBytes))
  18457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18458. utils.ErrorLog("解析失败:%v", err)
  18459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18460. return
  18461. }
  18462. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18463. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18464. if result3101.Infcode == "0" {
  18465. if len(result3101.Output.Result) > 0 {
  18466. var errMsgs []string
  18467. for _, item := range result3101.Output.Result {
  18468. errMsgs = append(errMsgs, item.VolaCont)
  18469. }
  18470. c.ServeSuccessJSON(map[string]interface{}{
  18471. "failed_code": -10,
  18472. "msg": errMsgs,
  18473. })
  18474. return
  18475. }
  18476. }
  18477. bytesData, _ := json.Marshal(data)
  18478. var req *http.Request
  18479. if miConfig.MdtrtareaAdmvs == "320921" {
  18480. data["diag_code"] = sickConfig.CountryCode
  18481. fmt.Println(data)
  18482. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18483. } else {
  18484. data["diag_code"] = sickConfig.CountryCode
  18485. fmt.Println(data)
  18486. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18487. }
  18488. resp, _ := client.Do(req)
  18489. defer resp.Body.Close()
  18490. body, ioErr := ioutil.ReadAll(resp.Body)
  18491. if ioErr != nil {
  18492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. return
  18495. }
  18496. var respJSON map[string]interface{}
  18497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18500. return
  18501. }
  18502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18503. userJSONBytes, _ := json.Marshal(respJSON)
  18504. fmt.Println("log")
  18505. fmt.Println(string(userJSONBytes))
  18506. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18507. utils.ErrorLog("解析失败:%v", err)
  18508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18509. return
  18510. }
  18511. res.InfRefmsgid = resFour10265.InfRefmsgid
  18512. res.Output = resFour10265.Output
  18513. res.ErrMsg = resFour10265.ErrMsg
  18514. res.Cainfo = resFour10265.Cainfo
  18515. res.WarnMsg = resFour10265.WarnMsg
  18516. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18517. res.Infcode = infocode
  18518. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18519. var pagesize int = 2
  18520. var start int = 1
  18521. var stop int
  18522. var pagecount int
  18523. var curpage int
  18524. var isSuccess bool = true
  18525. data["doctor_id"] = doctor_info.DoctorNumber
  18526. //总页数,向上取整,注意除之前要先转换类型为float64
  18527. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18528. for curpage = 1; curpage <= pagecount; curpage++ {
  18529. if curpage == 1 {
  18530. start = 1
  18531. } else {
  18532. start = (curpage-1)*pagesize + 1
  18533. }
  18534. stop = curpage * pagesize
  18535. if stop > len(prescriptions) {
  18536. stop = len(prescriptions)
  18537. }
  18538. //var requestLog string
  18539. data["pre"] = prescriptions[start-1 : stop]
  18540. fmt.Println(data["pre"])
  18541. bytesData, _ := json.Marshal(data)
  18542. var req *http.Request
  18543. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18544. resp, _ := client.Do(req)
  18545. defer resp.Body.Close()
  18546. body, ioErr := ioutil.ReadAll(resp.Body)
  18547. if ioErr != nil {
  18548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18550. return
  18551. }
  18552. var respJSON map[string]interface{}
  18553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18556. return
  18557. }
  18558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18559. userJSONBytes, _ := json.Marshal(respJSON)
  18560. fmt.Println("log")
  18561. fmt.Println(string(userJSONBytes))
  18562. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18563. utils.ErrorLog("解析失败:%v", err)
  18564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18565. return
  18566. }
  18567. res.InfRefmsgid = resFour10265.InfRefmsgid
  18568. res.Output = resFour10265.Output
  18569. res.ErrMsg = resFour10265.ErrMsg
  18570. res.Cainfo = resFour10265.Cainfo
  18571. res.WarnMsg = resFour10265.WarnMsg
  18572. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18573. res.Infcode = infocode
  18574. if infocode == 0 {
  18575. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  18576. } else {
  18577. isSuccess = false
  18578. errlog := &models.HisOrderError{
  18579. UserOrgId: adminUser.CurrentOrgId,
  18580. Ctime: time.Now().Unix(),
  18581. Mtime: time.Now().Unix(),
  18582. Number: chrg_bchno,
  18583. ErrMsg: "",
  18584. Status: 1,
  18585. PatientId: id,
  18586. RecordTime: recordDateTime,
  18587. Stage: 4,
  18588. }
  18589. service.CreateErrMsgLog(errlog)
  18590. c.ServeSuccessJSON(map[string]interface{}{
  18591. "failed_code": -10,
  18592. "msg": res.ErrMsg,
  18593. })
  18594. return
  18595. }
  18596. }
  18597. if isSuccess {
  18598. res.Infcode = 0
  18599. }
  18600. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18601. 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)
  18602. var dat map[string]interface{}
  18603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18604. fmt.Println(dat)
  18605. } else {
  18606. fmt.Println(err)
  18607. }
  18608. saveLog(result, request_log, "2204", "上传费用明细")
  18609. userJSONBytes, _ := json.Marshal(dat)
  18610. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18611. utils.ErrorLog("解析失败:%v", err)
  18612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18613. return
  18614. }
  18615. res.InfRefmsgid = resFour10265.InfRefmsgid
  18616. res.Output = resFour10265.Output
  18617. res.ErrMsg = resFour10265.ErrMsg
  18618. res.Cainfo = resFour10265.Cainfo
  18619. res.WarnMsg = resFour10265.WarnMsg
  18620. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18621. res.Infcode = infocode
  18622. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18623. bytesData, _ := json.Marshal(data)
  18624. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  18625. resp, _ := client.Do(req)
  18626. defer resp.Body.Close()
  18627. body, ioErr := ioutil.ReadAll(resp.Body)
  18628. if ioErr != nil {
  18629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18631. return
  18632. }
  18633. var respJSON map[string]interface{}
  18634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18637. return
  18638. }
  18639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18640. userJSONBytes, _ := json.Marshal(respJSON)
  18641. fmt.Println("log")
  18642. fmt.Println(string(userJSONBytes))
  18643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18644. utils.ErrorLog("解析失败:%v", err)
  18645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18646. return
  18647. }
  18648. } else {
  18649. if miConfig.Code == "H15049901371" {
  18650. 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)
  18651. var dat map[string]interface{}
  18652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18653. fmt.Println(dat)
  18654. } else {
  18655. fmt.Println(err)
  18656. }
  18657. saveLog(result, request_log, "2204", "上传费用明细")
  18658. userJSONBytes, _ := json.Marshal(dat)
  18659. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18660. utils.ErrorLog("解析失败:%v", err)
  18661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18662. return
  18663. }
  18664. res.InfRefmsgid = resFour10265.InfRefmsgid
  18665. res.Output = resFour10265.Output
  18666. res.ErrMsg = resFour10265.ErrMsg
  18667. res.Cainfo = resFour10265.Cainfo
  18668. res.WarnMsg = resFour10265.WarnMsg
  18669. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18670. res.Infcode = infocode
  18671. } else {
  18672. 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)
  18673. var dat map[string]interface{}
  18674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18675. fmt.Println(dat)
  18676. } else {
  18677. fmt.Println(err)
  18678. }
  18679. saveLog(result, request_log, "2204", "上传费用明细")
  18680. userJSONBytes, _ := json.Marshal(dat)
  18681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18682. utils.ErrorLog("解析失败:%v", err)
  18683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18684. return
  18685. }
  18686. }
  18687. }
  18688. if res.Infcode == 0 {
  18689. order := &models.HisOrder{
  18690. UserOrgId: adminUser.CurrentOrgId,
  18691. HisPatientId: his.ID,
  18692. PatientId: his.PatientId,
  18693. SettleAccountsDate: recordDateTime,
  18694. MdtrtId: his.Number,
  18695. PsnNo: his.PsnNo,
  18696. MedType: strconv.FormatInt(reg_type, 10),
  18697. Ctime: time.Now().Unix(),
  18698. Mtime: time.Now().Unix(),
  18699. Status: 1,
  18700. Number: chrg_bchno,
  18701. Infcode: res.Infcode,
  18702. WarnMsg: res.WarnMsg,
  18703. Cainfo: res.Cainfo,
  18704. ErrMsg: res.ErrMsg,
  18705. RespondTime: res.RefmsgTime,
  18706. InfRefmsgid: res.InfRefmsgid,
  18707. OrderStatus: 1,
  18708. PayWay: pay_way,
  18709. PayWays: pay_ways,
  18710. OthDesc: oth_desc,
  18711. PayPrice: pay_price,
  18712. PayCardNo: pay_card_no,
  18713. DiscountPrice: discount_price,
  18714. PreferentialPrice: preferential_price,
  18715. RealityPrice: reality_price,
  18716. FoundPrice: found_price,
  18717. MedicalInsurancePrice: medical_insurance_price,
  18718. PrivatePrice: private_price,
  18719. IsMedicineInsurance: 1,
  18720. SettleType: settle_accounts_type,
  18721. SettleStartTime: start_time,
  18722. SettleEndTime: end_time,
  18723. Creator: roles.AdminUserId,
  18724. Modify: roles.AdminUserId,
  18725. FaPiaoNumber: fapiao_number,
  18726. FaPiaoCode: fapiao_code,
  18727. PType: 2,
  18728. Diagnosis: diagnosis_id,
  18729. CashPay: cash_pay,
  18730. WechatPay: wechat_pay,
  18731. AliPay: ali_pay,
  18732. JifenPay: jifen_pay,
  18733. BandCardPay: band_card_pay,
  18734. }
  18735. err = service.CreateOrder(order)
  18736. if err != nil {
  18737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18738. return
  18739. }
  18740. for _, item := range res.Output.Result {
  18741. temp := strings.Split(item.FeedetlSn, "-")
  18742. var advice_id int64 = 0
  18743. var project_id int64 = 0
  18744. var types int64 = 0
  18745. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18746. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18747. if temp[1] == "1" {
  18748. advice_id = id
  18749. project_id = 0
  18750. } else if temp[1] == "2" {
  18751. advice_id = 0
  18752. project_id = id
  18753. }
  18754. if item.MedChrgitmType == "9" {
  18755. item.MedChrgitmType = "09"
  18756. }
  18757. info := &models.HisOrderInfo{
  18758. OrderNumber: order.Number,
  18759. FeedetlSn: item.FeedetlSn,
  18760. UploadDate: time.Now().Unix(),
  18761. AdviceId: advice_id,
  18762. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18763. Cnt: item.Cnt,
  18764. Pric: float64(item.Pric),
  18765. PatientId: his.PatientId,
  18766. PricUplmtAmt: item.PricUplmtAmt,
  18767. SelfpayProp: item.SelfpayProp,
  18768. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18769. OverlmtAmt: item.OverlmtAmt,
  18770. PreselfpayAmt: item.PreselfpayAmt,
  18771. BasMednFlag: item.BasMednFlag,
  18772. MedChrgitmType: item.MedChrgitmType,
  18773. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18774. Status: 1,
  18775. Memo: item.Memo,
  18776. Mtime: time.Now().Unix(),
  18777. InscpScpAmt: item.InscpScpAmt,
  18778. DrtReimFlag: item.DrtReimFlag,
  18779. Ctime: time.Now().Unix(),
  18780. ListSpItemFlag: item.ListSpItemFlag,
  18781. ChldMedcFlag: item.ChldMedcFlag,
  18782. LmtUsedFlag: item.LmtUsedFlag,
  18783. ChrgitmLv: item.ChrgitmLv,
  18784. UserOrgId: adminUser.CurrentOrgId,
  18785. HisPatientId: his.ID,
  18786. OrderId: order.ID,
  18787. ProjectId: project_id,
  18788. Type: types,
  18789. }
  18790. service.CreateOrderInfo(info)
  18791. }
  18792. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18793. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18794. var total float64
  18795. for _, item := range prescriptions {
  18796. if item.Type == 1 { //药品
  18797. for _, subItem := range item.HisDoctorAdviceInfo {
  18798. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18799. total_one := price * subItem.PrescribingNumber
  18800. total = total + total_one
  18801. }
  18802. }
  18803. if item.Type == 2 { //项目
  18804. for _, subItem := range item.HisPrescriptionProject {
  18805. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18806. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18807. total_one := price * cnt
  18808. total = total + total_one
  18809. }
  18810. }
  18811. }
  18812. allTotal := fmt.Sprintf("%.2f", total)
  18813. //if adminUser.CurrentOrgId == 9919 {
  18814. //
  18815. // allTotal = fmt.Sprintf("%.2f", total)
  18816. //
  18817. //} else {
  18818. //
  18819. // allTotal = fmt.Sprintf("%.2f", total)
  18820. //
  18821. //}
  18822. if res.Infcode == 0 {
  18823. var rf []*ResultFive
  18824. json.Unmarshal([]byte(his.Iinfo), &rf)
  18825. chrg_bchno := chrg_bchno
  18826. cert_no := his.Certno
  18827. var insutypes []string
  18828. var insutype string
  18829. var is390 int = 0
  18830. var is310 int = 0
  18831. for _, item := range rf {
  18832. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18833. insutypes = append(insutypes, item.Insutype)
  18834. }
  18835. }
  18836. if len(insutypes) == 1 {
  18837. insutype = insutypes[0]
  18838. } else {
  18839. for _, i := range insutypes {
  18840. if i == "390" {
  18841. is390 = 1
  18842. }
  18843. if i == "310" {
  18844. is310 = 1
  18845. }
  18846. }
  18847. }
  18848. if is390 == 1 {
  18849. insutype = "390"
  18850. }
  18851. if is310 == 1 {
  18852. insutype = "310"
  18853. }
  18854. if len(insutypes) == 0 {
  18855. insutype = "310"
  18856. }
  18857. if len(insutypes) == 2 {
  18858. insutype = strconv.FormatInt(his.SocialType, 10)
  18859. }
  18860. insutype = strconv.FormatInt(his.SocialType, 10)
  18861. //insutype = "390"
  18862. if his.IdCardType == 1 {
  18863. // cert_no = his.MedicalInsuranceNumber
  18864. cert_no = his.Certno
  18865. } else {
  18866. cert_no = his.Certno
  18867. }
  18868. var res ResultSeven
  18869. var resSeven10265 ResultSeven10265
  18870. var gzresSeven10265Two GZResultSeven10265Two
  18871. var src_resquest string
  18872. var result2 string
  18873. if miConfig.MdtrtareaAdmvs == "421300" {
  18874. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18875. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18876. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18878. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18879. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18880. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18881. resp, requestErr := http.Get(api)
  18882. if requestErr != nil {
  18883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18884. return
  18885. }
  18886. body, ioErr := ioutil.ReadAll(resp.Body)
  18887. if ioErr != nil {
  18888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18890. return
  18891. }
  18892. var respJSON map[string]interface{}
  18893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18896. return
  18897. }
  18898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18899. result, _ := json.Marshal(respJSON)
  18900. if miConfig.Code == "H15049901371" {
  18901. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18902. utils.ErrorLog("解析失败:%v", err)
  18903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18904. return
  18905. }
  18906. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18907. res.Output = resSeven10265.Output
  18908. res.ErrMsg = resSeven10265.ErrMsg
  18909. res.Cainfo = resSeven10265.Cainfo
  18910. res.WarnMsg = resSeven10265.WarnMsg
  18911. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18912. res.Infcode = infocode
  18913. } else {
  18914. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18915. utils.ErrorLog("解析失败:%v", err)
  18916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18917. return
  18918. }
  18919. }
  18920. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18921. if reg_type == 11 && his.Insutype == "390" {
  18922. reg_type = 110104
  18923. }
  18924. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18925. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18926. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18927. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18928. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18929. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18930. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18931. resp, requestErr := http.Get(api)
  18932. if requestErr != nil {
  18933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18934. return
  18935. }
  18936. body, ioErr := ioutil.ReadAll(resp.Body)
  18937. if ioErr != nil {
  18938. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18940. return
  18941. }
  18942. var respJSON map[string]interface{}
  18943. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18944. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18946. return
  18947. }
  18948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18949. result, _ := json.Marshal(respJSON)
  18950. if miConfig.Code == "H15049901371" {
  18951. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18952. utils.ErrorLog("解析失败:%v", err)
  18953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18954. return
  18955. }
  18956. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18957. res.Output = resSeven10265.Output
  18958. res.ErrMsg = resSeven10265.ErrMsg
  18959. res.Cainfo = resSeven10265.Cainfo
  18960. res.WarnMsg = resSeven10265.WarnMsg
  18961. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18962. res.Infcode = infocode
  18963. } else {
  18964. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18965. utils.ErrorLog("解析失败:%v", err)
  18966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18967. return
  18968. }
  18969. }
  18970. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18971. if reg_type == 11 && his.Insutype == "390" {
  18972. reg_type = 110104
  18973. }
  18974. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18975. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18976. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18978. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18979. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18980. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18981. resp, requestErr := http.Get(api)
  18982. if requestErr != nil {
  18983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18984. return
  18985. }
  18986. body, ioErr := ioutil.ReadAll(resp.Body)
  18987. if ioErr != nil {
  18988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18990. return
  18991. }
  18992. var respJSON map[string]interface{}
  18993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18996. return
  18997. }
  18998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18999. result, _ := json.Marshal(respJSON)
  19000. if miConfig.Code == "H15049901371" {
  19001. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19002. utils.ErrorLog("解析失败:%v", err)
  19003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19004. return
  19005. }
  19006. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19007. res.Output = resSeven10265.Output
  19008. res.ErrMsg = resSeven10265.ErrMsg
  19009. res.Cainfo = resSeven10265.Cainfo
  19010. res.WarnMsg = resSeven10265.WarnMsg
  19011. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19012. res.Infcode = infocode
  19013. } else {
  19014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19015. utils.ErrorLog("解析失败:%v", err)
  19016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19017. return
  19018. }
  19019. }
  19020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19021. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19022. if result3101.Infcode == "0" {
  19023. if len(result3101.Output.Result) > 0 {
  19024. var errMsgs []string
  19025. for _, item := range result3101.Output.Result {
  19026. errMsgs = append(errMsgs, item.VolaCont)
  19027. }
  19028. c.ServeSuccessJSON(map[string]interface{}{
  19029. "failed_code": -10,
  19030. "msg": errMsgs,
  19031. })
  19032. return
  19033. } else {
  19034. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19035. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19036. bas := strings.Split(psn_info.CardInfo, "|")
  19037. if his.IdCardType == 1 {
  19038. cert_no = bas[2]
  19039. } else if his.IdCardType == 3 {
  19040. cert_no = his.Certno
  19041. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19042. } else if his.IdCardType == 4 {
  19043. cert_no = his.Certno
  19044. psn_info.VerifyNumber = psn_info.VerifyNumber
  19045. }
  19046. var api string
  19047. if miConfig.MdtrtareaAdmvs == "320921" {
  19048. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19049. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19050. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19051. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19052. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19053. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19054. "&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
  19055. } else {
  19056. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19057. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19058. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19059. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19060. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19061. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19062. "&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
  19063. }
  19064. resp, requestErr := http.Get(api)
  19065. if requestErr != nil {
  19066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19067. return
  19068. }
  19069. body, ioErr := ioutil.ReadAll(resp.Body)
  19070. if ioErr != nil {
  19071. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19073. return
  19074. }
  19075. var respJSON map[string]interface{}
  19076. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19077. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19079. return
  19080. }
  19081. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19082. result, _ := json.Marshal(respJSON)
  19083. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19084. utils.ErrorLog("解析失败:%v", err)
  19085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19086. return
  19087. }
  19088. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19089. res.Output = resSeven10265.Output
  19090. res.ErrMsg = resSeven10265.ErrMsg
  19091. res.Cainfo = resSeven10265.Cainfo
  19092. res.WarnMsg = resSeven10265.WarnMsg
  19093. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19094. res.Infcode = infocode
  19095. }
  19096. }
  19097. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19098. psn_info, _ := service.GetPsnByPatientId(id)
  19099. var verify_number string
  19100. if psn_info.IdCardType == 4 {
  19101. verify_number = psn_info.VerifyNumber
  19102. } else if psn_info.IdCardType == 1 {
  19103. bas := strings.Split(psn_info.CardInfo, "|")
  19104. cardNumber := bas[2]
  19105. verify_number = cardNumber
  19106. } else {
  19107. psn_info.IdCardType = 2
  19108. verify_number = psn_info.Certno
  19109. }
  19110. var api string
  19111. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19112. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19113. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19115. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19116. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19117. "&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
  19118. resp, requestErr := http.Get(api)
  19119. if requestErr != nil {
  19120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19121. return
  19122. }
  19123. body, ioErr := ioutil.ReadAll(resp.Body)
  19124. if ioErr != nil {
  19125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19127. return
  19128. }
  19129. var respJSON map[string]interface{}
  19130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19133. return
  19134. }
  19135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19136. result, _ := json.Marshal(respJSON)
  19137. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19138. utils.ErrorLog("解析失败:%v", err)
  19139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19140. return
  19141. }
  19142. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19143. res.Output = resSeven10265.Output
  19144. res.ErrMsg = resSeven10265.ErrMsg
  19145. res.Cainfo = resSeven10265.Cainfo
  19146. res.WarnMsg = resSeven10265.WarnMsg
  19147. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19148. res.Infcode = infocode
  19149. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19150. var cert_no string
  19151. if his.IdCardType == 4 {
  19152. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19153. cert_no = psn_info.VerifyNumber
  19154. 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)
  19155. } else if his.IdCardType == 1 {
  19156. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19157. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19158. 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)
  19159. }
  19160. //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)
  19161. var dat map[string]interface{}
  19162. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19163. fmt.Println(dat)
  19164. } else {
  19165. fmt.Println(err)
  19166. }
  19167. saveLog(result2, src_resquest, "2207", "结算")
  19168. userJSONBytes, _ := json.Marshal(dat)
  19169. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19170. utils.ErrorLog("解析失败:%v", err)
  19171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19172. return
  19173. }
  19174. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19175. res.Output = resSeven10265.Output
  19176. res.ErrMsg = resSeven10265.ErrMsg
  19177. res.Cainfo = resSeven10265.Cainfo
  19178. res.WarnMsg = resSeven10265.WarnMsg
  19179. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19180. res.Infcode = infocode
  19181. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19182. res2 := c.GetoleInfo()
  19183. if res2.Infcode == 0 {
  19184. var result string
  19185. var request_log string
  19186. var result_log string
  19187. if res2.Output.MdtrtCertType == "02" {
  19188. 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)
  19189. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19190. } else if res2.Output.MdtrtCertType == "01" {
  19191. 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)
  19192. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19193. } else {
  19194. 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)
  19195. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19196. }
  19197. var dat map[string]interface{}
  19198. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19199. fmt.Println(dat)
  19200. } else {
  19201. fmt.Println(err)
  19202. }
  19203. userJSONBytes, _ := json.Marshal(dat)
  19204. var res5 ResultTwo
  19205. //var resTwo10265 ResultTwo10265
  19206. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19207. utils.ErrorLog("解析失败:%v", err)
  19208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19209. return
  19210. }
  19211. if res5.Infcode == -1 {
  19212. c.ServeSuccessJSON(map[string]interface{}{
  19213. "failed_code": -10,
  19214. "msg": res5.ErrMsg,
  19215. })
  19216. return
  19217. }
  19218. var insutypes []string
  19219. var insutype string
  19220. var is390 int = 0
  19221. var is310 int = 0
  19222. for _, item := range res5.Output.Iinfo {
  19223. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19224. insutypes = append(insutypes, item.Insutype)
  19225. }
  19226. }
  19227. if len(insutypes) == 1 {
  19228. insutype = insutypes[0]
  19229. } else {
  19230. for _, i := range insutypes {
  19231. if i == "390" {
  19232. is390 = 1
  19233. }
  19234. if i == "310" {
  19235. is310 = 1
  19236. }
  19237. }
  19238. }
  19239. if is390 == 1 {
  19240. insutype = "390"
  19241. }
  19242. if is310 == 1 {
  19243. insutype = "310"
  19244. }
  19245. if len(insutypes) == 0 {
  19246. insutype = "310"
  19247. }
  19248. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19249. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19250. infoStr := string(Iinfos)
  19251. idetinfoStr := string(Idetinfos)
  19252. psn := &models.HisPsn{
  19253. PsnNo: res5.Output.Baseinfo.PsnNo,
  19254. PatientId: id,
  19255. Certno: res5.Output.Baseinfo.Certno,
  19256. Gend: res5.Output.Baseinfo.Gend,
  19257. Naty: res5.Output.Baseinfo.Naty,
  19258. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19259. PsnName: res5.Output.Baseinfo.PsnName,
  19260. Idetinfo: idetinfoStr,
  19261. Insuinfo: infoStr,
  19262. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19263. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19264. VerifyNumber: res2.Output.EcToken,
  19265. }
  19266. if res2.Output.MdtrtCertType == "01" {
  19267. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19268. psn.VerifyNumber = res2.Output.EcToken
  19269. } else if res2.Output.MdtrtCertType == "02" {
  19270. psn.VerifyNumber = res2.Output.CardNo
  19271. } else {
  19272. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19273. }
  19274. service.CreateHisPsn(psn)
  19275. if res2.Output.MdtrtCertType == "01" {
  19276. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19277. token := res2.Output.EcToken
  19278. 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)
  19279. } else if res2.Output.MdtrtCertType == "02" {
  19280. 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)
  19281. } else {
  19282. 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)
  19283. }
  19284. var dat2 map[string]interface{}
  19285. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19286. fmt.Println(dat2)
  19287. } else {
  19288. fmt.Println(err)
  19289. }
  19290. userJSONBytes3, _ := json.Marshal(dat2)
  19291. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19292. utils.ErrorLog("解析失败:%v", err)
  19293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19294. return
  19295. }
  19296. saveLog(result2, src_resquest, "2207", "结算")
  19297. } else {
  19298. c.ServeSuccessJSON(map[string]interface{}{
  19299. "failed_code": -10,
  19300. "msg": res2.ErrMsg,
  19301. })
  19302. return
  19303. }
  19304. } else {
  19305. if miConfig.Code == "H15049901371" {
  19306. //赤峰地区国家医保医疗类别
  19307. //职工透析:医疗类别选特殊情况门诊990502
  19308. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19309. var med_type string
  19310. if his.Insutype == "390" {
  19311. if reg_type == 14 {
  19312. med_type = "9933"
  19313. } else if reg_type == 11 {
  19314. med_type = "11"
  19315. }
  19316. } else if his.Insutype == "310" {
  19317. if reg_type == 14 {
  19318. med_type = "990502"
  19319. } else if reg_type == 11 {
  19320. med_type = "11"
  19321. }
  19322. }
  19323. 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)
  19324. } else {
  19325. if his.IdCardType == 4 {
  19326. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19327. var token string
  19328. token = psn_info.VerifyNumber
  19329. 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)
  19330. } else {
  19331. if his.IdCardType == 1 {
  19332. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19333. bas := strings.Split(psn_info.CardInfo, "|")
  19334. basNumber := bas[2]
  19335. cert_no = basNumber
  19336. }
  19337. 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)
  19338. }
  19339. }
  19340. //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)
  19341. var dat map[string]interface{}
  19342. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19343. fmt.Println(dat)
  19344. } else {
  19345. fmt.Println(err)
  19346. }
  19347. saveLog(result2, src_resquest, "2207", "结算")
  19348. userJSONBytes, _ := json.Marshal(dat)
  19349. if miConfig.Code == "H15049901371" {
  19350. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19351. utils.ErrorLog("解析失败:%v", err)
  19352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19353. return
  19354. }
  19355. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19356. res.Output = resSeven10265.Output
  19357. res.ErrMsg = resSeven10265.ErrMsg
  19358. res.Cainfo = resSeven10265.Cainfo
  19359. res.WarnMsg = resSeven10265.WarnMsg
  19360. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19361. res.Infcode = infocode
  19362. } else {
  19363. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19364. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19365. utils.ErrorLog("解析失败:%v", err)
  19366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19367. return
  19368. }
  19369. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19370. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19371. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19372. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19373. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19374. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19375. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19376. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19377. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19378. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19379. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19380. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19381. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19382. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19383. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19384. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19385. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19386. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19387. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19388. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19389. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19390. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19391. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19392. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19393. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19394. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19395. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19396. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19397. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19398. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19399. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19400. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19401. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19402. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19403. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19404. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19405. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19406. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19407. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19408. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19409. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19410. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19411. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19412. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19413. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19414. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19415. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19416. res.Cainfo = gzresSeven10265Two.Cainfo
  19417. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19418. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19419. //res.Infcode = infocode
  19420. } else {
  19421. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19422. utils.ErrorLog("解析失败:%v", err)
  19423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19424. return
  19425. }
  19426. }
  19427. }
  19428. }
  19429. if res.Infcode == -1 {
  19430. errlog := &models.HisOrderError{
  19431. UserOrgId: adminUser.CurrentOrgId,
  19432. Ctime: time.Now().Unix(),
  19433. Mtime: time.Now().Unix(),
  19434. Number: chrg_bchno,
  19435. ErrMsg: res.ErrMsg,
  19436. Status: 1,
  19437. PatientId: id,
  19438. RecordTime: recordDateTime,
  19439. Stage: 6,
  19440. }
  19441. service.CreateErrMsgLog(errlog)
  19442. c.ServeSuccessJSON(map[string]interface{}{
  19443. "failed_code": -10,
  19444. "msg": res.ErrMsg,
  19445. })
  19446. return
  19447. } else {
  19448. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19449. order.OrderStatus = 2
  19450. order.Status = 1
  19451. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19452. order.SetlId = res.Output.Setlinfo.SetlID
  19453. order.PsnNo = res.Output.Setlinfo.PsnNo
  19454. order.PsnName = res.Output.Setlinfo.PsnName
  19455. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19456. order.Certno = res.Output.Setlinfo.Certno
  19457. order.Gend = res.Output.Setlinfo.Gend
  19458. order.Naty = res.Output.Setlinfo.Naty
  19459. order.Age = res.Output.Setlinfo.Age
  19460. order.Insutype = res.Output.Setlinfo.Insutype
  19461. order.PsnType = res.Output.Setlinfo.PsnType
  19462. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19463. order.SetlTime = res.Output.Setlinfo.SetlTime
  19464. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19465. if res.Output.Setlinfo.MedType == "140101" {
  19466. order.MedType = "14"
  19467. } else {
  19468. if res.Output.Setlinfo.MedType == "110104" {
  19469. order.MedType = "11"
  19470. } else {
  19471. order.MedType = res.Output.Setlinfo.MedType
  19472. }
  19473. }
  19474. if reg_type == 1112 {
  19475. order.MedType = "1112"
  19476. }
  19477. if reg_type == 1111 {
  19478. order.MedType = "1111"
  19479. }
  19480. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19481. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19482. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19483. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19484. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19485. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19486. order.HifpPay = res.Output.Setlinfo.HifpPay
  19487. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19488. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19489. order.HifesPay = res.Output.Setlinfo.HifesPay
  19490. order.HifobPay = res.Output.Setlinfo.HifobPay
  19491. order.MafPay = res.Output.Setlinfo.MafPay
  19492. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19493. order.OthPay = res.Output.Setlinfo.OthPay
  19494. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19495. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19496. order.AcctPay = res.Output.Setlinfo.AcctPay
  19497. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19498. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19499. order.Balc = res.Output.Setlinfo.Balc
  19500. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19501. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19502. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19503. order.ClrType = res.Output.Setlinfo.ClrType
  19504. order.ClrWay = res.Output.Setlinfo.ClrWay
  19505. order.Creator = order.Creator
  19506. order.Modify = roles.AdminUserId
  19507. order.RequestLog = src_resquest
  19508. order.FaPiaoNumber = fapiao_number
  19509. order.FaPiaoCode = fapiao_code
  19510. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19511. //detailStr := string(setlDetail)
  19512. //order.SetlDetail = detailStr
  19513. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19514. err = service.UpDateOrder(order)
  19515. if err == nil {
  19516. //判断是否使用了押金
  19517. if dec_way == "true" {
  19518. tmpstring := strconv.FormatInt(order.ID, 10)
  19519. order.Decimal = decimal
  19520. service.UpDateOrder(order)
  19521. //扣押金
  19522. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19523. if errmsg != nil {
  19524. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19525. return
  19526. }
  19527. }
  19528. c.ServeSuccessJSON(map[string]interface{}{
  19529. "msg": "结算成功",
  19530. })
  19531. } else {
  19532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19533. return
  19534. }
  19535. }
  19536. } else {
  19537. adminUser := c.GetAdminUserInfo()
  19538. errlog := &models.HisOrderError{
  19539. UserOrgId: adminUser.CurrentOrgId,
  19540. Ctime: time.Now().Unix(),
  19541. Mtime: time.Now().Unix(),
  19542. ErrMsg: res.ErrMsg,
  19543. Status: 1,
  19544. PatientId: id,
  19545. RecordTime: recordDateTime,
  19546. Stage: 4,
  19547. }
  19548. service.CreateErrMsgLog(errlog)
  19549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  19550. return
  19551. }
  19552. } else {
  19553. adminUser := c.GetAdminUserInfo()
  19554. errlog := &models.HisOrderError{
  19555. UserOrgId: adminUser.CurrentOrgId,
  19556. Ctime: time.Now().Unix(),
  19557. Mtime: time.Now().Unix(),
  19558. ErrMsg: res.ErrMsg,
  19559. Status: 1,
  19560. PatientId: id,
  19561. RecordTime: recordDateTime,
  19562. Stage: 4,
  19563. }
  19564. service.CreateErrMsgLog(errlog)
  19565. c.ServeSuccessJSON(map[string]interface{}{
  19566. "failed_code": -10,
  19567. "msg": res.ErrMsg,
  19568. })
  19569. return
  19570. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  19571. //return
  19572. }
  19573. }
  19574. }
  19575. } else if tempOrder.ID > 0 {
  19576. if tempOrder.IsPre == 1 {
  19577. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  19578. var rf []*ResultFive
  19579. json.Unmarshal([]byte(his.Iinfo), &rf)
  19580. chrg_bchno := tempOrder.Number
  19581. cert_no := his.Certno
  19582. var insutypes []string
  19583. var insutype string
  19584. var is390 int = 0
  19585. var is310 int = 0
  19586. for _, item := range rf {
  19587. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19588. insutypes = append(insutypes, item.Insutype)
  19589. }
  19590. }
  19591. if len(insutypes) == 1 {
  19592. insutype = insutypes[0]
  19593. } else {
  19594. for _, i := range insutypes {
  19595. if i == "390" {
  19596. is390 = 1
  19597. }
  19598. if i == "310" {
  19599. is310 = 1
  19600. }
  19601. }
  19602. }
  19603. if is390 == 1 {
  19604. insutype = "390"
  19605. }
  19606. if is310 == 1 {
  19607. insutype = "310"
  19608. }
  19609. if len(insutypes) == 0 {
  19610. insutype = "310"
  19611. }
  19612. if len(insutypes) == 2 {
  19613. insutype = strconv.FormatInt(his.SocialType, 10)
  19614. }
  19615. //insutype = "390"
  19616. if his.IdCardType == 1 {
  19617. // cert_no = his.MedicalInsuranceNumber
  19618. cert_no = his.Certno
  19619. } else {
  19620. cert_no = his.Certno
  19621. }
  19622. var res ResultSeven
  19623. var ahres ResultSevenAH
  19624. var resSeven10265 ResultSeven10265
  19625. var gzresSeven10265Two GZResultSeven10265Two
  19626. var src_resquest string
  19627. var result2 string
  19628. if miConfig.MdtrtareaAdmvs == "450721" {
  19629. res2 := c.GetoleInfo()
  19630. if res2.Infcode == 0 {
  19631. var result string
  19632. var request_log string
  19633. var result_log string
  19634. if res2.Output.MdtrtCertType == "02" {
  19635. 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)
  19636. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19637. } else if res2.Output.MdtrtCertType == "01" {
  19638. 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)
  19639. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19640. } else {
  19641. 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)
  19642. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19643. }
  19644. var dat map[string]interface{}
  19645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19646. fmt.Println(dat)
  19647. } else {
  19648. fmt.Println(err)
  19649. }
  19650. userJSONBytes, _ := json.Marshal(dat)
  19651. var res5 ResultTwo
  19652. //var resTwo10265 ResultTwo10265
  19653. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19654. utils.ErrorLog("解析失败:%v", err)
  19655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19656. return
  19657. }
  19658. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19659. if res5.Infcode == -1 {
  19660. c.ServeSuccessJSON(map[string]interface{}{
  19661. "failed_code": -10,
  19662. "msg": res5.ErrMsg,
  19663. })
  19664. return
  19665. }
  19666. var insutypes []string
  19667. var insutype string
  19668. var is390 int = 0
  19669. var is310 int = 0
  19670. for _, item := range res5.Output.Iinfo {
  19671. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19672. insutypes = append(insutypes, item.Insutype)
  19673. }
  19674. }
  19675. if len(insutypes) == 1 {
  19676. insutype = insutypes[0]
  19677. } else {
  19678. for _, i := range insutypes {
  19679. if i == "390" {
  19680. is390 = 1
  19681. }
  19682. if i == "310" {
  19683. is310 = 1
  19684. }
  19685. }
  19686. }
  19687. if is390 == 1 {
  19688. insutype = "390"
  19689. }
  19690. if is310 == 1 {
  19691. insutype = "310"
  19692. }
  19693. if len(insutypes) == 0 {
  19694. insutype = "310"
  19695. }
  19696. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19697. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19698. infoStr := string(Iinfos)
  19699. idetinfoStr := string(Idetinfos)
  19700. psn := &models.HisPsn{
  19701. PsnNo: res5.Output.Baseinfo.PsnNo,
  19702. PatientId: id,
  19703. Certno: res5.Output.Baseinfo.Certno,
  19704. Gend: res5.Output.Baseinfo.Gend,
  19705. Naty: res5.Output.Baseinfo.Naty,
  19706. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19707. PsnName: res5.Output.Baseinfo.PsnName,
  19708. Idetinfo: idetinfoStr,
  19709. Insuinfo: infoStr,
  19710. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19711. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19712. VerifyNumber: res2.Output.EcToken,
  19713. }
  19714. service.CreateHisPsn(psn)
  19715. if res2.Output.MdtrtCertType == "01" {
  19716. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19717. token := res2.Output.EcToken
  19718. 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)
  19719. } else if res2.Output.MdtrtCertType == "02" {
  19720. 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)
  19721. } else {
  19722. 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)
  19723. }
  19724. var dat2 map[string]interface{}
  19725. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19726. fmt.Println(dat2)
  19727. } else {
  19728. fmt.Println(err)
  19729. }
  19730. userJSONBytes3, _ := json.Marshal(dat2)
  19731. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19732. utils.ErrorLog("解析失败:%v", err)
  19733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19734. return
  19735. }
  19736. saveLog(result2, src_resquest, "2207", "结算")
  19737. } else {
  19738. c.ServeSuccessJSON(map[string]interface{}{
  19739. "failed_code": -10,
  19740. "msg": res2.ErrMsg,
  19741. })
  19742. return
  19743. }
  19744. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19745. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19746. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19747. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19748. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19749. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19750. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19751. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19752. resp, requestErr := http.Get(api)
  19753. if requestErr != nil {
  19754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19755. return
  19756. }
  19757. body, ioErr := ioutil.ReadAll(resp.Body)
  19758. if ioErr != nil {
  19759. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19761. return
  19762. }
  19763. var respJSON map[string]interface{}
  19764. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19765. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19767. return
  19768. }
  19769. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19770. result, _ := json.Marshal(respJSON)
  19771. fmt.Println("log")
  19772. fmt.Println(string(result))
  19773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19774. utils.ErrorLog("解析失败:%v", err)
  19775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19776. return
  19777. }
  19778. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19779. if reg_type == 11 && his.Insutype == "390" {
  19780. reg_type = 110104
  19781. }
  19782. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19783. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19784. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19786. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19787. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19788. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19789. resp, requestErr := http.Get(api)
  19790. if requestErr != nil {
  19791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19792. return
  19793. }
  19794. body, ioErr := ioutil.ReadAll(resp.Body)
  19795. if ioErr != nil {
  19796. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19798. return
  19799. }
  19800. var respJSON map[string]interface{}
  19801. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19802. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19804. return
  19805. }
  19806. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19807. result, _ := json.Marshal(respJSON)
  19808. fmt.Println("log")
  19809. fmt.Println(string(result))
  19810. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19811. utils.ErrorLog("解析失败:%v", err)
  19812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19813. return
  19814. }
  19815. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19816. if reg_type == 11 && his.Insutype == "390" {
  19817. reg_type = 110104
  19818. }
  19819. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19820. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19821. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19822. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19823. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19824. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19825. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19826. resp, requestErr := http.Get(api)
  19827. if requestErr != nil {
  19828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19829. return
  19830. }
  19831. body, ioErr := ioutil.ReadAll(resp.Body)
  19832. if ioErr != nil {
  19833. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19835. return
  19836. }
  19837. var respJSON map[string]interface{}
  19838. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19839. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19841. return
  19842. }
  19843. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19844. result, _ := json.Marshal(respJSON)
  19845. fmt.Println("log")
  19846. fmt.Println(string(result))
  19847. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19848. utils.ErrorLog("解析失败:%v", err)
  19849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19850. return
  19851. }
  19852. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19853. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19854. if result3101.Infcode == "0" {
  19855. if len(result3101.Output.Result) > 0 {
  19856. var errMsgs []string
  19857. for _, item := range result3101.Output.Result {
  19858. errMsgs = append(errMsgs, item.VolaCont)
  19859. }
  19860. c.ServeSuccessJSON(map[string]interface{}{
  19861. "failed_code": -10,
  19862. "msg": errMsgs,
  19863. })
  19864. return
  19865. } else {
  19866. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19867. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19868. bas := strings.Split(psn_info.CardInfo, "|")
  19869. if his.IdCardType == 1 {
  19870. cert_no = bas[2]
  19871. } else if his.IdCardType == 3 {
  19872. cert_no = his.Certno
  19873. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19874. } else if his.IdCardType == 4 {
  19875. cert_no = his.Certno
  19876. psn_info.VerifyNumber = psn_info.VerifyNumber
  19877. }
  19878. //江苏地区国家医保医疗类别
  19879. //职工透析:医疗类别选特殊情况门诊9933
  19880. //居民血透门慢: 医疗类别选门诊慢病1402
  19881. //var med_type string
  19882. //if his.Insutype == "310" {
  19883. // if reg_type == 14 {
  19884. // med_type = "9933"
  19885. // } else if reg_type == 11 {
  19886. // med_type = "11"
  19887. //
  19888. // }
  19889. //} else if his.Insutype == "390" {
  19890. // if reg_type == 14 {
  19891. // med_type = "1402"
  19892. // } else if reg_type == 11 {
  19893. // med_type = "11"
  19894. // }
  19895. //}
  19896. var api string
  19897. if miConfig.MdtrtareaAdmvs == "320921" {
  19898. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19899. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19900. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19902. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19903. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19904. "&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
  19905. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19906. } else {
  19907. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19908. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19909. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19910. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19911. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19912. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19913. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19914. "&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
  19915. }
  19916. resp, requestErr := http.Get(api)
  19917. if requestErr != nil {
  19918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19919. return
  19920. }
  19921. body, ioErr := ioutil.ReadAll(resp.Body)
  19922. if ioErr != nil {
  19923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19925. return
  19926. }
  19927. var respJSON map[string]interface{}
  19928. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19931. return
  19932. }
  19933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19934. result, _ := json.Marshal(respJSON)
  19935. fmt.Println("log")
  19936. fmt.Println(string(result))
  19937. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19938. utils.ErrorLog("解析失败:%v", err)
  19939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19940. return
  19941. }
  19942. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19943. res.Output = resSeven10265.Output
  19944. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19945. res.ErrMsg = resSeven10265.ErrMsg
  19946. res.Cainfo = resSeven10265.Cainfo
  19947. res.WarnMsg = resSeven10265.WarnMsg
  19948. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19949. res.Infcode = infocode
  19950. }
  19951. }
  19952. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19953. psn_info, _ := service.GetPsnByPatientId(id)
  19954. var verify_number string
  19955. if psn_info.IdCardType == 4 {
  19956. verify_number = psn_info.VerifyNumber
  19957. } else if psn_info.IdCardType == 1 {
  19958. bas := strings.Split(psn_info.CardInfo, "|")
  19959. cardNumber := bas[2]
  19960. verify_number = cardNumber
  19961. } else {
  19962. verify_number = psn_info.Certno
  19963. psn_info.IdCardType = 2
  19964. }
  19965. var api string
  19966. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19967. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19968. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19969. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19970. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19971. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19972. "&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
  19973. resp, requestErr := http.Get(api)
  19974. if requestErr != nil {
  19975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19976. return
  19977. }
  19978. body, ioErr := ioutil.ReadAll(resp.Body)
  19979. if ioErr != nil {
  19980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19982. return
  19983. }
  19984. var respJSON map[string]interface{}
  19985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19988. return
  19989. }
  19990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19991. result, _ := json.Marshal(respJSON)
  19992. fmt.Println("log")
  19993. fmt.Println(string(result))
  19994. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19995. utils.ErrorLog("解析失败:%v", err)
  19996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19997. return
  19998. }
  19999. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20000. res.Output = resSeven10265.Output
  20001. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20002. res.ErrMsg = resSeven10265.ErrMsg
  20003. res.Cainfo = resSeven10265.Cainfo
  20004. res.WarnMsg = resSeven10265.WarnMsg
  20005. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20006. res.Infcode = infocode
  20007. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20009. var cert_no string
  20010. if his.IdCardType == 1 {
  20011. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20012. } else {
  20013. cert_no = psn_info.VerifyNumber
  20014. }
  20015. 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)
  20016. var dat map[string]interface{}
  20017. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20018. fmt.Println(dat)
  20019. } else {
  20020. fmt.Println(err)
  20021. }
  20022. saveLog(result2, src_resquest, "2207", "结算")
  20023. userJSONBytes, _ := json.Marshal(dat)
  20024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20025. utils.ErrorLog("解析失败:%v", err)
  20026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20027. return
  20028. }
  20029. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20030. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20031. var cert_no string
  20032. var card_sn string
  20033. if his.IdCardType == 1 {
  20034. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20035. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20036. bas := strings.Split(psn_info.CardInfo, "|")
  20037. card_sn = bas[3]
  20038. } else if his.IdCardType == 2 {
  20039. cert_no = his.IdCardNo
  20040. } else {
  20041. cert_no = psn_info.VerifyNumber
  20042. }
  20043. var rf []*ResultFive
  20044. json.Unmarshal([]byte(his.Iinfo), &rf)
  20045. var psn_type string
  20046. for _, item := range rf {
  20047. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20048. psn_type = item.PsnType
  20049. }
  20050. }
  20051. 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)
  20052. var dat map[string]interface{}
  20053. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20054. fmt.Println(dat)
  20055. } else {
  20056. fmt.Println(err)
  20057. }
  20058. saveLog(result2, src_resquest, "2207", "结算")
  20059. userJSONBytes, _ := json.Marshal(dat)
  20060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20061. utils.ErrorLog("解析失败:%v", err)
  20062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20063. return
  20064. }
  20065. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20066. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20067. if his.IdCardType == 1 {
  20068. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20069. bas := strings.Split(psn_info.CardInfo, "|")
  20070. cert_no = bas[2]
  20071. } else if his.IdCardType == 3 {
  20072. cert_no = his.Certno
  20073. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20074. } else if his.IdCardType == 4 {
  20075. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20076. cert_no = his.Certno
  20077. psn_info.VerifyNumber = psn_info.VerifyNumber
  20078. } else {
  20079. cert_no = his.Certno
  20080. psn_info.VerifyNumber = his.Certno
  20081. }
  20082. var api string
  20083. var med_type string
  20084. if his.Insutype == "390" {
  20085. if reg_type == 992102 {
  20086. med_type = "992102"
  20087. }
  20088. if reg_type == 140104 {
  20089. med_type = "140104"
  20090. }
  20091. if reg_type == 14 {
  20092. med_type = "14"
  20093. }
  20094. } else if his.Insutype == "310" {
  20095. if reg_type == 992102 {
  20096. med_type = "992102"
  20097. }
  20098. if reg_type == 14 {
  20099. med_type = "14"
  20100. }
  20101. }
  20102. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20108. "&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
  20109. resp, requestErr := http.Get(api)
  20110. if requestErr != nil {
  20111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20112. return
  20113. }
  20114. body, ioErr := ioutil.ReadAll(resp.Body)
  20115. if ioErr != nil {
  20116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20118. return
  20119. }
  20120. var respJSON map[string]interface{}
  20121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20124. return
  20125. }
  20126. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20127. if status == "0" {
  20128. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20129. c.ServeSuccessJSON(map[string]interface{}{
  20130. "failed_code": -10,
  20131. "msg": err_msg,
  20132. })
  20133. return
  20134. }
  20135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20136. result, _ := json.Marshal(respJSON)
  20137. fmt.Println("log")
  20138. fmt.Println(string(result))
  20139. if err := json.Unmarshal(result, &ahres); err != nil {
  20140. utils.ErrorLog("解析失败:%v", err)
  20141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20142. return
  20143. }
  20144. res.InfRefmsgid = ahres.InfRefmsgid
  20145. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20146. // 创建对应的Time类型
  20147. t := time.UnixMilli(timestamp)
  20148. // 格式化成指定的日期字符串
  20149. str := t.Format("2006-01-02 15:04:05")
  20150. res.Output.Setlinfo.SetlTime = str
  20151. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20152. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20153. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20154. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20155. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20156. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20157. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20158. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20159. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20160. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20161. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20162. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20163. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20164. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20165. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20166. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20167. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20168. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20169. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20170. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20171. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20172. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20173. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20174. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20175. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20176. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20177. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20178. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20179. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20180. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20181. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20182. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20183. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20184. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20185. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20186. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20187. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20188. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20189. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20190. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20191. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20192. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20193. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20194. res.Output.Setldetail = ahres.Output.Setldetail
  20195. res.ErrMsg = ahres.ErrMsg
  20196. res.Cainfo = ahres.Cainfo
  20197. res.WarnMsg = ahres.WarnMsg
  20198. res.Infcode = ahres.Infcode
  20199. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20200. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20201. var cert_no string
  20202. if his.IdCardType == 1 {
  20203. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20204. } else if his.IdCardType == 2 {
  20205. cert_no = his.IdCardNo
  20206. } else {
  20207. cert_no = psn_info.VerifyNumber
  20208. }
  20209. 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, "")
  20210. var dat map[string]interface{}
  20211. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20212. fmt.Println(dat)
  20213. } else {
  20214. fmt.Println(err)
  20215. }
  20216. saveLog(result2, src_resquest, "2207", "结算")
  20217. userJSONBytes, _ := json.Marshal(dat)
  20218. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20219. utils.ErrorLog("解析失败:%v", err)
  20220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20221. return
  20222. }
  20223. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20224. psn_info, _ := service.GetPsnByPatientId(id)
  20225. var verify_number string
  20226. if psn_info.IdCardType == 4 {
  20227. verify_number = psn_info.VerifyNumber
  20228. } else if psn_info.IdCardType == 1 {
  20229. bas := strings.Split(psn_info.CardInfo, "|")
  20230. cardNumber := bas[2]
  20231. verify_number = cardNumber
  20232. } else {
  20233. verify_number = psn_info.Certno
  20234. psn_info.IdCardType = 2
  20235. }
  20236. var api string
  20237. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20238. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20239. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20241. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20242. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20243. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20244. resp, requestErr := http.Get(api)
  20245. if requestErr != nil {
  20246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20247. return
  20248. }
  20249. body, ioErr := ioutil.ReadAll(resp.Body)
  20250. if ioErr != nil {
  20251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20253. return
  20254. }
  20255. var respJSON map[string]interface{}
  20256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20259. return
  20260. }
  20261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20262. result, _ := json.Marshal(respJSON)
  20263. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20264. utils.ErrorLog("解析失败:%v", err)
  20265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20266. return
  20267. }
  20268. } else {
  20269. var src_resquest string
  20270. if miConfig.Code == "H15049901371" {
  20271. //赤峰地区国家医保医疗类别
  20272. //职工透析:医疗类别选特殊情况门诊990502
  20273. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20274. var med_type string
  20275. if his.Insutype == "390" {
  20276. if reg_type == 14 {
  20277. med_type = "9933"
  20278. } else if reg_type == 11 {
  20279. med_type = "11"
  20280. }
  20281. } else if his.Insutype == "310" {
  20282. if reg_type == 14 {
  20283. med_type = "990502"
  20284. } else if reg_type == 11 {
  20285. med_type = "11"
  20286. }
  20287. }
  20288. 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)
  20289. } else {
  20290. if his.IdCardType == 4 {
  20291. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20292. token := psn_info.VerifyNumber
  20293. 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)
  20294. } else {
  20295. 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)
  20296. }
  20297. }
  20298. var dat map[string]interface{}
  20299. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20300. fmt.Println(dat)
  20301. } else {
  20302. fmt.Println(err)
  20303. }
  20304. saveLog(result2, src_resquest, "2207", "结算")
  20305. userJSONBytes, _ := json.Marshal(dat)
  20306. if miConfig.Code == "H15049901371" {
  20307. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20308. utils.ErrorLog("解析失败:%v", err)
  20309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20310. return
  20311. }
  20312. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20313. res.Output = resSeven10265.Output
  20314. res.ErrMsg = resSeven10265.ErrMsg
  20315. res.Cainfo = resSeven10265.Cainfo
  20316. res.WarnMsg = resSeven10265.WarnMsg
  20317. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20318. res.Infcode = infocode
  20319. } else {
  20320. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20321. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20322. utils.ErrorLog("解析失败:%v", err)
  20323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20324. return
  20325. }
  20326. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20327. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20328. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20329. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20330. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20331. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20332. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20333. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20334. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20335. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20336. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20337. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20338. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20339. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20340. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20341. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20342. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20343. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20344. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20345. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20346. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20347. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20348. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20349. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20350. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20351. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20352. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20353. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20354. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20355. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20356. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20357. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20358. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20359. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20360. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20361. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20362. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20363. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20364. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20365. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20366. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20367. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20368. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20369. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20370. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20371. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20372. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20373. res.Cainfo = gzresSeven10265Two.Cainfo
  20374. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20375. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20376. //res.Infcode = infocode
  20377. } else {
  20378. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20379. utils.ErrorLog("解析失败:%v", err)
  20380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20381. return
  20382. }
  20383. }
  20384. }
  20385. }
  20386. if res.Infcode != 0 {
  20387. errlog := &models.HisOrderError{
  20388. UserOrgId: adminUser.CurrentOrgId,
  20389. Ctime: time.Now().Unix(),
  20390. Mtime: time.Now().Unix(),
  20391. Number: chrg_bchno,
  20392. ErrMsg: res.ErrMsg,
  20393. Status: 1,
  20394. PatientId: id,
  20395. RecordTime: recordDateTime,
  20396. Stage: 6,
  20397. }
  20398. service.CreateErrMsgLog(errlog)
  20399. c.ServeSuccessJSON(map[string]interface{}{
  20400. "failed_code": -10,
  20401. "msg": res.ErrMsg,
  20402. })
  20403. return
  20404. } else {
  20405. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20406. order.OrderStatus = 2
  20407. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20408. order.SetlId = res.Output.Setlinfo.SetlID
  20409. order.PsnNo = res.Output.Setlinfo.PsnNo
  20410. order.PsnName = res.Output.Setlinfo.PsnName
  20411. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20412. order.Certno = res.Output.Setlinfo.Certno
  20413. order.Gend = res.Output.Setlinfo.Gend
  20414. order.Naty = res.Output.Setlinfo.Naty
  20415. order.Age = res.Output.Setlinfo.Age
  20416. order.Insutype = res.Output.Setlinfo.Insutype
  20417. order.PsnType = res.Output.Setlinfo.PsnType
  20418. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20419. order.SetlTime = res.Output.Setlinfo.SetlTime
  20420. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20421. order.PayWays = pay_ways
  20422. order.AcctUsedFlag = acct_used_flag
  20423. order.WechatPay = wechat_pay
  20424. order.AliPay = ali_pay
  20425. order.JifenPay = jifen_pay
  20426. order.BandCardPay = band_card_pay
  20427. order.CashPay = cash_pay
  20428. order.OthDesc = oth_desc
  20429. //order.MedType = res.Output.Setlinfo.MedType
  20430. if reg_type == 1112 {
  20431. order.MedType = "1112"
  20432. }
  20433. if reg_type == 1111 {
  20434. order.MedType = "1111"
  20435. }
  20436. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20437. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20438. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20439. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20440. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20441. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20442. order.HifpPay = res.Output.Setlinfo.HifpPay
  20443. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20444. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20445. order.HifesPay = res.Output.Setlinfo.HifesPay
  20446. order.HifobPay = res.Output.Setlinfo.HifobPay
  20447. order.MafPay = res.Output.Setlinfo.MafPay
  20448. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20449. order.OthPay = res.Output.Setlinfo.OthPay
  20450. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20451. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20452. order.AcctPay = res.Output.Setlinfo.AcctPay
  20453. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20454. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20455. order.Balc = res.Output.Setlinfo.Balc
  20456. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20457. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20458. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20459. order.ClrWay = res.Output.Setlinfo.ClrWay
  20460. order.Creator = order.Creator
  20461. order.ClrType = res.Output.Setlinfo.ClrType
  20462. order.Modify = roles.AdminUserId
  20463. order.RequestLog = src_resquest
  20464. order.Diagnosis = diagnosis_id
  20465. order.FaPiaoNumber = fapiao_number
  20466. order.FaPiaoCode = fapiao_code
  20467. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20468. detailStr := string(setlDetail)
  20469. order.SetlDetail = detailStr
  20470. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20471. err = service.UpDateOrder(order)
  20472. if err == nil {
  20473. //判断是否使用了押金
  20474. if dec_way == "true" {
  20475. tmpstring := strconv.FormatInt(order.ID, 10)
  20476. //扣押金
  20477. order.Decimal = decimal
  20478. service.UpDateOrder(order)
  20479. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20480. if errmsg != nil {
  20481. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20482. return
  20483. }
  20484. }
  20485. c.ServeSuccessJSON(map[string]interface{}{
  20486. "msg": "结算成功",
  20487. })
  20488. } else {
  20489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20490. return
  20491. }
  20492. }
  20493. }
  20494. }
  20495. }
  20496. // 上传明细-预结算-
  20497. func (c *HisApiController) GetPreUploadInfo() {
  20498. id, _ := c.GetInt64("id")
  20499. record_time := c.GetString("record_time")
  20500. his_patient_id, _ := c.GetInt64("his_patient_id")
  20501. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  20502. admin_user_id, _ := c.GetInt64("admin_user_id")
  20503. diagnosis_id := c.GetString("diagnosis")
  20504. sick_type, _ := c.GetInt64("sick_type")
  20505. reg_type, _ := c.GetInt64("p_type")
  20506. begin_time := c.GetString("begin_time")
  20507. acct_used_flag := c.GetString("acct_used_flag")
  20508. id_str := c.GetString("ids")
  20509. ids_arr := strings.Split(id_str, ",")
  20510. timeLayout := "2006-01-02"
  20511. loc, _ := time.LoadLocation("Local")
  20512. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20513. if err != nil {
  20514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20515. return
  20516. }
  20517. recordDateTime := theTime.Unix()
  20518. adminUser := c.GetAdminUserInfo()
  20519. diagnosis_ids := strings.Split(diagnosis_id, ",")
  20520. var config []*models.HisXtDiagnoseConfig
  20521. for _, item := range diagnosis_ids {
  20522. id, _ := strconv.ParseInt(item, 10, 64)
  20523. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20524. config = append(config, &diagnosisConfig)
  20525. }
  20526. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  20527. sickConfig, _ := service.FindSickById(sick_type)
  20528. var prescriptions []*models.HisPrescription
  20529. var start_time int64
  20530. var end_time int64
  20531. var isSuccess bool = true
  20532. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20533. fmt.Println(his_patient_id)
  20534. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20535. timestamp := time.Now().Unix()
  20536. tempTime := time.Unix(timestamp, 0)
  20537. timeFormat := tempTime.Format("20060102150405")
  20538. chrgBchno := rand.Intn(100000) + 10000
  20539. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  20540. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20541. var patientPrescription models.HisPrescriptionInfo
  20542. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20543. if patientPrescription.ID == 0 {
  20544. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  20545. }
  20546. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20547. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  20548. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  20549. strconv.FormatInt(his.PatientId, 10)
  20550. var res2406 Result2406
  20551. //安徽单病种处理
  20552. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  20553. data := make(map[string]interface{})
  20554. client := &http.Client{}
  20555. data["psn_no"] = his.PsnNo
  20556. data["mdtrt_id"] = his.Number
  20557. data["operator"] = roles.UserName
  20558. data["cert_no"] = his.IdCardNo
  20559. data["org_name"] = miConfig.OrgName
  20560. data["psn_name"] = his.Name
  20561. data["ipt_otp_no"] = his.IptOtpNo
  20562. data["ipt_psn_sp_flag_type"] = "0901"
  20563. data["ipt_psn_sp_flag"] = "1"
  20564. data["fixmedins_code"] = miConfig.Code
  20565. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20567. data["url"] = miConfig.Url
  20568. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  20569. bytesData, _ := json.Marshal(data)
  20570. var req *http.Request
  20571. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  20572. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  20573. resp, _ := client.Do(req)
  20574. defer resp.Body.Close()
  20575. body, ioErr := ioutil.ReadAll(resp.Body)
  20576. if ioErr != nil {
  20577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20579. return
  20580. }
  20581. var respJSON map[string]interface{}
  20582. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20585. return
  20586. }
  20587. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20588. if status == "0" {
  20589. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20590. c.ServeSuccessJSON(map[string]interface{}{
  20591. "failed_code": -10,
  20592. "msg": err_msg,
  20593. })
  20594. return
  20595. }
  20596. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20597. userJSONBytes, _ := json.Marshal(respJSON)
  20598. fmt.Println("log")
  20599. fmt.Println(string(userJSONBytes))
  20600. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  20601. utils.ErrorLog("解析失败:%v", err)
  20602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20603. return
  20604. }
  20605. }
  20606. if res2406.Infcode != 0 {
  20607. adminUser := c.GetAdminUserInfo()
  20608. errlog := &models.HisOrderError{
  20609. UserOrgId: adminUser.CurrentOrgId,
  20610. Ctime: time.Now().Unix(),
  20611. Mtime: time.Now().Unix(),
  20612. ErrMsg: res2406.ErrMsg,
  20613. Status: 1,
  20614. PatientId: id,
  20615. RecordTime: recordDateTime,
  20616. Stage: 3,
  20617. }
  20618. service.CreateErrMsgLog(errlog)
  20619. c.ServeSuccessJSON(map[string]interface{}{
  20620. "failed_code": -10,
  20621. "msg": res2406.ErrMsg,
  20622. })
  20623. return
  20624. }
  20625. var res2 ResultSix
  20626. var res3 GZResultSix
  20627. var resSix10265 ResultSix10265
  20628. //var time_stamp string
  20629. if miConfig.MdtrtareaAdmvs == "421300" {
  20630. data := make(map[string]interface{})
  20631. client := &http.Client{}
  20632. data["psn_no"] = his.PsnNo
  20633. data["mdtrt_id"] = his.Number
  20634. data["department"] = department.Name
  20635. data["org_name"] = miConfig.OrgName
  20636. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20637. data["doctor_id"] = doctor_info.DoctorNumber
  20638. data["doctor_name"] = roles.UserName
  20639. data["fixmedins_code"] = miConfig.Code
  20640. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20642. data["secret_key"] = miConfig.SecretKey
  20643. data["sick_code"] = sickConfig.CountryCode
  20644. data["sick_name"] = sickConfig.ClassName
  20645. data["begin_time"] = begin_time
  20646. data["dept"] = strconv.FormatInt(department.ID, 10)
  20647. data["config"] = config
  20648. data["opter"] = roles.UserName
  20649. fmt.Println(data)
  20650. bytesData, _ := json.Marshal(data)
  20651. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20652. resp, _ := client.Do(req)
  20653. defer resp.Body.Close()
  20654. body, ioErr := ioutil.ReadAll(resp.Body)
  20655. if ioErr != nil {
  20656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20658. return
  20659. }
  20660. var respJSON map[string]interface{}
  20661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20664. return
  20665. }
  20666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20667. userJSONBytes, _ := json.Marshal(respJSON)
  20668. fmt.Println("log")
  20669. fmt.Println(string(userJSONBytes))
  20670. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20671. utils.ErrorLog("解析失败:%v", err)
  20672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20673. return
  20674. }
  20675. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20676. data := make(map[string]interface{})
  20677. client := &http.Client{}
  20678. data["psn_no"] = his.PsnNo
  20679. data["mdtrt_id"] = his.Number
  20680. data["department"] = department.Name
  20681. data["org_name"] = miConfig.OrgName
  20682. if reg_type == 11 && his.Insutype == "390" {
  20683. data["med_type"] = "110104"
  20684. } else {
  20685. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20686. }
  20687. data["doctor_id"] = doctor_info.DoctorNumber
  20688. data["doctor_name"] = roles.UserName
  20689. data["fixmedins_code"] = miConfig.Code
  20690. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20691. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20692. data["secret_key"] = miConfig.SecretKey
  20693. data["sick_code"] = sickConfig.CountryCode
  20694. data["sick_name"] = sickConfig.ClassName
  20695. data["begin_time"] = begin_time
  20696. data["dept"] = strconv.FormatInt(department.ID, 10)
  20697. data["config"] = config
  20698. data["opter"] = roles.UserName
  20699. fmt.Println(data)
  20700. bytesData, _ := json.Marshal(data)
  20701. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20702. resp, _ := client.Do(req)
  20703. defer resp.Body.Close()
  20704. body, ioErr := ioutil.ReadAll(resp.Body)
  20705. if ioErr != nil {
  20706. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20708. return
  20709. }
  20710. var respJSON map[string]interface{}
  20711. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20714. return
  20715. }
  20716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20717. userJSONBytes, _ := json.Marshal(respJSON)
  20718. fmt.Println("log")
  20719. fmt.Println(string(userJSONBytes))
  20720. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20721. utils.ErrorLog("解析失败:%v", err)
  20722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20723. return
  20724. }
  20725. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20726. data := make(map[string]interface{})
  20727. client := &http.Client{}
  20728. data["psn_no"] = his.PsnNo
  20729. data["mdtrt_id"] = his.Number
  20730. data["department"] = department.Name
  20731. data["org_name"] = miConfig.OrgName
  20732. if reg_type == 11 && his.Insutype == "390" {
  20733. data["med_type"] = "110104"
  20734. } else {
  20735. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20736. }
  20737. data["doctor_id"] = doctor_info.DoctorNumber
  20738. data["doctor_name"] = roles.UserName
  20739. data["fixmedins_code"] = miConfig.Code
  20740. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20741. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20742. data["secret_key"] = miConfig.SecretKey
  20743. data["sick_code"] = sickConfig.CountryCode
  20744. data["sick_name"] = sickConfig.ClassName
  20745. data["begin_time"] = begin_time
  20746. data["dept"] = strconv.FormatInt(department.ID, 10)
  20747. data["config"] = config
  20748. data["opter"] = roles.UserName
  20749. fmt.Println(data)
  20750. bytesData, _ := json.Marshal(data)
  20751. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20752. resp, _ := client.Do(req)
  20753. defer resp.Body.Close()
  20754. body, ioErr := ioutil.ReadAll(resp.Body)
  20755. if ioErr != nil {
  20756. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20758. return
  20759. }
  20760. var respJSON map[string]interface{}
  20761. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20762. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20764. return
  20765. }
  20766. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20767. userJSONBytes, _ := json.Marshal(respJSON)
  20768. fmt.Println("log")
  20769. fmt.Println(string(userJSONBytes))
  20770. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20771. utils.ErrorLog("解析失败:%v", err)
  20772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20773. return
  20774. }
  20775. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20776. data := make(map[string]interface{})
  20777. client := &http.Client{}
  20778. data["psn_no"] = his.PsnNo
  20779. data["mdtrt_id"] = his.Number
  20780. data["doctor"] = roles.UserName
  20781. data["department"] = department.Name
  20782. data["org_name"] = miConfig.OrgName
  20783. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20784. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20785. data["fixmedins_code"] = miConfig.Code
  20786. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20787. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20788. data["secret_key"] = miConfig.SecretKey
  20789. data["sick_code"] = sickConfig.CountryCode
  20790. data["sick_name"] = sickConfig.ClassName
  20791. data["begin_time"] = begin_time
  20792. data["dept"] = strconv.FormatInt(department.ID, 10)
  20793. data["config"] = config
  20794. data["url"] = miConfig.Url
  20795. data["ak"] = miConfig.AccessKey
  20796. data["cainfo"] = miConfig.Cainfo
  20797. bytesData, _ := json.Marshal(data)
  20798. var req *http.Request
  20799. if miConfig.MdtrtareaAdmvs == "320921" {
  20800. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20801. } else {
  20802. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20803. }
  20804. resp, _ := client.Do(req)
  20805. defer resp.Body.Close()
  20806. body, ioErr := ioutil.ReadAll(resp.Body)
  20807. if ioErr != nil {
  20808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20810. return
  20811. }
  20812. var respJSON map[string]interface{}
  20813. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20816. return
  20817. }
  20818. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20819. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20820. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20822. userJSONBytes, _ := json.Marshal(respJSON)
  20823. fmt.Println("log")
  20824. fmt.Println(string(userJSONBytes))
  20825. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20826. utils.ErrorLog("解析失败:%v", err)
  20827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20828. return
  20829. }
  20830. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20831. res2.Output = resSix10265.Output
  20832. res2.ErrMsg = resSix10265.ErrMsg
  20833. res2.Cainfo = resSix10265.Cainfo
  20834. res2.WarnMsg = resSix10265.WarnMsg
  20835. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20836. res2.Infcode = infocode
  20837. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20838. data := make(map[string]interface{})
  20839. client := &http.Client{}
  20840. data["psn_no"] = his.PsnNo
  20841. data["mdtrt_id"] = his.Number
  20842. data["doctor"] = roles.UserName
  20843. data["department"] = department.Name
  20844. data["org_name"] = miConfig.OrgName
  20845. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20846. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20847. data["fixmedins_code"] = miConfig.Code
  20848. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20849. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20850. data["secret_key"] = miConfig.SecretKey
  20851. data["sick_code"] = sickConfig.CountryCode
  20852. data["sick_name"] = sickConfig.ClassName
  20853. data["begin_time"] = begin_time
  20854. data["dept"] = strconv.FormatInt(department.ID, 10)
  20855. data["config"] = config
  20856. //data["url"] = miConfig.Url
  20857. //data["ak"] = miConfig.AccessKey
  20858. data["cainfo"] = miConfig.Cainfo
  20859. fmt.Println(data)
  20860. bytesData, _ := json.Marshal(data)
  20861. var req *http.Request
  20862. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20863. resp, _ := client.Do(req)
  20864. defer resp.Body.Close()
  20865. body, ioErr := ioutil.ReadAll(resp.Body)
  20866. if ioErr != nil {
  20867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20869. return
  20870. }
  20871. var respJSON map[string]interface{}
  20872. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20875. return
  20876. }
  20877. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20878. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20879. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20881. userJSONBytes, _ := json.Marshal(respJSON)
  20882. fmt.Println("log")
  20883. fmt.Println(string(userJSONBytes))
  20884. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20885. utils.ErrorLog("解析失败:%v", err)
  20886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20887. return
  20888. }
  20889. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20890. res2.Output = resSix10265.Output
  20891. res2.ErrMsg = resSix10265.ErrMsg
  20892. res2.Cainfo = resSix10265.Cainfo
  20893. res2.WarnMsg = resSix10265.WarnMsg
  20894. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20895. res2.Infcode = infocode
  20896. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20897. 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)
  20898. saveLog(result, requestLog, "2203", "上传就诊信息")
  20899. var respJSON2 map[string]interface{}
  20900. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20903. return
  20904. }
  20905. userJSONBytes2, _ := json.Marshal(respJSON2)
  20906. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20907. utils.ErrorLog("解析失败:%v", err)
  20908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20909. return
  20910. }
  20911. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20912. var result string
  20913. var requestLog string
  20914. 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, "")
  20915. saveLog(result, requestLog, "2203", "上传就诊信息")
  20916. var respJSON2 map[string]interface{}
  20917. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20920. return
  20921. }
  20922. userJSONBytes2, _ := json.Marshal(respJSON2)
  20923. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20924. utils.ErrorLog("解析失败:%v", err)
  20925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20926. return
  20927. }
  20928. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20929. data := make(map[string]interface{})
  20930. client := &http.Client{}
  20931. data["psn_no"] = his.PsnNo
  20932. data["mdtrt_id"] = his.Number
  20933. data["operator"] = roles.UserName
  20934. data["department"] = department.Name
  20935. data["org_name"] = miConfig.OrgName
  20936. var med_type string
  20937. if his.Insutype == "390" {
  20938. if reg_type == 992102 {
  20939. med_type = "992102"
  20940. data["sick_code"] = "ZDZ940"
  20941. data["sick_name"] = "慢性肾衰竭"
  20942. }
  20943. if reg_type == 140104 {
  20944. med_type = "140104"
  20945. data["sick_code"] = sickConfig.CountryCode
  20946. data["sick_name"] = sickConfig.ClassName
  20947. }
  20948. if reg_type == 14 {
  20949. med_type = "140104"
  20950. data["sick_code"] = sickConfig.CountryCode
  20951. data["sick_name"] = sickConfig.ClassName
  20952. }
  20953. } else if his.Insutype == "310" {
  20954. if reg_type == 992102 {
  20955. med_type = "992102"
  20956. data["sick_code"] = "ZDZ940"
  20957. data["sick_name"] = "慢性肾衰竭"
  20958. }
  20959. if reg_type == 140104 {
  20960. med_type = "140104"
  20961. data["sick_code"] = sickConfig.CountryCode
  20962. data["sick_name"] = sickConfig.ClassName
  20963. }
  20964. if reg_type == 14 {
  20965. med_type = "14"
  20966. data["sick_code"] = sickConfig.CountryCode
  20967. data["sick_name"] = sickConfig.ClassName
  20968. }
  20969. }
  20970. data["med_type"] = med_type
  20971. data["doctor_number"] = doctor_info.DoctorNumber
  20972. data["doctor_name"] = doctor_info.UserName
  20973. data["fixmedins_code"] = miConfig.Code
  20974. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20975. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20976. data["secret_key"] = miConfig.SecretKey
  20977. data["begin_time"] = begin_time
  20978. data["dept"] = strconv.FormatInt(department.ID, 10)
  20979. data["config"] = config
  20980. data["url"] = miConfig.Url
  20981. data["ak"] = miConfig.AccessKey
  20982. data["cainfo"] = miConfig.Cainfo
  20983. bytesData, _ := json.Marshal(data)
  20984. var req *http.Request
  20985. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  20986. resp, _ := client.Do(req)
  20987. defer resp.Body.Close()
  20988. body, ioErr := ioutil.ReadAll(resp.Body)
  20989. if ioErr != nil {
  20990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20992. return
  20993. }
  20994. var respJSON map[string]interface{}
  20995. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20998. return
  20999. }
  21000. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21001. if status == "0" {
  21002. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21003. c.ServeSuccessJSON(map[string]interface{}{
  21004. "failed_code": -10,
  21005. "msg": err_msg,
  21006. })
  21007. return
  21008. }
  21009. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21010. userJSONBytes, _ := json.Marshal(respJSON)
  21011. fmt.Println("log")
  21012. fmt.Println(string(userJSONBytes))
  21013. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21014. utils.ErrorLog("解析失败:%v", err)
  21015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21016. return
  21017. }
  21018. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21019. var result string
  21020. var requestLog string
  21021. 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, "")
  21022. saveLog(result, requestLog, "2203", "上传就诊信息")
  21023. var respJSON2 map[string]interface{}
  21024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21027. return
  21028. }
  21029. userJSONBytes2, _ := json.Marshal(respJSON2)
  21030. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21031. utils.ErrorLog("解析失败:%v", err)
  21032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21033. return
  21034. }
  21035. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21036. data := make(map[string]interface{})
  21037. client := &http.Client{}
  21038. data["psn_no"] = his.PsnNo
  21039. data["mdtrt_id"] = his.Number
  21040. data["doctor"] = roles.UserName
  21041. data["department"] = department.Name
  21042. data["org_name"] = miConfig.OrgName
  21043. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21044. data["doctor_id"] = doctor_info.DoctorNumber
  21045. data["fixmedins_code"] = miConfig.Code
  21046. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21047. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21048. data["secret_key"] = miConfig.SecretKey
  21049. data["sick_code"] = sickConfig.CountryCode
  21050. data["sick_name"] = sickConfig.ClassName
  21051. data["begin_time"] = begin_time
  21052. data["new_doctor_name"] = doctor_info.UserName
  21053. data["dept"] = strconv.FormatInt(department.ID, 10)
  21054. data["config"] = config
  21055. bytesData, _ := json.Marshal(data)
  21056. var req *http.Request
  21057. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21058. resp, _ := client.Do(req)
  21059. defer resp.Body.Close()
  21060. body, ioErr := ioutil.ReadAll(resp.Body)
  21061. if ioErr != nil {
  21062. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21064. return
  21065. }
  21066. var respJSON map[string]interface{}
  21067. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21068. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21070. return
  21071. }
  21072. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21073. userJSONBytes, _ := json.Marshal(respJSON)
  21074. fmt.Println("log")
  21075. fmt.Println(string(userJSONBytes))
  21076. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21077. utils.ErrorLog("解析失败:%v", err)
  21078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21079. return
  21080. }
  21081. } else {
  21082. var result string
  21083. var requestLog string
  21084. if miConfig.MdtrtareaAdmvs == "440781" { //
  21085. 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)
  21086. } else {
  21087. if miConfig.Code == "H15049901371" {
  21088. //赤峰地区国家医保医疗类别
  21089. //职工透析:医疗类别选特殊情况门诊990502
  21090. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21091. var med_type string
  21092. if his.Insutype == "390" {
  21093. if reg_type == 14 {
  21094. med_type = "9933"
  21095. } else if reg_type == 11 {
  21096. med_type = "11"
  21097. }
  21098. } else if his.Insutype == "310" {
  21099. if reg_type == 14 {
  21100. med_type = "990502"
  21101. } else if reg_type == 11 {
  21102. med_type = "11"
  21103. }
  21104. }
  21105. 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)
  21106. } else {
  21107. 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)
  21108. }
  21109. saveLog(result, requestLog, "2203", "上传就诊信息")
  21110. var respJSON2 map[string]interface{}
  21111. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21114. return
  21115. }
  21116. userJSONBytes2, _ := json.Marshal(respJSON2)
  21117. if miConfig.Code == "H15049901371" {
  21118. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21119. utils.ErrorLog("解析失败:%v", err)
  21120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21121. return
  21122. }
  21123. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21124. res2.Output = resSix10265.Output
  21125. res2.ErrMsg = resSix10265.ErrMsg
  21126. res2.Cainfo = resSix10265.Cainfo
  21127. res2.WarnMsg = resSix10265.WarnMsg
  21128. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21129. res2.Infcode = infocode
  21130. } else {
  21131. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21132. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21133. utils.ErrorLog("解析失败:%v", err)
  21134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21135. return
  21136. }
  21137. res2.Infcode = res3.Infcode
  21138. } else {
  21139. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21140. utils.ErrorLog("解析失败:%v", err)
  21141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21142. return
  21143. }
  21144. }
  21145. }
  21146. }
  21147. }
  21148. if res2.Infcode == -1 {
  21149. adminUser := c.GetAdminUserInfo()
  21150. errlog := &models.HisOrderError{
  21151. UserOrgId: adminUser.CurrentOrgId,
  21152. Ctime: time.Now().Unix(),
  21153. Mtime: time.Now().Unix(),
  21154. ErrMsg: res2.ErrMsg,
  21155. Status: 1,
  21156. PatientId: id,
  21157. RecordTime: recordDateTime,
  21158. Stage: 3,
  21159. }
  21160. service.CreateErrMsgLog(errlog)
  21161. c.ServeSuccessJSON(map[string]interface{}{
  21162. "failed_code": -10,
  21163. "msg": res2.ErrMsg,
  21164. })
  21165. return
  21166. }
  21167. if res2.Infcode != 0 {
  21168. adminUser := c.GetAdminUserInfo()
  21169. errlog := &models.HisOrderError{
  21170. UserOrgId: adminUser.CurrentOrgId,
  21171. Ctime: time.Now().Unix(),
  21172. Mtime: time.Now().Unix(),
  21173. ErrMsg: res2.ErrMsg,
  21174. Status: 1,
  21175. PatientId: id,
  21176. RecordTime: recordDateTime,
  21177. Stage: 3,
  21178. }
  21179. service.CreateErrMsgLog(errlog)
  21180. c.ServeSuccessJSON(map[string]interface{}{
  21181. "failed_code": -10,
  21182. "msg": res2.ErrMsg,
  21183. })
  21184. return
  21185. } else {
  21186. his.Diagnosis = diagnosis_id
  21187. his.SickType = sickConfig.ID
  21188. his.PType = fmt.Sprintf("%d", reg_type)
  21189. service.UpdateHisPatientThree(&his)
  21190. data := make(map[string]interface{})
  21191. if settle_accounts_type == 1 { //日结
  21192. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21193. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21194. } else {
  21195. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21196. }
  21197. data["pre"] = prescriptions
  21198. } else { //月结
  21199. start_time_str := c.GetString("start_time")
  21200. end_time_str := c.GetString("end_time")
  21201. timeLayout := "2006-01-02"
  21202. loc, _ := time.LoadLocation("Local")
  21203. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21204. if err != nil {
  21205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21206. return
  21207. }
  21208. recordStartTime := theStartTime.Unix()
  21209. start_time = recordStartTime
  21210. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21211. if err != nil {
  21212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21213. return
  21214. }
  21215. recordEndTime := theEndTime.Unix()
  21216. end_time = recordEndTime
  21217. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21218. data["pre"] = prescriptions
  21219. }
  21220. client := &http.Client{}
  21221. data["psn_no"] = his.PsnNo
  21222. data["mdtrt_id"] = his.Number
  21223. data["chrg_bchno"] = chrg_bchno
  21224. data["org_name"] = miConfig.OrgName
  21225. data["doctor"] = doctor_info.UserName
  21226. data["doctor_id"] = doctor_info.DoctorNumber
  21227. data["dept"] = department.Name
  21228. data["fixmedins_code"] = miConfig.Code
  21229. data["opter"] = roles.UserName
  21230. data["dept_code"] = department.Number
  21231. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21232. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21233. data["secret_key"] = miConfig.SecretKey
  21234. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21235. data["url"] = miConfig.Url
  21236. data["ak"] = miConfig.AccessKey
  21237. data["new_doctor_name"] = patientPrescription.Doctor
  21238. if his.Insutype == "390" {
  21239. if reg_type == 992102 {
  21240. data["diag_code"] = "ZDZ940"
  21241. }
  21242. if reg_type == 140104 {
  21243. data["diag_code"] = sickConfig.CountryCode
  21244. }
  21245. if reg_type == 14 {
  21246. data["diag_code"] = sickConfig.CountryCode
  21247. }
  21248. } else if his.Insutype == "310" {
  21249. if reg_type == 992102 {
  21250. data["diag_code"] = "ZDZ940"
  21251. }
  21252. if reg_type == 14 {
  21253. data["diag_code"] = sickConfig.CountryCode
  21254. }
  21255. }
  21256. data["cainfo"] = miConfig.Cainfo
  21257. data["opter"] = roles.UserName
  21258. var ids []int64
  21259. for _, item := range prescriptions {
  21260. ids = append(ids, item.ID)
  21261. }
  21262. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21263. if config.IsOpen == 1 { //对接了医保,走医保流程
  21264. var res ResultFour
  21265. var resFour10265 ResultFour10265
  21266. if miConfig.MdtrtareaAdmvs == "421300" {
  21267. bytesData, _ := json.Marshal(data)
  21268. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21269. resp, _ := client.Do(req)
  21270. defer resp.Body.Close()
  21271. body, ioErr := ioutil.ReadAll(resp.Body)
  21272. if ioErr != nil {
  21273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21275. return
  21276. }
  21277. var respJSON map[string]interface{}
  21278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21281. return
  21282. }
  21283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21284. userJSONBytes, _ := json.Marshal(respJSON)
  21285. fmt.Println("log")
  21286. fmt.Println(string(userJSONBytes))
  21287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21288. utils.ErrorLog("解析失败:%v", err)
  21289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21290. return
  21291. }
  21292. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21293. bytesData, _ := json.Marshal(data)
  21294. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21295. resp, _ := client.Do(req)
  21296. defer resp.Body.Close()
  21297. body, ioErr := ioutil.ReadAll(resp.Body)
  21298. if ioErr != nil {
  21299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21301. return
  21302. }
  21303. var respJSON map[string]interface{}
  21304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21307. return
  21308. }
  21309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21310. userJSONBytes, _ := json.Marshal(respJSON)
  21311. fmt.Println("log")
  21312. fmt.Println(string(userJSONBytes))
  21313. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21314. utils.ErrorLog("解析失败:%v", err)
  21315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21316. return
  21317. }
  21318. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21319. bytesData, _ := json.Marshal(data)
  21320. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21321. resp, _ := client.Do(req)
  21322. defer resp.Body.Close()
  21323. body, ioErr := ioutil.ReadAll(resp.Body)
  21324. if ioErr != nil {
  21325. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21327. return
  21328. }
  21329. var respJSON map[string]interface{}
  21330. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21331. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21333. return
  21334. }
  21335. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21336. userJSONBytes, _ := json.Marshal(respJSON)
  21337. fmt.Println("log")
  21338. fmt.Println(string(userJSONBytes))
  21339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21340. utils.ErrorLog("解析失败:%v", err)
  21341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21342. return
  21343. }
  21344. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21345. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21346. if result3101.Infcode == "0" {
  21347. if len(result3101.Output.Result) > 0 {
  21348. var errMsgs []string
  21349. for _, item := range result3101.Output.Result {
  21350. errMsgs = append(errMsgs, item.VolaCont)
  21351. }
  21352. c.ServeSuccessJSON(map[string]interface{}{
  21353. "failed_code": -10,
  21354. "msg": errMsgs,
  21355. })
  21356. return
  21357. } else {
  21358. if miConfig.MdtrtareaAdmvs == "320921" {
  21359. data["doctor_id"] = "D320923012139"
  21360. } else {
  21361. data["doctor_id"] = "D371621008686"
  21362. }
  21363. bytesData, _ := json.Marshal(data)
  21364. var req *http.Request
  21365. if miConfig.MdtrtareaAdmvs == "320921" {
  21366. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21367. } else {
  21368. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21369. }
  21370. resp, _ := client.Do(req)
  21371. defer resp.Body.Close()
  21372. body, ioErr := ioutil.ReadAll(resp.Body)
  21373. if ioErr != nil {
  21374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21376. return
  21377. }
  21378. var respJSON map[string]interface{}
  21379. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21382. return
  21383. }
  21384. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21385. userJSONBytes, _ := json.Marshal(respJSON)
  21386. fmt.Println("log")
  21387. fmt.Println(string(userJSONBytes))
  21388. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21389. utils.ErrorLog("解析失败:%v", err)
  21390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21391. return
  21392. }
  21393. res.InfRefmsgid = resFour10265.InfRefmsgid
  21394. res.Output = resFour10265.Output
  21395. res.ErrMsg = resFour10265.ErrMsg
  21396. res.Cainfo = resFour10265.Cainfo
  21397. res.WarnMsg = resFour10265.WarnMsg
  21398. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21399. res.Infcode = infocode
  21400. }
  21401. }
  21402. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21403. var pagesize int = 5
  21404. var start int = 1
  21405. var stop int
  21406. var pagecount int
  21407. var curpage int
  21408. data["doctor_id"] = doctor_info.DoctorNumber
  21409. var res2 ResultFour
  21410. //var result res.
  21411. //总页数,向上取整,注意除之前要先转换类型为float64
  21412. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  21413. for curpage = 1; curpage <= pagecount; curpage++ {
  21414. if curpage == 1 {
  21415. start = 1
  21416. } else {
  21417. start = (curpage-1)*pagesize + 1
  21418. }
  21419. stop = curpage * pagesize
  21420. if stop > len(prescriptions) {
  21421. stop = len(prescriptions)
  21422. }
  21423. //var requestLog string
  21424. data["pre"] = prescriptions[start-1 : stop]
  21425. fmt.Println(data["pre"])
  21426. bytesData, _ := json.Marshal(data)
  21427. var req *http.Request
  21428. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  21429. resp, _ := client.Do(req)
  21430. defer resp.Body.Close()
  21431. body, ioErr := ioutil.ReadAll(resp.Body)
  21432. if ioErr != nil {
  21433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21435. return
  21436. }
  21437. var respJSON map[string]interface{}
  21438. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21441. return
  21442. }
  21443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21444. userJSONBytes, _ := json.Marshal(respJSON)
  21445. fmt.Println("log")
  21446. fmt.Println(string(userJSONBytes))
  21447. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21448. utils.ErrorLog("解析失败:%v", err)
  21449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21450. return
  21451. }
  21452. res.InfRefmsgid = resFour10265.InfRefmsgid
  21453. res.Output = resFour10265.Output
  21454. res.ErrMsg = resFour10265.ErrMsg
  21455. res.Cainfo = resFour10265.Cainfo
  21456. res.WarnMsg = resFour10265.WarnMsg
  21457. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21458. res.Infcode = infocode
  21459. if infocode == 0 {
  21460. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  21461. } else {
  21462. isSuccess = false
  21463. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  21464. res.Infcode = -1
  21465. res.ErrMsg = resFour10265.ErrMsg
  21466. errlog := &models.HisOrderError{
  21467. UserOrgId: adminUser.CurrentOrgId,
  21468. Ctime: time.Now().Unix(),
  21469. Mtime: time.Now().Unix(),
  21470. Number: chrg_bchno,
  21471. ErrMsg: "",
  21472. Status: 1,
  21473. PatientId: id,
  21474. RecordTime: recordDateTime,
  21475. Stage: 4,
  21476. }
  21477. service.CreateErrMsgLog(errlog)
  21478. }
  21479. }
  21480. if isSuccess {
  21481. res.Infcode = 0
  21482. res.Output.Result = res2.Output.Result
  21483. } else {
  21484. order := &models.HisOrder{
  21485. UserOrgId: adminUser.CurrentOrgId,
  21486. HisPatientId: his.ID,
  21487. PatientId: his.PatientId,
  21488. SettleAccountsDate: recordDateTime,
  21489. Ctime: time.Now().Unix(),
  21490. Mtime: time.Now().Unix(),
  21491. MdtrtId: his.Number,
  21492. PsnNo: his.PsnNo,
  21493. MedType: strconv.FormatInt(reg_type, 10),
  21494. Status: 1,
  21495. Number: chrg_bchno,
  21496. Infcode: res.Infcode,
  21497. WarnMsg: res.WarnMsg,
  21498. Cainfo: res.Cainfo,
  21499. ErrMsg: res.ErrMsg,
  21500. RespondTime: res.RefmsgTime,
  21501. InfRefmsgid: res.InfRefmsgid,
  21502. OrderStatus: 1,
  21503. IsMedicineInsurance: 1,
  21504. SettleType: settle_accounts_type,
  21505. SettleStartTime: start_time,
  21506. SettleEndTime: end_time,
  21507. Creator: roles.AdminUserId,
  21508. Modify: roles.AdminUserId,
  21509. PType: 2,
  21510. Diagnosis: diagnosis_id,
  21511. }
  21512. err = service.CreateOrder(order)
  21513. if err != nil {
  21514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21515. return
  21516. }
  21517. c.ServeSuccessJSON(map[string]interface{}{
  21518. "failed_code": -10,
  21519. "msg": res2.ErrMsg,
  21520. })
  21521. return
  21522. }
  21523. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21524. 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)
  21525. var dat map[string]interface{}
  21526. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21527. fmt.Println(dat)
  21528. } else {
  21529. fmt.Println(err)
  21530. }
  21531. saveLog(result, request_log, "2204", "上传费用明细")
  21532. userJSONBytes, _ := json.Marshal(dat)
  21533. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21534. utils.ErrorLog("解析失败:%v", err)
  21535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21536. return
  21537. }
  21538. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21539. 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, "", "")
  21540. var dat map[string]interface{}
  21541. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21542. fmt.Println(dat)
  21543. } else {
  21544. fmt.Println(err)
  21545. }
  21546. saveLog(result, request_log, "2204", "上传费用明细")
  21547. userJSONBytes, _ := json.Marshal(dat)
  21548. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21549. utils.ErrorLog("解析失败:%v", err)
  21550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21551. return
  21552. }
  21553. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21554. bytesData, _ := json.Marshal(data)
  21555. var req *http.Request
  21556. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  21557. resp, _ := client.Do(req)
  21558. defer resp.Body.Close()
  21559. body, ioErr := ioutil.ReadAll(resp.Body)
  21560. if ioErr != nil {
  21561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21563. return
  21564. }
  21565. var respJSON map[string]interface{}
  21566. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21569. return
  21570. }
  21571. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21572. if status == "0" {
  21573. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21574. c.ServeSuccessJSON(map[string]interface{}{
  21575. "failed_code": -10,
  21576. "msg": err_msg,
  21577. })
  21578. return
  21579. }
  21580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21581. userJSONBytes, _ := json.Marshal(respJSON)
  21582. fmt.Println("log")
  21583. fmt.Println(string(userJSONBytes))
  21584. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21585. utils.ErrorLog("解析失败:%v", err)
  21586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21587. return
  21588. }
  21589. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21590. 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, "", "")
  21591. var dat map[string]interface{}
  21592. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21593. fmt.Println(dat)
  21594. } else {
  21595. fmt.Println(err)
  21596. }
  21597. saveLog(result, request_log, "2204", "上传费用明细")
  21598. userJSONBytes, _ := json.Marshal(dat)
  21599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21600. utils.ErrorLog("解析失败:%v", err)
  21601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21602. return
  21603. }
  21604. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21605. bytesData, _ := json.Marshal(data)
  21606. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  21607. resp, _ := client.Do(req)
  21608. defer resp.Body.Close()
  21609. body, ioErr := ioutil.ReadAll(resp.Body)
  21610. if ioErr != nil {
  21611. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21613. return
  21614. }
  21615. var respJSON map[string]interface{}
  21616. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21617. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21619. return
  21620. }
  21621. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21622. userJSONBytes, _ := json.Marshal(respJSON)
  21623. fmt.Println("log")
  21624. fmt.Println(string(userJSONBytes))
  21625. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21626. utils.ErrorLog("解析失败:%v", err)
  21627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21628. return
  21629. }
  21630. } else {
  21631. if miConfig.MdtrtareaAdmvs == "441202" {
  21632. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21633. if result3101.Infcode == 0 {
  21634. if len(result3101.Output.Result) > 0 {
  21635. var errMsgs []string
  21636. for _, item := range result3101.Output.Result {
  21637. errMsgs = append(errMsgs, item.VolaCont)
  21638. }
  21639. c.ServeSuccessJSON(map[string]interface{}{
  21640. "failed_code": -10,
  21641. "msg": errMsgs,
  21642. })
  21643. return
  21644. } else {
  21645. 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)
  21646. var dat map[string]interface{}
  21647. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21648. fmt.Println(dat)
  21649. } else {
  21650. fmt.Println(err)
  21651. }
  21652. saveLog(result, request_log, "2204", "上传费用明细")
  21653. userJSONBytes, _ := json.Marshal(dat)
  21654. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21655. utils.ErrorLog("解析失败:%v", err)
  21656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21657. return
  21658. }
  21659. }
  21660. } else {
  21661. c.ServeSuccessJSON(map[string]interface{}{
  21662. "failed_code": -10,
  21663. "msg": result3101.ErrMsg,
  21664. })
  21665. return
  21666. }
  21667. } else {
  21668. if miConfig.Code == "H15049901371" {
  21669. 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)
  21670. var dat map[string]interface{}
  21671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21672. fmt.Println(dat)
  21673. } else {
  21674. fmt.Println(err)
  21675. }
  21676. saveLog(result, request_log, "2204", "上传费用明细")
  21677. userJSONBytes, _ := json.Marshal(dat)
  21678. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21679. utils.ErrorLog("解析失败:%v", err)
  21680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21681. return
  21682. }
  21683. res.InfRefmsgid = resFour10265.InfRefmsgid
  21684. res.Output = resFour10265.Output
  21685. res.ErrMsg = resFour10265.ErrMsg
  21686. res.Cainfo = resFour10265.Cainfo
  21687. res.WarnMsg = resFour10265.WarnMsg
  21688. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21689. res.Infcode = infocode
  21690. } else {
  21691. 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)
  21692. var dat map[string]interface{}
  21693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21694. fmt.Println(dat)
  21695. } else {
  21696. fmt.Println(err)
  21697. }
  21698. saveLog(result, request_log, "2204", "上传费用明细")
  21699. userJSONBytes, _ := json.Marshal(dat)
  21700. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21701. utils.ErrorLog("解析失败:%v", err)
  21702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21703. return
  21704. }
  21705. }
  21706. }
  21707. }
  21708. var total_two float64
  21709. if res.Infcode == 0 {
  21710. order := &models.HisOrder{
  21711. UserOrgId: adminUser.CurrentOrgId,
  21712. HisPatientId: his.ID,
  21713. PatientId: his.PatientId,
  21714. SettleAccountsDate: recordDateTime,
  21715. Ctime: time.Now().Unix(),
  21716. Mtime: time.Now().Unix(),
  21717. MdtrtId: his.Number,
  21718. PsnNo: his.PsnNo,
  21719. MedType: strconv.FormatInt(reg_type, 10),
  21720. Status: 1,
  21721. Number: chrg_bchno,
  21722. Infcode: res.Infcode,
  21723. WarnMsg: res.WarnMsg,
  21724. Cainfo: res.Cainfo,
  21725. ErrMsg: res.ErrMsg,
  21726. RespondTime: res.RefmsgTime,
  21727. InfRefmsgid: res.InfRefmsgid,
  21728. OrderStatus: 1,
  21729. IsMedicineInsurance: 1,
  21730. SettleType: settle_accounts_type,
  21731. SettleStartTime: start_time,
  21732. SettleEndTime: end_time,
  21733. Creator: roles.AdminUserId,
  21734. Modify: roles.AdminUserId,
  21735. PType: 2,
  21736. Diagnosis: diagnosis_id,
  21737. }
  21738. err = service.CreateOrder(order)
  21739. if err != nil {
  21740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21741. return
  21742. }
  21743. for _, item := range res.Output.Result {
  21744. temp := strings.Split(item.FeedetlSn, "-")
  21745. var advice_id int64 = 0
  21746. var project_id int64 = 0
  21747. var types int64 = 0
  21748. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21749. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21750. if temp[1] == "1" {
  21751. advice_id = id
  21752. project_id = 0
  21753. } else if temp[1] == "2" {
  21754. advice_id = 0
  21755. project_id = id
  21756. }
  21757. total_two = total_two + item.DetItemFeeSumamt
  21758. info := &models.HisOrderInfo{
  21759. OrderNumber: order.Number,
  21760. FeedetlSn: item.FeedetlSn,
  21761. UploadDate: time.Now().Unix(),
  21762. AdviceId: advice_id,
  21763. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21764. Cnt: item.Cnt,
  21765. Pric: float64(item.Pric),
  21766. PatientId: his.PatientId,
  21767. PricUplmtAmt: item.PricUplmtAmt,
  21768. SelfpayProp: item.SelfpayProp,
  21769. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21770. OverlmtAmt: item.OverlmtAmt,
  21771. PreselfpayAmt: item.PreselfpayAmt,
  21772. BasMednFlag: item.BasMednFlag,
  21773. MedChrgitmType: item.MedChrgitmType,
  21774. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21775. Status: 1,
  21776. Memo: item.Memo,
  21777. Mtime: time.Now().Unix(),
  21778. InscpScpAmt: item.InscpScpAmt,
  21779. DrtReimFlag: item.DrtReimFlag,
  21780. Ctime: time.Now().Unix(),
  21781. ListSpItemFlag: item.ListSpItemFlag,
  21782. ChldMedcFlag: item.ChldMedcFlag,
  21783. LmtUsedFlag: item.LmtUsedFlag,
  21784. ChrgitmLv: item.ChrgitmLv,
  21785. UserOrgId: adminUser.CurrentOrgId,
  21786. HisPatientId: his.ID,
  21787. OrderId: order.ID,
  21788. ProjectId: project_id,
  21789. Type: types,
  21790. }
  21791. service.CreateOrderInfo(info)
  21792. }
  21793. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21794. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21795. var total float64
  21796. for _, item := range prescriptions {
  21797. if item.Type == 1 { //药品
  21798. for _, subItem := range item.HisDoctorAdviceInfo {
  21799. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21800. total_one := price * subItem.PrescribingNumber
  21801. fmt.Println("subItem")
  21802. fmt.Println(subItem.Price)
  21803. fmt.Println("price")
  21804. fmt.Println(price)
  21805. fmt.Println("total_one")
  21806. fmt.Println(total_one)
  21807. total = total + total_one
  21808. fmt.Println(total)
  21809. }
  21810. }
  21811. if item.Type == 2 { //项目
  21812. for _, subItem := range item.HisPrescriptionProject {
  21813. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21814. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21815. total_one := price * cnt
  21816. total = total + total_one
  21817. }
  21818. }
  21819. }
  21820. allTotal := fmt.Sprintf("%.2f", total)
  21821. if res.Infcode == 0 {
  21822. var rf []*ResultFive
  21823. json.Unmarshal([]byte(his.Iinfo), &rf)
  21824. chrg_bchno := chrg_bchno
  21825. cert_no := his.Certno
  21826. var insutypes []string
  21827. var insutype string
  21828. var is390 int = 0
  21829. var is310 int = 0
  21830. for _, item := range rf {
  21831. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21832. insutypes = append(insutypes, item.Insutype)
  21833. }
  21834. }
  21835. if len(insutypes) == 1 {
  21836. insutype = insutypes[0]
  21837. } else {
  21838. for _, i := range insutypes {
  21839. if i == "390" {
  21840. is390 = 1
  21841. }
  21842. if i == "310" {
  21843. is310 = 1
  21844. }
  21845. }
  21846. }
  21847. if is390 == 1 {
  21848. insutype = "390"
  21849. }
  21850. if is310 == 1 {
  21851. insutype = "310"
  21852. }
  21853. if len(insutypes) == 0 {
  21854. insutype = "390"
  21855. }
  21856. if len(insutypes) == 2 {
  21857. insutype = strconv.FormatInt(his.SocialType, 10)
  21858. }
  21859. //insutype = "390"
  21860. if his.IdCardType == 1 {
  21861. cert_no = his.MedicalInsuranceNumber
  21862. } else {
  21863. cert_no = his.Certno
  21864. }
  21865. var res ResultSeven
  21866. var ahres ResultSevenAH
  21867. var resSeven10265 ResultSeven10265
  21868. var resSeven10265Two ResultSeven10265Two
  21869. var gzresSeven10265Two GZResultSeven10265Two
  21870. if miConfig.MdtrtareaAdmvs == "421300" {
  21871. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21872. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21873. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21874. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21875. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21876. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21877. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21878. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21879. resp, requestErr := http.Get(api)
  21880. if requestErr != nil {
  21881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21882. return
  21883. }
  21884. body, ioErr := ioutil.ReadAll(resp.Body)
  21885. if ioErr != nil {
  21886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21888. return
  21889. }
  21890. var respJSON map[string]interface{}
  21891. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21894. return
  21895. }
  21896. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21897. result, _ := json.Marshal(respJSON)
  21898. fmt.Println("log")
  21899. fmt.Println(string(result))
  21900. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21901. utils.ErrorLog("解析失败:%v", err)
  21902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21903. return
  21904. }
  21905. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21906. if reg_type == 11 && his.Insutype == "390" {
  21907. reg_type = 110104
  21908. }
  21909. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21910. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21911. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21912. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21913. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21914. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21915. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21916. resp, requestErr := http.Get(api)
  21917. if requestErr != nil {
  21918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21919. return
  21920. }
  21921. body, ioErr := ioutil.ReadAll(resp.Body)
  21922. if ioErr != nil {
  21923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21925. return
  21926. }
  21927. var respJSON map[string]interface{}
  21928. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21931. return
  21932. }
  21933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21934. result, _ := json.Marshal(respJSON)
  21935. fmt.Println("log")
  21936. fmt.Println(string(result))
  21937. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21938. utils.ErrorLog("解析失败:%v", err)
  21939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21940. return
  21941. }
  21942. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21943. if reg_type == 11 && his.Insutype == "390" {
  21944. reg_type = 110104
  21945. }
  21946. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21947. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21948. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21950. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21951. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21952. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21953. resp, requestErr := http.Get(api)
  21954. if requestErr != nil {
  21955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21956. return
  21957. }
  21958. body, ioErr := ioutil.ReadAll(resp.Body)
  21959. if ioErr != nil {
  21960. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21962. return
  21963. }
  21964. var respJSON map[string]interface{}
  21965. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21968. return
  21969. }
  21970. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21971. result, _ := json.Marshal(respJSON)
  21972. fmt.Println("log")
  21973. fmt.Println(string(result))
  21974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21975. utils.ErrorLog("解析失败:%v", err)
  21976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21977. return
  21978. }
  21979. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21980. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21981. if result3101.Infcode == "0" {
  21982. if len(result3101.Output.Result) > 0 {
  21983. var errMsgs []string
  21984. for _, item := range result3101.Output.Result {
  21985. errMsgs = append(errMsgs, item.VolaCont)
  21986. }
  21987. c.ServeSuccessJSON(map[string]interface{}{
  21988. "failed_code": -10,
  21989. "msg": errMsgs,
  21990. })
  21991. return
  21992. } else {
  21993. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21994. if his.IdCardType != 4 {
  21995. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21996. bas := strings.Split(psn_info.CardInfo, "|")
  21997. if his.IdCardType == 1 {
  21998. cert_no = bas[2]
  21999. } else {
  22000. cert_no = bas[1]
  22001. }
  22002. } else {
  22003. cert_no = his.Certno
  22004. }
  22005. //江苏地区国家医保医疗类别
  22006. //职工透析:医疗类别选特殊情况门诊9933
  22007. //居民血透门慢: 医疗类别选门诊慢病1402
  22008. //var med_type string
  22009. //if his.Insutype == "310" {
  22010. // if reg_type == 14 {
  22011. // med_type = "9933"
  22012. // } else if reg_type == 11 {
  22013. // med_type = "11"
  22014. //
  22015. // }
  22016. //} else if his.Insutype == "390" {
  22017. // if reg_type == 14 {
  22018. // med_type = "1402"
  22019. // } else if reg_type == 11 {
  22020. // med_type = "11"
  22021. // }
  22022. //}
  22023. var api string
  22024. if miConfig.MdtrtareaAdmvs == "320921" {
  22025. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22026. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22027. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22028. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22029. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22030. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22031. "&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
  22032. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22033. } else {
  22034. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22035. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22036. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22037. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22038. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22039. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22040. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22041. "&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
  22042. }
  22043. resp, requestErr := http.Get(api)
  22044. if requestErr != nil {
  22045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22046. return
  22047. }
  22048. body, ioErr := ioutil.ReadAll(resp.Body)
  22049. if ioErr != nil {
  22050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22052. return
  22053. }
  22054. var respJSON map[string]interface{}
  22055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22058. return
  22059. }
  22060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22061. result, _ := json.Marshal(respJSON)
  22062. fmt.Println("log")
  22063. fmt.Println(string(result))
  22064. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22065. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22066. utils.ErrorLog("解析失败:%v", err)
  22067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22068. return
  22069. }
  22070. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22071. res.Output = resSeven10265.Output
  22072. res.ErrMsg = resSeven10265.ErrMsg
  22073. res.Cainfo = resSeven10265.Cainfo
  22074. res.WarnMsg = resSeven10265.WarnMsg
  22075. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22076. res.Infcode = infocode
  22077. } else {
  22078. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22079. utils.ErrorLog("解析失败:%v", err)
  22080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22081. return
  22082. }
  22083. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22084. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22085. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22086. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22087. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22088. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22089. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22090. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22091. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22092. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22093. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22094. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22095. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22096. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22097. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22098. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22099. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22100. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22101. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22102. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22103. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22104. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22105. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22106. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22107. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22108. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22109. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22110. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22111. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22112. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22113. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22114. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22115. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22116. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22117. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22118. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22119. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22120. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22121. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22122. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22123. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22124. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22125. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22126. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22127. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22128. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22129. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22130. res.ErrMsg = resSeven10265Two.ErrMsg
  22131. res.Cainfo = resSeven10265Two.Cainfo
  22132. res.WarnMsg = resSeven10265Two.WarnMsg
  22133. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22134. res.Infcode = infocode
  22135. }
  22136. }
  22137. }
  22138. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22139. psn_info, _ := service.GetPsnByPatientId(id)
  22140. var verify_number string
  22141. if psn_info.IdCardType == 4 {
  22142. verify_number = psn_info.VerifyNumber
  22143. } else if psn_info.IdCardType == 1 {
  22144. bas := strings.Split(psn_info.CardInfo, "|")
  22145. cardNumber := bas[2]
  22146. verify_number = cardNumber
  22147. } else {
  22148. psn_info.IdCardType = 2
  22149. verify_number = psn_info.Certno
  22150. }
  22151. var api string
  22152. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22153. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22154. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22155. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22156. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22157. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22158. "&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
  22159. resp, requestErr := http.Get(api)
  22160. if requestErr != nil {
  22161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22162. return
  22163. }
  22164. body, ioErr := ioutil.ReadAll(resp.Body)
  22165. if ioErr != nil {
  22166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22168. return
  22169. }
  22170. var respJSON map[string]interface{}
  22171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22174. return
  22175. }
  22176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22177. result, _ := json.Marshal(respJSON)
  22178. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22179. utils.ErrorLog("解析失败:%v", err)
  22180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22181. return
  22182. }
  22183. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22184. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22185. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22186. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22187. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22188. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22189. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22190. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22191. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22192. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22193. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22194. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22195. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22196. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22197. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22198. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22199. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22200. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22201. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22202. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22203. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22204. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22205. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22206. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22207. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22208. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22209. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22210. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22211. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22212. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22213. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22214. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22215. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22216. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22217. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22218. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22219. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22220. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22221. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22222. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22223. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22224. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22225. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22226. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22227. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22228. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22229. res.ErrMsg = resSeven10265.ErrMsg
  22230. res.Cainfo = resSeven10265.Cainfo
  22231. res.WarnMsg = resSeven10265.WarnMsg
  22232. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22233. res.Infcode = infocode
  22234. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22235. acct_used_flag := "1"
  22236. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22237. var result string
  22238. var request_log string
  22239. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22240. 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)
  22241. } else {
  22242. 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)
  22243. }
  22244. var dat map[string]interface{}
  22245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22246. fmt.Println(dat)
  22247. } else {
  22248. fmt.Println(err)
  22249. }
  22250. saveLog(result, request_log, "2206", "预结算")
  22251. userJSONBytes, _ := json.Marshal(dat)
  22252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22253. utils.ErrorLog("解析失败:%v", err)
  22254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22255. return
  22256. }
  22257. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22258. var result string
  22259. var request_log string
  22260. if his.IdCardType == 2 {
  22261. 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, "")
  22262. } else if his.IdCardType == 1 {
  22263. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22264. bas := strings.Split(psn_info.CardInfo, "|")
  22265. basNumber := bas[2]
  22266. card_sn := bas[3]
  22267. var rf []*ResultFive
  22268. json.Unmarshal([]byte(his.Iinfo), &rf)
  22269. var psn_type string
  22270. for _, item := range rf {
  22271. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  22272. psn_type = item.PsnType
  22273. }
  22274. }
  22275. 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)
  22276. } else {
  22277. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22278. result, request_log = service.Jxyb2206(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, "")
  22279. }
  22280. var dat map[string]interface{}
  22281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22282. fmt.Println(dat)
  22283. } else {
  22284. fmt.Println(err)
  22285. }
  22286. saveLog(result, request_log, "2206", "预结算")
  22287. userJSONBytes, _ := json.Marshal(dat)
  22288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22289. utils.ErrorLog("解析失败:%v", err)
  22290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22291. return
  22292. }
  22293. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22294. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22295. if his.IdCardType == 4 {
  22296. psn_info.VerifyNumber = psn_info.VerifyNumber
  22297. cert_no = psn_info.Certno
  22298. } else if his.IdCardType == 2 {
  22299. cert_no = psn_info.Certno
  22300. psn_info.VerifyNumber = psn_info.Certno
  22301. } else {
  22302. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22303. bas := strings.Split(psn_info.CardInfo, "|")
  22304. if his.IdCardType == 1 {
  22305. cert_no = bas[2]
  22306. } else {
  22307. cert_no = bas[1]
  22308. }
  22309. }
  22310. var api string
  22311. var med_type string
  22312. if his.Insutype == "390" {
  22313. if reg_type == 992102 {
  22314. med_type = "992102"
  22315. }
  22316. if reg_type == 140104 {
  22317. med_type = "140104"
  22318. }
  22319. if reg_type == 14 {
  22320. med_type = "140104"
  22321. }
  22322. } else if his.Insutype == "310" {
  22323. if reg_type == 992102 {
  22324. med_type = "992102"
  22325. }
  22326. if reg_type == 14 {
  22327. med_type = "14"
  22328. }
  22329. }
  22330. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22331. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22332. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22333. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22334. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22335. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22336. "&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
  22337. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22338. resp, requestErr := http.Get(api)
  22339. if requestErr != nil {
  22340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22341. return
  22342. }
  22343. body, ioErr := ioutil.ReadAll(resp.Body)
  22344. if ioErr != nil {
  22345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22347. return
  22348. }
  22349. var respJSON map[string]interface{}
  22350. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22353. return
  22354. }
  22355. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22356. if status == "0" {
  22357. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22358. c.ServeSuccessJSON(map[string]interface{}{
  22359. "failed_code": -10,
  22360. "msg": err_msg,
  22361. })
  22362. return
  22363. }
  22364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22365. result, _ := json.Marshal(respJSON)
  22366. fmt.Println("log")
  22367. fmt.Println(string(result))
  22368. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  22369. utils.ErrorLog("解析失败:%v", err)
  22370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22371. return
  22372. }
  22373. res.InfRefmsgid = ahres.InfRefmsgid
  22374. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22375. // 创建对应的Time类型
  22376. t := time.UnixMilli(timestamp)
  22377. // 格式化成指定的日期字符串
  22378. str := t.Format("2006-01-02 15:04:05")
  22379. res.Output.Setlinfo.SetlTime = str
  22380. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22381. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22382. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22383. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22384. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22385. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22386. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22387. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22388. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22389. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22390. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22391. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22392. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22393. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22394. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22395. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22396. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22397. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22398. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22399. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22400. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22401. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22402. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22403. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22404. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22405. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22406. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22407. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22408. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22409. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22410. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22411. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22412. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22413. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  22414. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22415. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  22416. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  22417. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  22418. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  22419. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22420. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  22421. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22422. //res.Output.Setldetail = ahres.Output.Setldetail
  22423. res.ErrMsg = ahres.ErrMsg
  22424. res.Cainfo = ahres.Cainfo
  22425. res.WarnMsg = ahres.WarnMsg
  22426. res.Infcode = ahres.Infcode
  22427. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22428. var result string
  22429. var request_log string
  22430. if his.IdCardType == 2 {
  22431. 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")
  22432. } else if his.IdCardType == 1 {
  22433. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22434. bas := strings.Split(psn_info.CardInfo, "|")
  22435. basNumber := bas[2]
  22436. card_sn := bas[3]
  22437. 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")
  22438. } else {
  22439. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22440. 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")
  22441. }
  22442. var dat map[string]interface{}
  22443. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22444. fmt.Println(dat)
  22445. } else {
  22446. fmt.Println(err)
  22447. }
  22448. saveLog(result, request_log, "2206", "预结算")
  22449. userJSONBytes, _ := json.Marshal(dat)
  22450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22451. utils.ErrorLog("解析失败:%v", err)
  22452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22453. return
  22454. }
  22455. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22456. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22457. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22458. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22459. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22460. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22461. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22462. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22463. resp, requestErr := http.Get(api)
  22464. if requestErr != nil {
  22465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22466. return
  22467. }
  22468. body, ioErr := ioutil.ReadAll(resp.Body)
  22469. if ioErr != nil {
  22470. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22472. return
  22473. }
  22474. var respJSON map[string]interface{}
  22475. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22476. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22478. return
  22479. }
  22480. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22481. result, _ := json.Marshal(respJSON)
  22482. fmt.Println("log")
  22483. fmt.Println(string(result))
  22484. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22485. utils.ErrorLog("解析失败:%v", err)
  22486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22487. return
  22488. }
  22489. } else {
  22490. if miConfig.MdtrtareaAdmvs == "441202" {
  22491. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22492. if result3101.Infcode == 0 {
  22493. if len(result3101.Output.Result) > 0 {
  22494. var errMsgs []string
  22495. for _, item := range result3101.Output.Result {
  22496. errMsgs = append(errMsgs, item.VolaCont)
  22497. }
  22498. c.ServeSuccessJSON(map[string]interface{}{
  22499. "failed_code": -10,
  22500. "msg": errMsgs,
  22501. })
  22502. return
  22503. } else {
  22504. var result string
  22505. var request_log string
  22506. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22507. allTotal = fmt.Sprintf("%.2f", total_two)
  22508. if his.IdCardType == 4 {
  22509. 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)
  22510. } else {
  22511. 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)
  22512. }
  22513. var dat map[string]interface{}
  22514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22515. fmt.Println(dat)
  22516. } else {
  22517. fmt.Println(err)
  22518. }
  22519. saveLog(result, request_log, "2206", "预结算")
  22520. //userJSONBytes, _ := json.Marshal(dat)
  22521. //
  22522. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22523. // utils.ErrorLog("解析失败:%v", err)
  22524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22525. // return
  22526. //}
  22527. userJSONBytes, _ := json.Marshal(dat)
  22528. if miConfig.Code == "H15049901371" {
  22529. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22530. utils.ErrorLog("解析失败:%v", err)
  22531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22532. return
  22533. }
  22534. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22535. res.Output = resSeven10265.Output
  22536. res.ErrMsg = resSeven10265.ErrMsg
  22537. res.Cainfo = resSeven10265.Cainfo
  22538. res.WarnMsg = resSeven10265.WarnMsg
  22539. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22540. res.Infcode = infocode
  22541. } else {
  22542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22543. utils.ErrorLog("解析失败:%v", err)
  22544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22545. return
  22546. }
  22547. }
  22548. }
  22549. } else {
  22550. c.ServeSuccessJSON(map[string]interface{}{
  22551. "failed_code": -10,
  22552. "msg": result3101.ErrMsg,
  22553. })
  22554. return
  22555. }
  22556. } else {
  22557. var result string
  22558. var request_log string
  22559. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22560. allTotal = fmt.Sprintf("%.2f", total_two)
  22561. if his.IdCardType == 4 {
  22562. 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)
  22563. } else {
  22564. 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)
  22565. }
  22566. var dat map[string]interface{}
  22567. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22568. fmt.Println(dat)
  22569. } else {
  22570. fmt.Println(err)
  22571. }
  22572. saveLog(result, request_log, "2206", "预结算")
  22573. //userJSONBytes, _ := json.Marshal(dat)
  22574. //
  22575. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22576. // utils.ErrorLog("解析失败:%v", err)
  22577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22578. // return
  22579. //}
  22580. userJSONBytes, _ := json.Marshal(dat)
  22581. if miConfig.Code == "H15049901371" {
  22582. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22583. utils.ErrorLog("解析失败:%v", err)
  22584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22585. return
  22586. }
  22587. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22588. res.Output = resSeven10265.Output
  22589. res.ErrMsg = resSeven10265.ErrMsg
  22590. res.Cainfo = resSeven10265.Cainfo
  22591. res.WarnMsg = resSeven10265.WarnMsg
  22592. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22593. res.Infcode = infocode
  22594. } else {
  22595. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22596. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22597. utils.ErrorLog("解析失败:%v", err)
  22598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22599. return
  22600. }
  22601. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22602. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22603. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22604. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22605. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22606. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22607. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22608. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22609. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22610. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22611. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22612. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22613. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22614. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22615. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22616. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22617. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22618. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22619. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22620. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22621. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22622. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22623. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22624. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22625. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22626. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22627. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22628. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22629. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22630. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22631. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22632. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22633. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22634. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22635. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22636. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22637. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22638. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22639. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22640. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22641. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22642. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22643. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22644. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22645. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22646. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22647. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22648. res.Cainfo = gzresSeven10265Two.Cainfo
  22649. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22650. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22651. //res.Infcode = infocode
  22652. } else {
  22653. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22654. utils.ErrorLog("解析失败:%v", err)
  22655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22656. return
  22657. }
  22658. }
  22659. }
  22660. }
  22661. }
  22662. utils.ErrorLog("解析失败:%v", res.Infcode)
  22663. if res.Infcode == -1 {
  22664. errlog := &models.HisOrderError{
  22665. UserOrgId: adminUser.CurrentOrgId,
  22666. Ctime: time.Now().Unix(),
  22667. Mtime: time.Now().Unix(),
  22668. Number: chrg_bchno,
  22669. ErrMsg: res.ErrMsg,
  22670. Status: 1,
  22671. PatientId: id,
  22672. RecordTime: recordDateTime,
  22673. Stage: 20,
  22674. }
  22675. service.CreateErrMsgLog(errlog)
  22676. c.ServeSuccessJSON(map[string]interface{}{
  22677. "failed_code": -10,
  22678. "msg": res.ErrMsg,
  22679. })
  22680. return
  22681. }
  22682. if res.Infcode != 0 {
  22683. errlog := &models.HisOrderError{
  22684. UserOrgId: adminUser.CurrentOrgId,
  22685. Ctime: time.Now().Unix(),
  22686. Mtime: time.Now().Unix(),
  22687. Number: chrg_bchno,
  22688. ErrMsg: res.ErrMsg,
  22689. Status: 1,
  22690. PatientId: id,
  22691. RecordTime: recordDateTime,
  22692. Stage: 20,
  22693. }
  22694. service.CreateErrMsgLog(errlog)
  22695. c.ServeSuccessJSON(map[string]interface{}{
  22696. "failed_code": -10,
  22697. "msg": res.ErrMsg,
  22698. })
  22699. return
  22700. } else {
  22701. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22702. order.OrderStatus = 1
  22703. order.IsPre = 1
  22704. order.Status = 1
  22705. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22706. order.SetlId = res.Output.Setlinfo.SetlID
  22707. order.PsnNo = res.Output.Setlinfo.PsnNo
  22708. order.PsnName = res.Output.Setlinfo.PsnName
  22709. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22710. order.Certno = res.Output.Setlinfo.Certno
  22711. order.Gend = res.Output.Setlinfo.Gend
  22712. order.Naty = res.Output.Setlinfo.Naty
  22713. order.Age = res.Output.Setlinfo.Age
  22714. order.Insutype = res.Output.Setlinfo.Insutype
  22715. order.PsnType = res.Output.Setlinfo.PsnType
  22716. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22717. order.SetlTime = res.Output.Setlinfo.SetlTime
  22718. order.AcctUsedFlag = acct_used_flag
  22719. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22720. if res.Output.Setlinfo.MedType == "140101" {
  22721. order.MedType = "14"
  22722. } else {
  22723. if res.Output.Setlinfo.MedType == "110104" {
  22724. order.MedType = "11"
  22725. } else {
  22726. order.MedType = res.Output.Setlinfo.MedType
  22727. }
  22728. }
  22729. if res.Output.Setlinfo.MedType == "992102" {
  22730. order.MedType = "992102"
  22731. }
  22732. if res.Output.Setlinfo.MedType == "140104" {
  22733. order.MedType = "140104"
  22734. }
  22735. if res.Output.Setlinfo.MedType == "14" {
  22736. order.MedType = "14"
  22737. }
  22738. if reg_type == 1112 {
  22739. order.MedType = "1112"
  22740. }
  22741. if reg_type == 1111 {
  22742. order.MedType = "1111"
  22743. }
  22744. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22745. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22746. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22747. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22748. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22749. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22750. order.HifpPay = res.Output.Setlinfo.HifpPay
  22751. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22752. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22753. order.HifesPay = res.Output.Setlinfo.HifesPay
  22754. order.HifobPay = res.Output.Setlinfo.HifobPay
  22755. order.MafPay = res.Output.Setlinfo.MafPay
  22756. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22757. order.OthPay = res.Output.Setlinfo.OthPay
  22758. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22759. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22760. order.AcctPay = res.Output.Setlinfo.AcctPay
  22761. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22762. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22763. order.Balc = res.Output.Setlinfo.Balc
  22764. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22765. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22766. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22767. order.ClrWay = res.Output.Setlinfo.ClrWay
  22768. order.Creator = order.Creator
  22769. order.Modify = roles.AdminUserId
  22770. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22771. //detailStr := string(setlDetail)
  22772. //order.SetlDetail = detailStr
  22773. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22774. err = service.UpDateOrder(order)
  22775. if err == nil {
  22776. c.ServeSuccessJSON(map[string]interface{}{
  22777. "msg": "预结算成功",
  22778. })
  22779. } else {
  22780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22781. return
  22782. }
  22783. }
  22784. } else {
  22785. adminUser := c.GetAdminUserInfo()
  22786. errlog := &models.HisOrderError{
  22787. UserOrgId: adminUser.CurrentOrgId,
  22788. Ctime: time.Now().Unix(),
  22789. Mtime: time.Now().Unix(),
  22790. ErrMsg: res.ErrMsg,
  22791. Status: 1,
  22792. PatientId: id,
  22793. RecordTime: recordDateTime,
  22794. Stage: 4,
  22795. }
  22796. service.CreateErrMsgLog(errlog)
  22797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22798. return
  22799. }
  22800. } else {
  22801. if miConfig.MdtrtareaAdmvs == "150499" {
  22802. order := &models.HisOrder{
  22803. UserOrgId: adminUser.CurrentOrgId,
  22804. HisPatientId: his.ID,
  22805. PatientId: his.PatientId,
  22806. SettleAccountsDate: recordDateTime,
  22807. Ctime: time.Now().Unix(),
  22808. Mtime: time.Now().Unix(),
  22809. MdtrtId: his.Number,
  22810. PsnNo: his.PsnNo,
  22811. MedType: strconv.FormatInt(reg_type, 10),
  22812. Status: 1,
  22813. Number: chrg_bchno,
  22814. Infcode: res.Infcode,
  22815. WarnMsg: res.WarnMsg,
  22816. Cainfo: res.Cainfo,
  22817. ErrMsg: res.ErrMsg,
  22818. RespondTime: res.RefmsgTime,
  22819. InfRefmsgid: res.InfRefmsgid,
  22820. OrderStatus: 1,
  22821. IsMedicineInsurance: 1,
  22822. SettleType: settle_accounts_type,
  22823. SettleStartTime: start_time,
  22824. SettleEndTime: end_time,
  22825. Creator: roles.AdminUserId,
  22826. Modify: roles.AdminUserId,
  22827. PType: 2,
  22828. Diagnosis: diagnosis_id,
  22829. }
  22830. err = service.CreateOrder(order)
  22831. if err != nil {
  22832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22833. return
  22834. }
  22835. }
  22836. adminUser := c.GetAdminUserInfo()
  22837. errlog := &models.HisOrderError{
  22838. UserOrgId: adminUser.CurrentOrgId,
  22839. Ctime: time.Now().Unix(),
  22840. Mtime: time.Now().Unix(),
  22841. ErrMsg: res.ErrMsg,
  22842. Status: 1,
  22843. PatientId: id,
  22844. RecordTime: recordDateTime,
  22845. Stage: 4,
  22846. }
  22847. service.CreateErrMsgLog(errlog)
  22848. c.ServeSuccessJSON(map[string]interface{}{
  22849. "failed_code": -10,
  22850. "msg": res.ErrMsg,
  22851. })
  22852. return
  22853. }
  22854. }
  22855. }
  22856. }
  22857. // 退款
  22858. func (c *HisApiController) Refund() {
  22859. order_id, _ := c.GetInt64("order_id")
  22860. admin_user_id, _ := c.GetInt64("admin_user_id")
  22861. adminUser := c.GetAdminUserInfo()
  22862. var order models.HisOrder
  22863. order, _ = service.GetHisOrderByID(order_id)
  22864. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22865. if order.ID == 0 {
  22866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22867. return
  22868. }
  22869. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22872. if config.IsOpen == 1 { //对接了医保,走医保流程
  22873. var res ResultSixteen
  22874. var ahres ResultSevenAH
  22875. var resSixteen10265 ResultSixteen10265
  22876. var resSixteen10265Two ResultSixteen10265Two
  22877. var gz ResultgzSixteen10265Two
  22878. var src_resquest string
  22879. var result string
  22880. if miConfig.MdtrtareaAdmvs == "421300" {
  22881. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22882. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22883. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22884. resp3, requestErr3 := http.Get(api3)
  22885. if requestErr3 != nil {
  22886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22887. return
  22888. }
  22889. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22890. if ioErr3 != nil {
  22891. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22893. return
  22894. }
  22895. var respJSON3 map[string]interface{}
  22896. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22897. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22899. return
  22900. }
  22901. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22902. userJSONBytes3, _ := json.Marshal(respJSON3)
  22903. fmt.Println("log")
  22904. fmt.Println(string(userJSONBytes3))
  22905. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22906. utils.ErrorLog("解析失败:%v", err)
  22907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22908. return
  22909. }
  22910. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22911. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22912. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22913. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22914. resp3, requestErr3 := http.Get(api3)
  22915. if requestErr3 != nil {
  22916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22917. return
  22918. }
  22919. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22920. if ioErr3 != nil {
  22921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22923. return
  22924. }
  22925. var respJSON3 map[string]interface{}
  22926. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22929. return
  22930. }
  22931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22932. userJSONBytes3, _ := json.Marshal(respJSON3)
  22933. fmt.Println("log")
  22934. fmt.Println(string(userJSONBytes3))
  22935. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22936. utils.ErrorLog("解析失败:%v", err)
  22937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22938. return
  22939. }
  22940. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22941. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22942. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22943. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22944. resp3, requestErr3 := http.Get(api3)
  22945. if requestErr3 != nil {
  22946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22947. return
  22948. }
  22949. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22950. if ioErr3 != nil {
  22951. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22953. return
  22954. }
  22955. var respJSON3 map[string]interface{}
  22956. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22957. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22959. return
  22960. }
  22961. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22962. userJSONBytes3, _ := json.Marshal(respJSON3)
  22963. fmt.Println("log")
  22964. fmt.Println(string(userJSONBytes3))
  22965. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22966. utils.ErrorLog("解析失败:%v", err)
  22967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22968. return
  22969. }
  22970. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22971. var api3 string
  22972. if miConfig.MdtrtareaAdmvs == "320921" {
  22973. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22974. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22975. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22976. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22977. } else {
  22978. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22979. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22980. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22982. }
  22983. resp3, requestErr3 := http.Get(api3)
  22984. if requestErr3 != nil {
  22985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22986. return
  22987. }
  22988. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22989. if ioErr3 != nil {
  22990. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22992. return
  22993. }
  22994. var respJSON3 map[string]interface{}
  22995. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22996. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22998. return
  22999. }
  23000. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23001. userJSONBytes3, _ := json.Marshal(respJSON3)
  23002. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23003. utils.ErrorLog("解析失败:%v", err)
  23004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23005. return
  23006. }
  23007. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23008. res.Output = resSixteen10265.Output
  23009. res.ErrMsg = resSixteen10265.ErrMsg
  23010. res.Cainfo = resSixteen10265.Cainfo
  23011. res.WarnMsg = resSixteen10265.WarnMsg
  23012. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23013. res.Infcode = infocode
  23014. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23015. var api3 string
  23016. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23017. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23018. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23019. resp3, requestErr3 := http.Get(api3)
  23020. if requestErr3 != nil {
  23021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23022. return
  23023. }
  23024. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23025. if ioErr3 != nil {
  23026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23028. return
  23029. }
  23030. var respJSON3 map[string]interface{}
  23031. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23034. return
  23035. }
  23036. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23037. userJSONBytes3, _ := json.Marshal(respJSON3)
  23038. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23039. utils.ErrorLog("解析失败:%v", err)
  23040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23041. return
  23042. }
  23043. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23044. res.Output = resSixteen10265.Output
  23045. res.ErrMsg = resSixteen10265.ErrMsg
  23046. res.Cainfo = resSixteen10265.Cainfo
  23047. res.WarnMsg = resSixteen10265.WarnMsg
  23048. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23049. res.Infcode = infocode
  23050. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23051. 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)
  23052. var dat map[string]interface{}
  23053. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23054. fmt.Println(dat)
  23055. } else {
  23056. fmt.Println(err)
  23057. }
  23058. saveLog(result, src_resquest, "2208", "退费")
  23059. userJSONBytes, _ := json.Marshal(dat)
  23060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23061. utils.ErrorLog("解析失败:%v", err)
  23062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23063. return
  23064. }
  23065. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23066. 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, "")
  23067. var dat map[string]interface{}
  23068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23069. fmt.Println(dat)
  23070. } else {
  23071. fmt.Println(err)
  23072. }
  23073. saveLog(result, src_resquest, "2208", "退费")
  23074. userJSONBytes, _ := json.Marshal(dat)
  23075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23076. utils.ErrorLog("解析失败:%v", err)
  23077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23078. return
  23079. }
  23080. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23081. var api3 string
  23082. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23083. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23084. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23085. resp3, requestErr3 := http.Get(api3)
  23086. if requestErr3 != nil {
  23087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23088. return
  23089. }
  23090. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23091. if ioErr3 != nil {
  23092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23094. return
  23095. }
  23096. var respJSON3 map[string]interface{}
  23097. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23100. return
  23101. }
  23102. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23103. if status == "0" {
  23104. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23105. c.ServeSuccessJSON(map[string]interface{}{
  23106. "failed_code": -10,
  23107. "msg": err_msg,
  23108. })
  23109. return
  23110. }
  23111. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23112. userJSONBytes3, _ := json.Marshal(respJSON3)
  23113. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23114. // utils.ErrorLog("解析失败:%v", err)
  23115. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23116. // return
  23117. //}
  23118. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23119. utils.ErrorLog("解析失败:%v", err)
  23120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23121. return
  23122. }
  23123. res.InfRefmsgid = ahres.InfRefmsgid
  23124. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23125. // 创建对应的Time类型
  23126. t := time.UnixMilli(timestamp)
  23127. // 格式化成指定的日期字符串
  23128. str := t.Format("2006-01-02 15:04:05")
  23129. res.Output.Setlinfo.SetlTime = str
  23130. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23131. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23132. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23133. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23134. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23135. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23136. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23137. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23138. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23139. //
  23140. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23141. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23142. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23143. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23144. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23145. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23146. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23147. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23148. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23149. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23150. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23151. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23152. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23153. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23154. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23155. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23156. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23157. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23158. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23159. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23160. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23161. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23162. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23163. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23164. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23165. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23166. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23167. //res.Output.Setldetail = ahres.Output.Setldetail
  23168. res.ErrMsg = ahres.ErrMsg
  23169. res.Cainfo = ahres.Cainfo
  23170. res.WarnMsg = ahres.WarnMsg
  23171. res.Infcode = ahres.Infcode
  23172. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23173. 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, "")
  23174. var dat map[string]interface{}
  23175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23176. fmt.Println(dat)
  23177. } else {
  23178. fmt.Println(err)
  23179. }
  23180. saveLog(result, src_resquest, "2208", "退费")
  23181. userJSONBytes, _ := json.Marshal(dat)
  23182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23183. utils.ErrorLog("解析失败:%v", err)
  23184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23185. return
  23186. }
  23187. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23188. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23189. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23190. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23191. resp3, requestErr3 := http.Get(api3)
  23192. if requestErr3 != nil {
  23193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23194. return
  23195. }
  23196. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23197. if ioErr3 != nil {
  23198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23200. return
  23201. }
  23202. var respJSON3 map[string]interface{}
  23203. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23206. return
  23207. }
  23208. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23209. userJSONBytes3, _ := json.Marshal(respJSON3)
  23210. fmt.Println("log")
  23211. fmt.Println(string(userJSONBytes3))
  23212. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23213. utils.ErrorLog("解析失败:%v", err)
  23214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23215. return
  23216. }
  23217. } else {
  23218. if miConfig.Code == "H15049901371" {
  23219. 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)
  23220. var dat map[string]interface{}
  23221. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23222. fmt.Println(dat)
  23223. } else {
  23224. fmt.Println(err)
  23225. }
  23226. saveLog(result, src_resquest, "2208", "退费")
  23227. userJSONBytes, _ := json.Marshal(dat)
  23228. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23229. utils.ErrorLog("解析失败:%v", err)
  23230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23231. return
  23232. }
  23233. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23234. res.Output = resSixteen10265.Output
  23235. res.ErrMsg = resSixteen10265.ErrMsg
  23236. res.Cainfo = resSixteen10265.Cainfo
  23237. res.WarnMsg = resSixteen10265.WarnMsg
  23238. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23239. res.Infcode = infocode
  23240. } else {
  23241. 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)
  23242. var dat map[string]interface{}
  23243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23244. fmt.Println(dat)
  23245. } else {
  23246. fmt.Println(err)
  23247. }
  23248. saveLog(result, src_resquest, "2208", "退费")
  23249. userJSONBytes, _ := json.Marshal(dat)
  23250. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23251. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  23252. utils.ErrorLog("解析失败:%v", err)
  23253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23254. return
  23255. }
  23256. res.Infcode = gz.Infcode
  23257. } else {
  23258. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23259. utils.ErrorLog("解析失败:%v", err)
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23261. return
  23262. }
  23263. }
  23264. }
  23265. }
  23266. if res.Infcode == 0 {
  23267. var res2 ResultSix
  23268. var resSix10265 ResultSix10265
  23269. if miConfig.MdtrtareaAdmvs == "421300" {
  23270. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23271. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23272. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23273. resp3, requestErr3 := http.Get(api3)
  23274. if requestErr3 != nil {
  23275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23276. return
  23277. }
  23278. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23279. if ioErr3 != nil {
  23280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23282. return
  23283. }
  23284. var respJSON3 map[string]interface{}
  23285. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23288. return
  23289. }
  23290. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23291. userJSONBytes3, _ := json.Marshal(respJSON3)
  23292. fmt.Println("log")
  23293. fmt.Println(string(userJSONBytes3))
  23294. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23295. utils.ErrorLog("解析失败:%v", err)
  23296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23297. return
  23298. }
  23299. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23300. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23301. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23303. resp3, requestErr3 := http.Get(api3)
  23304. if requestErr3 != nil {
  23305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23306. return
  23307. }
  23308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23309. if ioErr3 != nil {
  23310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23312. return
  23313. }
  23314. var respJSON3 map[string]interface{}
  23315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23318. return
  23319. }
  23320. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23321. userJSONBytes3, _ := json.Marshal(respJSON3)
  23322. fmt.Println("log")
  23323. fmt.Println(string(userJSONBytes3))
  23324. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23325. utils.ErrorLog("解析失败:%v", err)
  23326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23327. return
  23328. }
  23329. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23330. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23331. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23333. resp3, requestErr3 := http.Get(api3)
  23334. if requestErr3 != nil {
  23335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23336. return
  23337. }
  23338. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23339. if ioErr3 != nil {
  23340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23342. return
  23343. }
  23344. var respJSON3 map[string]interface{}
  23345. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23348. return
  23349. }
  23350. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23351. userJSONBytes3, _ := json.Marshal(respJSON3)
  23352. fmt.Println("log")
  23353. fmt.Println(string(userJSONBytes3))
  23354. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23355. utils.ErrorLog("解析失败:%v", err)
  23356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23357. return
  23358. }
  23359. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23360. var api3 string
  23361. if miConfig.MdtrtareaAdmvs == "320921" {
  23362. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23363. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23365. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23366. } else {
  23367. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23368. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23369. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23370. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23371. }
  23372. resp3, requestErr3 := http.Get(api3)
  23373. if requestErr3 != nil {
  23374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23375. return
  23376. }
  23377. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23378. if ioErr3 != nil {
  23379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23381. return
  23382. }
  23383. var respJSON3 map[string]interface{}
  23384. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23387. return
  23388. }
  23389. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23390. userJSONBytes3, _ := json.Marshal(respJSON3)
  23391. fmt.Println("log")
  23392. fmt.Println(string(userJSONBytes3))
  23393. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23394. utils.ErrorLog("解析失败:%v", err)
  23395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23396. return
  23397. }
  23398. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23399. res2.Output = resSix10265.Output
  23400. res2.ErrMsg = resSix10265.ErrMsg
  23401. res2.Cainfo = resSix10265.Cainfo
  23402. res2.WarnMsg = resSix10265.WarnMsg
  23403. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23404. res2.Infcode = infocode
  23405. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23406. var api3 string
  23407. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23408. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23409. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23410. resp3, requestErr3 := http.Get(api3)
  23411. if requestErr3 != nil {
  23412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23413. return
  23414. }
  23415. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23416. if ioErr3 != nil {
  23417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23419. return
  23420. }
  23421. var respJSON3 map[string]interface{}
  23422. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23425. return
  23426. }
  23427. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23428. userJSONBytes3, _ := json.Marshal(respJSON3)
  23429. fmt.Println("log")
  23430. fmt.Println(string(userJSONBytes3))
  23431. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23432. utils.ErrorLog("解析失败:%v", err)
  23433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23434. return
  23435. }
  23436. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23437. res2.Output = resSix10265.Output
  23438. res2.ErrMsg = resSix10265.ErrMsg
  23439. res2.Cainfo = resSix10265.Cainfo
  23440. res2.WarnMsg = resSix10265.WarnMsg
  23441. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23442. res2.Infcode = infocode
  23443. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23444. 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)
  23445. var dat map[string]interface{}
  23446. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23447. fmt.Println(dat)
  23448. } else {
  23449. fmt.Println(err)
  23450. }
  23451. saveLog(result2, src_request, "2205", "撤销明细")
  23452. userJSONBytes, _ := json.Marshal(dat)
  23453. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23454. utils.ErrorLog("解析失败:%v", err)
  23455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23456. return
  23457. }
  23458. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23459. 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, "")
  23460. var dat map[string]interface{}
  23461. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23462. fmt.Println(dat)
  23463. } else {
  23464. fmt.Println(err)
  23465. }
  23466. saveLog(result2, src_request, "2205", "撤销明细")
  23467. userJSONBytes, _ := json.Marshal(dat)
  23468. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23469. utils.ErrorLog("解析失败:%v", err)
  23470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23471. return
  23472. }
  23473. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23474. var api3 string
  23475. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23476. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23477. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23478. resp3, requestErr3 := http.Get(api3)
  23479. if requestErr3 != nil {
  23480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23481. return
  23482. }
  23483. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23484. if ioErr3 != nil {
  23485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23487. return
  23488. }
  23489. var respJSON3 map[string]interface{}
  23490. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23493. return
  23494. }
  23495. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23496. if status == "0" {
  23497. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23498. c.ServeSuccessJSON(map[string]interface{}{
  23499. "failed_code": -10,
  23500. "msg": err_msg,
  23501. })
  23502. return
  23503. }
  23504. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23505. userJSONBytes3, _ := json.Marshal(respJSON3)
  23506. fmt.Println("log")
  23507. fmt.Println(string(userJSONBytes3))
  23508. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23509. utils.ErrorLog("解析失败:%v", err)
  23510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23511. return
  23512. }
  23513. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23514. 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, "")
  23515. var dat map[string]interface{}
  23516. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23517. fmt.Println(dat)
  23518. } else {
  23519. fmt.Println(err)
  23520. }
  23521. saveLog(result2, src_request, "2205", "撤销明细")
  23522. userJSONBytes, _ := json.Marshal(dat)
  23523. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23524. utils.ErrorLog("解析失败:%v", err)
  23525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23526. return
  23527. }
  23528. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23529. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  23530. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23531. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23532. resp3, requestErr3 := http.Get(api3)
  23533. if requestErr3 != nil {
  23534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23535. return
  23536. }
  23537. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23538. if ioErr3 != nil {
  23539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23541. return
  23542. }
  23543. var respJSON3 map[string]interface{}
  23544. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23547. return
  23548. }
  23549. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23550. userJSONBytes3, _ := json.Marshal(respJSON3)
  23551. fmt.Println("log")
  23552. fmt.Println(string(userJSONBytes3))
  23553. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23554. utils.ErrorLog("解析失败:%v", err)
  23555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23556. return
  23557. }
  23558. } else {
  23559. if miConfig.Code == "H15049901371" {
  23560. 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)
  23561. var dat map[string]interface{}
  23562. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23563. fmt.Println(dat)
  23564. } else {
  23565. fmt.Println(err)
  23566. }
  23567. saveLog(result2, src_request, "2205", "撤销明细")
  23568. userJSONBytes, _ := json.Marshal(dat)
  23569. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  23570. utils.ErrorLog("解析失败:%v", err)
  23571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23572. return
  23573. }
  23574. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23575. res2.Output = resSix10265.Output
  23576. res2.ErrMsg = resSix10265.ErrMsg
  23577. res2.Cainfo = resSix10265.Cainfo
  23578. res2.WarnMsg = resSix10265.WarnMsg
  23579. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23580. res2.Infcode = infocode
  23581. } else {
  23582. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23583. res2.Infcode = 0
  23584. } else {
  23585. 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)
  23586. var dat map[string]interface{}
  23587. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23588. fmt.Println(dat)
  23589. } else {
  23590. fmt.Println(err)
  23591. }
  23592. saveLog(result2, src_request, "2205", "撤销明细")
  23593. userJSONBytes, _ := json.Marshal(dat)
  23594. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23595. utils.ErrorLog("解析失败:%v", err)
  23596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23597. return
  23598. }
  23599. }
  23600. }
  23601. }
  23602. if res2.Infcode == -1 {
  23603. c.ServeSuccessJSON(map[string]interface{}{
  23604. "failed_code": -10,
  23605. "msg": res2.ErrMsg,
  23606. })
  23607. return
  23608. }
  23609. if res2.Infcode == 0 {
  23610. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  23611. if err == nil {
  23612. //当押金不为零时产生退费记录
  23613. if order.Decimal != 0 {
  23614. tmp := strconv.FormatInt(order.ID, 10)
  23615. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  23616. if err != nil {
  23617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23618. return
  23619. }
  23620. }
  23621. c.ServeSuccessJSON(map[string]interface{}{
  23622. "msg": "退费成功",
  23623. })
  23624. } else {
  23625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23626. return
  23627. }
  23628. } else {
  23629. c.ServeSuccessJSON(map[string]interface{}{
  23630. "failed_code": -10,
  23631. "msg": res2.ErrMsg,
  23632. })
  23633. }
  23634. } else {
  23635. c.ServeSuccessJSON(map[string]interface{}{
  23636. "failed_code": -10,
  23637. "msg": res.ErrMsg,
  23638. })
  23639. }
  23640. }
  23641. }
  23642. func (c *HisApiController) RefundNumber() {
  23643. record_time := c.GetString("record_time")
  23644. //patient_id, _ := c.GetInt64("patient_id")
  23645. admin_user_id, _ := c.GetInt64("admin_user_id")
  23646. his_patient_id, _ := c.GetInt64("id")
  23647. timeLayout := "2006-01-02"
  23648. loc, _ := time.LoadLocation("Local")
  23649. adminUser := c.GetAdminUserInfo()
  23650. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23651. fmt.Println(err)
  23652. if err != nil {
  23653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23654. return
  23655. }
  23656. recordDateTime := theTime.Unix()
  23657. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23658. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23659. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23660. //order, _ := service.GetHisOrderByID(order_id)
  23661. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23662. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23663. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23664. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23665. if count > 0 {
  23666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23667. return
  23668. }
  23669. if config.IsOpen == 1 { //对接了医保,走医保流程
  23670. var res2 ResultSix
  23671. var res3 GZResultSix
  23672. var resSix10265 ResultSix10265
  23673. if miConfig.MdtrtareaAdmvs == "421300" {
  23674. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23675. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23676. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23677. resp3, requestErr3 := http.Get(api3)
  23678. if requestErr3 != nil {
  23679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23680. return
  23681. }
  23682. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23683. if ioErr3 != nil {
  23684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23686. return
  23687. }
  23688. var respJSON3 map[string]interface{}
  23689. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23692. return
  23693. }
  23694. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23695. userJSONBytes3, _ := json.Marshal(respJSON3)
  23696. fmt.Println("log")
  23697. fmt.Println(string(userJSONBytes3))
  23698. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23699. utils.ErrorLog("解析失败:%v", err)
  23700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23701. return
  23702. }
  23703. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23704. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23705. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23706. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23707. resp3, requestErr3 := http.Get(api3)
  23708. if requestErr3 != nil {
  23709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23710. return
  23711. }
  23712. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23713. if ioErr3 != nil {
  23714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23716. return
  23717. }
  23718. var respJSON3 map[string]interface{}
  23719. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23722. return
  23723. }
  23724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23725. userJSONBytes3, _ := json.Marshal(respJSON3)
  23726. fmt.Println("log")
  23727. fmt.Println(string(userJSONBytes3))
  23728. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23729. utils.ErrorLog("解析失败:%v", err)
  23730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23731. return
  23732. }
  23733. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23734. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23735. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23736. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23737. resp3, requestErr3 := http.Get(api3)
  23738. if requestErr3 != nil {
  23739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23740. return
  23741. }
  23742. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23743. if ioErr3 != nil {
  23744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23746. return
  23747. }
  23748. var respJSON3 map[string]interface{}
  23749. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23752. return
  23753. }
  23754. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23755. userJSONBytes3, _ := json.Marshal(respJSON3)
  23756. fmt.Println("log")
  23757. fmt.Println(string(userJSONBytes3))
  23758. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23759. utils.ErrorLog("解析失败:%v", err)
  23760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23761. return
  23762. }
  23763. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23764. var api3 string
  23765. if miConfig.MdtrtareaAdmvs == "320921" {
  23766. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23767. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23768. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23769. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23770. } else {
  23771. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23772. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23773. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23774. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23775. }
  23776. resp3, requestErr3 := http.Get(api3)
  23777. if requestErr3 != nil {
  23778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23779. return
  23780. }
  23781. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23782. if ioErr3 != nil {
  23783. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23785. return
  23786. }
  23787. var respJSON3 map[string]interface{}
  23788. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23789. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23791. return
  23792. }
  23793. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23794. userJSONBytes3, _ := json.Marshal(respJSON3)
  23795. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23796. utils.ErrorLog("解析失败:%v", err)
  23797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23798. return
  23799. }
  23800. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23801. res2.Output = resSix10265.Output
  23802. res2.ErrMsg = resSix10265.ErrMsg
  23803. res2.Cainfo = resSix10265.Cainfo
  23804. res2.WarnMsg = resSix10265.WarnMsg
  23805. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23806. res2.Infcode = infocode
  23807. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23808. var api3 string
  23809. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23810. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23812. resp3, requestErr3 := http.Get(api3)
  23813. if requestErr3 != nil {
  23814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23815. return
  23816. }
  23817. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23818. if ioErr3 != nil {
  23819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23821. return
  23822. }
  23823. var respJSON3 map[string]interface{}
  23824. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23827. return
  23828. }
  23829. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23830. userJSONBytes3, _ := json.Marshal(respJSON3)
  23831. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23832. utils.ErrorLog("解析失败:%v", err)
  23833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23834. return
  23835. }
  23836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23837. res2.Output = resSix10265.Output
  23838. res2.ErrMsg = resSix10265.ErrMsg
  23839. res2.Cainfo = resSix10265.Cainfo
  23840. res2.WarnMsg = resSix10265.WarnMsg
  23841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23842. res2.Infcode = infocode
  23843. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23844. 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)
  23845. var dat map[string]interface{}
  23846. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23847. fmt.Println(dat)
  23848. } else {
  23849. fmt.Println(err)
  23850. }
  23851. saveLog(result, request, "2202", "退号")
  23852. userJSONBytes, _ := json.Marshal(dat)
  23853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23854. utils.ErrorLog("解析失败:%v", err)
  23855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23856. return
  23857. }
  23858. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23859. 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, "")
  23860. var dat map[string]interface{}
  23861. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23862. fmt.Println(dat)
  23863. } else {
  23864. fmt.Println(err)
  23865. }
  23866. saveLog(result, request, "2202", "退号")
  23867. userJSONBytes, _ := json.Marshal(dat)
  23868. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23869. utils.ErrorLog("解析失败:%v", err)
  23870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23871. return
  23872. }
  23873. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23874. var api3 string
  23875. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23876. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23878. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23879. resp3, requestErr3 := http.Get(api3)
  23880. if requestErr3 != nil {
  23881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. return
  23883. }
  23884. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23885. if ioErr3 != nil {
  23886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23888. return
  23889. }
  23890. var respJSON3 map[string]interface{}
  23891. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23894. return
  23895. }
  23896. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23897. if status == "0" {
  23898. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23899. c.ServeSuccessJSON(map[string]interface{}{
  23900. "failed_code": -10,
  23901. "msg": err_msg,
  23902. })
  23903. return
  23904. }
  23905. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23906. userJSONBytes3, _ := json.Marshal(respJSON3)
  23907. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23908. utils.ErrorLog("解析失败:%v", err)
  23909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23910. return
  23911. }
  23912. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23913. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23914. 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, "")
  23915. var dat map[string]interface{}
  23916. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23917. fmt.Println(dat)
  23918. } else {
  23919. fmt.Println(err)
  23920. }
  23921. saveLog(result, request, "2202", "退号")
  23922. userJSONBytes, _ := json.Marshal(dat)
  23923. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23924. utils.ErrorLog("解析失败:%v", err)
  23925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23926. return
  23927. }
  23928. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23929. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23930. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23932. resp3, requestErr3 := http.Get(api3)
  23933. if requestErr3 != nil {
  23934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23935. return
  23936. }
  23937. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23938. if ioErr3 != nil {
  23939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23941. return
  23942. }
  23943. var respJSON3 map[string]interface{}
  23944. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23947. return
  23948. }
  23949. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23950. userJSONBytes3, _ := json.Marshal(respJSON3)
  23951. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23952. utils.ErrorLog("解析失败:%v", err)
  23953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23954. return
  23955. }
  23956. } else {
  23957. var api3 string
  23958. if miConfig.Code == "H15049901371" {
  23959. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23960. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23961. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23962. } else {
  23963. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23964. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23966. }
  23967. resp3, requestErr3 := http.Get(api3)
  23968. if requestErr3 != nil {
  23969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23970. return
  23971. }
  23972. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23973. if ioErr3 != nil {
  23974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23976. return
  23977. }
  23978. var respJSON3 map[string]interface{}
  23979. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23982. return
  23983. }
  23984. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23985. userJSONBytes3, _ := json.Marshal(respJSON3)
  23986. if miConfig.Code == "H15049901371" {
  23987. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23993. res2.Output = resSix10265.Output
  23994. res2.ErrMsg = resSix10265.ErrMsg
  23995. res2.Cainfo = resSix10265.Cainfo
  23996. res2.WarnMsg = resSix10265.WarnMsg
  23997. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23998. res2.Infcode = infocode
  23999. } else {
  24000. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24001. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24002. utils.ErrorLog("解析失败:%v", err)
  24003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24004. return
  24005. }
  24006. res2.Infcode = res3.Infcode
  24007. } else {
  24008. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24009. utils.ErrorLog("解析失败:%v", err)
  24010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24011. return
  24012. }
  24013. }
  24014. }
  24015. }
  24016. if res2.Infcode == -1 {
  24017. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24018. c.ServeSuccessJSON(map[string]interface{}{
  24019. "failed_code": -10,
  24020. "msg": res2.ErrMsg,
  24021. })
  24022. return
  24023. }
  24024. if res2.Infcode == 0 {
  24025. if err == nil {
  24026. c.ServeSuccessJSON(map[string]interface{}{
  24027. "msg": "退号成功",
  24028. })
  24029. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24030. } else {
  24031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24032. return
  24033. }
  24034. }
  24035. } else {
  24036. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24037. //if err == nil {
  24038. // c.ServeSuccessJSON(map[string]interface{}{
  24039. // "msg": "退费成功",
  24040. // })
  24041. //} else {
  24042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24043. // return
  24044. //}
  24045. }
  24046. }
  24047. func (c *HisApiController) RefundDetail() {
  24048. order_id, _ := c.GetInt64("order_id")
  24049. admin_user_id, _ := c.GetInt64("admin_user_id")
  24050. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24051. number := c.GetString("number")
  24052. record_time := c.GetString("record_time")
  24053. patient_id, _ := c.GetInt64("patient_id")
  24054. //med_type, _ := c.GetInt64("med_type")
  24055. timeLayout := "2006-01-02"
  24056. loc, _ := time.LoadLocation("Local")
  24057. adminUser := c.GetAdminUserInfo()
  24058. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24060. fmt.Println(err)
  24061. if err != nil {
  24062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24063. return
  24064. }
  24065. recordDateTime := theTime.Unix()
  24066. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24067. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24068. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24069. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24070. var order models.HisOrder
  24071. order, _ = service.GetHisOrderByID(order_id)
  24072. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24073. if config.IsOpen == 1 { //对接了医保,走医保流程
  24074. var res2 ResultSix
  24075. if miConfig.MdtrtareaAdmvs == "421300" {
  24076. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24077. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24079. resp3, requestErr3 := http.Get(api3)
  24080. if requestErr3 != nil {
  24081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24082. return
  24083. }
  24084. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24085. if ioErr3 != nil {
  24086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24088. return
  24089. }
  24090. var respJSON3 map[string]interface{}
  24091. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24094. return
  24095. }
  24096. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24097. userJSONBytes3, _ := json.Marshal(respJSON3)
  24098. fmt.Println("log")
  24099. fmt.Println(string(userJSONBytes3))
  24100. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24101. utils.ErrorLog("解析失败:%v", err)
  24102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24103. return
  24104. }
  24105. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24106. if err == nil {
  24107. c.ServeSuccessJSON(map[string]interface{}{
  24108. "msg": "撤销明细成功",
  24109. })
  24110. return
  24111. } else {
  24112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24113. return
  24114. }
  24115. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24116. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24117. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24118. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24119. resp3, requestErr3 := http.Get(api3)
  24120. if requestErr3 != nil {
  24121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24122. return
  24123. }
  24124. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24125. if ioErr3 != nil {
  24126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24128. return
  24129. }
  24130. var respJSON3 map[string]interface{}
  24131. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24134. return
  24135. }
  24136. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24137. userJSONBytes3, _ := json.Marshal(respJSON3)
  24138. fmt.Println("log")
  24139. fmt.Println(string(userJSONBytes3))
  24140. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24141. utils.ErrorLog("解析失败:%v", err)
  24142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24143. return
  24144. }
  24145. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24146. if err == nil {
  24147. c.ServeSuccessJSON(map[string]interface{}{
  24148. "msg": "撤销明细成功",
  24149. })
  24150. return
  24151. } else {
  24152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24153. return
  24154. }
  24155. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24156. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24157. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24158. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24159. resp3, requestErr3 := http.Get(api3)
  24160. if requestErr3 != nil {
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24165. if ioErr3 != nil {
  24166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24168. return
  24169. }
  24170. var respJSON3 map[string]interface{}
  24171. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24174. return
  24175. }
  24176. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24177. userJSONBytes3, _ := json.Marshal(respJSON3)
  24178. fmt.Println("log")
  24179. fmt.Println(string(userJSONBytes3))
  24180. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24181. utils.ErrorLog("解析失败:%v", err)
  24182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24183. return
  24184. }
  24185. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24186. if err == nil {
  24187. c.ServeSuccessJSON(map[string]interface{}{
  24188. "msg": "撤销明细成功",
  24189. })
  24190. return
  24191. } else {
  24192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24193. return
  24194. }
  24195. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24196. var resSix10265 ResultSix10265
  24197. var api3 string
  24198. if miConfig.MdtrtareaAdmvs == "320921" {
  24199. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24200. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24201. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24202. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24203. } else {
  24204. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24205. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24206. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24207. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24208. }
  24209. resp3, requestErr3 := http.Get(api3)
  24210. utils.ErrorLog("接口: %v", requestErr3)
  24211. if requestErr3 != nil {
  24212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24213. return
  24214. }
  24215. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24216. if ioErr3 != nil {
  24217. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24219. return
  24220. }
  24221. var respJSON3 map[string]interface{}
  24222. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24223. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24225. return
  24226. }
  24227. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24228. userJSONBytes3, _ := json.Marshal(respJSON3)
  24229. fmt.Println("log")
  24230. fmt.Println(string(userJSONBytes3))
  24231. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24232. utils.ErrorLog("解析失败:%v", err)
  24233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24234. return
  24235. }
  24236. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24237. res2.Output = resSix10265.Output
  24238. res2.ErrMsg = resSix10265.ErrMsg
  24239. res2.Cainfo = resSix10265.Cainfo
  24240. res2.WarnMsg = resSix10265.WarnMsg
  24241. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24242. res2.Infcode = infocode
  24243. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24244. if err == nil {
  24245. c.ServeSuccessJSON(map[string]interface{}{
  24246. "msg": "撤销明细成功",
  24247. })
  24248. return
  24249. } else {
  24250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24251. return
  24252. }
  24253. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24254. var api3 string
  24255. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24256. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24257. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24258. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24259. resp3, requestErr3 := http.Get(api3)
  24260. utils.ErrorLog("接口: %v", requestErr3)
  24261. if requestErr3 != nil {
  24262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24263. return
  24264. }
  24265. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24266. if ioErr3 != nil {
  24267. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24269. return
  24270. }
  24271. var respJSON3 map[string]interface{}
  24272. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24273. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24275. return
  24276. }
  24277. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24278. if status == "0" {
  24279. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24280. c.ServeSuccessJSON(map[string]interface{}{
  24281. "failed_code": -10,
  24282. "msg": err_msg,
  24283. })
  24284. return
  24285. }
  24286. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24287. userJSONBytes3, _ := json.Marshal(respJSON3)
  24288. fmt.Println("log")
  24289. fmt.Println(string(userJSONBytes3))
  24290. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24291. utils.ErrorLog("解析失败:%v", err)
  24292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24293. return
  24294. }
  24295. fmt.Println(res2.Infcode)
  24296. if res2.Infcode == -1 {
  24297. c.ServeSuccessJSON(map[string]interface{}{
  24298. "failed_code": -10,
  24299. "msg": res2.ErrMsg,
  24300. })
  24301. return
  24302. }
  24303. if res2.Infcode == 0 {
  24304. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24305. if err == nil {
  24306. c.ServeSuccessJSON(map[string]interface{}{
  24307. "msg": "撤销明细成功",
  24308. })
  24309. return
  24310. } else {
  24311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24312. return
  24313. }
  24314. } else {
  24315. c.ServeSuccessJSON(map[string]interface{}{
  24316. "failed_code": -10,
  24317. "msg": res2.ErrMsg,
  24318. })
  24319. }
  24320. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24321. if err == nil {
  24322. c.ServeSuccessJSON(map[string]interface{}{
  24323. "msg": "撤销明细成功",
  24324. })
  24325. return
  24326. } else {
  24327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24328. return
  24329. }
  24330. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24331. var resSix10265 ResultSix10265
  24332. var api3 string
  24333. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24334. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24335. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24336. resp3, requestErr3 := http.Get(api3)
  24337. if requestErr3 != nil {
  24338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24339. return
  24340. }
  24341. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24342. if ioErr3 != nil {
  24343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. var respJSON3 map[string]interface{}
  24348. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24351. return
  24352. }
  24353. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24354. userJSONBytes3, _ := json.Marshal(respJSON3)
  24355. fmt.Println("log")
  24356. fmt.Println(string(userJSONBytes3))
  24357. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24358. utils.ErrorLog("解析失败:%v", err)
  24359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24360. return
  24361. }
  24362. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24363. res2.Output = resSix10265.Output
  24364. res2.ErrMsg = resSix10265.ErrMsg
  24365. res2.Cainfo = resSix10265.Cainfo
  24366. res2.WarnMsg = resSix10265.WarnMsg
  24367. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24368. res2.Infcode = infocode
  24369. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24370. if err == nil {
  24371. c.ServeSuccessJSON(map[string]interface{}{
  24372. "msg": "撤销明细成功",
  24373. })
  24374. return
  24375. } else {
  24376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24377. return
  24378. }
  24379. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24380. 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)
  24381. var dat map[string]interface{}
  24382. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24383. fmt.Println(dat)
  24384. } else {
  24385. fmt.Println(err)
  24386. }
  24387. saveLog(result2, src_request, "2205", "撤销明细")
  24388. userJSONBytes, _ := json.Marshal(dat)
  24389. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24390. utils.ErrorLog("解析失败:%v", err)
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24392. return
  24393. }
  24394. if res2.Infcode == 0 {
  24395. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24396. if err == nil {
  24397. c.ServeSuccessJSON(map[string]interface{}{
  24398. "msg": "撤销明细成功",
  24399. })
  24400. return
  24401. } else {
  24402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24403. return
  24404. }
  24405. } else {
  24406. c.ServeSuccessJSON(map[string]interface{}{
  24407. "failed_code": -10,
  24408. "msg": res2.ErrMsg,
  24409. })
  24410. }
  24411. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24412. 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, "")
  24413. var dat map[string]interface{}
  24414. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24415. fmt.Println(dat)
  24416. } else {
  24417. fmt.Println(err)
  24418. }
  24419. saveLog(result2, src_request, "2205", "撤销明细")
  24420. userJSONBytes, _ := json.Marshal(dat)
  24421. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24422. utils.ErrorLog("解析失败:%v", err)
  24423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24424. return
  24425. }
  24426. if res2.Infcode == 0 {
  24427. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24428. if err == nil {
  24429. c.ServeSuccessJSON(map[string]interface{}{
  24430. "msg": "撤销明细成功",
  24431. })
  24432. return
  24433. } else {
  24434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24435. return
  24436. }
  24437. } else {
  24438. c.ServeSuccessJSON(map[string]interface{}{
  24439. "failed_code": -10,
  24440. "msg": res2.ErrMsg,
  24441. })
  24442. }
  24443. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24444. 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, "")
  24445. var dat map[string]interface{}
  24446. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24447. fmt.Println(dat)
  24448. } else {
  24449. fmt.Println(err)
  24450. }
  24451. saveLog(result2, src_request, "2205", "撤销明细")
  24452. userJSONBytes, _ := json.Marshal(dat)
  24453. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24454. utils.ErrorLog("解析失败:%v", err)
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24456. return
  24457. }
  24458. if res2.Infcode == 0 {
  24459. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24460. if err == nil {
  24461. c.ServeSuccessJSON(map[string]interface{}{
  24462. "msg": "撤销明细成功",
  24463. })
  24464. return
  24465. } else {
  24466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24467. return
  24468. }
  24469. } else {
  24470. c.ServeSuccessJSON(map[string]interface{}{
  24471. "failed_code": -10,
  24472. "msg": res2.ErrMsg,
  24473. })
  24474. }
  24475. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24476. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  24477. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24479. resp2, requestErr2 := http.Get(api2)
  24480. if requestErr2 != nil {
  24481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24482. return
  24483. }
  24484. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24485. if ioErr2 != nil {
  24486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24488. return
  24489. }
  24490. var respJSON2 map[string]interface{}
  24491. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24494. return
  24495. }
  24496. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24497. userJSONBytes3, _ := json.Marshal(respJSON2)
  24498. fmt.Println("log")
  24499. fmt.Println(string(userJSONBytes3))
  24500. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24501. utils.ErrorLog("解析失败:%v", err)
  24502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24503. return
  24504. }
  24505. if res2.Infcode == 0 {
  24506. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24507. if err == nil {
  24508. c.ServeSuccessJSON(map[string]interface{}{
  24509. "msg": "撤销明细成功",
  24510. })
  24511. return
  24512. } else {
  24513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24514. return
  24515. }
  24516. } else {
  24517. c.ServeSuccessJSON(map[string]interface{}{
  24518. "failed_code": -10,
  24519. "msg": res2.ErrMsg,
  24520. })
  24521. }
  24522. } else {
  24523. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  24524. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24525. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24526. resp2, requestErr2 := http.Get(api2)
  24527. if requestErr2 != nil {
  24528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24529. return
  24530. }
  24531. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24532. if ioErr2 != nil {
  24533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. var respJSON2 map[string]interface{}
  24538. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24541. return
  24542. }
  24543. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24544. if err == nil {
  24545. c.ServeSuccessJSON(map[string]interface{}{
  24546. "msg": "撤销明细成功",
  24547. })
  24548. return
  24549. } else {
  24550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24551. return
  24552. }
  24553. }
  24554. } else {
  24555. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24556. if err == nil {
  24557. c.ServeSuccessJSON(map[string]interface{}{
  24558. "msg": "退费成功",
  24559. })
  24560. } else {
  24561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24562. return
  24563. }
  24564. }
  24565. }
  24566. // 对账
  24567. func (c *HisApiController) GetCheckAccount() {
  24568. start_time := c.GetString("start_time")
  24569. end_time := c.GetString("end_time")
  24570. insutype := c.GetString("insutype")
  24571. clr_type := c.GetString("clr_type")
  24572. clr_org := c.GetString("clr_optins")
  24573. admin_user_id, _ := c.GetInt64("admin_user_id")
  24574. adminUser := c.GetAdminUserInfo()
  24575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24576. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24577. if len(clr_org) == 0 {
  24578. clr_org = miConfig.InsuplcAdmdvs
  24579. }
  24580. timeLayout := "2006-01-02"
  24581. loc, _ := time.LoadLocation("Local")
  24582. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24583. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24584. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24585. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24586. fixmedins_setl_cnt := int64(len(orders))
  24587. var medfee_sumamt float64
  24588. var acct_pay float64
  24589. var fund_pay_sumamt float64
  24590. for _, item := range orders {
  24591. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24592. acct_pay = acct_pay + item.AcctPay
  24593. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24594. }
  24595. var user_name string
  24596. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24597. if role.ID == 0 {
  24598. user_name = "xxx"
  24599. } else {
  24600. user_name = role.UserName
  24601. }
  24602. var res ResultEight
  24603. var res10188 ResultEightFor10188
  24604. if config.IsOpen == 1 {
  24605. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24606. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  24607. "insutype=" + insutype +
  24608. "&clr_type=" + clr_type +
  24609. "&setl_optins=" + clr_org +
  24610. "&stmt_begndate=" + start_time +
  24611. "&stm_enddate=" + end_time +
  24612. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24613. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24614. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24615. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24616. "&fixmedins_code=" + miConfig.Code +
  24617. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24618. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24619. "&secret_key=" + miConfig.SecretKey +
  24620. "&org_name=" + miConfig.OrgName +
  24621. "&doctor=" + user_name +
  24622. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24623. fmt.Println(api)
  24624. resp, requestErr := http.Get(api)
  24625. if requestErr != nil {
  24626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24627. return
  24628. }
  24629. body, ioErr := ioutil.ReadAll(resp.Body)
  24630. fmt.Println(body)
  24631. if ioErr != nil {
  24632. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24634. return
  24635. }
  24636. var respJSON map[string]interface{}
  24637. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24638. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24640. return
  24641. }
  24642. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24643. userJSONBytes, _ := json.Marshal(respJSON)
  24644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24645. utils.ErrorLog("解析失败:%v", err)
  24646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24647. return
  24648. }
  24649. res.InfRefmsgid = res10188.InfRefmsgid
  24650. res.Output = res10188.Output
  24651. res.ErrMsg = res10188.ErrMsg
  24652. res.Cainfo = res10188.Cainfo
  24653. res.WarnMsg = res10188.WarnMsg
  24654. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24655. res.Infcode = infocode
  24656. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24657. if clr_type != "9903" {
  24658. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24659. }
  24660. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24661. "insutype=" + insutype +
  24662. "&clr_type=" + clr_type +
  24663. "&setl_optins=" + clr_org +
  24664. "&stmt_begndate=" + start_time +
  24665. "&stm_enddate=" + end_time +
  24666. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24667. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24668. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24669. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24670. "&fixmedins_code=" + miConfig.Code +
  24671. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24672. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24673. "&secret_key=" + miConfig.SecretKey +
  24674. "&org_name=" + miConfig.OrgName +
  24675. "&doctor=" + user_name
  24676. resp, requestErr := http.Get(api)
  24677. if requestErr != nil {
  24678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24679. return
  24680. }
  24681. body, ioErr := ioutil.ReadAll(resp.Body)
  24682. if ioErr != nil {
  24683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24685. return
  24686. }
  24687. var respJSON map[string]interface{}
  24688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24691. return
  24692. }
  24693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24694. result, _ := json.Marshal(respJSON)
  24695. fmt.Println("log")
  24696. fmt.Println(string(result))
  24697. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24698. utils.ErrorLog("解析失败:%v", err)
  24699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24700. return
  24701. }
  24702. res.InfRefmsgid = res10188.InfRefmsgid
  24703. res.Output = res10188.Output
  24704. res.ErrMsg = res10188.ErrMsg
  24705. res.Cainfo = res10188.Cainfo
  24706. res.WarnMsg = res10188.WarnMsg
  24707. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24708. res.Infcode = infocode
  24709. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24710. var baseParams models.BaseParams
  24711. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24712. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24713. baseParams.SecretKey = miConfig.SecretKey
  24714. baseParams.OrgName = miConfig.OrgName
  24715. baseParams.FixmedinsCode = miConfig.Code
  24716. baseParams.EncKey = miConfig.EncKey
  24717. baseParams.AppSecret = miConfig.AppSecret
  24718. baseParams.SignKey = miConfig.SignKey
  24719. baseParams.AppID = miConfig.Code
  24720. baseParams.Doctor = role.UserName
  24721. baseParams.RequestUrl = miConfig.Url
  24722. businessParams := models.BusinessParams{
  24723. Insutype: insutype,
  24724. ClrType: clr_type,
  24725. SetlOptins: clr_org,
  24726. StmtBegndate: start_time,
  24727. StmtEnddate: end_time,
  24728. MedfeeSumamt: medfee_sumamt,
  24729. FundPaySumamt: fund_pay_sumamt,
  24730. AcctPay: acct_pay,
  24731. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24732. }
  24733. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24734. fmt.Println(requestLog)
  24735. fmt.Println(result)
  24736. fmt.Println(err_msg)
  24737. var dat map[string]interface{}
  24738. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24739. fmt.Println(dat)
  24740. } else {
  24741. fmt.Println(err)
  24742. }
  24743. userJSONBytes, _ := json.Marshal(dat)
  24744. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24745. utils.ErrorLog("解析失败:%v", err)
  24746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24747. return
  24748. }
  24749. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24750. var baseParams models.BaseParams
  24751. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24752. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24753. baseParams.SecretKey = miConfig.SecretKey
  24754. baseParams.OrgName = miConfig.OrgName
  24755. baseParams.FixmedinsCode = miConfig.Code
  24756. baseParams.EncKey = miConfig.EncKey
  24757. baseParams.AppSecret = miConfig.AppSecret
  24758. baseParams.SignKey = miConfig.SignKey
  24759. baseParams.AppID = miConfig.Code
  24760. baseParams.Doctor = role.UserName
  24761. baseParams.RequestUrl = miConfig.Url
  24762. baseParams.AccessKey = miConfig.AccessKey
  24763. businessParams := models.BusinessParams{
  24764. Insutype: insutype,
  24765. ClrType: clr_type,
  24766. SetlOptins: "430822",
  24767. StmtBegndate: start_time,
  24768. StmtEnddate: end_time,
  24769. MedfeeSumamt: medfee_sumamt,
  24770. FundPaySumamt: fund_pay_sumamt,
  24771. AcctPay: acct_pay,
  24772. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24773. }
  24774. 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)
  24775. fmt.Println(requestLog)
  24776. fmt.Println(result)
  24777. var dat map[string]interface{}
  24778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24779. fmt.Println(dat)
  24780. } else {
  24781. fmt.Println(err)
  24782. }
  24783. userJSONBytes, _ := json.Marshal(dat)
  24784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24785. utils.ErrorLog("解析失败:%v", err)
  24786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24787. return
  24788. }
  24789. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24790. var baseParams models.BaseParams
  24791. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24792. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24793. baseParams.SecretKey = miConfig.SecretKey
  24794. baseParams.OrgName = miConfig.OrgName
  24795. baseParams.FixmedinsCode = miConfig.Code
  24796. baseParams.EncKey = miConfig.EncKey
  24797. baseParams.AppSecret = miConfig.AppSecret
  24798. baseParams.SignKey = miConfig.SignKey
  24799. baseParams.AppID = miConfig.Code
  24800. baseParams.Doctor = role.UserName
  24801. baseParams.RequestUrl = miConfig.Url
  24802. businessParams := models.BusinessParams{
  24803. Insutype: insutype,
  24804. ClrType: clr_type,
  24805. SetlOptins: clr_org,
  24806. StmtBegndate: start_time,
  24807. StmtEnddate: end_time,
  24808. MedfeeSumamt: medfee_sumamt,
  24809. FundPaySumamt: fund_pay_sumamt,
  24810. AcctPay: acct_pay,
  24811. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24812. }
  24813. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24814. fmt.Println(requestLog)
  24815. fmt.Println(result)
  24816. fmt.Println(err_msg)
  24817. var dat map[string]interface{}
  24818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24819. fmt.Println(dat)
  24820. } else {
  24821. fmt.Println(err)
  24822. }
  24823. userJSONBytes, _ := json.Marshal(dat)
  24824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24825. utils.ErrorLog("解析失败:%v", err)
  24826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24827. return
  24828. }
  24829. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24830. if len(clr_type) == 0 {
  24831. clr_type = "11"
  24832. }
  24833. api := miConfig.Url + "gdyb/ten?" +
  24834. "insutype=" + insutype +
  24835. "&clr_type=" + clr_type +
  24836. "&setl_optins=" + clr_org +
  24837. "&stmt_begndate=" + start_time +
  24838. "&stm_enddate=" + end_time +
  24839. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24840. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24841. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24842. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24843. "&fixmedins_code=" + miConfig.Code +
  24844. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24845. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24846. "&secret_key=" + miConfig.SecretKey +
  24847. "&org_name=" + miConfig.OrgName +
  24848. "&doctor=" + user_name
  24849. fmt.Println(api)
  24850. resp, requestErr := http.Get(api)
  24851. if requestErr != nil {
  24852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24853. return
  24854. }
  24855. body, ioErr := ioutil.ReadAll(resp.Body)
  24856. fmt.Println(body)
  24857. if ioErr != nil {
  24858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24860. return
  24861. }
  24862. var respJSON map[string]interface{}
  24863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24866. return
  24867. }
  24868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24869. userJSONBytes, _ := json.Marshal(respJSON)
  24870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24871. utils.ErrorLog("解析失败:%v", err)
  24872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24873. return
  24874. }
  24875. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24876. var baseParams models.BaseParams
  24877. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24878. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24879. baseParams.SecretKey = miConfig.SecretKey
  24880. baseParams.OrgName = miConfig.OrgName
  24881. baseParams.FixmedinsCode = miConfig.Code
  24882. baseParams.EncKey = miConfig.EncKey
  24883. baseParams.AppSecret = miConfig.AppSecret
  24884. baseParams.SignKey = miConfig.SignKey
  24885. baseParams.AppID = miConfig.Code
  24886. baseParams.Doctor = role.UserName
  24887. baseParams.RequestUrl = miConfig.Url
  24888. if clr_type == "9903" {
  24889. clr_type = "9901"
  24890. }
  24891. businessParams := models.BusinessParams{
  24892. Insutype: insutype,
  24893. ClrType: clr_type,
  24894. SetlOptins: "360302",
  24895. StmtBegndate: start_time,
  24896. StmtEnddate: end_time,
  24897. MedfeeSumamt: 0,
  24898. FundPaySumamt: 0,
  24899. AcctPay: 0,
  24900. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24901. }
  24902. 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))
  24903. fmt.Println(requestLog)
  24904. fmt.Println(result)
  24905. var dat map[string]interface{}
  24906. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24907. fmt.Println(dat)
  24908. } else {
  24909. fmt.Println(err)
  24910. }
  24911. userJSONBytes, _ := json.Marshal(dat)
  24912. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24913. utils.ErrorLog("解析失败:%v", err)
  24914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24915. return
  24916. }
  24917. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24918. var api string
  24919. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24920. "&clr_type=" + clr_type +
  24921. "&setl_optins=" + clr_org +
  24922. "&stmt_begndate=" + start_time +
  24923. "&stm_enddate=" + end_time +
  24924. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24925. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24926. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24927. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24928. "&fixmedins_code=" + miConfig.Code +
  24929. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24930. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24931. "&secret_key=" + miConfig.SecretKey +
  24932. "&org_name=" + miConfig.OrgName +
  24933. "&doctor=" + user_name + "&url=" + miConfig.Url
  24934. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24935. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24936. resp, requestErr := http.Get(api)
  24937. if requestErr != nil {
  24938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24939. return
  24940. }
  24941. body, ioErr := ioutil.ReadAll(resp.Body)
  24942. if ioErr != nil {
  24943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24945. return
  24946. }
  24947. var respJSON map[string]interface{}
  24948. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24951. return
  24952. }
  24953. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24954. if status == "0" {
  24955. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24956. c.ServeSuccessJSON(map[string]interface{}{
  24957. "failed_code": -10,
  24958. "msg": err_msg,
  24959. })
  24960. return
  24961. }
  24962. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24963. userJSONBytes, _ := json.Marshal(respJSON)
  24964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24965. utils.ErrorLog("解析失败:%v", err)
  24966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24967. return
  24968. }
  24969. } else {
  24970. if len(clr_type) == 0 {
  24971. clr_type = "11"
  24972. }
  24973. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24974. "insutype=" + insutype +
  24975. "&clr_type=" + clr_type +
  24976. "&setl_optins=" + clr_org +
  24977. "&stmt_begndate=" + start_time +
  24978. "&stm_enddate=" + end_time +
  24979. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24980. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24981. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24982. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24983. "&fixmedins_code=" + miConfig.Code +
  24984. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24985. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24986. "&secret_key=" + miConfig.SecretKey +
  24987. "&org_name=" + miConfig.OrgName +
  24988. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24989. fmt.Println(api)
  24990. resp, requestErr := http.Get(api)
  24991. if requestErr != nil {
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. body, ioErr := ioutil.ReadAll(resp.Body)
  24996. fmt.Println(body)
  24997. if ioErr != nil {
  24998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. var respJSON map[string]interface{}
  25003. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25006. return
  25007. }
  25008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25009. userJSONBytes, _ := json.Marshal(respJSON)
  25010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25011. utils.ErrorLog("解析失败:%v", err)
  25012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25013. return
  25014. }
  25015. }
  25016. if res.Infcode == 0 {
  25017. if res.Output.Stmtinfo.StmtRslt == "0" {
  25018. micc := &models.MedicalInsuranceCostCompare{
  25019. StartTime: startime.Unix(),
  25020. EndTime: endtime.Unix(),
  25021. Insutype: insutype,
  25022. CheckType: 1,
  25023. Num: fixmedins_setl_cnt,
  25024. Mtime: time.Now().Unix(),
  25025. Status: 1,
  25026. UserOrgId: adminUser.CurrentOrgId,
  25027. CostTotal: medfee_sumamt,
  25028. FuncTotal: fund_pay_sumamt,
  25029. PsnPay: acct_pay,
  25030. Creator: admin_user_id,
  25031. Ctime: time.Now().Unix(),
  25032. ClrType: clr_type,
  25033. }
  25034. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25035. if err == nil {
  25036. c.ServeSuccessJSON(map[string]interface{}{
  25037. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25038. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25039. })
  25040. } else {
  25041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25042. }
  25043. } else {
  25044. c.ServeSuccessJSON(map[string]interface{}{
  25045. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25046. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25047. })
  25048. }
  25049. } else {
  25050. c.ServeSuccessJSON(map[string]interface{}{
  25051. "failed_code": -10,
  25052. "msg": res.ErrMsg,
  25053. })
  25054. }
  25055. }
  25056. }
  25057. func (c *HisApiController) Check310() {
  25058. adminUser := c.GetAdminUserInfo()
  25059. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25060. var user_name string
  25061. user_name = "高慧裕"
  25062. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25063. "insutype=" + "310" +
  25064. "&clr_type=" + "" +
  25065. "&setl_optins=" + "441202" +
  25066. "&stmt_begndate=" + "2022-03-01" +
  25067. "&stm_enddate=" + "2022-03-31" +
  25068. "&medfee_sumamt=" + "194930.12" +
  25069. "&fund_pay_sumamt=" + "188741.46" +
  25070. "&acct_pay=" + "0" +
  25071. "&fixmedins_setl_cnt=" + "452" +
  25072. "&fixmedins_code=" + miConfig.Code +
  25073. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25074. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25075. "&secret_key=" + miConfig.SecretKey +
  25076. "&org_name=" + miConfig.OrgName +
  25077. "&doctor=" + user_name
  25078. fmt.Println(api)
  25079. resp, requestErr := http.Get(api)
  25080. if requestErr != nil {
  25081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25082. return
  25083. }
  25084. body, ioErr := ioutil.ReadAll(resp.Body)
  25085. fmt.Println(body)
  25086. if ioErr != nil {
  25087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25089. return
  25090. }
  25091. var respJSON map[string]interface{}
  25092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25095. return
  25096. }
  25097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25098. userJSONBytes, _ := json.Marshal(respJSON)
  25099. var res ResultEight
  25100. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25101. utils.ErrorLog("解析失败:%v", err)
  25102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25103. return
  25104. }
  25105. }
  25106. func (c *HisApiController) Check390() {
  25107. adminUser := c.GetAdminUserInfo()
  25108. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25109. var user_name string
  25110. user_name = "高慧裕"
  25111. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25112. "insutype=" + "390" +
  25113. "&clr_type=" + "" +
  25114. "&setl_optins=" + "441202" +
  25115. "&stmt_begndate=" + "2022-03-01" +
  25116. "&stm_enddate=" + "2022-03-31" +
  25117. "&medfee_sumamt=" + "1068448.89" +
  25118. "&fund_pay_sumamt=" + "1014677.62" +
  25119. "&acct_pay=" + "0" +
  25120. "&fixmedins_setl_cnt=" + "1950" +
  25121. "&fixmedins_code=" + miConfig.Code +
  25122. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25123. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25124. "&secret_key=" + miConfig.SecretKey +
  25125. "&org_name=" + miConfig.OrgName +
  25126. "&doctor=" + user_name
  25127. fmt.Println(api)
  25128. resp, requestErr := http.Get(api)
  25129. if requestErr != nil {
  25130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25131. return
  25132. }
  25133. body, ioErr := ioutil.ReadAll(resp.Body)
  25134. fmt.Println(body)
  25135. if ioErr != nil {
  25136. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25138. return
  25139. }
  25140. var respJSON map[string]interface{}
  25141. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25144. return
  25145. }
  25146. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25147. userJSONBytes, _ := json.Marshal(respJSON)
  25148. var res ResultEight
  25149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25150. utils.ErrorLog("解析失败:%v", err)
  25151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25152. return
  25153. }
  25154. }
  25155. // 对账明细
  25156. func (c *HisApiController) GetCheckDetailAccount() {
  25157. start_time := c.GetString("start_time")
  25158. end_time := c.GetString("end_time")
  25159. admin_user_id, _ := c.GetInt64("admin_user_id")
  25160. adminUser := c.GetAdminUserInfo()
  25161. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25162. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25163. timeLayout := "2006-01-02"
  25164. loc, _ := time.LoadLocation("Local")
  25165. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25166. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25167. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  25168. rand.Seed(time.Now().UnixNano())
  25169. num := rand.Intn(30000)
  25170. Mkdir(miConfig.OrgName)
  25171. file := strconv.FormatInt(int64(num), 10)
  25172. file_name := file + ".txt"
  25173. zip_name := file + ".zip"
  25174. zip_path := miConfig.OrgName + "/" + zip_name
  25175. file_path := miConfig.OrgName + "/" + file_name
  25176. decimal.DivisionPrecision = 2
  25177. var medfee_sumamt float64
  25178. var psn_cash_pay float64
  25179. var fund_pay_sumamt float64
  25180. fixmedins_setl_cnt := int64(len(orders))
  25181. for _, item := range orders {
  25182. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25183. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  25184. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25185. }
  25186. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  25187. defer f.Close()
  25188. if err != nil {
  25189. fmt.Println(err.Error())
  25190. } else {
  25191. for _, item := range orders {
  25192. var refd_setl_flag string
  25193. if item.OrderStatus == 2 {
  25194. refd_setl_flag = "0"
  25195. var str string
  25196. str = item.SetlId + " " +
  25197. item.MdtrtId + " " +
  25198. item.PsnNo + " " +
  25199. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25200. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25201. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  25202. _, err = f.Write([]byte(str))
  25203. }
  25204. if item.OrderStatus == 3 {
  25205. var str string
  25206. str = item.SetlId + " " +
  25207. item.MdtrtId + " " +
  25208. item.PsnNo + " " +
  25209. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25210. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25211. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  25212. _, err = f.Write([]byte(str))
  25213. var str2 string
  25214. str2 = item.SetlId + " " +
  25215. item.MdtrtId + " " +
  25216. item.PsnNo + " " +
  25217. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  25218. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  25219. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  25220. _, err = f.Write([]byte(str2))
  25221. }
  25222. }
  25223. }
  25224. Zip(file_path, zip_path)
  25225. fmt.Println(ReadFile(zip_path))
  25226. fmt.Println(string(ReadFile(zip_path)))
  25227. if config.IsOpen == 1 {
  25228. var user_name string
  25229. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25230. if role.ID == 0 {
  25231. user_name = "管理员"
  25232. } else {
  25233. user_name = role.UserName
  25234. }
  25235. baseParams := models.BaseParams{
  25236. SecretKey: miConfig.SecretKey,
  25237. FixmedinsCode: miConfig.Code,
  25238. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25239. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25240. OrgName: miConfig.OrgName,
  25241. Doctor: user_name,
  25242. }
  25243. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  25244. var dat map[string]interface{}
  25245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25246. fmt.Println(dat)
  25247. } else {
  25248. fmt.Println(err)
  25249. }
  25250. userJSONBytes, _ := json.Marshal(dat)
  25251. var res ResultNine
  25252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25253. utils.ErrorLog("解析失败:%v", err)
  25254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25255. return
  25256. }
  25257. if res.Infcode == 0 {
  25258. fileNo := res.Output.FileQuryNo
  25259. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  25260. "file_qury_no=" + fileNo +
  25261. "&setl_optins=" + "定点医保中心" +
  25262. "&stmt_begndate=" + start_time +
  25263. "&stm_enddate=" + end_time +
  25264. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25265. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25266. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  25267. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25268. "&fixmedins_code=" + miConfig.Code +
  25269. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25270. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25271. "&secret_key=" + miConfig.SecretKey +
  25272. "&org_name=" + miConfig.OrgName +
  25273. "&doctor=" + user_name
  25274. resp, requestErr := http.Get(api)
  25275. if requestErr != nil {
  25276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25277. return
  25278. }
  25279. body, ioErr := ioutil.ReadAll(resp.Body)
  25280. if ioErr != nil {
  25281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25283. return
  25284. }
  25285. var respJSON map[string]interface{}
  25286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25289. return
  25290. }
  25291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25292. userJSONBytes, _ := json.Marshal(respJSON)
  25293. var res ResultTen
  25294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25295. utils.ErrorLog("解析失败:%v", err)
  25296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25297. return
  25298. }
  25299. if res.Infcode == 0 {
  25300. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  25301. micc := &models.MedicalInsuranceCostCompare{
  25302. StartTime: startime.Unix(),
  25303. EndTime: endtime.Unix(),
  25304. Insutype: "0",
  25305. CheckType: 2,
  25306. Num: fixmedins_setl_cnt,
  25307. Mtime: time.Now().Unix(),
  25308. Status: 1,
  25309. UserOrgId: adminUser.CurrentOrgId,
  25310. CostTotal: medfee_sumamt,
  25311. FuncTotal: fund_pay_sumamt,
  25312. PsnPay: psn_cash_pay,
  25313. Creator: admin_user_id,
  25314. Ctime: time.Now().Unix(),
  25315. }
  25316. service.CreateMedicalInsuranceCostCompareRecord(micc)
  25317. c.ServeSuccessJSON(map[string]interface{}{
  25318. "msg": "明细对账成功",
  25319. })
  25320. }
  25321. } else {
  25322. }
  25323. }
  25324. }
  25325. type CustomOrderInfo struct {
  25326. Name string
  25327. Spec string
  25328. Unit string
  25329. Count float64
  25330. Price float64
  25331. Total float64
  25332. }
  25333. func (c *HisApiController) GetBatchSettleAccounts() {
  25334. admin_user_id, _ := c.GetInt64("admin_user_id")
  25335. order_ids := c.GetString("order_ids")
  25336. order_ids_arr := strings.Split(order_ids, ",")
  25337. data3 := []map[string]interface{}{}
  25338. for _, item := range order_ids_arr {
  25339. id, _ := strconv.ParseInt(item, 10, 64)
  25340. order_id := id
  25341. adminUser := c.GetAdminUserInfo()
  25342. order, _ := service.GetHisOrderByID(order_id)
  25343. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25344. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25345. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25346. orderInfos = append(orderInfos, orderInfos_two...)
  25347. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25348. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25349. var diagnosis_ids []string
  25350. if his.ID > 0 {
  25351. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25352. } else {
  25353. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25354. }
  25355. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25356. var dia_config []*models.HisXtDiagnoseConfig
  25357. var name string
  25358. for _, item := range diagnosis_ids {
  25359. id, _ := strconv.ParseInt(item, 10, 64)
  25360. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25361. dia_config = append(dia_config, &diagnosisConfig)
  25362. if len(name) == 0 {
  25363. name = diagnosisConfig.ClassName
  25364. }
  25365. //} else {
  25366. // name = name + "," + diagnosisConfig.ClassName
  25367. //}
  25368. }
  25369. var bedCostTotal float64 = 0 //床位总费
  25370. var bedCostSelfTotal float64 = 0 //床位自费
  25371. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25372. var bedSelfTotal float64 = 0 //床位部分项目自费
  25373. var bedInscpTotal float64 = 0 //床位部分项目自费
  25374. var operationCostTotal float64 = 0 //手术费
  25375. var operationCostSelfTotal float64 = 0 //手术费
  25376. var operationCostPartSelfTotal float64 = 0 //手术费
  25377. var operationSelfTotal float64 = 0 //床位部分项目自费
  25378. var operationInscpTotal float64 = 0 //床位部分项目自费
  25379. var otherCostTotal float64 = 0 //其他费用
  25380. var otherCostSelfTotal float64 = 0 //其他费用
  25381. var otherCostPartSelfTotal float64 = 0 //其他费用
  25382. var otherSelfTotal float64 = 0 //床位部分项目自费
  25383. var otherInscpTotal float64 = 0 //床位部分项目自费
  25384. var materialCostTotal float64 = 0 //材料费
  25385. var materialCostSelfTotal float64 = 0 //材料费
  25386. var materialCostPartSelfTotal float64 = 0 //材料费
  25387. var materialSelfTotal float64 = 0 //床位部分项目自费
  25388. var materialInscpTotal float64 = 0 //床位部分项目自费
  25389. var westernMedicineCostTotal float64 = 0 //西药费
  25390. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25391. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25392. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25393. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25394. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25395. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25396. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25397. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25398. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25399. var checkCostTotal float64 = 0 //检查费
  25400. var checkCostSelfTotal float64 = 0 //检查费
  25401. var checkCostPartSelfTotal float64 = 0 //检查费
  25402. var checkSelfTotal float64 = 0 //床位部分项目自费
  25403. var checkInscpTotal float64 = 0 //床位部分项目自费
  25404. var laboratoryCostTotal float64 = 0 //化验费
  25405. var laboratoryCostSelfTotal float64 = 0 //化验费
  25406. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25407. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25408. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25409. var treatCostTotal float64 = 0 //治疗费用
  25410. var treatCostSelfTotal float64 = 0 //治疗费用
  25411. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25412. var treatSelfTotal float64 = 0 //床位部分项目自费
  25413. var treatInscpTotal float64 = 0 //床位部分项目自费
  25414. decimal.DivisionPrecision = 2
  25415. for _, item := range orderInfos {
  25416. if item.MedChrgitmType == "01" { //床位费
  25417. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25418. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25419. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25420. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25421. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25422. }
  25423. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25424. if item.MedChrgitmType == "03" { //检查费
  25425. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25426. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25427. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25428. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25429. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25430. }
  25431. } else {
  25432. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25433. fmt.Println("------------")
  25434. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25435. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25436. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25437. }
  25438. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25439. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25440. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25441. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25442. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25443. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25444. }
  25445. }
  25446. if item.MedChrgitmType == "04" { //化验费
  25447. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25448. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25449. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25450. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25451. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25452. }
  25453. if item.MedChrgitmType == "05" { //治疗费
  25454. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25455. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25456. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25457. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25458. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25459. }
  25460. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25461. fmt.Println("------------")
  25462. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25463. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25464. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25465. }
  25466. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25467. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25468. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25469. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25470. }
  25471. //if item.MedChrgitmType == "06" { //手术费
  25472. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25473. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25474. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25475. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25476. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25477. //
  25478. //}
  25479. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25480. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25481. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25482. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25483. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25484. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25485. }
  25486. if item.MedChrgitmType == "09" { //西药费
  25487. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25488. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25489. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25490. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25491. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25492. }
  25493. if item.MedChrgitmType == "11" { //中成费
  25494. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25495. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25496. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25497. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25498. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25499. }
  25500. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25501. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25502. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25503. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25504. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25505. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25506. }
  25507. }
  25508. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25509. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25510. var user_name string
  25511. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25512. if role.ID == 0 {
  25513. user_name = "管理员"
  25514. } else {
  25515. user_name = role.UserName
  25516. }
  25517. baseParams := models.BaseParams{
  25518. SecretKey: miConfig.SecretKey,
  25519. FixmedinsCode: miConfig.Code,
  25520. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25521. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25522. OrgName: miConfig.OrgName,
  25523. Doctor: user_name,
  25524. RequestUrl: miConfig.Url,
  25525. AccessKey: miConfig.AccessKey,
  25526. }
  25527. businessParams := models.BusinessParams{
  25528. PsnNo: order.PsnNo,
  25529. MdtrtId: order.MdtrtId,
  25530. SetlId: order.SetlId,
  25531. }
  25532. var res ResultEleven
  25533. var resEleven10265 ResultEleven10265
  25534. if config.IsOpen == 1 {
  25535. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25536. result := service.Gdyb5203(baseParams, businessParams)
  25537. service.Gdyb5204(baseParams, businessParams)
  25538. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25539. var dat map[string]interface{}
  25540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25541. fmt.Println(dat)
  25542. } else {
  25543. fmt.Println(err)
  25544. }
  25545. userJSONBytes, _ := json.Marshal(dat)
  25546. if miConfig.Code == "H15049901371" {
  25547. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25548. utils.ErrorLog("解析失败:%v", err)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25553. res.Output = resEleven10265.Output
  25554. res.ErrMsg = resEleven10265.ErrMsg
  25555. res.Cainfo = resEleven10265.Cainfo
  25556. res.WarnMsg = resEleven10265.WarnMsg
  25557. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25558. res.Infcode = infocode
  25559. } else {
  25560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25561. utils.ErrorLog("解析失败:%v", err)
  25562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25563. return
  25564. }
  25565. }
  25566. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25567. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25568. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25569. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25570. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25571. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25572. var doctor_name string
  25573. if roles.ID == 0 {
  25574. doctor_name = "管理员"
  25575. } else {
  25576. doctor_name = roles.UserName
  25577. }
  25578. yiliao_leibie := ""
  25579. switch order.MedType {
  25580. case "11":
  25581. yiliao_leibie = "普通门诊"
  25582. break
  25583. case "12":
  25584. yiliao_leibie = "门诊挂号"
  25585. break
  25586. case "13":
  25587. yiliao_leibie = "急诊"
  25588. break
  25589. case "14":
  25590. yiliao_leibie = "门诊特殊病"
  25591. break
  25592. case "15":
  25593. yiliao_leibie = "门诊统筹"
  25594. break
  25595. case "16":
  25596. yiliao_leibie = "门诊慢性病"
  25597. break
  25598. case "21":
  25599. yiliao_leibie = "普通住院"
  25600. break
  25601. }
  25602. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25603. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  25604. if res.Infcode == 0 {
  25605. data2 := map[string]interface{}{
  25606. "diagnosis": name,
  25607. "order_infos": orderInfos,
  25608. "number": order.MdtrtId,
  25609. "date": order.SettleAccountsDate,
  25610. "charge_admin": charge_admin,
  25611. "printor_admin": printor_admin,
  25612. "info": res.Output.Setlinfo,
  25613. "order": order,
  25614. "bedCostTotal": bedCostTotal,
  25615. "bedCostSelfTotal": bedCostSelfTotal,
  25616. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25617. "bedSelfTotal": bedSelfTotal,
  25618. "bedInscpTotal": bedInscpTotal,
  25619. "operationCostTotal": operationCostTotal,
  25620. "operationCostSelfTotal": operationCostSelfTotal,
  25621. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25622. "operationSelfTotal": operationSelfTotal,
  25623. "operationInscpTotal": operationInscpTotal,
  25624. "otherCostTotal": otherCostTotal,
  25625. "otherCostSelfTotal": otherCostSelfTotal,
  25626. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25627. "otherSelfTotal": otherSelfTotal,
  25628. "otherInscpTotal": otherInscpTotal,
  25629. "materialCostTotal": materialCostTotal,
  25630. "materialCostSelfTotal": materialCostSelfTotal,
  25631. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25632. "materialSelfTotal": materialSelfTotal,
  25633. "materialInscpTotal": materialInscpTotal,
  25634. "westernMedicineCostTotal": westernMedicineCostTotal,
  25635. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25636. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25637. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25638. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25639. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25640. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25641. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25642. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25643. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25644. "checkCostTotal": checkCostTotal,
  25645. "checkCostSelfTotal": checkCostSelfTotal,
  25646. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25647. "checkSelfTotal": checkSelfTotal,
  25648. "checkInscpTotal": checkInscpTotal,
  25649. "laboratoryCostTotal": laboratoryCostTotal,
  25650. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25651. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25652. "laboratorySelfTotal": laboratorySelfTotal,
  25653. "laboratoryInscpTotal": laboratoryInscpTotal,
  25654. "treatCostTotal": treatCostTotal,
  25655. "treatCostSelfTotal": treatCostSelfTotal,
  25656. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25657. "treatSelfTotal": treatSelfTotal,
  25658. "treatInscpTotal": treatInscpTotal,
  25659. "doctor_info": doctor_info,
  25660. "doctor_code": adminRole_two.DoctorCode,
  25661. "doctor_name": doctor_name,
  25662. "health_card_no": order.PsnNo,
  25663. "department": departments.Name,
  25664. "yiliao_leibie": yiliao_leibie,
  25665. "after_money": order.AccountPrice,
  25666. "patient": patient,
  25667. "org_name": miConfig.OrgName,
  25668. "org_code": miConfig.Code,
  25669. "order_number": order.Number,
  25670. "his_hospital": his_hospital,
  25671. "his": his,
  25672. "dia_config": dia_config,
  25673. "psn_cash_pay": order.PsnCashPay,
  25674. //"check_order_info": cus_slice,
  25675. }
  25676. data3 = append(data3, data2)
  25677. }
  25678. }
  25679. }
  25680. c.ServeSuccessJSON(map[string]interface{}{
  25681. "infos": data3,
  25682. })
  25683. }
  25684. func (c *HisApiController) GetSettleAccounts() {
  25685. //id, _ := c.GetInt64("id")
  25686. //record_time := c.GetString("record_time")
  25687. order_id, _ := c.GetInt64("order_id")
  25688. admin_user_id, _ := c.GetInt64("admin_user_id")
  25689. //timeLayout := "2006-01-02"
  25690. //loc, _ := time.LoadLocation("Local")
  25691. //
  25692. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25693. //if err != nil {
  25694. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25695. // return
  25696. //}Hbyb5203
  25697. //recordDateTime := theTime.Unix()
  25698. adminUser := c.GetAdminUserInfo()
  25699. order, _ := service.GetHisOrderByID(order_id)
  25700. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25701. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25702. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25703. orderInfos = append(orderInfos, orderInfos_two...)
  25704. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25705. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25706. var diagnosis_ids []string
  25707. if his.ID > 0 {
  25708. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25709. } else {
  25710. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25711. }
  25712. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25713. var dia_config []*models.HisXtDiagnoseConfig
  25714. var name string
  25715. for _, item := range diagnosis_ids {
  25716. id, _ := strconv.ParseInt(item, 10, 64)
  25717. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25718. dia_config = append(dia_config, &diagnosisConfig)
  25719. if len(name) == 0 {
  25720. name = diagnosisConfig.ClassName
  25721. } else {
  25722. name = name + "," + diagnosisConfig.ClassName
  25723. }
  25724. }
  25725. if patient.UserOrgId == 10215 {
  25726. name = "慢性肾功能不全(血透治疗)"
  25727. }
  25728. var bedCostTotal float64 = 0 //床位总费
  25729. var bedCostSelfTotal float64 = 0 //床位自费
  25730. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25731. var bedSelfTotal float64 = 0 //床位部分项目自费
  25732. var bedInscpTotal float64 = 0 //床位部分项目自费
  25733. var operationCostTotal float64 = 0 //手术费
  25734. var operationCostSelfTotal float64 = 0 //手术费
  25735. var operationCostPartSelfTotal float64 = 0 //手术费
  25736. var operationSelfTotal float64 = 0 //床位部分项目自费
  25737. var operationInscpTotal float64 = 0 //床位部分项目自费
  25738. var otherCostTotal float64 = 0 //其他费用
  25739. var otherCostSelfTotal float64 = 0 //其他费用
  25740. var otherCostPartSelfTotal float64 = 0 //其他费用
  25741. var otherSelfTotal float64 = 0 //床位部分项目自费
  25742. var otherInscpTotal float64 = 0 //床位部分项目自费
  25743. var materialCostTotal float64 = 0 //材料费
  25744. var materialCostSelfTotal float64 = 0 //材料费
  25745. var materialCostPartSelfTotal float64 = 0 //材料费
  25746. var materialSelfTotal float64 = 0 //床位部分项目自费
  25747. var materialInscpTotal float64 = 0 //床位部分项目自费
  25748. var westernMedicineCostTotal float64 = 0 //西药费
  25749. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25750. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25751. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25752. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25753. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25754. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25755. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25756. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25757. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25758. var checkCostTotal float64 = 0 //检查费
  25759. var checkCostSelfTotal float64 = 0 //检查费
  25760. var checkCostPartSelfTotal float64 = 0 //检查费
  25761. var checkSelfTotal float64 = 0 //床位部分项目自费
  25762. var checkInscpTotal float64 = 0 //床位部分项目自费
  25763. var laboratoryCostTotal float64 = 0 //化验费
  25764. var laboratoryCostSelfTotal float64 = 0 //化验费
  25765. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25766. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25767. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25768. var treatCostTotal float64 = 0 //治疗费用
  25769. var treatCostSelfTotal float64 = 0 //治疗费用
  25770. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25771. var treatSelfTotal float64 = 0 //床位部分项目自费
  25772. var treatInscpTotal float64 = 0 //床位部分项目自费
  25773. decimal.DivisionPrecision = 2
  25774. for _, item := range orderInfos {
  25775. if item.MedChrgitmType == "01" { //床位费
  25776. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25777. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25778. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25779. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25780. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25781. }
  25782. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25783. if item.MedChrgitmType == "03" { //检查费
  25784. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25785. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25786. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25787. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25788. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25789. }
  25790. } else {
  25791. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25792. fmt.Println("------------")
  25793. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25794. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25795. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25796. }
  25797. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25798. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25799. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25800. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25801. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25802. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25803. }
  25804. }
  25805. if item.MedChrgitmType == "04" { //化验费
  25806. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25807. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25808. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25809. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25810. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25811. }
  25812. if item.MedChrgitmType == "05" { //治疗费
  25813. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25814. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25815. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25816. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25817. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25818. }
  25819. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25820. fmt.Println("------------")
  25821. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25822. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25823. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25824. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25825. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25826. }
  25827. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25828. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25829. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25830. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25831. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25832. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25833. }
  25834. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25835. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25836. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25837. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25838. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25839. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25840. }
  25841. if item.MedChrgitmType == "09" { //西药费
  25842. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25843. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25844. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25845. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25846. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25847. }
  25848. if item.MedChrgitmType == "11" { //中成费
  25849. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25850. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25851. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25852. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25853. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25854. }
  25855. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25856. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25857. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25858. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25859. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25860. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25861. }
  25862. }
  25863. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25864. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25865. var user_name string
  25866. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25867. if role.ID == 0 {
  25868. user_name = "管理员"
  25869. } else {
  25870. user_name = role.UserName
  25871. }
  25872. baseParams := models.BaseParams{
  25873. SecretKey: miConfig.SecretKey,
  25874. FixmedinsCode: miConfig.Code,
  25875. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25876. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25877. OrgName: miConfig.OrgName,
  25878. Doctor: user_name,
  25879. RequestUrl: miConfig.Url,
  25880. AccessKey: miConfig.AccessKey,
  25881. }
  25882. businessParams := models.BusinessParams{
  25883. PsnNo: order.PsnNo,
  25884. MdtrtId: order.MdtrtId,
  25885. SetlId: order.SetlId,
  25886. }
  25887. var res ResultEleven
  25888. var resah ResultElevenah
  25889. var resEleven10265 ResultEleven10265
  25890. if config.IsOpen == 1 {
  25891. if miConfig.MdtrtareaAdmvs == "421300" {
  25892. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25893. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25894. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25895. resp, requestErr := http.Get(api)
  25896. if requestErr != nil {
  25897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25898. return
  25899. }
  25900. body, ioErr := ioutil.ReadAll(resp.Body)
  25901. if ioErr != nil {
  25902. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25904. return
  25905. }
  25906. var respJSON map[string]interface{}
  25907. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25910. return
  25911. }
  25912. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25913. result, _ := json.Marshal(respJSON)
  25914. fmt.Println("log")
  25915. fmt.Println(string(result))
  25916. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25917. utils.ErrorLog("解析失败:%v", err)
  25918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25919. return
  25920. }
  25921. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25922. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25923. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25924. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25925. resp, requestErr := http.Get(api)
  25926. if requestErr != nil {
  25927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25928. return
  25929. }
  25930. body, ioErr := ioutil.ReadAll(resp.Body)
  25931. if ioErr != nil {
  25932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25934. return
  25935. }
  25936. var respJSON map[string]interface{}
  25937. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25940. return
  25941. }
  25942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25943. result, _ := json.Marshal(respJSON)
  25944. fmt.Println("log")
  25945. fmt.Println(string(result))
  25946. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25947. utils.ErrorLog("解析失败:%v", err)
  25948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25949. return
  25950. }
  25951. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25952. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25953. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25954. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  25955. resp, requestErr := http.Get(api)
  25956. if requestErr != nil {
  25957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25958. return
  25959. }
  25960. body, ioErr := ioutil.ReadAll(resp.Body)
  25961. if ioErr != nil {
  25962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25964. return
  25965. }
  25966. var respJSON map[string]interface{}
  25967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25970. return
  25971. }
  25972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25973. result, _ := json.Marshal(respJSON)
  25974. fmt.Println("log")
  25975. fmt.Println(string(result))
  25976. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25977. utils.ErrorLog("解析失败:%v", err)
  25978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25979. return
  25980. }
  25981. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25982. var api string
  25983. if miConfig.MdtrtareaAdmvs == "320921" {
  25984. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25985. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25986. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25987. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25988. } else {
  25989. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25990. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25991. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25992. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25993. }
  25994. resp, requestErr := http.Get(api)
  25995. if requestErr != nil {
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. body, ioErr := ioutil.ReadAll(resp.Body)
  26000. if ioErr != nil {
  26001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. var respJSON map[string]interface{}
  26006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26009. return
  26010. }
  26011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26012. result, _ := json.Marshal(respJSON)
  26013. fmt.Println("log")
  26014. fmt.Println(string(result))
  26015. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26016. utils.ErrorLog("解析失败:%v", err)
  26017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26018. return
  26019. }
  26020. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26021. res.Output = resEleven10265.Output
  26022. res.ErrMsg = resEleven10265.ErrMsg
  26023. res.Cainfo = resEleven10265.Cainfo
  26024. res.WarnMsg = resEleven10265.WarnMsg
  26025. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26026. res.Infcode = infocode
  26027. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26028. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26029. saveLog(result, requestLog, "5203", "结算单")
  26030. var dat map[string]interface{}
  26031. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26032. fmt.Println(dat)
  26033. } else {
  26034. fmt.Println(err)
  26035. }
  26036. userJSONBytes, _ := json.Marshal(dat)
  26037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26038. utils.ErrorLog("解析失败:%v", err)
  26039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26040. return
  26041. }
  26042. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26043. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26044. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26045. fmt.Println(result3)
  26046. fmt.Println(requestLog3)
  26047. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26048. fmt.Println(result2)
  26049. fmt.Println(requestLog2)
  26050. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26051. saveLog(result, requestLog, "5203", "结算单")
  26052. var dat map[string]interface{}
  26053. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26054. fmt.Println(dat)
  26055. } else {
  26056. fmt.Println(err)
  26057. }
  26058. userJSONBytes, _ := json.Marshal(dat)
  26059. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26060. utils.ErrorLog("解析失败:%v", err)
  26061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26062. return
  26063. }
  26064. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26065. var api string
  26066. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26067. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26069. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26070. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26071. resp, requestErr := http.Get(api)
  26072. if requestErr != nil {
  26073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26074. return
  26075. }
  26076. body, ioErr := ioutil.ReadAll(resp.Body)
  26077. if ioErr != nil {
  26078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26080. return
  26081. }
  26082. var respJSON map[string]interface{}
  26083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26086. return
  26087. }
  26088. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26089. if status == "0" {
  26090. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26091. c.ServeSuccessJSON(map[string]interface{}{
  26092. "failed_code": -10,
  26093. "msg": err_msg,
  26094. })
  26095. return
  26096. }
  26097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26098. result, _ := json.Marshal(respJSON)
  26099. fmt.Println("log")
  26100. fmt.Println(string(result))
  26101. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26102. utils.ErrorLog("解析失败:%v", err)
  26103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26104. return
  26105. }
  26106. res.InfRefmsgid = resah.InfRefmsgid
  26107. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26108. // 创建对应的Time类型
  26109. t := time.UnixMilli(timestamp)
  26110. // 格式化成指定的日期字符串
  26111. str := t.Format("2006-01-02 15:04:05")
  26112. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26113. // 创建对应的Time类型
  26114. t3 := time.UnixMilli(timestamp2)
  26115. // 格式化成指定的日期字符串
  26116. str2 := t3.Format("2006-01-02 15:04:05")
  26117. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  26118. // 创建对应的Time类型
  26119. t4 := time.UnixMilli(timestamp3)
  26120. // 格式化成指定的日期字符串
  26121. str3 := t4.Format("2006-01-02 15:04:05")
  26122. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  26123. // 创建对应的Time类型
  26124. t5 := time.UnixMilli(timestamp4)
  26125. // 格式化成指定的日期字符串
  26126. str5 := t5.Format("2006-01-02 15:04:05")
  26127. res.Output.Setlinfo.Brdy = str2
  26128. res.Output.Setlinfo.SetlTime = str
  26129. res.Output.Setlinfo.Begndate = str3
  26130. res.Output.Setlinfo.Enddate = str5
  26131. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  26132. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  26133. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  26134. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  26135. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26136. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26137. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  26138. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  26139. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26140. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  26141. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  26142. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  26143. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26144. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  26145. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  26146. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  26147. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  26148. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  26149. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26150. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  26151. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  26152. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26153. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  26154. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  26155. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  26156. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26157. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  26158. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  26159. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  26160. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  26161. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26162. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  26163. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26164. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  26165. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  26166. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  26167. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  26168. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  26169. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  26170. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  26171. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  26172. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  26173. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  26174. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  26175. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  26176. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26177. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  26178. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  26179. //res.Output.Setldetail = resah.Output.Setldetail
  26180. res.ErrMsg = resah.ErrMsg
  26181. res.Cainfo = resah.Cainfo
  26182. res.WarnMsg = resah.WarnMsg
  26183. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26184. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  26185. saveLog(result, requestLog, "5203", "结算单")
  26186. var dat map[string]interface{}
  26187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26188. fmt.Println(dat)
  26189. } else {
  26190. fmt.Println(err)
  26191. }
  26192. userJSONBytes, _ := json.Marshal(dat)
  26193. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26194. utils.ErrorLog("解析失败:%v", err)
  26195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26196. return
  26197. }
  26198. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26199. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26200. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26201. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26202. resp, requestErr := http.Get(api)
  26203. if requestErr != nil {
  26204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26205. return
  26206. }
  26207. body, ioErr := ioutil.ReadAll(resp.Body)
  26208. if ioErr != nil {
  26209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26211. return
  26212. }
  26213. var respJSON map[string]interface{}
  26214. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26217. return
  26218. }
  26219. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26220. result, _ := json.Marshal(respJSON)
  26221. fmt.Println("log")
  26222. fmt.Println(string(result))
  26223. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26224. utils.ErrorLog("解析失败:%v", err)
  26225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26226. return
  26227. }
  26228. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26229. res.Output = resEleven10265.Output
  26230. res.ErrMsg = resEleven10265.ErrMsg
  26231. res.Cainfo = resEleven10265.Cainfo
  26232. res.WarnMsg = resEleven10265.WarnMsg
  26233. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26234. res.Infcode = infocode
  26235. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26236. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26237. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26238. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26239. resp, requestErr := http.Get(api)
  26240. if requestErr != nil {
  26241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26242. return
  26243. }
  26244. body, ioErr := ioutil.ReadAll(resp.Body)
  26245. if ioErr != nil {
  26246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26248. return
  26249. }
  26250. var respJSON map[string]interface{}
  26251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26254. return
  26255. }
  26256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26257. result, _ := json.Marshal(respJSON)
  26258. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26259. utils.ErrorLog("解析失败:%v", err)
  26260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26261. return
  26262. }
  26263. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26264. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  26265. //return
  26266. } else {
  26267. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26268. if len(his.InsuplcAdmdvs) == 0 {
  26269. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26270. } else {
  26271. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26272. }
  26273. result := service.Gdyb5203(baseParams, businessParams)
  26274. //service.Gdyb5204(baseParams, businessParams)
  26275. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26276. var dat map[string]interface{}
  26277. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26278. fmt.Println(dat)
  26279. } else {
  26280. fmt.Println(err)
  26281. }
  26282. userJSONBytes, _ := json.Marshal(dat)
  26283. if miConfig.Code == "H15049901371" {
  26284. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26285. utils.ErrorLog("解析失败:%v", err)
  26286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26287. return
  26288. }
  26289. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26290. res.Output = resEleven10265.Output
  26291. res.ErrMsg = resEleven10265.ErrMsg
  26292. res.Cainfo = resEleven10265.Cainfo
  26293. res.WarnMsg = resEleven10265.WarnMsg
  26294. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26295. res.Infcode = infocode
  26296. } else {
  26297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26298. utils.ErrorLog("解析失败:%v", err)
  26299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26300. return
  26301. }
  26302. }
  26303. }
  26304. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26305. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26306. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26307. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26308. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26309. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26310. var doctor_name string
  26311. if roles.ID == 0 {
  26312. doctor_name = "管理员"
  26313. } else {
  26314. doctor_name = roles.UserName
  26315. }
  26316. yiliao_leibie := ""
  26317. switch order.MedType {
  26318. case "11":
  26319. yiliao_leibie = "普通门诊"
  26320. break
  26321. case "12":
  26322. yiliao_leibie = "门诊挂号"
  26323. break
  26324. case "13":
  26325. yiliao_leibie = "急诊"
  26326. break
  26327. case "14":
  26328. yiliao_leibie = "门诊特殊病"
  26329. break
  26330. case "15":
  26331. yiliao_leibie = "门诊统筹"
  26332. break
  26333. case "16":
  26334. yiliao_leibie = "门诊慢性病"
  26335. break
  26336. case "21":
  26337. yiliao_leibie = "普通住院"
  26338. break
  26339. }
  26340. //var rf []CustomFundPay
  26341. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  26342. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26343. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  26344. if res.Infcode == 0 {
  26345. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  26346. c.ServeSuccessJSON(map[string]interface{}{
  26347. "diagnosis": name,
  26348. "order_infos": orderInfos,
  26349. "number": order.MdtrtId,
  26350. "date": order.SettleAccountsDate,
  26351. "charge_admin": charge_admin,
  26352. "printor_admin": printor_admin,
  26353. "info": res.Output.Setlinfo,
  26354. "order": order,
  26355. "bedCostTotal": bedCostTotal,
  26356. "bedCostSelfTotal": bedCostSelfTotal,
  26357. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26358. "bedSelfTotal": bedSelfTotal,
  26359. "bedInscpTotal": bedInscpTotal,
  26360. "operationCostTotal": operationCostTotal,
  26361. "operationCostSelfTotal": operationCostSelfTotal,
  26362. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26363. "operationSelfTotal": operationSelfTotal,
  26364. "operationInscpTotal": operationInscpTotal,
  26365. "otherCostTotal": otherCostTotal,
  26366. "otherCostSelfTotal": otherCostSelfTotal,
  26367. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26368. "otherSelfTotal": otherSelfTotal,
  26369. "otherInscpTotal": otherInscpTotal,
  26370. "materialCostTotal": materialCostTotal,
  26371. "materialCostSelfTotal": materialCostSelfTotal,
  26372. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26373. "materialSelfTotal": materialSelfTotal,
  26374. "materialInscpTotal": materialInscpTotal,
  26375. "westernMedicineCostTotal": westernMedicineCostTotal,
  26376. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26377. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26378. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26379. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26380. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26381. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26382. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26383. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26384. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26385. "checkCostTotal": checkCostTotal,
  26386. "checkCostSelfTotal": checkCostSelfTotal,
  26387. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26388. "checkSelfTotal": checkSelfTotal,
  26389. "checkInscpTotal": checkInscpTotal,
  26390. "laboratoryCostTotal": laboratoryCostTotal,
  26391. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26392. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26393. "laboratorySelfTotal": laboratorySelfTotal,
  26394. "laboratoryInscpTotal": laboratoryInscpTotal,
  26395. "treatCostTotal": treatCostTotal,
  26396. "treatCostSelfTotal": treatCostSelfTotal,
  26397. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26398. "treatSelfTotal": treatSelfTotal,
  26399. "treatInscpTotal": treatInscpTotal,
  26400. "doctor_info": doctor_info,
  26401. "doctor_code": adminRole_two.DoctorCode,
  26402. "doctor_name": doctor_name,
  26403. "health_card_no": order.PsnNo,
  26404. "department": departments.Name,
  26405. "yiliao_leibie": yiliao_leibie,
  26406. "after_money": order.AccountPrice,
  26407. "patient": patient,
  26408. "org_name": miConfig.OrgName,
  26409. "org_code": miConfig.Code,
  26410. "order_number": order.Number,
  26411. "his_hospital": his_hospital,
  26412. "his": his,
  26413. "dia_config": dia_config,
  26414. "psn_cash_pay": order.PsnCashPay,
  26415. //"funds": rf,
  26416. //"check_order_info": cus_slice,
  26417. })
  26418. } else {
  26419. c.ServeSuccessJSON(map[string]interface{}{
  26420. "diagnosis": name,
  26421. "order_infos": orderInfos,
  26422. "number": order.MdtrtId,
  26423. "date": order.SettleAccountsDate,
  26424. "charge_admin": charge_admin,
  26425. "printor_admin": printor_admin,
  26426. "info": order,
  26427. "order": order,
  26428. "bedCostTotal": bedCostTotal,
  26429. "bedCostSelfTotal": bedCostSelfTotal,
  26430. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26431. "bedSelfTotal": bedSelfTotal,
  26432. "bedInscpTotal": bedInscpTotal,
  26433. "operationCostTotal": operationCostTotal,
  26434. "operationCostSelfTotal": operationCostSelfTotal,
  26435. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26436. "operationSelfTotal": operationSelfTotal,
  26437. "operationInscpTotal": operationInscpTotal,
  26438. "otherCostTotal": otherCostTotal,
  26439. "otherCostSelfTotal": otherCostSelfTotal,
  26440. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26441. "otherSelfTotal": otherSelfTotal,
  26442. "otherInscpTotal": otherInscpTotal,
  26443. "materialCostTotal": materialCostTotal,
  26444. "materialCostSelfTotal": materialCostSelfTotal,
  26445. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26446. "materialSelfTotal": materialSelfTotal,
  26447. "materialInscpTotal": materialInscpTotal,
  26448. "westernMedicineCostTotal": westernMedicineCostTotal,
  26449. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26450. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26451. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26452. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26453. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26454. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26455. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26456. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26457. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26458. "checkCostTotal": checkCostTotal,
  26459. "checkCostSelfTotal": checkCostSelfTotal,
  26460. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26461. "checkSelfTotal": checkSelfTotal,
  26462. "checkInscpTotal": checkInscpTotal,
  26463. "laboratoryCostTotal": laboratoryCostTotal,
  26464. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26465. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26466. "laboratorySelfTotal": laboratorySelfTotal,
  26467. "laboratoryInscpTotal": laboratoryInscpTotal,
  26468. "treatCostTotal": treatCostTotal,
  26469. "treatCostSelfTotal": treatCostSelfTotal,
  26470. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26471. "treatSelfTotal": treatSelfTotal,
  26472. "treatInscpTotal": treatInscpTotal,
  26473. "doctor_info": doctor_info,
  26474. "doctor_code": adminRole_two.DoctorCode,
  26475. "doctor_name": doctor_name,
  26476. "health_card_no": order.PsnNo,
  26477. "department": departments.Name,
  26478. "yiliao_leibie": yiliao_leibie,
  26479. "after_money": order.AccountPrice,
  26480. "patient": patient,
  26481. "org_name": miConfig.OrgName,
  26482. "org_code": miConfig.Code,
  26483. "order_number": order.Number,
  26484. "his_hospital": his_hospital,
  26485. "his": his,
  26486. "dia_config": dia_config,
  26487. "psn_cash_pay": order.PsnCashPay,
  26488. //"funds": rf,
  26489. //"check_order_info": cus_slice,
  26490. })
  26491. }
  26492. }
  26493. }
  26494. }
  26495. //func (c *HisApiController) CheckTreatment() {
  26496. // patient_id, _ := c.GetInt64("patient_id")
  26497. // id_card_no := c.GetString("id_card_no")
  26498. // insutype := c.GetString("insutype")
  26499. // med_type := c.GetString("med_type")
  26500. // admin_user_id, _ := c.GetInt64("admin_user_id")
  26501. //
  26502. // adminUser := c.GetAdminUserInfo()
  26503. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26504. //
  26505. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26506. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26507. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26508. //
  26509. // if miConfig.MdtrtareaAdmvs == "421300" {
  26510. // var res ResultTwo
  26511. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  26512. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26513. // "&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)
  26514. // resp, requestErr := http.Get(api)
  26515. // if requestErr != nil {
  26516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26517. // return
  26518. // }
  26519. //
  26520. // body, ioErr := ioutil.ReadAll(resp.Body)
  26521. // if ioErr != nil {
  26522. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26524. // return
  26525. // }
  26526. // var respJSON map[string]interface{}
  26527. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26528. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26530. // return
  26531. // }
  26532. //
  26533. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26534. // result, _ := json.Marshal(respJSON)
  26535. //
  26536. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26537. // utils.ErrorLog("解析失败:%v", err)
  26538. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26539. // return
  26540. // }
  26541. //
  26542. // if res.Infcode == 0 {
  26543. //
  26544. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  26545. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26546. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  26547. // resp, requestErr := http.Get(api)
  26548. // if requestErr != nil {
  26549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26550. // return
  26551. // }
  26552. //
  26553. // body, ioErr := ioutil.ReadAll(resp.Body)
  26554. // if ioErr != nil {
  26555. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26557. // return
  26558. // }
  26559. // var respJSON map[string]interface{}
  26560. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26561. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26562. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26563. // return
  26564. // }
  26565. // var res Result2001
  26566. //
  26567. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26568. // result2, _ := json.Marshal(respJSON)
  26569. //
  26570. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  26571. // utils.ErrorLog("解析失败:%v", err)
  26572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26573. // return
  26574. // }
  26575. //
  26576. // if res.Infcode == 0 {
  26577. // c.ServeSuccessJSON(map[string]interface{}{
  26578. // "msg": res.Output.Trtinfo,
  26579. // })
  26580. // }
  26581. //
  26582. // } else {
  26583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  26584. // return
  26585. // }
  26586. //
  26587. // } else {
  26588. //
  26589. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26590. // var dat map[string]interface{}
  26591. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26592. // fmt.Println(dat)
  26593. // } else {
  26594. // fmt.Println(err)
  26595. // }
  26596. // userJSONBytes, _ := json.Marshal(dat)
  26597. // var res ResultTwo
  26598. // var res10265 ResultTwo10265
  26599. // if miConfig.Code == "H15049901371" {
  26600. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26601. // utils.ErrorLog("解析失败:%v", err)
  26602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26603. // return
  26604. // }
  26605. // res.ErrMsg = res10265.ErrMsg
  26606. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26607. // res.Infcode = infocode
  26608. // res.Output = res10265.Output
  26609. // res.InfRefmsgid = res10265.InfRefmsgid
  26610. // } else {
  26611. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26612. // utils.ErrorLog("解析失败:%v", err)
  26613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26614. // return
  26615. // }
  26616. // }
  26617. //
  26618. // var user_name string
  26619. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  26620. // if role.ID == 0 {
  26621. // user_name = "xxx"
  26622. // } else {
  26623. // user_name = role.UserName
  26624. // }
  26625. //
  26626. // baseParams := models.BaseParams{
  26627. // SecretKey: miConfig.SecretKey,
  26628. // FixmedinsCode: miConfig.Code,
  26629. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26630. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26631. // OrgName: miConfig.OrgName,
  26632. // Doctor: user_name,
  26633. // }
  26634. //
  26635. // if config.IsOpen == 1 {
  26636. // if miConfig.Code == "H15049901371" {
  26637. // if med_type == "14" {
  26638. // if insutype == "390" {
  26639. // med_type = "9933"
  26640. // } else if insutype == "310" {
  26641. // med_type = "990502"
  26642. // }
  26643. // } else if med_type == "11" {
  26644. // med_type = "11"
  26645. // }
  26646. // }
  26647. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  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. // var res Result2001
  26655. // var res10265 Result2001Org10265
  26656. // if miConfig.Code == "H15049901371" {
  26657. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26658. // utils.ErrorLog("解析失败:%v", err)
  26659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26660. // return
  26661. // }
  26662. // res.ErrMsg = res10265.ErrMsg
  26663. // res.Output = res10265.Output
  26664. // res.InfRefmsgid = res10265.InfRefmsgid
  26665. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26666. // res.Infcode = infocode
  26667. // } else {
  26668. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26669. // utils.ErrorLog("解析失败:%v", err)
  26670. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26671. // return
  26672. // }
  26673. // }
  26674. // if res.Infcode == 0 {
  26675. // c.ServeSuccessJSON(map[string]interface{}{
  26676. // "msg": res.Output.Trtinfo,
  26677. // })
  26678. // }
  26679. // }
  26680. // }
  26681. //}
  26682. //func (c *HisApiController) PutRecord() {
  26683. // id, _ := c.GetInt64("id")
  26684. // record_time := c.GetString("record_time")
  26685. // timeLayout := "2006-01-02"
  26686. // loc, _ := time.LoadLocation("Local")
  26687. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26688. // if err != nil {
  26689. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26690. // return
  26691. // }
  26692. // recordDateTime := theTime.Unix()
  26693. //
  26694. // adminInfo := c.GetAdminUserInfo()
  26695. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26696. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26697. //
  26698. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26699. //
  26700. // fmt.Println(miConfig.SecretKey)
  26701. //
  26702. // if patient == nil {
  26703. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26704. // return
  26705. // }
  26706. // if len(patient.IdCardNo) == 0 {
  26707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26708. // return
  26709. // }
  26710. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26711. // if config.IsOpen == 1 {
  26712. // 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
  26713. // resp, requestErr := http.Get(api)
  26714. // if requestErr != nil {
  26715. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26716. // return
  26717. // }
  26718. // defer resp.Body.Close()
  26719. // body, ioErr := ioutil.ReadAll(resp.Body)
  26720. // if ioErr != nil {
  26721. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26723. // return
  26724. // }
  26725. // var respJSON map[string]interface{}
  26726. //
  26727. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26728. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26730. // return
  26731. // }
  26732. //
  26733. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26734. // userJSONBytes, _ := json.Marshal(userJSON)
  26735. // var res ResultTwo
  26736. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26737. // utils.ErrorLog("解析失败:%v", err)
  26738. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26739. // return
  26740. // }
  26741. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26742. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26743. // infoStr := string(Iinfos)
  26744. // idetinfoStr := string(Idetinfos)
  26745. //
  26746. // if res.Infcode == 0 {
  26747. // his := models.VMHisPatient{
  26748. // Status: 1,
  26749. // Ctime: time.Now().Unix(),
  26750. // Mtime: time.Now().Unix(),
  26751. // PsnNo: res.Output.Baseinfo.PsnNo,
  26752. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26753. // Certno: res.Output.Baseinfo.Certno,
  26754. // PsnName: res.Output.Baseinfo.PsnName,
  26755. // Gend: res.Output.Baseinfo.Gend,
  26756. // Naty: res.Output.Baseinfo.Naty,
  26757. // Brdy: res.Output.Baseinfo.Brdy,
  26758. // Age: res.Output.Baseinfo.Age,
  26759. // Iinfo: infoStr,
  26760. // Idetinfo: idetinfoStr,
  26761. // PatientId: patient.ID,
  26762. // RecordDate: theTime.Unix(),
  26763. // UserOrgId: adminInfo.CurrentOrgId,
  26764. // AdminUserId: adminInfo.AdminUser.Id,
  26765. // IsReturn: 1,
  26766. // }
  26767. //
  26768. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26769. // //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")
  26770. // //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")
  26771. //
  26772. // //var dat map[string]interface{}
  26773. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26774. // // fmt.Println(dat)
  26775. // //} else {
  26776. // // fmt.Println(err)
  26777. // //}
  26778. //
  26779. // var dat2 map[string]interface{}
  26780. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26781. // fmt.Println(dat2)
  26782. // } else {
  26783. // fmt.Println(err)
  26784. // }
  26785. //
  26786. // } else {
  26787. // adminUser := c.GetAdminUserInfo()
  26788. // errlog := &models.HisOrderError{
  26789. // UserOrgId: adminUser.CurrentOrgId,
  26790. // Ctime: time.Now().Unix(),
  26791. // Mtime: time.Now().Unix(),
  26792. // ErrMsg: res.ErrMsg,
  26793. // Status: 1,
  26794. // PatientId: id,
  26795. // RecordTime: recordDateTime,
  26796. // Stage: 1,
  26797. // }
  26798. // service.CreateErrMsgLog(errlog)
  26799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26800. // return
  26801. // }
  26802. // }
  26803. //
  26804. //}
  26805. //func (c *HisApiController) GetUploadDiag() {
  26806. // id, _ := c.GetInt64("id")
  26807. // record_time := c.GetString("record_time")
  26808. //
  26809. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26810. // sick_type, _ := c.GetInt64("sick_type")
  26811. // reg_type, _ := c.GetInt64("reg_type")
  26812. //
  26813. // timeLayout := "2006-01-02"
  26814. // loc, _ := time.LoadLocation("Local")
  26815. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26816. // if err != nil {
  26817. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26818. // return
  26819. // }
  26820. //
  26821. // var patientPrescription models.HisPrescriptionInfo
  26822. // recordDateTime := theTime.Unix()
  26823. // adminInfo := c.GetAdminUserInfo()
  26824. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26825. //
  26826. // if patientPrescription.ID == 0 {
  26827. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26828. // }
  26829. //
  26830. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26831. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26832. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26833. // sickConfig, _ := service.FindSickById(sick_type)
  26834. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26835. //
  26836. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26837. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26838. // "&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 +
  26839. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26840. // resp2, requestErr2 := http.Get(api2)
  26841. // if requestErr2 != nil {
  26842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26843. // return
  26844. // }
  26845. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26846. // if ioErr2 != nil {
  26847. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26849. // return
  26850. // }
  26851. // var respJSON2 map[string]interface{}
  26852. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26853. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26855. // return
  26856. // }
  26857. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26858. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26859. //
  26860. // var res2 ResultSix
  26861. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26862. // utils.ErrorLog("解析失败:%v", err)
  26863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26864. // return
  26865. // }
  26866. // if res2.Infcode != 0 {
  26867. // adminUser := c.GetAdminUserInfo()
  26868. // errlog := &models.HisOrderError{
  26869. // UserOrgId: adminUser.CurrentOrgId,
  26870. // Ctime: time.Now().Unix(),
  26871. // Mtime: time.Now().Unix(),
  26872. // ErrMsg: res2.ErrMsg,
  26873. // Status: 1,
  26874. // PatientId: id,
  26875. // RecordTime: recordDateTime,
  26876. // Stage: 3,
  26877. // }
  26878. // service.CreateErrMsgLog(errlog)
  26879. //
  26880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26881. // return
  26882. // }
  26883. //
  26884. // c.ServeSuccessJSON(map[string]interface{}{
  26885. // "msg": "上传成功",
  26886. // })
  26887. //
  26888. //}
  26889. type QueryResult struct {
  26890. ID int64
  26891. Name string
  26892. Code string
  26893. List_type_code string
  26894. }
  26895. func (c *HisApiController) GetCheckCode() {
  26896. ids_str := c.GetString("ids")
  26897. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26898. ids_arr := strings.Split(ids_str, ",")
  26899. var queryResult []QueryResult
  26900. ids := make([]int64, 0)
  26901. for _, item := range ids_arr {
  26902. id, _ := strconv.ParseInt(item, 10, 64)
  26903. ids = append(ids, id)
  26904. }
  26905. if record_type == 1 {
  26906. drugs, _ := service.GetBatchDrugList(ids)
  26907. for _, item := range drugs {
  26908. result := QueryResult{
  26909. ID: item.ID,
  26910. Name: item.DrugName,
  26911. Code: item.MedicalInsuranceNumber,
  26912. List_type_code: "101",
  26913. }
  26914. queryResult = append(queryResult, result)
  26915. }
  26916. } else if record_type == 2 {
  26917. goods, _ := service.GetBatchGoodInformationList(ids)
  26918. fmt.Println(goods)
  26919. for _, item := range goods {
  26920. result := QueryResult{
  26921. ID: item.ID,
  26922. Name: item.GoodName,
  26923. Code: item.SocialSecurityDirectoryCode,
  26924. List_type_code: "301",
  26925. }
  26926. queryResult = append(queryResult, result)
  26927. }
  26928. } else if record_type == 3 {
  26929. projects, _ := service.GetBathchMyPorjecgList(ids)
  26930. for _, item := range projects {
  26931. result := QueryResult{
  26932. ID: item.ID,
  26933. Name: item.ProjectName,
  26934. Code: item.MedicalCode,
  26935. List_type_code: "201",
  26936. }
  26937. queryResult = append(queryResult, result)
  26938. }
  26939. }
  26940. admin_user_id, _ := c.GetInt64("admin_user_id")
  26941. adminUser := c.GetAdminUserInfo()
  26942. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26943. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26944. var user_name string
  26945. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26946. if role.ID == 0 {
  26947. user_name = "管理员"
  26948. } else {
  26949. user_name = role.UserName
  26950. }
  26951. baseParams := models.BaseParams{
  26952. SecretKey: miConfig.SecretKey,
  26953. FixmedinsCode: miConfig.Code,
  26954. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26955. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26956. OrgName: miConfig.OrgName,
  26957. Doctor: user_name,
  26958. }
  26959. var result string
  26960. if miConfig.MdtrtareaAdmvs == "430800" {
  26961. for _, item := range queryResult {
  26962. if record_type == 1 {
  26963. 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)
  26964. } else if record_type == 2 {
  26965. fmt.Println(item.Code)
  26966. 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)
  26967. } else if record_type == 3 {
  26968. 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)
  26969. }
  26970. var dat map[string]interface{}
  26971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26972. fmt.Println(dat)
  26973. } else {
  26974. fmt.Println(err)
  26975. }
  26976. userJSONBytes, _ := json.Marshal(dat)
  26977. var res ResultSix
  26978. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26979. utils.ErrorLog("解析失败:%v", err)
  26980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26981. return
  26982. }
  26983. if res.Infcode == 0 {
  26984. if record_type == 1 {
  26985. service.UpdateBaseDrugById(item.ID)
  26986. } else if record_type == 2 {
  26987. service.UpdateGoodInformaitonByDetail(item.ID)
  26988. } else if record_type == 3 {
  26989. service.UpdateProjectById(item.ID)
  26990. }
  26991. c.ServeSuccessJSON(map[string]interface{}{
  26992. "failed_code": 0,
  26993. "msg": "目录对照成功",
  26994. })
  26995. } else {
  26996. c.ServeSuccessJSON(map[string]interface{}{
  26997. "failed_code": -10,
  26998. "msg": res.ErrMsg,
  26999. })
  27000. }
  27001. }
  27002. } else {
  27003. for _, item := range queryResult {
  27004. var result string
  27005. if record_type == 1 {
  27006. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27007. } else if record_type == 2 {
  27008. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27009. } else if record_type == 3 {
  27010. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27011. }
  27012. var dat map[string]interface{}
  27013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27014. fmt.Println(dat)
  27015. } else {
  27016. fmt.Println(err)
  27017. }
  27018. userJSONBytes, _ := json.Marshal(dat)
  27019. var res ResultSix
  27020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27021. utils.ErrorLog("解析失败:%v", err)
  27022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27023. return
  27024. }
  27025. if res.Infcode == 0 {
  27026. if record_type == 1 {
  27027. service.UpdateBaseDrugById(item.ID)
  27028. } else if record_type == 2 {
  27029. service.UpdateGoodInformaitonByDetail(item.ID)
  27030. } else if record_type == 3 {
  27031. service.UpdateProjectById(item.ID)
  27032. }
  27033. c.ServeSuccessJSON(map[string]interface{}{
  27034. "failed_code": 0,
  27035. "msg": "目录对照成功",
  27036. })
  27037. } else {
  27038. c.ServeSuccessJSON(map[string]interface{}{
  27039. "failed_code": -10,
  27040. "msg": res.ErrMsg,
  27041. })
  27042. }
  27043. }
  27044. }
  27045. }
  27046. func (c *HisApiController) UnCheckCode() {
  27047. ids_str := c.GetString("ids")
  27048. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27049. admin_user_id, _ := c.GetInt64("admin_user_id")
  27050. ids_arr := strings.Split(ids_str, ",")
  27051. var queryResult []QueryResult
  27052. ids := make([]int64, 0)
  27053. for _, item := range ids_arr {
  27054. id, _ := strconv.ParseInt(item, 10, 64)
  27055. ids = append(ids, id)
  27056. }
  27057. if record_type == 1 {
  27058. drugs, _ := service.GetBatchDrugList(ids)
  27059. for _, item := range drugs {
  27060. result := QueryResult{
  27061. ID: item.ID,
  27062. Name: item.DrugName,
  27063. Code: item.MedicalInsuranceNumber,
  27064. List_type_code: "101",
  27065. }
  27066. queryResult = append(queryResult, result)
  27067. }
  27068. } else if record_type == 2 {
  27069. goods, _ := service.GetBatchGoodInformationList(ids)
  27070. for _, item := range goods {
  27071. result := QueryResult{
  27072. ID: item.ID,
  27073. Name: item.GoodName,
  27074. Code: item.SocialSecurityDirectoryCode,
  27075. List_type_code: "301",
  27076. }
  27077. queryResult = append(queryResult, result)
  27078. }
  27079. } else if record_type == 3 {
  27080. projects, _ := service.GetBathchMyPorjecgList(ids)
  27081. for _, item := range projects {
  27082. result := QueryResult{
  27083. ID: item.ID,
  27084. Name: item.ProjectName,
  27085. Code: item.MedicalCode,
  27086. List_type_code: "201",
  27087. }
  27088. queryResult = append(queryResult, result)
  27089. }
  27090. }
  27091. adminUser := c.GetAdminUserInfo()
  27092. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27093. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27094. var user_name string
  27095. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27096. if role.ID == 0 {
  27097. user_name = "xxx"
  27098. } else {
  27099. user_name = role.UserName
  27100. }
  27101. baseParams := &models.BaseParams{
  27102. SecretKey: miConfig.SecretKey,
  27103. FixmedinsCode: miConfig.Code,
  27104. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27105. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27106. OrgName: miConfig.OrgName,
  27107. Doctor: user_name,
  27108. }
  27109. if config.IsOpen == 1 {
  27110. if miConfig.MdtrtareaAdmvs == "430800" {
  27111. for _, item := range queryResult {
  27112. var result string
  27113. if record_type == 1 {
  27114. 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)
  27115. } else if record_type == 2 {
  27116. fmt.Println(item.Code)
  27117. 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)
  27118. } else if record_type == 3 {
  27119. 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)
  27120. }
  27121. var dat map[string]interface{}
  27122. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27123. fmt.Println(dat)
  27124. } else {
  27125. fmt.Println(err)
  27126. }
  27127. userJSONBytes, _ := json.Marshal(dat)
  27128. var res ResultSix
  27129. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27130. utils.ErrorLog("解析失败:%v", err)
  27131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27132. return
  27133. }
  27134. if res.Infcode == 0 {
  27135. if record_type == 1 {
  27136. service.UpdateBaseDrugById(item.ID)
  27137. } else if record_type == 2 {
  27138. service.UpdateGoodInformaitonByDetail(item.ID)
  27139. } else if record_type == 3 {
  27140. service.UpdateProjectById(item.ID)
  27141. }
  27142. c.ServeSuccessJSON(map[string]interface{}{
  27143. "failed_code": 0,
  27144. "msg": "目录对照成功",
  27145. })
  27146. } else {
  27147. c.ServeSuccessJSON(map[string]interface{}{
  27148. "failed_code": -10,
  27149. "msg": res.ErrMsg,
  27150. })
  27151. }
  27152. }
  27153. } else {
  27154. for _, item := range queryResult {
  27155. var result string
  27156. if record_type == 1 {
  27157. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27158. } else if record_type == 2 {
  27159. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27160. } else if record_type == 3 {
  27161. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27162. }
  27163. var dat2 map[string]interface{}
  27164. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27165. fmt.Println(dat2)
  27166. } else {
  27167. fmt.Println(err)
  27168. }
  27169. userJSONBytes, _ := json.Marshal(dat2)
  27170. var res ResultSix
  27171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27172. utils.ErrorLog("解析失败:%v", err)
  27173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27174. return
  27175. }
  27176. if res.Infcode == 0 {
  27177. if record_type == 1 {
  27178. service.UpdateDrugByIdDetail(item.ID)
  27179. } else if record_type == 2 {
  27180. service.UpdateGoodInfoById(item.ID)
  27181. } else if record_type == 3 {
  27182. service.UpdateMyProjectById(item.ID)
  27183. }
  27184. c.ServeSuccessJSON(map[string]interface{}{
  27185. "failed_code": 0,
  27186. "msg": "撤销目录对照成功",
  27187. })
  27188. } else {
  27189. c.ServeSuccessJSON(map[string]interface{}{
  27190. "failed_code": -10,
  27191. "msg": res.ErrMsg,
  27192. })
  27193. }
  27194. }
  27195. }
  27196. }
  27197. }
  27198. func (c *HisApiController) GetPatientInfo() {
  27199. id_card_no := c.GetString("id_card_no")
  27200. admin_user_id, _ := c.GetInt64("admin_user_id")
  27201. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  27202. if patient.ID == 0 {
  27203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27204. return
  27205. }
  27206. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  27207. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  27208. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  27209. var res ResultTwo
  27210. var res10265 ResultTwo10265
  27211. if config.IsOpen == 1 {
  27212. if miConfig.MdtrtareaAdmvs == "150499" {
  27213. //请求内网数据
  27214. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  27215. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27216. "&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
  27217. resp, requestErr := http.Get(api)
  27218. if requestErr != nil {
  27219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27220. return
  27221. }
  27222. body, ioErr := ioutil.ReadAll(resp.Body)
  27223. if ioErr != nil {
  27224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27226. return
  27227. }
  27228. var respJSON map[string]interface{}
  27229. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27232. return
  27233. }
  27234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27235. result_byte, _ := json.Marshal(respJSON)
  27236. result := string(result_byte)
  27237. var dat map[string]interface{}
  27238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27239. fmt.Println(dat)
  27240. } else {
  27241. fmt.Println(err)
  27242. }
  27243. userJSONBytes, _ := json.Marshal(dat)
  27244. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27245. utils.ErrorLog("解析失败:%v", err)
  27246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27247. return
  27248. }
  27249. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27250. res.Infcode = Infcode
  27251. res.ErrMsg = res10265.ErrMsg
  27252. res.Output = res10265.Output
  27253. res.InfRefmsgid = res10265.InfRefmsgid
  27254. res.RespondTime = res10265.RespondTime
  27255. res.WarnInfo = res10265.WarnInfo
  27256. } else {
  27257. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27258. var dat map[string]interface{}
  27259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27260. fmt.Println(dat)
  27261. } else {
  27262. fmt.Println(err)
  27263. }
  27264. userJSONBytes, _ := json.Marshal(dat)
  27265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27266. utils.ErrorLog("解析失败:%v", err)
  27267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27268. return
  27269. }
  27270. }
  27271. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27272. // utils.ErrorLog("解析失败:%v", err)
  27273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27274. // return
  27275. //}
  27276. for index, item := range res.Output.Iinfo {
  27277. if item.PsnInsuStas == "2" {
  27278. fmt.Println("--------")
  27279. res.Output.Iinfo[index].Insutype = "300"
  27280. res.Output.Iinfo[index].PsnInsuStas = "1"
  27281. }
  27282. }
  27283. fmt.Println(res.Output.Iinfo)
  27284. if res.Infcode != 0 {
  27285. c.ServeSuccessJSON(map[string]interface{}{
  27286. "failed_code": -10,
  27287. "msg": res.ErrMsg,
  27288. })
  27289. } else {
  27290. c.ServeSuccessJSON(map[string]interface{}{
  27291. "failed_code": 0,
  27292. "info": res,
  27293. })
  27294. }
  27295. }
  27296. }
  27297. func (c *HisApiController) PsnPutOnRecord() {
  27298. record_type, _ := c.GetInt64("type")
  27299. patient_id, _ := c.GetInt64("patient_id")
  27300. admin_user_id, _ := c.GetInt64("admin_user_id")
  27301. start_time := c.GetString("start_time")
  27302. end_time := c.GetString("end_time")
  27303. adminUser := c.GetAdminUserInfo()
  27304. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27305. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27306. var patients []*models.Patients
  27307. if record_type == 1 { //全部备案
  27308. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  27309. patients = append(patients, patient...)
  27310. } else { //单个备案
  27311. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27312. patients = append(patients, patient)
  27313. }
  27314. var user_name string
  27315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27316. if role.ID == 0 {
  27317. user_name = "xxx"
  27318. } else {
  27319. user_name = role.UserName
  27320. }
  27321. if config.IsOpen == 1 {
  27322. for _, item := range patients {
  27323. 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
  27324. resp, requestErr := http.Get(api)
  27325. if requestErr != nil {
  27326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27327. return
  27328. }
  27329. defer resp.Body.Close()
  27330. body, ioErr := ioutil.ReadAll(resp.Body)
  27331. if ioErr != nil {
  27332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. var respJSON map[string]interface{}
  27337. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27340. return
  27341. }
  27342. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27343. userJSONBytes, _ := json.Marshal(userJSON)
  27344. var res ResultTwo
  27345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27346. utils.ErrorLog("解析失败:%v", err)
  27347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27348. return
  27349. }
  27350. if res.Infcode == 0 {
  27351. 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)
  27352. var dat map[string]interface{}
  27353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27354. fmt.Println(dat)
  27355. } else {
  27356. fmt.Println(err)
  27357. }
  27358. userJSONBytes, _ := json.Marshal(dat)
  27359. var res2 ResultThirteen
  27360. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27361. utils.ErrorLog("解析失败:%v", err)
  27362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27363. return
  27364. }
  27365. if res2.Infcode == 0 {
  27366. psnResult := &models.GdybPsnRecord{
  27367. UserOrgId: adminUser.CurrentOrgId,
  27368. PatientId: item.ID,
  27369. PsnNo: res.Output.Baseinfo.PsnNo,
  27370. Ctime: time.Now().Unix(),
  27371. Mtime: time.Now().Unix(),
  27372. Status: 1,
  27373. IsCancel: 1,
  27374. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27375. }
  27376. service.CreatePsnRecord(psnResult)
  27377. } else {
  27378. c.ServeSuccessJSON(map[string]interface{}{
  27379. "failed_code": -10,
  27380. "msg": res2.ErrMsg,
  27381. })
  27382. return
  27383. }
  27384. }
  27385. }
  27386. }
  27387. }
  27388. func (c *HisApiController) PsnUnPutOnRecord() {
  27389. id, _ := c.GetInt64("id")
  27390. //record_type, _ := c.GetInt64("type")
  27391. admin_user_id, _ := c.GetInt64("admin_user_id")
  27392. adminUser := c.GetAdminUserInfo()
  27393. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27394. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27395. var user_name string
  27396. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27397. if role.ID == 0 {
  27398. user_name = "xxx"
  27399. } else {
  27400. user_name = role.UserName
  27401. }
  27402. psn_record, _ := service.GetPsnRecordById(id)
  27403. if psn_record.ID == 0 {
  27404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27405. return
  27406. }
  27407. if config.IsOpen == 1 {
  27408. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27409. var dat map[string]interface{}
  27410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27411. fmt.Println(dat)
  27412. } else {
  27413. fmt.Println(err)
  27414. }
  27415. userJSONBytes, _ := json.Marshal(dat)
  27416. var res ResultFourteen
  27417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27418. utils.ErrorLog("解析失败:%v", err)
  27419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27420. return
  27421. }
  27422. if res.Infcode == 0 {
  27423. psn_record.IsCancel = 2
  27424. service.CreatePsnRecord(&psn_record)
  27425. } else {
  27426. c.ServeSuccessJSON(map[string]interface{}{
  27427. "failed_code": -10,
  27428. "msg": res.ErrMsg,
  27429. })
  27430. return
  27431. }
  27432. }
  27433. }
  27434. func (c *HisApiController) PsnPutNCDSOnRecord() {
  27435. patient_id, _ := c.GetInt64("patient_id")
  27436. insutype_two := c.GetString("insutype")
  27437. psn_no := c.GetString("psn_no")
  27438. doctor_id, _ := c.GetInt64("doctor_id")
  27439. sick_id, _ := c.GetInt64("sick_id")
  27440. department_id, _ := c.GetInt64("department_id")
  27441. start_time := c.GetString("start_time")
  27442. end_time := c.GetString("end_time")
  27443. check_time := c.GetString("check_time")
  27444. hospital_code := c.GetString("hospital_code")
  27445. hospital_name := c.GetString("hospital_name")
  27446. adminUser := c.GetAdminUserInfo()
  27447. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27448. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27449. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27450. sick, _ := service.FindSickById(sick_id)
  27451. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27452. if len(hospital_code) == 0 {
  27453. hospital_code = miConfig.Code
  27454. }
  27455. if len(hospital_name) == 0 {
  27456. hospital_name = miConfig.OrgName
  27457. }
  27458. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27459. var res ResultTwo
  27460. var res10265 ResultTwo10265
  27461. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27462. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  27463. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  27464. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27465. "&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
  27466. resp, requestErr := http.Get(api)
  27467. if requestErr != nil {
  27468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27469. return
  27470. }
  27471. body, ioErr := ioutil.ReadAll(resp.Body)
  27472. if ioErr != nil {
  27473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27475. return
  27476. }
  27477. var respJSON map[string]interface{}
  27478. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27481. return
  27482. }
  27483. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27484. result, _ := json.Marshal(respJSON)
  27485. fmt.Println("log")
  27486. fmt.Println(string(result))
  27487. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27488. utils.ErrorLog("解析失败:%v", err)
  27489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27490. return
  27491. }
  27492. res.ErrMsg = res10265.ErrMsg
  27493. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27494. res.Infcode = infocode
  27495. res.Output = res10265.Output
  27496. res.InfRefmsgid = res10265.InfRefmsgid
  27497. } else {
  27498. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27499. if miConfig.Code == "H15049901371" {
  27500. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27501. utils.ErrorLog("解析失败:%v", err)
  27502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27503. return
  27504. }
  27505. res.ErrMsg = res10265.ErrMsg
  27506. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27507. res.Infcode = infocode
  27508. res.Output = res10265.Output
  27509. res.InfRefmsgid = res10265.InfRefmsgid
  27510. } else {
  27511. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27512. utils.ErrorLog("解析失败:%v", err)
  27513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27514. return
  27515. }
  27516. }
  27517. }
  27518. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27519. infoStr := string(Iinfos)
  27520. var rf []*ResultFive
  27521. json.Unmarshal([]byte(infoStr), &rf)
  27522. var insuplc_admdvs string
  27523. var insutype string
  27524. var is390 int = 0
  27525. var is310 int = 0
  27526. var insutypes []*ResultFive
  27527. for _, item := range rf {
  27528. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27529. insutypes = append(insutypes, item)
  27530. }
  27531. }
  27532. if len(insutypes) == 1 {
  27533. insutype = insutypes[0].Insutype
  27534. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27535. } else {
  27536. for _, i := range insutypes {
  27537. if i.Insutype == "390" {
  27538. is390 = 1
  27539. }
  27540. if i.Insutype == "310" {
  27541. is310 = 1
  27542. }
  27543. }
  27544. }
  27545. if is390 == 1 {
  27546. insutype = "390"
  27547. }
  27548. if is310 == 1 {
  27549. insutype = "310"
  27550. }
  27551. if len(insutypes) == 2 {
  27552. insutype = insutype_two
  27553. }
  27554. if len(insutypes) == 0 {
  27555. insutype = "310"
  27556. }
  27557. insutype = insutype_two
  27558. fmt.Println(insutype)
  27559. for _, item := range rf {
  27560. fmt.Println(item.Insutype)
  27561. fmt.Println(insutype)
  27562. if item.Insutype == insutype {
  27563. fmt.Println(item.Insutype)
  27564. fmt.Println(insutype)
  27565. insuplc_admdvs = item.InsuplcAdmdvs
  27566. }
  27567. }
  27568. fmt.Println(insuplc_admdvs)
  27569. var res2 ResultThirteen
  27570. var res10265_2 ResultThirteen10265
  27571. if config.IsOpen == 1 {
  27572. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27573. } else {
  27574. if miConfig.MdtrtareaAdmvs == "150499" {
  27575. //
  27576. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  27577. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27578. // "&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
  27579. //resp, requestErr := http.Get(api)
  27580. //if requestErr != nil {
  27581. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27582. // return
  27583. //}
  27584. //
  27585. //body, ioErr := ioutil.ReadAll(resp.Body)
  27586. //if ioErr != nil {
  27587. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27589. // return
  27590. //}
  27591. //var respJSON map[string]interface{}
  27592. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27593. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27595. // return
  27596. //}
  27597. //
  27598. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27599. //result, _ := json.Marshal(respJSON)
  27600. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  27601. // utils.ErrorLog("解析失败:%v", err)
  27602. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27603. // return
  27604. //}
  27605. //infocode = resThree.Infcode
  27606. //result, _ := json.Marshal(respJSON)
  27607. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  27608. // utils.ErrorLog("解析失败:%v", err)
  27609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27610. // return
  27611. //}
  27612. //
  27613. //resThree.ErrMsg = resThree10265.ErrMsg
  27614. //
  27615. //resThree.Output = resThree10265.Output
  27616. //
  27617. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  27618. //
  27619. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  27620. //
  27621. } else {
  27622. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time, hospital_code, hospital_name)
  27623. var dat map[string]interface{}
  27624. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27625. fmt.Println(dat)
  27626. } else {
  27627. fmt.Println(err)
  27628. }
  27629. userJSONBytes, _ := json.Marshal(dat)
  27630. if miConfig.Code == "H15049901371" {
  27631. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27632. utils.ErrorLog("解析失败:%v", err)
  27633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27634. return
  27635. }
  27636. res2.ErrMsg = res10265_2.ErrMsg
  27637. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27638. res2.Infcode = infocode
  27639. res2.Output = res10265_2.Output
  27640. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27641. } else {
  27642. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27643. utils.ErrorLog("解析失败:%v", err)
  27644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27645. return
  27646. }
  27647. }
  27648. }
  27649. }
  27650. if res2.Infcode == 0 {
  27651. psnResult := &models.GdybPsnNcdsRecord{
  27652. UserOrgId: adminUser.CurrentOrgId,
  27653. PatientId: patient.ID,
  27654. PsnNo: psn_no,
  27655. DoctorId: doctor.AdminUserId,
  27656. DepartmentId: department_id,
  27657. SickType: sick_id,
  27658. Insutype: insutype,
  27659. Ctime: time.Now().Unix(),
  27660. Mtime: time.Now().Unix(),
  27661. Status: 1,
  27662. IsCancel: 1,
  27663. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27664. }
  27665. service.CreatePsnNCDSRecord(psnResult)
  27666. c.ServeSuccessJSON(map[string]interface{}{
  27667. "failed_code": 0,
  27668. "msg": "备案成功",
  27669. "result": psnResult,
  27670. })
  27671. } else {
  27672. c.ServeSuccessJSON(map[string]interface{}{
  27673. "failed_code": -10,
  27674. "msg": res2.ErrMsg,
  27675. })
  27676. return
  27677. }
  27678. }
  27679. }
  27680. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27681. id, _ := c.GetInt64("id")
  27682. admin_user_id, _ := c.GetInt64("admin_user_id")
  27683. adminUser := c.GetAdminUserInfo()
  27684. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27685. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27686. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27687. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27688. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27689. //var user_name string
  27690. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27691. //if role.ID == 0 {
  27692. // user_name = "xxx"
  27693. //} else {
  27694. // user_name = role.UserName
  27695. //}
  27696. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27697. if psn_record.ID == 0 {
  27698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27699. return
  27700. }
  27701. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27702. var res ResultTwo
  27703. var res10265 ResultTwo10265
  27704. if miConfig.Code == "H15049901371" {
  27705. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27706. utils.ErrorLog("解析失败:%v", err)
  27707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27708. return
  27709. }
  27710. res.ErrMsg = res10265.ErrMsg
  27711. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27712. res.Infcode = infocode
  27713. res.Output = res10265.Output
  27714. res.InfRefmsgid = res10265.InfRefmsgid
  27715. } else {
  27716. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27717. utils.ErrorLog("解析失败:%v", err)
  27718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27719. return
  27720. }
  27721. }
  27722. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27723. infoStr := string(Iinfos)
  27724. var rf []*ResultFive
  27725. json.Unmarshal([]byte(infoStr), &rf)
  27726. var insuplc_admdvs string
  27727. var insutype string
  27728. var is390 int = 0
  27729. var is310 int = 0
  27730. var insutypes []*ResultFive
  27731. for _, item := range rf {
  27732. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27733. insutypes = append(insutypes, item)
  27734. }
  27735. }
  27736. if len(insutypes) == 1 {
  27737. insutype = insutypes[0].Insutype
  27738. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27739. } else {
  27740. for _, i := range insutypes {
  27741. if i.Insutype == "390" {
  27742. is390 = 1
  27743. }
  27744. if i.Insutype == "310" {
  27745. is310 = 1
  27746. }
  27747. }
  27748. }
  27749. if is390 == 1 {
  27750. insutype = "390"
  27751. }
  27752. if is310 == 1 {
  27753. insutype = "310"
  27754. }
  27755. if len(insutypes) == 0 {
  27756. insutype = "310"
  27757. }
  27758. insutype = psn_record.Insutype
  27759. for _, item := range rf {
  27760. if item.Insutype == insutype {
  27761. insuplc_admdvs = item.InsuplcAdmdvs
  27762. }
  27763. }
  27764. if config.IsOpen == 1 {
  27765. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27766. var dat map[string]interface{}
  27767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27768. fmt.Println(dat)
  27769. } else {
  27770. fmt.Println(err)
  27771. }
  27772. userJSONBytes, _ := json.Marshal(dat)
  27773. var res ResultFourteen
  27774. var res10265 ResultFourteen10265
  27775. if miConfig.Code == "H15049901371" {
  27776. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27777. utils.ErrorLog("解析失败:%v", err)
  27778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27779. return
  27780. }
  27781. res.ErrMsg = res10265.ErrMsg
  27782. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27783. res.Infcode = infocode
  27784. res.Output = res10265.Output
  27785. res.InfRefmsgid = res10265.InfRefmsgid
  27786. } else {
  27787. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27788. utils.ErrorLog("解析失败:%v", err)
  27789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27790. return
  27791. }
  27792. }
  27793. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27794. // utils.ErrorLog("解析失败:%v", err)
  27795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27796. // return
  27797. //}
  27798. if res.Infcode == 0 {
  27799. psn_record.IsCancel = 2
  27800. service.CreatePsnNCDSRecord(&psn_record)
  27801. c.ServeSuccessJSON(map[string]interface{}{
  27802. "failed_code": 0,
  27803. "msg": "撤销备案成功",
  27804. })
  27805. } else {
  27806. c.ServeSuccessJSON(map[string]interface{}{
  27807. "failed_code": -10,
  27808. "msg": res.ErrMsg,
  27809. })
  27810. return
  27811. }
  27812. }
  27813. }
  27814. func (c *HisApiController) TestTest() {
  27815. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27816. fmt.Println(patient.Iinfo)
  27817. }
  27818. type CustomData struct {
  27819. MsgId string
  27820. PsnNo string
  27821. Info string
  27822. }
  27823. func (c *HisApiController) ReversalData() {
  27824. var customData []*CustomData
  27825. custom := &CustomData{
  27826. MsgId: "H44022900158202103301714472004",
  27827. PsnNo: "44020000001101329945",
  27828. Info: "2207",
  27829. }
  27830. customData = append(customData, custom)
  27831. custom1 := &CustomData{
  27832. MsgId: "H4402290015820210330172057803",
  27833. PsnNo: "44020000001101161813",
  27834. Info: "2207",
  27835. }
  27836. customData = append(customData, custom1)
  27837. custom2 := &CustomData{
  27838. MsgId: "H44022900158202103301705198813",
  27839. PsnNo: "44190000133097375417",
  27840. Info: "2207",
  27841. }
  27842. customData = append(customData, custom2)
  27843. custom3 := &CustomData{
  27844. MsgId: "H44022900158202103301715524756",
  27845. PsnNo: "44020000001100187221",
  27846. Info: "2207",
  27847. }
  27848. customData = append(customData, custom3)
  27849. custom4 := &CustomData{
  27850. MsgId: "H44022900158202103301730376224",
  27851. PsnNo: "44020000001101959155",
  27852. Info: "2207",
  27853. }
  27854. customData = append(customData, custom4)
  27855. custom5 := &CustomData{
  27856. MsgId: "H44022900158202103301748008725",
  27857. PsnNo: "44020000001104246641",
  27858. Info: "2207",
  27859. }
  27860. customData = append(customData, custom5)
  27861. custom6 := &CustomData{
  27862. MsgId: "H44022900158202103301718096755",
  27863. PsnNo: "44020000001102211860",
  27864. Info: "2207",
  27865. }
  27866. customData = append(customData, custom6)
  27867. custom7 := &CustomData{
  27868. MsgId: "H44022900158202103301736551640",
  27869. PsnNo: "44020000001102687718",
  27870. Info: "2207",
  27871. }
  27872. customData = append(customData, custom7)
  27873. custom8 := &CustomData{
  27874. MsgId: "H44022900158202103301743097676",
  27875. PsnNo: "44020000001102127785",
  27876. Info: "2207",
  27877. }
  27878. customData = append(customData, custom8)
  27879. custom9 := &CustomData{
  27880. MsgId: "H44022900158202103301712304203",
  27881. PsnNo: "44020000001101518097",
  27882. Info: "2207",
  27883. }
  27884. customData = append(customData, custom9)
  27885. custom10 := &CustomData{
  27886. MsgId: "H44022900158202103301738448785",
  27887. PsnNo: "44020000001100500813",
  27888. Info: "2207",
  27889. }
  27890. customData = append(customData, custom10)
  27891. custom11 := &CustomData{
  27892. MsgId: "H44022900158202103301732455843",
  27893. PsnNo: "44020000001102690557",
  27894. Info: "2207",
  27895. }
  27896. customData = append(customData, custom11)
  27897. custom12 := &CustomData{
  27898. MsgId: "H44022900158202103301745421708",
  27899. PsnNo: "44020000001102211928",
  27900. Info: "2207",
  27901. }
  27902. customData = append(customData, custom12)
  27903. custom1212 := &CustomData{
  27904. MsgId: "H440229001582021033017351627",
  27905. PsnNo: "44020000001102481733",
  27906. Info: "2207",
  27907. }
  27908. customData = append(customData, custom1212)
  27909. custom13 := &CustomData{
  27910. MsgId: "H44022900158202103301740327951",
  27911. PsnNo: "44020000001103174866",
  27912. Info: "2207",
  27913. }
  27914. customData = append(customData, custom13)
  27915. custom14 := &CustomData{
  27916. MsgId: "H4402290015820210330174922668",
  27917. PsnNo: "44020000001102927272",
  27918. Info: "2207",
  27919. }
  27920. customData = append(customData, custom14)
  27921. custom15 := &CustomData{
  27922. MsgId: "H44022900158202103301752362273",
  27923. PsnNo: "44020000001102942890",
  27924. Info: "2207",
  27925. }
  27926. customData = append(customData, custom15)
  27927. custom16 := &CustomData{
  27928. MsgId: "H44022900158202103301751082917",
  27929. PsnNo: "44020000001101662162",
  27930. Info: "2207",
  27931. }
  27932. customData = append(customData, custom16)
  27933. custom17 := &CustomData{
  27934. MsgId: "H44022900158202103301754147728",
  27935. PsnNo: "44020000000229014511",
  27936. Info: "2207",
  27937. }
  27938. customData = append(customData, custom17)
  27939. adminUser := c.GetAdminUserInfo()
  27940. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27941. for _, item := range customData {
  27942. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27943. fmt.Println(result)
  27944. }
  27945. }
  27946. func (c *HisApiController) GetAllopatry() {
  27947. year := c.GetString("year")
  27948. month := c.GetString("month")
  27949. admin_user_id, _ := c.GetInt64("admin_user_id")
  27950. adminUser := c.GetAdminUserInfo()
  27951. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27952. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27953. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27954. var dat map[string]interface{}
  27955. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27956. fmt.Println(dat)
  27957. } else {
  27958. fmt.Println(err)
  27959. }
  27960. userJSONBytes, _ := json.Marshal(dat)
  27961. var res models.Result9001
  27962. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27963. utils.ErrorLog("解析失败:%v", err)
  27964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27965. return
  27966. }
  27967. fmt.Println(res.Output.Signinoutb)
  27968. fmt.Println(res.Output.Signinoutb.SignNo)
  27969. fmt.Println(string(userJSONBytes))
  27970. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27971. var dat3 map[string]interface{}
  27972. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27973. fmt.Println(dat3)
  27974. } else {
  27975. fmt.Println(err)
  27976. }
  27977. userJSONBytes3, _ := json.Marshal(dat3)
  27978. var res3 models.Result3260
  27979. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27980. utils.ErrorLog("解析失败:%v", err)
  27981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27982. return
  27983. }
  27984. var curpage int
  27985. var pagesize int = 100
  27986. var start int = 1
  27987. //var stop int
  27988. //pagecount := 10
  27989. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27990. var res22 []models.Result3260
  27991. for curpage = 1; curpage <= pagecount; curpage++ {
  27992. if curpage == 1 {
  27993. start = 0
  27994. } else {
  27995. start = (curpage-1)*pagesize + 1
  27996. }
  27997. fmt.Println(start)
  27998. //stop = curpage * pagesize
  27999. //if stop > int(res3.Output.Totalrow) {
  28000. // stop =int(res3.Output.Totalrow)
  28001. //}
  28002. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28003. var dat2 map[string]interface{}
  28004. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28005. fmt.Println(dat)
  28006. } else {
  28007. fmt.Println(err)
  28008. }
  28009. userJSONBytes2, _ := json.Marshal(dat2)
  28010. var res2 models.Result3260
  28011. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28012. utils.ErrorLog("解析失败:%v", err)
  28013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28014. return
  28015. }
  28016. if res2.Infcode == 0 {
  28017. res22 = append(res22, res2)
  28018. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28019. //var dat2 map[string]interface{}
  28020. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28021. // fmt.Println(dat)
  28022. //} else {
  28023. // fmt.Println(err)
  28024. //}
  28025. //c.ServeSuccessJSON(map[string]interface{}{
  28026. // "list": res2.Output.Data,
  28027. //})
  28028. //continue
  28029. }
  28030. }
  28031. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28032. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28033. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28034. //var dat2 map[string]interface{}
  28035. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28036. // fmt.Println(dat)
  28037. //} else {
  28038. // fmt.Println(err)
  28039. //}
  28040. //userJSONBytes2, _ := json.Marshal(dat2)
  28041. //var res2 models.Result3260
  28042. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28043. // utils.ErrorLog("解析失败:%v", err)
  28044. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28045. // return
  28046. //}
  28047. //if res2.Infcode == 0 {
  28048. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28049. // var dat2 map[string]interface{}
  28050. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28051. // fmt.Println(dat)
  28052. // } else {
  28053. // fmt.Println(err)
  28054. // }
  28055. // c.ServeSuccessJSON(map[string]interface{}{
  28056. // "list": res2.Output.Data,
  28057. // })
  28058. //}
  28059. }
  28060. func (c *HisApiController) ComfirmAllopatry() {
  28061. year := c.GetString("year")
  28062. month := c.GetString("month")
  28063. admin_user_id, _ := c.GetInt64("admin_user_id")
  28064. adminUser := c.GetAdminUserInfo()
  28065. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28066. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28067. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28068. var dat map[string]interface{}
  28069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28070. fmt.Println(dat)
  28071. } else {
  28072. fmt.Println(err)
  28073. }
  28074. userJSONBytes, _ := json.Marshal(dat)
  28075. var res models.Result9001
  28076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28077. utils.ErrorLog("解析失败:%v", err)
  28078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28079. return
  28080. }
  28081. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28082. var dat2 map[string]interface{}
  28083. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28084. fmt.Println(dat)
  28085. } else {
  28086. fmt.Println(err)
  28087. }
  28088. userJSONBytes2, _ := json.Marshal(dat2)
  28089. var res2 models.Result3260
  28090. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28091. utils.ErrorLog("解析失败:%v", err)
  28092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28093. return
  28094. }
  28095. //if res2.Infcode == 0 {
  28096. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28097. // var dat map[string]interface{}
  28098. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28099. // fmt.Println(dat)
  28100. // } else {
  28101. // fmt.Println(err)
  28102. // }
  28103. // userJSONBytes, _ := json.Marshal(dat)
  28104. // var res3 models.Result3261
  28105. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  28106. // utils.ErrorLog("解析失败:%v", err)
  28107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28108. // return
  28109. // }
  28110. //
  28111. // if res3.Infcode == 0 {
  28112. // record := &models.HisYidiClearRecord{
  28113. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28114. // Ctime: time.Now().Unix(),
  28115. // Mtime: time.Now().Unix(),
  28116. // Status: 1,
  28117. // MsgId: msgId,
  28118. // }
  28119. // service.SaveClearRecord(record)
  28120. // c.ServeSuccessJSON(map[string]interface{}{
  28121. // "msg": "提取成功",
  28122. // })
  28123. // }
  28124. //}
  28125. }
  28126. func (c *HisApiController) RefundAllopatry() {
  28127. year := c.GetString("year")
  28128. month := c.GetString("month")
  28129. //id, _ := c.GetInt64("id")
  28130. admin_user_id, _ := c.GetInt64("admin_user_id")
  28131. adminUser := c.GetAdminUserInfo()
  28132. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28133. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28134. //record, _ := service.GetClearRecordById(id)
  28135. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28136. var dat map[string]interface{}
  28137. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28138. fmt.Println(dat)
  28139. } else {
  28140. fmt.Println(err)
  28141. }
  28142. userJSONBytes, _ := json.Marshal(dat)
  28143. var res models.Result9001
  28144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28145. utils.ErrorLog("解析失败:%v", err)
  28146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28147. return
  28148. }
  28149. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  28150. var dat2 map[string]interface{}
  28151. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28152. fmt.Println(dat)
  28153. } else {
  28154. fmt.Println(err)
  28155. }
  28156. userJSONBytes2, _ := json.Marshal(dat2)
  28157. var empty ResultFourteen
  28158. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  28159. utils.ErrorLog("解析失败:%v", err)
  28160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28161. return
  28162. }
  28163. if empty.Infcode == 0 {
  28164. c.ServeSuccessJSON(map[string]interface{}{
  28165. "msg": "撤销成功",
  28166. })
  28167. return
  28168. }
  28169. }
  28170. func (c *HisApiController) ReversalOtherData() {
  28171. var customData []*CustomData
  28172. custom := &CustomData{
  28173. MsgId: "H44022900158202103301714472004",
  28174. PsnNo: "44020000001101329945",
  28175. Info: "2208",
  28176. }
  28177. customData = append(customData, custom)
  28178. custom1 := &CustomData{
  28179. MsgId: "H4402290015820210330172057803",
  28180. PsnNo: "44020000001101161813",
  28181. Info: "2208",
  28182. }
  28183. customData = append(customData, custom1)
  28184. custom2 := &CustomData{
  28185. MsgId: "H44022900158202103301705198813",
  28186. PsnNo: "44190000133097375417",
  28187. Info: "2208",
  28188. }
  28189. customData = append(customData, custom2)
  28190. custom3 := &CustomData{
  28191. MsgId: "H44022900158202103301715524756",
  28192. PsnNo: "44020000001100187221",
  28193. Info: "2208",
  28194. }
  28195. customData = append(customData, custom3)
  28196. custom4 := &CustomData{
  28197. MsgId: "H44022900158202103301730376224",
  28198. PsnNo: "44020000001101959155",
  28199. Info: "2208",
  28200. }
  28201. customData = append(customData, custom4)
  28202. custom5 := &CustomData{
  28203. MsgId: "H44022900158202103301748008725",
  28204. PsnNo: "44020000001104246641",
  28205. Info: "2208",
  28206. }
  28207. customData = append(customData, custom5)
  28208. custom6 := &CustomData{
  28209. MsgId: "H44022900158202103301718096755",
  28210. PsnNo: "44020000001102211860",
  28211. Info: "2208",
  28212. }
  28213. customData = append(customData, custom6)
  28214. custom7 := &CustomData{
  28215. MsgId: "H44022900158202103301736551640",
  28216. PsnNo: "44020000001102687718",
  28217. Info: "2208",
  28218. }
  28219. customData = append(customData, custom7)
  28220. custom8 := &CustomData{
  28221. MsgId: "H44022900158202103301743097676",
  28222. PsnNo: "44020000001102127785",
  28223. Info: "2208",
  28224. }
  28225. customData = append(customData, custom8)
  28226. custom9 := &CustomData{
  28227. MsgId: "H44022900158202103301712304203",
  28228. PsnNo: "44020000001101518097",
  28229. Info: "2208",
  28230. }
  28231. customData = append(customData, custom9)
  28232. custom10 := &CustomData{
  28233. MsgId: "H44022900158202103301738448785",
  28234. PsnNo: "44020000001100500813",
  28235. Info: "2208",
  28236. }
  28237. customData = append(customData, custom10)
  28238. custom11 := &CustomData{
  28239. MsgId: "H44022900158202103301732455843",
  28240. PsnNo: "44020000001102690557",
  28241. Info: "2208",
  28242. }
  28243. customData = append(customData, custom11)
  28244. custom12 := &CustomData{
  28245. MsgId: "H44022900158202103301745421708",
  28246. PsnNo: "44020000001102211928",
  28247. Info: "2208",
  28248. }
  28249. customData = append(customData, custom12)
  28250. custom1212 := &CustomData{
  28251. MsgId: "H440229001582021033017351627",
  28252. PsnNo: "44020000001102481733",
  28253. Info: "2208",
  28254. }
  28255. customData = append(customData, custom1212)
  28256. custom13 := &CustomData{
  28257. MsgId: "H44022900158202103301740327951",
  28258. PsnNo: "44020000001103174866",
  28259. Info: "2208",
  28260. }
  28261. customData = append(customData, custom13)
  28262. custom14 := &CustomData{
  28263. MsgId: "H4402290015820210330174922668",
  28264. PsnNo: "44020000001102927272",
  28265. Info: "2208",
  28266. }
  28267. customData = append(customData, custom14)
  28268. custom15 := &CustomData{
  28269. MsgId: "H44022900158202103301752362273",
  28270. PsnNo: "44020000001102942890",
  28271. Info: "2208",
  28272. }
  28273. customData = append(customData, custom15)
  28274. custom16 := &CustomData{
  28275. MsgId: "H44022900158202103301751082917",
  28276. PsnNo: "44020000001101662162",
  28277. Info: "2208",
  28278. }
  28279. customData = append(customData, custom16)
  28280. custom17 := &CustomData{
  28281. MsgId: "H44022900158202103301754147728",
  28282. PsnNo: "44020000000229014511",
  28283. Info: "2208",
  28284. }
  28285. customData = append(customData, custom17)
  28286. adminUser := c.GetAdminUserInfo()
  28287. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28288. for _, item := range customData {
  28289. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28290. fmt.Println(result)
  28291. }
  28292. }
  28293. func PathExists(path string) (bool, error) {
  28294. _, err := os.Stat(path)
  28295. if err == nil {
  28296. return true, nil
  28297. }
  28298. if os.IsNotExist(err) {
  28299. return false, nil
  28300. }
  28301. return false, err
  28302. }
  28303. // 创建文件夹
  28304. func Mkdir(dir string) {
  28305. // 创建文件夹
  28306. exist, err := PathExists(dir)
  28307. if err != nil {
  28308. fmt.Println(err.Error())
  28309. } else {
  28310. if exist {
  28311. fmt.Println(dir + "文件夹已存在!")
  28312. } else {
  28313. // 文件夹名称,权限
  28314. err := os.Mkdir(dir, os.ModePerm)
  28315. if err != nil {
  28316. fmt.Println(dir+"文件夹创建失败:", err.Error())
  28317. } else {
  28318. fmt.Println(dir + "文件夹创建成功!")
  28319. }
  28320. }
  28321. }
  28322. }
  28323. // 压缩文件
  28324. func Zip(srcFile string, destZip string) error {
  28325. zipfile, err := os.Create(destZip)
  28326. if err != nil {
  28327. return err
  28328. }
  28329. defer zipfile.Close()
  28330. archive := zip.NewWriter(zipfile)
  28331. defer archive.Close()
  28332. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  28333. if err != nil {
  28334. return err
  28335. }
  28336. header, err := zip.FileInfoHeader(info)
  28337. if err != nil {
  28338. return err
  28339. }
  28340. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  28341. // header.Name = path
  28342. if info.IsDir() {
  28343. header.Name += "/"
  28344. } else {
  28345. header.Method = zip.Deflate
  28346. }
  28347. writer, err := archive.CreateHeader(header)
  28348. if err != nil {
  28349. return err
  28350. }
  28351. if !info.IsDir() {
  28352. file, err := os.Open(path)
  28353. if err != nil {
  28354. return err
  28355. }
  28356. defer file.Close()
  28357. _, err = io.Copy(writer, file)
  28358. }
  28359. return err
  28360. })
  28361. return err
  28362. }
  28363. func ReadFile(filePath string) []byte {
  28364. f, err := os.Open(filePath)
  28365. if err != nil {
  28366. fmt.Println("read file fail", err)
  28367. return nil
  28368. }
  28369. defer f.Close()
  28370. fd, err := ioutil.ReadAll(f)
  28371. if err != nil {
  28372. fmt.Println("read to fd fail", err)
  28373. return nil
  28374. }
  28375. return fd
  28376. }
  28377. func saveLogq(result string, request string, infno string, desc string) {
  28378. dir := "日志"
  28379. utils.Mkdir(dir)
  28380. month := time.Unix(1557042972, 0).Format("1")
  28381. year := time.Now().Format("2006")
  28382. month = time.Now().Format("01")
  28383. day := time.Now().Format("02")
  28384. hour := time.Now().Format("15")
  28385. min := time.Now().Format("04")
  28386. sec := time.Now().Format("05")
  28387. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28388. file := year + month + day + "_log"
  28389. file_name := file + ".txt"
  28390. file_path := "日志" + "/" + file_name
  28391. exist, _ := utils.PathExists(file_path)
  28392. if exist { //存在
  28393. fmt.Println("存在")
  28394. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28395. if err != nil {
  28396. fmt.Println("read fail")
  28397. }
  28398. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28399. n, _ := f.Seek(0, 2)
  28400. _, err = f.WriteAt([]byte(content), n)
  28401. } else { //不存在
  28402. fmt.Println("文件不存在,创建文件")
  28403. f, err := os.Create("日志" + "/" + file_name)
  28404. defer f.Close()
  28405. if err != nil {
  28406. } else {
  28407. _, err = f.Write([]byte("记录日志"))
  28408. }
  28409. }
  28410. }
  28411. func saveLog(result string, request string, infno string, desc string) {
  28412. org_id, _ := beego.AppConfig.Int64("org_id")
  28413. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28414. dir := miConfig.OrgName + "日志"
  28415. utils.Mkdir(dir)
  28416. month := time.Unix(1557042972, 0).Format("1")
  28417. year := time.Now().Format("2006")
  28418. month = time.Now().Format("01")
  28419. day := time.Now().Format("02")
  28420. hour := time.Now().Format("15")
  28421. min := time.Now().Format("04")
  28422. sec := time.Now().Format("05")
  28423. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28424. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  28425. file_name := file + ".txt"
  28426. file_path := miConfig.OrgName + "日志" + "/" + file_name
  28427. exist, _ := utils.PathExists(file_path)
  28428. if exist { //存在
  28429. fmt.Println("存在")
  28430. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28431. if err != nil {
  28432. fmt.Println("read fail")
  28433. }
  28434. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28435. n, _ := f.Seek(0, 2)
  28436. _, err = f.WriteAt([]byte(content), n)
  28437. } else { //不存在
  28438. fmt.Println("文件不存在,创建文件")
  28439. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  28440. defer f.Close()
  28441. if err != nil {
  28442. } else {
  28443. _, err = f.Write([]byte("记录日志"))
  28444. }
  28445. }
  28446. }
  28447. type Charset string
  28448. const (
  28449. UTF8 = Charset("UTF-8")
  28450. GB18030 = Charset("GB18030")
  28451. )
  28452. func ConvertToString(src string, srcCode string, tagCode string) string {
  28453. srcCoder := mahonia.NewDecoder(srcCode)
  28454. srcResult := srcCoder.ConvertString(src)
  28455. tagCoder := mahonia.NewDecoder(tagCode)
  28456. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  28457. result := string(cdata)
  28458. return result
  28459. }
  28460. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  28461. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28462. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28463. var token string
  28464. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28465. var api string
  28466. if miConfig.MdtrtareaAdmvs == "320921" {
  28467. 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 +
  28468. "&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
  28469. fmt.Println(api)
  28470. } else {
  28471. 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 +
  28472. "&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
  28473. }
  28474. resp, requestErr := http.Get(api)
  28475. if requestErr != nil {
  28476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28477. return ""
  28478. }
  28479. body, ioErr := ioutil.ReadAll(resp.Body)
  28480. if ioErr != nil {
  28481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28483. return ""
  28484. }
  28485. var respJSON map[string]interface{}
  28486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28489. return ""
  28490. }
  28491. var status string
  28492. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28493. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28494. var res ResultTwo //1101结果
  28495. var res10265 ResultTwo10265 //1101结果
  28496. if status == "0" { //读卡成功
  28497. var card_info string //卡信息
  28498. var busi_card_info string
  28499. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28500. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28501. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28502. fmt.Println(card_info)
  28503. fmt.Println(busi_card_info)
  28504. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28505. result, _ := json.Marshal(respJSON)
  28506. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28507. utils.ErrorLog("解析失败:%v", err)
  28508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28509. return ""
  28510. }
  28511. res.ErrMsg = res10265.ErrMsg
  28512. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28513. res.Infcode = infocode
  28514. res.Output = res10265.Output
  28515. res.InfRefmsgid = res10265.InfRefmsgid
  28516. if res.Infcode == 0 {
  28517. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28518. if err == gorm.ErrRecordNotFound {
  28519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28520. return ""
  28521. } else if err != nil {
  28522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28523. return ""
  28524. } else {
  28525. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28526. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28527. infoStr := string(Iinfos)
  28528. idetinfoStr := string(Idetinfos)
  28529. psn := &models.HisPsn{
  28530. PsnNo: res.Output.Baseinfo.PsnNo,
  28531. PatientId: patient.ID,
  28532. Certno: res.Output.Baseinfo.Certno,
  28533. Gend: res.Output.Baseinfo.Gend,
  28534. Naty: res.Output.Baseinfo.Naty,
  28535. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28536. PsnName: res.Output.Baseinfo.PsnName,
  28537. Idetinfo: idetinfoStr,
  28538. Insuinfo: infoStr,
  28539. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28540. CardInfo: card_info,
  28541. VerifyNumber: token,
  28542. }
  28543. service.CreateHisPsn(psn)
  28544. return token
  28545. }
  28546. }
  28547. } else {
  28548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28549. return ""
  28550. }
  28551. } else { //读卡失败
  28552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28553. return ""
  28554. }
  28555. return token
  28556. }
  28557. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  28558. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28559. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28560. var token string
  28561. var api string
  28562. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28563. "&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
  28564. fmt.Println(api)
  28565. resp, requestErr := http.Get(api)
  28566. if requestErr != nil {
  28567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28568. return ""
  28569. }
  28570. body, ioErr := ioutil.ReadAll(resp.Body)
  28571. if ioErr != nil {
  28572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28574. return ""
  28575. }
  28576. var respJSON map[string]interface{}
  28577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28580. return ""
  28581. }
  28582. var status string
  28583. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28584. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28585. var res ResultTwo //1101结果
  28586. if status == "1" { //读卡成功
  28587. var card_info string //卡信息
  28588. var busi_card_info string
  28589. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28590. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28591. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28592. fmt.Println(card_info)
  28593. fmt.Println(busi_card_info)
  28594. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28595. result, _ := json.Marshal(respJSON)
  28596. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28597. utils.ErrorLog("解析失败:%v", err)
  28598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28599. return ""
  28600. }
  28601. if res.Infcode == 0 {
  28602. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28603. if err == gorm.ErrRecordNotFound {
  28604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28605. return ""
  28606. } else if err != nil {
  28607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28608. return ""
  28609. } else {
  28610. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28611. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28612. infoStr := string(Iinfos)
  28613. idetinfoStr := string(Idetinfos)
  28614. psn := &models.HisPsn{
  28615. PsnNo: res.Output.Baseinfo.PsnNo,
  28616. PatientId: patient.ID,
  28617. Certno: res.Output.Baseinfo.Certno,
  28618. Gend: res.Output.Baseinfo.Gend,
  28619. Naty: res.Output.Baseinfo.Naty,
  28620. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28621. PsnName: res.Output.Baseinfo.PsnName,
  28622. Idetinfo: idetinfoStr,
  28623. Insuinfo: infoStr,
  28624. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28625. CardInfo: card_info,
  28626. VerifyNumber: token,
  28627. }
  28628. service.CreateHisPsn(psn)
  28629. return token
  28630. }
  28631. }
  28632. } else {
  28633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28634. return ""
  28635. }
  28636. return token
  28637. }
  28638. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28639. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28640. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28641. var token string
  28642. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28643. var api string
  28644. if miConfig.MdtrtareaAdmvs == "320921" {
  28645. 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 +
  28646. "&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
  28647. fmt.Println(api)
  28648. } else {
  28649. 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 +
  28650. "&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
  28651. }
  28652. resp, requestErr := http.Get(api)
  28653. if requestErr != nil {
  28654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28655. return ""
  28656. }
  28657. body, ioErr := ioutil.ReadAll(resp.Body)
  28658. if ioErr != nil {
  28659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28661. return ""
  28662. }
  28663. var respJSON map[string]interface{}
  28664. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28665. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28667. return ""
  28668. }
  28669. var status string
  28670. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28671. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28672. var res ResultTwo //1101结果
  28673. var res10265 ResultTwo10265 //1101结果
  28674. if status == "0" { //读卡成功
  28675. var card_info string //卡信息
  28676. var busi_card_info string
  28677. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28678. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28679. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28680. fmt.Println(card_info)
  28681. fmt.Println(busi_card_info)
  28682. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28683. result, _ := json.Marshal(respJSON)
  28684. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28685. utils.ErrorLog("解析失败:%v", err)
  28686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28687. return ""
  28688. }
  28689. res.ErrMsg = res10265.ErrMsg
  28690. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28691. res.Infcode = infocode
  28692. res.Output = res10265.Output
  28693. res.InfRefmsgid = res10265.InfRefmsgid
  28694. if res.Infcode == 0 {
  28695. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28696. if err == gorm.ErrRecordNotFound {
  28697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28698. return ""
  28699. } else if err != nil {
  28700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28701. return ""
  28702. } else {
  28703. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28704. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28705. infoStr := string(Iinfos)
  28706. idetinfoStr := string(Idetinfos)
  28707. psn := &models.HisPsn{
  28708. PsnNo: res.Output.Baseinfo.PsnNo,
  28709. PatientId: patient.ID,
  28710. Certno: res.Output.Baseinfo.Certno,
  28711. Gend: res.Output.Baseinfo.Gend,
  28712. Naty: res.Output.Baseinfo.Naty,
  28713. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28714. PsnName: res.Output.Baseinfo.PsnName,
  28715. Idetinfo: idetinfoStr,
  28716. Insuinfo: infoStr,
  28717. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28718. CardInfo: card_info,
  28719. VerifyNumber: token,
  28720. }
  28721. service.CreateHisPsn(psn)
  28722. return token
  28723. }
  28724. }
  28725. } else {
  28726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28727. return ""
  28728. }
  28729. } else { //读卡失败
  28730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28731. return ""
  28732. }
  28733. return token
  28734. }
  28735. func DeleteExtraSpaceTwo(s string) string {
  28736. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28737. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28738. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28739. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28740. s2 := make([]byte, len(s1)) //定义字符数组切片
  28741. copy(s2, s1) //将字符串复制到切片
  28742. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28743. for len(spc_index) > 0 { //找到适配项
  28744. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28745. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28746. }
  28747. return string(s2)
  28748. }
  28749. func Remove0000(s string) string {
  28750. str := make([]rune, 0, len(s))
  28751. for _, v := range []rune(s) {
  28752. if v == 0 {
  28753. continue
  28754. }
  28755. str = append(str, v)
  28756. }
  28757. return string(str)
  28758. }
  28759. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28760. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28761. readCard := DllDef.MustFindProc("EcQuery")
  28762. pCardInfo := make([]byte, 8192)
  28763. pBusiCardInfo := make([]byte, 8192)
  28764. data := make(map[string]interface{})
  28765. //pData := make(map[string]interface{})
  28766. inputData := make(map[string]interface{})
  28767. inputData["orgId"] = code
  28768. inputData["businessType"] = "01101"
  28769. inputData["operatorId"] = operator_id
  28770. inputData["operatorName"] = operator_name
  28771. inputData["officeId"] = "001"
  28772. inputData["officeName"] = "血透室"
  28773. //
  28774. data["data"] = inputData
  28775. data["transType"] = "ec.query"
  28776. data["orgId"] = code
  28777. bytesData, _ := json.Marshal(data)
  28778. pCardInfo = bytesData
  28779. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28780. fmt.Println(ret2)
  28781. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28782. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28783. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28784. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28785. if ret2 != 0 {
  28786. return "", ""
  28787. }
  28788. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28789. }
  28790. func DeleteExtraSpace(s string) string {
  28791. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28792. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28793. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28794. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28795. s2 := make([]byte, len(s1)) //定义字符数组切片
  28796. copy(s2, s1) //将字符串复制到切片
  28797. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28798. for len(spc_index) > 0 { //找到适配项
  28799. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28800. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28801. }
  28802. return string(s2)
  28803. }
  28804. // 对账
  28805. func (c *HisApiController) Post3202() {
  28806. start_time := c.GetString("start_time")
  28807. end_time := c.GetString("end_time")
  28808. //insutype := c.GetString("insutype")
  28809. clr_type := c.GetString("clr_type")
  28810. clr_org := c.GetString("clr_optins")
  28811. admin_user_id, _ := c.GetInt64("admin_user_id")
  28812. adminUser := c.GetAdminUserInfo()
  28813. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28814. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28815. if len(clr_org) == 0 {
  28816. clr_org = miConfig.MdtrtareaAdmvs
  28817. }
  28818. timeLayout := "2006-01-02"
  28819. loc, _ := time.LoadLocation("Local")
  28820. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28821. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28822. var orders []*models.HisOrder
  28823. if clr_org == "421300" {
  28824. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28825. } else {
  28826. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28827. }
  28828. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28829. //fixmedins_setl_cnt := int64(len(orders))
  28830. var medfee_sumamt float64
  28831. var acct_pay float64
  28832. var fund_pay_sumamt float64
  28833. for _, item := range orders {
  28834. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28835. acct_pay = acct_pay + item.AcctPay
  28836. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28837. }
  28838. //var medfee_sumamt_two float64
  28839. //var acct_pay_two float64
  28840. //var fund_pay_sumamt_two float64
  28841. //for _, item := range orders_two {
  28842. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28843. // acct_pay_two = acct_pay_two + item.AcctPay
  28844. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28845. //}
  28846. //var user_name string
  28847. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28848. //if role.ID == 0 {
  28849. // user_name = "xxx"
  28850. //} else {
  28851. // user_name = role.UserName
  28852. //}
  28853. var res ResultSix
  28854. if config.IsOpen == 1 {
  28855. var bps []*models.BusinessParamsTwo
  28856. var bp models.BusinessParamsTwo
  28857. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28858. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28859. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28860. bp.MedfeeSumamt = medfee_sumamt_str
  28861. bp.AcctPay = acct_pay_str
  28862. bp.FundPaySumamt = fund_pay_sumamt_str
  28863. bp.Insutype = ""
  28864. bp.StmtBegndate = start_time
  28865. bp.ClrType = clr_type
  28866. bp.SetlOptins = clr_org
  28867. bp.StmtEnddate = end_time
  28868. bps = append(bps, &bp)
  28869. data := make(map[string]interface{})
  28870. data["bps"] = bps
  28871. data["org_name"] = miConfig.OrgName
  28872. data["doctor"] = role.UserName
  28873. data["fixmedins_code"] = miConfig.Code
  28874. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28875. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28876. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28877. if miConfig.MdtrtareaAdmvs == "421300" {
  28878. client := &http.Client{}
  28879. bytesData, _ := json.Marshal(data)
  28880. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28881. resp, _ := client.Do(req)
  28882. defer resp.Body.Close()
  28883. body, ioErr := ioutil.ReadAll(resp.Body)
  28884. if ioErr != nil {
  28885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28887. return
  28888. }
  28889. var respJSON map[string]interface{}
  28890. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28893. return
  28894. }
  28895. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28896. userJSONBytes, _ := json.Marshal(respJSON)
  28897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28898. utils.ErrorLog("解析失败:%v", err)
  28899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28900. return
  28901. }
  28902. }
  28903. if miConfig.MdtrtareaAdmvs == "420200" {
  28904. client := &http.Client{}
  28905. bytesData, _ := json.Marshal(data)
  28906. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28907. resp, _ := client.Do(req)
  28908. defer resp.Body.Close()
  28909. body, ioErr := ioutil.ReadAll(resp.Body)
  28910. if ioErr != nil {
  28911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28913. return
  28914. }
  28915. var respJSON map[string]interface{}
  28916. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28919. return
  28920. }
  28921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28922. userJSONBytes, _ := json.Marshal(respJSON)
  28923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28924. utils.ErrorLog("解析失败:%v", err)
  28925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28926. return
  28927. }
  28928. }
  28929. if miConfig.MdtrtareaAdmvs == "421182" {
  28930. client := &http.Client{}
  28931. bytesData, _ := json.Marshal(data)
  28932. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28933. resp, _ := client.Do(req)
  28934. defer resp.Body.Close()
  28935. body, ioErr := ioutil.ReadAll(resp.Body)
  28936. if ioErr != nil {
  28937. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28939. return
  28940. }
  28941. var respJSON map[string]interface{}
  28942. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28943. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28945. return
  28946. }
  28947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28948. userJSONBytes, _ := json.Marshal(respJSON)
  28949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28950. utils.ErrorLog("解析失败:%v", err)
  28951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28952. return
  28953. }
  28954. }
  28955. if res.Infcode == 0 {
  28956. c.ServeSuccessJSON(map[string]interface{}{
  28957. "msg": "发起成功",
  28958. })
  28959. } else {
  28960. c.ServeSuccessJSON(map[string]interface{}{
  28961. "failed_code": -10,
  28962. "msg": res.ErrMsg,
  28963. })
  28964. }
  28965. }
  28966. }
  28967. func (c *HisApiController) Post3202b() {
  28968. start_time := c.GetString("start_time")
  28969. end_time := c.GetString("end_time")
  28970. //insutype := c.GetString("insutype")
  28971. clr_type := c.GetString("clr_type")
  28972. clr_org := c.GetString("clr_optins")
  28973. admin_user_id, _ := c.GetInt64("admin_user_id")
  28974. adminUser := c.GetAdminUserInfo()
  28975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28976. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28977. if len(clr_org) == 0 {
  28978. clr_org = miConfig.MdtrtareaAdmvs
  28979. }
  28980. timeLayout := "2006-01-02"
  28981. loc, _ := time.LoadLocation("Local")
  28982. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28983. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28984. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28985. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28986. //fixmedins_setl_cnt := int64(len(orders))
  28987. var medfee_sumamt float64
  28988. var acct_pay float64
  28989. var fund_pay_sumamt float64
  28990. for _, item := range orders {
  28991. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28992. acct_pay = acct_pay + item.AcctPay
  28993. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28994. }
  28995. //var medfee_sumamt_two float64
  28996. //var acct_pay_two float64
  28997. //var fund_pay_sumamt_two float64
  28998. //for _, item := range orders_two {
  28999. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29000. // acct_pay_two = acct_pay_two + item.AcctPay
  29001. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29002. //}
  29003. //var user_name string
  29004. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29005. //if role.ID == 0 {
  29006. // user_name = "xxx"
  29007. //} else {
  29008. // user_name = role.UserName
  29009. //}
  29010. var res ResultSix
  29011. if config.IsOpen == 1 {
  29012. var bps []*models.BusinessParamsTwo
  29013. var bp models.BusinessParamsTwo
  29014. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29015. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29016. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29017. bp.MedfeeSumamt = medfee_sumamt_str
  29018. bp.AcctPay = acct_pay_str
  29019. bp.FundPaySumamt = fund_pay_sumamt_str
  29020. bp.Insutype = "390"
  29021. bp.StmtBegndate = start_time
  29022. bp.ClrType = clr_type
  29023. bp.SetlOptins = clr_org
  29024. bp.StmtEnddate = end_time
  29025. bps = append(bps, &bp)
  29026. data := make(map[string]interface{})
  29027. data["bps"] = bps
  29028. data["org_name"] = miConfig.OrgName
  29029. data["doctor"] = role.UserName
  29030. data["fixmedins_code"] = miConfig.Code
  29031. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29032. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29033. if miConfig.MdtrtareaAdmvs == "421300" {
  29034. client := &http.Client{}
  29035. bytesData, _ := json.Marshal(data)
  29036. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29037. resp, _ := client.Do(req)
  29038. defer resp.Body.Close()
  29039. body, ioErr := ioutil.ReadAll(resp.Body)
  29040. if ioErr != nil {
  29041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29043. return
  29044. }
  29045. var respJSON map[string]interface{}
  29046. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29049. return
  29050. }
  29051. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29052. userJSONBytes, _ := json.Marshal(respJSON)
  29053. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29054. utils.ErrorLog("解析失败:%v", err)
  29055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29056. return
  29057. }
  29058. }
  29059. if miConfig.MdtrtareaAdmvs == "420200" {
  29060. client := &http.Client{}
  29061. bytesData, _ := json.Marshal(data)
  29062. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29063. resp, _ := client.Do(req)
  29064. defer resp.Body.Close()
  29065. body, ioErr := ioutil.ReadAll(resp.Body)
  29066. if ioErr != nil {
  29067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29069. return
  29070. }
  29071. var respJSON map[string]interface{}
  29072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29075. return
  29076. }
  29077. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29078. userJSONBytes, _ := json.Marshal(respJSON)
  29079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29080. utils.ErrorLog("解析失败:%v", err)
  29081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29082. return
  29083. }
  29084. }
  29085. if miConfig.MdtrtareaAdmvs == "421182" {
  29086. client := &http.Client{}
  29087. bytesData, _ := json.Marshal(data)
  29088. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29089. resp, _ := client.Do(req)
  29090. defer resp.Body.Close()
  29091. body, ioErr := ioutil.ReadAll(resp.Body)
  29092. if ioErr != nil {
  29093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29095. return
  29096. }
  29097. var respJSON map[string]interface{}
  29098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29101. return
  29102. }
  29103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29104. userJSONBytes, _ := json.Marshal(respJSON)
  29105. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29106. utils.ErrorLog("解析失败:%v", err)
  29107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29108. return
  29109. }
  29110. }
  29111. if res.Infcode == 0 {
  29112. c.ServeSuccessJSON(map[string]interface{}{
  29113. "msg": "发起成功",
  29114. })
  29115. } else {
  29116. c.ServeSuccessJSON(map[string]interface{}{
  29117. "failed_code": -10,
  29118. "msg": res.ErrMsg,
  29119. })
  29120. }
  29121. }
  29122. }
  29123. func (c *HisApiController) Post1608() {
  29124. start_time := c.GetString("start_time")
  29125. end_time := c.GetString("end_time")
  29126. admin_user_id, _ := c.GetInt64("admin_user_id")
  29127. adminUser := c.GetAdminUserInfo()
  29128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29129. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29130. timeLayout := "2006-01-02"
  29131. loc, _ := time.LoadLocation("Local")
  29132. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29133. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29134. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29135. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29136. fixmedins_setl_cnt := int64(len(orders))
  29137. var medfee_sumamt float64
  29138. var func_smamt float64
  29139. for _, item := range orders {
  29140. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29141. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  29142. }
  29143. times := strings.Split(start_time, "-")
  29144. time_tows := strings.Split(end_time, "-")
  29145. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29146. var res ResultSix
  29147. if config.IsOpen == 1 {
  29148. //var bps []*models.BusinessParamsTwo
  29149. //var bp models.BusinessParamsTwo
  29150. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29151. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  29152. data := make(map[string]interface{})
  29153. data["org_name"] = miConfig.OrgName
  29154. data["doctor"] = role.UserName
  29155. data["func_smamt"] = func_smamt_str
  29156. data["fixmedins_code"] = miConfig.Code
  29157. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29158. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29159. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  29160. data["medfee_sumamt"] = medfee_sumamt_str
  29161. data["start_time"] = times[0] + times[1] + times[2]
  29162. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  29163. if miConfig.MdtrtareaAdmvs == "421300" {
  29164. client := &http.Client{}
  29165. bytesData, _ := json.Marshal(data)
  29166. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29167. resp, _ := client.Do(req)
  29168. defer resp.Body.Close()
  29169. body, ioErr := ioutil.ReadAll(resp.Body)
  29170. if ioErr != nil {
  29171. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29173. return
  29174. }
  29175. var respJSON map[string]interface{}
  29176. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29177. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29179. return
  29180. }
  29181. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29182. userJSONBytes, _ := json.Marshal(respJSON)
  29183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29184. utils.ErrorLog("解析失败:%v", err)
  29185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29186. return
  29187. }
  29188. }
  29189. if miConfig.MdtrtareaAdmvs == "420200" {
  29190. client := &http.Client{}
  29191. bytesData, _ := json.Marshal(data)
  29192. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29193. resp, _ := client.Do(req)
  29194. defer resp.Body.Close()
  29195. body, ioErr := ioutil.ReadAll(resp.Body)
  29196. if ioErr != nil {
  29197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29199. return
  29200. }
  29201. var respJSON map[string]interface{}
  29202. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29205. return
  29206. }
  29207. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29208. userJSONBytes, _ := json.Marshal(respJSON)
  29209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29210. utils.ErrorLog("解析失败:%v", err)
  29211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29212. return
  29213. }
  29214. }
  29215. if miConfig.MdtrtareaAdmvs == "421182" {
  29216. client := &http.Client{}
  29217. bytesData, _ := json.Marshal(data)
  29218. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  29219. resp, _ := client.Do(req)
  29220. defer resp.Body.Close()
  29221. body, ioErr := ioutil.ReadAll(resp.Body)
  29222. if ioErr != nil {
  29223. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29225. return
  29226. }
  29227. var respJSON map[string]interface{}
  29228. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29229. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29231. return
  29232. }
  29233. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29234. userJSONBytes, _ := json.Marshal(respJSON)
  29235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29236. utils.ErrorLog("解析失败:%v", err)
  29237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29238. return
  29239. }
  29240. }
  29241. if res.Infcode == 0 {
  29242. c.ServeSuccessJSON(map[string]interface{}{
  29243. "msg": "发起成功",
  29244. })
  29245. } else {
  29246. c.ServeSuccessJSON(map[string]interface{}{
  29247. "failed_code": -10,
  29248. "msg": res.ErrMsg,
  29249. })
  29250. }
  29251. }
  29252. }
  29253. // 5.11.1.1【5262】结算信息按时间段查询
  29254. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29255. admin_user_id, _ := c.GetInt64("admin_user_id")
  29256. adminUser := c.GetAdminUserInfo()
  29257. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29258. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29259. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29260. var res Result5262
  29261. if config.IsOpen == 1 {
  29262. if miConfig.MdtrtareaAdmvs == "421300" {
  29263. data := make(map[string]interface{})
  29264. data["bps"] = bp
  29265. data["org_name"] = miConfig.OrgName
  29266. data["doctor"] = role.UserName
  29267. data["fixmedins_code"] = miConfig.Code
  29268. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29269. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29270. data["page"] = strconv.FormatInt(page, 10)
  29271. data["limit"] = strconv.FormatInt(limit, 10)
  29272. fmt.Println(data)
  29273. client := &http.Client{}
  29274. bytesData, _ := json.Marshal(data)
  29275. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29276. resp, _ := client.Do(req)
  29277. defer resp.Body.Close()
  29278. body, ioErr := ioutil.ReadAll(resp.Body)
  29279. if ioErr != nil {
  29280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29282. return
  29283. }
  29284. var respJSON map[string]interface{}
  29285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29288. return
  29289. }
  29290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29291. userJSONBytes, _ := json.Marshal(respJSON)
  29292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29293. utils.ErrorLog("解析失败:%v", err)
  29294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29295. return
  29296. }
  29297. }
  29298. if miConfig.MdtrtareaAdmvs == "420200" {
  29299. data := make(map[string]interface{})
  29300. data["bps"] = bp
  29301. data["org_name"] = miConfig.OrgName
  29302. data["doctor"] = role.UserName
  29303. data["fixmedins_code"] = miConfig.Code
  29304. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29305. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29306. data["page"] = strconv.FormatInt(page, 10)
  29307. data["limit"] = strconv.FormatInt(limit, 10)
  29308. fmt.Println(data)
  29309. client := &http.Client{}
  29310. bytesData, _ := json.Marshal(data)
  29311. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29312. resp, _ := client.Do(req)
  29313. defer resp.Body.Close()
  29314. body, ioErr := ioutil.ReadAll(resp.Body)
  29315. if ioErr != nil {
  29316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29318. return
  29319. }
  29320. var respJSON map[string]interface{}
  29321. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29324. return
  29325. }
  29326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29327. userJSONBytes, _ := json.Marshal(respJSON)
  29328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29329. utils.ErrorLog("解析失败:%v", err)
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. }
  29334. if miConfig.MdtrtareaAdmvs == "421182" {
  29335. data := make(map[string]interface{})
  29336. data["bps"] = bp
  29337. data["org_name"] = miConfig.OrgName
  29338. data["doctor"] = role.UserName
  29339. data["fixmedins_code"] = miConfig.Code
  29340. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29341. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29342. data["page"] = strconv.FormatInt(page, 10)
  29343. data["limit"] = strconv.FormatInt(limit, 10)
  29344. fmt.Println(data)
  29345. client := &http.Client{}
  29346. bytesData, _ := json.Marshal(data)
  29347. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  29348. resp, _ := client.Do(req)
  29349. defer resp.Body.Close()
  29350. body, ioErr := ioutil.ReadAll(resp.Body)
  29351. if ioErr != nil {
  29352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29354. return
  29355. }
  29356. var respJSON map[string]interface{}
  29357. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29360. return
  29361. }
  29362. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29363. userJSONBytes, _ := json.Marshal(respJSON)
  29364. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29365. utils.ErrorLog("解析失败:%v", err)
  29366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29367. return
  29368. }
  29369. }
  29370. if res.Infcode == 0 {
  29371. c.ServeSuccessJSON(map[string]interface{}{
  29372. "order": res.Output.Result,
  29373. "total": res.Output.PageInfo.RecordCounts,
  29374. })
  29375. } else {
  29376. c.ServeSuccessJSON(map[string]interface{}{
  29377. "failed_code": -10,
  29378. "msg": res.ErrMsg,
  29379. })
  29380. }
  29381. }
  29382. }
  29383. // 5.11.1.2【5267】异地结算信息时间段查询
  29384. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29385. admin_user_id, _ := c.GetInt64("admin_user_id")
  29386. adminUser := c.GetAdminUserInfo()
  29387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29389. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29390. var res Result5267
  29391. if config.IsOpen == 1 {
  29392. if miConfig.MdtrtareaAdmvs == "421300" {
  29393. data := make(map[string]interface{})
  29394. data["bps"] = bp
  29395. data["org_name"] = miConfig.OrgName
  29396. data["doctor"] = role.UserName
  29397. data["fixmedins_code"] = miConfig.Code
  29398. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29399. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29400. data["page"] = page
  29401. data["limit"] = limit
  29402. fmt.Println(data)
  29403. client := &http.Client{}
  29404. bytesData, _ := json.Marshal(data)
  29405. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29406. resp, _ := client.Do(req)
  29407. defer resp.Body.Close()
  29408. body, ioErr := ioutil.ReadAll(resp.Body)
  29409. if ioErr != nil {
  29410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29412. return
  29413. }
  29414. var respJSON map[string]interface{}
  29415. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29418. return
  29419. }
  29420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29421. userJSONBytes, _ := json.Marshal(respJSON)
  29422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29423. utils.ErrorLog("解析失败:%v", err)
  29424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29425. return
  29426. }
  29427. }
  29428. if miConfig.MdtrtareaAdmvs == "420200" {
  29429. data := make(map[string]interface{})
  29430. data["bps"] = bp
  29431. data["org_name"] = miConfig.OrgName
  29432. data["doctor"] = role.UserName
  29433. data["fixmedins_code"] = miConfig.Code
  29434. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29436. data["page"] = page
  29437. data["limit"] = limit
  29438. fmt.Println(data)
  29439. client := &http.Client{}
  29440. bytesData, _ := json.Marshal(data)
  29441. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29442. resp, _ := client.Do(req)
  29443. defer resp.Body.Close()
  29444. body, ioErr := ioutil.ReadAll(resp.Body)
  29445. if ioErr != nil {
  29446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29448. return
  29449. }
  29450. var respJSON map[string]interface{}
  29451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29454. return
  29455. }
  29456. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29457. userJSONBytes, _ := json.Marshal(respJSON)
  29458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29459. utils.ErrorLog("解析失败:%v", err)
  29460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29461. return
  29462. }
  29463. }
  29464. if miConfig.MdtrtareaAdmvs == "421182" {
  29465. data := make(map[string]interface{})
  29466. data["bps"] = bp
  29467. data["org_name"] = miConfig.OrgName
  29468. data["doctor"] = role.UserName
  29469. data["fixmedins_code"] = miConfig.Code
  29470. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29471. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29472. data["page"] = page
  29473. data["limit"] = limit
  29474. fmt.Println(data)
  29475. client := &http.Client{}
  29476. bytesData, _ := json.Marshal(data)
  29477. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  29478. resp, _ := client.Do(req)
  29479. defer resp.Body.Close()
  29480. body, ioErr := ioutil.ReadAll(resp.Body)
  29481. if ioErr != nil {
  29482. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29484. return
  29485. }
  29486. var respJSON map[string]interface{}
  29487. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29488. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29490. return
  29491. }
  29492. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29493. userJSONBytes, _ := json.Marshal(respJSON)
  29494. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29495. utils.ErrorLog("解析失败:%v", err)
  29496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29497. return
  29498. }
  29499. }
  29500. if res.Infcode == 0 {
  29501. c.ServeSuccessJSON(map[string]interface{}{
  29502. "order": res.Output.Result,
  29503. "total": res.Output.PageInfo.RecordCounts,
  29504. })
  29505. } else {
  29506. c.ServeSuccessJSON(map[string]interface{}{
  29507. "failed_code": -10,
  29508. "msg": res.ErrMsg,
  29509. })
  29510. }
  29511. }
  29512. }
  29513. func (c *HisApiController) Post3501() {
  29514. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29515. data := make(map[string]interface{})
  29516. var struct3501s []models.Struct3501
  29517. var struct3501 models.Struct3501
  29518. struct3501.OrgName = miConfig.OrgName
  29519. struct3501.AccessKey = miConfig.AccessKey
  29520. struct3501.RequestUrl = miConfig.Url
  29521. struct3501.SecretKey = miConfig.SecretKey
  29522. struct3501.ManuDate = "2022-08-17"
  29523. struct3501.FixmedinsBchno = ""
  29524. struct3501.ManuLotnum = ""
  29525. struct3501.RxFlag = "0"
  29526. struct3501.ExpyEnd = "2022-08-17"
  29527. struct3501.Invdate = "2022-08-17"
  29528. struct3501.InvCnt = "20.25"
  29529. struct3501.Memo = ""
  29530. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29531. struct3501.FixmedinsHilistId = miConfig.Code
  29532. struct3501.FixmedinsHilistName = miConfig.OrgName
  29533. struct3501s = append(struct3501s, struct3501)
  29534. data["struct_3501s"] = struct3501s
  29535. client := &http.Client{}
  29536. bytesData, _ := json.Marshal(data)
  29537. var req *http.Request
  29538. if miConfig.MdtrtareaAdmvs == "320921" {
  29539. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29540. } else {
  29541. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29542. }
  29543. resp, _ := client.Do(req)
  29544. defer resp.Body.Close()
  29545. body, ioErr := ioutil.ReadAll(resp.Body)
  29546. if ioErr != nil {
  29547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29549. return
  29550. }
  29551. var respJSON map[string]interface{}
  29552. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29555. return
  29556. }
  29557. var res ResultSix
  29558. var resSix10265 ResultSix10265 //1101结果
  29559. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29560. result, _ := json.Marshal(respJSON)
  29561. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29562. utils.ErrorLog("解析失败:%v", err)
  29563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29564. return
  29565. }
  29566. res.InfRefmsgid = resSix10265.InfRefmsgid
  29567. res.Output = resSix10265.Output
  29568. res.ErrMsg = resSix10265.ErrMsg
  29569. res.Cainfo = resSix10265.Cainfo
  29570. res.WarnMsg = resSix10265.WarnMsg
  29571. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29572. res.Infcode = infocode
  29573. if infocode == 0 {
  29574. c.ServeSuccessJSON(map[string]interface{}{
  29575. "msg": "上传成功",
  29576. })
  29577. return
  29578. } else {
  29579. c.ServeSuccessJSON(map[string]interface{}{
  29580. "failed_code": -10,
  29581. "msg": res.ErrMsg,
  29582. })
  29583. return
  29584. }
  29585. }
  29586. func (c *HisApiController) Post3502() {
  29587. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29588. data := make(map[string]interface{})
  29589. var struct3502s []models.Struct3502
  29590. var struct3502 models.Struct3502
  29591. struct3502.OrgName = miConfig.OrgName
  29592. struct3502.AccessKey = miConfig.AccessKey
  29593. struct3502.RequestUrl = miConfig.Url
  29594. struct3502.SecretKey = miConfig.SecretKey
  29595. struct3502.ManuDate = "2022-08-15"
  29596. struct3502.FixmedinsBchno = ""
  29597. struct3502.ManuLotnum = ""
  29598. struct3502.RxFlag = "0"
  29599. struct3502.ExpyEnd = "2022-08-15"
  29600. struct3502.Invdate = "2022-08-15"
  29601. struct3502.InvCnt = "20.25"
  29602. struct3502.Memo = ""
  29603. struct3502.MedListCodg = "XB01ABD056B002020200517"
  29604. struct3502.FixmedinsHilistId = miConfig.Code
  29605. struct3502.FixmedinsHilistName = miConfig.OrgName
  29606. struct3502s = append(struct3502s, struct3502)
  29607. data["struct_3502s"] = struct3502s
  29608. client := &http.Client{}
  29609. bytesData, _ := json.Marshal(data)
  29610. var req *http.Request
  29611. if miConfig.MdtrtareaAdmvs == "320921" {
  29612. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29613. } else {
  29614. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29615. }
  29616. resp, _ := client.Do(req)
  29617. defer resp.Body.Close()
  29618. body, ioErr := ioutil.ReadAll(resp.Body)
  29619. if ioErr != nil {
  29620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29622. return
  29623. }
  29624. var respJSON map[string]interface{}
  29625. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29628. return
  29629. }
  29630. var res ResultSix
  29631. var resSix10265 ResultSix10265 //1101结果
  29632. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29633. result, _ := json.Marshal(respJSON)
  29634. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29635. utils.ErrorLog("解析失败:%v", err)
  29636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29637. return
  29638. }
  29639. res.InfRefmsgid = resSix10265.InfRefmsgid
  29640. res.Output = resSix10265.Output
  29641. res.ErrMsg = resSix10265.ErrMsg
  29642. res.Cainfo = resSix10265.Cainfo
  29643. res.WarnMsg = resSix10265.WarnMsg
  29644. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29645. res.Infcode = infocode
  29646. if infocode == 0 {
  29647. c.ServeSuccessJSON(map[string]interface{}{
  29648. "msg": "上传成功",
  29649. })
  29650. return
  29651. } else {
  29652. c.ServeSuccessJSON(map[string]interface{}{
  29653. "failed_code": -10,
  29654. "msg": res.ErrMsg,
  29655. })
  29656. return
  29657. }
  29658. }
  29659. func (c *HisApiController) Post3503() {
  29660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29661. data := make(map[string]interface{})
  29662. var struct3501s []models.Struct3501
  29663. var struct3501 models.Struct3501
  29664. struct3501.OrgName = miConfig.OrgName
  29665. struct3501.AccessKey = miConfig.AccessKey
  29666. struct3501.RequestUrl = miConfig.Url
  29667. struct3501.SecretKey = miConfig.SecretKey
  29668. struct3501.ManuDate = "2022-08-15"
  29669. struct3501.FixmedinsBchno = ""
  29670. struct3501.ManuLotnum = ""
  29671. struct3501.RxFlag = "0"
  29672. struct3501.ExpyEnd = "2022-08-15"
  29673. struct3501.Invdate = "2022-08-15"
  29674. struct3501.InvCnt = "20.25"
  29675. struct3501.Memo = ""
  29676. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29677. struct3501.FixmedinsHilistId = miConfig.Code
  29678. struct3501.FixmedinsHilistName = miConfig.OrgName
  29679. struct3501s = append(struct3501s, struct3501)
  29680. data["struct_3501s"] = struct3501s
  29681. client := &http.Client{}
  29682. bytesData, _ := json.Marshal(data)
  29683. var req *http.Request
  29684. if miConfig.MdtrtareaAdmvs == "320921" {
  29685. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29686. } else {
  29687. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29688. }
  29689. resp, _ := client.Do(req)
  29690. defer resp.Body.Close()
  29691. body, ioErr := ioutil.ReadAll(resp.Body)
  29692. if ioErr != nil {
  29693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29695. return
  29696. }
  29697. var respJSON map[string]interface{}
  29698. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29701. return
  29702. }
  29703. var res ResultSix
  29704. var resSix10265 ResultSix10265 //1101结果
  29705. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29706. result, _ := json.Marshal(respJSON)
  29707. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29708. utils.ErrorLog("解析失败:%v", err)
  29709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29710. return
  29711. }
  29712. res.InfRefmsgid = resSix10265.InfRefmsgid
  29713. res.Output = resSix10265.Output
  29714. res.ErrMsg = resSix10265.ErrMsg
  29715. res.Cainfo = resSix10265.Cainfo
  29716. res.WarnMsg = resSix10265.WarnMsg
  29717. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29718. res.Infcode = infocode
  29719. if infocode == 0 {
  29720. c.ServeSuccessJSON(map[string]interface{}{
  29721. "msg": "上传成功",
  29722. })
  29723. return
  29724. } else {
  29725. c.ServeSuccessJSON(map[string]interface{}{
  29726. "failed_code": -10,
  29727. "msg": res.ErrMsg,
  29728. })
  29729. return
  29730. }
  29731. }
  29732. func (c *HisApiController) Post3504() {
  29733. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29734. data := make(map[string]interface{})
  29735. var struct3501s []models.Struct3501
  29736. var struct3501 models.Struct3501
  29737. struct3501.OrgName = miConfig.OrgName
  29738. struct3501.AccessKey = miConfig.AccessKey
  29739. struct3501.RequestUrl = miConfig.Url
  29740. struct3501.SecretKey = miConfig.SecretKey
  29741. struct3501.ManuDate = "2022-08-15"
  29742. struct3501.FixmedinsBchno = ""
  29743. struct3501.ManuLotnum = ""
  29744. struct3501.RxFlag = "0"
  29745. struct3501.ExpyEnd = "2022-08-15"
  29746. struct3501.Invdate = "2022-08-15"
  29747. struct3501.InvCnt = "20.25"
  29748. struct3501.Memo = ""
  29749. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29750. struct3501.FixmedinsHilistId = miConfig.Code
  29751. struct3501.FixmedinsHilistName = miConfig.OrgName
  29752. struct3501s = append(struct3501s, struct3501)
  29753. data["struct_3501s"] = struct3501s
  29754. client := &http.Client{}
  29755. bytesData, _ := json.Marshal(data)
  29756. var req *http.Request
  29757. if miConfig.MdtrtareaAdmvs == "320921" {
  29758. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29759. } else {
  29760. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29761. }
  29762. resp, _ := client.Do(req)
  29763. defer resp.Body.Close()
  29764. body, ioErr := ioutil.ReadAll(resp.Body)
  29765. if ioErr != nil {
  29766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29768. return
  29769. }
  29770. var respJSON map[string]interface{}
  29771. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29774. return
  29775. }
  29776. var res ResultSix
  29777. var resSix10265 ResultSix10265 //1101结果
  29778. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29779. result, _ := json.Marshal(respJSON)
  29780. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29781. utils.ErrorLog("解析失败:%v", err)
  29782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29783. return
  29784. }
  29785. res.InfRefmsgid = resSix10265.InfRefmsgid
  29786. res.Output = resSix10265.Output
  29787. res.ErrMsg = resSix10265.ErrMsg
  29788. res.Cainfo = resSix10265.Cainfo
  29789. res.WarnMsg = resSix10265.WarnMsg
  29790. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29791. res.Infcode = infocode
  29792. if infocode == 0 {
  29793. c.ServeSuccessJSON(map[string]interface{}{
  29794. "msg": "上传成功",
  29795. })
  29796. return
  29797. } else {
  29798. c.ServeSuccessJSON(map[string]interface{}{
  29799. "failed_code": -10,
  29800. "msg": res.ErrMsg,
  29801. })
  29802. return
  29803. }
  29804. }
  29805. func (c *HisApiController) Post3505() {
  29806. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29807. data := make(map[string]interface{})
  29808. var struct3501s []models.Struct3501
  29809. var struct3501 models.Struct3501
  29810. struct3501.OrgName = miConfig.OrgName
  29811. struct3501.AccessKey = miConfig.AccessKey
  29812. struct3501.RequestUrl = miConfig.Url
  29813. struct3501.SecretKey = miConfig.SecretKey
  29814. struct3501.ManuDate = "2022-08-15"
  29815. struct3501.FixmedinsBchno = ""
  29816. struct3501.ManuLotnum = ""
  29817. struct3501.RxFlag = "0"
  29818. struct3501.ExpyEnd = "2022-08-15"
  29819. struct3501.Invdate = "2022-08-15"
  29820. struct3501.InvCnt = "20.25"
  29821. struct3501.Memo = ""
  29822. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29823. struct3501.FixmedinsHilistId = miConfig.Code
  29824. struct3501.FixmedinsHilistName = miConfig.OrgName
  29825. struct3501s = append(struct3501s, struct3501)
  29826. data["struct_3501s"] = struct3501s
  29827. client := &http.Client{}
  29828. bytesData, _ := json.Marshal(data)
  29829. var req *http.Request
  29830. if miConfig.MdtrtareaAdmvs == "320921" {
  29831. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29832. } else {
  29833. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29834. }
  29835. resp, _ := client.Do(req)
  29836. defer resp.Body.Close()
  29837. body, ioErr := ioutil.ReadAll(resp.Body)
  29838. if ioErr != nil {
  29839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29841. return
  29842. }
  29843. var respJSON map[string]interface{}
  29844. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29847. return
  29848. }
  29849. var res ResultSix
  29850. var resSix10265 ResultSix10265 //1101结果
  29851. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29852. result, _ := json.Marshal(respJSON)
  29853. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29854. utils.ErrorLog("解析失败:%v", err)
  29855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29856. return
  29857. }
  29858. res.InfRefmsgid = resSix10265.InfRefmsgid
  29859. res.Output = resSix10265.Output
  29860. res.ErrMsg = resSix10265.ErrMsg
  29861. res.Cainfo = resSix10265.Cainfo
  29862. res.WarnMsg = resSix10265.WarnMsg
  29863. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29864. res.Infcode = infocode
  29865. if infocode == 0 {
  29866. c.ServeSuccessJSON(map[string]interface{}{
  29867. "msg": "上传成功",
  29868. })
  29869. return
  29870. } else {
  29871. c.ServeSuccessJSON(map[string]interface{}{
  29872. "failed_code": -10,
  29873. "msg": res.ErrMsg,
  29874. })
  29875. return
  29876. }
  29877. }
  29878. func (c *HisApiController) Post3506() {
  29879. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29880. data := make(map[string]interface{})
  29881. var struct3501s []models.Struct3501
  29882. var struct3501 models.Struct3501
  29883. struct3501.OrgName = miConfig.OrgName
  29884. struct3501.AccessKey = miConfig.AccessKey
  29885. struct3501.RequestUrl = miConfig.Url
  29886. struct3501.SecretKey = miConfig.SecretKey
  29887. struct3501.ManuDate = "2022-08-15"
  29888. struct3501.FixmedinsBchno = ""
  29889. struct3501.ManuLotnum = ""
  29890. struct3501.RxFlag = "0"
  29891. struct3501.ExpyEnd = "2022-08-15"
  29892. struct3501.Invdate = "2022-08-15"
  29893. struct3501.InvCnt = "20.25"
  29894. struct3501.Memo = ""
  29895. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29896. struct3501.FixmedinsHilistId = miConfig.Code
  29897. struct3501.FixmedinsHilistName = miConfig.OrgName
  29898. struct3501s = append(struct3501s, struct3501)
  29899. data["struct_3501s"] = struct3501s
  29900. client := &http.Client{}
  29901. bytesData, _ := json.Marshal(data)
  29902. var req *http.Request
  29903. if miConfig.MdtrtareaAdmvs == "320921" {
  29904. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29905. } else {
  29906. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29907. }
  29908. resp, _ := client.Do(req)
  29909. defer resp.Body.Close()
  29910. body, ioErr := ioutil.ReadAll(resp.Body)
  29911. if ioErr != nil {
  29912. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29914. return
  29915. }
  29916. var respJSON map[string]interface{}
  29917. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29918. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29920. return
  29921. }
  29922. var res ResultSix
  29923. var resSix10265 ResultSix10265 //1101结果
  29924. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29925. result, _ := json.Marshal(respJSON)
  29926. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29927. utils.ErrorLog("解析失败:%v", err)
  29928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29929. return
  29930. }
  29931. res.InfRefmsgid = resSix10265.InfRefmsgid
  29932. res.Output = resSix10265.Output
  29933. res.ErrMsg = resSix10265.ErrMsg
  29934. res.Cainfo = resSix10265.Cainfo
  29935. res.WarnMsg = resSix10265.WarnMsg
  29936. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29937. res.Infcode = infocode
  29938. if infocode == 0 {
  29939. c.ServeSuccessJSON(map[string]interface{}{
  29940. "msg": "上传成功",
  29941. })
  29942. return
  29943. } else {
  29944. c.ServeSuccessJSON(map[string]interface{}{
  29945. "failed_code": -10,
  29946. "msg": res.ErrMsg,
  29947. })
  29948. return
  29949. }
  29950. }
  29951. func (c *HisApiController) Post3507() {
  29952. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29953. data := make(map[string]interface{})
  29954. var struct3501s []models.Struct3501
  29955. var struct3501 models.Struct3501
  29956. struct3501.OrgName = miConfig.OrgName
  29957. struct3501.AccessKey = miConfig.AccessKey
  29958. struct3501.RequestUrl = miConfig.Url
  29959. struct3501.SecretKey = miConfig.SecretKey
  29960. struct3501.ManuDate = "2022-08-15"
  29961. struct3501.FixmedinsBchno = ""
  29962. struct3501.ManuLotnum = ""
  29963. struct3501.RxFlag = "0"
  29964. struct3501.ExpyEnd = "2022-08-15"
  29965. struct3501.Invdate = "2022-08-15"
  29966. struct3501.InvCnt = "20.25"
  29967. struct3501.Memo = ""
  29968. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29969. struct3501.FixmedinsHilistId = miConfig.Code
  29970. struct3501.FixmedinsHilistName = miConfig.OrgName
  29971. struct3501s = append(struct3501s, struct3501)
  29972. data["struct_3501s"] = struct3501s
  29973. client := &http.Client{}
  29974. bytesData, _ := json.Marshal(data)
  29975. var req *http.Request
  29976. if miConfig.MdtrtareaAdmvs == "320921" {
  29977. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29978. } else {
  29979. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29980. }
  29981. resp, _ := client.Do(req)
  29982. defer resp.Body.Close()
  29983. body, ioErr := ioutil.ReadAll(resp.Body)
  29984. if ioErr != nil {
  29985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29987. return
  29988. }
  29989. var respJSON map[string]interface{}
  29990. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29993. return
  29994. }
  29995. var res ResultSix
  29996. var resSix10265 ResultSix10265 //1101结果
  29997. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29998. result, _ := json.Marshal(respJSON)
  29999. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30000. utils.ErrorLog("解析失败:%v", err)
  30001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30002. return
  30003. }
  30004. res.InfRefmsgid = resSix10265.InfRefmsgid
  30005. res.Output = resSix10265.Output
  30006. res.ErrMsg = resSix10265.ErrMsg
  30007. res.Cainfo = resSix10265.Cainfo
  30008. res.WarnMsg = resSix10265.WarnMsg
  30009. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30010. res.Infcode = infocode
  30011. if infocode == 0 {
  30012. c.ServeSuccessJSON(map[string]interface{}{
  30013. "msg": "上传成功",
  30014. })
  30015. return
  30016. } else {
  30017. c.ServeSuccessJSON(map[string]interface{}{
  30018. "failed_code": -10,
  30019. "msg": res.ErrMsg,
  30020. })
  30021. return
  30022. }
  30023. }
  30024. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30025. // WebSocket服务器地址
  30026. serverURL := "ws://127.0.0.1:8899"
  30027. // 解析WebSocket服务器地址
  30028. u, err := url.Parse(serverURL)
  30029. if err != nil {
  30030. }
  30031. // 建立WebSocket连接
  30032. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30033. if err != nil {
  30034. }
  30035. defer conn.Close()
  30036. input2 := make(map[string]interface{})
  30037. input := make(map[string]interface{})
  30038. inputData := make(map[string]interface{})
  30039. inputData["orgId"] = code
  30040. inputData["businessType"] = "01101"
  30041. inputData["operatorId"] = operator_id
  30042. inputData["operatorName"] = operator_name
  30043. inputData["officeId"] = "001"
  30044. inputData["officeName"] = "血透室"
  30045. inputData["deviceType"] = ""
  30046. input["data"] = inputData
  30047. input["orgId"] = code
  30048. input["transType"] = "ec.query"
  30049. //if md == ""
  30050. if md[:4] == "4403" {
  30051. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30052. } else if md[:4] == "4401" {
  30053. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30054. } else {
  30055. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30056. }
  30057. input2["indata"] = input
  30058. fmt.Println(input2)
  30059. bytesData, _ := json.Marshal(input2)
  30060. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30061. if err != nil {
  30062. fmt.Println(err)
  30063. }
  30064. // 接收消息
  30065. _, receivedMessage, err := conn.ReadMessage()
  30066. if err != nil {
  30067. fmt.Println(err)
  30068. }
  30069. return "", string(receivedMessage)
  30070. }
  30071. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30072. // WebSocket服务器地址
  30073. serverURL := "ws://127.0.0.1:8899"
  30074. // 解析WebSocket服务器地址
  30075. u, err := url.Parse(serverURL)
  30076. if err != nil {
  30077. }
  30078. // 建立WebSocket连接
  30079. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30080. if err != nil {
  30081. }
  30082. defer conn.Close()
  30083. input2 := make(map[string]interface{})
  30084. input := make(map[string]interface{})
  30085. inputData := make(map[string]interface{})
  30086. inputData["orgId"] = code
  30087. inputData["businessType"] = "01103"
  30088. inputData["operatorId"] = operator_id
  30089. inputData["operatorName"] = operator_name
  30090. inputData["officeId"] = "001"
  30091. inputData["officeName"] = "血透室"
  30092. inputData["deviceType"] = ""
  30093. input["data"] = inputData
  30094. input["orgId"] = code
  30095. input["transType"] = "ec.query"
  30096. //if md ==
  30097. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30098. input2["indata"] = input
  30099. fmt.Println(input2)
  30100. bytesData, _ := json.Marshal(input2)
  30101. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30102. if err != nil {
  30103. fmt.Println(err)
  30104. }
  30105. // 接收消息
  30106. _, receivedMessage, err := conn.ReadMessage()
  30107. if err != nil {
  30108. fmt.Println(err)
  30109. }
  30110. return "", string(receivedMessage)
  30111. }
  30112. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30113. // WebSocket服务器地址
  30114. serverURL := "ws://127.0.0.1:8899"
  30115. // 解析WebSocket服务器地址
  30116. u, err := url.Parse(serverURL)
  30117. if err != nil {
  30118. }
  30119. // 建立WebSocket连接
  30120. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30121. if err != nil {
  30122. }
  30123. defer conn.Close()
  30124. input2 := make(map[string]interface{})
  30125. input := make(map[string]interface{})
  30126. inputData := make(map[string]interface{})
  30127. inputData["orgId"] = code
  30128. inputData["businessType"] = "01101"
  30129. inputData["operatorId"] = operator_id
  30130. inputData["operatorName"] = operator_name
  30131. inputData["officeId"] = "001"
  30132. inputData["officeName"] = "血透室"
  30133. inputData["deviceType"] = ""
  30134. input["data"] = inputData
  30135. input["orgId"] = code
  30136. input["transType"] = "ec.query"
  30137. //if md == ""
  30138. if md[:4] == "4403" {
  30139. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30140. } else if md[:4] == "4401" {
  30141. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30142. } else {
  30143. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30144. }
  30145. input2["indata"] = input
  30146. fmt.Println(input2)
  30147. bytesData, _ := json.Marshal(input2)
  30148. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30149. if err != nil {
  30150. fmt.Println(err)
  30151. }
  30152. // 接收消息
  30153. _, receivedMessage, err := conn.ReadMessage()
  30154. if err != nil {
  30155. fmt.Println(err)
  30156. }
  30157. return "", string(receivedMessage)
  30158. }
  30159. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  30160. // WebSocket服务器地址
  30161. serverURL := "ws://127.0.0.1:8899"
  30162. // 解析WebSocket服务器地址
  30163. u, err := url.Parse(serverURL)
  30164. if err != nil {
  30165. }
  30166. // 建立WebSocket连接
  30167. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30168. if err != nil {
  30169. }
  30170. defer conn.Close()
  30171. input2 := make(map[string]interface{})
  30172. input := make(map[string]interface{})
  30173. inputData := make(map[string]interface{})
  30174. inputData["orgId"] = code
  30175. inputData["businessType"] = "01301"
  30176. inputData["operatorId"] = operator_id
  30177. inputData["operatorName"] = operator_name
  30178. inputData["officeId"] = "001"
  30179. inputData["officeName"] = "血透室"
  30180. inputData["deviceType"] = ""
  30181. input["data"] = inputData
  30182. input["orgId"] = code
  30183. input["transType"] = "ec.query"
  30184. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30185. input2["indata"] = input
  30186. bytesData, _ := json.Marshal(input2)
  30187. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30188. if err != nil {
  30189. fmt.Println(err)
  30190. }
  30191. // 接收消息
  30192. _, receivedMessage, err := conn.ReadMessage()
  30193. if err != nil {
  30194. fmt.Println(err)
  30195. }
  30196. return "", string(receivedMessage)
  30197. }
  30198. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  30199. newArr = make([]string, 0)
  30200. for i := 0; i < len(arr); i++ {
  30201. repeat := false
  30202. for j := i + 1; j < len(arr); j++ {
  30203. if arr[i] == arr[j] {
  30204. repeat = true
  30205. break
  30206. }
  30207. }
  30208. if !repeat {
  30209. newArr = append(newArr, arr[i])
  30210. }
  30211. }
  30212. return
  30213. }
  30214. func getBirthdateAndAge(idNumber string) (string, int, error) {
  30215. if len(idNumber) != 18 {
  30216. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  30217. }
  30218. // 提取出生日期
  30219. year, err := strconv.Atoi(idNumber[6:10])
  30220. if err != nil {
  30221. return "", 0, err
  30222. }
  30223. month, err := strconv.Atoi(idNumber[10:12])
  30224. if err != nil {
  30225. return "", 0, err
  30226. }
  30227. day, err := strconv.Atoi(idNumber[12:14])
  30228. if err != nil {
  30229. return "", 0, err
  30230. }
  30231. // 格式化生日字符串
  30232. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  30233. birthdateFormatted := birthdate.Format("2006-01-02")
  30234. // 计算年龄
  30235. today := time.Now()
  30236. age := today.Year() - birthdate.Year()
  30237. if today.YearDay() < birthdate.YearDay() {
  30238. age--
  30239. }
  30240. return birthdateFormatted, age, nil
  30241. }