his_api_controller.go 1.3MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606
  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.GetP(id)
  6970. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6971. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  6972. //
  6973. //if psn_record.ID == 0 {
  6974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6975. // return
  6976. //}
  6977. var res Result5301
  6978. var res10265 Result5301For10265
  6979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6980. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6981. var api string
  6982. if miConfig.MdtrtareaAdmvs == "320921" {
  6983. 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 +
  6984. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6985. } else {
  6986. 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 +
  6987. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6988. }
  6989. resp, requestErr := http.Get(api)
  6990. if requestErr != nil {
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. body, ioErr := ioutil.ReadAll(resp.Body)
  6995. if ioErr != nil {
  6996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6998. return
  6999. }
  7000. var respJSON map[string]interface{}
  7001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7004. return
  7005. }
  7006. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7007. result, _ := json.Marshal(respJSON)
  7008. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7009. utils.ErrorLog("解析失败:%v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. res.ErrMsg = res10265.ErrMsg
  7014. res.Output = res10265.Output
  7015. res.InfRefmsgid = res10265.InfRefmsgid
  7016. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7017. res.Infcode = infocode
  7018. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7019. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7020. var api string
  7021. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7022. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7023. resp, requestErr := http.Get(api)
  7024. if requestErr != nil {
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. return
  7027. }
  7028. body, ioErr := ioutil.ReadAll(resp.Body)
  7029. if ioErr != nil {
  7030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. var respJSON map[string]interface{}
  7035. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7041. if status == "0" {
  7042. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7043. c.ServeSuccessJSON(map[string]interface{}{
  7044. "failed_code": -10,
  7045. "msg": err_msg,
  7046. })
  7047. return
  7048. }
  7049. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7050. result, _ := json.Marshal(respJSON)
  7051. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7052. utils.ErrorLog("解析失败:%v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7057. p, _ := service.GetHisPatientById(patient_id)
  7058. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7059. var dat map[string]interface{}
  7060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7061. fmt.Println(dat)
  7062. } else {
  7063. fmt.Println(err)
  7064. }
  7065. userJSONBytes, _ := json.Marshal(dat)
  7066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7067. utils.ErrorLog("解析失败:%v", err)
  7068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7069. return
  7070. }
  7071. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7072. p, _ := service.GetHisPatientById(patient_id)
  7073. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7074. var dat map[string]interface{}
  7075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7076. fmt.Println(dat)
  7077. } else {
  7078. fmt.Println(err)
  7079. }
  7080. userJSONBytes, _ := json.Marshal(dat)
  7081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7082. utils.ErrorLog("解析失败:%v", err)
  7083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7084. return
  7085. }
  7086. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7087. p, _ := service.GetHisPatientById(patient_id)
  7088. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7089. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7090. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7091. resp, requestErr := http.Get(api)
  7092. if requestErr != nil {
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. body, ioErr := ioutil.ReadAll(resp.Body)
  7097. if ioErr != nil {
  7098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. return
  7101. }
  7102. var respJSON map[string]interface{}
  7103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7106. return
  7107. }
  7108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7109. result, _ := json.Marshal(respJSON)
  7110. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7111. utils.ErrorLog("解析失败:%v", err)
  7112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7113. return
  7114. }
  7115. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7116. p, _ := service.GetHisPatientById(patient_id)
  7117. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7118. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7119. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7120. resp, requestErr := http.Get(api)
  7121. if requestErr != nil {
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. return
  7124. }
  7125. body, ioErr := ioutil.ReadAll(resp.Body)
  7126. if ioErr != nil {
  7127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. return
  7130. }
  7131. var respJSON map[string]interface{}
  7132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7135. return
  7136. }
  7137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7138. result, _ := json.Marshal(respJSON)
  7139. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7140. utils.ErrorLog("解析失败:%v", err)
  7141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7142. return
  7143. }
  7144. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7145. p, _ := service.GetHisPatientById(patient_id)
  7146. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7147. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7148. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7149. resp, requestErr := http.Get(api)
  7150. if requestErr != nil {
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. body, ioErr := ioutil.ReadAll(resp.Body)
  7155. if ioErr != nil {
  7156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. var respJSON map[string]interface{}
  7161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7164. return
  7165. }
  7166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7167. result, _ := json.Marshal(respJSON)
  7168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7169. utils.ErrorLog("解析失败:%v", err)
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7174. p, _ := service.GetHisPatientById(patient_id)
  7175. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7176. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7177. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7178. resp, requestErr := http.Get(api)
  7179. if requestErr != nil {
  7180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7181. return
  7182. }
  7183. body, ioErr := ioutil.ReadAll(resp.Body)
  7184. if ioErr != nil {
  7185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. return
  7188. }
  7189. var respJSON map[string]interface{}
  7190. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7193. return
  7194. }
  7195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7196. result, _ := json.Marshal(respJSON)
  7197. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7198. utils.ErrorLog("解析失败:%v", err)
  7199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7200. return
  7201. }
  7202. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7203. p, _ := service.GetHisPatientById(patient_id)
  7204. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7205. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7206. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7207. resp, requestErr := http.Get(api)
  7208. if requestErr != nil {
  7209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7210. return
  7211. }
  7212. body, ioErr := ioutil.ReadAll(resp.Body)
  7213. if ioErr != nil {
  7214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7216. return
  7217. }
  7218. var respJSON map[string]interface{}
  7219. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7222. return
  7223. }
  7224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7225. result, _ := json.Marshal(respJSON)
  7226. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7227. utils.ErrorLog("解析失败:%v", err)
  7228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7229. return
  7230. }
  7231. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7232. p, _ := service.GetHisPatientById(patient_id)
  7233. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7234. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7235. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7236. resp, requestErr := http.Get(api)
  7237. if requestErr != nil {
  7238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7239. return
  7240. }
  7241. body, ioErr := ioutil.ReadAll(resp.Body)
  7242. if ioErr != nil {
  7243. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. return
  7246. }
  7247. var respJSON map[string]interface{}
  7248. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7249. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return
  7252. }
  7253. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7254. result, _ := json.Marshal(respJSON)
  7255. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7256. utils.ErrorLog("解析失败:%v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. } else {
  7261. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7262. var dat map[string]interface{}
  7263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7264. fmt.Println(dat)
  7265. } else {
  7266. fmt.Println(err)
  7267. }
  7268. userJSONBytes, _ := json.Marshal(dat)
  7269. if miConfig.Code == "H15049901371" {
  7270. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7271. utils.ErrorLog("解析失败:%v", err)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. res.InfRefmsgid = res10265.InfRefmsgid
  7276. res.Output = res10265.Output
  7277. res.ErrMsg = res10265.ErrMsg
  7278. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7279. res.Infcode = infocode
  7280. } else {
  7281. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7282. utils.ErrorLog("解析失败:%v", err)
  7283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7284. return
  7285. }
  7286. }
  7287. }
  7288. if res.Infcode == 0 {
  7289. c.ServeSuccessJSON(map[string]interface{}{
  7290. "result": res.Output.Result,
  7291. })
  7292. }
  7293. }
  7294. func (c *HisApiController) CheckInsutype() {
  7295. his_patient_id, _ := c.GetInt64("his_patient_id")
  7296. admin_user_id, _ := c.GetInt64("admin_user_id")
  7297. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7298. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7300. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7301. var dat map[string]interface{}
  7302. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7303. fmt.Println(dat)
  7304. } else {
  7305. fmt.Println(err)
  7306. }
  7307. userJSONBytes, _ := json.Marshal(dat)
  7308. var res Result90100
  7309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7310. utils.ErrorLog("解析失败:%v", err)
  7311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7312. return
  7313. }
  7314. if res.Infcode != 0 {
  7315. c.ServeSuccessJSON(map[string]interface{}{
  7316. "failed_code": -10,
  7317. "msg": res.ErrMsg,
  7318. })
  7319. return
  7320. } else {
  7321. fmt.Println(res)
  7322. }
  7323. }
  7324. func (c *HisApiController) CheckCardPWD() {
  7325. card_pwd := c.GetString("card_pwd")
  7326. his_patient_id, _ := c.GetInt64("his_patient_id")
  7327. admin_user_id, _ := c.GetInt64("admin_user_id")
  7328. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7329. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7330. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7331. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7332. bas := strings.Split(psn.CardInfo, "|")
  7333. basNumber := bas[2]
  7334. if psn.InsuplcAdmdvs[:4] == "4403" {
  7335. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7336. var dat map[string]interface{}
  7337. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7338. fmt.Println(dat)
  7339. } else {
  7340. fmt.Println(err)
  7341. }
  7342. userJSONBytes, _ := json.Marshal(dat)
  7343. var res Result90991
  7344. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7345. utils.ErrorLog("解析失败:%v", err)
  7346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7347. return
  7348. }
  7349. if res.Infcode != 0 {
  7350. c.ServeSuccessJSON(map[string]interface{}{
  7351. "failed_code": -10,
  7352. "msg": res.ErrMsg,
  7353. })
  7354. return
  7355. } else {
  7356. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7357. var msg string
  7358. switch res.Output.Result.CardStat {
  7359. case "00":
  7360. msg = "未激活"
  7361. break
  7362. case "10":
  7363. msg = "激活"
  7364. break
  7365. case "20":
  7366. msg = "窗口挂失"
  7367. break
  7368. case "21":
  7369. msg = "电话挂失"
  7370. break
  7371. case "22":
  7372. msg = "单位网上申报挂失"
  7373. break
  7374. case "23":
  7375. msg = "保健办挂失"
  7376. break
  7377. case "24":
  7378. msg = "个人网上挂失"
  7379. break
  7380. case "25":
  7381. msg = "网上服务大厅挂失"
  7382. break
  7383. case "30":
  7384. msg = "注销"
  7385. break
  7386. case "40":
  7387. msg = "回收"
  7388. break
  7389. case "99":
  7390. msg = "制卡中(无效卡)"
  7391. break
  7392. }
  7393. c.ServeSuccessJSON(map[string]interface{}{
  7394. "failed_code": -10,
  7395. "msg": msg,
  7396. })
  7397. return
  7398. } else {
  7399. c.ServeSuccessJSON(map[string]interface{}{
  7400. "msg": "校验成功",
  7401. })
  7402. return
  7403. }
  7404. }
  7405. } else {
  7406. c.ServeSuccessJSON(map[string]interface{}{
  7407. "msg": "校验成功",
  7408. })
  7409. return
  7410. }
  7411. }
  7412. func (c *HisApiController) CheckCardPWDTwo() {
  7413. //card_pwd := c.GetString("card_pwd")
  7414. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7415. admin_user_id, _ := c.GetInt64("admin_user_id")
  7416. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7417. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7418. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7419. var dat map[string]interface{}
  7420. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7421. fmt.Println(dat)
  7422. } else {
  7423. fmt.Println(err)
  7424. }
  7425. userJSONBytes, _ := json.Marshal(dat)
  7426. var res Result90991
  7427. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7428. utils.ErrorLog("解析失败:%v", err)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. if res.Infcode != 0 {
  7433. c.ServeSuccessJSON(map[string]interface{}{
  7434. "failed_code": -10,
  7435. "msg": res.ErrMsg,
  7436. })
  7437. return
  7438. } else {
  7439. if res.Output.Result.SscnoCheckStat == "0" {
  7440. var msg string
  7441. switch res.Output.Result.CardStat {
  7442. case "00":
  7443. msg = "未激活"
  7444. break
  7445. case "10":
  7446. msg = "激活"
  7447. break
  7448. case "20":
  7449. msg = "窗口挂失"
  7450. break
  7451. case "21":
  7452. msg = "电话挂失"
  7453. break
  7454. case "22":
  7455. msg = "单位网上申报挂失"
  7456. break
  7457. case "23":
  7458. msg = "保健办挂失"
  7459. break
  7460. case "24":
  7461. msg = "个人网上挂失"
  7462. break
  7463. case "25":
  7464. msg = "网上服务大厅挂失"
  7465. break
  7466. case "30":
  7467. msg = "注销"
  7468. break
  7469. case "40":
  7470. msg = "回收"
  7471. break
  7472. case "99":
  7473. msg = "制卡中(无效卡)"
  7474. break
  7475. }
  7476. c.ServeSuccessJSON(map[string]interface{}{
  7477. "failed_code": -10,
  7478. "msg": msg,
  7479. })
  7480. return
  7481. } else {
  7482. c.ServeSuccessJSON(map[string]interface{}{
  7483. "msg": "校验成功",
  7484. })
  7485. return
  7486. }
  7487. }
  7488. }
  7489. type ELeCertData struct {
  7490. Data struct {
  7491. Extra string `json:"extra"`
  7492. IDNo string `json:"idNo"`
  7493. IDType string `json:"idType"`
  7494. EcToken string `json:"ecToken"`
  7495. InsuOrg string `json:"insuOrg"`
  7496. UserName string `json:"userName"`
  7497. EcIndexNo string `json:"ecIndexNo"`
  7498. Gender string `json:"gender"`
  7499. Birthday string `json:"birthday"`
  7500. Nationality string `json:"nationality"`
  7501. Email string `json:"email"`
  7502. } `json:"OutData"`
  7503. }
  7504. func (c *HisApiController) ReadCard() {
  7505. id_card_type, _ := c.GetInt64("id_card_type")
  7506. admin_user_id, _ := c.GetInt64("admin_user_id")
  7507. certificates, _ := c.GetInt64("certificates")
  7508. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7509. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7510. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7511. switch id_card_type {
  7512. case 1:
  7513. if miConfig.MdtrtareaAdmvs == "421300" {
  7514. var res ResultTwo
  7515. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7516. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7517. "&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)
  7518. resp, requestErr := http.Get(api)
  7519. if requestErr != nil {
  7520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7521. return
  7522. }
  7523. body, ioErr := ioutil.ReadAll(resp.Body)
  7524. if ioErr != nil {
  7525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7527. return
  7528. }
  7529. var respJSON map[string]interface{}
  7530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. return
  7534. }
  7535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7536. result, _ := json.Marshal(respJSON)
  7537. fmt.Println("log")
  7538. fmt.Println(string(result))
  7539. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7540. utils.ErrorLog("解析失败:%v", err)
  7541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7542. return
  7543. }
  7544. if res.Infcode == 0 {
  7545. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7546. if err == gorm.ErrRecordNotFound {
  7547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7548. return
  7549. } else if err != nil {
  7550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7551. return
  7552. } else {
  7553. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7554. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7555. infoStr := string(Iinfos)
  7556. idetinfoStr := string(Idetinfos)
  7557. var rf []*ResultFive
  7558. json.Unmarshal([]byte(infoStr), &rf)
  7559. var insutypes []*ResultFive
  7560. var insutype string
  7561. var is390 int = 0
  7562. var is310 int = 0
  7563. for _, item := range rf {
  7564. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7565. insutypes = append(insutypes, item)
  7566. }
  7567. }
  7568. if len(insutypes) == 1 {
  7569. insutype = insutypes[0].Insutype
  7570. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7571. } else {
  7572. for _, i := range insutypes {
  7573. if i.Insutype == "390" {
  7574. is390 = 1
  7575. }
  7576. if i.Insutype == "310" {
  7577. is310 = 1
  7578. }
  7579. }
  7580. }
  7581. if is390 == 1 {
  7582. insutype = "390"
  7583. }
  7584. if is310 == 1 {
  7585. insutype = "310"
  7586. }
  7587. if len(insutypes) == 0 {
  7588. insutype = "390"
  7589. }
  7590. var insuplc_admdvs string
  7591. for _, item := range rf {
  7592. if item.Insutype == insutype {
  7593. insuplc_admdvs = item.InsuplcAdmdvs
  7594. }
  7595. }
  7596. if strings.Contains(insuplc_admdvs, "4213") {
  7597. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7598. }
  7599. psn := &models.HisPsn{
  7600. PsnNo: res.Output.Baseinfo.PsnNo,
  7601. PatientId: patient.ID,
  7602. Certno: res.Output.Baseinfo.Certno,
  7603. Gend: res.Output.Baseinfo.Gend,
  7604. Naty: res.Output.Baseinfo.Naty,
  7605. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7606. PsnName: res.Output.Baseinfo.PsnName,
  7607. Idetinfo: idetinfoStr,
  7608. Insuinfo: infoStr,
  7609. InsuplcAdmdvs: insuplc_admdvs,
  7610. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7611. }
  7612. service.CreateHisPsn(psn)
  7613. c.ServeSuccessJSON(map[string]interface{}{
  7614. "patient": patient,
  7615. "number": res.Output.Baseinfo.Certno,
  7616. })
  7617. }
  7618. } else {
  7619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7620. return
  7621. }
  7622. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7623. var res ResultTwo
  7624. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7625. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7626. "&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)
  7627. resp, requestErr := http.Get(api)
  7628. if requestErr != nil {
  7629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7630. return
  7631. }
  7632. body, ioErr := ioutil.ReadAll(resp.Body)
  7633. if ioErr != nil {
  7634. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7636. return
  7637. }
  7638. var respJSON map[string]interface{}
  7639. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7640. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7642. return
  7643. }
  7644. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7645. result, _ := json.Marshal(respJSON)
  7646. fmt.Println("log")
  7647. fmt.Println(string(result))
  7648. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7649. utils.ErrorLog("解析失败:%v", err)
  7650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7651. return
  7652. }
  7653. if res.Infcode == 0 {
  7654. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7655. if err == gorm.ErrRecordNotFound {
  7656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7657. return
  7658. } else if err != nil {
  7659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7660. return
  7661. } else {
  7662. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7663. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7664. infoStr := string(Iinfos)
  7665. idetinfoStr := string(Idetinfos)
  7666. psn := &models.HisPsn{
  7667. PsnNo: res.Output.Baseinfo.PsnNo,
  7668. PatientId: patient.ID,
  7669. Certno: res.Output.Baseinfo.Certno,
  7670. Gend: res.Output.Baseinfo.Gend,
  7671. Naty: res.Output.Baseinfo.Naty,
  7672. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7673. PsnName: res.Output.Baseinfo.PsnName,
  7674. Idetinfo: idetinfoStr,
  7675. Insuinfo: infoStr,
  7676. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7677. }
  7678. service.CreateHisPsn(psn)
  7679. var rf []*ResultFive
  7680. json.Unmarshal([]byte(infoStr), &rf)
  7681. var insutypes []*ResultFive
  7682. var insutype string
  7683. var is390 int = 0
  7684. var is310 int = 0
  7685. for _, item := range rf {
  7686. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7687. insutypes = append(insutypes, item)
  7688. }
  7689. }
  7690. if len(insutypes) == 1 {
  7691. insutype = insutypes[0].Insutype
  7692. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7693. } else {
  7694. for _, i := range insutypes {
  7695. if i.Insutype == "390" {
  7696. is390 = 1
  7697. }
  7698. if i.Insutype == "310" {
  7699. is310 = 1
  7700. }
  7701. }
  7702. }
  7703. if is390 == 1 {
  7704. insutype = "390"
  7705. }
  7706. if is310 == 1 {
  7707. insutype = "310"
  7708. }
  7709. if len(insutypes) == 0 {
  7710. insutype = "310"
  7711. }
  7712. c.ServeSuccessJSON(map[string]interface{}{
  7713. "patient": patient,
  7714. "number": res.Output.Baseinfo.Certno,
  7715. "insutype": insutype,
  7716. })
  7717. }
  7718. } else {
  7719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7720. return
  7721. }
  7722. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7723. var res ResultTwo
  7724. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7725. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7726. "&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)
  7727. resp, requestErr := http.Get(api)
  7728. if requestErr != nil {
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. body, ioErr := ioutil.ReadAll(resp.Body)
  7733. if ioErr != nil {
  7734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7736. return
  7737. }
  7738. var respJSON map[string]interface{}
  7739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7742. return
  7743. }
  7744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7745. result, _ := json.Marshal(respJSON)
  7746. fmt.Println("log")
  7747. fmt.Println(string(result))
  7748. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7749. utils.ErrorLog("解析失败:%v", err)
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. if res.Infcode == 0 {
  7754. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7755. if err == gorm.ErrRecordNotFound {
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7757. return
  7758. } else if err != nil {
  7759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7760. return
  7761. } else {
  7762. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7763. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7764. infoStr := string(Iinfos)
  7765. idetinfoStr := string(Idetinfos)
  7766. var rf []*ResultFive
  7767. json.Unmarshal([]byte(infoStr), &rf)
  7768. var insutypes []*ResultFive
  7769. var insutype string
  7770. var is390 int = 0
  7771. var is310 int = 0
  7772. for _, item := range rf {
  7773. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7774. insutypes = append(insutypes, item)
  7775. }
  7776. }
  7777. if len(insutypes) == 1 {
  7778. insutype = insutypes[0].Insutype
  7779. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7780. } else {
  7781. for _, i := range insutypes {
  7782. if i.Insutype == "390" {
  7783. is390 = 1
  7784. }
  7785. if i.Insutype == "310" {
  7786. is310 = 1
  7787. }
  7788. }
  7789. }
  7790. if is390 == 1 {
  7791. insutype = "390"
  7792. }
  7793. if is310 == 1 {
  7794. insutype = "310"
  7795. }
  7796. if len(insutypes) == 0 {
  7797. insutype = "390"
  7798. }
  7799. var insuplc_admdvs string
  7800. for _, item := range rf {
  7801. if item.Insutype == insutype {
  7802. insuplc_admdvs = item.InsuplcAdmdvs
  7803. }
  7804. }
  7805. psn := &models.HisPsn{
  7806. PsnNo: res.Output.Baseinfo.PsnNo,
  7807. PatientId: patient.ID,
  7808. Certno: res.Output.Baseinfo.Certno,
  7809. Gend: res.Output.Baseinfo.Gend,
  7810. Naty: res.Output.Baseinfo.Naty,
  7811. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7812. PsnName: res.Output.Baseinfo.PsnName,
  7813. Idetinfo: idetinfoStr,
  7814. Insuinfo: infoStr,
  7815. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7816. InsuplcAdmdvs: insuplc_admdvs,
  7817. }
  7818. service.CreateHisPsn(psn)
  7819. for _, item := range rf {
  7820. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7821. insutypes = append(insutypes, item)
  7822. }
  7823. }
  7824. if len(insutypes) == 1 {
  7825. insutype = insutypes[0].Insutype
  7826. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7827. } else {
  7828. for _, i := range insutypes {
  7829. if i.Insutype == "390" {
  7830. is390 = 1
  7831. }
  7832. if i.Insutype == "310" {
  7833. is310 = 1
  7834. }
  7835. }
  7836. }
  7837. if is390 == 1 {
  7838. insutype = "390"
  7839. }
  7840. if is310 == 1 {
  7841. insutype = "310"
  7842. }
  7843. if len(insutypes) == 0 {
  7844. insutype = "310"
  7845. }
  7846. c.ServeSuccessJSON(map[string]interface{}{
  7847. "patient": patient,
  7848. "number": res.Output.Baseinfo.Certno,
  7849. "insutype": insutype,
  7850. })
  7851. }
  7852. } else {
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7854. return
  7855. }
  7856. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7857. var res ResultTwo
  7858. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7859. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7860. "&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)
  7861. resp, requestErr := http.Get(api)
  7862. if requestErr != nil {
  7863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7864. return
  7865. }
  7866. body, ioErr := ioutil.ReadAll(resp.Body)
  7867. if ioErr != nil {
  7868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7870. return
  7871. }
  7872. var respJSON map[string]interface{}
  7873. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7876. return
  7877. }
  7878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7879. result, _ := json.Marshal(respJSON)
  7880. fmt.Println("log")
  7881. fmt.Println(string(result))
  7882. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7883. utils.ErrorLog("解析失败:%v", err)
  7884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7885. return
  7886. }
  7887. if res.Infcode == 0 {
  7888. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7889. if err == gorm.ErrRecordNotFound {
  7890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7891. return
  7892. } else if err != nil {
  7893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7894. return
  7895. } else {
  7896. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7897. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7898. infoStr := string(Iinfos)
  7899. idetinfoStr := string(Idetinfos)
  7900. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7901. psn := &models.HisPsn{
  7902. PsnNo: res.Output.Baseinfo.PsnNo,
  7903. PatientId: patient.ID,
  7904. Certno: res.Output.Baseinfo.Certno,
  7905. Brdy: b,
  7906. Age: float64(age),
  7907. Gend: res.Output.Baseinfo.Gend,
  7908. Naty: res.Output.Baseinfo.Naty,
  7909. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7910. PsnName: res.Output.Baseinfo.PsnName,
  7911. Idetinfo: idetinfoStr,
  7912. Insuinfo: infoStr,
  7913. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7914. }
  7915. service.CreateHisPsn(psn)
  7916. var rf []*ResultFive
  7917. json.Unmarshal([]byte(infoStr), &rf)
  7918. var insutypes []*ResultFive
  7919. var insutype string
  7920. var is390 int = 0
  7921. var is310 int = 0
  7922. for _, item := range rf {
  7923. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7924. insutypes = append(insutypes, item)
  7925. }
  7926. }
  7927. if len(insutypes) == 1 {
  7928. insutype = insutypes[0].Insutype
  7929. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7930. } else {
  7931. for _, i := range insutypes {
  7932. if i.Insutype == "390" {
  7933. is390 = 1
  7934. }
  7935. if i.Insutype == "310" {
  7936. is310 = 1
  7937. }
  7938. }
  7939. }
  7940. if is390 == 1 {
  7941. insutype = "390"
  7942. }
  7943. if is310 == 1 {
  7944. insutype = "310"
  7945. }
  7946. if len(insutypes) == 0 {
  7947. insutype = "310"
  7948. }
  7949. c.ServeSuccessJSON(map[string]interface{}{
  7950. "patient": patient,
  7951. "number": res.Output.Baseinfo.Certno,
  7952. "insutype": insutype,
  7953. })
  7954. }
  7955. } else {
  7956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7957. return
  7958. }
  7959. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7960. var api string
  7961. if miConfig.MdtrtareaAdmvs == "320921" {
  7962. 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 +
  7963. "&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
  7964. fmt.Println(api)
  7965. } else {
  7966. 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 +
  7967. "&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)
  7968. }
  7969. resp, requestErr := http.Get(api)
  7970. if requestErr != nil {
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. body, ioErr := ioutil.ReadAll(resp.Body)
  7975. if ioErr != nil {
  7976. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. var respJSON map[string]interface{}
  7981. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7982. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7984. return
  7985. }
  7986. var status string
  7987. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7988. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7989. //console.log()
  7990. fmt.Println("type===")
  7991. fmt.Println(card_type)
  7992. var token string
  7993. var res ResultTwo //1101结果
  7994. var res10265 ResultTwo10265 //1101结果
  7995. var card_info string //卡信息
  7996. var busi_card_info string
  7997. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7998. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7999. if status == "0" { //读卡成功
  8000. if card_type == "1" {
  8001. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8002. result, _ := json.Marshal(respJSON)
  8003. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8004. utils.ErrorLog("解析失败:%v", err)
  8005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8006. return
  8007. }
  8008. res.ErrMsg = res10265.ErrMsg
  8009. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8010. res.Infcode = infocode
  8011. res.Output = res10265.Output
  8012. res.InfRefmsgid = res10265.InfRefmsgid
  8013. } else {
  8014. //var card_info string //卡信息
  8015. //var busi_card_info string
  8016. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8017. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8018. //fmt.Println(card_info)
  8019. //fmt.Println(busi_card_info)
  8020. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8021. result, _ := json.Marshal(respJSON)
  8022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8023. utils.ErrorLog("解析失败:%v", err)
  8024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8025. return
  8026. }
  8027. res.ErrMsg = res10265.ErrMsg
  8028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8029. res.Infcode = infocode
  8030. res.Output = res10265.Output
  8031. res.InfRefmsgid = res10265.InfRefmsgid
  8032. }
  8033. if res.Infcode == 0 {
  8034. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8035. if err == gorm.ErrRecordNotFound {
  8036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8037. return
  8038. } else if err != nil {
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8040. return
  8041. } else {
  8042. if card_type == "1" {
  8043. bas := strings.Split(card_info, "|")
  8044. basNumber := bas[2]
  8045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8047. infoStr := string(Iinfos)
  8048. idetinfoStr := string(Idetinfos)
  8049. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8050. psn := &models.HisPsn{
  8051. PsnNo: res.Output.Baseinfo.PsnNo,
  8052. PatientId: patient.ID,
  8053. Certno: res.Output.Baseinfo.Certno,
  8054. Brdy: b,
  8055. Age: float64(age),
  8056. Gend: res.Output.Baseinfo.Gend,
  8057. Naty: res.Output.Baseinfo.Naty,
  8058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8059. PsnName: res.Output.Baseinfo.PsnName,
  8060. Idetinfo: idetinfoStr,
  8061. Insuinfo: infoStr,
  8062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8063. CardInfo: card_info,
  8064. VerifyNumber: busi_card_info,
  8065. }
  8066. service.CreateHisPsn(psn)
  8067. var rf []*ResultFive
  8068. json.Unmarshal([]byte(infoStr), &rf)
  8069. var insutypes []*ResultFive
  8070. var insutype string
  8071. var is390 int = 0
  8072. var is310 int = 0
  8073. for _, item := range rf {
  8074. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8075. insutypes = append(insutypes, item)
  8076. }
  8077. }
  8078. if len(insutypes) == 1 {
  8079. insutype = insutypes[0].Insutype
  8080. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8081. } else {
  8082. for _, i := range insutypes {
  8083. if i.Insutype == "390" {
  8084. is390 = 1
  8085. }
  8086. if i.Insutype == "310" {
  8087. is310 = 1
  8088. }
  8089. }
  8090. }
  8091. if is390 == 1 {
  8092. insutype = "390"
  8093. }
  8094. if is310 == 1 {
  8095. insutype = "310"
  8096. }
  8097. if len(insutypes) == 0 {
  8098. insutype = "310"
  8099. }
  8100. c.ServeSuccessJSON(map[string]interface{}{
  8101. "patient": patient,
  8102. "number": basNumber,
  8103. "insutype": insutype,
  8104. })
  8105. } else {
  8106. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8107. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8108. infoStr := string(Iinfos)
  8109. idetinfoStr := string(Idetinfos)
  8110. psn := &models.HisPsn{
  8111. PsnNo: res.Output.Baseinfo.PsnNo,
  8112. PatientId: patient.ID,
  8113. Certno: res.Output.Baseinfo.Certno,
  8114. Gend: res.Output.Baseinfo.Gend,
  8115. Naty: res.Output.Baseinfo.Naty,
  8116. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8117. PsnName: res.Output.Baseinfo.PsnName,
  8118. Idetinfo: idetinfoStr,
  8119. Insuinfo: infoStr,
  8120. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8121. CardInfo: card_info,
  8122. VerifyNumber: token,
  8123. }
  8124. service.CreateHisPsn(psn)
  8125. c.ServeSuccessJSON(map[string]interface{}{
  8126. "patient": patient,
  8127. "number": token,
  8128. })
  8129. }
  8130. }
  8131. } else {
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8133. return
  8134. }
  8135. } else { //读卡失败
  8136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8137. return
  8138. }
  8139. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8140. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8141. cardnum = DeleteExtraSpaceTwo(cardnum)
  8142. cardCode = DeleteExtraSpaceTwo(cardCode)
  8143. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8144. name = DeleteExtraSpaceTwo(name)
  8145. errmsg = DeleteExtraSpaceTwo(errmsg)
  8146. cardnum = Remove0000(cardnum)
  8147. cardCode = Remove0000(cardCode)
  8148. id_card_no = Remove0000(id_card_no)
  8149. name = Remove0000(name)
  8150. errmsg = Remove0000(errmsg)
  8151. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8152. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8153. //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)
  8154. //fmt.Println(result2)
  8155. //fmt.Println(requestLog2)
  8156. //fmt.Println(errMsgLog2)
  8157. 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)
  8158. saveLog(result, requestLog, "1101", "获取人员信息")
  8159. fmt.Println(errMsgLog)
  8160. if len(errMsgLog) > 0 {
  8161. } else {
  8162. var dat map[string]interface{}
  8163. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8164. fmt.Println(dat)
  8165. } else {
  8166. fmt.Println(err)
  8167. }
  8168. userJSONBytes, _ := json.Marshal(dat)
  8169. var res ResultTwo
  8170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8171. utils.ErrorLog("解析失败:%v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. res.ErrMsg = errMsgLog
  8176. if res.Infcode == 0 {
  8177. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8178. if err == gorm.ErrRecordNotFound {
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8180. return
  8181. } else if err != nil {
  8182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8183. return
  8184. } else {
  8185. fmt.Println(res)
  8186. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8187. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8188. infoStr := string(Iinfos)
  8189. idetinfoStr := string(Idetinfos)
  8190. var rf []*ResultFive
  8191. json.Unmarshal([]byte(infoStr), &rf)
  8192. var insutypes []*ResultFive
  8193. var insutype string
  8194. var is390 int = 0
  8195. var is310 int = 0
  8196. for _, item := range rf {
  8197. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8198. insutypes = append(insutypes, item)
  8199. }
  8200. }
  8201. if len(insutypes) == 1 {
  8202. insutype = insutypes[0].Insutype
  8203. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8204. } else {
  8205. for _, i := range insutypes {
  8206. if i.Insutype == "390" {
  8207. is390 = 1
  8208. }
  8209. if i.Insutype == "310" {
  8210. is310 = 1
  8211. }
  8212. }
  8213. }
  8214. if is390 == 1 {
  8215. insutype = "390"
  8216. }
  8217. if is310 == 1 {
  8218. insutype = "310"
  8219. }
  8220. if len(insutypes) == 0 {
  8221. insutype = "390"
  8222. }
  8223. var insuplc_admdvs string
  8224. for _, item := range rf {
  8225. if item.Insutype == insutype {
  8226. insuplc_admdvs = item.InsuplcAdmdvs
  8227. }
  8228. }
  8229. psn := &models.HisPsn{
  8230. PsnNo: res.Output.Baseinfo.PsnNo,
  8231. PatientId: patient.ID,
  8232. Certno: res.Output.Baseinfo.Certno,
  8233. Gend: res.Output.Baseinfo.Gend,
  8234. Naty: res.Output.Baseinfo.Naty,
  8235. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8236. PsnName: res.Output.Baseinfo.PsnName,
  8237. Idetinfo: idetinfoStr,
  8238. Insuinfo: infoStr,
  8239. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8240. CardInfo: basStr,
  8241. VerifyNumber: "",
  8242. InsuplcAdmdvs: insuplc_admdvs,
  8243. }
  8244. service.CreateHisPsn(psn)
  8245. c.ServeSuccessJSON(map[string]interface{}{
  8246. "patient": patient,
  8247. "number": cardnum,
  8248. "insutype": insutype,
  8249. })
  8250. }
  8251. } else {
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8253. return
  8254. }
  8255. }
  8256. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8257. fmt.Println(initFlag)
  8258. fmt.Println("initFlag")
  8259. if initFlag == 0 {
  8260. c.TestGetJiangXiBasBaseInit()
  8261. }
  8262. basStr := c.GetBasBaseInfo()
  8263. if len(basStr) == 0 {
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8265. return
  8266. }
  8267. fmt.Println(basStr)
  8268. bas := strings.Split(basStr, "|")
  8269. basNumber := bas[1]
  8270. fmt.Println(basNumber)
  8271. card_sn := bas[3]
  8272. fmt.Println(card_sn)
  8273. 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, "")
  8274. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8275. var dat map[string]interface{}
  8276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8277. fmt.Println(dat)
  8278. } else {
  8279. fmt.Println(err)
  8280. }
  8281. userJSONBytes, _ := json.Marshal(dat)
  8282. var res ResultTwo
  8283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8284. utils.ErrorLog("解析失败:%v", err)
  8285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8286. return
  8287. }
  8288. if res.Infcode == 0 {
  8289. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8290. if err == gorm.ErrRecordNotFound {
  8291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8292. return
  8293. } else if err != nil {
  8294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8295. return
  8296. } else {
  8297. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8298. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8299. infoStr := string(Iinfos)
  8300. idetinfoStr := string(Idetinfos)
  8301. var rf []*ResultFive
  8302. json.Unmarshal([]byte(infoStr), &rf)
  8303. var insutypes []*ResultFive
  8304. var insutype string
  8305. var is390 int = 0
  8306. var is310 int = 0
  8307. var insuplc_admdvs string
  8308. for _, item := range rf {
  8309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8310. insutypes = append(insutypes, item)
  8311. }
  8312. }
  8313. if len(insutypes) == 1 {
  8314. insutype = insutypes[0].Insutype
  8315. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8316. } else {
  8317. for _, i := range insutypes {
  8318. if i.Insutype == "390" {
  8319. is390 = 1
  8320. }
  8321. if i.Insutype == "310" {
  8322. is310 = 1
  8323. }
  8324. }
  8325. }
  8326. if is390 == 1 {
  8327. insutype = "390"
  8328. }
  8329. if is310 == 1 {
  8330. insutype = "310"
  8331. }
  8332. if len(insutypes) == 0 {
  8333. insutype = "310"
  8334. }
  8335. for _, item := range rf {
  8336. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8337. insuplc_admdvs = item.InsuplcAdmdvs
  8338. }
  8339. }
  8340. psn := &models.HisPsn{
  8341. PsnNo: res.Output.Baseinfo.PsnNo,
  8342. PatientId: patient.ID,
  8343. Certno: res.Output.Baseinfo.Certno,
  8344. Gend: res.Output.Baseinfo.Gend,
  8345. Naty: res.Output.Baseinfo.Naty,
  8346. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8347. PsnName: res.Output.Baseinfo.PsnName,
  8348. Idetinfo: idetinfoStr,
  8349. Insuinfo: infoStr,
  8350. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8351. CardInfo: basStr,
  8352. InsuplcAdmdvs: insuplc_admdvs,
  8353. VerifyNumber: "",
  8354. }
  8355. service.CreateHisPsn(psn)
  8356. c.ServeSuccessJSON(map[string]interface{}{
  8357. "patient": patient,
  8358. "number": basNumber,
  8359. "insutype": insutype,
  8360. })
  8361. }
  8362. } else {
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8364. return
  8365. }
  8366. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8367. fmt.Println(initFlag)
  8368. fmt.Println("initFlag")
  8369. if initFlag == 0 {
  8370. c.TestGetHnBasBaseInit()
  8371. }
  8372. basStr := c.GetBasBaseInfo()
  8373. if len(basStr) == 0 {
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8375. return
  8376. }
  8377. fmt.Println(basStr)
  8378. bas := strings.Split(basStr, "|")
  8379. basNumber := bas[1]
  8380. fmt.Println(basNumber)
  8381. card_sn := bas[3]
  8382. card_no := bas[2]
  8383. fmt.Println(card_sn)
  8384. name := bas[4]
  8385. name = ConvertToString(name, "gbk", "utf-8")
  8386. 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)
  8387. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8388. var dat map[string]interface{}
  8389. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8390. fmt.Println(dat)
  8391. } else {
  8392. fmt.Println(err)
  8393. }
  8394. userJSONBytes, _ := json.Marshal(dat)
  8395. var res ResultTwo
  8396. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8397. utils.ErrorLog("解析失败:%v", err)
  8398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8399. return
  8400. }
  8401. if res.Infcode == 0 {
  8402. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8403. if err == gorm.ErrRecordNotFound {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8405. return
  8406. } else if err != nil {
  8407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8408. return
  8409. } else {
  8410. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8411. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8412. infoStr := string(Iinfos)
  8413. idetinfoStr := string(Idetinfos)
  8414. psn := &models.HisPsn{
  8415. PsnNo: res.Output.Baseinfo.PsnNo,
  8416. PatientId: patient.ID,
  8417. Certno: res.Output.Baseinfo.Certno,
  8418. Gend: res.Output.Baseinfo.Gend,
  8419. Naty: res.Output.Baseinfo.Naty,
  8420. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8421. PsnName: res.Output.Baseinfo.PsnName,
  8422. Idetinfo: idetinfoStr,
  8423. Insuinfo: infoStr,
  8424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8425. CardInfo: basStr,
  8426. VerifyNumber: "",
  8427. }
  8428. service.CreateHisPsn(psn)
  8429. var rf []*ResultFive
  8430. json.Unmarshal([]byte(infoStr), &rf)
  8431. var insutypes []*ResultFive
  8432. var insutype string
  8433. var is390 int = 0
  8434. var is310 int = 0
  8435. for _, item := range rf {
  8436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8437. insutypes = append(insutypes, item)
  8438. }
  8439. }
  8440. if len(insutypes) == 1 {
  8441. insutype = insutypes[0].Insutype
  8442. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8443. } else {
  8444. for _, i := range insutypes {
  8445. if i.Insutype == "390" {
  8446. is390 = 1
  8447. }
  8448. if i.Insutype == "310" {
  8449. is310 = 1
  8450. }
  8451. }
  8452. }
  8453. if is390 == 1 {
  8454. insutype = "390"
  8455. }
  8456. if is310 == 1 {
  8457. insutype = "310"
  8458. }
  8459. if len(insutypes) == 0 {
  8460. insutype = "310"
  8461. }
  8462. c.ServeSuccessJSON(map[string]interface{}{
  8463. "patient": patient,
  8464. "number": basNumber,
  8465. "insutype": insutype,
  8466. })
  8467. }
  8468. } else {
  8469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8470. return
  8471. }
  8472. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8473. var api string
  8474. 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 +
  8475. "&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
  8476. fmt.Println(api)
  8477. resp, requestErr := http.Get(api)
  8478. if requestErr != nil {
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. body, ioErr := ioutil.ReadAll(resp.Body)
  8483. if ioErr != nil {
  8484. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8486. return
  8487. }
  8488. var respJSON map[string]interface{}
  8489. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8492. return
  8493. }
  8494. var res ResultTwo //1101结果
  8495. var res10265 ResultTwo10265 //1101结果
  8496. var card_info string //卡信息
  8497. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8498. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8499. result, _ := json.Marshal(respJSON)
  8500. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8501. utils.ErrorLog("解析失败:%v", err)
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. res.ErrMsg = res10265.ErrMsg
  8506. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8507. res.Infcode = infocode
  8508. res.Output = res10265.Output
  8509. res.InfRefmsgid = res10265.InfRefmsgid
  8510. if res.Infcode == 0 {
  8511. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8512. if err == gorm.ErrRecordNotFound {
  8513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8514. return
  8515. } else if err != nil {
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8517. return
  8518. } else {
  8519. bas := strings.Split(card_info, "|")
  8520. basNumber := bas[2]
  8521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8523. infoStr := string(Iinfos)
  8524. idetinfoStr := string(Idetinfos)
  8525. psn := &models.HisPsn{
  8526. PsnNo: res.Output.Baseinfo.PsnNo,
  8527. PatientId: patient.ID,
  8528. Certno: res.Output.Baseinfo.Certno,
  8529. Gend: res.Output.Baseinfo.Gend,
  8530. Naty: res.Output.Baseinfo.Naty,
  8531. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8532. PsnName: res.Output.Baseinfo.PsnName,
  8533. Idetinfo: idetinfoStr,
  8534. Insuinfo: infoStr,
  8535. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8536. CardInfo: card_info,
  8537. VerifyNumber: token,
  8538. }
  8539. service.CreateHisPsn(psn)
  8540. var rf []*ResultFive
  8541. json.Unmarshal([]byte(infoStr), &rf)
  8542. var insutypes []*ResultFive
  8543. var insutype string
  8544. var is390 int = 0
  8545. var is310 int = 0
  8546. for _, item := range rf {
  8547. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8548. insutypes = append(insutypes, item)
  8549. }
  8550. }
  8551. if len(insutypes) == 1 {
  8552. insutype = insutypes[0].Insutype
  8553. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8554. } else {
  8555. for _, i := range insutypes {
  8556. if i.Insutype == "390" {
  8557. is390 = 1
  8558. }
  8559. if i.Insutype == "310" {
  8560. is310 = 1
  8561. }
  8562. }
  8563. }
  8564. if is390 == 1 {
  8565. insutype = "390"
  8566. }
  8567. if is310 == 1 {
  8568. insutype = "310"
  8569. }
  8570. if len(insutypes) == 0 {
  8571. insutype = "310"
  8572. }
  8573. c.ServeSuccessJSON(map[string]interface{}{
  8574. "patient": patient,
  8575. "number": basNumber,
  8576. "insutype": insutype,
  8577. })
  8578. }
  8579. } else {
  8580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8581. return
  8582. }
  8583. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8584. res := c.GetoleInfo()
  8585. if res.Infcode == 0 {
  8586. var result string
  8587. if res.Output.MdtrtCertType == "01" {
  8588. 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)
  8589. } else if res.Output.MdtrtCertType == "02" {
  8590. 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)
  8591. } else if res.Output.MdtrtCertType == "03" {
  8592. 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)
  8593. }
  8594. var dat map[string]interface{}
  8595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8596. fmt.Println(dat)
  8597. } else {
  8598. fmt.Println(err)
  8599. }
  8600. userJSONBytes, _ := json.Marshal(dat)
  8601. var res2 ResultTwo
  8602. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8603. utils.ErrorLog("解析失败:%v", err)
  8604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8605. return
  8606. }
  8607. if res2.Infcode == 0 {
  8608. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8609. if err == gorm.ErrRecordNotFound {
  8610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8611. return
  8612. } else if err != nil {
  8613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8614. return
  8615. } else {
  8616. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8617. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8618. infoStr := string(Iinfos)
  8619. idetinfoStr := string(Idetinfos)
  8620. var rf []*ResultFive
  8621. json.Unmarshal([]byte(infoStr), &rf)
  8622. var insutypes []*ResultFive
  8623. var insutype string
  8624. var is390 int = 0
  8625. var is310 int = 0
  8626. //var insuplc_admdvs string
  8627. for _, item := range rf {
  8628. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8629. insutypes = append(insutypes, item)
  8630. }
  8631. }
  8632. if len(insutypes) == 1 {
  8633. insutype = insutypes[0].Insutype
  8634. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8635. } else {
  8636. for _, i := range insutypes {
  8637. if i.Insutype == "390" {
  8638. is390 = 1
  8639. }
  8640. if i.Insutype == "310" {
  8641. is310 = 1
  8642. }
  8643. }
  8644. }
  8645. if is390 == 1 {
  8646. insutype = "390"
  8647. }
  8648. if is310 == 1 {
  8649. insutype = "310"
  8650. }
  8651. if len(insutypes) == 0 {
  8652. insutype = "310"
  8653. }
  8654. psn := &models.HisPsn{
  8655. PsnNo: res2.Output.Baseinfo.PsnNo,
  8656. PatientId: patient.ID,
  8657. Certno: res2.Output.Baseinfo.Certno,
  8658. Gend: res2.Output.Baseinfo.Gend,
  8659. Naty: res2.Output.Baseinfo.Naty,
  8660. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8661. PsnName: res2.Output.Baseinfo.PsnName,
  8662. Idetinfo: idetinfoStr,
  8663. Insuinfo: infoStr,
  8664. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8665. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8666. VerifyNumber: res.Output.EcToken,
  8667. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8668. }
  8669. if res.Output.MdtrtCertType == "01" {
  8670. psn.VerifyNumber = res.Output.EcToken
  8671. //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)
  8672. } else if res.Output.MdtrtCertType == "02" {
  8673. psn.VerifyNumber = res.Output.MdtrtCertNo
  8674. //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)
  8675. } else if res.Output.MdtrtCertType == "03" {
  8676. psn.VerifyNumber = res.Output.MdtrtCertNo
  8677. //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)
  8678. }
  8679. var balc float64
  8680. for _, item := range rf {
  8681. if item.Insutype == insutype {
  8682. balc = item.Balc
  8683. }
  8684. }
  8685. service.CreateHisPsn(psn)
  8686. c.ServeSuccessJSON(map[string]interface{}{
  8687. "patient": patient,
  8688. "number": res.Output.CardNo,
  8689. "insutype": insutype,
  8690. "blac": balc,
  8691. "desc": idetinfoStr,
  8692. })
  8693. }
  8694. } else {
  8695. c.ServeSuccessJSON(map[string]interface{}{
  8696. "failed_code": -10,
  8697. "msg": res2.ErrMsg,
  8698. })
  8699. }
  8700. } else {
  8701. c.ServeSuccessJSON(map[string]interface{}{
  8702. "failed_code": -10,
  8703. "msg": res.ErrMsg,
  8704. })
  8705. }
  8706. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8707. var api string
  8708. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8709. "&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
  8710. fmt.Println(api)
  8711. resp, requestErr := http.Get(api)
  8712. if requestErr != nil {
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8714. return
  8715. }
  8716. body, ioErr := ioutil.ReadAll(resp.Body)
  8717. if ioErr != nil {
  8718. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. var respJSON map[string]interface{}
  8723. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8724. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8726. return
  8727. }
  8728. var status string
  8729. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8730. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8731. //console.log()
  8732. fmt.Println("type===")
  8733. fmt.Println(card_type)
  8734. var token string
  8735. var res ResultTwo //1101结果
  8736. //var res10265 ResultTwoesultTwo10265 //1101结果
  8737. var card_info string //卡信息
  8738. var busi_card_info string
  8739. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8740. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8741. if status == "0" { //读卡成功
  8742. if card_type == "1" {
  8743. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8744. result, _ := json.Marshal(respJSON)
  8745. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8746. utils.ErrorLog("解析失败:%v", err)
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8748. return
  8749. }
  8750. } else {
  8751. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8752. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8753. result, _ := json.Marshal(respJSON)
  8754. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8755. utils.ErrorLog("解析失败:%v", err)
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. }
  8760. if res.Infcode == 0 {
  8761. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8762. if err == gorm.ErrRecordNotFound {
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8764. return
  8765. } else if err != nil {
  8766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8767. return
  8768. } else {
  8769. if card_type == "1" {
  8770. bas := strings.Split(card_info, "|")
  8771. basNumber := bas[2]
  8772. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8773. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8774. infoStr := string(Iinfos)
  8775. idetinfoStr := string(Idetinfos)
  8776. psn := &models.HisPsn{
  8777. PsnNo: res.Output.Baseinfo.PsnNo,
  8778. PatientId: patient.ID,
  8779. Certno: res.Output.Baseinfo.Certno,
  8780. Gend: res.Output.Baseinfo.Gend,
  8781. Naty: res.Output.Baseinfo.Naty,
  8782. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8783. PsnName: res.Output.Baseinfo.PsnName,
  8784. Idetinfo: idetinfoStr,
  8785. Insuinfo: infoStr,
  8786. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8787. CardInfo: card_info,
  8788. VerifyNumber: busi_card_info,
  8789. }
  8790. service.CreateHisPsn(psn)
  8791. var rf []*ResultFive
  8792. json.Unmarshal([]byte(infoStr), &rf)
  8793. var insutypes []*ResultFive
  8794. var insutype string
  8795. var is390 int = 0
  8796. var is310 int = 0
  8797. for _, item := range rf {
  8798. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8799. insutypes = append(insutypes, item)
  8800. }
  8801. }
  8802. if len(insutypes) == 1 {
  8803. insutype = insutypes[0].Insutype
  8804. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8805. } else {
  8806. for _, i := range insutypes {
  8807. if i.Insutype == "390" {
  8808. is390 = 1
  8809. }
  8810. if i.Insutype == "310" {
  8811. is310 = 1
  8812. }
  8813. }
  8814. }
  8815. if is390 == 1 {
  8816. insutype = "390"
  8817. }
  8818. if is310 == 1 {
  8819. insutype = "310"
  8820. }
  8821. if len(insutypes) == 0 {
  8822. insutype = "310"
  8823. }
  8824. c.ServeSuccessJSON(map[string]interface{}{
  8825. "patient": patient,
  8826. "number": basNumber,
  8827. "insutype": insutype,
  8828. })
  8829. } else {
  8830. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8831. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8832. infoStr := string(Iinfos)
  8833. idetinfoStr := string(Idetinfos)
  8834. psn := &models.HisPsn{
  8835. PsnNo: res.Output.Baseinfo.PsnNo,
  8836. PatientId: patient.ID,
  8837. Certno: res.Output.Baseinfo.Certno,
  8838. Gend: res.Output.Baseinfo.Gend,
  8839. Naty: res.Output.Baseinfo.Naty,
  8840. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8841. PsnName: res.Output.Baseinfo.PsnName,
  8842. Idetinfo: idetinfoStr,
  8843. Insuinfo: infoStr,
  8844. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8845. CardInfo: card_info,
  8846. VerifyNumber: token,
  8847. }
  8848. service.CreateHisPsn(psn)
  8849. c.ServeSuccessJSON(map[string]interface{}{
  8850. "patient": patient,
  8851. "number": token,
  8852. })
  8853. }
  8854. }
  8855. } else {
  8856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8857. return
  8858. }
  8859. } else { //读卡失败
  8860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8861. return
  8862. }
  8863. } else {
  8864. if initFlag == 0 {
  8865. c.TestGetBasBaseInit()
  8866. }
  8867. basStr := c.GetBasBaseInfo()
  8868. if len(basStr) == 0 {
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8870. return
  8871. }
  8872. fmt.Println(basStr)
  8873. bas := strings.Split(basStr, "|")
  8874. basNumber := bas[1]
  8875. fmt.Println(basNumber)
  8876. card_sn := bas[3]
  8877. fmt.Println(card_sn)
  8878. cardNumber := bas[2]
  8879. fmt.Println(cardNumber)
  8880. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8881. var result string
  8882. if bas[0][:2] == "44" {
  8883. 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)
  8884. } else {
  8885. 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)
  8886. }
  8887. var dat map[string]interface{}
  8888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8889. fmt.Println(dat)
  8890. } else {
  8891. fmt.Println(err)
  8892. }
  8893. userJSONBytes, _ := json.Marshal(dat)
  8894. var res ResultTwo
  8895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8896. utils.ErrorLog("解析失败:%v", err)
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8898. return
  8899. }
  8900. if res.Infcode == 0 {
  8901. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8902. if err == gorm.ErrRecordNotFound {
  8903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8904. return
  8905. } else if err != nil {
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8907. return
  8908. } else {
  8909. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8910. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8911. infoStr := string(Iinfos)
  8912. idetinfoStr := string(Idetinfos)
  8913. var rf []*ResultFive
  8914. json.Unmarshal([]byte(infoStr), &rf)
  8915. var insutypes []*ResultFive
  8916. var insutype string
  8917. var is390 int = 0
  8918. var is310 int = 0
  8919. var insuplc_admdvs string
  8920. for _, item := range rf {
  8921. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8922. insutypes = append(insutypes, item)
  8923. }
  8924. }
  8925. if len(insutypes) == 1 {
  8926. insutype = insutypes[0].Insutype
  8927. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8928. } else {
  8929. for _, i := range insutypes {
  8930. if i.Insutype == "390" {
  8931. is390 = 1
  8932. }
  8933. if i.Insutype == "310" {
  8934. is310 = 1
  8935. }
  8936. }
  8937. }
  8938. if is390 == 1 {
  8939. insutype = "390"
  8940. }
  8941. if is310 == 1 {
  8942. insutype = "310"
  8943. }
  8944. if len(insutypes) == 0 {
  8945. insutype = "310"
  8946. }
  8947. for _, item := range rf {
  8948. if item.Insutype == insutype {
  8949. insuplc_admdvs = item.InsuplcAdmdvs
  8950. }
  8951. }
  8952. psn := &models.HisPsn{
  8953. PsnNo: res.Output.Baseinfo.PsnNo,
  8954. PatientId: patient.ID,
  8955. Certno: res.Output.Baseinfo.Certno,
  8956. Gend: res.Output.Baseinfo.Gend,
  8957. Naty: res.Output.Baseinfo.Naty,
  8958. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8959. PsnName: res.Output.Baseinfo.PsnName,
  8960. Idetinfo: idetinfoStr,
  8961. Insuinfo: infoStr,
  8962. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8963. CardInfo: basStr,
  8964. VerifyNumber: "",
  8965. InsuplcAdmdvs: insuplc_admdvs,
  8966. }
  8967. service.CreateHisPsn(psn)
  8968. c.ServeSuccessJSON(map[string]interface{}{
  8969. "patient": patient,
  8970. "number": basNumber,
  8971. })
  8972. }
  8973. } else {
  8974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8975. return
  8976. }
  8977. break
  8978. }
  8979. case 2:
  8980. if miConfig.MdtrtareaAdmvs == "430800" {
  8981. if initFlag == 0 {
  8982. c.TestGetHnBasBaseInit()
  8983. }
  8984. SFZStr := c.GetSFZBaseInfo()
  8985. if len(SFZStr) == 0 {
  8986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8987. return
  8988. }
  8989. fmt.Println(SFZStr)
  8990. id_card_str := strings.Split(SFZStr, "^")
  8991. card_no := id_card_str[0]
  8992. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8993. //name := id_card_str[1]
  8994. //name = ConvertToString(name, "gbk", "utf-8")
  8995. 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)
  8996. var dat map[string]interface{}
  8997. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8998. fmt.Println(dat)
  8999. } else {
  9000. fmt.Println(err)
  9001. }
  9002. userJSONBytes, _ := json.Marshal(dat)
  9003. var res ResultTwo
  9004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9005. utils.ErrorLog("解析失败:%v", err)
  9006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9007. return
  9008. }
  9009. if res.Infcode == 0 {
  9010. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9011. if err == gorm.ErrRecordNotFound {
  9012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9013. return
  9014. } else if err != nil {
  9015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9016. return
  9017. } else {
  9018. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9019. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9020. infoStr := string(Iinfos)
  9021. idetinfoStr := string(Idetinfos)
  9022. var rf []*ResultFive
  9023. json.Unmarshal([]byte(infoStr), &rf)
  9024. var insutypes []*ResultFive
  9025. var insutype string
  9026. var is390 int = 0
  9027. var is310 int = 0
  9028. for _, item := range rf {
  9029. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9030. insutypes = append(insutypes, item)
  9031. }
  9032. }
  9033. if len(insutypes) == 1 {
  9034. insutype = insutypes[0].Insutype
  9035. } else {
  9036. for _, i := range insutypes {
  9037. if i.Insutype == "390" {
  9038. is390 = 1
  9039. }
  9040. if i.Insutype == "310" {
  9041. is310 = 1
  9042. }
  9043. }
  9044. }
  9045. if is390 == 1 {
  9046. insutype = "390"
  9047. }
  9048. if is310 == 1 {
  9049. insutype = "310"
  9050. }
  9051. if len(insutypes) == 0 {
  9052. insutype = "310"
  9053. }
  9054. var InsuplcAdmdvs string
  9055. for _, item := range rf {
  9056. if item.Insutype == insutype {
  9057. InsuplcAdmdvs = item.InsuplcAdmdvs
  9058. }
  9059. }
  9060. psn := &models.HisPsn{
  9061. PsnNo: res.Output.Baseinfo.PsnNo,
  9062. PatientId: patient.ID,
  9063. Certno: res.Output.Baseinfo.Certno,
  9064. Gend: res.Output.Baseinfo.Gend,
  9065. Naty: res.Output.Baseinfo.Naty,
  9066. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9067. PsnName: res.Output.Baseinfo.PsnName,
  9068. Idetinfo: idetinfoStr,
  9069. Insuinfo: infoStr,
  9070. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9071. CardInfo: SFZStr,
  9072. VerifyNumber: "",
  9073. InsuplcAdmdvs: InsuplcAdmdvs,
  9074. }
  9075. service.CreateHisPsn(psn)
  9076. c.ServeSuccessJSON(map[string]interface{}{
  9077. "patient": patient,
  9078. "number": card_no,
  9079. "insutype": insutype,
  9080. })
  9081. }
  9082. } else {
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9084. return
  9085. }
  9086. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9087. var res ResultTwo
  9088. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9089. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9090. "&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)
  9091. resp, requestErr := http.Get(api)
  9092. if requestErr != nil {
  9093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9094. return
  9095. }
  9096. body, ioErr := ioutil.ReadAll(resp.Body)
  9097. if ioErr != nil {
  9098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9100. return
  9101. }
  9102. var respJSON map[string]interface{}
  9103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9106. return
  9107. }
  9108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9109. result, _ := json.Marshal(respJSON)
  9110. fmt.Println("log")
  9111. fmt.Println(string(result))
  9112. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9113. utils.ErrorLog("解析失败:%v", err)
  9114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9115. return
  9116. }
  9117. if res.Infcode == 0 {
  9118. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9119. if err == gorm.ErrRecordNotFound {
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9121. return
  9122. } else if err != nil {
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9124. return
  9125. } else {
  9126. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9127. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9128. infoStr := string(Iinfos)
  9129. idetinfoStr := string(Idetinfos)
  9130. psn := &models.HisPsn{
  9131. PsnNo: res.Output.Baseinfo.PsnNo,
  9132. PatientId: patient.ID,
  9133. Certno: res.Output.Baseinfo.Certno,
  9134. Gend: res.Output.Baseinfo.Gend,
  9135. Naty: res.Output.Baseinfo.Naty,
  9136. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9137. PsnName: res.Output.Baseinfo.PsnName,
  9138. Idetinfo: idetinfoStr,
  9139. Insuinfo: infoStr,
  9140. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9141. }
  9142. service.CreateHisPsn(psn)
  9143. c.ServeSuccessJSON(map[string]interface{}{
  9144. "patient": patient,
  9145. "number": res.Output.Baseinfo.Certno,
  9146. })
  9147. }
  9148. } else {
  9149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9150. return
  9151. }
  9152. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9153. var res ResultTwo
  9154. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9155. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9156. "&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)
  9157. resp, requestErr := http.Get(api)
  9158. if requestErr != nil {
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. body, ioErr := ioutil.ReadAll(resp.Body)
  9163. if ioErr != nil {
  9164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. var respJSON map[string]interface{}
  9169. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9175. result, _ := json.Marshal(respJSON)
  9176. fmt.Println("log")
  9177. fmt.Println(string(result))
  9178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9179. utils.ErrorLog("解析失败:%v", err)
  9180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9181. return
  9182. }
  9183. if res.Infcode == 0 {
  9184. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9185. if err == gorm.ErrRecordNotFound {
  9186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9187. return
  9188. } else if err != nil {
  9189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9190. return
  9191. } else {
  9192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9193. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9194. infoStr := string(Iinfos)
  9195. idetinfoStr := string(Idetinfos)
  9196. psn := &models.HisPsn{
  9197. PsnNo: res.Output.Baseinfo.PsnNo,
  9198. PatientId: patient.ID,
  9199. Certno: res.Output.Baseinfo.Certno,
  9200. Gend: res.Output.Baseinfo.Gend,
  9201. Naty: res.Output.Baseinfo.Naty,
  9202. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9203. PsnName: res.Output.Baseinfo.PsnName,
  9204. Idetinfo: idetinfoStr,
  9205. Insuinfo: infoStr,
  9206. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9207. }
  9208. service.CreateHisPsn(psn)
  9209. c.ServeSuccessJSON(map[string]interface{}{
  9210. "patient": patient,
  9211. "number": res.Output.Baseinfo.Certno,
  9212. })
  9213. }
  9214. } else {
  9215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9216. return
  9217. }
  9218. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9219. var res ResultTwo
  9220. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9221. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9222. "&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)
  9223. resp, requestErr := http.Get(api)
  9224. if requestErr != nil {
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. body, ioErr := ioutil.ReadAll(resp.Body)
  9229. if ioErr != nil {
  9230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9232. return
  9233. }
  9234. var respJSON map[string]interface{}
  9235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9238. return
  9239. }
  9240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9241. result, _ := json.Marshal(respJSON)
  9242. fmt.Println("log")
  9243. fmt.Println(string(result))
  9244. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9245. utils.ErrorLog("解析失败:%v", err)
  9246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9247. return
  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. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9259. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9260. infoStr := string(Iinfos)
  9261. idetinfoStr := string(Idetinfos)
  9262. var rf []*ResultFive
  9263. json.Unmarshal([]byte(infoStr), &rf)
  9264. var insutypes []*ResultFive
  9265. var insutype string
  9266. var is390 int = 0
  9267. var is310 int = 0
  9268. for _, item := range rf {
  9269. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9270. insutypes = append(insutypes, item)
  9271. }
  9272. }
  9273. if len(insutypes) == 1 {
  9274. insutype = insutypes[0].Insutype
  9275. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9276. } else {
  9277. for _, i := range insutypes {
  9278. if i.Insutype == "390" {
  9279. is390 = 1
  9280. }
  9281. if i.Insutype == "310" {
  9282. is310 = 1
  9283. }
  9284. }
  9285. }
  9286. if is390 == 1 {
  9287. insutype = "390"
  9288. }
  9289. if is310 == 1 {
  9290. insutype = "310"
  9291. }
  9292. if len(insutypes) == 0 {
  9293. insutype = "390"
  9294. }
  9295. var insuplc_admdvs string
  9296. for _, item := range rf {
  9297. if item.Insutype == insutype {
  9298. insuplc_admdvs = item.InsuplcAdmdvs
  9299. }
  9300. }
  9301. psn := &models.HisPsn{
  9302. PsnNo: res.Output.Baseinfo.PsnNo,
  9303. PatientId: patient.ID,
  9304. Certno: res.Output.Baseinfo.Certno,
  9305. Gend: res.Output.Baseinfo.Gend,
  9306. Naty: res.Output.Baseinfo.Naty,
  9307. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9308. PsnName: res.Output.Baseinfo.PsnName,
  9309. Idetinfo: idetinfoStr,
  9310. Insuinfo: infoStr,
  9311. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9312. InsuplcAdmdvs: insuplc_admdvs,
  9313. }
  9314. service.CreateHisPsn(psn)
  9315. c.ServeSuccessJSON(map[string]interface{}{
  9316. "patient": patient,
  9317. "number": res.Output.Baseinfo.Certno,
  9318. })
  9319. }
  9320. } else {
  9321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9322. return
  9323. }
  9324. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9325. res := c.GetoleInfo()
  9326. if res.Infcode == 0 {
  9327. var result string
  9328. if res.Output.MdtrtCertType == "01" {
  9329. 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)
  9330. } else if res.Output.MdtrtCertType == "02" {
  9331. 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)
  9332. } else if res.Output.MdtrtCertType == "03" {
  9333. 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)
  9334. }
  9335. var dat map[string]interface{}
  9336. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9337. fmt.Println(dat)
  9338. } else {
  9339. fmt.Println(err)
  9340. }
  9341. userJSONBytes, _ := json.Marshal(dat)
  9342. var res2 ResultTwo
  9343. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9344. utils.ErrorLog("解析失败:%v", err)
  9345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9346. return
  9347. }
  9348. if res2.Infcode == 0 {
  9349. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9350. if err == gorm.ErrRecordNotFound {
  9351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9352. return
  9353. } else if err != nil {
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9355. return
  9356. } else {
  9357. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9358. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9359. infoStr := string(Iinfos)
  9360. idetinfoStr := string(Idetinfos)
  9361. var rf []*ResultFive
  9362. json.Unmarshal([]byte(infoStr), &rf)
  9363. var insutypes []*ResultFive
  9364. var insutype string
  9365. var is390 int = 0
  9366. var is310 int = 0
  9367. //var insuplc_admdvs string
  9368. for _, item := range rf {
  9369. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9370. insutypes = append(insutypes, item)
  9371. }
  9372. }
  9373. if len(insutypes) == 1 {
  9374. insutype = insutypes[0].Insutype
  9375. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9376. } else {
  9377. for _, i := range insutypes {
  9378. if i.Insutype == "390" {
  9379. is390 = 1
  9380. }
  9381. if i.Insutype == "310" {
  9382. is310 = 1
  9383. }
  9384. }
  9385. }
  9386. if is390 == 1 {
  9387. insutype = "390"
  9388. }
  9389. if is310 == 1 {
  9390. insutype = "310"
  9391. }
  9392. if len(insutypes) == 0 {
  9393. insutype = "310"
  9394. }
  9395. psn := &models.HisPsn{
  9396. PsnNo: res2.Output.Baseinfo.PsnNo,
  9397. PatientId: patient.ID,
  9398. //Brdy: res2.Output.Baseinfo.Brdy,
  9399. Certno: res2.Output.Baseinfo.Certno,
  9400. Gend: res2.Output.Baseinfo.Gend,
  9401. Naty: res2.Output.Baseinfo.Naty,
  9402. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9403. PsnName: res2.Output.Baseinfo.PsnName,
  9404. Idetinfo: idetinfoStr,
  9405. Insuinfo: infoStr,
  9406. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9407. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9408. VerifyNumber: res.Output.EcToken,
  9409. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9410. }
  9411. service.CreateHisPsn(psn)
  9412. var balc float64
  9413. for _, item := range rf {
  9414. if item.Insutype == insutype {
  9415. balc = item.Balc
  9416. }
  9417. }
  9418. c.ServeSuccessJSON(map[string]interface{}{
  9419. "patient": patient,
  9420. "number": res.Output.CardNo,
  9421. "insutype": insutype,
  9422. "blac": balc,
  9423. "desc": idetinfoStr,
  9424. })
  9425. }
  9426. } else {
  9427. c.ServeSuccessJSON(map[string]interface{}{
  9428. "failed_code": -10,
  9429. "msg": res2.ErrMsg,
  9430. })
  9431. }
  9432. } else {
  9433. c.ServeSuccessJSON(map[string]interface{}{
  9434. "failed_code": -10,
  9435. "msg": res.ErrMsg,
  9436. })
  9437. }
  9438. } else {
  9439. SFZStr := c.GetSFZBaseInfo()
  9440. id_card_str := strings.Split(SFZStr, "^")
  9441. id_card_number := id_card_str[0]
  9442. card_sn := ""
  9443. 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)
  9444. var dat map[string]interface{}
  9445. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9446. fmt.Println(dat)
  9447. } else {
  9448. fmt.Println(err)
  9449. }
  9450. userJSONBytes, _ := json.Marshal(dat)
  9451. var res ResultTwo
  9452. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9453. utils.ErrorLog("解析失败:%v", err)
  9454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9455. return
  9456. }
  9457. if res.Infcode == 0 {
  9458. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9459. if err == gorm.ErrRecordNotFound {
  9460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9461. return
  9462. } else if err != nil {
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9464. return
  9465. } else {
  9466. c.ServeSuccessJSON(map[string]interface{}{
  9467. "patient": patient,
  9468. "number": id_card_number,
  9469. })
  9470. }
  9471. } else {
  9472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9473. return
  9474. }
  9475. }
  9476. break
  9477. case 3:
  9478. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9479. var api string
  9480. if miConfig.MdtrtareaAdmvs == "320921" {
  9481. 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 +
  9482. "&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
  9483. fmt.Println(api)
  9484. } else {
  9485. 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 +
  9486. "&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)
  9487. }
  9488. resp, requestErr := http.Get(api)
  9489. if requestErr != nil {
  9490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9491. return
  9492. }
  9493. body, ioErr := ioutil.ReadAll(resp.Body)
  9494. if ioErr != nil {
  9495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9497. return
  9498. }
  9499. var respJSON map[string]interface{}
  9500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9503. return
  9504. }
  9505. var status string
  9506. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9507. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9508. var token string
  9509. var res ResultTwo //1101结果
  9510. var res10265 ResultTwo10265 //1101结果
  9511. var card_info string //卡信息
  9512. var busi_card_info string
  9513. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9514. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9515. if status == "0" { //读卡成功
  9516. if card_type == "1" {
  9517. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9518. result, _ := json.Marshal(respJSON)
  9519. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9520. utils.ErrorLog("解析失败:%v", err)
  9521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. return
  9523. }
  9524. res.ErrMsg = res10265.ErrMsg
  9525. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9526. res.Infcode = infocode
  9527. res.Output = res10265.Output
  9528. res.InfRefmsgid = res10265.InfRefmsgid
  9529. } else {
  9530. //var card_info string //卡信息
  9531. //var busi_card_info string
  9532. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9533. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9534. //fmt.Println(card_info)
  9535. //fmt.Println(busi_card_info)
  9536. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9537. result, _ := json.Marshal(respJSON)
  9538. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9539. utils.ErrorLog("解析失败:%v", err)
  9540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9541. return
  9542. }
  9543. res.ErrMsg = res10265.ErrMsg
  9544. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9545. res.Infcode = infocode
  9546. res.Output = res10265.Output
  9547. res.InfRefmsgid = res10265.InfRefmsgid
  9548. }
  9549. if res.Infcode == 0 {
  9550. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9551. if err == gorm.ErrRecordNotFound {
  9552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9553. return
  9554. } else if err != nil {
  9555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9556. return
  9557. } else {
  9558. if card_type == "1" {
  9559. bas := strings.Split(card_info, "|")
  9560. basNumber := bas[2]
  9561. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9562. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9563. infoStr := string(Iinfos)
  9564. idetinfoStr := string(Idetinfos)
  9565. psn := &models.HisPsn{
  9566. PsnNo: res.Output.Baseinfo.PsnNo,
  9567. PatientId: patient.ID,
  9568. Certno: res.Output.Baseinfo.Certno,
  9569. //Brdy: res.Output.Baseinfo.Brdy,
  9570. Gend: res.Output.Baseinfo.Gend,
  9571. Naty: res.Output.Baseinfo.Naty,
  9572. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9573. PsnName: res.Output.Baseinfo.PsnName,
  9574. Idetinfo: idetinfoStr,
  9575. Insuinfo: infoStr,
  9576. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9577. CardInfo: card_info,
  9578. VerifyNumber: busi_card_info,
  9579. }
  9580. service.CreateHisPsn(psn)
  9581. c.ServeSuccessJSON(map[string]interface{}{
  9582. "patient": patient,
  9583. "number": basNumber,
  9584. })
  9585. } else {
  9586. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9587. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9588. infoStr := string(Iinfos)
  9589. idetinfoStr := string(Idetinfos)
  9590. psn := &models.HisPsn{
  9591. PsnNo: res.Output.Baseinfo.PsnNo,
  9592. PatientId: patient.ID,
  9593. Certno: res.Output.Baseinfo.Certno,
  9594. Gend: res.Output.Baseinfo.Gend,
  9595. Naty: res.Output.Baseinfo.Naty,
  9596. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9597. PsnName: res.Output.Baseinfo.PsnName,
  9598. Idetinfo: idetinfoStr,
  9599. Insuinfo: infoStr,
  9600. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9601. CardInfo: card_info,
  9602. VerifyNumber: token,
  9603. }
  9604. service.CreateHisPsn(psn)
  9605. var rf []*ResultFive
  9606. json.Unmarshal([]byte(infoStr), &rf)
  9607. var insutypes []*ResultFive
  9608. var insutype string
  9609. var is390 int = 0
  9610. var is310 int = 0
  9611. for _, item := range rf {
  9612. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9613. insutypes = append(insutypes, item)
  9614. }
  9615. }
  9616. if len(insutypes) == 1 {
  9617. insutype = insutypes[0].Insutype
  9618. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9619. } else {
  9620. for _, i := range insutypes {
  9621. if i.Insutype == "390" {
  9622. is390 = 1
  9623. }
  9624. if i.Insutype == "310" {
  9625. is310 = 1
  9626. }
  9627. }
  9628. }
  9629. if is390 == 1 {
  9630. insutype = "390"
  9631. }
  9632. if is310 == 1 {
  9633. insutype = "310"
  9634. }
  9635. if len(insutypes) == 0 {
  9636. insutype = "310"
  9637. }
  9638. c.ServeSuccessJSON(map[string]interface{}{
  9639. "patient": patient,
  9640. "number": token,
  9641. "insutype": insutype,
  9642. })
  9643. }
  9644. }
  9645. } else {
  9646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9647. return
  9648. }
  9649. } else { //读卡失败
  9650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9651. return
  9652. }
  9653. }
  9654. break
  9655. case 4:
  9656. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9657. var api string
  9658. if miConfig.MdtrtareaAdmvs == "320921" {
  9659. 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 +
  9660. "&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
  9661. fmt.Println(api)
  9662. } else {
  9663. 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 +
  9664. "&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)
  9665. }
  9666. resp, requestErr := http.Get(api)
  9667. if requestErr != nil {
  9668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9669. return
  9670. }
  9671. body, ioErr := ioutil.ReadAll(resp.Body)
  9672. if ioErr != nil {
  9673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9675. return
  9676. }
  9677. var respJSON map[string]interface{}
  9678. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9679. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9681. return
  9682. }
  9683. var status string
  9684. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9685. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9686. var token string
  9687. var res ResultTwo //1101结果
  9688. var res10265 ResultTwo10265 //1101结果
  9689. if status == "0" { //读卡成功
  9690. var card_info string //卡信息
  9691. var busi_card_info string
  9692. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9693. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9694. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9695. fmt.Println(card_info)
  9696. fmt.Println(busi_card_info)
  9697. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9698. result, _ := json.Marshal(respJSON)
  9699. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9700. utils.ErrorLog("解析失败:%v", err)
  9701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9702. return
  9703. }
  9704. res.ErrMsg = res10265.ErrMsg
  9705. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9706. res.Infcode = infocode
  9707. res.Output = res10265.Output
  9708. res.InfRefmsgid = res10265.InfRefmsgid
  9709. if res.Infcode == 0 {
  9710. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9711. if err == gorm.ErrRecordNotFound {
  9712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9713. return
  9714. } else if err != nil {
  9715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9716. return
  9717. } else {
  9718. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9719. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9720. infoStr := string(Iinfos)
  9721. idetinfoStr := string(Idetinfos)
  9722. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9723. psn := &models.HisPsn{
  9724. PsnNo: res.Output.Baseinfo.PsnNo,
  9725. PatientId: patient.ID,
  9726. Certno: res.Output.Baseinfo.Certno,
  9727. Brdy: b,
  9728. Age: float64(age),
  9729. //Brdy: res.Output.Baseinfo.Brdy,
  9730. Gend: res.Output.Baseinfo.Gend,
  9731. Naty: res.Output.Baseinfo.Naty,
  9732. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9733. PsnName: res.Output.Baseinfo.PsnName,
  9734. Idetinfo: idetinfoStr,
  9735. Insuinfo: infoStr,
  9736. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9737. CardInfo: card_info,
  9738. VerifyNumber: token,
  9739. }
  9740. var rf []*ResultFive
  9741. json.Unmarshal([]byte(infoStr), &rf)
  9742. var insutypes []*ResultFive
  9743. var insutype string
  9744. var is390 int = 0
  9745. var is310 int = 0
  9746. for _, item := range rf {
  9747. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9748. insutypes = append(insutypes, item)
  9749. }
  9750. }
  9751. if len(insutypes) == 1 {
  9752. insutype = insutypes[0].Insutype
  9753. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9754. } else {
  9755. for _, i := range insutypes {
  9756. if i.Insutype == "390" {
  9757. is390 = 1
  9758. }
  9759. if i.Insutype == "310" {
  9760. is310 = 1
  9761. }
  9762. }
  9763. }
  9764. if is390 == 1 {
  9765. insutype = "390"
  9766. }
  9767. if is310 == 1 {
  9768. insutype = "310"
  9769. }
  9770. if len(insutypes) == 0 {
  9771. insutype = "310"
  9772. }
  9773. service.CreateHisPsn(psn)
  9774. c.ServeSuccessJSON(map[string]interface{}{
  9775. "patient": patient,
  9776. "number": token,
  9777. "insutype": insutype,
  9778. })
  9779. }
  9780. } else {
  9781. c.ServeSuccessJSON(map[string]interface{}{
  9782. "failed_code": -10,
  9783. "msg": res.ErrMsg,
  9784. })
  9785. }
  9786. } else { //读卡失败
  9787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9788. return
  9789. }
  9790. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9791. var api string
  9792. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9793. "&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
  9794. resp, requestErr := http.Get(api)
  9795. if requestErr != nil {
  9796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. return
  9798. }
  9799. body, ioErr := ioutil.ReadAll(resp.Body)
  9800. if ioErr != nil {
  9801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9803. return
  9804. }
  9805. var respJSON map[string]interface{}
  9806. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9809. return
  9810. }
  9811. var status string
  9812. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9813. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9814. var token string
  9815. var res ResultTwo //1101结果
  9816. if status == "1" { //读卡成功
  9817. var card_info string //卡信息
  9818. var busi_card_info string
  9819. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9820. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9821. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9822. fmt.Println(card_info)
  9823. fmt.Println(busi_card_info)
  9824. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9825. result, _ := json.Marshal(respJSON)
  9826. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9827. utils.ErrorLog("解析失败:%v", err)
  9828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9829. return
  9830. }
  9831. if res.Infcode == 0 {
  9832. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9833. if err == gorm.ErrRecordNotFound {
  9834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9835. return
  9836. } else if err != nil {
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9838. return
  9839. } else {
  9840. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9841. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9842. infoStr := string(Iinfos)
  9843. idetinfoStr := string(Idetinfos)
  9844. psn := &models.HisPsn{
  9845. PsnNo: res.Output.Baseinfo.PsnNo,
  9846. PatientId: patient.ID,
  9847. Certno: res.Output.Baseinfo.Certno,
  9848. Gend: res.Output.Baseinfo.Gend,
  9849. Naty: res.Output.Baseinfo.Naty,
  9850. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9851. PsnName: res.Output.Baseinfo.PsnName,
  9852. Idetinfo: idetinfoStr,
  9853. Insuinfo: infoStr,
  9854. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9855. CardInfo: card_info,
  9856. VerifyNumber: token,
  9857. }
  9858. var rf []*ResultFive
  9859. json.Unmarshal([]byte(infoStr), &rf)
  9860. var insutypes []*ResultFive
  9861. var insutype string
  9862. var is390 int = 0
  9863. var is310 int = 0
  9864. for _, item := range rf {
  9865. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9866. insutypes = append(insutypes, item)
  9867. }
  9868. }
  9869. if len(insutypes) == 1 {
  9870. insutype = insutypes[0].Insutype
  9871. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9872. } else {
  9873. for _, i := range insutypes {
  9874. if i.Insutype == "390" {
  9875. is390 = 1
  9876. }
  9877. if i.Insutype == "310" {
  9878. is310 = 1
  9879. }
  9880. }
  9881. }
  9882. if is390 == 1 {
  9883. insutype = "390"
  9884. }
  9885. if is310 == 1 {
  9886. insutype = "310"
  9887. }
  9888. if len(insutypes) == 0 {
  9889. insutype = "310"
  9890. }
  9891. service.CreateHisPsn(psn)
  9892. c.ServeSuccessJSON(map[string]interface{}{
  9893. "patient": patient,
  9894. "number": token,
  9895. "insutype": insutype,
  9896. })
  9897. }
  9898. } else {
  9899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9900. return
  9901. }
  9902. } else { //读卡失败
  9903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9904. return
  9905. }
  9906. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9907. idNo := c.GetString("idNo")
  9908. userName := c.GetString("userName")
  9909. ecToken := c.GetString("ecToken")
  9910. insuOrg := c.GetString("insuOrg")
  9911. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9912. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9913. var res ResultTwo
  9914. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9915. utils.ErrorLog("解析失败:%v", err)
  9916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9917. return
  9918. }
  9919. if res.Infcode == 0 {
  9920. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9921. if err == gorm.ErrRecordNotFound {
  9922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9923. return
  9924. } else if err != nil {
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9926. return
  9927. } else {
  9928. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9929. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9930. infoStr := string(Iinfos)
  9931. idetinfoStr := string(Idetinfos)
  9932. psn := &models.HisPsn{
  9933. PsnNo: res.Output.Baseinfo.PsnNo,
  9934. PatientId: patient.ID,
  9935. Certno: res.Output.Baseinfo.Certno,
  9936. Gend: res.Output.Baseinfo.Gend,
  9937. Naty: res.Output.Baseinfo.Naty,
  9938. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9939. PsnName: res.Output.Baseinfo.PsnName,
  9940. Idetinfo: idetinfoStr,
  9941. Insuinfo: infoStr,
  9942. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9943. CardInfo: "",
  9944. Stage: "1",
  9945. VerifyNumber: ecToken,
  9946. InsuplcAdmdvs: insuOrg,
  9947. }
  9948. service.CreateHisPsn(psn)
  9949. var rf []*ResultFive
  9950. json.Unmarshal([]byte(infoStr), &rf)
  9951. var insutypes []*ResultFive
  9952. var insutype string
  9953. var is390 int = 0
  9954. var is310 int = 0
  9955. for _, item := range rf {
  9956. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9957. insutypes = append(insutypes, item)
  9958. }
  9959. }
  9960. if len(insutypes) == 1 {
  9961. insutype = insutypes[0].Insutype
  9962. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9963. } else {
  9964. for _, i := range insutypes {
  9965. if i.Insutype == "390" {
  9966. is390 = 1
  9967. }
  9968. if i.Insutype == "310" {
  9969. is310 = 1
  9970. }
  9971. }
  9972. }
  9973. if is390 == 1 {
  9974. insutype = "390"
  9975. }
  9976. if is310 == 1 {
  9977. insutype = "310"
  9978. }
  9979. if len(insutypes) == 0 {
  9980. insutype = "310"
  9981. }
  9982. c.ServeSuccessJSON(map[string]interface{}{
  9983. "patient": patient,
  9984. "number": ecToken,
  9985. "insutype": insutype,
  9986. })
  9987. }
  9988. } else {
  9989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9990. return
  9991. }
  9992. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9993. //if initFlag == 0 {
  9994. //c.TestGetJiangXiBasBaseInit()
  9995. //}
  9996. //if initEleFlag == 0 {
  9997. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9998. //}
  9999. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10000. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10001. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10002. type ELeData struct {
  10003. Data struct {
  10004. IdNo string `json:"idNo"`
  10005. IdType string `json:"idType"`
  10006. UserName string `json:"userName"`
  10007. EcToken string `json:"ecToken"`
  10008. InsuOrg string `json:"insuOrg"`
  10009. Gender string `json:"gender"`
  10010. Birthday string `json:"birthday"`
  10011. Nationality string `json:"nationality"`
  10012. Email string `json:"email"`
  10013. Extra string `json:"extra"`
  10014. } `json:"data"`
  10015. Code int `json:"code"`
  10016. Message string `json:"message"`
  10017. }
  10018. var ele ELeData
  10019. err := json.Unmarshal([]byte(result), &ele)
  10020. if err != nil {
  10021. utils.ErrorLog("解析失败:%v", err)
  10022. }
  10023. token := ele.Data.EcToken
  10024. token = Remove0000(token)
  10025. 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)
  10026. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10027. var res ResultTwo
  10028. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10029. utils.ErrorLog("解析失败:%v", err)
  10030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10031. return
  10032. }
  10033. if res.Infcode == 0 {
  10034. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10035. if err == gorm.ErrRecordNotFound {
  10036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10037. return
  10038. } else if err != nil {
  10039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10040. return
  10041. } else {
  10042. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10043. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10044. infoStr := string(Iinfos)
  10045. idetinfoStr := string(Idetinfos)
  10046. psn := &models.HisPsn{
  10047. PsnNo: res.Output.Baseinfo.PsnNo,
  10048. PatientId: patient.ID,
  10049. Certno: res.Output.Baseinfo.Certno,
  10050. Gend: res.Output.Baseinfo.Gend,
  10051. Naty: res.Output.Baseinfo.Naty,
  10052. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10053. PsnName: res.Output.Baseinfo.PsnName,
  10054. Idetinfo: idetinfoStr,
  10055. Insuinfo: infoStr,
  10056. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10057. CardInfo: "",
  10058. VerifyNumber: token,
  10059. }
  10060. service.CreateHisPsn(psn)
  10061. var rf []*ResultFive
  10062. json.Unmarshal([]byte(infoStr), &rf)
  10063. var insutypes []*ResultFive
  10064. var insutype string
  10065. var is390 int = 0
  10066. var is310 int = 0
  10067. for _, item := range rf {
  10068. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10069. insutypes = append(insutypes, item)
  10070. }
  10071. }
  10072. if len(insutypes) == 1 {
  10073. insutype = insutypes[0].Insutype
  10074. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10075. } else {
  10076. for _, i := range insutypes {
  10077. if i.Insutype == "390" {
  10078. is390 = 1
  10079. }
  10080. if i.Insutype == "310" {
  10081. is310 = 1
  10082. }
  10083. }
  10084. }
  10085. if is390 == 1 {
  10086. insutype = "390"
  10087. }
  10088. if is310 == 1 {
  10089. insutype = "310"
  10090. }
  10091. if len(insutypes) == 0 {
  10092. insutype = "310"
  10093. }
  10094. c.ServeSuccessJSON(map[string]interface{}{
  10095. "patient": patient,
  10096. "number": token,
  10097. "insutype": insutype,
  10098. })
  10099. }
  10100. } else {
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10102. return
  10103. }
  10104. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10105. //if initFlag == 0 {
  10106. c.TestGetJiangXiBasBaseInit()
  10107. //}
  10108. //if initEleFlag == 0 {
  10109. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10110. //}
  10111. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10112. type ELeData struct {
  10113. Data struct {
  10114. IdNo string `json:"idNo"`
  10115. IdType string `json:"idType"`
  10116. UserName string `json:"userName"`
  10117. EcToken string `json:"ecToken"`
  10118. InsuOrg string `json:"insuOrg"`
  10119. Gender string `json:"gender"`
  10120. Birthday string `json:"birthday"`
  10121. Nationality string `json:"nationality"`
  10122. Email string `json:"email"`
  10123. Extra string `json:"extra"`
  10124. } `json:"data"`
  10125. Code int `json:"code"`
  10126. Message string `json:"message"`
  10127. }
  10128. var ele ELeData
  10129. err := json.Unmarshal([]byte(json_result), &ele)
  10130. if err != nil {
  10131. utils.ErrorLog("解析失败:%v", err)
  10132. }
  10133. token := ele.Data.EcToken
  10134. token = Remove0000(token)
  10135. 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)
  10136. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10137. var res ResultTwo
  10138. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10139. utils.ErrorLog("解析失败:%v", err)
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return
  10142. }
  10143. if res.Infcode == 0 {
  10144. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10145. if err == gorm.ErrRecordNotFound {
  10146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10147. return
  10148. } else if err != nil {
  10149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10150. return
  10151. } else {
  10152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10154. infoStr := string(Iinfos)
  10155. idetinfoStr := string(Idetinfos)
  10156. psn := &models.HisPsn{
  10157. PsnNo: res.Output.Baseinfo.PsnNo,
  10158. PatientId: patient.ID,
  10159. Certno: res.Output.Baseinfo.Certno,
  10160. Gend: res.Output.Baseinfo.Gend,
  10161. Naty: res.Output.Baseinfo.Naty,
  10162. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10163. PsnName: res.Output.Baseinfo.PsnName,
  10164. Idetinfo: idetinfoStr,
  10165. Insuinfo: infoStr,
  10166. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10167. CardInfo: "",
  10168. VerifyNumber: token,
  10169. }
  10170. service.CreateHisPsn(psn)
  10171. var rf []*ResultFive
  10172. json.Unmarshal([]byte(infoStr), &rf)
  10173. var insutypes []*ResultFive
  10174. var insutype string
  10175. var is390 int = 0
  10176. var is310 int = 0
  10177. for _, item := range rf {
  10178. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10179. insutypes = append(insutypes, item)
  10180. }
  10181. }
  10182. if len(insutypes) == 1 {
  10183. insutype = insutypes[0].Insutype
  10184. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10185. } else {
  10186. for _, i := range insutypes {
  10187. if i.Insutype == "390" {
  10188. is390 = 1
  10189. }
  10190. if i.Insutype == "310" {
  10191. is310 = 1
  10192. }
  10193. }
  10194. }
  10195. if is390 == 1 {
  10196. insutype = "390"
  10197. }
  10198. if is310 == 1 {
  10199. insutype = "310"
  10200. }
  10201. if len(insutypes) == 0 {
  10202. insutype = "310"
  10203. }
  10204. c.ServeSuccessJSON(map[string]interface{}{
  10205. "patient": patient,
  10206. "number": token,
  10207. "insutype": insutype,
  10208. })
  10209. }
  10210. } else {
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10212. return
  10213. }
  10214. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10215. type ELeData struct {
  10216. Code string `json:"code"`
  10217. Data struct {
  10218. Aac002 string `json:"aac002"`
  10219. Aaz500 string `json:"aaz500"`
  10220. ActCardNo string `json:"actCardNo"`
  10221. Bab520 string `json:"bab520"`
  10222. Bkz543 string `json:"bkz543"`
  10223. BusinessType string `json:"businessType"`
  10224. CertfCodg string `json:"certfCodg"`
  10225. EcIndexNo string `json:"ecIndexNo"`
  10226. EcToken string `json:"ecToken"`
  10227. ID0000 string `json:"id0000"`
  10228. IDNo string `json:"idNo"`
  10229. IDType string `json:"idType"`
  10230. Idcode string `json:"idcode"`
  10231. IdentityToken string `json:"identity_token"`
  10232. InsuOrg string `json:"insuOrg"`
  10233. OfficeID string `json:"officeId"`
  10234. OfficeName string `json:"officeName"`
  10235. OperatorID string `json:"operatorId"`
  10236. OperatorName string `json:"operatorName"`
  10237. OrgID string `json:"orgId"`
  10238. UserName string `json:"userName"`
  10239. } `json:"data"`
  10240. Infno interface{} `json:"infno"`
  10241. Message string `json:"message"`
  10242. OrgID string `json:"orgId"`
  10243. TransType string `json:"transType"`
  10244. }
  10245. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10246. outPutInfo = Remove0000(outPutInfo)
  10247. if len(outPutInfo) > 0 {
  10248. var ele ELeData
  10249. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10250. if err != nil {
  10251. utils.ErrorLog("解析失败:%v", err)
  10252. }
  10253. token := ele.Data.EcToken
  10254. fmt.Println(inputInfo)
  10255. fmt.Println(outPutInfo)
  10256. 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)
  10257. saveLog(result, requestLog, "1101", "获取人员信息")
  10258. var dat map[string]interface{}
  10259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10260. fmt.Println(dat)
  10261. } else {
  10262. fmt.Println(err)
  10263. }
  10264. userJSONBytes, _ := json.Marshal(dat)
  10265. var res ResultTwo
  10266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10267. utils.ErrorLog("解析失败:%v", err)
  10268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10269. return
  10270. }
  10271. res.ErrMsg = errMsgLog
  10272. if res.Infcode == 0 {
  10273. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10274. if err == gorm.ErrRecordNotFound {
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10276. return
  10277. } else if err != nil {
  10278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10279. return
  10280. } else {
  10281. fmt.Println(res)
  10282. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10283. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10284. infoStr := string(Iinfos)
  10285. idetinfoStr := string(Idetinfos)
  10286. psn := &models.HisPsn{
  10287. PsnNo: res.Output.Baseinfo.PsnNo,
  10288. PatientId: patient.ID,
  10289. Certno: res.Output.Baseinfo.Certno,
  10290. Gend: res.Output.Baseinfo.Gend,
  10291. Naty: res.Output.Baseinfo.Naty,
  10292. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10293. PsnName: res.Output.Baseinfo.PsnName,
  10294. Idetinfo: idetinfoStr,
  10295. Insuinfo: infoStr,
  10296. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10297. CardInfo: outPutInfo,
  10298. VerifyNumber: token,
  10299. InsuplcAdmdvs: ele.Data.InsuOrg,
  10300. }
  10301. service.CreateHisPsn(psn)
  10302. var rf []*ResultFive
  10303. json.Unmarshal([]byte(infoStr), &rf)
  10304. var insutypes []*ResultFive
  10305. var insutype string
  10306. var is390 int = 0
  10307. var is310 int = 0
  10308. for _, item := range rf {
  10309. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10310. insutypes = append(insutypes, item)
  10311. }
  10312. }
  10313. if len(insutypes) == 1 {
  10314. insutype = insutypes[0].Insutype
  10315. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10316. } else {
  10317. for _, i := range insutypes {
  10318. if i.Insutype == "390" {
  10319. is390 = 1
  10320. }
  10321. if i.Insutype == "310" {
  10322. is310 = 1
  10323. }
  10324. }
  10325. }
  10326. if is390 == 1 {
  10327. insutype = "390"
  10328. }
  10329. if is310 == 1 {
  10330. insutype = "310"
  10331. }
  10332. if len(insutypes) == 0 {
  10333. insutype = "310"
  10334. }
  10335. c.ServeSuccessJSON(map[string]interface{}{
  10336. "patient": patient,
  10337. "number": token,
  10338. "insutype": insutype,
  10339. })
  10340. }
  10341. } else {
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10343. return
  10344. }
  10345. }
  10346. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10347. var api string
  10348. 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 +
  10349. "&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
  10350. resp, requestErr := http.Get(api)
  10351. if requestErr != nil {
  10352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10353. return
  10354. }
  10355. body, ioErr := ioutil.ReadAll(resp.Body)
  10356. if ioErr != nil {
  10357. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10359. return
  10360. }
  10361. var respJSON map[string]interface{}
  10362. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10365. return
  10366. }
  10367. var status string
  10368. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10369. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10370. var token string
  10371. var res ResultTwo //1101结果
  10372. var res10265 ResultTwo10265 //1101结果
  10373. if status == "0" { //读卡成功
  10374. var card_info string //卡信息
  10375. var busi_card_info string
  10376. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10377. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10378. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10379. fmt.Println(card_info)
  10380. fmt.Println(busi_card_info)
  10381. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10382. result, _ := json.Marshal(respJSON)
  10383. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10384. utils.ErrorLog("解析失败:%v", err)
  10385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10386. return
  10387. }
  10388. res.ErrMsg = res10265.ErrMsg
  10389. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10390. res.Infcode = infocode
  10391. res.Output = res10265.Output
  10392. res.InfRefmsgid = res10265.InfRefmsgid
  10393. if res.Infcode == 0 {
  10394. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10395. if err == gorm.ErrRecordNotFound {
  10396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10397. return
  10398. } else if err != nil {
  10399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10400. return
  10401. } else {
  10402. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10403. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10404. infoStr := string(Iinfos)
  10405. idetinfoStr := string(Idetinfos)
  10406. psn := &models.HisPsn{
  10407. PsnNo: res.Output.Baseinfo.PsnNo,
  10408. PatientId: patient.ID,
  10409. Certno: res.Output.Baseinfo.Certno,
  10410. Gend: res.Output.Baseinfo.Gend,
  10411. Naty: res.Output.Baseinfo.Naty,
  10412. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10413. PsnName: res.Output.Baseinfo.PsnName,
  10414. Idetinfo: idetinfoStr,
  10415. Insuinfo: infoStr,
  10416. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10417. CardInfo: card_info,
  10418. VerifyNumber: token,
  10419. }
  10420. var rf []*ResultFive
  10421. json.Unmarshal([]byte(infoStr), &rf)
  10422. var insutypes []*ResultFive
  10423. var insutype string
  10424. var is390 int = 0
  10425. var is310 int = 0
  10426. for _, item := range rf {
  10427. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10428. insutypes = append(insutypes, item)
  10429. }
  10430. }
  10431. if len(insutypes) == 1 {
  10432. insutype = insutypes[0].Insutype
  10433. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10434. } else {
  10435. for _, i := range insutypes {
  10436. if i.Insutype == "390" {
  10437. is390 = 1
  10438. }
  10439. if i.Insutype == "310" {
  10440. is310 = 1
  10441. }
  10442. }
  10443. }
  10444. if is390 == 1 {
  10445. insutype = "390"
  10446. }
  10447. if is310 == 1 {
  10448. insutype = "310"
  10449. }
  10450. if len(insutypes) == 0 {
  10451. insutype = "310"
  10452. }
  10453. service.CreateHisPsn(psn)
  10454. c.ServeSuccessJSON(map[string]interface{}{
  10455. "patient": patient,
  10456. "number": token,
  10457. "insutype": insutype,
  10458. })
  10459. }
  10460. } else {
  10461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10462. return
  10463. }
  10464. } else { //读卡失败
  10465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10466. return
  10467. }
  10468. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10469. res := c.GetoleInfo()
  10470. if res.Infcode == 0 {
  10471. var result string
  10472. if res.Output.MdtrtCertType == "01" {
  10473. 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)
  10474. } else if res.Output.MdtrtCertType == "02" {
  10475. 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)
  10476. } else if res.Output.MdtrtCertType == "03" {
  10477. 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)
  10478. }
  10479. var dat map[string]interface{}
  10480. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10481. fmt.Println(dat)
  10482. } else {
  10483. fmt.Println(err)
  10484. }
  10485. userJSONBytes, _ := json.Marshal(dat)
  10486. var res2 ResultTwo
  10487. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10488. utils.ErrorLog("解析失败:%v", err)
  10489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10490. return
  10491. }
  10492. if res2.Infcode == 0 {
  10493. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10494. if err == gorm.ErrRecordNotFound {
  10495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10496. return
  10497. } else if err != nil {
  10498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10499. return
  10500. } else {
  10501. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10502. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10503. infoStr := string(Iinfos)
  10504. idetinfoStr := string(Idetinfos)
  10505. var rf []*ResultFive
  10506. json.Unmarshal([]byte(infoStr), &rf)
  10507. var insutypes []*ResultFive
  10508. var insutype string
  10509. var is390 int = 0
  10510. var is310 int = 0
  10511. //var insuplc_admdvs string
  10512. for _, item := range rf {
  10513. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10514. insutypes = append(insutypes, item)
  10515. }
  10516. }
  10517. if len(insutypes) == 1 {
  10518. insutype = insutypes[0].Insutype
  10519. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10520. } else {
  10521. for _, i := range insutypes {
  10522. if i.Insutype == "390" {
  10523. is390 = 1
  10524. }
  10525. if i.Insutype == "310" {
  10526. is310 = 1
  10527. }
  10528. }
  10529. }
  10530. if is390 == 1 {
  10531. insutype = "390"
  10532. }
  10533. if is310 == 1 {
  10534. insutype = "310"
  10535. }
  10536. if len(insutypes) == 0 {
  10537. insutype = "310"
  10538. }
  10539. psn := &models.HisPsn{
  10540. PsnNo: res2.Output.Baseinfo.PsnNo,
  10541. PatientId: patient.ID,
  10542. Certno: res2.Output.Baseinfo.Certno,
  10543. Gend: res2.Output.Baseinfo.Gend,
  10544. Naty: res2.Output.Baseinfo.Naty,
  10545. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10546. PsnName: res2.Output.Baseinfo.PsnName,
  10547. Idetinfo: idetinfoStr,
  10548. Insuinfo: infoStr,
  10549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10550. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10551. VerifyNumber: res.Output.EcToken,
  10552. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10553. }
  10554. if res.Output.MdtrtCertType == "01" {
  10555. psn.VerifyNumber = res.Output.EcToken
  10556. //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)
  10557. } else if res.Output.MdtrtCertType == "02" {
  10558. psn.VerifyNumber = res.Output.CardNo
  10559. //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)
  10560. } else if res.Output.MdtrtCertType == "03" {
  10561. psn.VerifyNumber = res.Output.MdtrtCertNo
  10562. //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)
  10563. }
  10564. service.CreateHisPsn(psn)
  10565. var balc float64
  10566. for _, item := range rf {
  10567. if item.Insutype == insutype {
  10568. balc = item.Balc
  10569. }
  10570. }
  10571. c.ServeSuccessJSON(map[string]interface{}{
  10572. "patient": patient,
  10573. "number": res.Output.CardNo,
  10574. "insutype": insutype,
  10575. "blac": balc,
  10576. "desc": idetinfoStr,
  10577. })
  10578. }
  10579. } else {
  10580. c.ServeSuccessJSON(map[string]interface{}{
  10581. "failed_code": -10,
  10582. "msg": res2.ErrMsg,
  10583. })
  10584. }
  10585. } else {
  10586. c.ServeSuccessJSON(map[string]interface{}{
  10587. "failed_code": -10,
  10588. "msg": res.ErrMsg,
  10589. })
  10590. }
  10591. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10592. var res ResultTwo
  10593. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10594. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10595. "&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)
  10596. resp, requestErr := http.Get(api)
  10597. if requestErr != nil {
  10598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10599. return
  10600. }
  10601. body, ioErr := ioutil.ReadAll(resp.Body)
  10602. if ioErr != nil {
  10603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10605. return
  10606. }
  10607. var respJSON map[string]interface{}
  10608. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10611. return
  10612. }
  10613. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10614. result, _ := json.Marshal(respJSON)
  10615. fmt.Println("log")
  10616. fmt.Println(string(result))
  10617. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10618. utils.ErrorLog("解析失败:%v", err)
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10620. return
  10621. }
  10622. if res.Infcode == 0 {
  10623. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10624. if err == gorm.ErrRecordNotFound {
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10626. return
  10627. } else if err != nil {
  10628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10629. return
  10630. } else {
  10631. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10632. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10633. infoStr := string(Iinfos)
  10634. idetinfoStr := string(Idetinfos)
  10635. var rf []*ResultFive
  10636. json.Unmarshal([]byte(infoStr), &rf)
  10637. var insutypes []*ResultFive
  10638. var insutype string
  10639. var is390 int = 0
  10640. var is310 int = 0
  10641. for _, item := range rf {
  10642. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10643. insutypes = append(insutypes, item)
  10644. }
  10645. }
  10646. if len(insutypes) == 1 {
  10647. insutype = insutypes[0].Insutype
  10648. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10649. } else {
  10650. for _, i := range insutypes {
  10651. if i.Insutype == "390" {
  10652. is390 = 1
  10653. }
  10654. if i.Insutype == "310" {
  10655. is310 = 1
  10656. }
  10657. }
  10658. }
  10659. if is390 == 1 {
  10660. insutype = "390"
  10661. }
  10662. if is310 == 1 {
  10663. insutype = "310"
  10664. }
  10665. if len(insutypes) == 0 {
  10666. insutype = "390"
  10667. }
  10668. var insuplc_admdvs string
  10669. for _, item := range rf {
  10670. if item.Insutype == insutype {
  10671. insuplc_admdvs = item.InsuplcAdmdvs
  10672. }
  10673. }
  10674. psn := &models.HisPsn{
  10675. PsnNo: res.Output.Baseinfo.PsnNo,
  10676. PatientId: patient.ID,
  10677. Certno: res.Output.Baseinfo.Certno,
  10678. Gend: res.Output.Baseinfo.Gend,
  10679. Naty: res.Output.Baseinfo.Naty,
  10680. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10681. PsnName: res.Output.Baseinfo.PsnName,
  10682. Idetinfo: idetinfoStr,
  10683. Insuinfo: infoStr,
  10684. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10685. InsuplcAdmdvs: insuplc_admdvs,
  10686. }
  10687. service.CreateHisPsn(psn)
  10688. c.ServeSuccessJSON(map[string]interface{}{
  10689. "patient": patient,
  10690. "number": res.Output.Baseinfo.Certno,
  10691. })
  10692. }
  10693. } else {
  10694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10695. return
  10696. }
  10697. } else {
  10698. type ELeData struct {
  10699. Code string `json:"code"`
  10700. Data struct {
  10701. Aac002 string `json:"aac002"`
  10702. Aaz500 string `json:"aaz500"`
  10703. ActCardNo string `json:"actCardNo"`
  10704. Bab520 string `json:"bab520"`
  10705. Bkz543 string `json:"bkz543"`
  10706. BusinessType string `json:"businessType"`
  10707. CertfCodg string `json:"certfCodg"`
  10708. EcIndexNo string `json:"ecIndexNo"`
  10709. EcToken string `json:"ecToken"`
  10710. ID0000 string `json:"id0000"`
  10711. IDNo string `json:"idNo"`
  10712. IDType string `json:"idType"`
  10713. Idcode string `json:"idcode"`
  10714. IdentityToken string `json:"identity_token"`
  10715. InsuOrg string `json:"insuOrg"`
  10716. OfficeID string `json:"officeId"`
  10717. OfficeName string `json:"officeName"`
  10718. OperatorID string `json:"operatorId"`
  10719. OperatorName string `json:"operatorName"`
  10720. OrgID string `json:"orgId"`
  10721. UserName string `json:"userName"`
  10722. } `json:"data"`
  10723. Infno interface{} `json:"infno"`
  10724. Message string `json:"message"`
  10725. OrgID string `json:"orgId"`
  10726. TransType string `json:"transType"`
  10727. }
  10728. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10729. fmt.Println(result)
  10730. outPutInfo := Remove0000(result)
  10731. fmt.Println(outPutInfo)
  10732. if len(outPutInfo) > 0 {
  10733. var ele ELeData
  10734. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10735. if err != nil {
  10736. utils.ErrorLog("解析失败:%v", err)
  10737. }
  10738. token := ele.Data.EcToken
  10739. fmt.Println(outPutInfo)
  10740. 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)
  10741. saveLog(result, requestLog, "1101", "获取人员信息")
  10742. var dat map[string]interface{}
  10743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10744. fmt.Println(dat)
  10745. } else {
  10746. fmt.Println(err)
  10747. }
  10748. userJSONBytes, _ := json.Marshal(dat)
  10749. var res ResultTwo
  10750. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10751. utils.ErrorLog("解析失败:%v", err)
  10752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10753. return
  10754. }
  10755. if res.Infcode == 0 {
  10756. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10757. if err == gorm.ErrRecordNotFound {
  10758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10759. return
  10760. } else if err != nil {
  10761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10762. return
  10763. } else {
  10764. fmt.Println(res)
  10765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10767. infoStr := string(Iinfos)
  10768. idetinfoStr := string(Idetinfos)
  10769. psn := &models.HisPsn{
  10770. PsnNo: res.Output.Baseinfo.PsnNo,
  10771. PatientId: patient.ID,
  10772. Certno: res.Output.Baseinfo.Certno,
  10773. Gend: res.Output.Baseinfo.Gend,
  10774. Naty: res.Output.Baseinfo.Naty,
  10775. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10776. PsnName: res.Output.Baseinfo.PsnName,
  10777. Idetinfo: idetinfoStr,
  10778. Insuinfo: infoStr,
  10779. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10780. CardInfo: outPutInfo,
  10781. VerifyNumber: token,
  10782. InsuplcAdmdvs: ele.Data.InsuOrg,
  10783. }
  10784. service.CreateHisPsn(psn)
  10785. var rf []*ResultFive
  10786. json.Unmarshal([]byte(infoStr), &rf)
  10787. var insutypes []*ResultFive
  10788. var insutype string
  10789. var is390 int = 0
  10790. var is310 int = 0
  10791. for _, item := range rf {
  10792. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10793. insutypes = append(insutypes, item)
  10794. }
  10795. }
  10796. if len(insutypes) == 1 {
  10797. insutype = insutypes[0].Insutype
  10798. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10799. } else {
  10800. for _, i := range insutypes {
  10801. if i.Insutype == "390" {
  10802. is390 = 1
  10803. }
  10804. if i.Insutype == "310" {
  10805. is310 = 1
  10806. }
  10807. }
  10808. }
  10809. if is390 == 1 {
  10810. insutype = "390"
  10811. }
  10812. if is310 == 1 {
  10813. insutype = "310"
  10814. }
  10815. if len(insutypes) == 0 {
  10816. insutype = "310"
  10817. }
  10818. c.ServeSuccessJSON(map[string]interface{}{
  10819. "patient": patient,
  10820. "number": token,
  10821. "insutype": insutype,
  10822. })
  10823. }
  10824. } else {
  10825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10826. return
  10827. }
  10828. }
  10829. //fmt.Println(result)
  10830. //
  10831. //if initFlag == 0 {
  10832. // c.TestGetBasBaseInit()
  10833. //}
  10834. //token := c.GetEleBaseInfo()
  10835. //
  10836. //token = Remove0000(token)
  10837. //
  10838. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10839. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10840. ////
  10841. //var res ResultTwo
  10842. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10843. // utils.ErrorLog("解析失败:%v", err)
  10844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10845. // return
  10846. //}
  10847. //
  10848. //if res.Infcode == 0 {
  10849. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10850. // if err == gorm.ErrRecordNotFound {
  10851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10852. // return
  10853. // } else if err != nil {
  10854. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10855. // return
  10856. //
  10857. // } else {
  10858. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10859. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10860. // infoStr := string(Iinfos)
  10861. // idetinfoStr := string(Idetinfos)
  10862. //
  10863. //
  10864. //
  10865. //
  10866. // var rf []*ResultFive
  10867. // json.Unmarshal([]byte(infoStr), &rf)
  10868. //
  10869. // var insutypes []*ResultFive
  10870. // var insutype string
  10871. // var is390 int = 0
  10872. // var is310 int = 0
  10873. // var insuplc_admdvs string
  10874. //
  10875. // for _, item := range rf {
  10876. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10877. // insutypes = append(insutypes, item)
  10878. // }
  10879. // }
  10880. //
  10881. // if len(insutypes) == 1 {
  10882. // insutype = insutypes[0].Insutype
  10883. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10884. // } else {
  10885. // for _, i := range insutypes {
  10886. // if i.Insutype == "390" {
  10887. // is390 = 1
  10888. // }
  10889. //
  10890. // if i.Insutype == "310" {
  10891. // is310 = 1
  10892. // }
  10893. // }
  10894. // }
  10895. // if is390 == 1 {
  10896. // insutype = "390"
  10897. // }
  10898. //
  10899. // if is310 == 1 {
  10900. // insutype = "310"
  10901. // }
  10902. // if len(insutypes) == 0 {
  10903. // insutype = "310"
  10904. // }
  10905. // for _, item := range rf {
  10906. // if item.Insutype == insutype {
  10907. // insuplc_admdvs = item.InsuplcAdmdvs
  10908. // }
  10909. // }
  10910. // psn := &models.HisPsn{
  10911. // PsnNo: res.Output.Baseinfo.PsnNo,
  10912. // Age: res.Output.Baseinfo.Age,
  10913. // PatientId: patient.ID,
  10914. // Certno: res.Output.Baseinfo.Certno,
  10915. // Brdy: res.Output.Baseinfo.Brdy,
  10916. // Gend: res.Output.Baseinfo.Gend,
  10917. // Naty: res.Output.Baseinfo.Naty,
  10918. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10919. // PsnName: res.Output.Baseinfo.PsnName,
  10920. // Idetinfo: idetinfoStr,
  10921. // Insuinfo: infoStr,
  10922. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10923. // CardInfo: "",
  10924. // VerifyNumber: token,
  10925. // InsuplcAdmdvs: insuplc_admdvs,
  10926. // }
  10927. // service.CreateHisPsn(psn)
  10928. //
  10929. // c.ServeSuccessJSON(map[string]interface{}{
  10930. // "patient": patient,
  10931. // "number": token,
  10932. // })
  10933. // }
  10934. //} else {
  10935. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10936. // return
  10937. //}
  10938. }
  10939. break
  10940. case 5:
  10941. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10942. var api string
  10943. if miConfig.MdtrtareaAdmvs == "320921" {
  10944. 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 +
  10945. "&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
  10946. fmt.Println(api)
  10947. } else {
  10948. 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 +
  10949. "&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)
  10950. }
  10951. resp, requestErr := http.Get(api)
  10952. if requestErr != nil {
  10953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10954. return
  10955. }
  10956. body, ioErr := ioutil.ReadAll(resp.Body)
  10957. if ioErr != nil {
  10958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10960. return
  10961. }
  10962. var respJSON map[string]interface{}
  10963. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10966. return
  10967. }
  10968. var status string
  10969. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10970. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10971. var token string
  10972. var res ResultTwo //1101结果
  10973. var res10265 ResultTwo10265 //1101结果
  10974. if status == "0" { //读卡成功
  10975. var card_info string //卡信息
  10976. //var busi_card_info string
  10977. var auth_info string
  10978. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10979. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10980. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10981. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10982. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10983. result, _ := json.Marshal(respJSON)
  10984. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10985. utils.ErrorLog("解析失败:%v", err)
  10986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10987. return
  10988. }
  10989. res.ErrMsg = res10265.ErrMsg
  10990. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10991. res.Infcode = infocode
  10992. res.Output = res10265.Output
  10993. res.InfRefmsgid = res10265.InfRefmsgid
  10994. if res.Infcode == 0 {
  10995. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10996. if err == gorm.ErrRecordNotFound {
  10997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10998. return
  10999. } else if err != nil {
  11000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11001. return
  11002. } else {
  11003. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11004. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11005. infoStr := string(Iinfos)
  11006. idetinfoStr := string(Idetinfos)
  11007. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11008. psn := &models.HisPsn{
  11009. PsnNo: res.Output.Baseinfo.PsnNo,
  11010. PatientId: patient.ID,
  11011. Certno: res.Output.Baseinfo.Certno,
  11012. Gend: res.Output.Baseinfo.Gend,
  11013. Brdy: b,
  11014. Age: float64(age),
  11015. Naty: res.Output.Baseinfo.Naty,
  11016. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11017. PsnName: res.Output.Baseinfo.PsnName,
  11018. Idetinfo: idetinfoStr,
  11019. Insuinfo: infoStr,
  11020. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11021. CardInfo: card_info,
  11022. VerifyNumber: token,
  11023. AuthInfo: auth_info,
  11024. }
  11025. var rf []*ResultFive
  11026. json.Unmarshal([]byte(infoStr), &rf)
  11027. var insutypes []*ResultFive
  11028. var insutype string
  11029. var is390 int = 0
  11030. var is310 int = 0
  11031. for _, item := range rf {
  11032. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11033. insutypes = append(insutypes, item)
  11034. }
  11035. }
  11036. if len(insutypes) == 1 {
  11037. insutype = insutypes[0].Insutype
  11038. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11039. } else {
  11040. for _, i := range insutypes {
  11041. if i.Insutype == "390" {
  11042. is390 = 1
  11043. }
  11044. if i.Insutype == "310" {
  11045. is310 = 1
  11046. }
  11047. }
  11048. }
  11049. if is390 == 1 {
  11050. insutype = "390"
  11051. }
  11052. if is310 == 1 {
  11053. insutype = "310"
  11054. }
  11055. if len(insutypes) == 0 {
  11056. insutype = "310"
  11057. }
  11058. service.CreateHisPsn(psn)
  11059. c.ServeSuccessJSON(map[string]interface{}{
  11060. "patient": patient,
  11061. "number": token,
  11062. "insutype": insutype,
  11063. })
  11064. }
  11065. } else {
  11066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11067. return
  11068. }
  11069. } else { //读卡失败
  11070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11071. return
  11072. }
  11073. }
  11074. break
  11075. }
  11076. }
  11077. var initFlag int64 = 0
  11078. var initEleFlag int64 = 0
  11079. func (c *HisApiController) TestGetBasBaseInit() {
  11080. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11081. Iinit := DllDef.MustFindProc("Init")
  11082. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11083. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11084. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11085. if ret != 0 {
  11086. fmt.Println("SSCard的报错原因:", err)
  11087. fmt.Println("SSCard的运算结果为:", ret)
  11088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11089. return
  11090. }
  11091. result := int(ret)
  11092. fmt.Println("SSCard的运算结果为1:", result)
  11093. initFlag = 1
  11094. return
  11095. }
  11096. func (c *HisApiController) HandleJiangXiReadCard() {
  11097. fmt.Println("~~~~~~")
  11098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11099. admin_user_id, _ := c.GetInt64("admin_user_id")
  11100. id_card_type, _ := c.GetInt64("id_card_type")
  11101. //certificates, _ := c.GetInt64("certificates")
  11102. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11103. if initFlag == 0 {
  11104. c.TestGetJiangXiBasBaseInit()
  11105. }
  11106. basStr := c.GetBasBaseInfo()
  11107. if len(basStr) == 0 {
  11108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11109. return
  11110. }
  11111. fmt.Println(basStr)
  11112. bas := strings.Split(basStr, "|")
  11113. basNumber := bas[1]
  11114. fmt.Println(basNumber)
  11115. card_sn := bas[3]
  11116. fmt.Println(card_sn)
  11117. 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, "")
  11118. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11119. var dat map[string]interface{}
  11120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11121. fmt.Println(dat)
  11122. } else {
  11123. fmt.Println(err)
  11124. }
  11125. userJSONBytes, _ := json.Marshal(dat)
  11126. var res ResultTwo
  11127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11128. utils.ErrorLog("解析失败:%v", err)
  11129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11130. return
  11131. }
  11132. if res.Infcode == 0 {
  11133. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11134. if err == gorm.ErrRecordNotFound {
  11135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11136. return
  11137. } else if err != nil {
  11138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11139. return
  11140. } else {
  11141. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11142. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11143. infoStr := string(Iinfos)
  11144. idetinfoStr := string(Idetinfos)
  11145. psn := &models.HisPsn{
  11146. PsnNo: res.Output.Baseinfo.PsnNo,
  11147. PatientId: patient.ID,
  11148. Certno: res.Output.Baseinfo.Certno,
  11149. Gend: res.Output.Baseinfo.Gend,
  11150. Naty: res.Output.Baseinfo.Naty,
  11151. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11152. PsnName: res.Output.Baseinfo.PsnName,
  11153. Idetinfo: idetinfoStr,
  11154. Insuinfo: infoStr,
  11155. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11156. CardInfo: basStr,
  11157. VerifyNumber: "",
  11158. }
  11159. service.CreateHisPsn(psn)
  11160. c.ServeSuccessJSON(map[string]interface{}{
  11161. "patient": patient,
  11162. "number": basNumber,
  11163. })
  11164. }
  11165. } else {
  11166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11167. return
  11168. }
  11169. }
  11170. func (c *HisApiController) TestGetHnBasBaseInit() {
  11171. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11172. Iinit := DllDef.MustFindProc("Init")
  11173. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11174. //http://10.77.211.236/CSB/hsa-fsi-1303
  11175. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11176. if ret != 0 {
  11177. fmt.Println("SSCard的报错原因:", err)
  11178. fmt.Println("SSCard的运算结果为:", ret)
  11179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11180. return
  11181. }
  11182. result := int(ret)
  11183. fmt.Println("SSCard的运算结果为1:", result)
  11184. initFlag = 1
  11185. return
  11186. }
  11187. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11188. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11189. Iinit := DllDef.MustFindProc("Init")
  11190. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11191. //http://10.77.211.236/CSB/hsa-fsi-1303
  11192. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11193. if ret != 0 {
  11194. fmt.Println("SSCard的报错原因:", err)
  11195. fmt.Println("SSCard的运算结果为:", ret)
  11196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11197. return
  11198. }
  11199. result := int(ret)
  11200. fmt.Println("SSCard的运算结果为1:", result)
  11201. initFlag = 1
  11202. return
  11203. }
  11204. func (c *HisApiController) GetSFZBaseInfo() string {
  11205. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11206. readCard := DllDef.MustFindProc("ReadSFZ")
  11207. if readCard == nil {
  11208. fmt.Println("readcard is nil")
  11209. readCard = DllDef.MustFindProc("ReadSFZ")
  11210. }
  11211. str := make([]byte, 8096)
  11212. str1 := make([]byte, 8096)
  11213. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11214. fmt.Println(r)
  11215. return Remove0000(string(str))
  11216. }
  11217. func (c *HisApiController) GetEleBaseInfo() string {
  11218. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11219. readCard := DllDef.MustFindProc("GetQRBase")
  11220. fmt.Println(readCard)
  11221. if readCard == nil {
  11222. fmt.Println("readcard is nil")
  11223. readCard = DllDef.MustFindProc("GetQRBase")
  11224. }
  11225. str := make([]byte, 1024)
  11226. str1 := make([]byte, 1024)
  11227. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11228. fmt.Println(ret2)
  11229. fmt.Println(string(str1))
  11230. fmt.Println(string(str))
  11231. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11232. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11233. if ret2 != 0 {
  11234. return ""
  11235. }
  11236. return string(str)
  11237. }
  11238. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11239. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11240. readCard := DllDef.MustFindProc("NationEcTrans")
  11241. fmt.Println(readCard)
  11242. fmt.Println("!!!!!")
  11243. pBusiCardInfo := make([]byte, 2048)
  11244. input := make(map[string]interface{})
  11245. inputData := make(map[string]interface{})
  11246. inputData["orgId"] = code
  11247. inputData["businessType"] = "01101"
  11248. inputData["operatorId"] = "1"
  11249. inputData["operatorName"] = "admin"
  11250. inputData["officeId"] = "001"
  11251. inputData["officeName"] = "血透室"
  11252. inputData["deviceType"] = ""
  11253. input["data"] = inputData
  11254. input["orgId"] = code
  11255. input["transType"] = "ec.query"
  11256. bytesData, _ := json.Marshal(input)
  11257. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11258. fmt.Println(ret2)
  11259. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11260. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11261. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11262. }
  11263. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11264. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11265. readCard := DllDef.MustFindProc("NationEcTrans")
  11266. fmt.Println(readCard)
  11267. fmt.Println("!!!!!")
  11268. pBusiCardInfo := make([]byte, 2048)
  11269. input := make(map[string]interface{})
  11270. inputData := make(map[string]interface{})
  11271. inputData["orgId"] = code
  11272. inputData["businessType"] = "01101"
  11273. inputData["operatorId"] = "9"
  11274. inputData["operatorName"] = "admin"
  11275. inputData["officeId"] = "001"
  11276. inputData["officeName"] = "血透室"
  11277. inputData["deviceType"] = ""
  11278. input["data"] = inputData
  11279. input["orgId"] = code
  11280. input["transType"] = "ec.query"
  11281. bytesData, _ := json.Marshal(input)
  11282. 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])))
  11283. fmt.Println(ret2)
  11284. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11285. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11286. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11287. }
  11288. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11289. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11290. readCard := DllDef.MustFindProc("NationEcTrans")
  11291. fmt.Println(readCard)
  11292. fmt.Println("!!!!!")
  11293. pBusiCardInfo := make([]byte, 2048)
  11294. input := make(map[string]interface{})
  11295. inputData := make(map[string]interface{})
  11296. inputData["orgId"] = code
  11297. inputData["businessType"] = "01301"
  11298. inputData["operatorId"] = "9"
  11299. inputData["operatorName"] = "admin"
  11300. inputData["officeId"] = "001"
  11301. inputData["officeName"] = "血透室"
  11302. inputData["deviceType"] = ""
  11303. input["data"] = inputData
  11304. input["orgId"] = code
  11305. input["transType"] = "ec.query"
  11306. bytesData, _ := json.Marshal(input)
  11307. 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])))
  11308. fmt.Println(ret2)
  11309. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11310. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11311. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11312. }
  11313. func GetJxEleBaseInfo(org_id int64) string {
  11314. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11315. readCard := DllDef.MustFindProc("NationEcTrans")
  11316. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11317. if readCard == nil {
  11318. fmt.Println("readcard is nil")
  11319. readCard = DllDef.MustFindProc("NationEcTrans")
  11320. }
  11321. str1 := make([]byte, 1024)
  11322. data := make(map[string]interface{})
  11323. inputData := make(map[string]interface{})
  11324. inputData["orgId"] = miConfig.Code
  11325. inputData["businessType"] = "01101"
  11326. inputData["operatorId"] = "test001"
  11327. inputData["operatorName"] = "cn"
  11328. inputData["officeId"] = "32760"
  11329. inputData["officeName"] = "waike"
  11330. inputData["deviceType"] = ""
  11331. data["data"] = inputData
  11332. data["transType"] = "ec.query"
  11333. data["extra "] = ""
  11334. data["orgId"] = miConfig.Code
  11335. bytesData, _ := json.Marshal(data)
  11336. //bytesData, _ := json.Marshal(data)
  11337. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11338. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11339. fmt.Println(ret2)
  11340. fmt.Println(string(str1))
  11341. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11342. if ret2 != 0 {
  11343. return ""
  11344. }
  11345. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11346. }
  11347. func GetJxEleBaseInitInfo(org_id int64) string {
  11348. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11349. readCard := DllDef.MustFindProc("NationEcTrans")
  11350. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11351. if readCard == nil {
  11352. fmt.Println("readcard is nil")
  11353. readCard = DllDef.MustFindProc("NationEcTrans")
  11354. }
  11355. str1 := make([]byte, 2048)
  11356. data := make(map[string]interface{})
  11357. inputData := make(map[string]interface{})
  11358. inputData["orgId"] = miConfig.Code
  11359. inputData["businessType"] = "01101"
  11360. inputData["operatorId"] = "1"
  11361. inputData["operatorName"] = "huangchuang"
  11362. inputData["officeId"] = "101"
  11363. inputData["officeName"] = "xuetou"
  11364. inputData["deviceType"] = ""
  11365. data["data"] = inputData
  11366. data["transType"] = "ec.query"
  11367. data["orgId"] = miConfig.Code
  11368. bytesData, _ := json.Marshal(data)
  11369. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11370. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11371. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11372. fmt.Println(ret2)
  11373. fmt.Println(string(str1))
  11374. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11375. if ret2 != 0 {
  11376. return ""
  11377. }
  11378. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11379. initEleFlag = 1
  11380. }
  11381. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11382. }
  11383. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11384. // // 构建命令
  11385. // cmd := exec.Command("python", "b.py")
  11386. //
  11387. // // 执行命令并等待完成
  11388. // output, err := cmd.CombinedOutput()
  11389. // if err != nil {
  11390. // fmt.Println("Error executing Python script:", err)
  11391. // return
  11392. // }
  11393. //
  11394. // // 打印Python脚本的输出
  11395. // fmt.Println(string(output))
  11396. //}
  11397. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11398. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11399. readCard := DllDef.MustFindProc("gxyb_call")
  11400. if readCard == nil {
  11401. fmt.Println("readcard is nil")
  11402. readCard = DllDef.MustFindProc("gxyb_call")
  11403. }
  11404. str := make([]byte, 1024)
  11405. str1 := make([]byte, 1024)
  11406. //data := make(map[string]interface{})
  11407. currentTime := time.Now()
  11408. // 格式化时间为 "YYYYMMDDHH24MISS"
  11409. formattedTime := currentTime.Format("20060102150405")
  11410. inputData := make(map[string]interface{})
  11411. inputData2 := make(map[string]interface{})
  11412. inputData["transNo"] = "1401"
  11413. inputData["transType"] = "passwordCheck"
  11414. inputData["timestamp"] = formattedTime
  11415. inputData2["fixmedinsCode"] = code
  11416. inputData2["psnNo"] = ""
  11417. inputData["data"] = inputData2
  11418. jsonBytes, err := json.Marshal(inputData)
  11419. if err != nil {
  11420. fmt.Println("Error encoding map to JSON:", err)
  11421. }
  11422. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11423. fmt.Println(string(str1))
  11424. fmt.Println(string(str))
  11425. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11426. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11427. if ret2 != 0 {
  11428. return ""
  11429. }
  11430. return string(str)
  11431. }
  11432. func (c *HisApiController) GetoleInfo() Response {
  11433. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11434. defer ole.CoUninitialize()
  11435. // Replace with the ProgID or CLSID of your COM object
  11436. progID := "YinHai.XJ.Actual.Interface.New"
  11437. // Create COM object
  11438. unknown, err := oleutil.CreateObject(progID)
  11439. if err != nil {
  11440. fmt.Println("Unable to create COM object:", err)
  11441. }
  11442. defer unknown.Release()
  11443. // Query for the IDispatch interface
  11444. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11445. if err != nil {
  11446. fmt.Println("Unable to get IDispatch interface:", err)
  11447. }
  11448. defer dispatch.Release()
  11449. // Prepare parameters
  11450. transNo := "1401"
  11451. transType := "passwordCheck"
  11452. timestamp := time.Now().Unix()
  11453. fixmedinsCode := "H45072101171"
  11454. psnNo := ""
  11455. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11456. result2 := ""
  11457. // Call COM object's method using the IDispatch interface
  11458. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11459. fmt.Println(resulr)
  11460. fmt.Println(result2)
  11461. if err != nil {
  11462. fmt.Println("调用COM对象方法失败:", err)
  11463. }
  11464. var response Response
  11465. err2 := json.Unmarshal([]byte(result2), &response)
  11466. if err2 != nil {
  11467. fmt.Println("解析JSON失败:", err)
  11468. }
  11469. return response
  11470. }
  11471. func (c *HisApiController) GetBasBaseInfo() string {
  11472. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11473. readCard := DllDef.MustFindProc("ReadCardBas")
  11474. if readCard == nil {
  11475. fmt.Println("readcard is nil")
  11476. readCard = DllDef.MustFindProc("ReadCardBas")
  11477. }
  11478. str := make([]byte, 1024)
  11479. str1 := make([]byte, 1024)
  11480. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11481. fmt.Println(string(str1))
  11482. fmt.Println(string(str))
  11483. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11484. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11485. if ret2 != 0 {
  11486. return ""
  11487. }
  11488. return string(str)
  11489. }
  11490. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11491. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11492. readCard := DllDef.MustFindProc("read_cardinfo")
  11493. if readCard == nil {
  11494. fmt.Println("readcard is nil")
  11495. readCard = DllDef.MustFindProc("read_cardinfo")
  11496. }
  11497. str := make([]byte, 1024) //卡号
  11498. str1 := make([]byte, 1024) //卡识别码
  11499. str2 := make([]byte, 1024) //身份证号
  11500. str3 := make([]byte, 1024) //姓名
  11501. str4 := make([]byte, 1024) //错误信息
  11502. 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])))
  11503. fmt.Println(string(str1))
  11504. fmt.Println(string(str))
  11505. fmt.Println(string(str2))
  11506. fmt.Println(string(str3))
  11507. fmt.Println(string(str4))
  11508. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11509. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11510. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11511. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11512. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11513. if ret2 != 0 {
  11514. return "", "", "", "", ""
  11515. }
  11516. return string(str), string(str1), string(str2), string(str3), string(str4)
  11517. }
  11518. type CustomFundPay struct {
  11519. FundPayType string `json:"fund_pay_type"`
  11520. FundPayamt float64 `json:"fund_payamt"`
  11521. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11522. }
  11523. //func (c *HisApiController) GetBatchSettleList() {
  11524. // start_time_str := c.GetString("start_time")
  11525. // //end_time_str := c.GetString("end_time")
  11526. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11527. //
  11528. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11529. //
  11530. // for _, item := range orders {
  11531. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11532. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11533. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11534. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11535. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11536. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11537. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11538. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11539. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11540. //
  11541. // if order.ID == 0 {
  11542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11543. // return
  11544. // }
  11545. //
  11546. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11547. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11548. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11549. // //fmt.Println(count)
  11550. // //var zero string
  11551. // //number := count + 1
  11552. // //if number >= 1000 {
  11553. // // zero = "0000" + strconv.FormatInt(number, 10)
  11554. // //} else if number >= 10000 {
  11555. // // zero = "000" + strconv.FormatInt(number, 10)
  11556. // //} else if number >= 100000 {
  11557. // // zero = "00" + strconv.FormatInt(number, 10)
  11558. // //} else if number >= 1000000 {
  11559. // // zero = "0" + strconv.FormatInt(number, 10)
  11560. // //} else {
  11561. // // zero = strconv.FormatInt(number, 10)
  11562. // //}
  11563. // //fmt.Println(zero)
  11564. //
  11565. // struct4101 := service.Struct4101{
  11566. // PsnNo: order.PsnNo,
  11567. // MdtrtId: order.MdtrtId,
  11568. // SetlId: order.SetlId,
  11569. // PsnName: order.PsnName,
  11570. // Gend: order.Gend,
  11571. // Brdy: his.Brdy,
  11572. // Age: his.Age,
  11573. // Naty: order.Naty,
  11574. // PatnCertType: "01",
  11575. // Certno: order.Certno,
  11576. // Prfs: "90",
  11577. // ConerName: roles[0].UserName,
  11578. // PatnRlts: "99",
  11579. // ConerAddr: miConfig.OrgName,
  11580. // ConerTel: admin.Mobile,
  11581. // HiType: order.Insutype,
  11582. // Insuplc: miConfig.InsuplcAdmdvs,
  11583. // MaindiagFlag: "1",
  11584. // BillCode: order.SetlId,
  11585. // BillNo: order.SetlId,
  11586. // BizSn: order.Number,
  11587. // PsnSelfPay: order.PsnPartAmt,
  11588. // PsnOwnPay: order.PsnPartAmt,
  11589. // AcctPay: order.AcctPay,
  11590. // PsnCashpay: order.PsnCashPay,
  11591. // HiPaymtd: "1",
  11592. // Hsorg: miConfig.InsuplcAdmdvs,
  11593. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11594. // MedinsFillPsn: curRoles.UserName,
  11595. // MedinsFillDept: miConfig.OrgName,
  11596. // IptMedType: "2",
  11597. // }
  11598. // struct4101.SetlBegnDate = order.SetlTime
  11599. // struct4101.SetlEndDate = order.SetlTime
  11600. // time_arr := strings.Split(order.SetlTime, " ")
  11601. // struct4101.AdmTime = time_arr[0]
  11602. // struct4101.AdmEndTime = time_arr[0]
  11603. //
  11604. // var rf []CustomFundPay
  11605. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11606. //
  11607. // var tempFunPays []service.CustomStruct
  11608. // for _, item := range rf {
  11609. // var tempFunPay service.CustomStruct
  11610. // tempFunPay.FundPayamt = item.FundPayamt
  11611. // tempFunPay.FundPayType = item.FundPayType
  11612. // tempFunPays = append(tempFunPays, tempFunPay)
  11613. // }
  11614. // struct4101.CustomStruct = tempFunPays
  11615. //
  11616. // var tempDiaginfos []service.DiaginfoStructTwo
  11617. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11618. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11619. //
  11620. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11621. // var config []*models.HisXtDiagnoseConfig
  11622. // for _, item := range diagnosis_ids {
  11623. // id, _ := strconv.ParseInt(item, 10, 64)
  11624. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11625. // config = append(config, &diagnosisConfig)
  11626. // }
  11627. //
  11628. // for index, item := range config {
  11629. // if index == 0 {
  11630. // var tempDiaginfo service.DiaginfoStructTwo
  11631. // tempDiaginfo.DiagCode = item.CountryCode
  11632. // tempDiaginfo.DiagName = item.CountryContentName
  11633. // tempDiaginfo.DiagType = "1"
  11634. // tempDiaginfo.MaindiagFlag = "1"
  11635. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11636. // } else {
  11637. // var tempDiaginfo service.DiaginfoStructTwo
  11638. // tempDiaginfo.DiagCode = item.CountryCode
  11639. // tempDiaginfo.DiagName = item.CountryContentName
  11640. // tempDiaginfo.DiagType = "1"
  11641. // tempDiaginfo.MaindiagFlag = "0"
  11642. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11643. // }
  11644. // }
  11645. // struct4101.Diseinfo = tempDiaginfos
  11646. //
  11647. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11648. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11649. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11650. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11651. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11652. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11653. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11654. //
  11655. // var iteminfo service.IteminfoStruct
  11656. //
  11657. // var bedCostTotal float64 = 0 //床位总费
  11658. // var bedCostSelfTotal float64 = 0 //床位自费
  11659. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11660. //
  11661. // var operationCostTotal float64 = 0 //手术费
  11662. // var operationCostSelfTotal float64 = 0 //手术费
  11663. // var operationCostPartSelfTotal float64 = 0 //手术费
  11664. //
  11665. // var otherCostTotal float64 = 0 //其他费用
  11666. // var otherCostSelfTotal float64 = 0 //其他费用
  11667. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11668. //
  11669. // var materialCostTotal float64 = 0 //材料费
  11670. // var materialCostSelfTotal float64 = 0 //材料费
  11671. // var materialCostPartSelfTotal float64 = 0 //材料费
  11672. //
  11673. // var westernMedicineCostTotal float64 = 0 //西药费
  11674. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11675. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11676. //
  11677. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11678. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11679. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11680. //
  11681. // var checkCostTotal float64 = 0 //检查费
  11682. // var checkCostSelfTotal float64 = 0 //检查费
  11683. // var checkCostPartSelfTotal float64 = 0 //检查费
  11684. //
  11685. // var laboratoryCostTotal float64 = 0 //化验费
  11686. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11687. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11688. //
  11689. // var treatCostTotal float64 = 0 //治疗费用
  11690. // var treatCostSelfTotal float64 = 0 //治疗费用
  11691. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11692. //
  11693. // decimal.DivisionPrecision = 2
  11694. //
  11695. // var bed_fulamt_ownpay_amt float64 = 0
  11696. // var operation_fulamt_ownpay_amt float64 = 0
  11697. // var other_fulamt_ownpay_amt float64 = 0
  11698. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11699. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11700. // var check_fulamt_ownpay_amt float64 = 0
  11701. // var material_fulamt_ownpay_amt float64 = 0
  11702. // var laboratory_fulamt_ownpay_amt float64 = 0
  11703. // var treat_fulamt_ownpay_amt float64 = 0
  11704. //
  11705. // var bed_claa_sunmfee float64 = 0
  11706. // var bed_clab_amt float64 = 0
  11707. // var bed_other_amt float64 = 0
  11708. //
  11709. // var operation_claa_sunmfee float64 = 0
  11710. // var operation_clab_amt float64 = 0
  11711. // var operation_other_amt float64 = 0
  11712. //
  11713. // var other_claa_sunmfee float64 = 0
  11714. // var other_clab_amt float64 = 0
  11715. // var other_other_amt float64 = 0
  11716. //
  11717. // var westernMedicine_claa_sunmfee float64 = 0
  11718. // var westernMedicine_clab_amt float64 = 0
  11719. // var westernMedicine_other_amt float64 = 0
  11720. //
  11721. // var chineseTraditional_claa_sunmfee float64 = 0
  11722. // var chineseTraditional_clab_amt float64 = 0
  11723. // var chineseTraditional_other_amt float64 = 0
  11724. //
  11725. // var check_claa_sunmfee float64 = 0
  11726. // var check_clab_amt float64 = 0
  11727. // var check_other_amt float64 = 0
  11728. //
  11729. // var material_claa_sunmfee float64 = 0
  11730. // var material_clab_amt float64 = 0
  11731. // var material_other_amt float64 = 0
  11732. //
  11733. // var laboratory_claa_sunmfee float64 = 0
  11734. // var laboratory_clab_amt float64 = 0
  11735. // var laboratory_other_amt float64 = 0
  11736. //
  11737. // var treat_claa_sunmfee float64 = 0
  11738. // var treat_clab_amt float64 = 0
  11739. // var treat_other_amt float64 = 0
  11740. //
  11741. // for _, item := range order.HisOrderInfo {
  11742. // if item.MedChrgitmType == "01" { //床位费
  11743. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11744. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11745. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11746. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11747. // if item.ChrgitmLv == "1" {
  11748. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11749. // }
  11750. // if item.ChrgitmLv == "2" {
  11751. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11752. //
  11753. // }
  11754. // if item.ChrgitmLv == "3" {
  11755. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11756. // }
  11757. //
  11758. // }
  11759. //
  11760. // if item.MedChrgitmType == "03" { //检查费
  11761. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11762. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11763. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11764. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11765. // if item.ChrgitmLv == "1" {
  11766. //
  11767. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11768. //
  11769. // }
  11770. // if item.ChrgitmLv == "2" {
  11771. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11772. //
  11773. // }
  11774. // if item.ChrgitmLv == "3" {
  11775. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11776. // }
  11777. // }
  11778. //
  11779. // if item.MedChrgitmType == "04" { //化验费
  11780. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11781. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11782. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11783. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11784. // if item.ChrgitmLv == "1" {
  11785. //
  11786. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11787. //
  11788. // }
  11789. // if item.ChrgitmLv == "2" {
  11790. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11791. //
  11792. // }
  11793. // if item.ChrgitmLv == "3" {
  11794. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11795. // }
  11796. // }
  11797. //
  11798. // if item.MedChrgitmType == "05" { //治疗费
  11799. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11800. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11801. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11802. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11803. // if item.ChrgitmLv == "1" {
  11804. //
  11805. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11806. //
  11807. // }
  11808. // if item.ChrgitmLv == "2" {
  11809. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11810. //
  11811. // }
  11812. // if item.ChrgitmLv == "3" {
  11813. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11814. // }
  11815. // }
  11816. //
  11817. // if item.MedChrgitmType == "06" { //手术费
  11818. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11819. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11820. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11821. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11822. //
  11823. // if item.ChrgitmLv == "1" {
  11824. //
  11825. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11826. //
  11827. // }
  11828. // if item.ChrgitmLv == "2" {
  11829. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11830. //
  11831. // }
  11832. // if item.ChrgitmLv == "3" {
  11833. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11834. // }
  11835. // }
  11836. //
  11837. // if item.MedChrgitmType == "08" { //材料费
  11838. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11839. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11840. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11841. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11842. // if item.ChrgitmLv == "1" {
  11843. //
  11844. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11845. //
  11846. // }
  11847. // if item.ChrgitmLv == "2" {
  11848. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11849. //
  11850. // }
  11851. // if item.ChrgitmLv == "3" {
  11852. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11853. // }
  11854. // }
  11855. //
  11856. // if item.MedChrgitmType == "09" { //西药费
  11857. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11858. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11859. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11860. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11861. // if item.ChrgitmLv == "1" {
  11862. //
  11863. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11864. //
  11865. // }
  11866. // if item.ChrgitmLv == "2" {
  11867. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11868. //
  11869. // }
  11870. // if item.ChrgitmLv == "3" {
  11871. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11872. // }
  11873. // }
  11874. //
  11875. // if item.MedChrgitmType == "11" { //中成费
  11876. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11877. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11878. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11879. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11880. // if item.ChrgitmLv == "1" {
  11881. //
  11882. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11883. //
  11884. // }
  11885. // if item.ChrgitmLv == "2" {
  11886. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11887. //
  11888. // }
  11889. // if item.ChrgitmLv == "3" {
  11890. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11891. // }
  11892. // }
  11893. //
  11894. // if item.MedChrgitmType == "14" { //其他费
  11895. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11896. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11897. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11898. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11899. // if item.ChrgitmLv == "1" {
  11900. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11901. //
  11902. // }
  11903. // if item.ChrgitmLv == "2" {
  11904. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11905. //
  11906. // }
  11907. // if item.ChrgitmLv == "3" {
  11908. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11909. // }
  11910. // }
  11911. //
  11912. // }
  11913. //
  11914. // var iteminfoStructs []service.IteminfoStruct
  11915. //
  11916. // if bedCostTotal != 0 {
  11917. // iteminfo.MedChrgitm = "01"
  11918. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11919. // iteminfo.Amt = bedCostTotal
  11920. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11921. // iteminfo.ClabAmt = bed_clab_amt
  11922. // iteminfo.OthAmt = bed_other_amt
  11923. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11924. // }
  11925. //
  11926. // if checkCostTotal != 0 {
  11927. // iteminfo.MedChrgitm = "03"
  11928. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11929. // iteminfo.Amt = checkCostTotal
  11930. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11931. // iteminfo.ClabAmt = check_clab_amt
  11932. // iteminfo.OthAmt = check_other_amt
  11933. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11934. //
  11935. // }
  11936. //
  11937. // if laboratoryCostTotal != 0 {
  11938. // iteminfo.MedChrgitm = "04"
  11939. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11940. // iteminfo.Amt = laboratoryCostTotal
  11941. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11942. // iteminfo.ClabAmt = laboratory_clab_amt
  11943. // iteminfo.OthAmt = laboratory_other_amt
  11944. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11945. //
  11946. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11947. //
  11948. // }
  11949. //
  11950. // if treatCostTotal != 0 {
  11951. // iteminfo.MedChrgitm = "05"
  11952. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11953. // iteminfo.Amt = treatCostTotal
  11954. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11955. // iteminfo.ClabAmt = treat_clab_amt
  11956. // iteminfo.OthAmt = treat_other_amt
  11957. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11958. // //(struct4101.IteminfoStruct, iteminfo)
  11959. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11960. // }
  11961. //
  11962. // if operationCostTotal != 0 {
  11963. // iteminfo.MedChrgitm = "06"
  11964. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11965. // iteminfo.Amt = operationCostTotal
  11966. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11967. // iteminfo.ClabAmt = operation_clab_amt
  11968. // iteminfo.OthAmt = operation_other_amt
  11969. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11970. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11971. // }
  11972. //
  11973. // if materialCostTotal != 0 {
  11974. // iteminfo.MedChrgitm = "08"
  11975. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11976. // iteminfo.Amt = materialCostTotal
  11977. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11978. // iteminfo.ClabAmt = material_clab_amt
  11979. // iteminfo.OthAmt = material_other_amt
  11980. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11981. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11982. // }
  11983. //
  11984. // if westernMedicineCostTotal != 0 {
  11985. // iteminfo.MedChrgitm = "09"
  11986. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11987. // iteminfo.Amt = westernMedicineCostTotal
  11988. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11989. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11990. // iteminfo.OthAmt = westernMedicine_other_amt
  11991. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11992. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11993. //
  11994. // }
  11995. // if chineseTraditionalMedicineCostTotal != 0 {
  11996. // iteminfo.MedChrgitm = "11"
  11997. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11998. // iteminfo.Amt = westernMedicineCostTotal
  11999. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12000. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12001. // iteminfo.OthAmt = westernMedicine_other_amt
  12002. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12003. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12004. //
  12005. // }
  12006. // if otherCostTotal != 0 {
  12007. // iteminfo.MedChrgitm = "14"
  12008. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12009. // iteminfo.Amt = otherCostTotal
  12010. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12011. // iteminfo.ClabAmt = other_clab_amt
  12012. // iteminfo.OthAmt = other_other_amt
  12013. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12014. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12015. //
  12016. // }
  12017. // struct4101.IteminfoStruct = iteminfoStructs
  12018. // struct4101.Ntly = "中国"
  12019. // struct4101.AdmCaty = "A03.06"
  12020. //
  12021. // struct4101.DoctorName = doctor.UserName
  12022. // struct4101.DoctorCode = doctor.DoctorNumber
  12023. //
  12024. // var res ResultSeventeen
  12025. //
  12026. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12027. // struct4101.BillCode = order.Number
  12028. // struct4101.BillNo = order.SetlId
  12029. // var resOther ResultSeventeenOther
  12030. // var pp models.PublicParams
  12031. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12032. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12033. // pp.FixmedinsName = miConfig.OrgName
  12034. // pp.FixmedinsCode = miConfig.Code
  12035. // pp.RequestUrl = miConfig.Url
  12036. // pp.Cainfo = miConfig.Cainfo
  12037. // pp.SecretKey = miConfig.SecretKey
  12038. // pp.AccessKey = miConfig.AccessKey
  12039. // pp.OpterName = curRoles.UserName
  12040. //
  12041. // client := &http.Client{}
  12042. // var req *http.Request
  12043. // data := make(map[string]interface{})
  12044. // data["struct4101"] = struct4101
  12045. // data["pp"] = pp
  12046. // bytesData, _ := json.Marshal(data)
  12047. // if miConfig.MdtrtareaAdmvs == "320921" {
  12048. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12049. // } else {
  12050. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12051. // }
  12052. // resp, _ := client.Do(req)
  12053. // defer resp.Body.Close()
  12054. // body, ioErr := ioutil.ReadAll(resp.Body)
  12055. // if ioErr != nil {
  12056. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12057. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12058. // return
  12059. // }
  12060. // var respJSON map[string]interface{}
  12061. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12062. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12063. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12064. // return
  12065. // }
  12066. //
  12067. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12068. // userJSONBytes, _ := json.Marshal(respJSON)
  12069. // fmt.Println("log")
  12070. // fmt.Println(string(userJSONBytes))
  12071. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12072. // utils.ErrorLog("解析失败:%v", err)
  12073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. // return
  12075. // }
  12076. // res.InfRefmsgid = resOther.InfRefmsgid
  12077. // res.Output = resOther.Output
  12078. // res.ErrMsg = resOther.ErrMsg
  12079. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12080. // res.Infcode = infocode
  12081. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12082. //
  12083. // var pp models.PublicParams
  12084. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12085. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12086. // pp.FixmedinsName = miConfig.OrgName
  12087. // pp.FixmedinsCode = miConfig.Code
  12088. // pp.RequestUrl = miConfig.Url
  12089. // pp.Cainfo = miConfig.Cainfo
  12090. // pp.SecretKey = miConfig.SecretKey
  12091. // pp.AccessKey = miConfig.AccessKey
  12092. // pp.OpterName = curRoles.UserName
  12093. // result, _ := service.Jxyb4101(struct4101, pp)
  12094. // var dat map[string]interface{}
  12095. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12096. // fmt.Println(dat)
  12097. // } else {
  12098. // fmt.Println(err)
  12099. // }
  12100. // userJSONBytes, _ := json.Marshal(dat)
  12101. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12102. // utils.ErrorLog("解析失败:%v", err)
  12103. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12104. // return
  12105. // }
  12106. //
  12107. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12108. // var pp models.PublicParams
  12109. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12110. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12111. // pp.FixmedinsName = miConfig.OrgName
  12112. // pp.FixmedinsCode = miConfig.Code
  12113. // pp.RequestUrl = miConfig.Url
  12114. // pp.Cainfo = miConfig.Cainfo
  12115. // pp.SecretKey = miConfig.SecretKey
  12116. // pp.AccessKey = miConfig.AccessKey
  12117. // pp.OpterName = curRoles.UserName
  12118. // result, _ := service.Hnyb4101(struct4101, pp)
  12119. // var dat map[string]interface{}
  12120. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12121. // fmt.Println(dat)
  12122. // } else {
  12123. // fmt.Println(err)
  12124. // }
  12125. // userJSONBytes, _ := json.Marshal(dat)
  12126. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12127. // utils.ErrorLog("解析失败:%v", err)
  12128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12129. // return
  12130. // }
  12131. //
  12132. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12133. // var resOther ResultSeventeenOther
  12134. //
  12135. // var pp models.PublicParams
  12136. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12137. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12138. // pp.FixmedinsName = miConfig.OrgName
  12139. // pp.FixmedinsCode = miConfig.Code
  12140. // pp.RequestUrl = miConfig.Url
  12141. // pp.Cainfo = miConfig.Cainfo
  12142. // pp.SecretKey = miConfig.SecretKey
  12143. // pp.AccessKey = miConfig.AccessKey
  12144. // pp.OpterName = curRoles.UserName
  12145. // client := &http.Client{}
  12146. // var req *http.Request
  12147. // data := make(map[string]interface{})
  12148. // data["struct4101"] = struct4101
  12149. // data["pp"] = pp
  12150. // bytesData, _ := json.Marshal(data)
  12151. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12152. // resp, _ := client.Do(req)
  12153. // defer resp.Body.Close()
  12154. // body, ioErr := ioutil.ReadAll(resp.Body)
  12155. // if ioErr != nil {
  12156. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12157. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12158. // return
  12159. // }
  12160. // var respJSON map[string]interface{}
  12161. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12162. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12164. // return
  12165. // }
  12166. //
  12167. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12168. // userJSONBytes, _ := json.Marshal(respJSON)
  12169. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12170. // utils.ErrorLog("解析失败:%v", err)
  12171. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12172. // return
  12173. // }
  12174. // res.InfRefmsgid = resOther.InfRefmsgid
  12175. // res.Output = resOther.Output
  12176. // res.ErrMsg = resOther.ErrMsg
  12177. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12178. // res.Infcode = infocode
  12179. //
  12180. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12181. // var pp models.PublicParams
  12182. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12183. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12184. // pp.FixmedinsName = miConfig.OrgName
  12185. // pp.FixmedinsCode = miConfig.Code
  12186. // pp.RequestUrl = miConfig.Url
  12187. // pp.Cainfo = miConfig.Cainfo
  12188. // pp.SecretKey = miConfig.SecretKey
  12189. // pp.AccessKey = miConfig.AccessKey
  12190. // pp.OpterName = curRoles.UserName
  12191. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12192. // fmt.Println(requestLog)
  12193. // fmt.Println(errMsgLog)
  12194. //
  12195. // saveLog(result, requestLog, "4101a", "上传清单")
  12196. //
  12197. // var dat map[string]interface{}
  12198. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12199. // fmt.Println(dat)
  12200. // } else {
  12201. // fmt.Println(err)
  12202. // }
  12203. // userJSONBytes, _ := json.Marshal(dat)
  12204. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12205. // utils.ErrorLog("解析失败:%v", err)
  12206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. // return
  12208. // }
  12209. //
  12210. // } else {
  12211. //
  12212. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12213. // var dat map[string]interface{}
  12214. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12215. // fmt.Println(dat)
  12216. // } else {
  12217. // fmt.Println(err)
  12218. // }
  12219. // userJSONBytes, _ := json.Marshal(dat)
  12220. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12221. // utils.ErrorLog("解析失败:%v", err)
  12222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12223. // return
  12224. // }
  12225. // }
  12226. //
  12227. // if res.Infcode != 0 {
  12228. // adminUser := c.GetAdminUserInfo()
  12229. // errlog := &models.HisOrderError{
  12230. // UserOrgId: adminUser.CurrentOrgId,
  12231. // Ctime: time.Now().Unix(),
  12232. // Mtime: time.Now().Unix(),
  12233. // ErrMsg: res.ErrMsg,
  12234. // Status: 1,
  12235. // PatientId: order.ID,
  12236. // Stage: 10265,
  12237. // }
  12238. // service.CreateErrMsgLog(errlog)
  12239. // continue
  12240. // } else {
  12241. // //order.FaPiaoNumber = zero
  12242. // //order.FaPiaoCode = last_order.FaPiaoCode
  12243. // //service.UpdateOrder(order)
  12244. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12245. // Number: res.Output.SetlListId,
  12246. // Status: 1,
  12247. // Ctime: time.Now().Unix(),
  12248. // Mtime: time.Now().Unix(),
  12249. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12250. // IsUpload: 1,
  12251. // OrderId: order.ID,
  12252. // }
  12253. // service.CreateUploadRecord(hisFundSettleListResult)
  12254. // c.ServeSuccessJSON(map[string]interface{}{
  12255. // "msg": "上传成功",
  12256. // "result": hisFundSettleListResult,
  12257. // })
  12258. // continue
  12259. // }
  12260. // }
  12261. //}
  12262. func (c *HisApiController) GetbatchSettleList() {
  12263. //order_id, _ := c.GetInt64("order_id")
  12264. admin_user_id, _ := c.GetInt64("admin_user_id")
  12265. orders, _ := service.GetAllHisOrderTwo10485()
  12266. for _, item := range orders {
  12267. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12268. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12269. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12270. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12271. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12272. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12274. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12275. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12276. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12277. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12278. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12279. //fmt.Println(count)
  12280. //var zero string
  12281. //number := count + 1
  12282. //if number >= 1000 {
  12283. // zero = "0000" + strconv.FormatInt(number, 10)
  12284. //} else if number >= 10000 {
  12285. // zero = "000" + strconv.FormatInt(number, 10)
  12286. //} else if number >= 100000 {
  12287. // zero = "00" + strconv.FormatInt(number, 10)
  12288. //} else if number >= 1000000 {
  12289. // zero = "0" + strconv.FormatInt(number, 10)
  12290. //} else {
  12291. // zero = strconv.FormatInt(number, 10)
  12292. //}
  12293. //fmt.Println(zero)
  12294. struct4101 := service.Struct4101{
  12295. PsnNo: order.PsnNo,
  12296. MdtrtId: order.MdtrtId,
  12297. SetlId: order.SetlId,
  12298. PsnName: order.PsnName,
  12299. Gend: order.Gend,
  12300. Brdy: his.Brdy,
  12301. Age: his.Age,
  12302. Naty: order.Naty,
  12303. PatnCertType: "01",
  12304. Certno: order.Certno,
  12305. Prfs: "90",
  12306. ConerName: roles[0].UserName,
  12307. PatnRlts: "99",
  12308. ConerAddr: miConfig.OrgName,
  12309. ConerTel: admin.Mobile,
  12310. HiType: order.Insutype,
  12311. Insuplc: miConfig.InsuplcAdmdvs,
  12312. MaindiagFlag: "1",
  12313. BillCode: order.SetlId,
  12314. BillNo: order.SetlId,
  12315. BizSn: order.Number,
  12316. PsnSelfPay: order.PsnPartAmt,
  12317. PsnOwnPay: order.PsnPartAmt,
  12318. AcctPay: order.AcctPay,
  12319. PsnCashpay: order.PsnCashPay,
  12320. HiPaymtd: "1",
  12321. Hsorg: miConfig.InsuplcAdmdvs,
  12322. HsorgOpter: miConfig.InsuplcAdmdvs,
  12323. MedinsFillPsn: curRoles.UserName,
  12324. MedinsFillDept: miConfig.OrgName,
  12325. IptMedType: "2",
  12326. }
  12327. struct4101.SetlBegnDate = order.SetlTime
  12328. struct4101.SetlEndDate = order.SetlTime
  12329. time_arr := strings.Split(order.SetlTime, " ")
  12330. struct4101.AdmTime = time_arr[0]
  12331. struct4101.AdmEndTime = time_arr[0]
  12332. //var rf []CustomFundPay
  12333. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12334. //
  12335. //var tempFunPays []service.CustomStruct
  12336. //for _, item := range rf {
  12337. // var tempFunPay service.CustomStruct
  12338. // tempFunPay.FundPayamt = item.FundPayamt
  12339. // tempFunPay.FundPayType = item.FundPayType
  12340. // tempFunPays = append(tempFunPays, tempFunPay)
  12341. //}
  12342. //struct4101.CustomStruct = tempFunPays
  12343. var tempDiaginfos []service.DiaginfoStructTwo
  12344. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12345. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12346. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12347. var config []*models.HisXtDiagnoseConfig
  12348. for _, item := range diagnosis_ids {
  12349. id, _ := strconv.ParseInt(item, 10, 64)
  12350. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12351. config = append(config, &diagnosisConfig)
  12352. }
  12353. for index, item := range config {
  12354. if index == 0 {
  12355. var tempDiaginfo service.DiaginfoStructTwo
  12356. tempDiaginfo.DiagCode = item.CountryCode
  12357. tempDiaginfo.DiagName = item.CountryContentName
  12358. tempDiaginfo.DiagType = "1"
  12359. tempDiaginfo.MaindiagFlag = "1"
  12360. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12361. } else {
  12362. var tempDiaginfo service.DiaginfoStructTwo
  12363. tempDiaginfo.DiagCode = item.CountryCode
  12364. tempDiaginfo.DiagName = item.CountryContentName
  12365. tempDiaginfo.DiagType = "1"
  12366. tempDiaginfo.MaindiagFlag = "0"
  12367. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12368. }
  12369. }
  12370. struct4101.Diseinfo = tempDiaginfos
  12371. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12372. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12373. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12374. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12375. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12376. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12377. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12378. var iteminfo service.IteminfoStruct
  12379. var bedCostTotal float64 = 0 //床位总费
  12380. var bedCostSelfTotal float64 = 0 //床位自费
  12381. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12382. var operationCostTotal float64 = 0 //手术费
  12383. var operationCostSelfTotal float64 = 0 //手术费
  12384. var operationCostPartSelfTotal float64 = 0 //手术费
  12385. var otherCostTotal float64 = 0 //其他费用
  12386. var otherCostSelfTotal float64 = 0 //其他费用
  12387. var otherCostPartSelfTotal float64 = 0 //其他费用
  12388. var materialCostTotal float64 = 0 //材料费
  12389. var materialCostSelfTotal float64 = 0 //材料费
  12390. var materialCostPartSelfTotal float64 = 0 //材料费
  12391. var westernMedicineCostTotal float64 = 0 //西药费
  12392. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12393. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12394. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12395. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12396. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12397. var checkCostTotal float64 = 0 //检查费
  12398. var checkCostSelfTotal float64 = 0 //检查费
  12399. var checkCostPartSelfTotal float64 = 0 //检查费
  12400. var laboratoryCostTotal float64 = 0 //化验费
  12401. var laboratoryCostSelfTotal float64 = 0 //化验费
  12402. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12403. var treatCostTotal float64 = 0 //治疗费用
  12404. var treatCostSelfTotal float64 = 0 //治疗费用
  12405. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12406. decimal.DivisionPrecision = 2
  12407. var bed_fulamt_ownpay_amt float64 = 0
  12408. var operation_fulamt_ownpay_amt float64 = 0
  12409. var other_fulamt_ownpay_amt float64 = 0
  12410. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12411. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12412. var check_fulamt_ownpay_amt float64 = 0
  12413. var material_fulamt_ownpay_amt float64 = 0
  12414. var laboratory_fulamt_ownpay_amt float64 = 0
  12415. var treat_fulamt_ownpay_amt float64 = 0
  12416. var bed_claa_sunmfee float64 = 0
  12417. var bed_clab_amt float64 = 0
  12418. var bed_other_amt float64 = 0
  12419. var operation_claa_sunmfee float64 = 0
  12420. var operation_clab_amt float64 = 0
  12421. var operation_other_amt float64 = 0
  12422. var other_claa_sunmfee float64 = 0
  12423. var other_clab_amt float64 = 0
  12424. var other_other_amt float64 = 0
  12425. var westernMedicine_claa_sunmfee float64 = 0
  12426. var westernMedicine_clab_amt float64 = 0
  12427. var westernMedicine_other_amt float64 = 0
  12428. var chineseTraditional_claa_sunmfee float64 = 0
  12429. var chineseTraditional_clab_amt float64 = 0
  12430. var chineseTraditional_other_amt float64 = 0
  12431. var check_claa_sunmfee float64 = 0
  12432. var check_clab_amt float64 = 0
  12433. var check_other_amt float64 = 0
  12434. var material_claa_sunmfee float64 = 0
  12435. var material_clab_amt float64 = 0
  12436. var material_other_amt float64 = 0
  12437. var laboratory_claa_sunmfee float64 = 0
  12438. var laboratory_clab_amt float64 = 0
  12439. var laboratory_other_amt float64 = 0
  12440. var treat_claa_sunmfee float64 = 0
  12441. var treat_clab_amt float64 = 0
  12442. var treat_other_amt float64 = 0
  12443. for _, item := range order.HisOrderInfo {
  12444. if item.MedChrgitmType == "01" { //床位费
  12445. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12446. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12447. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12448. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12449. if item.ChrgitmLv == "1" {
  12450. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12451. }
  12452. if item.ChrgitmLv == "2" {
  12453. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12454. }
  12455. if item.ChrgitmLv == "3" {
  12456. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12457. }
  12458. }
  12459. if item.MedChrgitmType == "03" { //检查费
  12460. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12461. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12462. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12463. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12464. if item.ChrgitmLv == "1" {
  12465. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12466. }
  12467. if item.ChrgitmLv == "2" {
  12468. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12469. }
  12470. if item.ChrgitmLv == "3" {
  12471. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12472. }
  12473. }
  12474. if item.MedChrgitmType == "04" { //化验费
  12475. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12476. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12477. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12478. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12479. if item.ChrgitmLv == "1" {
  12480. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12481. }
  12482. if item.ChrgitmLv == "2" {
  12483. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12484. }
  12485. if item.ChrgitmLv == "3" {
  12486. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12487. }
  12488. }
  12489. if item.MedChrgitmType == "05" { //治疗费
  12490. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12491. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12492. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12493. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12494. if item.ChrgitmLv == "1" {
  12495. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12496. }
  12497. if item.ChrgitmLv == "2" {
  12498. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12499. }
  12500. if item.ChrgitmLv == "3" {
  12501. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12502. }
  12503. }
  12504. if item.MedChrgitmType == "06" { //手术费
  12505. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12506. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12507. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12508. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12509. if item.ChrgitmLv == "1" {
  12510. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12511. }
  12512. if item.ChrgitmLv == "2" {
  12513. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12514. }
  12515. if item.ChrgitmLv == "3" {
  12516. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12517. }
  12518. }
  12519. if item.MedChrgitmType == "08" { //材料费
  12520. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12521. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12522. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12523. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12524. if item.ChrgitmLv == "1" {
  12525. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12526. }
  12527. if item.ChrgitmLv == "2" {
  12528. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12529. }
  12530. if item.ChrgitmLv == "3" {
  12531. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12532. }
  12533. }
  12534. if item.MedChrgitmType == "09" { //西药费
  12535. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12536. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12537. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12538. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12539. if item.ChrgitmLv == "1" {
  12540. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12541. }
  12542. if item.ChrgitmLv == "2" {
  12543. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12544. }
  12545. if item.ChrgitmLv == "3" {
  12546. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12547. }
  12548. }
  12549. if item.MedChrgitmType == "11" { //中成费
  12550. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12551. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12552. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12553. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12554. if item.ChrgitmLv == "1" {
  12555. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12556. }
  12557. if item.ChrgitmLv == "2" {
  12558. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12559. }
  12560. if item.ChrgitmLv == "3" {
  12561. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12562. }
  12563. }
  12564. if item.MedChrgitmType == "14" { //其他费
  12565. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12566. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12567. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12568. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12569. if item.ChrgitmLv == "1" {
  12570. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12571. }
  12572. if item.ChrgitmLv == "2" {
  12573. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12574. }
  12575. if item.ChrgitmLv == "3" {
  12576. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12577. }
  12578. }
  12579. }
  12580. var iteminfoStructs []service.IteminfoStruct
  12581. if bedCostTotal != 0 {
  12582. iteminfo.MedChrgitm = "01"
  12583. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12584. iteminfo.Amt = bedCostTotal
  12585. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12586. iteminfo.ClabAmt = bed_clab_amt
  12587. iteminfo.OthAmt = bed_other_amt
  12588. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12589. }
  12590. if checkCostTotal != 0 {
  12591. iteminfo.MedChrgitm = "03"
  12592. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12593. iteminfo.Amt = checkCostTotal
  12594. iteminfo.ClaaSumfee = check_claa_sunmfee
  12595. iteminfo.ClabAmt = check_clab_amt
  12596. iteminfo.OthAmt = check_other_amt
  12597. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12598. }
  12599. if laboratoryCostTotal != 0 {
  12600. iteminfo.MedChrgitm = "04"
  12601. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12602. iteminfo.Amt = laboratoryCostTotal
  12603. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12604. iteminfo.ClabAmt = laboratory_clab_amt
  12605. iteminfo.OthAmt = laboratory_other_amt
  12606. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12607. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12608. }
  12609. if treatCostTotal != 0 {
  12610. iteminfo.MedChrgitm = "05"
  12611. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12612. iteminfo.Amt = treatCostTotal
  12613. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12614. iteminfo.ClabAmt = treat_clab_amt
  12615. iteminfo.OthAmt = treat_other_amt
  12616. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12617. //(struct4101.IteminfoStruct, iteminfo)
  12618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12619. }
  12620. if operationCostTotal != 0 {
  12621. iteminfo.MedChrgitm = "06"
  12622. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12623. iteminfo.Amt = operationCostTotal
  12624. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12625. iteminfo.ClabAmt = operation_clab_amt
  12626. iteminfo.OthAmt = operation_other_amt
  12627. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12629. }
  12630. if materialCostTotal != 0 {
  12631. iteminfo.MedChrgitm = "08"
  12632. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12633. iteminfo.Amt = materialCostTotal
  12634. iteminfo.ClaaSumfee = material_claa_sunmfee
  12635. iteminfo.ClabAmt = material_clab_amt
  12636. iteminfo.OthAmt = material_other_amt
  12637. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12639. }
  12640. if westernMedicineCostTotal != 0 {
  12641. iteminfo.MedChrgitm = "09"
  12642. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12643. iteminfo.Amt = westernMedicineCostTotal
  12644. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12645. iteminfo.ClabAmt = westernMedicine_clab_amt
  12646. iteminfo.OthAmt = westernMedicine_other_amt
  12647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12648. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12649. }
  12650. if chineseTraditionalMedicineCostTotal != 0 {
  12651. iteminfo.MedChrgitm = "11"
  12652. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12653. iteminfo.Amt = westernMedicineCostTotal
  12654. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12655. iteminfo.ClabAmt = westernMedicine_clab_amt
  12656. iteminfo.OthAmt = westernMedicine_other_amt
  12657. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12658. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12659. }
  12660. if otherCostTotal != 0 {
  12661. iteminfo.MedChrgitm = "14"
  12662. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12663. iteminfo.Amt = otherCostTotal
  12664. iteminfo.ClaaSumfee = other_claa_sunmfee
  12665. iteminfo.ClabAmt = other_clab_amt
  12666. iteminfo.OthAmt = other_other_amt
  12667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12669. }
  12670. struct4101.IteminfoStruct = iteminfoStructs
  12671. struct4101.Ntly = "中国"
  12672. struct4101.AdmCaty = "A03.06"
  12673. struct4101.DoctorName = doctor.UserName
  12674. struct4101.DoctorCode = doctor.DoctorNumber
  12675. var res ResultSeventeen
  12676. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12677. struct4101.BillCode = order.Number
  12678. struct4101.BillNo = order.SetlId
  12679. var resOther ResultSeventeenOther
  12680. var pp models.PublicParams
  12681. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12682. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12683. pp.FixmedinsName = miConfig.OrgName
  12684. pp.FixmedinsCode = miConfig.Code
  12685. pp.RequestUrl = miConfig.Url
  12686. pp.Cainfo = miConfig.Cainfo
  12687. pp.SecretKey = miConfig.SecretKey
  12688. pp.AccessKey = miConfig.AccessKey
  12689. pp.OpterName = curRoles.UserName
  12690. client := &http.Client{}
  12691. var req *http.Request
  12692. data := make(map[string]interface{})
  12693. data["struct4101"] = struct4101
  12694. data["pp"] = pp
  12695. bytesData, _ := json.Marshal(data)
  12696. if miConfig.MdtrtareaAdmvs == "320921" {
  12697. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12698. } else {
  12699. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12700. }
  12701. resp, _ := client.Do(req)
  12702. defer resp.Body.Close()
  12703. body, ioErr := ioutil.ReadAll(resp.Body)
  12704. if ioErr != nil {
  12705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12707. return
  12708. }
  12709. var respJSON map[string]interface{}
  12710. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12713. return
  12714. }
  12715. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12716. userJSONBytes, _ := json.Marshal(respJSON)
  12717. fmt.Println("log")
  12718. fmt.Println(string(userJSONBytes))
  12719. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12720. utils.ErrorLog("解析失败:%v", err)
  12721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12722. return
  12723. }
  12724. res.InfRefmsgid = resOther.InfRefmsgid
  12725. res.Output = resOther.Output
  12726. res.ErrMsg = resOther.ErrMsg
  12727. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12728. res.Infcode = infocode
  12729. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12730. var pp models.PublicParams
  12731. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12732. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12733. pp.FixmedinsName = miConfig.OrgName
  12734. pp.FixmedinsCode = miConfig.Code
  12735. pp.RequestUrl = miConfig.Url
  12736. pp.Cainfo = miConfig.Cainfo
  12737. pp.SecretKey = miConfig.SecretKey
  12738. pp.AccessKey = miConfig.AccessKey
  12739. pp.OpterName = curRoles.UserName
  12740. result, _ := service.Jxyb4101(struct4101, pp)
  12741. var dat map[string]interface{}
  12742. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12743. fmt.Println(dat)
  12744. } else {
  12745. fmt.Println(err)
  12746. }
  12747. userJSONBytes, _ := json.Marshal(dat)
  12748. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12749. utils.ErrorLog("解析失败:%v", err)
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12751. return
  12752. }
  12753. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12754. var pp models.PublicParams
  12755. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12756. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12757. pp.FixmedinsName = miConfig.OrgName
  12758. pp.FixmedinsCode = miConfig.Code
  12759. pp.RequestUrl = miConfig.Url
  12760. pp.Cainfo = miConfig.Cainfo
  12761. pp.SecretKey = miConfig.SecretKey
  12762. pp.AccessKey = miConfig.AccessKey
  12763. pp.OpterName = curRoles.UserName
  12764. result, _ := service.Hnyb4101(struct4101, pp)
  12765. var dat map[string]interface{}
  12766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12767. fmt.Println(dat)
  12768. } else {
  12769. fmt.Println(err)
  12770. }
  12771. userJSONBytes, _ := json.Marshal(dat)
  12772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12773. utils.ErrorLog("解析失败:%v", err)
  12774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12775. return
  12776. }
  12777. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12778. var resOther ResultSeventeenOther
  12779. var pp models.PublicParams
  12780. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12781. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12782. pp.FixmedinsName = miConfig.OrgName
  12783. pp.FixmedinsCode = miConfig.Code
  12784. pp.RequestUrl = miConfig.Url
  12785. pp.Cainfo = miConfig.Cainfo
  12786. pp.SecretKey = miConfig.SecretKey
  12787. pp.AccessKey = miConfig.AccessKey
  12788. pp.OpterName = curRoles.UserName
  12789. client := &http.Client{}
  12790. var req *http.Request
  12791. data := make(map[string]interface{})
  12792. data["struct4101"] = struct4101
  12793. data["pp"] = pp
  12794. bytesData, _ := json.Marshal(data)
  12795. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12796. resp, _ := client.Do(req)
  12797. defer resp.Body.Close()
  12798. body, ioErr := ioutil.ReadAll(resp.Body)
  12799. if ioErr != nil {
  12800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12802. return
  12803. }
  12804. var respJSON map[string]interface{}
  12805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12808. return
  12809. }
  12810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12811. userJSONBytes, _ := json.Marshal(respJSON)
  12812. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12813. utils.ErrorLog("解析失败:%v", err)
  12814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12815. return
  12816. }
  12817. res.InfRefmsgid = resOther.InfRefmsgid
  12818. res.Output = resOther.Output
  12819. res.ErrMsg = resOther.ErrMsg
  12820. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12821. res.Infcode = infocode
  12822. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12823. var pp models.PublicParams
  12824. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12825. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12826. pp.FixmedinsName = miConfig.OrgName
  12827. pp.FixmedinsCode = miConfig.Code
  12828. pp.RequestUrl = miConfig.Url
  12829. pp.Cainfo = miConfig.Cainfo
  12830. pp.SecretKey = miConfig.SecretKey
  12831. pp.AccessKey = miConfig.AccessKey
  12832. pp.OpterName = curRoles.UserName
  12833. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12834. fmt.Println(requestLog)
  12835. fmt.Println(errMsgLog)
  12836. saveLog(result, requestLog, "4101a", "上传清单")
  12837. var dat map[string]interface{}
  12838. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12839. fmt.Println(dat)
  12840. } else {
  12841. fmt.Println(err)
  12842. }
  12843. userJSONBytes, _ := json.Marshal(dat)
  12844. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12845. utils.ErrorLog("解析失败:%v", err)
  12846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12847. return
  12848. }
  12849. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12850. var pp models.PublicParams
  12851. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12852. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12853. pp.FixmedinsName = miConfig.OrgName
  12854. pp.FixmedinsCode = miConfig.Code
  12855. pp.RequestUrl = miConfig.Url
  12856. pp.Cainfo = miConfig.Cainfo
  12857. pp.SecretKey = miConfig.SecretKey
  12858. pp.AccessKey = miConfig.AccessKey
  12859. pp.OpterName = curRoles.UserName
  12860. client := &http.Client{}
  12861. var req *http.Request
  12862. data := make(map[string]interface{})
  12863. data["struct4101"] = struct4101
  12864. data["pp"] = pp
  12865. bytesData, _ := json.Marshal(data)
  12866. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12867. resp, _ := client.Do(req)
  12868. defer resp.Body.Close()
  12869. body, ioErr := ioutil.ReadAll(resp.Body)
  12870. if ioErr != nil {
  12871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12873. return
  12874. }
  12875. var respJSON map[string]interface{}
  12876. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12879. return
  12880. }
  12881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12882. userJSONBytes, _ := json.Marshal(respJSON)
  12883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12884. utils.ErrorLog("解析失败:%v", err)
  12885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12886. return
  12887. }
  12888. } else {
  12889. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12890. var dat map[string]interface{}
  12891. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12892. fmt.Println(dat)
  12893. } else {
  12894. fmt.Println(err)
  12895. }
  12896. userJSONBytes, _ := json.Marshal(dat)
  12897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12898. utils.ErrorLog("解析失败:%v", err)
  12899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12900. return
  12901. }
  12902. }
  12903. if res.Infcode != 0 {
  12904. errlog := &models.HisOrderError{
  12905. UserOrgId: order.UserOrgId,
  12906. Ctime: time.Now().Unix(),
  12907. Mtime: time.Now().Unix(),
  12908. ErrMsg: res.ErrMsg + "解析失败",
  12909. Status: 1,
  12910. PatientId: order.ID,
  12911. Stage: 10485,
  12912. }
  12913. service.CreateErrMsgLog(errlog)
  12914. continue
  12915. //c.ServeSuccessJSON(map[string]interface{}{
  12916. // "failed_code": -10,
  12917. // "msg": res.ErrMsg,
  12918. //})
  12919. } else {
  12920. //order.FaPiaoNumber = zero
  12921. //order.FaPiaoCode = last_order.FaPiaoCode
  12922. //service.UpdateOrder(order)
  12923. hisFundSettleListResult := &models.HisFundSettleListResult{
  12924. Number: res.Output.SetlListId,
  12925. Status: 1,
  12926. Ctime: time.Now().Unix(),
  12927. Mtime: time.Now().Unix(),
  12928. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12929. IsUpload: 1,
  12930. OrderId: order.ID,
  12931. }
  12932. service.CreateUploadRecord(hisFundSettleListResult)
  12933. continue
  12934. }
  12935. }
  12936. }
  12937. func (c *HisApiController) GetSettleList() {
  12938. order_id, _ := c.GetInt64("order_id")
  12939. admin_user_id, _ := c.GetInt64("admin_user_id")
  12940. order, _ := service.GetHisOrderByIDTwo(order_id)
  12941. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12942. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12943. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12944. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12945. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12946. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12947. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12948. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12949. if order.ID == 0 {
  12950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12951. return
  12952. }
  12953. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12954. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12955. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12956. //fmt.Println(count)
  12957. //var zero string
  12958. //number := count + 1
  12959. //if number >= 1000 {
  12960. // zero = "0000" + strconv.FormatInt(number, 10)
  12961. //} else if number >= 10000 {
  12962. // zero = "000" + strconv.FormatInt(number, 10)
  12963. //} else if number >= 100000 {
  12964. // zero = "00" + strconv.FormatInt(number, 10)
  12965. //} else if number >= 1000000 {
  12966. // zero = "0" + strconv.FormatInt(number, 10)
  12967. //} else {
  12968. // zero = strconv.FormatInt(number, 10)
  12969. //}
  12970. //fmt.Println(zero)
  12971. struct4101 := service.Struct4101{
  12972. PsnNo: order.PsnNo,
  12973. MdtrtId: order.MdtrtId,
  12974. SetlId: order.SetlId,
  12975. PsnName: order.PsnName,
  12976. Gend: order.Gend,
  12977. Brdy: his.Brdy,
  12978. Age: his.Age,
  12979. Naty: order.Naty,
  12980. PatnCertType: "01",
  12981. Certno: order.Certno,
  12982. Prfs: "90",
  12983. ConerName: roles[0].UserName,
  12984. PatnRlts: "99",
  12985. ConerAddr: miConfig.OrgName,
  12986. ConerTel: admin.Mobile,
  12987. HiType: order.Insutype,
  12988. Insuplc: miConfig.InsuplcAdmdvs,
  12989. MaindiagFlag: "1",
  12990. BillCode: order.SetlId,
  12991. BillNo: order.SetlId,
  12992. BizSn: order.Number,
  12993. PsnSelfPay: order.PsnPartAmt,
  12994. PsnOwnPay: order.PsnPartAmt,
  12995. AcctPay: order.AcctPay,
  12996. PsnCashpay: order.PsnCashPay,
  12997. HiPaymtd: "1",
  12998. Hsorg: miConfig.InsuplcAdmdvs,
  12999. HsorgOpter: miConfig.InsuplcAdmdvs,
  13000. MedinsFillPsn: curRoles.UserName,
  13001. MedinsFillDept: miConfig.OrgName,
  13002. IptMedType: "2",
  13003. }
  13004. struct4101.SetlBegnDate = order.SetlTime
  13005. struct4101.SetlEndDate = order.SetlTime
  13006. time_arr := strings.Split(order.SetlTime, " ")
  13007. struct4101.AdmTime = time_arr[0]
  13008. struct4101.AdmEndTime = time_arr[0]
  13009. //
  13010. //var rf []CustomFundPay
  13011. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13012. //
  13013. //var tempFunPays []service.CustomStruct
  13014. //for _, item := range rf {
  13015. // var tempFunPay service.CustomStruct
  13016. // tempFunPay.FundPayamt = item.FundPayamt
  13017. // tempFunPay.FundPayType = item.FundPayType
  13018. // tempFunPays = append(tempFunPays, tempFunPay)
  13019. //}
  13020. //struct4101.CustomStruct = tempFunPays
  13021. var tempDiaginfos []service.DiaginfoStructTwo
  13022. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13023. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13024. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13025. var config []*models.HisXtDiagnoseConfig
  13026. for _, item := range diagnosis_ids {
  13027. id, _ := strconv.ParseInt(item, 10, 64)
  13028. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13029. config = append(config, &diagnosisConfig)
  13030. }
  13031. if miConfig.Code == "H15049901371" {
  13032. //for _, item := range config {
  13033. // if item.ID == 138 {
  13034. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13035. var tempDiaginfo service.DiaginfoStructTwo
  13036. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13037. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13038. tempDiaginfo.DiagType = "1"
  13039. tempDiaginfo.MaindiagFlag = "1"
  13040. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13041. //}
  13042. //}
  13043. for _, item := range config {
  13044. if item.ID != 138 {
  13045. var tempDiaginfo service.DiaginfoStructTwo
  13046. tempDiaginfo.DiagCode = item.CountryCode
  13047. tempDiaginfo.DiagName = item.CountryContentName
  13048. tempDiaginfo.DiagType = "1"
  13049. tempDiaginfo.MaindiagFlag = "0"
  13050. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13051. }
  13052. }
  13053. } else {
  13054. for index, item := range config {
  13055. if index == 0 {
  13056. var tempDiaginfo service.DiaginfoStructTwo
  13057. tempDiaginfo.DiagCode = item.CountryCode
  13058. tempDiaginfo.DiagName = item.CountryContentName
  13059. tempDiaginfo.DiagType = "1"
  13060. tempDiaginfo.MaindiagFlag = "1"
  13061. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13062. } else {
  13063. var tempDiaginfo service.DiaginfoStructTwo
  13064. tempDiaginfo.DiagCode = item.CountryCode
  13065. tempDiaginfo.DiagName = item.CountryContentName
  13066. tempDiaginfo.DiagType = "1"
  13067. tempDiaginfo.MaindiagFlag = "0"
  13068. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13069. }
  13070. }
  13071. }
  13072. struct4101.Diseinfo = tempDiaginfos
  13073. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13074. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13075. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13076. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13077. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13078. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13079. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13080. var iteminfo service.IteminfoStruct
  13081. var bedCostTotal float64 = 0 //床位总费
  13082. var bedCostSelfTotal float64 = 0 //床位自费
  13083. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13084. var operationCostTotal float64 = 0 //手术费
  13085. var operationCostSelfTotal float64 = 0 //手术费
  13086. var operationCostPartSelfTotal float64 = 0 //手术费
  13087. var otherCostTotal float64 = 0 //其他费用
  13088. var otherCostSelfTotal float64 = 0 //其他费用
  13089. var otherCostPartSelfTotal float64 = 0 //其他费用
  13090. var materialCostTotal float64 = 0 //材料费
  13091. var materialCostSelfTotal float64 = 0 //材料费
  13092. var materialCostPartSelfTotal float64 = 0 //材料费
  13093. var westernMedicineCostTotal float64 = 0 //西药费
  13094. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13095. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13096. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13097. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13098. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13099. var checkCostTotal float64 = 0 //检查费
  13100. var checkCostSelfTotal float64 = 0 //检查费
  13101. var checkCostPartSelfTotal float64 = 0 //检查费
  13102. var laboratoryCostTotal float64 = 0 //化验费
  13103. var laboratoryCostSelfTotal float64 = 0 //化验费
  13104. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13105. var treatCostTotal float64 = 0 //治疗费用
  13106. var treatCostSelfTotal float64 = 0 //治疗费用
  13107. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13108. decimal.DivisionPrecision = 2
  13109. var bed_fulamt_ownpay_amt float64 = 0
  13110. var operation_fulamt_ownpay_amt float64 = 0
  13111. var other_fulamt_ownpay_amt float64 = 0
  13112. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13113. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13114. var check_fulamt_ownpay_amt float64 = 0
  13115. var material_fulamt_ownpay_amt float64 = 0
  13116. var laboratory_fulamt_ownpay_amt float64 = 0
  13117. var treat_fulamt_ownpay_amt float64 = 0
  13118. var bed_claa_sunmfee float64 = 0
  13119. var bed_clab_amt float64 = 0
  13120. var bed_other_amt float64 = 0
  13121. var operation_claa_sunmfee float64 = 0
  13122. var operation_clab_amt float64 = 0
  13123. var operation_other_amt float64 = 0
  13124. var other_claa_sunmfee float64 = 0
  13125. var other_clab_amt float64 = 0
  13126. var other_other_amt float64 = 0
  13127. var westernMedicine_claa_sunmfee float64 = 0
  13128. var westernMedicine_clab_amt float64 = 0
  13129. var westernMedicine_other_amt float64 = 0
  13130. var chineseTraditional_claa_sunmfee float64 = 0
  13131. var chineseTraditional_clab_amt float64 = 0
  13132. var chineseTraditional_other_amt float64 = 0
  13133. var check_claa_sunmfee float64 = 0
  13134. var check_clab_amt float64 = 0
  13135. var check_other_amt float64 = 0
  13136. var material_claa_sunmfee float64 = 0
  13137. var material_clab_amt float64 = 0
  13138. var material_other_amt float64 = 0
  13139. var laboratory_claa_sunmfee float64 = 0
  13140. var laboratory_clab_amt float64 = 0
  13141. var laboratory_other_amt float64 = 0
  13142. var treat_claa_sunmfee float64 = 0
  13143. var treat_clab_amt float64 = 0
  13144. var treat_other_amt float64 = 0
  13145. for _, item := range order.HisOrderInfo {
  13146. if item.MedChrgitmType == "01" { //床位费
  13147. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13148. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13149. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13150. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13151. if item.ChrgitmLv == "1" {
  13152. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13153. }
  13154. if item.ChrgitmLv == "2" {
  13155. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13156. }
  13157. if item.ChrgitmLv == "3" {
  13158. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13159. }
  13160. }
  13161. if item.MedChrgitmType == "03" { //检查费
  13162. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13163. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13164. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13165. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13166. if item.ChrgitmLv == "1" {
  13167. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13168. }
  13169. if item.ChrgitmLv == "2" {
  13170. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13171. }
  13172. if item.ChrgitmLv == "3" {
  13173. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13174. }
  13175. }
  13176. if item.MedChrgitmType == "04" { //化验费
  13177. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13178. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13179. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13180. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13181. if item.ChrgitmLv == "1" {
  13182. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13183. }
  13184. if item.ChrgitmLv == "2" {
  13185. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13186. }
  13187. if item.ChrgitmLv == "3" {
  13188. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13189. }
  13190. }
  13191. if item.MedChrgitmType == "05" { //治疗费
  13192. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13193. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13194. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13195. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13196. if item.ChrgitmLv == "1" {
  13197. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13198. }
  13199. if item.ChrgitmLv == "2" {
  13200. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13201. }
  13202. if item.ChrgitmLv == "3" {
  13203. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13204. }
  13205. }
  13206. if item.MedChrgitmType == "06" { //手术费
  13207. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13208. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13209. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13210. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13211. if item.ChrgitmLv == "1" {
  13212. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13213. }
  13214. if item.ChrgitmLv == "2" {
  13215. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13216. }
  13217. if item.ChrgitmLv == "3" {
  13218. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13219. }
  13220. }
  13221. if item.MedChrgitmType == "08" { //材料费
  13222. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13223. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13224. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13225. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13226. if item.ChrgitmLv == "1" {
  13227. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13228. }
  13229. if item.ChrgitmLv == "2" {
  13230. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13231. }
  13232. if item.ChrgitmLv == "3" {
  13233. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13234. }
  13235. }
  13236. if item.MedChrgitmType == "09" { //西药费
  13237. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13238. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13239. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13240. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13241. if item.ChrgitmLv == "1" {
  13242. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13243. }
  13244. if item.ChrgitmLv == "2" {
  13245. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13246. }
  13247. if item.ChrgitmLv == "3" {
  13248. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13249. }
  13250. }
  13251. if item.MedChrgitmType == "11" { //中成费
  13252. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13253. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13254. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13255. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13256. if item.ChrgitmLv == "1" {
  13257. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13258. }
  13259. if item.ChrgitmLv == "2" {
  13260. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13261. }
  13262. if item.ChrgitmLv == "3" {
  13263. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13264. }
  13265. }
  13266. if item.MedChrgitmType == "14" { //其他费
  13267. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13268. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13269. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13270. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13271. if item.ChrgitmLv == "1" {
  13272. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13273. }
  13274. if item.ChrgitmLv == "2" {
  13275. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13276. }
  13277. if item.ChrgitmLv == "3" {
  13278. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13279. }
  13280. }
  13281. }
  13282. var iteminfoStructs []service.IteminfoStruct
  13283. if bedCostTotal != 0 {
  13284. iteminfo.MedChrgitm = "01"
  13285. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13286. iteminfo.Amt = bedCostTotal
  13287. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13288. iteminfo.ClabAmt = bed_clab_amt
  13289. iteminfo.OthAmt = bed_other_amt
  13290. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13291. }
  13292. if checkCostTotal != 0 {
  13293. iteminfo.MedChrgitm = "03"
  13294. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13295. iteminfo.Amt = checkCostTotal
  13296. iteminfo.ClaaSumfee = check_claa_sunmfee
  13297. iteminfo.ClabAmt = check_clab_amt
  13298. iteminfo.OthAmt = check_other_amt
  13299. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13300. }
  13301. if laboratoryCostTotal != 0 {
  13302. iteminfo.MedChrgitm = "04"
  13303. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13304. iteminfo.Amt = laboratoryCostTotal
  13305. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13306. iteminfo.ClabAmt = laboratory_clab_amt
  13307. iteminfo.OthAmt = laboratory_other_amt
  13308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13309. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13310. }
  13311. if treatCostTotal != 0 {
  13312. iteminfo.MedChrgitm = "05"
  13313. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13314. iteminfo.Amt = treatCostTotal
  13315. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13316. iteminfo.ClabAmt = treat_clab_amt
  13317. iteminfo.OthAmt = treat_other_amt
  13318. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13319. //(struct4101.IteminfoStruct, iteminfo)
  13320. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13321. }
  13322. if operationCostTotal != 0 {
  13323. iteminfo.MedChrgitm = "06"
  13324. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13325. iteminfo.Amt = operationCostTotal
  13326. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13327. iteminfo.ClabAmt = operation_clab_amt
  13328. iteminfo.OthAmt = operation_other_amt
  13329. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13330. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13331. }
  13332. if materialCostTotal != 0 {
  13333. iteminfo.MedChrgitm = "08"
  13334. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13335. iteminfo.Amt = materialCostTotal
  13336. iteminfo.ClaaSumfee = material_claa_sunmfee
  13337. iteminfo.ClabAmt = material_clab_amt
  13338. iteminfo.OthAmt = material_other_amt
  13339. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13340. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13341. }
  13342. if westernMedicineCostTotal != 0 {
  13343. iteminfo.MedChrgitm = "09"
  13344. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13345. iteminfo.Amt = westernMedicineCostTotal
  13346. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13347. iteminfo.ClabAmt = westernMedicine_clab_amt
  13348. iteminfo.OthAmt = westernMedicine_other_amt
  13349. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13350. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13351. }
  13352. if chineseTraditionalMedicineCostTotal != 0 {
  13353. iteminfo.MedChrgitm = "11"
  13354. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13355. iteminfo.Amt = westernMedicineCostTotal
  13356. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13357. iteminfo.ClabAmt = westernMedicine_clab_amt
  13358. iteminfo.OthAmt = westernMedicine_other_amt
  13359. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13360. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13361. }
  13362. if otherCostTotal != 0 {
  13363. iteminfo.MedChrgitm = "14"
  13364. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13365. iteminfo.Amt = otherCostTotal
  13366. iteminfo.ClaaSumfee = other_claa_sunmfee
  13367. iteminfo.ClabAmt = other_clab_amt
  13368. iteminfo.OthAmt = other_other_amt
  13369. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13371. }
  13372. struct4101.IteminfoStruct = iteminfoStructs
  13373. struct4101.Ntly = "中国"
  13374. struct4101.AdmCaty = "A03.06"
  13375. struct4101.DoctorName = doctor.UserName
  13376. struct4101.DoctorCode = doctor.DoctorNumber
  13377. var res ResultSeventeen
  13378. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13379. struct4101.BillCode = order.Number
  13380. struct4101.BillNo = order.SetlId
  13381. var resOther ResultSeventeenOther
  13382. var pp models.PublicParams
  13383. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13384. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13385. pp.FixmedinsName = miConfig.OrgName
  13386. pp.FixmedinsCode = miConfig.Code
  13387. pp.RequestUrl = miConfig.Url
  13388. pp.Cainfo = miConfig.Cainfo
  13389. pp.SecretKey = miConfig.SecretKey
  13390. pp.AccessKey = miConfig.AccessKey
  13391. pp.OpterName = curRoles.UserName
  13392. client := &http.Client{}
  13393. var req *http.Request
  13394. data := make(map[string]interface{})
  13395. data["struct4101"] = struct4101
  13396. data["pp"] = pp
  13397. bytesData, _ := json.Marshal(data)
  13398. if miConfig.MdtrtareaAdmvs == "320921" {
  13399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13400. } else {
  13401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13402. }
  13403. resp, _ := client.Do(req)
  13404. defer resp.Body.Close()
  13405. body, ioErr := ioutil.ReadAll(resp.Body)
  13406. if ioErr != nil {
  13407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13409. return
  13410. }
  13411. var respJSON map[string]interface{}
  13412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13415. return
  13416. }
  13417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13418. userJSONBytes, _ := json.Marshal(respJSON)
  13419. fmt.Println("log")
  13420. fmt.Println(string(userJSONBytes))
  13421. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13422. utils.ErrorLog("解析失败:%v", err)
  13423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13424. return
  13425. }
  13426. res.InfRefmsgid = resOther.InfRefmsgid
  13427. res.Output = resOther.Output
  13428. res.ErrMsg = resOther.ErrMsg
  13429. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13430. res.Infcode = infocode
  13431. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13432. var pp models.PublicParams
  13433. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13434. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13435. pp.FixmedinsName = miConfig.OrgName
  13436. pp.FixmedinsCode = miConfig.Code
  13437. pp.RequestUrl = miConfig.Url
  13438. pp.Cainfo = miConfig.Cainfo
  13439. pp.SecretKey = miConfig.SecretKey
  13440. pp.AccessKey = miConfig.AccessKey
  13441. pp.OpterName = curRoles.UserName
  13442. result, _ := service.Jxyb4101(struct4101, pp)
  13443. var dat map[string]interface{}
  13444. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13445. fmt.Println(dat)
  13446. } else {
  13447. fmt.Println(err)
  13448. }
  13449. userJSONBytes, _ := json.Marshal(dat)
  13450. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13451. utils.ErrorLog("解析失败:%v", err)
  13452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13453. return
  13454. }
  13455. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13456. var pp models.PublicParams
  13457. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13458. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13459. pp.FixmedinsName = miConfig.OrgName
  13460. pp.FixmedinsCode = miConfig.Code
  13461. pp.RequestUrl = miConfig.Url
  13462. pp.Cainfo = miConfig.Cainfo
  13463. pp.SecretKey = miConfig.SecretKey
  13464. pp.AccessKey = miConfig.AccessKey
  13465. pp.OpterName = curRoles.UserName
  13466. result, _ := service.Hnyb4101(struct4101, pp)
  13467. var dat map[string]interface{}
  13468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13469. fmt.Println(dat)
  13470. } else {
  13471. fmt.Println(err)
  13472. }
  13473. userJSONBytes, _ := json.Marshal(dat)
  13474. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13475. utils.ErrorLog("解析失败:%v", err)
  13476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13477. return
  13478. }
  13479. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13480. var resOther ResultSeventeenOther
  13481. var pp models.PublicParams
  13482. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13483. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13484. pp.FixmedinsName = miConfig.OrgName
  13485. pp.FixmedinsCode = miConfig.Code
  13486. pp.RequestUrl = miConfig.Url
  13487. pp.Cainfo = miConfig.Cainfo
  13488. pp.SecretKey = miConfig.SecretKey
  13489. pp.AccessKey = miConfig.AccessKey
  13490. pp.OpterName = curRoles.UserName
  13491. client := &http.Client{}
  13492. var req *http.Request
  13493. data := make(map[string]interface{})
  13494. data["struct4101"] = struct4101
  13495. data["pp"] = pp
  13496. bytesData, _ := json.Marshal(data)
  13497. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13498. resp, _ := client.Do(req)
  13499. defer resp.Body.Close()
  13500. body, ioErr := ioutil.ReadAll(resp.Body)
  13501. if ioErr != nil {
  13502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13504. return
  13505. }
  13506. var respJSON map[string]interface{}
  13507. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13510. return
  13511. }
  13512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13513. userJSONBytes, _ := json.Marshal(respJSON)
  13514. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13515. utils.ErrorLog("解析失败:%v", err)
  13516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13517. return
  13518. }
  13519. res.InfRefmsgid = resOther.InfRefmsgid
  13520. res.Output = resOther.Output
  13521. res.ErrMsg = resOther.ErrMsg
  13522. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13523. res.Infcode = infocode
  13524. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13525. var pp models.PublicParams
  13526. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13527. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13528. pp.FixmedinsName = miConfig.OrgName
  13529. pp.FixmedinsCode = miConfig.Code
  13530. pp.RequestUrl = miConfig.Url
  13531. pp.Cainfo = miConfig.Cainfo
  13532. pp.SecretKey = miConfig.SecretKey
  13533. pp.AccessKey = miConfig.AccessKey
  13534. pp.OpterName = curRoles.UserName
  13535. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13536. fmt.Println(requestLog)
  13537. fmt.Println(errMsgLog)
  13538. saveLog(result, requestLog, "4101a", "上传清单")
  13539. var dat map[string]interface{}
  13540. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13541. fmt.Println(dat)
  13542. } else {
  13543. fmt.Println(err)
  13544. }
  13545. userJSONBytes, _ := json.Marshal(dat)
  13546. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13547. utils.ErrorLog("解析失败:%v", err)
  13548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13549. return
  13550. }
  13551. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13552. var pp models.PublicParams
  13553. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13554. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13555. pp.FixmedinsName = miConfig.OrgName
  13556. pp.FixmedinsCode = miConfig.Code
  13557. pp.RequestUrl = miConfig.Url
  13558. pp.Cainfo = miConfig.Cainfo
  13559. pp.SecretKey = miConfig.SecretKey
  13560. pp.AccessKey = miConfig.AccessKey
  13561. pp.OpterName = curRoles.UserName
  13562. client := &http.Client{}
  13563. var req *http.Request
  13564. data := make(map[string]interface{})
  13565. data["struct4101"] = struct4101
  13566. data["pp"] = pp
  13567. bytesData, _ := json.Marshal(data)
  13568. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13569. resp, _ := client.Do(req)
  13570. defer resp.Body.Close()
  13571. body, ioErr := ioutil.ReadAll(resp.Body)
  13572. if ioErr != nil {
  13573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13575. return
  13576. }
  13577. var respJSON map[string]interface{}
  13578. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13581. return
  13582. }
  13583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13584. userJSONBytes, _ := json.Marshal(respJSON)
  13585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13586. utils.ErrorLog("解析失败:%v", err)
  13587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13588. return
  13589. }
  13590. } else {
  13591. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13592. var dat map[string]interface{}
  13593. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13594. fmt.Println(dat)
  13595. } else {
  13596. fmt.Println(err)
  13597. }
  13598. userJSONBytes, _ := json.Marshal(dat)
  13599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13600. utils.ErrorLog("解析失败:%v", err)
  13601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13602. return
  13603. }
  13604. }
  13605. if res.Infcode != 0 {
  13606. c.ServeSuccessJSON(map[string]interface{}{
  13607. "failed_code": -10,
  13608. "msg": res.ErrMsg,
  13609. })
  13610. return
  13611. } else {
  13612. //order.FaPiaoNumber = zero
  13613. //order.FaPiaoCode = last_order.FaPiaoCode
  13614. //service.UpdateOrder(order)
  13615. hisFundSettleListResult := &models.HisFundSettleListResult{
  13616. Number: res.Output.SetlListId,
  13617. Status: 1,
  13618. Ctime: time.Now().Unix(),
  13619. Mtime: time.Now().Unix(),
  13620. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13621. IsUpload: 1,
  13622. OrderId: order_id,
  13623. }
  13624. service.CreateUploadRecord(hisFundSettleListResult)
  13625. c.ServeSuccessJSON(map[string]interface{}{
  13626. "msg": "上传成功",
  13627. "result": hisFundSettleListResult,
  13628. })
  13629. return
  13630. }
  13631. }
  13632. func (c *HisApiController) GetSettleListHospital() {
  13633. order_id, _ := c.GetInt64("order_id")
  13634. admin_user_id, _ := c.GetInt64("admin_user_id")
  13635. order, _ := service.GetHisOrderByIDTwo(order_id)
  13636. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13637. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13638. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13639. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13640. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13641. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13642. if order.ID == 0 {
  13643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13644. return
  13645. }
  13646. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13647. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13648. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13649. fmt.Println(count)
  13650. var zero string
  13651. number := count + 1
  13652. if number >= 1000 {
  13653. zero = "0000" + strconv.FormatInt(number, 10)
  13654. } else if number >= 10000 {
  13655. zero = "000" + strconv.FormatInt(number, 10)
  13656. } else if number >= 100000 {
  13657. zero = "00" + strconv.FormatInt(number, 10)
  13658. } else if number >= 1000000 {
  13659. zero = "0" + strconv.FormatInt(number, 10)
  13660. } else {
  13661. zero = strconv.FormatInt(number, 10)
  13662. }
  13663. fmt.Println(zero)
  13664. struct4101 := service.Struct4101{
  13665. PsnNo: order.PsnNo,
  13666. MdtrtId: order.MdtrtId,
  13667. SetlId: order.SetlId,
  13668. PsnName: order.PsnName,
  13669. Gend: order.Gend,
  13670. Brdy: his.Brdy,
  13671. Age: int64(order.Age),
  13672. Naty: order.Naty,
  13673. PatnCertType: "01",
  13674. Certno: order.Certno,
  13675. Prfs: "90",
  13676. ConerName: roles[0].UserName,
  13677. PatnRlts: "99",
  13678. ConerAddr: miConfig.OrgName,
  13679. ConerTel: admin.Mobile,
  13680. HiType: order.Insutype,
  13681. Insuplc: miConfig.InsuplcAdmdvs,
  13682. MaindiagFlag: "1",
  13683. BillCode: order.SetlId,
  13684. BillNo: order.SetlId,
  13685. BizSn: order.Number,
  13686. PsnSelfPay: order.PsnPartAmt,
  13687. PsnOwnPay: order.PsnPartAmt,
  13688. AcctPay: order.AcctPay,
  13689. PsnCashpay: order.PsnCashPay,
  13690. HiPaymtd: "1",
  13691. Hsorg: miConfig.InsuplcAdmdvs,
  13692. HsorgOpter: miConfig.InsuplcAdmdvs,
  13693. MedinsFillPsn: curRoles.UserName,
  13694. MedinsFillDept: depart.Name,
  13695. IptMedType: "2",
  13696. AdmTime: his.InHosptialTime,
  13697. AdmEndTime: his.OutHosptialTime,
  13698. }
  13699. struct4101.SetlBegnDate = order.SetlTime
  13700. struct4101.SetlEndDate = order.SetlTime
  13701. //var rf []CustomFundPay
  13702. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13703. //
  13704. //var tempFunPays []service.CustomStruct
  13705. //for _, item := range rf {
  13706. // var tempFunPay service.CustomStruct
  13707. // tempFunPay.FundPayamt = item.FundPayamt
  13708. // tempFunPay.FundPayType = item.FundPayType
  13709. // tempFunPays = append(tempFunPays, tempFunPay)
  13710. //}
  13711. //struct4101.CustomStruct = tempFunPays
  13712. var tempDiaginfos []service.DiaginfoStructTwo
  13713. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13714. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13715. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13716. //for _, item := range infos {
  13717. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13718. //}
  13719. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13720. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13721. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13722. fmt.Println(diagnosis_ids_arr)
  13723. if order.UserOrgId == 10210 {
  13724. var diagnosis_ids_arr_two []int64
  13725. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13726. var config []*models.HisXtDiagnoseConfig
  13727. for _, id := range diagnosis_ids_arr_two {
  13728. //id, _ := strconv.ParseInt(item, 10, 64)
  13729. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13730. if diagnosisConfig.ID > 0 {
  13731. config = append(config, &diagnosisConfig)
  13732. }
  13733. }
  13734. for index, item := range config {
  13735. if item.ID > 0 {
  13736. if index == 0 {
  13737. var tempDiaginfo service.DiaginfoStructTwo
  13738. tempDiaginfo.DiagCode = item.CountryCode
  13739. tempDiaginfo.DiagName = item.CountryContentName
  13740. tempDiaginfo.DiagType = "1"
  13741. tempDiaginfo.MaindiagFlag = "1"
  13742. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13743. } else {
  13744. var tempDiaginfo service.DiaginfoStructTwo
  13745. tempDiaginfo.DiagCode = item.CountryCode
  13746. tempDiaginfo.DiagName = item.CountryContentName
  13747. tempDiaginfo.DiagType = "1"
  13748. tempDiaginfo.MaindiagFlag = "0"
  13749. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13750. }
  13751. }
  13752. }
  13753. struct4101.Diseinfo = tempDiaginfos
  13754. } else {
  13755. var config []*models.HisXtDiagnoseConfig
  13756. for _, item := range diagnosis_ids_arr {
  13757. id, _ := strconv.ParseInt(item, 10, 64)
  13758. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13759. if diagnosisConfig.ID > 0 {
  13760. config = append(config, &diagnosisConfig)
  13761. }
  13762. }
  13763. for index, item := range config {
  13764. if item.ID > 0 {
  13765. if index == 0 {
  13766. var tempDiaginfo service.DiaginfoStructTwo
  13767. tempDiaginfo.DiagCode = item.CountryCode
  13768. tempDiaginfo.DiagName = item.CountryContentName
  13769. tempDiaginfo.DiagType = "1"
  13770. tempDiaginfo.MaindiagFlag = "1"
  13771. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13772. } else {
  13773. var tempDiaginfo service.DiaginfoStructTwo
  13774. tempDiaginfo.DiagCode = item.CountryCode
  13775. tempDiaginfo.DiagName = item.CountryContentName
  13776. tempDiaginfo.DiagType = "1"
  13777. tempDiaginfo.MaindiagFlag = "0"
  13778. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13779. }
  13780. }
  13781. }
  13782. struct4101.Diseinfo = tempDiaginfos
  13783. }
  13784. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13785. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13786. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13787. tempOpspdiseinfo2.OprnOprtCode = ""
  13788. tempOpspdiseinfo2.OprnOprtName = ""
  13789. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13790. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13791. var iteminfo service.IteminfoStruct
  13792. var bedCostTotal float64 = 0 //床位总费
  13793. var bedCostSelfTotal float64 = 0 //床位自费
  13794. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13795. var operationCostTotal float64 = 0 //手术费
  13796. var operationCostSelfTotal float64 = 0 //手术费
  13797. var operationCostPartSelfTotal float64 = 0 //手术费
  13798. var otherCostTotal float64 = 0 //其他费用
  13799. var otherCostSelfTotal float64 = 0 //其他费用
  13800. var otherCostPartSelfTotal float64 = 0 //其他费用
  13801. var materialCostTotal float64 = 0 //材料费
  13802. var materialCostSelfTotal float64 = 0 //材料费
  13803. var materialCostPartSelfTotal float64 = 0 //材料费
  13804. var westernMedicineCostTotal float64 = 0 //西药费
  13805. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13806. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13807. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13808. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13809. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13810. var checkCostTotal float64 = 0 //检查费
  13811. var checkCostSelfTotal float64 = 0 //检查费
  13812. var checkCostPartSelfTotal float64 = 0 //检查费
  13813. var laboratoryCostTotal float64 = 0 //化验费
  13814. var laboratoryCostSelfTotal float64 = 0 //化验费
  13815. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13816. var treatCostTotal float64 = 0 //治疗费用
  13817. var treatCostSelfTotal float64 = 0 //治疗费用
  13818. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13819. decimal.DivisionPrecision = 2
  13820. var bed_fulamt_ownpay_amt float64 = 0
  13821. var operation_fulamt_ownpay_amt float64 = 0
  13822. var other_fulamt_ownpay_amt float64 = 0
  13823. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13824. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13825. var check_fulamt_ownpay_amt float64 = 0
  13826. var material_fulamt_ownpay_amt float64 = 0
  13827. var laboratory_fulamt_ownpay_amt float64 = 0
  13828. var treat_fulamt_ownpay_amt float64 = 0
  13829. var bed_claa_sunmfee float64 = 0
  13830. var bed_clab_amt float64 = 0
  13831. var bed_other_amt float64 = 0
  13832. var operation_claa_sunmfee float64 = 0
  13833. var operation_clab_amt float64 = 0
  13834. var operation_other_amt float64 = 0
  13835. var other_claa_sunmfee float64 = 0
  13836. var other_clab_amt float64 = 0
  13837. var other_other_amt float64 = 0
  13838. var westernMedicine_claa_sunmfee float64 = 0
  13839. var westernMedicine_clab_amt float64 = 0
  13840. var westernMedicine_other_amt float64 = 0
  13841. var chineseTraditional_claa_sunmfee float64 = 0
  13842. var chineseTraditional_clab_amt float64 = 0
  13843. var chineseTraditional_other_amt float64 = 0
  13844. var check_claa_sunmfee float64 = 0
  13845. var check_clab_amt float64 = 0
  13846. var check_other_amt float64 = 0
  13847. var material_claa_sunmfee float64 = 0
  13848. var material_clab_amt float64 = 0
  13849. var material_other_amt float64 = 0
  13850. var laboratory_claa_sunmfee float64 = 0
  13851. var laboratory_clab_amt float64 = 0
  13852. var laboratory_other_amt float64 = 0
  13853. var treat_claa_sunmfee float64 = 0
  13854. var treat_clab_amt float64 = 0
  13855. var treat_other_amt float64 = 0
  13856. for _, item := range order.HisOrderInfo {
  13857. if item.MedChrgitmType == "01" { //床位费
  13858. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13859. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13860. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13861. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13862. if item.ChrgitmLv == "1" {
  13863. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13864. }
  13865. if item.ChrgitmLv == "2" {
  13866. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13867. }
  13868. if item.ChrgitmLv == "3" {
  13869. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13870. }
  13871. }
  13872. if item.MedChrgitmType == "03" { //检查费
  13873. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13874. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13875. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13876. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13877. if item.ChrgitmLv == "1" {
  13878. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13879. }
  13880. if item.ChrgitmLv == "2" {
  13881. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13882. }
  13883. if item.ChrgitmLv == "3" {
  13884. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13885. }
  13886. }
  13887. if item.MedChrgitmType == "04" { //化验费
  13888. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13889. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13890. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13891. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13892. if item.ChrgitmLv == "1" {
  13893. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13894. }
  13895. if item.ChrgitmLv == "2" {
  13896. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13897. }
  13898. if item.ChrgitmLv == "3" {
  13899. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13900. }
  13901. }
  13902. if item.MedChrgitmType == "05" { //治疗费
  13903. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13904. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13905. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13906. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13907. if item.ChrgitmLv == "1" {
  13908. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13909. }
  13910. if item.ChrgitmLv == "2" {
  13911. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13912. }
  13913. if item.ChrgitmLv == "3" {
  13914. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13915. }
  13916. }
  13917. if item.MedChrgitmType == "06" { //手术费
  13918. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13919. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13920. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13921. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13922. if item.ChrgitmLv == "1" {
  13923. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13924. }
  13925. if item.ChrgitmLv == "2" {
  13926. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13927. }
  13928. if item.ChrgitmLv == "3" {
  13929. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13930. }
  13931. }
  13932. if item.MedChrgitmType == "08" { //材料费
  13933. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13934. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13935. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13936. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13937. if item.ChrgitmLv == "1" {
  13938. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13939. }
  13940. if item.ChrgitmLv == "2" {
  13941. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13942. }
  13943. if item.ChrgitmLv == "3" {
  13944. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13945. }
  13946. }
  13947. if item.MedChrgitmType == "09" { //西药费
  13948. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13949. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13950. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13951. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13952. if item.ChrgitmLv == "1" {
  13953. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13954. }
  13955. if item.ChrgitmLv == "2" {
  13956. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13957. }
  13958. if item.ChrgitmLv == "3" {
  13959. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13960. }
  13961. }
  13962. if item.MedChrgitmType == "11" { //中成费
  13963. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13964. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13965. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13966. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13967. if item.ChrgitmLv == "1" {
  13968. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13969. }
  13970. if item.ChrgitmLv == "2" {
  13971. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13972. }
  13973. if item.ChrgitmLv == "3" {
  13974. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13975. }
  13976. }
  13977. if item.MedChrgitmType == "14" { //其他费
  13978. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13979. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13980. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13981. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13982. if item.ChrgitmLv == "1" {
  13983. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13984. }
  13985. if item.ChrgitmLv == "2" {
  13986. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13987. }
  13988. if item.ChrgitmLv == "3" {
  13989. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13990. }
  13991. }
  13992. }
  13993. var iteminfoStructs []service.IteminfoStruct
  13994. if bedCostTotal != 0 {
  13995. iteminfo.MedChrgitm = "01"
  13996. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13997. iteminfo.Amt = bedCostTotal
  13998. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13999. iteminfo.ClabAmt = bed_clab_amt
  14000. iteminfo.OthAmt = bed_other_amt
  14001. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14002. }
  14003. if checkCostTotal != 0 {
  14004. iteminfo.MedChrgitm = "03"
  14005. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14006. iteminfo.Amt = checkCostTotal
  14007. iteminfo.ClaaSumfee = check_claa_sunmfee
  14008. iteminfo.ClabAmt = check_clab_amt
  14009. iteminfo.OthAmt = check_other_amt
  14010. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14011. }
  14012. if laboratoryCostTotal != 0 {
  14013. iteminfo.MedChrgitm = "04"
  14014. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14015. iteminfo.Amt = laboratoryCostTotal
  14016. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14017. iteminfo.ClabAmt = laboratory_clab_amt
  14018. iteminfo.OthAmt = laboratory_other_amt
  14019. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14020. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14021. }
  14022. if treatCostTotal != 0 {
  14023. iteminfo.MedChrgitm = "05"
  14024. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14025. iteminfo.Amt = treatCostTotal
  14026. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14027. iteminfo.ClabAmt = treat_clab_amt
  14028. iteminfo.OthAmt = treat_other_amt
  14029. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14030. //(struct4101.IteminfoStruct, iteminfo)
  14031. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14032. }
  14033. if operationCostTotal != 0 {
  14034. iteminfo.MedChrgitm = "06"
  14035. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14036. iteminfo.Amt = operationCostTotal
  14037. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14038. iteminfo.ClabAmt = operation_clab_amt
  14039. iteminfo.OthAmt = operation_other_amt
  14040. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14041. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14042. }
  14043. if materialCostTotal != 0 {
  14044. iteminfo.MedChrgitm = "08"
  14045. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14046. iteminfo.Amt = materialCostTotal
  14047. iteminfo.ClaaSumfee = material_claa_sunmfee
  14048. iteminfo.ClabAmt = material_clab_amt
  14049. iteminfo.OthAmt = material_other_amt
  14050. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14051. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14052. }
  14053. if westernMedicineCostTotal != 0 {
  14054. iteminfo.MedChrgitm = "09"
  14055. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14056. iteminfo.Amt = westernMedicineCostTotal
  14057. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14058. iteminfo.ClabAmt = westernMedicine_clab_amt
  14059. iteminfo.OthAmt = westernMedicine_other_amt
  14060. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14062. }
  14063. if chineseTraditionalMedicineCostTotal != 0 {
  14064. iteminfo.MedChrgitm = "11"
  14065. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14066. iteminfo.Amt = westernMedicineCostTotal
  14067. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14068. iteminfo.ClabAmt = westernMedicine_clab_amt
  14069. iteminfo.OthAmt = westernMedicine_other_amt
  14070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14072. }
  14073. if otherCostTotal != 0 {
  14074. iteminfo.MedChrgitm = "14"
  14075. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14076. iteminfo.Amt = otherCostTotal
  14077. iteminfo.ClaaSumfee = other_claa_sunmfee
  14078. iteminfo.ClabAmt = other_clab_amt
  14079. iteminfo.OthAmt = other_other_amt
  14080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14082. }
  14083. struct4101.IteminfoStruct = iteminfoStructs
  14084. struct4101.Ntly = "中国"
  14085. struct4101.AdmCaty = "A03.06"
  14086. var resOther ResultSeventeenOther
  14087. var res ResultSeventeen
  14088. if miConfig.MdtrtareaAdmvs == "150499" {
  14089. var pp models.PublicParams
  14090. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14091. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14092. pp.FixmedinsName = miConfig.OrgName
  14093. pp.FixmedinsCode = miConfig.Code
  14094. pp.RequestUrl = miConfig.Url
  14095. pp.Cainfo = miConfig.Cainfo
  14096. pp.SecretKey = miConfig.SecretKey
  14097. pp.AccessKey = miConfig.AccessKey
  14098. pp.OpterName = curRoles.UserName
  14099. client := &http.Client{}
  14100. var req *http.Request
  14101. data := make(map[string]interface{})
  14102. data["struct4101"] = struct4101
  14103. data["pp"] = pp
  14104. bytesData, _ := json.Marshal(data)
  14105. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14106. resp, _ := client.Do(req)
  14107. defer resp.Body.Close()
  14108. body, ioErr := ioutil.ReadAll(resp.Body)
  14109. if ioErr != nil {
  14110. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14112. return
  14113. }
  14114. var respJSON map[string]interface{}
  14115. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14116. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14118. return
  14119. }
  14120. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14121. userJSONBytes, _ := json.Marshal(respJSON)
  14122. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14123. utils.ErrorLog("解析失败:%v", err)
  14124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14125. return
  14126. }
  14127. res.InfRefmsgid = resOther.InfRefmsgid
  14128. res.Output = resOther.Output
  14129. res.ErrMsg = resOther.ErrMsg
  14130. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14131. res.Infcode = infocode
  14132. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14133. var pp models.PublicParams
  14134. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14135. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14136. pp.FixmedinsName = miConfig.OrgName
  14137. pp.FixmedinsCode = miConfig.Code
  14138. pp.RequestUrl = miConfig.Url
  14139. pp.Cainfo = miConfig.Cainfo
  14140. pp.SecretKey = miConfig.SecretKey
  14141. pp.AccessKey = miConfig.AccessKey
  14142. pp.OpterName = curRoles.UserName
  14143. result, _ := service.Jxyb4101(struct4101, pp)
  14144. var dat map[string]interface{}
  14145. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14146. fmt.Println(dat)
  14147. } else {
  14148. fmt.Println(err)
  14149. }
  14150. userJSONBytes, _ := json.Marshal(dat)
  14151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14152. utils.ErrorLog("解析失败:%v", err)
  14153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14154. return
  14155. }
  14156. } else {
  14157. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14158. var dat map[string]interface{}
  14159. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14160. fmt.Println(dat)
  14161. } else {
  14162. fmt.Println(err)
  14163. }
  14164. userJSONBytes, _ := json.Marshal(dat)
  14165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14166. utils.ErrorLog("解析失败:%v", err)
  14167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14168. return
  14169. }
  14170. }
  14171. if res.Infcode != 0 {
  14172. c.ServeSuccessJSON(map[string]interface{}{
  14173. "failed_code": -10,
  14174. "msg": res.ErrMsg,
  14175. })
  14176. return
  14177. } else {
  14178. if miConfig.MdtrtareaAdmvs != "150499" {
  14179. order.FaPiaoNumber = zero
  14180. order.FaPiaoCode = last_order.FaPiaoCode
  14181. service.UpdateOrder(order)
  14182. }
  14183. hisFundSettleListResult := &models.HisFundSettleListResult{
  14184. Number: res.Output.SetlListId,
  14185. Status: 1,
  14186. Ctime: time.Now().Unix(),
  14187. Mtime: time.Now().Unix(),
  14188. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14189. IsUpload: 1,
  14190. OrderId: order_id,
  14191. }
  14192. service.CreateUploadRecord(hisFundSettleListResult)
  14193. c.ServeSuccessJSON(map[string]interface{}{
  14194. "msg": "上传成功",
  14195. "result": hisFundSettleListResult,
  14196. })
  14197. return
  14198. }
  14199. }
  14200. //func (c *HisApiController) GetBatchSettleList() {
  14201. // orders, _ := service.GetAllHisOrder(10106)
  14202. // for _, item := range orders {
  14203. // order_id := item.ID
  14204. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14205. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14206. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14207. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14208. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14209. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14210. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14211. //
  14212. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14213. //
  14214. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14215. //
  14216. // if order.ID == 0 {
  14217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14218. // return
  14219. // }
  14220. // if his.BalanceAccountsType == 2 {
  14221. // continue
  14222. // }
  14223. // struct4101 := service.Struct4101{
  14224. // PsnNo: order.PsnNo,
  14225. // MdtrtId: order.MdtrtId,
  14226. // SetlId: order.SetlId,
  14227. // PsnName: order.PsnName,
  14228. // Gend: order.Gend,
  14229. // Brdy: his.Brdy,
  14230. // Age: his.Age,
  14231. // Naty: order.Naty,
  14232. // PatnCertType: "01",
  14233. // Certno: order.Certno,
  14234. // Prfs: "90",
  14235. // ConerName: roles[0].UserName,
  14236. // PatnRlts: "99",
  14237. // ConerAddr: miConfig.OrgName,
  14238. // ConerTel: admin.Mobile,
  14239. // HiType: order.Insutype,
  14240. // Insuplc: his.InsuplcAdmdvs,
  14241. // MaindiagFlag: "1",
  14242. // BillCode: order.SetlId,
  14243. // BillNo: order.SetlId,
  14244. // BizSn: order.Number,
  14245. // PsnSelfPay: order.PsnPartAmt,
  14246. // PsnOwnPay: order.PsnPartAmt,
  14247. // AcctPay: order.AcctPay,
  14248. // PsnCashpay: order.PsnCashPay,
  14249. // HiPaymtd: "1",
  14250. // Hsorg: his.InsuplcAdmdvs,
  14251. // HsorgOpter: his.InsuplcAdmdvs,
  14252. // MedinsFillPsn: curRoles.UserName,
  14253. // MedinsFillDept: depart.Name,
  14254. // IptMedType: "2",
  14255. // }
  14256. // struct4101.SetlBegnDate = order.SetlTime
  14257. // struct4101.SetlEndDate = order.SetlTime
  14258. // //if order.SettleType == 1 {
  14259. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14260. // // dateStr := t.Format("2006-01-02")
  14261. // // struct4101.SetlBegnDate = dateStr
  14262. // // struct4101.SetlEndDate = dateStr
  14263. // //} else {
  14264. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14265. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14266. // // dateStartStr := t.Format("2006-01-02")
  14267. // // dateEndStr := t2.Format("2006-01-02")
  14268. // // struct4101.SetlBegnDate = dateStartStr
  14269. // // struct4101.SetlEndDate = dateEndStr
  14270. // //}
  14271. //
  14272. // var rf []CustomFundPay
  14273. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14274. //
  14275. // var tempFunPays []service.CustomStruct
  14276. // var tempFunPay610100 service.CustomStruct
  14277. //
  14278. // for _, item := range rf {
  14279. // if item.FundPayType == "610100" {
  14280. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14281. // tempFunPay610100.FundPayType = item.FundPayType
  14282. // } else {
  14283. // var tempFunPay service.CustomStruct
  14284. // tempFunPay.FundPayamt = item.FundPayamt
  14285. // tempFunPay.FundPayType = item.FundPayType
  14286. // tempFunPays = append(tempFunPays, tempFunPay)
  14287. // }
  14288. // }
  14289. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14290. // struct4101.CustomStruct = tempFunPays
  14291. //
  14292. // var tempDiaginfos []service.DiaginfoStructTwo
  14293. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14294. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14295. //
  14296. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14297. // var config []*models.HisXtDiagnoseConfig
  14298. // for _, item := range diagnosis_ids {
  14299. // id, _ := strconv.ParseInt(item, 10, 64)
  14300. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14301. // config = append(config, &diagnosisConfig)
  14302. // }
  14303. //
  14304. // for index, item := range config {
  14305. // if index == 0 {
  14306. // var tempDiaginfo service.DiaginfoStructTwo
  14307. // tempDiaginfo.DiagCode = item.CountryCode
  14308. // tempDiaginfo.DiagName = item.CountryContentName
  14309. // tempDiaginfo.DiagType = "1"
  14310. // tempDiaginfo.MaindiagFlag = "1"
  14311. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14312. // } else {
  14313. //
  14314. // var tempDiaginfo service.DiaginfoStructTwo
  14315. // tempDiaginfo.DiagCode = item.CountryCode
  14316. // tempDiaginfo.DiagName = item.CountryContentName
  14317. // tempDiaginfo.DiagType = "2"
  14318. // tempDiaginfo.MaindiagFlag = "0"
  14319. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14320. // }
  14321. // }
  14322. // struct4101.Diseinfo = tempDiaginfos
  14323. //
  14324. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14325. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14326. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14327. // tempOpspdiseinfo2.OprnOprtCode = ""
  14328. // tempOpspdiseinfo2.OprnOprtName = ""
  14329. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14330. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14331. //
  14332. // var iteminfo service.IteminfoStruct
  14333. //
  14334. // var bedCostTotal float64 = 0 //床位总费
  14335. // var bedCostSelfTotal float64 = 0 //床位自费
  14336. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14337. //
  14338. // var examineCostTotal float64 = 0 //诊查总费
  14339. // var examineCostSelfTotal float64 = 0 //诊查自费
  14340. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14341. //
  14342. // var nursingCostTotal float64 = 0 //护理总费
  14343. // var nursingCostSelfTotal float64 = 0 //护理自费
  14344. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14345. //
  14346. // var chineseMedicineCostTotal float64 = 0 //中成药
  14347. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14348. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14349. //
  14350. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14351. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14352. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14353. //
  14354. // var registerCostTotal float64 = 0 //一般诊疗费
  14355. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14356. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14357. //
  14358. // var operationCostTotal float64 = 0 //手术费
  14359. // var operationCostSelfTotal float64 = 0 //手术费
  14360. // var operationCostPartSelfTotal float64 = 0 //手术费
  14361. //
  14362. // var otherCostTotal float64 = 0 //其他费用
  14363. // var otherCostSelfTotal float64 = 0 //其他费用
  14364. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14365. //
  14366. // var materialCostTotal float64 = 0 //材料费
  14367. // var materialCostSelfTotal float64 = 0 //材料费
  14368. // var materialCostPartSelfTotal float64 = 0 //材料费
  14369. //
  14370. // var westernMedicineCostTotal float64 = 0 //西药费
  14371. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14372. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14373. //
  14374. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14375. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14376. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14377. //
  14378. // var checkCostTotal float64 = 0 //检查费
  14379. // var checkCostSelfTotal float64 = 0 //检查费
  14380. // var checkCostPartSelfTotal float64 = 0 //检查费
  14381. //
  14382. // var laboratoryCostTotal float64 = 0 //化验费
  14383. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14384. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14385. //
  14386. // var treatCostTotal float64 = 0 //治疗费用
  14387. // var treatCostSelfTotal float64 = 0 //治疗费用
  14388. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14389. //
  14390. // decimal.DivisionPrecision = 2
  14391. //
  14392. // var bed_fulamt_ownpay_amt float64 = 0
  14393. //
  14394. // var examine_fulamt_ownpay_amt float64 = 0
  14395. //
  14396. // var nursing_fulamt_ownpay_amt float64 = 0
  14397. //
  14398. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14399. //
  14400. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14401. //
  14402. // var register_fulamt_ownpay_amt float64 = 0
  14403. //
  14404. // var operation_fulamt_ownpay_amt float64 = 0
  14405. // var other_fulamt_ownpay_amt float64 = 0
  14406. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14407. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14408. // var check_fulamt_ownpay_amt float64 = 0
  14409. // var material_fulamt_ownpay_amt float64 = 0
  14410. // var laboratory_fulamt_ownpay_amt float64 = 0
  14411. // var treat_fulamt_ownpay_amt float64 = 0
  14412. //
  14413. // var bed_claa_sunmfee float64 = 0
  14414. // var bed_clab_amt float64 = 0
  14415. // var bed_other_amt float64 = 0
  14416. //
  14417. // var examine_claa_sunmfee float64 = 0
  14418. // var examine_clab_amt float64 = 0
  14419. // var examine_other_amt float64 = 0
  14420. //
  14421. // var nursing_claa_sunmfee float64 = 0
  14422. // var nursing_clab_amt float64 = 0
  14423. // var nursing_other_amt float64 = 0
  14424. //
  14425. // var chinese_medicine_claa_sunmfee float64 = 0
  14426. // var chinese_medicine_clab_amt float64 = 0
  14427. // var chinese_medicine_other_amt float64 = 0
  14428. //
  14429. // var commonly_treatment_claa_sunmfee float64 = 0
  14430. // var commonly_treatment_clab_amt float64 = 0
  14431. // var commonly_treatment_other_amt float64 = 0
  14432. //
  14433. // var operation_claa_sunmfee float64 = 0
  14434. // var operation_clab_amt float64 = 0
  14435. // var operation_other_amt float64 = 0
  14436. //
  14437. // var other_claa_sunmfee float64 = 0
  14438. // var other_clab_amt float64 = 0
  14439. // var other_other_amt float64 = 0
  14440. //
  14441. // var westernMedicine_claa_sunmfee float64 = 0
  14442. // var westernMedicine_clab_amt float64 = 0
  14443. // var westernMedicine_other_amt float64 = 0
  14444. //
  14445. // var chineseTraditional_claa_sunmfee float64 = 0
  14446. // var chineseTraditional_clab_amt float64 = 0
  14447. // var chineseTraditional_other_amt float64 = 0
  14448. //
  14449. // var check_claa_sunmfee float64 = 0
  14450. // var check_clab_amt float64 = 0
  14451. // var check_other_amt float64 = 0
  14452. //
  14453. // var material_claa_sunmfee float64 = 0
  14454. // var material_clab_amt float64 = 0
  14455. // var material_other_amt float64 = 0
  14456. //
  14457. // var laboratory_claa_sunmfee float64 = 0
  14458. // var laboratory_clab_amt float64 = 0
  14459. // var laboratory_other_amt float64 = 0
  14460. //
  14461. // var treat_claa_sunmfee float64 = 0
  14462. // var treat_clab_amt float64 = 0
  14463. // var treat_other_amt float64 = 0
  14464. //
  14465. // var register_claa_sunmfee float64 = 0
  14466. // var register_clab_amt float64 = 0
  14467. // var register_other_amt float64 = 0
  14468. //
  14469. // for _, item := range order.HisOrderInfo {
  14470. // if item.MedChrgitmType == "01" { //床位费
  14471. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14472. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14473. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14474. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14475. // if item.ChrgitmLv == "1" {
  14476. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14477. // }
  14478. // if item.ChrgitmLv == "2" {
  14479. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14480. //
  14481. // }
  14482. // if item.ChrgitmLv == "3" {
  14483. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14484. // }
  14485. //
  14486. // }
  14487. //
  14488. // if item.MedChrgitmType == "02" { //诊查
  14489. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14490. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14491. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14492. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14493. // if item.ChrgitmLv == "1" {
  14494. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14495. // }
  14496. // if item.ChrgitmLv == "2" {
  14497. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14498. //
  14499. // }
  14500. // if item.ChrgitmLv == "3" {
  14501. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14502. // }
  14503. //
  14504. // }
  14505. //
  14506. // if item.MedChrgitmType == "03" { //检查费
  14507. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14508. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14509. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14510. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14511. // if item.ChrgitmLv == "1" {
  14512. //
  14513. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14514. //
  14515. // }
  14516. // if item.ChrgitmLv == "2" {
  14517. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14518. //
  14519. // }
  14520. // if item.ChrgitmLv == "3" {
  14521. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14522. // }
  14523. // }
  14524. //
  14525. // if item.MedChrgitmType == "04" { //化验费
  14526. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14527. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14528. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14529. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14530. // if item.ChrgitmLv == "1" {
  14531. //
  14532. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14533. //
  14534. // }
  14535. // if item.ChrgitmLv == "2" {
  14536. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14537. //
  14538. // }
  14539. // if item.ChrgitmLv == "3" {
  14540. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14541. // }
  14542. // }
  14543. //
  14544. // if item.MedChrgitmType == "05" { //治疗费
  14545. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14546. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14547. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14548. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14549. // if item.ChrgitmLv == "1" {
  14550. //
  14551. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14552. //
  14553. // }
  14554. // if item.ChrgitmLv == "2" {
  14555. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14556. //
  14557. // }
  14558. // if item.ChrgitmLv == "3" {
  14559. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14560. // }
  14561. // }
  14562. //
  14563. // if item.MedChrgitmType == "06" { //手术费
  14564. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14565. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14566. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14567. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14568. //
  14569. // if item.ChrgitmLv == "1" {
  14570. //
  14571. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14572. //
  14573. // }
  14574. // if item.ChrgitmLv == "2" {
  14575. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14576. //
  14577. // }
  14578. // if item.ChrgitmLv == "3" {
  14579. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14580. // }
  14581. // }
  14582. //
  14583. // if item.MedChrgitmType == "07" { //手术费
  14584. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14585. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14586. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14587. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14588. //
  14589. // if item.ChrgitmLv == "1" {
  14590. //
  14591. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14592. //
  14593. // }
  14594. // if item.ChrgitmLv == "2" {
  14595. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14596. //
  14597. // }
  14598. // if item.ChrgitmLv == "3" {
  14599. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14600. // }
  14601. // }
  14602. //
  14603. // if item.MedChrgitmType == "08" { //材料费
  14604. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14605. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14606. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14607. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14608. // if item.ChrgitmLv == "1" {
  14609. //
  14610. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14611. //
  14612. // }
  14613. // if item.ChrgitmLv == "2" {
  14614. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14615. //
  14616. // }
  14617. // if item.ChrgitmLv == "3" {
  14618. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14619. // }
  14620. // }
  14621. // if item.MedChrgitmType == "09" { //西药费
  14622. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14623. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14624. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14625. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14626. // if item.ChrgitmLv == "1" {
  14627. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14628. // }
  14629. // if item.ChrgitmLv == "2" {
  14630. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14631. // }
  14632. // if item.ChrgitmLv == "3" {
  14633. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14634. // }
  14635. // }
  14636. // if item.MedChrgitmType == "10" { //中药饮片
  14637. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14638. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14639. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14640. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14641. // if item.ChrgitmLv == "1" {
  14642. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14643. // }
  14644. // if item.ChrgitmLv == "2" {
  14645. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14646. // }
  14647. // if item.ChrgitmLv == "3" {
  14648. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14649. // }
  14650. // }
  14651. //
  14652. // if item.MedChrgitmType == "11" { //中成费
  14653. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14654. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14655. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14656. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14657. // if item.ChrgitmLv == "1" {
  14658. //
  14659. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14660. //
  14661. // }
  14662. // if item.ChrgitmLv == "2" {
  14663. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14664. //
  14665. // }
  14666. // if item.ChrgitmLv == "3" {
  14667. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14668. // }
  14669. // }
  14670. //
  14671. // if item.MedChrgitmType == "12" { //中成费
  14672. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14673. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14674. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14675. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14676. // if item.ChrgitmLv == "1" {
  14677. //
  14678. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14679. //
  14680. // }
  14681. // if item.ChrgitmLv == "2" {
  14682. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14683. //
  14684. // }
  14685. // if item.ChrgitmLv == "3" {
  14686. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14687. // }
  14688. // }
  14689. //
  14690. // if item.MedChrgitmType == "13" { //中成费
  14691. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14692. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14693. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14694. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14695. // if item.ChrgitmLv == "1" {
  14696. //
  14697. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14698. //
  14699. // }
  14700. // if item.ChrgitmLv == "2" {
  14701. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14702. //
  14703. // }
  14704. // if item.ChrgitmLv == "3" {
  14705. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14706. // }
  14707. // }
  14708. //
  14709. // if item.MedChrgitmType == "14" { //其他费
  14710. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14711. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14712. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14713. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14714. // if item.ChrgitmLv == "1" {
  14715. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14716. //
  14717. // }
  14718. // if item.ChrgitmLv == "2" {
  14719. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14720. //
  14721. // }
  14722. // if item.ChrgitmLv == "3" {
  14723. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14724. // }
  14725. // }
  14726. //
  14727. // }
  14728. //
  14729. // var iteminfoStructs []service.IteminfoStruct
  14730. //
  14731. // if bedCostTotal != 0 {
  14732. // iteminfo.MedChrgitm = "01"
  14733. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14734. // iteminfo.Amt = bedCostTotal
  14735. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14736. // iteminfo.ClabAmt = bed_clab_amt
  14737. // iteminfo.OthAmt = bed_other_amt
  14738. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14739. // }
  14740. //
  14741. // if examineCostTotal != 0 {
  14742. // iteminfo.MedChrgitm = "02"
  14743. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14744. // iteminfo.Amt = examineCostTotal
  14745. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14746. // iteminfo.ClabAmt = examine_clab_amt
  14747. // iteminfo.OthAmt = examine_other_amt
  14748. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14749. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14750. // }
  14751. //
  14752. // if checkCostTotal != 0 {
  14753. // iteminfo.MedChrgitm = "03"
  14754. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14755. // iteminfo.Amt = checkCostTotal
  14756. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14757. // iteminfo.ClabAmt = check_clab_amt
  14758. // iteminfo.OthAmt = check_other_amt
  14759. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14760. //
  14761. // }
  14762. //
  14763. // if laboratoryCostTotal != 0 {
  14764. // iteminfo.MedChrgitm = "04"
  14765. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14766. // iteminfo.Amt = laboratoryCostTotal
  14767. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14768. // iteminfo.ClabAmt = laboratory_clab_amt
  14769. // iteminfo.OthAmt = laboratory_other_amt
  14770. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14771. //
  14772. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14773. //
  14774. // }
  14775. //
  14776. // if treatCostTotal != 0 {
  14777. // iteminfo.MedChrgitm = "05"
  14778. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14779. // iteminfo.Amt = treatCostTotal
  14780. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14781. // iteminfo.ClabAmt = treat_clab_amt
  14782. // iteminfo.OthAmt = treat_other_amt
  14783. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14784. // //(struct4101.IteminfoStruct, iteminfo)
  14785. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14786. // }
  14787. //
  14788. // if operationCostTotal != 0 {
  14789. // iteminfo.MedChrgitm = "06"
  14790. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14791. // iteminfo.Amt = operationCostTotal
  14792. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14793. // iteminfo.ClabAmt = operation_clab_amt
  14794. // iteminfo.OthAmt = operation_other_amt
  14795. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14796. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14797. // }
  14798. //
  14799. // if nursingCostTotal != 0 {
  14800. // iteminfo.MedChrgitm = "07"
  14801. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14802. // iteminfo.Amt = nursingCostTotal
  14803. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14804. // iteminfo.ClabAmt = nursing_clab_amt
  14805. // iteminfo.OthAmt = nursing_other_amt
  14806. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14807. // }
  14808. //
  14809. // if materialCostTotal != 0 {
  14810. // iteminfo.MedChrgitm = "08"
  14811. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14812. // iteminfo.Amt = materialCostTotal
  14813. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14814. // iteminfo.ClabAmt = material_clab_amt
  14815. // iteminfo.OthAmt = material_other_amt
  14816. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14817. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14818. // }
  14819. //
  14820. // if westernMedicineCostTotal != 0 {
  14821. // iteminfo.MedChrgitm = "09"
  14822. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14823. // iteminfo.Amt = westernMedicineCostTotal
  14824. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14825. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14826. // iteminfo.OthAmt = westernMedicine_other_amt
  14827. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14828. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14829. //
  14830. // }
  14831. //
  14832. // if chineseMedicineCostTotal != 0 {
  14833. // iteminfo.MedChrgitm = "10"
  14834. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14835. // iteminfo.Amt = chineseMedicineCostTotal
  14836. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14837. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14838. // iteminfo.OthAmt = chinese_medicine_other_amt
  14839. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14840. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14841. //
  14842. // }
  14843. //
  14844. // if chineseTraditionalMedicineCostTotal != 0 {
  14845. // iteminfo.MedChrgitm = "11"
  14846. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14847. // iteminfo.Amt = westernMedicineCostTotal
  14848. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14849. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14850. // iteminfo.OthAmt = westernMedicine_other_amt
  14851. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14852. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14853. //
  14854. // }
  14855. //
  14856. // if commonlyTreatmentCostTotal != 0 {
  14857. // iteminfo.MedChrgitm = "12"
  14858. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14859. // iteminfo.Amt = commonlyTreatmentCostTotal
  14860. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14861. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14862. // iteminfo.OthAmt = commonly_treatment_other_amt
  14863. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14864. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14865. //
  14866. // }
  14867. //
  14868. // if registerCostTotal != 0 {
  14869. // iteminfo.MedChrgitm = "13"
  14870. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14871. // iteminfo.Amt = registerCostTotal
  14872. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14873. // iteminfo.ClabAmt = register_clab_amt
  14874. // iteminfo.OthAmt = register_other_amt
  14875. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14876. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14877. //
  14878. // }
  14879. //
  14880. // if otherCostTotal != 0 {
  14881. // iteminfo.MedChrgitm = "14"
  14882. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14883. // iteminfo.Amt = otherCostTotal
  14884. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14885. // iteminfo.ClabAmt = other_clab_amt
  14886. // iteminfo.OthAmt = other_other_amt
  14887. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14888. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14889. //
  14890. // }
  14891. // struct4101.IteminfoStruct = iteminfoStructs
  14892. // time_arr := strings.Split(order.SetlTime, " ")
  14893. // struct4101.AdmTime = time_arr[0]
  14894. // struct4101.AdmEndTime = time_arr[0]
  14895. //
  14896. // struct4101.DoctorName = doctor.UserName
  14897. // struct4101.DoctorCode = doctor.DoctorNumber
  14898. //
  14899. // struct4101.Ntly = "中国"
  14900. // struct4101.AdmCaty = "A03.06"
  14901. // var res ResultSeventeen
  14902. // if miConfig.MdtrtareaAdmvs == "421300" {
  14903. // data := make(map[string]interface{})
  14904. // data["struct4101"] = struct4101
  14905. // data["secret_key"] = miConfig.SecretKey
  14906. // data["org_name"] = miConfig.OrgName
  14907. // data["opera"] = curRoles.UserName
  14908. // data["code"] = miConfig.Code
  14909. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14910. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14911. //
  14912. // client := &http.Client{}
  14913. // bytesData, _ := json.Marshal(data)
  14914. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14915. // resp, _ := client.Do(req)
  14916. // defer resp.Body.Close()
  14917. // body, ioErr := ioutil.ReadAll(resp.Body)
  14918. // if ioErr != nil {
  14919. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14921. // return
  14922. // }
  14923. // var respJSON map[string]interface{}
  14924. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14925. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14927. // return
  14928. // }
  14929. //
  14930. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14931. // userJSONBytes, _ := json.Marshal(respJSON)
  14932. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14933. // utils.ErrorLog("解析失败:%v", err)
  14934. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14935. // adminUser := c.GetAdminUserInfo()
  14936. // errlog := &models.HisOrderError{
  14937. // UserOrgId: adminUser.CurrentOrgId,
  14938. // Ctime: time.Now().Unix(),
  14939. // Mtime: time.Now().Unix(),
  14940. // ErrMsg: res.ErrMsg + "解析失败",
  14941. // Status: 1,
  14942. // PatientId: order_id,
  14943. // Stage: 10088,
  14944. // }
  14945. // service.CreateErrMsgLog(errlog)
  14946. // continue
  14947. // }
  14948. //
  14949. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14950. // data := make(map[string]interface{})
  14951. // data["struct4101"] = struct4101
  14952. // data["secret_key"] = miConfig.SecretKey
  14953. // data["org_name"] = miConfig.OrgName
  14954. // data["opera"] = curRoles.UserName
  14955. // data["code"] = miConfig.Code
  14956. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14957. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14958. //
  14959. // client := &http.Client{}
  14960. // bytesData, _ := json.Marshal(data)
  14961. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14962. // resp, _ := client.Do(req)
  14963. // defer resp.Body.Close()
  14964. // body, ioErr := ioutil.ReadAll(resp.Body)
  14965. // if ioErr != nil {
  14966. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14967. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14968. // return
  14969. // }
  14970. // var respJSON map[string]interface{}
  14971. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14972. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14973. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14974. // return
  14975. // }
  14976. //
  14977. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14978. // userJSONBytes, _ := json.Marshal(respJSON)
  14979. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14980. // utils.ErrorLog("解析失败:%v", err)
  14981. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14982. // adminUser := c.GetAdminUserInfo()
  14983. // errlog := &models.HisOrderError{
  14984. // UserOrgId: adminUser.CurrentOrgId,
  14985. // Ctime: time.Now().Unix(),
  14986. // Mtime: time.Now().Unix(),
  14987. // ErrMsg: res.ErrMsg + "解析失败",
  14988. // Status: 1,
  14989. // PatientId: order_id,
  14990. // Stage: 10088,
  14991. // }
  14992. // service.CreateErrMsgLog(errlog)
  14993. // continue
  14994. // }
  14995. //
  14996. // } else {
  14997. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14998. // fmt.Println(result)
  14999. //
  15000. // var dat map[string]interface{}
  15001. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15002. // fmt.Println(dat)
  15003. // } else {
  15004. // fmt.Println(err)
  15005. // }
  15006. // userJSONBytes, _ := json.Marshal(dat)
  15007. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15008. // utils.ErrorLog("解析失败:%v", err)
  15009. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15010. // adminUser := c.GetAdminUserInfo()
  15011. // errlog := &models.HisOrderError{
  15012. // UserOrgId: adminUser.CurrentOrgId,
  15013. // Ctime: time.Now().Unix(),
  15014. // Mtime: time.Now().Unix(),
  15015. // ErrMsg: res.ErrMsg + "解析失败",
  15016. // Status: 1,
  15017. // PatientId: order_id,
  15018. // Stage: 10106,
  15019. // }
  15020. // service.CreateErrMsgLog(errlog)
  15021. // continue
  15022. // }
  15023. // }
  15024. //
  15025. // if res.Infcode != 0 {
  15026. // adminUser := c.GetAdminUserInfo()
  15027. // errlog := &models.HisOrderError{
  15028. // UserOrgId: adminUser.CurrentOrgId,
  15029. // Ctime: time.Now().Unix(),
  15030. // Mtime: time.Now().Unix(),
  15031. // ErrMsg: res.ErrMsg,
  15032. // Status: 1,
  15033. // PatientId: order_id,
  15034. // Stage: 10106,
  15035. // }
  15036. // service.CreateErrMsgLog(errlog)
  15037. // continue
  15038. // } else {
  15039. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15040. // Number: res.Output.SetlListId,
  15041. // Status: 1,
  15042. // Ctime: time.Now().Unix(),
  15043. // Mtime: time.Now().Unix(),
  15044. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15045. // IsUpload: 1,
  15046. // OrderId: order_id,
  15047. // }
  15048. // service.CreateUploadRecord(hisFundSettleListResult)
  15049. // continue
  15050. // }
  15051. // }
  15052. //}
  15053. func (c *HisApiController) GetOrgInfo() {
  15054. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15055. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15056. }
  15057. func (c *HisApiController) GetHisPatientInfo() {
  15058. medical_insurance_card := c.GetString("medical_insurance_card")
  15059. id_card_type, _ := c.GetInt64("id_card_type")
  15060. id_card := c.GetString("id_card")
  15061. adminInfo := c.GetAdminUserInfo()
  15062. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15063. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15064. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15065. IdCardNo := ""
  15066. if id_card_type == 1 {
  15067. IdCardNo = medical_insurance_card
  15068. } else if id_card_type == 2 {
  15069. IdCardNo = id_card
  15070. }
  15071. if config.IsOpen == 1 {
  15072. 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
  15073. resp, requestErr := http.Get(api)
  15074. if requestErr != nil {
  15075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15076. return
  15077. }
  15078. defer resp.Body.Close()
  15079. body, ioErr := ioutil.ReadAll(resp.Body)
  15080. if ioErr != nil {
  15081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15083. return
  15084. }
  15085. var respJSON map[string]interface{}
  15086. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15089. return
  15090. }
  15091. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15092. userJSONBytes, _ := json.Marshal(userJSON)
  15093. var res ResultTwo
  15094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15095. utils.ErrorLog("解析失败:%v", err)
  15096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15097. return
  15098. }
  15099. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15100. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15101. infoStr := string(Iinfos)
  15102. idetinfoStr := string(Idetinfos)
  15103. if res.Infcode == 0 {
  15104. his := models.VMHisPatient{
  15105. Status: 1,
  15106. Ctime: time.Now().Unix(),
  15107. Mtime: time.Now().Unix(),
  15108. PsnNo: res.Output.Baseinfo.PsnNo,
  15109. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15110. Certno: res.Output.Baseinfo.Certno,
  15111. PsnName: res.Output.Baseinfo.PsnName,
  15112. Gend: res.Output.Baseinfo.Gend,
  15113. Naty: res.Output.Baseinfo.Naty,
  15114. Iinfo: infoStr,
  15115. Idetinfo: idetinfoStr,
  15116. UserOrgId: adminInfo.CurrentOrgId,
  15117. IsReturn: 1,
  15118. IdCardType: id_card_type,
  15119. }
  15120. c.ServeSuccessJSON(map[string]interface{}{
  15121. "info": his,
  15122. })
  15123. } else {
  15124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15125. return
  15126. }
  15127. }
  15128. }
  15129. //func GetBasBaseInfo() (jsonStr string, err error) {
  15130. //
  15131. // handle := syscall.NewLazyDLL("SSCard.dll")
  15132. // add := handle.NewProc("ReadCardBas")
  15133. // str := make([]byte, 1024)
  15134. // str1 := make([]byte, 1024)
  15135. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15136. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15137. //
  15138. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15139. //
  15140. // fmt.Println("> Add(4,5)的结果为:", ret)
  15141. // handle.Release()
  15142. //
  15143. // return "", nil
  15144. //
  15145. //}
  15146. //func GetQRBaseInfo() (jsonStr string, err error) {
  15147. // handle := syscall.LoadDLL("SSCard.dll")
  15148. // ReadCardBas := handle.FindProc("GetQRBase")
  15149. //
  15150. // str := make([]byte, 256)
  15151. // str1 := make([]byte, 256)
  15152. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15153. //
  15154. // fmt.Println(string(str))
  15155. // fmt.Println(r)
  15156. // return string(str), nil
  15157. //}
  15158. //func CardInit() int {
  15159. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15160. // add := DllTestDef.MustFindProc("Init")
  15161. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15162. // if err != nil {
  15163. // fmt.Println("SSCard的运算结果为:", ret)
  15164. // }
  15165. // result := int(ret)
  15166. // return result
  15167. //}
  15168. //func CardInit() int {
  15169. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15170. // if err != nil {
  15171. // fmt.Println("SSCard的运算结果为:", ret)
  15172. // }
  15173. // fmt.Println(err)
  15174. // result := int(ret)
  15175. // return result
  15176. //}
  15177. func IntPtr(n int) uintptr {
  15178. return uintptr(n)
  15179. }
  15180. func StrPtr(s string) uintptr {
  15181. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15182. }
  15183. type Result2001 struct {
  15184. Cainfo interface{} `json:"cainfo"`
  15185. ErrMsg string `json:"err_msg"`
  15186. InfRefmsgid string `json:"inf_refmsgid"`
  15187. Infcode int64 `json:"infcode"`
  15188. Output struct {
  15189. Trtinfo struct {
  15190. PsnNo string `json:"psn_no"`
  15191. TrtChkType string `json:"trt_chk_type"`
  15192. FundPayType string `json:"fund_pay_type"`
  15193. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15194. Begndate string `json:"begndate"`
  15195. Enddate string `json:"enddate"`
  15196. TrtChkRslt string `json:"trt_chk_rslt"`
  15197. } `json:"trtinfo"`
  15198. } `json:"output"`
  15199. RefmsgTime string `json:"refmsg_time"`
  15200. RespondTime string `json:"respond_time"`
  15201. Signtype interface{} `json:"signtype"`
  15202. WarnMsg interface{} `json:"warn_msg"`
  15203. }
  15204. type Result2001Org10265 struct {
  15205. Cainfo interface{} `json:"cainfo"`
  15206. ErrMsg string `json:"err_msg"`
  15207. InfRefmsgid string `json:"inf_refmsgid"`
  15208. Infcode string `json:"infcode"`
  15209. Output struct {
  15210. Trtinfo struct {
  15211. PsnNo string `json:"psn_no"`
  15212. TrtChkType string `json:"trt_chk_type"`
  15213. FundPayType string `json:"fund_pay_type"`
  15214. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15215. Begndate string `json:"begndate"`
  15216. Enddate string `json:"enddate"`
  15217. TrtChkRslt string `json:"trt_chk_rslt"`
  15218. } `json:"trtinfo"`
  15219. } `json:"output"`
  15220. RefmsgTime string `json:"refmsg_time"`
  15221. RespondTime string `json:"respond_time"`
  15222. Signtype interface{} `json:"signtype"`
  15223. WarnMsg interface{} `json:"warn_msg"`
  15224. }
  15225. type ResultTwo struct {
  15226. ErrMsg string `json:"err_msg"`
  15227. InfRefmsgid string `json:"inf_refmsgid"`
  15228. Infcode int64 `json:"infcode"`
  15229. Output struct {
  15230. Baseinfo struct {
  15231. //Brdy string `json:"brdy"`
  15232. Certno string `json:"certno"`
  15233. Gend string `json:"gend"`
  15234. Naty string `json:"naty"`
  15235. PsnCertType string `json:"psn_cert_type"`
  15236. PsnName string `json:"psn_name"`
  15237. PsnNo string `json:"psn_no"`
  15238. } `json:"baseinfo"`
  15239. Idetinfo []interface{} `json:"idetinfo"`
  15240. Iinfo []struct {
  15241. Balc float64 `json:"balc"`
  15242. CvlservFlag string `json:"cvlserv_flag"`
  15243. EmpName string `json:"emp_name"`
  15244. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15245. Insutype string `json:"insutype"`
  15246. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15247. //PausInsuDate string `json:"paus_insu_date"`
  15248. //PsnInsuDate string `json:"psn_insu_date"`
  15249. PsnInsuStas string `json:"psn_insu_stas"`
  15250. PsnType string `json:"psn_type"`
  15251. } `json:"insuinfo"`
  15252. } `json:"output"`
  15253. RefmsgTime string `json:"refmsg_time"`
  15254. RespondTime string `json:"respond_time"`
  15255. Signtype interface{} `json:"signtype"`
  15256. WarnInfo interface{} `json:"warn_info"`
  15257. }
  15258. type ResultTwo10265 struct {
  15259. ErrMsg string `json:"err_msg"`
  15260. InfRefmsgid string `json:"inf_refmsgid"`
  15261. Infcode string `json:"infcode"`
  15262. Output struct {
  15263. Baseinfo struct {
  15264. //Brdy string `json:"brdy"`
  15265. Certno string `json:"certno"`
  15266. Gend string `json:"gend"`
  15267. Naty string `json:"naty"`
  15268. PsnCertType string `json:"psn_cert_type"`
  15269. PsnName string `json:"psn_name"`
  15270. PsnNo string `json:"psn_no"`
  15271. } `json:"baseinfo"`
  15272. Idetinfo []interface{} `json:"idetinfo"`
  15273. Iinfo []struct {
  15274. Balc float64 `json:"balc"`
  15275. CvlservFlag string `json:"cvlserv_flag"`
  15276. EmpName string `json:"emp_name"`
  15277. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15278. Insutype string `json:"insutype"`
  15279. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15280. PsnInsuStas string `json:"psn_insu_stas"`
  15281. PsnType string `json:"psn_type"`
  15282. } `json:"insuinfo"`
  15283. } `json:"output"`
  15284. RefmsgTime string `json:"refmsg_time"`
  15285. RespondTime string `json:"respond_time"`
  15286. Signtype interface{} `json:"signtype"`
  15287. WarnInfo interface{} `json:"warn_info"`
  15288. }
  15289. type ResultThree struct {
  15290. Cainfo interface{} `json:"cainfo"`
  15291. ErrMsg string `json:"err_msg"`
  15292. InfRefmsgid string `json:"inf_refmsgid"`
  15293. Infcode int64 `json:"infcode"`
  15294. Output struct {
  15295. Data struct {
  15296. IptOtpNo string `json:"ipt_otp_no"`
  15297. MdtrtID string `json:"mdtrt_id"`
  15298. PsnNo string `json:"psn_no"`
  15299. } `json:"data"`
  15300. } `json:"output"`
  15301. RefmsgTime string `json:"refmsg_time"`
  15302. RespondTime string `json:"respond_time"`
  15303. Signtype interface{} `json:"signtype"`
  15304. WarnMsg interface{} `json:"warn_msg"`
  15305. }
  15306. type ResultThree10265 struct {
  15307. Cainfo interface{} `json:"cainfo"`
  15308. ErrMsg string `json:"err_msg"`
  15309. InfRefmsgid string `json:"inf_refmsgid"`
  15310. Infcode string `json:"infcode"`
  15311. Output struct {
  15312. Data struct {
  15313. IptOtpNo string `json:"ipt_otp_no"`
  15314. MdtrtID string `json:"mdtrt_id"`
  15315. PsnNo string `json:"psn_no"`
  15316. } `json:"data"`
  15317. } `json:"output"`
  15318. RefmsgTime string `json:"refmsg_time"`
  15319. RespondTime string `json:"respond_time"`
  15320. Signtype interface{} `json:"signtype"`
  15321. WarnMsg interface{} `json:"warn_msg"`
  15322. }
  15323. type ResultFour struct {
  15324. Cainfo string `json:"cainfo"`
  15325. ErrMsg string `json:"err_msg"`
  15326. InfRefmsgid string `json:"inf_refmsgid"`
  15327. Infcode int64 `json:"infcode"`
  15328. Output struct {
  15329. Result []struct {
  15330. BasMednFlag string `json:"bas_medn_flag"`
  15331. ChldMedcFlag string `json:"chld_medc_flag"`
  15332. ChrgitmLv string `json:"chrgitm_lv"`
  15333. Cnt float64 `json:"cnt"`
  15334. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15335. DrtReimFlag string `json:"drt_reim_flag"`
  15336. FeedetlSn string `json:"feedetl_sn"`
  15337. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15338. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15339. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15340. ListSpItemFlag string `json:"list_sp_item_flag"`
  15341. LmtUsedFlag string `json:"lmt_used_flag"`
  15342. MedChrgitmType string `json:"med_chrgitm_type"`
  15343. Memo string `json:"memo"`
  15344. OverlmtAmt float64 `json:"overlmt_amt"`
  15345. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15346. Pric float64 `json:"pric"`
  15347. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15348. SelfpayProp float64 `json:"selfpay_prop"`
  15349. } `json:"result"`
  15350. } `json:"output"`
  15351. RefmsgTime string `json:"refmsg_time"`
  15352. RespondTime string `json:"respond_time"`
  15353. Signtype string `json:"signtype"`
  15354. WarnMsg string `json:"warn_msg"`
  15355. }
  15356. type ResultFour10265 struct {
  15357. Cainfo string `json:"cainfo"`
  15358. ErrMsg string `json:"err_msg"`
  15359. InfRefmsgid string `json:"inf_refmsgid"`
  15360. Infcode string `json:"infcode"`
  15361. Output struct {
  15362. Result []struct {
  15363. BasMednFlag string `json:"bas_medn_flag"`
  15364. ChldMedcFlag string `json:"chld_medc_flag"`
  15365. ChrgitmLv string `json:"chrgitm_lv"`
  15366. Cnt float64 `json:"cnt"`
  15367. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15368. DrtReimFlag string `json:"drt_reim_flag"`
  15369. FeedetlSn string `json:"feedetl_sn"`
  15370. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15371. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15372. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15373. ListSpItemFlag string `json:"list_sp_item_flag"`
  15374. LmtUsedFlag string `json:"lmt_used_flag"`
  15375. MedChrgitmType string `json:"med_chrgitm_type"`
  15376. Memo string `json:"memo"`
  15377. OverlmtAmt float64 `json:"overlmt_amt"`
  15378. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15379. Pric float64 `json:"pric"`
  15380. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15381. SelfpayProp float64 `json:"selfpay_prop"`
  15382. } `json:"result"`
  15383. } `json:"output"`
  15384. RefmsgTime string `json:"refmsg_time"`
  15385. RespondTime string `json:"respond_time"`
  15386. Signtype string `json:"signtype"`
  15387. WarnMsg string `json:"warn_msg"`
  15388. }
  15389. type ResultMemo struct {
  15390. InsuAdmdvs string `json:"insuAdmdvs"`
  15391. }
  15392. // [{"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}]
  15393. type ResultIDInfo struct {
  15394. Begntime string `json:"begntime"`
  15395. Endtime string `json:"endtime"`
  15396. Memo string `json:"memo"`
  15397. }
  15398. type ResultFive struct {
  15399. Balc float64 `json:"balc"`
  15400. CvlservFlag string `json:"cvlserv_flag"`
  15401. EmpName string `json:"emp_name"`
  15402. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15403. Insutype string `json:"insutype"`
  15404. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15405. PausInsuDate string `json:"paus_insu_date"`
  15406. PsnInsuDate string `json:"psn_insu_date"`
  15407. PsnInsuStas string `json:"psn_insu_stas"`
  15408. PsnType string `json:"psn_type"`
  15409. }
  15410. type ResultSix struct {
  15411. Cainfo interface{} `json:"cainfo"`
  15412. ErrMsg string `json:"err_msg"`
  15413. InfRefmsgid string `json:"inf_refmsgid"`
  15414. Infcode int64 `json:"infcode"`
  15415. Output struct {
  15416. } `json:"output"`
  15417. RefmsgTime string `json:"refmsg_time"`
  15418. RespondTime string `json:"respond_time"`
  15419. Signtype interface{} `json:"signtype"`
  15420. WarnMsg interface{} `json:"warn_msg"`
  15421. }
  15422. type Result2406 struct {
  15423. Cainfo interface{} `json:"cainfo"`
  15424. ErrMsg string `json:"err_msg"`
  15425. InfRefmsgid string `json:"inf_refmsgid"`
  15426. Infcode int64 `json:"infcode"`
  15427. Output struct {
  15428. Result struct {
  15429. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15430. } `json:"result"`
  15431. } `json:"output"`
  15432. RefmsgTime string `json:"refmsg_time"`
  15433. RespondTime string `json:"respond_time"`
  15434. Signtype interface{} `json:"signtype"`
  15435. WarnMsg interface{} `json:"warn_msg"`
  15436. }
  15437. type GZResultSix struct {
  15438. Cainfo interface{} `json:"cainfo"`
  15439. ErrMsg string `json:"err_msg"`
  15440. InfRefmsgid string `json:"inf_refmsgid"`
  15441. Infcode int64 `json:"infcode"`
  15442. Output string `json:"output"`
  15443. RefmsgTime string `json:"refmsg_time"`
  15444. RespondTime string `json:"respond_time"`
  15445. Signtype interface{} `json:"signtype"`
  15446. WarnMsg interface{} `json:"warn_msg"`
  15447. }
  15448. type ResultSix10265 struct {
  15449. Cainfo interface{} `json:"cainfo"`
  15450. ErrMsg string `json:"err_msg"`
  15451. InfRefmsgid string `json:"inf_refmsgid"`
  15452. Infcode string `json:"infcode"`
  15453. Output struct {
  15454. } `json:"output"`
  15455. RefmsgTime string `json:"refmsg_time"`
  15456. RespondTime string `json:"respond_time"`
  15457. Signtype interface{} `json:"signtype"`
  15458. WarnMsg interface{} `json:"warn_msg"`
  15459. }
  15460. type ResultSeven struct {
  15461. Cainfo string `json:"cainfo"`
  15462. ErrMsg string `json:"err_msg"`
  15463. InfRefmsgid string `json:"inf_refmsgid"`
  15464. Infcode int64 `json:"infcode"`
  15465. Output struct {
  15466. Setlinfo struct {
  15467. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15468. AcctPay float64 `json:"acct_pay"`
  15469. ActPayDedc float64 `json:"act_pay_dedc"`
  15470. Age float64 `json:"age"`
  15471. Balc float64 `json:"balc"`
  15472. Certno string `json:"certno"`
  15473. ClrOptins string `json:"clr_optins"`
  15474. ClrType string `json:"clr_type"`
  15475. ClrWay string `json:"clr_way"`
  15476. CvlservFlag string `json:"cvlserv_flag"`
  15477. CvlservPay float64 `json:"cvlserv_pay"`
  15478. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15479. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15480. Gend string `json:"gend"`
  15481. HifesPay float64 `json:"hifes_pay"`
  15482. HifmiPay float64 `json:"hifmi_pay"`
  15483. HifpPay float64 `json:"hifp_pay"`
  15484. HospPartAmt float64 `json:"hosp_part_amt"`
  15485. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15486. Insutype string `json:"insutype"`
  15487. MafPay float64 `json:"maf_pay"`
  15488. MdtrtCertType string `json:"mdtrt_cert_type"`
  15489. HifobPay float64 `json:"hifob_pay"`
  15490. MdtrtID string `json:"mdtrt_id"`
  15491. MedType string `json:"med_type"`
  15492. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15493. MedinsSetlID string `json:"medins_setl_id"`
  15494. Naty string `json:"naty"`
  15495. OthPay float64 `json:"oth_pay"`
  15496. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15497. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15498. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15499. PsnCashPay float64 `json:"psn_cash_pay"`
  15500. PsnCertType string `json:"psn_cert_type"`
  15501. PsnName string `json:"psn_name"`
  15502. PsnNo string `json:"psn_no"`
  15503. PsnPartAmt float64 `json:"psn_part_amt"`
  15504. PsnType string `json:"psn_type"`
  15505. SetlID string `json:"setl_id"`
  15506. SetlTime string `json:"setl_time"`
  15507. } `json:"setlinfo"`
  15508. Setldetail interface{} `json:"setldetail"`
  15509. } `json:"output"`
  15510. RefmsgTime string `json:"refmsg_time"`
  15511. RespondTime string `json:"respond_time"`
  15512. Signtype interface{} `json:"signtype"`
  15513. WarnMsg interface{} `json:"warn_msg"`
  15514. }
  15515. type ResultSevenAH struct {
  15516. Cainfo string `json:"cainfo"`
  15517. ErrMsg string `json:"err_msg"`
  15518. InfRefmsgid string `json:"inf_refmsgid"`
  15519. Infcode int64 `json:"infcode"`
  15520. Output struct {
  15521. Setlinfo struct {
  15522. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15523. AcctPay float64 `json:"acct_pay"`
  15524. ActPayDedc float64 `json:"act_pay_dedc"`
  15525. Age float64 `json:"age"`
  15526. Balc float64 `json:"balc"`
  15527. Certno string `json:"certno"`
  15528. ClrOptins string `json:"clr_optins"`
  15529. ClrType string `json:"clr_type"`
  15530. ClrWay string `json:"clr_way"`
  15531. CvlservFlag string `json:"cvlserv_flag"`
  15532. CvlservPay float64 `json:"cvlserv_pay"`
  15533. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15534. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15535. Gend string `json:"gend"`
  15536. HifesPay float64 `json:"hifes_pay"`
  15537. HifmiPay float64 `json:"hifmi_pay"`
  15538. HifpPay float64 `json:"hifp_pay"`
  15539. HospPartAmt float64 `json:"hosp_part_amt"`
  15540. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15541. Insutype string `json:"insutype"`
  15542. MafPay float64 `json:"maf_pay"`
  15543. MdtrtCertType string `json:"mdtrt_cert_type"`
  15544. HifobPay float64 `json:"hifob_pay"`
  15545. MdtrtID string `json:"mdtrt_id"`
  15546. MedType string `json:"med_type"`
  15547. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15548. MedinsSetlID string `json:"medins_setl_id"`
  15549. Naty string `json:"naty"`
  15550. OthPay float64 `json:"oth_pay"`
  15551. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15552. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15553. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15554. PsnCashPay float64 `json:"psn_cash_pay"`
  15555. PsnCertType string `json:"psn_cert_type"`
  15556. PsnName string `json:"psn_name"`
  15557. PsnNo string `json:"psn_no"`
  15558. PsnPartAmt float64 `json:"psn_part_amt"`
  15559. PsnType string `json:"psn_type"`
  15560. SetlID string `json:"setl_id"`
  15561. SetlTime int64 `json:"setl_time"`
  15562. } `json:"setlinfo"`
  15563. Setldetail interface{} `json:"setldetail"`
  15564. } `json:"output"`
  15565. RefmsgTime string `json:"refmsg_time"`
  15566. RespondTime string `json:"respond_time"`
  15567. Signtype interface{} `json:"signtype"`
  15568. WarnMsg interface{} `json:"warn_msg"`
  15569. }
  15570. type ResultSeven10265 struct {
  15571. Cainfo string `json:"cainfo"`
  15572. ErrMsg string `json:"err_msg"`
  15573. InfRefmsgid string `json:"inf_refmsgid"`
  15574. Infcode string `json:"infcode"`
  15575. Output struct {
  15576. Setlinfo struct {
  15577. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15578. AcctPay float64 `json:"acct_pay"`
  15579. ActPayDedc float64 `json:"act_pay_dedc"`
  15580. Age float64 `json:"age"`
  15581. Balc float64 `json:"balc"`
  15582. Certno string `json:"certno"`
  15583. ClrOptins string `json:"clr_optins"`
  15584. ClrType string `json:"clr_type"`
  15585. ClrWay string `json:"clr_way"`
  15586. CvlservFlag string `json:"cvlserv_flag"`
  15587. CvlservPay float64 `json:"cvlserv_pay"`
  15588. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15589. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15590. Gend string `json:"gend"`
  15591. HifesPay float64 `json:"hifes_pay"`
  15592. HifmiPay float64 `json:"hifmi_pay"`
  15593. HifpPay float64 `json:"hifp_pay"`
  15594. HospPartAmt float64 `json:"hosp_part_amt"`
  15595. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15596. Insutype string `json:"insutype"`
  15597. MafPay float64 `json:"maf_pay"`
  15598. MdtrtCertType string `json:"mdtrt_cert_type"`
  15599. HifobPay float64 `json:"hifob_pay"`
  15600. MdtrtID string `json:"mdtrt_id"`
  15601. MedType string `json:"med_type"`
  15602. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15603. MedinsSetlID string `json:"medins_setl_id"`
  15604. Naty string `json:"naty"`
  15605. OthPay float64 `json:"oth_pay"`
  15606. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15607. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15608. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15609. PsnCashPay float64 `json:"psn_cash_pay"`
  15610. PsnCertType string `json:"psn_cert_type"`
  15611. PsnName string `json:"psn_name"`
  15612. PsnNo string `json:"psn_no"`
  15613. PsnPartAmt float64 `json:"psn_part_amt"`
  15614. PsnType string `json:"psn_type"`
  15615. SetlID string `json:"setl_id"`
  15616. SetlTime string `json:"setl_time"`
  15617. } `json:"setlinfo"`
  15618. Setldetail interface{} `json:"setldetail"`
  15619. } `json:"output"`
  15620. RefmsgTime string `json:"refmsg_time"`
  15621. RespondTime string `json:"respond_time"`
  15622. Signtype interface{} `json:"signtype"`
  15623. WarnMsg interface{} `json:"warn_msg"`
  15624. }
  15625. type ResultSeven10265Two struct {
  15626. Cainfo string `json:"cainfo"`
  15627. ErrMsg string `json:"err_msg"`
  15628. InfRefmsgid string `json:"inf_refmsgid"`
  15629. Infcode string `json:"infcode"`
  15630. Output struct {
  15631. Setlinfo struct {
  15632. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15633. AcctPay float64 `json:"acct_pay"`
  15634. ActPayDedc float64 `json:"act_pay_dedc"`
  15635. Age float64 `json:"age"`
  15636. Balc float64 `json:"balc"`
  15637. Certno string `json:"certno"`
  15638. ClrOptins string `json:"clr_optins"`
  15639. ClrType string `json:"clr_type"`
  15640. ClrWay string `json:"clr_way"`
  15641. CvlservFlag string `json:"cvlserv_flag"`
  15642. CvlservPay float64 `json:"cvlserv_pay"`
  15643. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15644. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15645. Gend string `json:"gend"`
  15646. HifesPay float64 `json:"hifes_pay"`
  15647. HifmiPay float64 `json:"hifmi_pay"`
  15648. HifpPay float64 `json:"hifp_pay"`
  15649. HospPartAmt string `json:"hosp_part_amt"`
  15650. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15651. Insutype string `json:"insutype"`
  15652. MafPay float64 `json:"maf_pay"`
  15653. MdtrtCertType string `json:"mdtrt_cert_type"`
  15654. HifobPay float64 `json:"hifob_pay"`
  15655. MdtrtID string `json:"mdtrt_id"`
  15656. MedType string `json:"med_type"`
  15657. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15658. MedinsSetlID string `json:"medins_setl_id"`
  15659. Naty string `json:"naty"`
  15660. OthPay float64 `json:"oth_pay"`
  15661. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15662. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15663. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15664. PsnCashPay float64 `json:"psn_cash_pay"`
  15665. PsnCertType string `json:"psn_cert_type"`
  15666. PsnName string `json:"psn_name"`
  15667. PsnNo string `json:"psn_no"`
  15668. PsnPartAmt float64 `json:"psn_part_amt"`
  15669. PsnType string `json:"psn_type"`
  15670. SetlID string `json:"setl_id"`
  15671. SetlTime string `json:"setl_time"`
  15672. } `json:"setlinfo"`
  15673. Setldetail interface{} `json:"setldetail"`
  15674. } `json:"output"`
  15675. RefmsgTime string `json:"refmsg_time"`
  15676. RespondTime string `json:"respond_time"`
  15677. Signtype interface{} `json:"signtype"`
  15678. WarnMsg interface{} `json:"warn_msg"`
  15679. }
  15680. type GZResultSeven10265Two struct {
  15681. Cainfo string `json:"cainfo"`
  15682. ErrMsg string `json:"err_msg"`
  15683. InfRefmsgid string `json:"inf_refmsgid"`
  15684. Infcode int64 `json:"infcode"`
  15685. Output struct {
  15686. Setlinfo struct {
  15687. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15688. AcctPay float64 `json:"acct_pay"`
  15689. ActPayDedc float64 `json:"act_pay_dedc"`
  15690. Age float64 `json:"age"`
  15691. Balc float64 `json:"balc"`
  15692. Certno string `json:"certno"`
  15693. ClrOptins string `json:"clr_optins"`
  15694. ClrType string `json:"clr_type"`
  15695. ClrWay string `json:"clr_way"`
  15696. CvlservFlag string `json:"cvlserv_flag"`
  15697. CvlservPay float64 `json:"cvlserv_pay"`
  15698. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15699. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15700. Gend string `json:"gend"`
  15701. HifesPay float64 `json:"hifes_pay"`
  15702. HifmiPay float64 `json:"hifmi_pay"`
  15703. HifpPay float64 `json:"hifp_pay"`
  15704. HospPartAmt float64 `json:"hosp_part_amt"`
  15705. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15706. Insutype string `json:"insutype"`
  15707. MafPay float64 `json:"maf_pay"`
  15708. MdtrtCertType string `json:"mdtrt_cert_type"`
  15709. HifobPay float64 `json:"hifob_pay"`
  15710. MdtrtID string `json:"mdtrt_id"`
  15711. MedType string `json:"med_type"`
  15712. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15713. MedinsSetlID string `json:"medins_setl_id"`
  15714. Naty string `json:"naty"`
  15715. OthPay float64 `json:"oth_pay"`
  15716. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15717. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15718. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15719. PsnCashPay float64 `json:"psn_cash_pay"`
  15720. PsnCertType string `json:"psn_cert_type"`
  15721. PsnName string `json:"psn_name"`
  15722. PsnNo string `json:"psn_no"`
  15723. PsnPartAmt float64 `json:"psn_part_amt"`
  15724. PsnType string `json:"psn_type"`
  15725. SetlID string `json:"setl_id"`
  15726. SetlTime string `json:"setl_time"`
  15727. } `json:"setlinfo"`
  15728. Setldetail interface{} `json:"setldetail"`
  15729. } `json:"output"`
  15730. RefmsgTime string `json:"refmsg_time"`
  15731. RespondTime string `json:"respond_time"`
  15732. Signtype interface{} `json:"signtype"`
  15733. WarnMsg interface{} `json:"warn_msg"`
  15734. }
  15735. type ResultEight struct {
  15736. Cainfo string `json:"cainfo"`
  15737. ErrMsg string `json:"err_msg"`
  15738. InfRefmsgid string `json:"inf_refmsgid"`
  15739. Infcode int64 `json:"infcode"`
  15740. Output struct {
  15741. Stmtinfo struct {
  15742. SetlOptins string `json:"setl_optins"`
  15743. StmtRslt string `json:"stmt_rslt"`
  15744. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15745. } `json:"stmtinfo"`
  15746. } `json:"output"`
  15747. RefmsgTime string `json:"refmsg_time"`
  15748. RespondTime string `json:"respond_time"`
  15749. Signtype interface{} `json:"signtype"`
  15750. WarnMsg interface{} `json:"warn_msg"`
  15751. }
  15752. type ResultEightFor10188 struct {
  15753. Cainfo string `json:"cainfo"`
  15754. ErrMsg string `json:"err_msg"`
  15755. InfRefmsgid string `json:"inf_refmsgid"`
  15756. Infcode string `json:"infcode"`
  15757. Output struct {
  15758. Stmtinfo struct {
  15759. SetlOptins string `json:"setl_optins"`
  15760. StmtRslt string `json:"stmt_rslt"`
  15761. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15762. } `json:"stmtinfo"`
  15763. } `json:"output"`
  15764. RefmsgTime string `json:"refmsg_time"`
  15765. RespondTime string `json:"respond_time"`
  15766. Signtype interface{} `json:"signtype"`
  15767. WarnMsg interface{} `json:"warn_msg"`
  15768. }
  15769. type ResultNine struct {
  15770. Cainfo string `json:"cainfo"`
  15771. ErrMsg string `json:"err_msg"`
  15772. InfRefmsgid string `json:"inf_refmsgid"`
  15773. Infcode int64 `json:"infcode"`
  15774. Output struct {
  15775. FileQuryNo string `json:"file_qury_no"`
  15776. } `json:"output"`
  15777. RefmsgTime string `json:"refmsg_time"`
  15778. RespondTime string `json:"respond_time"`
  15779. Signtype interface{} `json:"signtype"`
  15780. WarnMsg interface{} `json:"warn_msg"`
  15781. }
  15782. type ResultTen struct {
  15783. Cainfo string `json:"cainfo"`
  15784. ErrMsg string `json:"err_msg"`
  15785. InfRefmsgid string `json:"inf_refmsgid"`
  15786. Infcode int64 `json:"infcode"`
  15787. Output struct {
  15788. Fileinfo struct {
  15789. DldEndtime string `json:"dld_endtime"`
  15790. FileQuryNo string `json:"file_qury_no"`
  15791. Filename string `json:"filename"`
  15792. } `json:"fileinfo"`
  15793. } `json:"output"`
  15794. RefmsgTime string `json:"refmsg_time"`
  15795. RespondTime string `json:"respond_time"`
  15796. Signtype interface{} `json:"signtype"`
  15797. WarnMsg interface{} `json:"warn_msg"`
  15798. }
  15799. type Result5262 struct {
  15800. ErrMsg string `json:"err_msg"`
  15801. InfRefmsgid string `json:"inf_refmsgid"`
  15802. Infcode int64 `json:"infcode"`
  15803. Output struct {
  15804. PageInfo struct {
  15805. Size int `json:"size"`
  15806. RecordCounts int `json:"record_counts"`
  15807. } `json:"page_info"`
  15808. Idetinfo []interface{} `json:"idetinfo"`
  15809. Result []struct {
  15810. SetlID string `json:"setl_id"`
  15811. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15812. MdtrtID string `json:"mdtrt_id"`
  15813. InitSetlID string `json:"init_setl_id,omitempty"`
  15814. PsnNo string `json:"psn_no"`
  15815. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15816. PsnName string `json:"psn_name"`
  15817. PsnCertType string `json:"psn_cert_type"`
  15818. Certno string `json:"certno"`
  15819. Gend string `json:"gend,omitempty"`
  15820. Naty string `json:"naty,omitempty"`
  15821. Brdy string `json:"brdy,omitempty"`
  15822. Age float64 `json:"age,omitempty"`
  15823. Insutype string `json:"insutype,omitempty"`
  15824. PsnType string `json:"psn_type"`
  15825. CvlservFlag string `json:"cvlserv_flag"`
  15826. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15827. SpPsnType string `json:"sp_psn_type,omitempty"`
  15828. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15829. ClctGrde string `json:"clct_grde,omitempty"`
  15830. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15831. NwbFlag string `json:"nwb_flag,omitempty"`
  15832. InsuAdmdvs string `json:"insu_admdvs"`
  15833. EmpNo string `json:"emp_no,omitempty"`
  15834. EmpName string `json:"emp_name,omitempty"`
  15835. EmpType string `json:"emp_type,omitempty"`
  15836. EconType string `json:"econ_type,omitempty"`
  15837. AfilIndu string `json:"afil_indu,omitempty"`
  15838. AfilRlts string `json:"afil_rlts,omitempty"`
  15839. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15840. PayLoc string `json:"pay_loc,omitempty"`
  15841. FixmedinsCode string `json:"fixmedins_code"`
  15842. FixmedinsName string `json:"fixmedins_name"`
  15843. HospLv string `json:"hosp_lv,omitempty"`
  15844. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15845. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15846. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15847. Begndate string `json:"begndate"`
  15848. Enddate string `json:"enddate"`
  15849. SetlTime string `json:"setl_time"`
  15850. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15851. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15852. MedType string `json:"med_type"`
  15853. SetlType string `json:"setl_type,omitempty"`
  15854. ClrType string `json:"clr_type,omitempty"`
  15855. ClrWay string `json:"clr_way,omitempty"`
  15856. PsnSetlway string `json:"psn_setlway,omitempty"`
  15857. ClrOptins string `json:"clr_optins,omitempty"`
  15858. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15859. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15860. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15861. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15862. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15863. DedcStd float64 `json:"dedc_std,omitempty"`
  15864. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15865. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15866. HifpPay float64 `json:"hifp_pay,omitempty"`
  15867. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15868. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15869. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15870. HifesPay float64 `json:"hifes_pay,omitempty"`
  15871. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15872. HifobPay float64 `json:"hifob_pay,omitempty"`
  15873. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15874. MafPay float64 `json:"maf_pay,omitempty"`
  15875. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15876. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15877. PsnPay float64 `json:"psn_pay,omitempty"`
  15878. AcctPay float64 `json:"acct_pay,omitempty"`
  15879. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15880. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15881. Balc float64 `json:"balc,omitempty"`
  15882. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15883. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15884. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15885. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15886. Year string `json:"year,omitempty"`
  15887. DiseNo string `json:"dise_no,omitempty"`
  15888. DiseName string `json:"dise_name,omitempty"`
  15889. Invono string `json:"invono,omitempty"`
  15890. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15891. ValiFlag string `json:"vali_flag,omitempty"`
  15892. Memo string `json:"memo,omitempty"`
  15893. Rid string `json:"rid"`
  15894. UpdtTime string `json:"updt_time,omitempty"`
  15895. CrterID string `json:"crter_id,omitempty"`
  15896. CrterName string `json:"crter_name,omitempty"`
  15897. CrteTime string `json:"crte_time,omitempty"`
  15898. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15899. OpterID string `json:"opter_id,omitempty"`
  15900. OpterName string `json:"opter_name,omitempty"`
  15901. OptTime string `json:"opt_time,omitempty"`
  15902. OptinsNo string `json:"optins_no,omitempty"`
  15903. PoolareaNo string `json:"poolarea_no,omitempty"`
  15904. } `json:"result"`
  15905. } `json:"output"`
  15906. RefmsgTime string `json:"refmsg_time"`
  15907. RespondTime string `json:"respond_time"`
  15908. Signtype interface{} `json:"signtype"`
  15909. WarnInfo interface{} `json:"warn_info"`
  15910. }
  15911. type Result5267 struct {
  15912. ErrMsg string `json:"err_msg"`
  15913. InfRefmsgid string `json:"inf_refmsgid"`
  15914. Infcode int64 `json:"infcode"`
  15915. Output struct {
  15916. PageInfo struct {
  15917. Size int `json:"size"`
  15918. RecordCounts int `json:"record_counts"`
  15919. } `json:"pageinfo"`
  15920. Result []struct {
  15921. SetlID string `json:"setl_id"`
  15922. ClrOptins string `json:"clr_optins"`
  15923. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15924. MdtrtID string `json:"mdtrt_id"`
  15925. InitSetlID string `json:"init_setl_id,omitempty"`
  15926. PsnNo string `json:"psn_no"`
  15927. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15928. PsnName string `json:"psn_name"`
  15929. PsnCertType string `json:"psn_cert_type"`
  15930. Certno string `json:"certno"`
  15931. Gend string `json:"gend,omitempty"`
  15932. Naty string `json:"naty,omitempty"`
  15933. Brdy string `json:"brdy,omitempty"`
  15934. Age float64 `json:"age,omitempty"`
  15935. Insutype string `json:"insutype,omitempty"`
  15936. PsnType string `json:"psn_type"`
  15937. CvlservFlag string `json:"cvlserv_flag"`
  15938. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15939. SpPsnType string `json:"sp_psn_type,omitempty"`
  15940. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15941. ClctGrde string `json:"clct_grde,omitempty"`
  15942. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15943. NwbFlag string `json:"nwb_flag,omitempty"`
  15944. InsuAdmdvs string `json:"insu_admdvs"`
  15945. EmpNo string `json:"emp_no,omitempty"`
  15946. EmpName string `json:"emp_name,omitempty"`
  15947. EmpType string `json:"emp_type,omitempty"`
  15948. EconType string `json:"econ_type,omitempty"`
  15949. AfilIndu string `json:"afil_indu,omitempty"`
  15950. AfilRlts string `json:"afil_rlts,omitempty"`
  15951. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15952. PayLoc string `json:"pay_loc,omitempty"`
  15953. FixmedinsCode string `json:"fixmedins_code"`
  15954. FixmedinsName string `json:"fixmedins_name"`
  15955. HospLv string `json:"hosp_lv,omitempty"`
  15956. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15957. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15958. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15959. Begndate string `json:"begndate,omitempty"`
  15960. Enddate string `json:"enddate,omitempty"`
  15961. SetlTime string `json:"setl_time,omitempty"`
  15962. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15963. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15964. MedType string `json:"med_type"`
  15965. SetlType string `json:"setl_type,omitempty"`
  15966. ClrType string `json:"clr_type,omitempty"`
  15967. ClrWay string `json:"clr_way,omitempty"`
  15968. PsnSetlway string `json:"psn_setlway,omitempty"`
  15969. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15970. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15971. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15972. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15973. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15974. DedcStd float64 `json:"dedc_std,omitempty"`
  15975. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15976. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15977. HifpPay float64 `json:"hifp_pay,omitempty"`
  15978. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15979. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15980. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15981. HifesPay float64 `json:"hifes_pay,omitempty"`
  15982. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15983. HifobPay float64 `json:"hifob_pay,omitempty"`
  15984. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15985. MafPay float64 `json:"maf_pay,omitempty"`
  15986. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15987. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15988. PsnPay float64 `json:"psn_pay,omitempty"`
  15989. AcctPay float64 `json:"acct_pay,omitempty"`
  15990. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15991. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15992. Balc float64 `json:"balc,omitempty"`
  15993. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15994. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15995. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15996. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15997. Year string `json:"year,omitempty"`
  15998. DiseNo string `json:"dise_no,omitempty"`
  15999. DiseName string `json:"dise_name,omitempty"`
  16000. Invono string `json:"invono,omitempty"`
  16001. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16002. Memo string `json:"memo,omitempty"`
  16003. UpdtTime string `json:"updt_time,omitempty"`
  16004. OpterID string `json:"opter_id,omitempty"`
  16005. OpterName string `json:"opter_name,omitempty"`
  16006. OptTime string `json:"opt_time,omitempty"`
  16007. OptinsNo string `json:"optins_no,omitempty"`
  16008. PoolareaNo string `json:"poolarea_no,omitempty"`
  16009. } `json:"result"`
  16010. } `json:"output"`
  16011. RefmsgTime string `json:"refmsg_time"`
  16012. RespondTime string `json:"respond_time"`
  16013. Signtype interface{} `json:"signtype"`
  16014. WarnInfo interface{} `json:"warn_info"`
  16015. }
  16016. // type Autogenerated struct {
  16017. // Output struct {
  16018. // Setlinfo struct {
  16019. // SetlTime string `json:"setl_time"`
  16020. // CvlservPay float64 `json:"cvlserv_pay"`
  16021. // Year string `json:"year"`
  16022. // MedType string `json:"med_type"`
  16023. // PsnPay float64 `json:"psn_pay"`
  16024. // OpterID string `json:"opter_id"`
  16025. // Begndate string `json:"begndate"`
  16026. // FlxempeFlag string `json:"flxempe_flag"`
  16027. // HifmiPay float64 `json:"hifmi_pay"`
  16028. // PsnNo string `json:"psn_no"`
  16029. // ActPayDedc float64 `json:"act_pay_dedc"`
  16030. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16031. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16032. // ClrWay string `json:"clr_way"`
  16033. // OthPay float64 `json:"oth_pay"`
  16034. // Gend string `json:"gend"`
  16035. // MdtrtID string `json:"mdtrt_id"`
  16036. // AcctPay float64 `json:"acct_pay"`
  16037. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16038. // Insutype string `json:"insutype"`
  16039. // Invono interface{} `json:"invono"`
  16040. // Enddate string `json:"enddate"`
  16041. // CashPayamt float64 `json:"cash_payamt"`
  16042. // PsnType string `json:"psn_type"`
  16043. // FixmedinsName string `json:"fixmedins_name"`
  16044. // HifpPay float64 `json:"hifp_pay"`
  16045. // NewFlag interface{} `json:"new_flag"`
  16046. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16047. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16048. // PayLoc string `json:"pay_loc"`
  16049. // ClrType string `json:"clr_type"`
  16050. // RefdSetlFlag string `json:"refd_setl_flag"`
  16051. // CvlservFlag string `json:"cvlserv_flag"`
  16052. // EmpName string `json:"emp_name"`
  16053. // Brdy string `json:"brdy"`
  16054. // Naty string `json:"naty"`
  16055. // Certno string `json:"certno"`
  16056. // DiseCode string `json:"dise_code"`
  16057. // FixmedinsCode string `json:"fixmedins_code"`
  16058. // DedcHospLv string `json:"dedc_hosp_lv"`
  16059. // OpterName string `json:"opter_name"`
  16060. // Balc float64 `json:"balc"`
  16061. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16062. // PsnCertType string `json:"psn_cert_type"`
  16063. // HifobPay float64 `json:"hifob_pay"`
  16064. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16065. // HifesPay float64 `json:"hifes_pay"`
  16066. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16067. // OptTime string `json:"opt_time"`
  16068. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16069. // SetlID string `json:"setl_id"`
  16070. // MafPay float64 `json:"maf_pay"`
  16071. // PsnName string `json:"psn_name"`
  16072. // InsuOptins interface{} `json:"insu_optins"`
  16073. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16074. // ClrOptins string `json:"clr_optins"`
  16075. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16076. // DiseName string `json:"dise_name"`
  16077. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16078. // Age float64 `json:"age"`
  16079. // DtrtCertType string `json:"dtrt_cert_type"`
  16080. // HospLv string `json:"hosp_lv"`
  16081. // } `json:"setlinfo"`
  16082. // Setldetail []struct {
  16083. // FundPayType string `json:"fund_pay_type"`
  16084. // FundPayamt float64 `json:"fund_payamt"`
  16085. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16086. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16087. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16088. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16089. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16090. // } `json:"setldetail"`
  16091. // } `json:"output"`
  16092. // Infcode int `json:"infcode"`
  16093. // WarnMsg interface{} `json:"warn_msg"`
  16094. // Cainfo interface{} `json:"cainfo"`
  16095. // ErrMsg interface{} `json:"err_msg"`
  16096. // RefmsgTime string `json:"refmsg_time"`
  16097. // Signtype interface{} `json:"signtype"`
  16098. // RespondTime string `json:"respond_time"`
  16099. // InfRefmsgid string `json:"inf_refmsgid"`
  16100. // }
  16101. type Result002 struct {
  16102. Cainfo interface{} `json:"cainfo"`
  16103. ErrMsg string `json:"err_msg"`
  16104. InfRefmsgid string `json:"inf_refmsgid"`
  16105. Infcode int64 `json:"infcode"`
  16106. Output struct {
  16107. RxFile string `json:"rx_file"`
  16108. SignDigest string `json:"sign_digest"`
  16109. SignCertSn string `json:"sign_cert_sn"`
  16110. SignCertDn string `json:"sign_cert_dn"`
  16111. } `json:"output"`
  16112. RefmsgTime string `json:"refmsg_time"`
  16113. RespondTime string `json:"respond_time"`
  16114. Signtype interface{} `json:"signtype"`
  16115. WarnMsg interface{} `json:"warn_msg"`
  16116. }
  16117. type Result003 struct {
  16118. Cainfo interface{} `json:"cainfo"`
  16119. ErrMsg string `json:"err_msg"`
  16120. InfRefmsgid string `json:"inf_refmsgid"`
  16121. Infcode int64 `json:"infcode"`
  16122. Output struct {
  16123. HiRxno string `json:"hi_rxno"`
  16124. RxStasCodg string `json:"rx_stas_codg"`
  16125. RxStasName string `json:"rx_stas_name"`
  16126. } `json:"output"`
  16127. RefmsgTime string `json:"refmsg_time"`
  16128. RespondTime string `json:"respond_time"`
  16129. Signtype interface{} `json:"signtype"`
  16130. WarnMsg interface{} `json:"warn_msg"`
  16131. }
  16132. type ResultEleven struct {
  16133. Cainfo string `json:"cainfo"`
  16134. ErrMsg string `json:"err_msg"`
  16135. InfRefmsgid string `json:"inf_refmsgid"`
  16136. Infcode int64 `json:"infcode"`
  16137. Output struct {
  16138. Setlinfo struct {
  16139. SetlTime string `json:"setl_time"`
  16140. CvlservPay float64 `json:"cvlserv_pay"`
  16141. Year string `json:"year"`
  16142. MedType string `json:"med_type"`
  16143. PsnPay float64 `json:"psn_pay"`
  16144. OpterID string `json:"opter_id"`
  16145. Begndate string `json:"begndate"`
  16146. FlxempeFlag string `json:"flxempe_flag"`
  16147. HifmiPay float64 `json:"hifmi_pay"`
  16148. PsnNo string `json:"psn_no"`
  16149. ActPayDedc float64 `json:"act_pay_dedc"`
  16150. MedinsSetlID interface{} `json:"medins_setl_id"`
  16151. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16152. ClrWay string `json:"clr_way"`
  16153. OthPay float64 `json:"oth_pay"`
  16154. Gend string `json:"gend"`
  16155. MdtrtID string `json:"mdtrt_id"`
  16156. AcctPay float64 `json:"acct_pay"`
  16157. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16158. Insutype string `json:"insutype"`
  16159. Invono interface{} `json:"invono"`
  16160. Enddate string `json:"enddate"`
  16161. CashPayamt float64 `json:"cash_payamt"`
  16162. PsnType string `json:"psn_type"`
  16163. FixmedinsName string `json:"fixmedins_name"`
  16164. HifpPay float64 `json:"hifp_pay"`
  16165. NewFlag interface{} `json:"new_flag"`
  16166. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16167. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16168. PayLoc string `json:"pay_loc"`
  16169. ClrType string `json:"clr_type"`
  16170. RefdSetlFlag string `json:"refd_setl_flag"`
  16171. CvlservFlag string `json:"cvlserv_flag"`
  16172. EmpName string `json:"emp_name"`
  16173. Brdy string `json:"brdy"`
  16174. Naty string `json:"naty"`
  16175. Certno string `json:"certno"`
  16176. DiseCode string `json:"dise_code"`
  16177. FixmedinsCode string `json:"fixmedins_code"`
  16178. DedcHospLv string `json:"dedc_hosp_lv"`
  16179. OpterName string `json:"opter_name"`
  16180. Balc float64 `json:"balc"`
  16181. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16182. PsnCertType string `json:"psn_cert_type"`
  16183. HifobPay float64 `json:"hifob_pay"`
  16184. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16185. HifesPay float64 `json:"hifes_pay"`
  16186. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16187. OptTime string `json:"opt_time"`
  16188. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16189. SetlID string `json:"setl_id"`
  16190. MafPay float64 `json:"maf_pay"`
  16191. PsnName string `json:"psn_name"`
  16192. InsuOptins interface{} `json:"insu_optins"`
  16193. PrefFundPay interface{} `json:"pref_fund_pay"`
  16194. ClrOptins string `json:"clr_optins"`
  16195. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16196. DiseName string `json:"dise_name"`
  16197. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16198. Age float64 `json:"age"`
  16199. DtrtCertType string `json:"dtrt_cert_type"`
  16200. HospLv string `json:"hosp_lv"`
  16201. PsnCashPay float64 `json:"psn_cash_pay"`
  16202. } `json:"setlinfo"`
  16203. } `json:"output"`
  16204. RefmsgTime string `json:"refmsg_time"`
  16205. RespondTime string `json:"respond_time"`
  16206. Signtype interface{} `json:"signtype"`
  16207. WarnMsg interface{} `json:"warn_msg"`
  16208. }
  16209. type ResultElevenah struct {
  16210. Cainfo string `json:"cainfo"`
  16211. ErrMsg string `json:"err_msg"`
  16212. InfRefmsgid string `json:"inf_refmsgid"`
  16213. Infcode int64 `json:"infcode"`
  16214. Output struct {
  16215. Setlinfo struct {
  16216. SetlTime int64 `json:"setl_time"`
  16217. CvlservPay float64 `json:"cvlserv_pay"`
  16218. Year string `json:"year"`
  16219. MedType string `json:"med_type"`
  16220. PsnPay float64 `json:"psn_pay"`
  16221. OpterID string `json:"opter_id"`
  16222. Begndate int64 `json:"begndate"`
  16223. FlxempeFlag string `json:"flxempe_flag"`
  16224. HifmiPay float64 `json:"hifmi_pay"`
  16225. PsnNo string `json:"psn_no"`
  16226. ActPayDedc float64 `json:"act_pay_dedc"`
  16227. MedinsSetlID interface{} `json:"medins_setl_id"`
  16228. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16229. ClrWay string `json:"clr_way"`
  16230. OthPay float64 `json:"oth_pay"`
  16231. Gend string `json:"gend"`
  16232. MdtrtID string `json:"mdtrt_id"`
  16233. AcctPay float64 `json:"acct_pay"`
  16234. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16235. Insutype string `json:"insutype"`
  16236. Invono interface{} `json:"invono"`
  16237. Enddate int64 `json:"enddate"`
  16238. CashPayamt float64 `json:"cash_payamt"`
  16239. PsnType string `json:"psn_type"`
  16240. FixmedinsName string `json:"fixmedins_name"`
  16241. HifpPay float64 `json:"hifp_pay"`
  16242. NewFlag interface{} `json:"new_flag"`
  16243. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16244. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16245. PayLoc string `json:"pay_loc"`
  16246. ClrType string `json:"clr_type"`
  16247. RefdSetlFlag string `json:"refd_setl_flag"`
  16248. CvlservFlag string `json:"cvlserv_flag"`
  16249. EmpName string `json:"emp_name"`
  16250. Brdy int64 `json:"brdy"`
  16251. Naty string `json:"naty"`
  16252. Certno string `json:"certno"`
  16253. DiseCode string `json:"dise_code"`
  16254. FixmedinsCode string `json:"fixmedins_code"`
  16255. DedcHospLv string `json:"dedc_hosp_lv"`
  16256. OpterName string `json:"opter_name"`
  16257. Balc float64 `json:"balc"`
  16258. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16259. PsnCertType string `json:"psn_cert_type"`
  16260. HifobPay float64 `json:"hifob_pay"`
  16261. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16262. HifesPay float64 `json:"hifes_pay"`
  16263. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16264. OptTime int64 `json:"opt_time"`
  16265. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16266. SetlID string `json:"setl_id"`
  16267. MafPay float64 `json:"maf_pay"`
  16268. PsnName string `json:"psn_name"`
  16269. InsuOptins interface{} `json:"insu_optins"`
  16270. PrefFundPay interface{} `json:"pref_fund_pay"`
  16271. ClrOptins string `json:"clr_optins"`
  16272. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16273. DiseName string `json:"dise_name"`
  16274. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16275. Age float64 `json:"age"`
  16276. DtrtCertType string `json:"dtrt_cert_type"`
  16277. HospLv string `json:"hosp_lv"`
  16278. PsnCashPay float64 `json:"psn_cash_pay"`
  16279. } `json:"setlinfo"`
  16280. } `json:"output"`
  16281. RefmsgTime string `json:"refmsg_time"`
  16282. RespondTime string `json:"respond_time"`
  16283. Signtype interface{} `json:"signtype"`
  16284. WarnMsg interface{} `json:"warn_msg"`
  16285. }
  16286. type ResultEleven10265 struct {
  16287. Cainfo string `json:"cainfo"`
  16288. ErrMsg string `json:"err_msg"`
  16289. InfRefmsgid string `json:"inf_refmsgid"`
  16290. Infcode string `json:"infcode"`
  16291. Output struct {
  16292. Setlinfo struct {
  16293. SetlTime string `json:"setl_time"`
  16294. CvlservPay float64 `json:"cvlserv_pay"`
  16295. Year string `json:"year"`
  16296. MedType string `json:"med_type"`
  16297. PsnPay float64 `json:"psn_pay"`
  16298. OpterID string `json:"opter_id"`
  16299. Begndate string `json:"begndate"`
  16300. FlxempeFlag string `json:"flxempe_flag"`
  16301. HifmiPay float64 `json:"hifmi_pay"`
  16302. PsnNo string `json:"psn_no"`
  16303. ActPayDedc float64 `json:"act_pay_dedc"`
  16304. MedinsSetlID interface{} `json:"medins_setl_id"`
  16305. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16306. ClrWay string `json:"clr_way"`
  16307. OthPay float64 `json:"oth_pay"`
  16308. Gend string `json:"gend"`
  16309. MdtrtID string `json:"mdtrt_id"`
  16310. AcctPay float64 `json:"acct_pay"`
  16311. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16312. Insutype string `json:"insutype"`
  16313. Invono interface{} `json:"invono"`
  16314. Enddate string `json:"enddate"`
  16315. CashPayamt float64 `json:"cash_payamt"`
  16316. PsnType string `json:"psn_type"`
  16317. FixmedinsName string `json:"fixmedins_name"`
  16318. HifpPay float64 `json:"hifp_pay"`
  16319. NewFlag interface{} `json:"new_flag"`
  16320. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16321. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16322. PayLoc string `json:"pay_loc"`
  16323. ClrType string `json:"clr_type"`
  16324. RefdSetlFlag string `json:"refd_setl_flag"`
  16325. CvlservFlag string `json:"cvlserv_flag"`
  16326. EmpName string `json:"emp_name"`
  16327. Brdy string `json:"brdy"`
  16328. Naty string `json:"naty"`
  16329. Certno string `json:"certno"`
  16330. DiseCode string `json:"dise_code"`
  16331. FixmedinsCode string `json:"fixmedins_code"`
  16332. DedcHospLv string `json:"dedc_hosp_lv"`
  16333. OpterName string `json:"opter_name"`
  16334. Balc float64 `json:"balc"`
  16335. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16336. PsnCertType string `json:"psn_cert_type"`
  16337. HifobPay float64 `json:"hifob_pay"`
  16338. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16339. HifesPay float64 `json:"hifes_pay"`
  16340. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16341. OptTime string `json:"opt_time"`
  16342. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16343. SetlID string `json:"setl_id"`
  16344. MafPay float64 `json:"maf_pay"`
  16345. PsnName string `json:"psn_name"`
  16346. InsuOptins interface{} `json:"insu_optins"`
  16347. PrefFundPay interface{} `json:"pref_fund_pay"`
  16348. ClrOptins string `json:"clr_optins"`
  16349. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16350. DiseName string `json:"dise_name"`
  16351. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16352. Age float64 `json:"age"`
  16353. DtrtCertType string `json:"dtrt_cert_type"`
  16354. HospLv string `json:"hosp_lv"`
  16355. PsnCashPay float64 `json:"psn_cash_pay"`
  16356. } `json:"setlinfo"`
  16357. } `json:"output"`
  16358. RefmsgTime string `json:"refmsg_time"`
  16359. RespondTime string `json:"respond_time"`
  16360. Signtype interface{} `json:"signtype"`
  16361. WarnMsg interface{} `json:"warn_msg"`
  16362. }
  16363. type ResultTwelve struct {
  16364. Cainfo string `json:"cainfo"`
  16365. ErrMsg string `json:"err_msg"`
  16366. InfRefmsgid string `json:"inf_refmsgid"`
  16367. Infcode int64 `json:"infcode"`
  16368. Output struct {
  16369. MdtrtId string `json:"mdtrt_id"`
  16370. ChrgBchno string `json:"chrg_bchno"`
  16371. PsnNo string `json:"psn_no"`
  16372. } `json:"output"`
  16373. RefmsgTime string `json:"refmsg_time"`
  16374. RespondTime string `json:"respond_time"`
  16375. Signtype interface{} `json:"signtype"`
  16376. WarnMsg interface{} `json:"warn_msg"`
  16377. }
  16378. type ResultThirteen struct {
  16379. ErrMsg string `json:"err_msg"`
  16380. InfRefmsgid string `json:"inf_refmsgid"`
  16381. Infcode int64 `json:"infcode"`
  16382. Output struct {
  16383. Result struct {
  16384. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16385. } `json:"result"`
  16386. } `json:"output"`
  16387. RefmsgTime string `json:"refmsg_time"`
  16388. RespondTime string `json:"respond_time"`
  16389. Signtype interface{} `json:"signtype"`
  16390. WarnInfo interface{} `json:"warn_info"`
  16391. }
  16392. type ResultThirteen10265 struct {
  16393. ErrMsg string `json:"err_msg"`
  16394. InfRefmsgid string `json:"inf_refmsgid"`
  16395. Infcode string `json:"infcode"`
  16396. Output struct {
  16397. Result struct {
  16398. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16399. } `json:"result"`
  16400. } `json:"output"`
  16401. RefmsgTime string `json:"refmsg_time"`
  16402. RespondTime string `json:"respond_time"`
  16403. Signtype interface{} `json:"signtype"`
  16404. WarnInfo interface{} `json:"warn_info"`
  16405. }
  16406. type ResultFourteen struct {
  16407. ErrMsg string `json:"err_msg"`
  16408. InfRefmsgid string `json:"inf_refmsgid"`
  16409. Infcode int64 `json:"infcode"`
  16410. Output struct {
  16411. } `json:"output"`
  16412. RefmsgTime string `json:"refmsg_time"`
  16413. RespondTime string `json:"respond_time"`
  16414. Signtype interface{} `json:"signtype"`
  16415. WarnInfo interface{} `json:"warn_info"`
  16416. }
  16417. type ResultCFYLJG001 struct {
  16418. ErrMsg string `json:"err_msg"`
  16419. InfRefmsgid string `json:"inf_refmsgid"`
  16420. Infcode int64 `json:"infcode"`
  16421. Output struct {
  16422. RxTraceCode string `json:"rx_trace_code"`
  16423. HiRxno string `json:"hi_rxno"`
  16424. } `json:"output"`
  16425. RefmsgTime string `json:"refmsg_time"`
  16426. RespondTime string `json:"respond_time"`
  16427. Signtype interface{} `json:"signtype"`
  16428. WarnInfo interface{} `json:"warn_info"`
  16429. }
  16430. type ResultCFYLJG007 struct {
  16431. ErrMsg string `json:"err_msg"`
  16432. InfRefmsgid string `json:"inf_refmsgid"`
  16433. Infcode int64 `json:"infcode"`
  16434. Output struct {
  16435. HiRxno string `json:"hi_rxno"`
  16436. RxStasName string `json:"rx_stas_name"`
  16437. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16438. Seltdelts []interface{} `json:"seltdelts"`
  16439. RxUsedStasName string `json:"rx_used_stas_name"`
  16440. RxStasCodg string `json:"rx_stas_codg"`
  16441. } `json:"output"`
  16442. RefmsgTime string `json:"refmsg_time"`
  16443. RespondTime string `json:"respond_time"`
  16444. Signtype interface{} `json:"signtype"`
  16445. WarnInfo interface{} `json:"warn_info"`
  16446. }
  16447. type ResultCFYLJG002 struct {
  16448. ErrMsg string `json:"err_msg"`
  16449. InfRefmsgid string `json:"inf_refmsgid"`
  16450. Infcode int64 `json:"infcode"`
  16451. Output struct {
  16452. RxFile string `json:"rx_file"`
  16453. SignDigest string `json:"sign_digest"`
  16454. SignCertSn string `json:"sign_cert_sn"`
  16455. SignCertDn string `json:"sign_cert_dn"`
  16456. } `json:"output"`
  16457. RefmsgTime string `json:"refmsg_time"`
  16458. RespondTime string `json:"respond_time"`
  16459. Signtype interface{} `json:"signtype"`
  16460. WarnInfo interface{} `json:"warn_info"`
  16461. }
  16462. type ResultCFYLJG003 struct {
  16463. ErrMsg string `json:"err_msg"`
  16464. InfRefmsgid string `json:"inf_refmsgid"`
  16465. Infcode int64 `json:"infcode"`
  16466. Output struct {
  16467. HiRxno string `json:"hi_rxno"`
  16468. RxStasCodg string `json:"rx_stas_codg"`
  16469. RxStasName string `json:"rx_stas_name"`
  16470. } `json:"output"`
  16471. RefmsgTime string `json:"refmsg_time"`
  16472. RespondTime string `json:"respond_time"`
  16473. Signtype interface{} `json:"signtype"`
  16474. WarnInfo interface{} `json:"warn_info"`
  16475. }
  16476. type ResultCFYLJG004 struct {
  16477. ErrMsg string `json:"err_msg"`
  16478. InfRefmsgid string `json:"inf_refmsgid"`
  16479. Infcode int64 `json:"infcode"`
  16480. Output struct {
  16481. HiRxno string `json:"hi_rxno"`
  16482. RxStasCodg string `json:"rx_stas_codg"`
  16483. RxStasName string `json:"rx_stas_name"`
  16484. } `json:"output"`
  16485. RefmsgTime string `json:"refmsg_time"`
  16486. RespondTime string `json:"respond_time"`
  16487. Signtype interface{} `json:"signtype"`
  16488. WarnInfo interface{} `json:"warn_info"`
  16489. }
  16490. type ResultCFYLJG008 struct {
  16491. ErrMsg string `json:"err_msg"`
  16492. InfRefmsgid string `json:"inf_refmsgid"`
  16493. Infcode int64 `json:"infcode"`
  16494. Output struct {
  16495. PoolareaNo string `json:"poolareaNo"`
  16496. AdmdvsName string `json:"admdvsName"`
  16497. Count string `json:"count"`
  16498. } `json:"output"`
  16499. RefmsgTime string `json:"refmsg_time"`
  16500. RespondTime string `json:"respond_time"`
  16501. Signtype interface{} `json:"signtype"`
  16502. WarnInfo interface{} `json:"warn_info"`
  16503. }
  16504. type ResultCFYLJG005 struct {
  16505. ErrMsg string `json:"err_msg"`
  16506. InfRefmsgid string `json:"inf_refmsgid"`
  16507. Infcode int64 `json:"infcode"`
  16508. Output struct {
  16509. HiRxNo string `json:"hi_rxno"`
  16510. FixMedinsCode string `json:"fixmedins_code"`
  16511. FixMedinsName string `json:"fixmedins_name"`
  16512. RxStasCodg string `json:"rx_stas_codg"`
  16513. RxStasName string `json:"rx_stas_name"`
  16514. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16515. RxUserdStasName string `json:"rx_userd_stas_name"`
  16516. PrscTime string `json:"prsc_time"`
  16517. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16518. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16519. RxUsedWayName string `json:"rx_used_way_name"`
  16520. RxFrquCodg string `json:"rx_frqu_codg"`
  16521. RxFrquName string `json:"rx_frqu_name"`
  16522. RxDosunt string `json:"rx_dosunt"`
  16523. RxDoscnt float64 `json:"rx_doscnt"`
  16524. RxDrordDscr string `json:"rx_drord_dscr"`
  16525. ValiDays int64 `json:"vali_days"`
  16526. ValiEndTime string `json:"vali_end_time"`
  16527. ReptFlag string `json:"rept_flag"`
  16528. MaxReptCnt int64 `json:"max_rept_cnt"`
  16529. ReptdCnt int64 `json:"reptd_cnt"`
  16530. MinInrvDays int64 `json:"min_inrv_days"`
  16531. RxTypeCode string `json:"rx_type_code"`
  16532. RxTypeName string `json:"rx_type_name"`
  16533. LongRxFlag string `json:"long_rx_flag"`
  16534. RxDetlList []struct {
  16535. MedListCodg string `json:"med_list_codg"`
  16536. MedinsListCodg string `json:"medins_list_codg"`
  16537. HospPrepFlag string `json:"hosp_prep_flag"`
  16538. RxItemTypeCode string `json:"rx_item_type_code"`
  16539. RxItemTypeName string `json:"rx_item_type_name"`
  16540. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16541. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16542. TcmHerbFoote string `json:"tcmherb_foote"`
  16543. MednTypeCode string `json:"medn_type_code"`
  16544. MednTypeName string `json:"medn_type_name"`
  16545. MainMedcFlag string `json:"main_medc_flag"`
  16546. UrgtFlag string `json:"urgt_flag"`
  16547. BasMednFlag string `json:"bas_medn_flag"`
  16548. ImpDrugFlag string `json:"imp_drug_flag"`
  16549. ProdBarc string `json:"prod_barc"`
  16550. DrugProdname string `json:"drug_prodname"`
  16551. GennameCodg string `json:"genname_codg"`
  16552. DrugGenname string `json:"drug_genname"`
  16553. DrugDosform string `json:"drug_dosform"`
  16554. DrugSpec string `json:"drug_spec"`
  16555. PrdrName string `json:"prdr_name"`
  16556. MedcWayCodg string `json:"medc_way_codg"`
  16557. MedcWayDscr string `json:"medc_way_dscr"`
  16558. MedcBegntime string `json:"medc_begntime"`
  16559. MedcEndtime string `json:"medc_endtime"`
  16560. MedcDays float64 `json:"medc_days"`
  16561. DrugPric float64 `json:"drug_pric"`
  16562. DrugSumamt float64 `json:"drug_sumamt"`
  16563. DrugCnt float64 `json:"drug_cnt"`
  16564. DrugDosunt string `json:"drug_dosunt"`
  16565. SinDoscnt float64 `json:"sin_doscnt"`
  16566. SinDosunt string `json:"sin_dosunt"`
  16567. UsedFrquCodg string `json:"used_frqu_codg"`
  16568. UsedFrquName string `json:"used_frqu_name"`
  16569. DrugTotlcnt string `json:"drug_totlcnt"`
  16570. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16571. DiseCodg string `json:"dise_codg"`
  16572. HospApprFlag string `json:"hosp_appr_flag"`
  16573. } `json:"rx_detl_list"`
  16574. RxOtpinfo struct {
  16575. MedType string `json:"med_type"`
  16576. IptOtpNo string `json:"ipt_otp_no"`
  16577. OtpIptFlag string `json:"otp_ipt_flag"`
  16578. PatnName string `json:"patn_name"`
  16579. PatnAge float64 `json:"patn_age"`
  16580. PatnHgt float64 `json:"patn_hgt"`
  16581. PatnWt float64 `json:"patn_wt"`
  16582. Gend string `json:"gend"`
  16583. GesoVal float64 `json:"geso_val"`
  16584. NwbFlag string `json:"nwb_flag"`
  16585. NwbAge string `json:"nwb_age"`
  16586. SuckPrdFlag string `json:"suck_prd_flag"`
  16587. AlgsHis string `json:"algs_his"`
  16588. Insutype string `json:"insutype"`
  16589. PrscDeptName string `json:"prsc_dept_name"`
  16590. PrscDrName string `json:"prsc_dr_name"`
  16591. PharName string `json:"phar_name"`
  16592. PharChkTime string `json:"phar_chk_time"`
  16593. MdtrtTime string `json:"mdtrt_time"`
  16594. DiseCodg string `json:"dise_codg"`
  16595. DiseName string `json:"dise_name"`
  16596. SpDiseFlag string `json:"sp_dise_flag"`
  16597. MaindiagCode string `json:"maindiag_code"`
  16598. MaindiagName string `json:"maindiag_name"`
  16599. DiseCondDscr string `json:"dise_cond_dscr"`
  16600. FstdiagFlag string `json:"fstdiag_flag"`
  16601. } `json:"rx_otpinfo"`
  16602. RxDiseList []struct {
  16603. DiagType string `json:"diag_type"`
  16604. MaindiagFlag string `json:"maindiag_flag"`
  16605. DiagSrtNo string `json:"diag_srt_no"`
  16606. DiagCode string `json:"diag_code"`
  16607. DiagName string `json:"diag_name"`
  16608. DiagDept string `json:"diag_dept"`
  16609. DiagDrNo string `json:"diag_dr_no"`
  16610. DiagDrName string `json:"diag_dr_name"`
  16611. DiagTime string `json:"diag_time"`
  16612. TcmDiseCode string `json:"tcm_dise_code"`
  16613. TcmDiseName string `json:"tcm_dise_name"`
  16614. TcmSympCode string `json:"tcmsymp_code"`
  16615. TcmSymp string `json:"tcmsymp"`
  16616. } `json:"rx_dise_list"`
  16617. } `json:"output"`
  16618. RefmsgTime string `json:"refmsg_time"`
  16619. RespondTime string `json:"respond_time"`
  16620. Signtype interface{} `json:"signtype"`
  16621. WarnInfo interface{} `json:"warn_info"`
  16622. }
  16623. type ResultCFYLJG006 struct {
  16624. ErrMsg string `json:"err_msg"`
  16625. InfRefmsgid string `json:"inf_refmsgid"`
  16626. Infcode int64 `json:"infcode"`
  16627. Output struct {
  16628. HiRxNo string `json:"hi_rxno"`
  16629. PharCode string `json:"phar_code"`
  16630. PharName string `json:"phar_name"`
  16631. RxChkOpnn string `json:"rx_chk_opnn"`
  16632. RxChkTime string `json:"rx_chk_time"`
  16633. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16634. RxChkStasName string `json:"rx_chk_stas_name"`
  16635. RxStasCodg string `json:"rx_stas_codg"`
  16636. RxStasName string `json:"rx_stas_name"`
  16637. } `json:"output"`
  16638. RefmsgTime string `json:"refmsg_time"`
  16639. RespondTime string `json:"respond_time"`
  16640. Signtype interface{} `json:"signtype"`
  16641. WarnInfo interface{} `json:"warn_info"`
  16642. }
  16643. type ResultFourteen10265 struct {
  16644. ErrMsg string `json:"err_msg"`
  16645. InfRefmsgid string `json:"inf_refmsgid"`
  16646. Infcode string `json:"infcode"`
  16647. Output struct {
  16648. } `json:"output"`
  16649. RefmsgTime string `json:"refmsg_time"`
  16650. RespondTime string `json:"respond_time"`
  16651. Signtype interface{} `json:"signtype"`
  16652. WarnInfo interface{} `json:"warn_info"`
  16653. }
  16654. type ResultSixteen struct {
  16655. Cainfo string `json:"cainfo"`
  16656. ErrMsg string `json:"err_msg"`
  16657. InfRefmsgid string `json:"inf_refmsgid"`
  16658. Infcode int64 `json:"infcode"`
  16659. Output struct {
  16660. Setlinfo struct {
  16661. MdtrtID string `json:"mdtrt_id"`
  16662. SetlID string `json:"setl_id"`
  16663. ClrOptins string `json:"clr_optins"`
  16664. SetlTime string `json:"setl_time"`
  16665. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16666. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16667. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16668. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16669. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16670. ActPayDedc float64 `json:"act_pay_dedc"`
  16671. HifpPay float64 `json:"hifp_pay"`
  16672. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16673. Lfpay float64 `json:"selfpay"`
  16674. CvlservPay float64 `json:"cvlserv_pay"`
  16675. HifesPay float64 `json:"hifes_pay"`
  16676. HifmiPay float64 `json:"hifmi_pay"`
  16677. HifobPay float64 `json:"hifob_pay"`
  16678. MafPay float64 `json:"maf_pay"`
  16679. OthPay float64 `json:"oth_pay"`
  16680. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16681. PsnPartAmt float64 `json:"psn_part_amt"`
  16682. AcctPay float64 `json:"acct_pay"`
  16683. Balc float64 `json:"balc"`
  16684. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16685. HospPartAmt float64 `json:"hosp_part_amt"`
  16686. MedinsSetlID string `json:"medins_setl_id"`
  16687. PdnCashPay string `json:"pdn_cash_pay"`
  16688. } `json:"setlinfo"`
  16689. } `json:"output"`
  16690. RefmsgTime string `json:"refmsg_time"`
  16691. RespondTime string `json:"respond_time"`
  16692. Signtype interface{} `json:"signtype"`
  16693. WarnMsg interface{} `json:"warn_msg"`
  16694. }
  16695. type ResultSixteen10265 struct {
  16696. Cainfo string `json:"cainfo"`
  16697. ErrMsg string `json:"err_msg"`
  16698. InfRefmsgid string `json:"inf_refmsgid"`
  16699. Infcode string `json:"infcode"`
  16700. Output struct {
  16701. Setlinfo struct {
  16702. MdtrtID string `json:"mdtrt_id"`
  16703. SetlID string `json:"setl_id"`
  16704. ClrOptins string `json:"clr_optins"`
  16705. SetlTime string `json:"setl_time"`
  16706. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16707. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16708. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16709. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16710. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16711. ActPayDedc float64 `json:"act_pay_dedc"`
  16712. HifpPay float64 `json:"hifp_pay"`
  16713. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16714. Lfpay float64 `json:"selfpay"`
  16715. CvlservPay float64 `json:"cvlserv_pay"`
  16716. HifesPay float64 `json:"hifes_pay"`
  16717. HifmiPay float64 `json:"hifmi_pay"`
  16718. HifobPay float64 `json:"hifob_pay"`
  16719. MafPay float64 `json:"maf_pay"`
  16720. OthPay float64 `json:"oth_pay"`
  16721. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16722. PsnPartAmt float64 `json:"psn_part_amt"`
  16723. AcctPay float64 `json:"acct_pay"`
  16724. Balc float64 `json:"balc"`
  16725. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16726. HospPartAmt float64 `json:"hosp_part_amt"`
  16727. MedinsSetlID string `json:"medins_setl_id"`
  16728. PdnCashPay string `json:"pdn_cash_pay"`
  16729. } `json:"setlinfo"`
  16730. } `json:"output"`
  16731. RefmsgTime string `json:"refmsg_time"`
  16732. RespondTime string `json:"respond_time"`
  16733. Signtype interface{} `json:"signtype"`
  16734. WarnMsg interface{} `json:"warn_msg"`
  16735. }
  16736. type ResultSixteen10265Two struct {
  16737. Cainfo string `json:"cainfo"`
  16738. ErrMsg string `json:"err_msg"`
  16739. InfRefmsgid string `json:"inf_refmsgid"`
  16740. Infcode string `json:"infcode"`
  16741. Output struct {
  16742. Setlinfo interface{} `json:"setlinfo"`
  16743. } `json:"output"`
  16744. RefmsgTime string `json:"refmsg_time"`
  16745. RespondTime string `json:"respond_time"`
  16746. Signtype interface{} `json:"signtype"`
  16747. WarnMsg interface{} `json:"warn_msg"`
  16748. }
  16749. type ResultgzSixteen10265Two struct {
  16750. Cainfo string `json:"cainfo"`
  16751. ErrMsg string `json:"err_msg"`
  16752. InfRefmsgid string `json:"inf_refmsgid"`
  16753. Infcode int64 `json:"infcode"`
  16754. Output struct {
  16755. Setlinfo interface{} `json:"setlinfo"`
  16756. } `json:"output"`
  16757. RefmsgTime string `json:"refmsg_time"`
  16758. RespondTime string `json:"respond_time"`
  16759. Signtype interface{} `json:"signtype"`
  16760. WarnMsg interface{} `json:"warn_msg"`
  16761. }
  16762. type ResultSeventeen struct {
  16763. ErrMsg string `json:"err_msg"`
  16764. InfRefmsgid string `json:"inf_refmsgid"`
  16765. Infcode int64 `json:"infcode"`
  16766. Output struct {
  16767. SetlListId string `json:"setl_list_id"`
  16768. } `json:"output"`
  16769. RefmsgTime string `json:"refmsg_time"`
  16770. RespondTime string `json:"respond_time"`
  16771. Signtype string `json:"signtype"`
  16772. WarnInfo string `json:"warn_info"`
  16773. }
  16774. type ResultSeventeenOther struct {
  16775. ErrMsg string `json:"err_msg"`
  16776. InfRefmsgid string `json:"inf_refmsgid"`
  16777. Infcode string `json:"infcode"`
  16778. Output struct {
  16779. SetlListId string `json:"setl_list_id"`
  16780. } `json:"output"`
  16781. RefmsgTime string `json:"refmsg_time"`
  16782. RespondTime string `json:"respond_time"`
  16783. Signtype string `json:"signtype"`
  16784. WarnInfo string `json:"warn_info"`
  16785. }
  16786. type Result90991 struct {
  16787. ErrMsg string `json:"err_msg"`
  16788. InfRefmsgid string `json:"inf_refmsgid"`
  16789. Infcode int64 `json:"infcode"`
  16790. Output struct {
  16791. Result struct {
  16792. PsnNo string `json:"psn_no"`
  16793. CardStat string `json:"card_stat"`
  16794. Certno string `json:"certno"`
  16795. PsnName string `json:"psn_name"`
  16796. CheckStat string `json:"check_stat"`
  16797. SscnoCheckStat string `json:"sscno_check_stat"`
  16798. } `json:"result"`
  16799. } `json:"output"`
  16800. RefmsgTime string `json:"refmsg_time"`
  16801. RespondTime string `json:"respond_time"`
  16802. Signtype interface{} `json:"signtype"`
  16803. WarnInfo interface{} `json:"warn_info"`
  16804. }
  16805. type Result90100 struct {
  16806. ErrMsg string `json:"err_msg"`
  16807. InfRefmsgid string `json:"inf_refmsgid"`
  16808. Infcode int64 `json:"infcode"`
  16809. Output struct {
  16810. PoolareaNo string `json:"poolarea_no"`
  16811. PoolareaNoName string `json:"poolarea_no_name"`
  16812. Insutype string `json:"insutype"`
  16813. InsutypeName string `json:"insutype_name"`
  16814. ClctType string `json:"clct_type"`
  16815. ClctTypeName string `json:"clct_type_name"`
  16816. ClctFlag string `json:"clct_flag"`
  16817. ClctFlagName string `json:"clct_flag_name"`
  16818. AccrymBegn string `json:"accrym_begn"`
  16819. AccrymEnd string `json:"accrym_end"`
  16820. ClctTime string `json:"clct_time"`
  16821. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16822. } `json:"output"`
  16823. RefmsgTime string `json:"refmsg_time"`
  16824. RespondTime string `json:"respond_time"`
  16825. Signtype interface{} `json:"signtype"`
  16826. WarnInfo interface{} `json:"warn_info"`
  16827. }
  16828. type Custom struct {
  16829. DetItemFeeSumamt string
  16830. Cut string
  16831. FeedetlSn string
  16832. Price string
  16833. MedListCodg string
  16834. Type int64
  16835. AdviceId int64
  16836. ProjectId int64
  16837. ItemId int64
  16838. }
  16839. type Result5301 struct {
  16840. ErrMsg string `json:"err_msg"`
  16841. InfRefmsgid string `json:"inf_refmsgid"`
  16842. Infcode int64 `json:"infcode"`
  16843. Output struct {
  16844. Result []struct {
  16845. OpspDiseCode string `json:"opsp_dise_code"`
  16846. OpspDiseName string `json:"opsp_dise_name"`
  16847. Begndate string `json:"begndate"`
  16848. Enddate string `json:"enddate"`
  16849. } `json:"feedetail"`
  16850. } `json:"output"`
  16851. RefmsgTime string `json:"refmsg_time"`
  16852. RespondTime string `json:"respond_time"`
  16853. Signtype interface{} `json:"signtype"`
  16854. WarnInfo interface{} `json:"warn_info"`
  16855. }
  16856. type Result5301For10265 struct {
  16857. ErrMsg string `json:"err_msg"`
  16858. InfRefmsgid string `json:"inf_refmsgid"`
  16859. Infcode string `json:"infcode"`
  16860. Output struct {
  16861. Result []struct {
  16862. OpspDiseCode string `json:"opsp_dise_code"`
  16863. OpspDiseName string `json:"opsp_dise_name"`
  16864. Begndate string `json:"begndate"`
  16865. Enddate string `json:"enddate"`
  16866. } `json:"feedetail"`
  16867. } `json:"output"`
  16868. RefmsgTime string `json:"refmsg_time"`
  16869. RespondTime string `json:"respond_time"`
  16870. Signtype interface{} `json:"signtype"`
  16871. WarnInfo interface{} `json:"warn_info"`
  16872. }
  16873. //获取个人信息----挂号-----上传就诊信息
  16874. func (c *HisApiController) GetRegisterInfo() {
  16875. id, _ := c.GetInt64("id")
  16876. record_time := c.GetString("record_time")
  16877. settlementValue, _ := c.GetInt64("settlement_value")
  16878. medical_insurance_card := c.GetString("medical_insurance_card")
  16879. name := c.GetString("name")
  16880. id_card_type, _ := c.GetInt64("id_card_type")
  16881. certificates, _ := c.GetInt64("certificates")
  16882. medical_care, _ := c.GetInt64("medical_care")
  16883. birthday := c.GetString("birthday")
  16884. id_card := c.GetString("id_card")
  16885. register_type, _ := c.GetInt64("register")
  16886. doctor, _ := c.GetInt64("doctor")
  16887. department, _ := c.GetInt64("department")
  16888. gender, _ := c.GetInt64("sex")
  16889. registration_fee, _ := c.GetFloat("registration_fee")
  16890. medical_expenses, _ := c.GetFloat("medical_expenses")
  16891. social_type, _ := c.GetInt64("social_type")
  16892. admin_user_id, _ := c.GetInt64("admin_user_id")
  16893. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16894. mdtrt_type := c.GetString("mdtrt_type")
  16895. if id_card_type == 5 {
  16896. id_card_type = 4
  16897. }
  16898. timeLayout := "2006-01-02"
  16899. loc, _ := time.LoadLocation("Local")
  16900. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16901. birthUnix := birthdays.Unix()
  16902. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16903. if err != nil {
  16904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16905. return
  16906. }
  16907. recordDateTime := theTime.Unix()
  16908. adminInfo := c.GetAdminUserInfo()
  16909. var patient service.Patients
  16910. if id == 0 {
  16911. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16912. } else {
  16913. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16914. }
  16915. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16916. if patientPrescription.ID == 0 {
  16917. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16918. }
  16919. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16920. if patient.ID == 0 {
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16922. return
  16923. }
  16924. if len(patient.IdCardNo) == 0 {
  16925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16926. return
  16927. }
  16928. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16929. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16930. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16931. //就诊结算未完成,不能进行二次挂号
  16932. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16933. //if len(his) >= 1 {
  16934. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16935. // if len(his) >= 1 && order.ID == 0 {
  16936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16937. // return
  16938. // }
  16939. //}
  16940. //var register_log string
  16941. if config.IsOpen == 1 {
  16942. var res ResultTwo
  16943. var res10265 ResultTwo10265
  16944. var PsnNo string
  16945. var PsnCertType string
  16946. var Certno string
  16947. var PsnName string
  16948. var Gend string
  16949. var Naty string
  16950. var Brdy string
  16951. var Age float64
  16952. var infoStr string
  16953. var idetinfoStr string
  16954. var infocode int64
  16955. var verify_number string
  16956. fmt.Println(verify_number)
  16957. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  16958. psn_info, _ := service.GetPsnByPatientId(id)
  16959. PsnNo = psn_info.PsnNo
  16960. PsnCertType = psn_info.PsnCertType
  16961. Certno = psn_info.Certno
  16962. PsnName = psn_info.PsnName
  16963. Gend = psn_info.Gend
  16964. Naty = psn_info.Naty
  16965. Brdy = psn_info.Brdy
  16966. Age = psn_info.Age
  16967. infoStr = psn_info.Insuinfo
  16968. idetinfoStr = psn_info.Idetinfo
  16969. infocode = 0
  16970. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16971. psn_info, _ := service.GetPsnByPatientId(id)
  16972. PsnNo = psn_info.PsnNo
  16973. PsnCertType = psn_info.PsnCertType
  16974. Certno = psn_info.Certno
  16975. PsnName = psn_info.PsnName
  16976. Gend = psn_info.Gend
  16977. Naty = psn_info.Naty
  16978. Brdy = psn_info.Brdy
  16979. Age = psn_info.Age
  16980. infoStr = psn_info.Insuinfo
  16981. idetinfoStr = psn_info.Idetinfo
  16982. infocode = 0
  16983. verify_number = psn_info.VerifyNumber
  16984. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16985. if id_card_type == 2 {
  16986. //请求内网数据
  16987. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16988. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16989. "&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
  16990. resp, requestErr := http.Get(api)
  16991. if requestErr != nil {
  16992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16993. return
  16994. }
  16995. body, ioErr := ioutil.ReadAll(resp.Body)
  16996. if ioErr != nil {
  16997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16999. return
  17000. }
  17001. var respJSON map[string]interface{}
  17002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17005. return
  17006. }
  17007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17008. result_byte, _ := json.Marshal(respJSON)
  17009. result := string(result_byte)
  17010. var dat map[string]interface{}
  17011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17012. fmt.Println(dat)
  17013. } else {
  17014. fmt.Println(err)
  17015. }
  17016. userJSONBytes, _ := json.Marshal(dat)
  17017. var res ResultTwo
  17018. var resTwo10265 ResultTwo10265
  17019. if miConfig.Code == "H15049901371" {
  17020. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17021. utils.ErrorLog("解析失败:%v", err)
  17022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17023. return
  17024. }
  17025. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17026. res.Infcode = Infcode
  17027. res.ErrMsg = resTwo10265.ErrMsg
  17028. res.Output = resTwo10265.Output
  17029. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17030. res.RespondTime = resTwo10265.RespondTime
  17031. res.WarnInfo = resTwo10265.WarnInfo
  17032. } else {
  17033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17034. utils.ErrorLog("解析失败:%v", err)
  17035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17036. return
  17037. }
  17038. }
  17039. //var insutypes []string
  17040. //var insutype string
  17041. //var is390 int = 0
  17042. //var is310 int = 0
  17043. //for _, item := range res.Output.Iinfo {
  17044. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17045. // insutypes = append(insutypes, item.Insutype)
  17046. // }
  17047. //}
  17048. //if len(insutypes) == 1 {
  17049. // insutype = insutypes[0]
  17050. //} else {
  17051. // for _, i := range insutypes {
  17052. // if i == "390" {
  17053. // is390 = 1
  17054. // }
  17055. //
  17056. // if i == "310" {
  17057. // is310 = 1
  17058. // }
  17059. // }
  17060. //}
  17061. //if is390 == 1 {
  17062. // insutype = "390"
  17063. //}
  17064. //if is310 == 1 {
  17065. // insutype = "310"
  17066. //}
  17067. //if len(insutypes) == 0 {
  17068. // insutype = "310"
  17069. //}
  17070. PsnNo = res.Output.Baseinfo.PsnNo
  17071. PsnCertType = res.Output.Baseinfo.PsnCertType
  17072. Certno = res.Output.Baseinfo.Certno
  17073. PsnName = res.Output.Baseinfo.PsnName
  17074. Gend = res.Output.Baseinfo.Gend
  17075. Naty = res.Output.Baseinfo.Naty
  17076. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17077. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17078. infoStr = string(Iinfos)
  17079. idetinfoStr = string(Idetinfos)
  17080. infocode = res.Infcode
  17081. //infocode = 0
  17082. //verify_number = psn_info.VerifyNumber
  17083. } else {
  17084. psn_info, _ := service.GetPsnByPatientId(id)
  17085. PsnNo = psn_info.PsnNo
  17086. PsnCertType = psn_info.PsnCertType
  17087. Certno = psn_info.Certno
  17088. PsnName = psn_info.PsnName
  17089. Gend = psn_info.Gend
  17090. Naty = psn_info.Naty
  17091. Brdy = psn_info.Brdy
  17092. Age = psn_info.Age
  17093. infoStr = psn_info.Insuinfo
  17094. idetinfoStr = psn_info.Idetinfo
  17095. infocode = 0
  17096. verify_number = psn_info.VerifyNumber
  17097. }
  17098. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17099. if id_card_type == 1 {
  17100. psn_info, _ := service.GetPsnByPatientId(id)
  17101. PsnNo = psn_info.PsnNo
  17102. PsnCertType = psn_info.PsnCertType
  17103. Certno = psn_info.Certno
  17104. PsnName = psn_info.PsnName
  17105. Gend = psn_info.Gend
  17106. Naty = psn_info.Naty
  17107. Brdy = psn_info.Brdy
  17108. Age = psn_info.Age
  17109. infoStr = psn_info.Insuinfo
  17110. idetinfoStr = psn_info.Idetinfo
  17111. infocode = 0
  17112. verify_number = psn_info.VerifyNumber
  17113. } else if id_card_type == 2 {
  17114. 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)
  17115. fmt.Println(errMsgLog)
  17116. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17117. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17118. utils.ErrorLog("解析失败:%v", err)
  17119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17120. return
  17121. }
  17122. PsnNo = res.Output.Baseinfo.PsnNo
  17123. PsnCertType = res.Output.Baseinfo.PsnCertType
  17124. Certno = res.Output.Baseinfo.Certno
  17125. PsnName = res.Output.Baseinfo.PsnName
  17126. Gend = res.Output.Baseinfo.Gend
  17127. Naty = res.Output.Baseinfo.Naty
  17128. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17129. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17130. infoStr = string(Iinfos)
  17131. idetinfoStr = string(Idetinfos)
  17132. infocode = res.Infcode
  17133. }
  17134. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17135. if id_card_type == 1 {
  17136. psn_info, _ := service.GetPsnByPatientId(id)
  17137. PsnNo = psn_info.PsnNo
  17138. PsnCertType = psn_info.PsnCertType
  17139. Certno = psn_info.Certno
  17140. PsnName = psn_info.PsnName
  17141. Gend = psn_info.Gend
  17142. Naty = psn_info.Naty
  17143. Brdy = psn_info.Brdy
  17144. Age = psn_info.Age
  17145. infoStr = psn_info.Insuinfo
  17146. idetinfoStr = psn_info.Idetinfo
  17147. infocode = 0
  17148. verify_number = psn_info.VerifyNumber
  17149. } else if id_card_type == 2 {
  17150. 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, "")
  17151. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17152. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17153. utils.ErrorLog("解析失败:%v", err)
  17154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17155. return
  17156. }
  17157. PsnNo = res.Output.Baseinfo.PsnNo
  17158. PsnCertType = res.Output.Baseinfo.PsnCertType
  17159. Certno = res.Output.Baseinfo.Certno
  17160. PsnName = res.Output.Baseinfo.PsnName
  17161. Gend = res.Output.Baseinfo.Gend
  17162. Naty = res.Output.Baseinfo.Naty
  17163. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17164. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17165. infoStr = string(Iinfos)
  17166. idetinfoStr = string(Idetinfos)
  17167. infocode = res.Infcode
  17168. } else {
  17169. psn_info, _ := service.GetPsnByPatientId(id)
  17170. PsnNo = psn_info.PsnNo
  17171. PsnCertType = psn_info.PsnCertType
  17172. Certno = psn_info.Certno
  17173. PsnName = psn_info.PsnName
  17174. Gend = psn_info.Gend
  17175. Naty = psn_info.Naty
  17176. Brdy = psn_info.Brdy
  17177. Age = psn_info.Age
  17178. infoStr = psn_info.Insuinfo
  17179. idetinfoStr = psn_info.Idetinfo
  17180. infocode = 0
  17181. verify_number = psn_info.VerifyNumber
  17182. }
  17183. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17184. psn_info, _ := service.GetPsnByPatientId(id)
  17185. PsnNo = psn_info.PsnNo
  17186. PsnCertType = psn_info.PsnCertType
  17187. Certno = psn_info.Certno
  17188. PsnName = psn_info.PsnName
  17189. Gend = psn_info.Gend
  17190. Naty = psn_info.Naty
  17191. Brdy = psn_info.Brdy
  17192. Age = psn_info.Age
  17193. infoStr = psn_info.Insuinfo
  17194. idetinfoStr = psn_info.Idetinfo
  17195. infocode = 0
  17196. verify_number = psn_info.VerifyNumber
  17197. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17198. if id_card_type == 1 {
  17199. psn_info, _ := service.GetPsnByPatientId(id)
  17200. PsnNo = psn_info.PsnNo
  17201. PsnCertType = psn_info.PsnCertType
  17202. Certno = psn_info.Certno
  17203. PsnName = psn_info.PsnName
  17204. Gend = psn_info.Gend
  17205. Naty = psn_info.Naty
  17206. Brdy = psn_info.Brdy
  17207. Age = psn_info.Age
  17208. infoStr = psn_info.Insuinfo
  17209. idetinfoStr = psn_info.Idetinfo
  17210. infocode = 0
  17211. verify_number = psn_info.VerifyNumber
  17212. } else if id_card_type == 2 {
  17213. 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)
  17214. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17215. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17216. utils.ErrorLog("解析失败:%v", err)
  17217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17218. return
  17219. }
  17220. PsnNo = res.Output.Baseinfo.PsnNo
  17221. PsnCertType = res.Output.Baseinfo.PsnCertType
  17222. Certno = res.Output.Baseinfo.Certno
  17223. PsnName = res.Output.Baseinfo.PsnName
  17224. Gend = res.Output.Baseinfo.Gend
  17225. Naty = res.Output.Baseinfo.Naty
  17226. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17227. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17228. infoStr = string(Iinfos)
  17229. idetinfoStr = string(Idetinfos)
  17230. infocode = res.Infcode
  17231. } else if id_card_type == 4 {
  17232. psn_info, _ := service.GetPsnByPatientId(id)
  17233. PsnNo = psn_info.PsnNo
  17234. PsnCertType = psn_info.PsnCertType
  17235. Certno = psn_info.Certno
  17236. PsnName = psn_info.PsnName
  17237. Gend = psn_info.Gend
  17238. Naty = psn_info.Naty
  17239. Brdy = psn_info.Brdy
  17240. Age = psn_info.Age
  17241. infoStr = psn_info.Insuinfo
  17242. idetinfoStr = psn_info.Idetinfo
  17243. infocode = 0
  17244. verify_number = psn_info.VerifyNumber
  17245. }
  17246. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17247. var result string
  17248. var requestLog string
  17249. 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), "")
  17250. if id_card_type == 4 {
  17251. psn_info, _ := service.GetPsnByPatientId(id)
  17252. PsnNo = psn_info.PsnNo
  17253. PsnCertType = psn_info.PsnCertType
  17254. Certno = psn_info.Certno
  17255. PsnName = psn_info.PsnName
  17256. Gend = psn_info.Gend
  17257. Naty = psn_info.Naty
  17258. Brdy = psn_info.Brdy
  17259. Age = psn_info.Age
  17260. infoStr = psn_info.Insuinfo
  17261. idetinfoStr = psn_info.Idetinfo
  17262. infocode = 0
  17263. verify_number = psn_info.VerifyNumber
  17264. } else {
  17265. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17266. if miConfig.Code == "H15049901371" {
  17267. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17268. utils.ErrorLog("解析失败:%v", err)
  17269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17270. return
  17271. }
  17272. res.ErrMsg = res10265.ErrMsg
  17273. res.Output = res10265.Output
  17274. res.InfRefmsgid = res10265.InfRefmsgid
  17275. } else {
  17276. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17277. utils.ErrorLog("解析失败:%v", err)
  17278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17279. return
  17280. }
  17281. }
  17282. PsnNo = res.Output.Baseinfo.PsnNo
  17283. PsnCertType = res.Output.Baseinfo.PsnCertType
  17284. Certno = res.Output.Baseinfo.Certno
  17285. PsnName = res.Output.Baseinfo.PsnName
  17286. Gend = res.Output.Baseinfo.Gend
  17287. Naty = res.Output.Baseinfo.Naty
  17288. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17289. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17290. infoStr = string(Iinfos)
  17291. idetinfoStr = string(Idetinfos)
  17292. if miConfig.Code == "H15049901371" {
  17293. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17294. } else {
  17295. infocode = res.Infcode
  17296. }
  17297. }
  17298. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17299. psn_info, _ := service.GetPsnByPatientId(id)
  17300. PsnNo = psn_info.PsnNo
  17301. PsnCertType = psn_info.PsnCertType
  17302. Certno = psn_info.Certno
  17303. PsnName = psn_info.PsnName
  17304. Gend = psn_info.Gend
  17305. Naty = psn_info.Naty
  17306. Brdy = psn_info.Brdy
  17307. Age = psn_info.Age
  17308. infoStr = psn_info.Insuinfo
  17309. idetinfoStr = psn_info.Idetinfo
  17310. infocode = 0
  17311. verify_number = psn_info.VerifyNumber
  17312. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17313. psn_info, _ := service.GetPsnByPatientId(id)
  17314. PsnNo = psn_info.PsnNo
  17315. PsnCertType = psn_info.PsnCertType
  17316. Certno = psn_info.Certno
  17317. PsnName = psn_info.PsnName
  17318. Gend = psn_info.Gend
  17319. Naty = psn_info.Naty
  17320. Brdy = psn_info.Brdy
  17321. Age = psn_info.Age
  17322. infoStr = psn_info.Insuinfo
  17323. idetinfoStr = psn_info.Idetinfo
  17324. infocode = 0
  17325. verify_number = psn_info.VerifyNumber
  17326. } else {
  17327. var result string
  17328. var requestLog string
  17329. //if miConfig.UserOrgId == 10138 {
  17330. if id_card_type != 4 || id_card_type != 1 {
  17331. var insa string
  17332. if len(patient.InsuplcAdmdvs) > 0 {
  17333. insa = patient.InsuplcAdmdvs
  17334. } else {
  17335. insa = miConfig.InsuplcAdmdvs
  17336. }
  17337. //psn_info, _ := service.GetPsnByPatientId(id)
  17338. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17339. 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)
  17340. }
  17341. //}
  17342. //else {
  17343. // var insa string
  17344. // if len(patient.InsuplcAdmdvs) > 0 {
  17345. // insa = patient.InsuplcAdmdvs
  17346. // } else {
  17347. // insa = miConfig.InsuplcAdmdvs
  17348. // }
  17349. // 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)
  17350. //}
  17351. if id_card_type == 4 || id_card_type == 1 {
  17352. psn_info, _ := service.GetPsnByPatientId(id)
  17353. PsnNo = psn_info.PsnNo
  17354. PsnCertType = psn_info.PsnCertType
  17355. Certno = psn_info.Certno
  17356. PsnName = psn_info.PsnName
  17357. Gend = psn_info.Gend
  17358. Naty = psn_info.Naty
  17359. Brdy = psn_info.Brdy
  17360. Age = psn_info.Age
  17361. infoStr = psn_info.Insuinfo
  17362. idetinfoStr = psn_info.Idetinfo
  17363. infocode = 0
  17364. verify_number = psn_info.VerifyNumber
  17365. } else {
  17366. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17367. if miConfig.Code == "H15049901371" {
  17368. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17369. utils.ErrorLog("解析失败:%v", err)
  17370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17371. return
  17372. }
  17373. res.ErrMsg = res10265.ErrMsg
  17374. res.Output = res10265.Output
  17375. res.InfRefmsgid = res10265.InfRefmsgid
  17376. } else {
  17377. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17378. utils.ErrorLog("解析失败:%v", err)
  17379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17380. return
  17381. }
  17382. }
  17383. PsnNo = res.Output.Baseinfo.PsnNo
  17384. PsnCertType = res.Output.Baseinfo.PsnCertType
  17385. Certno = res.Output.Baseinfo.Certno
  17386. PsnName = res.Output.Baseinfo.PsnName
  17387. Gend = res.Output.Baseinfo.Gend
  17388. Naty = res.Output.Baseinfo.Naty
  17389. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17390. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17391. infoStr = string(Iinfos)
  17392. idetinfoStr = string(Idetinfos)
  17393. if miConfig.Code == "H15049901371" {
  17394. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17395. } else {
  17396. infocode = res.Infcode
  17397. }
  17398. }
  17399. }
  17400. if infocode == 0 {
  17401. his := models.VMHisPatient{
  17402. Name: name,
  17403. Gender: gender,
  17404. Birthday: birthUnix,
  17405. MedicalTreatmentType: medical_care,
  17406. IdType: certificates,
  17407. IdCardNo: id_card,
  17408. BalanceAccountsType: settlementValue,
  17409. SocialType: social_type,
  17410. MedicalInsuranceNumber: medical_insurance_card,
  17411. RegisterType: register_type,
  17412. RegisterCost: registration_fee,
  17413. TreatmentCost: medical_expenses,
  17414. Status: 1,
  17415. Ctime: time.Now().Unix(),
  17416. Mtime: time.Now().Unix(),
  17417. PsnNo: PsnNo,
  17418. PsnCertType: PsnCertType,
  17419. Certno: Certno,
  17420. PsnName: PsnName,
  17421. Gend: Gend,
  17422. Naty: Naty,
  17423. Brdy: Brdy,
  17424. Age: Age,
  17425. Iinfo: infoStr,
  17426. Idetinfo: idetinfoStr,
  17427. PatientId: patient.ID,
  17428. RecordDate: theTime.Unix(),
  17429. UserOrgId: adminInfo.CurrentOrgId,
  17430. AdminUserId: admin_user_id,
  17431. IsReturn: 1,
  17432. IdCardType: id_card_type,
  17433. Doctor: doctor,
  17434. Departments: department,
  17435. MdtrtGrpType: mdtrt_type,
  17436. }
  17437. timestamp := time.Now().Unix()
  17438. tempTime := time.Unix(timestamp, 0)
  17439. timeFormat := tempTime.Format("20060102150405")
  17440. chrgBchno := rand.Intn(100000) + 10000
  17441. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17442. his.Number = ipt_otp_no
  17443. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17444. department, _ := service.GetDepartMentDetail(department)
  17445. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17446. IdCardNo := ""
  17447. if id_card_type == 1 {
  17448. // IdCardNo = medical_insurance_card
  17449. IdCardNo = patient.IdCardNo
  17450. } else {
  17451. IdCardNo = patient.IdCardNo
  17452. }
  17453. var rf []*ResultFive
  17454. json.Unmarshal([]byte(his.Iinfo), &rf)
  17455. var insutypes []*ResultFive
  17456. var insutype string
  17457. var insuplc_admdvs_temp string
  17458. var is390 int = 0
  17459. var is310 int = 0
  17460. for _, item := range rf {
  17461. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17462. insutypes = append(insutypes, item)
  17463. }
  17464. }
  17465. if len(insutypes) == 1 {
  17466. insutype = insutypes[0].Insutype
  17467. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17468. if insutype == "390" {
  17469. is390 = 1
  17470. }
  17471. if insutype == "310" {
  17472. is310 = 1
  17473. }
  17474. } else {
  17475. for _, i := range insutypes {
  17476. if i.Insutype == "390" {
  17477. is390 = 1
  17478. }
  17479. if i.Insutype == "310" {
  17480. is310 = 1
  17481. }
  17482. }
  17483. }
  17484. if is390 == 1 {
  17485. insutype = "390"
  17486. }
  17487. if is310 == 1 {
  17488. insutype = "310"
  17489. }
  17490. fmt.Println(social_type)
  17491. if social_type > 0 {
  17492. insutype = strconv.FormatInt(social_type, 10)
  17493. }
  17494. var infocode int64
  17495. var resThree ResultThree
  17496. var resThree10265 ResultThree10265
  17497. if len(insuplc_admdvs) == 0 {
  17498. psn_info, _ := service.GetPsnByPatientId(id)
  17499. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17500. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17501. //}
  17502. } else {
  17503. insuplc_admdvs_temp = insuplc_admdvs
  17504. }
  17505. if miConfig.MdtrtareaAdmvs == "421300" {
  17506. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17507. psn_info, _ := service.GetPsnByPatientId(id)
  17508. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17509. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17510. "&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
  17511. resp, requestErr := http.Get(api)
  17512. if requestErr != nil {
  17513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17514. return
  17515. }
  17516. body, ioErr := ioutil.ReadAll(resp.Body)
  17517. if ioErr != nil {
  17518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17520. return
  17521. }
  17522. var respJSON map[string]interface{}
  17523. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17526. return
  17527. }
  17528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17529. result, _ := json.Marshal(respJSON)
  17530. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17531. utils.ErrorLog("解析失败:%v", err)
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. infocode = resThree.Infcode
  17536. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17537. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17538. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17539. // insuplc_admdvs_temp =
  17540. //}
  17541. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17542. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17543. //}
  17544. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17545. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17546. "&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
  17547. resp, requestErr := http.Get(api)
  17548. if requestErr != nil {
  17549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17550. return
  17551. }
  17552. body, ioErr := ioutil.ReadAll(resp.Body)
  17553. if ioErr != nil {
  17554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17556. return
  17557. }
  17558. var respJSON map[string]interface{}
  17559. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17562. return
  17563. }
  17564. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17565. result, _ := json.Marshal(respJSON)
  17566. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17567. utils.ErrorLog("解析失败:%v", err)
  17568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17569. return
  17570. }
  17571. infocode = resThree.Infcode
  17572. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17573. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17574. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17575. // insuplc_admdvs_temp =
  17576. //}
  17577. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17578. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17579. //}
  17580. utils.ErrorLog("解析失败:%v", insutype)
  17581. utils.ErrorLog("解析失败:%v", PsnNo)
  17582. utils.ErrorLog("解析失败:%v", Certno)
  17583. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17584. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17585. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17586. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17587. utils.ErrorLog("解析失败:%v", PsnNo)
  17588. utils.ErrorLog("解析失败:%v", department.Number )
  17589. utils.ErrorLog("解析失败:%v", department.Name )
  17590. utils.ErrorLog("解析失败:%v", roles.UserName)
  17591. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17592. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17593. "&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
  17594. resp, requestErr := http.Get(api)
  17595. if requestErr != nil {
  17596. utils.ErrorLog("解析失败:%v", requestErr)
  17597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17598. return
  17599. }
  17600. body, ioErr := ioutil.ReadAll(resp.Body)
  17601. if ioErr != nil {
  17602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17604. return
  17605. }
  17606. var respJSON map[string]interface{}
  17607. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17610. return
  17611. }
  17612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17613. result, _ := json.Marshal(respJSON)
  17614. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17615. utils.ErrorLog("解析失败:%v", err)
  17616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17617. return
  17618. }
  17619. infocode = resThree.Infcode
  17620. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17621. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17622. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17623. // insuplc_admdvs_temp =
  17624. //}
  17625. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17626. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17627. //}
  17628. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17629. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17630. "&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
  17631. resp, requestErr := http.Get(api)
  17632. if requestErr != nil {
  17633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17634. return
  17635. }
  17636. body, ioErr := ioutil.ReadAll(resp.Body)
  17637. if ioErr != nil {
  17638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17640. return
  17641. }
  17642. var respJSON map[string]interface{}
  17643. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17646. return
  17647. }
  17648. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17649. result, _ := json.Marshal(respJSON)
  17650. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17651. utils.ErrorLog("解析失败:%v", err)
  17652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17653. return
  17654. }
  17655. infocode = resThree.Infcode
  17656. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17657. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17658. psn_info, _ := service.GetPsnByPatientId(id)
  17659. var verify_number string
  17660. if id_card_type == 4 {
  17661. verify_number = psn_info.VerifyNumber
  17662. } else if id_card_type == 1 {
  17663. bas := strings.Split(psn_info.CardInfo, "|")
  17664. cardNumber := bas[2]
  17665. verify_number = cardNumber
  17666. }
  17667. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17668. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17669. "&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
  17670. resp, requestErr := http.Get(api)
  17671. if requestErr != nil {
  17672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17673. return
  17674. }
  17675. body, ioErr := ioutil.ReadAll(resp.Body)
  17676. if ioErr != nil {
  17677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17679. return
  17680. }
  17681. var respJSON map[string]interface{}
  17682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17685. return
  17686. }
  17687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17688. result, _ := json.Marshal(respJSON)
  17689. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17690. // utils.ErrorLog("解析失败:%v", err)
  17691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17692. // return
  17693. //}
  17694. //infocode = resThree.Infcode
  17695. //result, _ := json.Marshal(respJSON)
  17696. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17697. utils.ErrorLog("解析失败:%v", err)
  17698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17699. return
  17700. }
  17701. resThree.ErrMsg = resThree10265.ErrMsg
  17702. resThree.Output = resThree10265.Output
  17703. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17704. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17705. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17706. psn_info, _ := service.GetPsnByPatientId(id)
  17707. his.PsnNo = psn_info.PsnNo
  17708. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17709. var cert_no string
  17710. if id_card_type == 3 {
  17711. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17712. cert_no = IdCardNo
  17713. } else if id_card_type == 4 {
  17714. cert_no = IdCardNo
  17715. psn_info.VerifyNumber = psn_info.VerifyNumber
  17716. } else {
  17717. bas := strings.Split(psn_info.CardInfo, "|")
  17718. cert_no = bas[2]
  17719. }
  17720. var hisPrescription []*models.HisPrescription
  17721. for _, item := range rf {
  17722. if item.Insutype == insutype {
  17723. //insuplc_admdvs = item.InsuplcAdmdvs
  17724. his.InsuplcAdmdvs = insuplc_admdvs
  17725. }
  17726. }
  17727. his.Insutype = insutype
  17728. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17729. fmt.Println(res3101)
  17730. fmt.Println(res3101.Infcode)
  17731. if res3101.Infcode == "0" {
  17732. fmt.Println("33333333")
  17733. if len(res3101.Output.Result) > 0 {
  17734. fmt.Println("222222")
  17735. for _, item := range res3101.Output.Result {
  17736. if len(res3101.ErrMsg) == 0 {
  17737. res3101.ErrMsg = item.VolaCont
  17738. } else {
  17739. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17740. }
  17741. }
  17742. c.ServeSuccessJSON(map[string]interface{}{
  17743. "failed_code": -10,
  17744. "msg": res3101.ErrMsg,
  17745. })
  17746. return
  17747. } else {
  17748. fmt.Println("11111")
  17749. var api string
  17750. if miConfig.MdtrtareaAdmvs == "320921" {
  17751. ipt_otp_no = timeFormat
  17752. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17753. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17754. "&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
  17755. } else {
  17756. ipt_otp_no = timeFormat
  17757. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17758. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17759. "&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
  17760. }
  17761. resp, requestErr := http.Get(api)
  17762. if requestErr != nil {
  17763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17764. return
  17765. }
  17766. body, ioErr := ioutil.ReadAll(resp.Body)
  17767. if ioErr != nil {
  17768. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17770. return
  17771. }
  17772. var respJSON map[string]interface{}
  17773. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17774. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17776. return
  17777. }
  17778. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17779. result, _ := json.Marshal(respJSON)
  17780. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17781. utils.ErrorLog("解析失败:%v", err)
  17782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17783. return
  17784. }
  17785. resThree.ErrMsg = resThree10265.ErrMsg
  17786. resThree.Output = resThree10265.Output
  17787. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17788. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17789. }
  17790. } else if res3101.Infcode != "0" {
  17791. c.ServeSuccessJSON(map[string]interface{}{
  17792. "failed_code": -10,
  17793. "msg": res3101.ErrMsg,
  17794. })
  17795. return
  17796. }
  17797. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17798. psn_info, _ := service.GetPsnByPatientId(id)
  17799. var cert_no string
  17800. if id_card_type == 1 {
  17801. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17802. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17803. } else if id_card_type == 4 {
  17804. cert_no = psn_info.VerifyNumber
  17805. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17806. } else {
  17807. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17808. cert_no = psn_info.VerifyNumber
  17809. }
  17810. 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)
  17811. saveLog(result, requestLog, "2201", "挂号")
  17812. if miConfig.Code == "H15049901371" {
  17813. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17814. utils.ErrorLog("解析失败:%v", err)
  17815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17816. return
  17817. }
  17818. resThree.ErrMsg = resThree10265.ErrMsg
  17819. resThree.Output = resThree10265.Output
  17820. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17821. } else {
  17822. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17823. utils.ErrorLog("解析失败:%v", err)
  17824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17825. return
  17826. }
  17827. }
  17828. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17829. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17830. psn_info, _ := service.GetPsnByPatientId(id)
  17831. var result string
  17832. var requestLog string
  17833. if id_card_type == 1 {
  17834. bas := strings.Split(psn_info.CardInfo, "|")
  17835. basNumber := bas[2]
  17836. card_sn := bas[3]
  17837. 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)
  17838. saveLog(result, requestLog, "2201A", "挂号")
  17839. } else if id_card_type == 2 {
  17840. 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, "", "", "", "", "", "")
  17841. saveLog(result, requestLog, "2201A", "挂号")
  17842. } else {
  17843. 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)
  17844. saveLog(result, requestLog, "2201A", "挂号")
  17845. }
  17846. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17847. utils.ErrorLog("解析失败:%v", err)
  17848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17849. return
  17850. }
  17851. infocode = resThree.Infcode
  17852. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17853. psn_info, _ := service.GetPsnByPatientId(id)
  17854. his.PsnNo = psn_info.PsnNo
  17855. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17856. var cert_no string
  17857. if id_card_type == 1 {
  17858. bas := strings.Split(psn_info.CardInfo, "|")
  17859. cert_no = bas[2]
  17860. } else if id_card_type == 4 {
  17861. cert_no = IdCardNo
  17862. psn_info.VerifyNumber = psn_info.VerifyNumber
  17863. } else {
  17864. cert_no = IdCardNo
  17865. psn_info.VerifyNumber = cert_no
  17866. }
  17867. for _, item := range rf {
  17868. if item.Insutype == insutype {
  17869. his.InsuplcAdmdvs = insuplc_admdvs
  17870. }
  17871. }
  17872. his.Insutype = insutype
  17873. var api string
  17874. ipt_otp_no = timeFormat
  17875. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17876. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17877. "&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
  17878. resp, requestErr := http.Get(api)
  17879. if requestErr != nil {
  17880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17881. return
  17882. }
  17883. body, ioErr := ioutil.ReadAll(resp.Body)
  17884. if ioErr != nil {
  17885. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17887. return
  17888. }
  17889. var respJSON map[string]interface{}
  17890. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17891. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17893. return
  17894. }
  17895. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17896. if status == "0" {
  17897. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17898. c.ServeSuccessJSON(map[string]interface{}{
  17899. "failed_code": -10,
  17900. "msg": err_msg,
  17901. })
  17902. return
  17903. }
  17904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17905. result, _ := json.Marshal(respJSON)
  17906. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17907. utils.ErrorLog("解析失败:%v", err)
  17908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17909. return
  17910. }
  17911. infocode = resThree.Infcode
  17912. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17913. psn_info, _ := service.GetPsnByPatientId(id)
  17914. var result string
  17915. var requestLog string
  17916. if id_card_type == 1 {
  17917. bas := strings.Split(psn_info.CardInfo, "|")
  17918. basNumber := bas[2]
  17919. card_sn := bas[3]
  17920. 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)
  17921. saveLog(result, requestLog, "2201A", "挂号")
  17922. } else if id_card_type == 2 {
  17923. 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, "", "")
  17924. saveLog(result, requestLog, "2201A", "挂号")
  17925. } else {
  17926. 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, "", "")
  17927. saveLog(result, requestLog, "2201A", "挂号")
  17928. }
  17929. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17930. utils.ErrorLog("解析失败:%v", err)
  17931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17932. return
  17933. }
  17934. infocode = resThree.Infcode
  17935. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17936. psn_info, _ := service.GetPsnByPatientId(id)
  17937. 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)
  17938. saveLog(result, requestLog, "2201A", "挂号")
  17939. if miConfig.Code == "H15049901371" {
  17940. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17941. utils.ErrorLog("解析失败:%v", err)
  17942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17943. return
  17944. }
  17945. resThree.ErrMsg = resThree10265.ErrMsg
  17946. resThree.Output = resThree10265.Output
  17947. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17948. } else {
  17949. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17950. utils.ErrorLog("解析失败:%v", err)
  17951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17952. return
  17953. }
  17954. }
  17955. if miConfig.Code == "H15049901371" {
  17956. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17957. } else {
  17958. infocode = resThree.Infcode
  17959. }
  17960. } else {
  17961. psn_info, _ := service.GetPsnByPatientId(id)
  17962. if id_card_type == 4 || id_card_type == 1 {
  17963. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17964. }
  17965. var rf []*ResultFive
  17966. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17967. var insutypes []*ResultFive
  17968. var insutype string
  17969. var is390 int = 0
  17970. var is310 int = 0
  17971. for _, item := range rf {
  17972. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17973. insutypes = append(insutypes, item)
  17974. }
  17975. }
  17976. if len(insutypes) == 1 {
  17977. insutype = insutypes[0].Insutype
  17978. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17979. } else {
  17980. for _, i := range insutypes {
  17981. if i.Insutype == "390" {
  17982. is390 = 1
  17983. }
  17984. if i.Insutype == "310" {
  17985. is310 = 1
  17986. }
  17987. }
  17988. }
  17989. if is390 == 1 {
  17990. insutype = "390"
  17991. }
  17992. if is310 == 1 {
  17993. insutype = "310"
  17994. }
  17995. fmt.Println(len(insutypes))
  17996. if len(insutypes) == 0 {
  17997. for index, item := range rf {
  17998. if index == 0 {
  17999. insutype = item.Insutype
  18000. insuplc_admdvs = item.InsuplcAdmdvs
  18001. }
  18002. }
  18003. fmt.Println(insutype)
  18004. fmt.Println(insuplc_admdvs)
  18005. }
  18006. if social_type > 0 {
  18007. insutype = strconv.FormatInt(social_type, 10)
  18008. }
  18009. fmt.Println("--------")
  18010. fmt.Println(psn_info)
  18011. fmt.Println(psn_info.PsnNo)
  18012. if miConfig.MdtrtareaAdmvs == "441202" {
  18013. var hisPrescription []*models.HisPrescription
  18014. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18015. if res3101.Infcode == 0 {
  18016. fmt.Println("33333333")
  18017. if len(res3101.Output.Result) > 0 {
  18018. fmt.Println("222222")
  18019. for _, item := range res3101.Output.Result {
  18020. if len(res3101.ErrMsg) == 0 {
  18021. res3101.ErrMsg = item.VolaCont
  18022. } else {
  18023. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18024. }
  18025. }
  18026. c.ServeSuccessJSON(map[string]interface{}{
  18027. "failed_code": -10,
  18028. "msg": res3101.ErrMsg,
  18029. })
  18030. return
  18031. } else {
  18032. hour := time.Now().Format("15")
  18033. min := time.Now().Format("04")
  18034. sec := time.Now().Format("05")
  18035. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18036. fmt.Println(record_time_two)
  18037. 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)
  18038. saveLog(result, requestLog, "2201A", "挂号")
  18039. if miConfig.Code == "H15049901371" {
  18040. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18041. utils.ErrorLog("解析失败:%v", err)
  18042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18043. return
  18044. }
  18045. resThree.ErrMsg = resThree10265.ErrMsg
  18046. resThree.Output = resThree10265.Output
  18047. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18048. } else {
  18049. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18050. utils.ErrorLog("解析失败:%v", err)
  18051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18052. return
  18053. }
  18054. }
  18055. if miConfig.Code == "H15049901371" {
  18056. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18057. } else {
  18058. infocode = resThree.Infcode
  18059. }
  18060. }
  18061. } else if res3101.Infcode != 0 {
  18062. c.ServeSuccessJSON(map[string]interface{}{
  18063. "failed_code": -10,
  18064. "msg": res3101.ErrMsg,
  18065. })
  18066. return
  18067. }
  18068. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18069. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18070. psn_info, _ := service.GetPsnByPatientId(id)
  18071. var verify_number string
  18072. if id_card_type == 4 {
  18073. verify_number = psn_info.VerifyNumber
  18074. } else if id_card_type == 1 {
  18075. bas := strings.Split(psn_info.CardInfo, "|")
  18076. cardNumber := bas[2]
  18077. verify_number = cardNumber
  18078. } else {
  18079. verify_number = psn_info.Certno
  18080. }
  18081. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18082. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18083. "&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
  18084. resp, requestErr := http.Get(api)
  18085. if requestErr != nil {
  18086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18087. return
  18088. }
  18089. body, ioErr := ioutil.ReadAll(resp.Body)
  18090. if ioErr != nil {
  18091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18093. return
  18094. }
  18095. var respJSON map[string]interface{}
  18096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18099. return
  18100. }
  18101. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18102. result, _ := json.Marshal(respJSON)
  18103. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18104. utils.ErrorLog("解析失败:%v", err)
  18105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18106. return
  18107. }
  18108. infocode = resThree.Infcode
  18109. } else {
  18110. hour := time.Now().Format("15")
  18111. min := time.Now().Format("04")
  18112. sec := time.Now().Format("05")
  18113. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18114. if id_card_type == 1 {
  18115. for _, item := range rf {
  18116. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18117. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18118. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18119. } else if strconv.FormatInt(social_type, 10) == "390" {
  18120. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18121. } else {
  18122. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18123. }
  18124. }
  18125. }
  18126. }
  18127. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18128. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18129. }
  18130. if id_card_type == 1 {
  18131. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18132. bas := strings.Split(psn_info.CardInfo, "|")
  18133. basNumber := bas[1]
  18134. IdCardNo = basNumber
  18135. }
  18136. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18137. IdCardNo = psn_info.VerifyNumber
  18138. }
  18139. 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)
  18140. saveLog(result, requestLog, "2201A", "挂号")
  18141. if miConfig.Code == "H15049901371" {
  18142. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18143. utils.ErrorLog("解析失败:%v", err)
  18144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18145. return
  18146. }
  18147. resThree.ErrMsg = resThree10265.ErrMsg
  18148. resThree.Output = resThree10265.Output
  18149. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18150. } else {
  18151. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18152. utils.ErrorLog("解析失败:%v", err)
  18153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18154. return
  18155. }
  18156. }
  18157. if miConfig.Code == "H15049901371" {
  18158. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18159. } else {
  18160. infocode = resThree.Infcode
  18161. }
  18162. }
  18163. }
  18164. if infocode != 0 {
  18165. adminUser := c.GetAdminUserInfo()
  18166. errlog := &models.HisOrderError{
  18167. UserOrgId: adminUser.CurrentOrgId,
  18168. Ctime: time.Now().Unix(),
  18169. Mtime: time.Now().Unix(),
  18170. ErrMsg: resThree.ErrMsg,
  18171. Status: 1,
  18172. PatientId: id,
  18173. RecordTime: recordDateTime,
  18174. Stage: 2,
  18175. }
  18176. service.CreateErrMsgLog(errlog)
  18177. c.ServeSuccessJSON(map[string]interface{}{
  18178. "failed_code": -10,
  18179. "msg": resThree.ErrMsg,
  18180. })
  18181. return
  18182. }
  18183. his.Number = resThree.Output.Data.MdtrtID
  18184. his.PsnNo = resThree.Output.Data.PsnNo
  18185. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18186. his.IdCardNo = patient.IdCardNo
  18187. his.PhoneNumber = patient.Phone
  18188. his.UserOrgId = adminInfo.CurrentOrgId
  18189. his.Insutype = insutype
  18190. his.Ctime = time.Now().Unix()
  18191. his.Mtime = time.Now().Unix()
  18192. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18193. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18194. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18195. }
  18196. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18197. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18198. }
  18199. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18200. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18201. }
  18202. his.Status = 1
  18203. his.MdtrtGrpType = mdtrt_type
  18204. service.UpdateHisPatientStatus(&his)
  18205. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18206. c.ServeSuccessJSON(map[string]interface{}{
  18207. "his_info": his,
  18208. })
  18209. } else {
  18210. adminUser := c.GetAdminUserInfo()
  18211. errlog := &models.HisOrderError{
  18212. UserOrgId: adminUser.CurrentOrgId,
  18213. Ctime: time.Now().Unix(),
  18214. Mtime: time.Now().Unix(),
  18215. ErrMsg: res.ErrMsg,
  18216. Status: 1,
  18217. PatientId: id,
  18218. RecordTime: recordDateTime,
  18219. Stage: 1,
  18220. }
  18221. service.CreateErrMsgLog(errlog)
  18222. c.ServeSuccessJSON(map[string]interface{}{
  18223. "failed_code": -10,
  18224. "msg": res.ErrMsg,
  18225. })
  18226. return
  18227. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18228. }
  18229. }
  18230. }
  18231. func (c *HisApiController) GetUploadInfo() {
  18232. id, _ := c.GetInt64("id")
  18233. record_time := c.GetString("record_time")
  18234. his_patient_id, _ := c.GetInt64("his_patient_id")
  18235. order_id, _ := c.GetInt64("order_id")
  18236. pay_way, _ := c.GetInt64("pay_way")
  18237. pay_ways := c.GetString("pay_ways")
  18238. oth_desc := c.GetString("oth_desc")
  18239. pay_price, _ := c.GetFloat("pay_price")
  18240. pay_card_no := c.GetString("pay_card_no")
  18241. discount_price, _ := c.GetFloat("discount_price")
  18242. preferential_price, _ := c.GetFloat("preferential_price")
  18243. reality_price, _ := c.GetFloat("reality_price")
  18244. found_price, _ := c.GetFloat("found_price")
  18245. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18246. private_price, _ := c.GetFloat("private_price")
  18247. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18248. admin_user_id, _ := c.GetInt64("admin_user_id")
  18249. fapiao_code := c.GetString("fapiao_code")
  18250. fapiao_number := c.GetString("fapiao_number")
  18251. diagnosis_id := c.GetString("diagnosis")
  18252. sick_type, _ := c.GetInt64("sick_type")
  18253. reg_type, _ := c.GetInt64("p_type")
  18254. begin_time := c.GetString("begin_time")
  18255. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18256. cash_pay := c.GetString("cash_pay")
  18257. band_card_pay := c.GetString("band_card_pay")
  18258. wechat_pay := c.GetString("wechat_pay")
  18259. ali_pay := c.GetString("ali_pay")
  18260. jifen_pay := c.GetString("jifen_pay")
  18261. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18262. fmt.Println(acct_used_flag)
  18263. id_str := c.GetString("ids")
  18264. ids_arr := strings.Split(id_str, ",")
  18265. timeLayout := "2006-01-02"
  18266. loc, _ := time.LoadLocation("Local")
  18267. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18268. if err != nil {
  18269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18270. return
  18271. }
  18272. recordDateTime := theTime.Unix()
  18273. adminUser := c.GetAdminUserInfo()
  18274. var tempOrder models.HisOrder
  18275. tempOrder, _ = service.GetHisOrderByID(order_id)
  18276. var prescriptions []*models.HisPrescription
  18277. var start_time int64
  18278. var end_time int64
  18279. //押金模块
  18280. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18281. tmp_decimal := c.GetString("tmp_decimal")
  18282. var decimal float64 //本次使用的押金
  18283. var errmsg error
  18284. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18285. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18286. return
  18287. }
  18288. if len(tmp_decimal) > 0 {
  18289. if tmp_decimal[0] == 45 {
  18290. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18291. return
  18292. }
  18293. }
  18294. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18295. fmt.Println(errs)
  18296. decimal = tt
  18297. //if adminUser.CurrentOrgId == 10106{
  18298. // if len(fapiao_code) == 0{
  18299. // fapiao_code = "144072080589"
  18300. // }
  18301. // if len(fapiao_number) == 0{
  18302. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18303. // if order.ID == 0{
  18304. // fapiao_number = "00001520"
  18305. // }else{
  18306. // //fapiao_code = "00001520"
  18307. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18308. // var zero string
  18309. // if fpNumber >= 1000{
  18310. // zero = "0000" + strconv.Itoa(fpNumber)
  18311. // }else if fpNumber >= 10000{
  18312. // zero = "000" + strconv.Itoa(fpNumber)
  18313. // } else if fpNumber >= 100000{
  18314. // zero = "00" + strconv.Itoa(fpNumber)
  18315. // } else if fpNumber >= 1000000{
  18316. // zero = "0" + strconv.Itoa(fpNumber)
  18317. // }else {
  18318. // zero = strconv.Itoa(fpNumber)
  18319. // }
  18320. // fapiao_number = zero
  18321. // }
  18322. // }
  18323. //}
  18324. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18325. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18326. var patientPrescription models.HisPrescriptionInfo
  18327. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18328. if patientPrescription.ID == 0 {
  18329. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18330. }
  18331. //if patientPrescription.Do
  18332. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18333. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18334. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18335. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18336. var config []*models.HisXtDiagnoseConfig
  18337. for _, item := range diagnosis_ids {
  18338. id, _ := strconv.ParseInt(item, 10, 64)
  18339. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18340. config = append(config, &diagnosisConfig)
  18341. }
  18342. sickConfig, _ := service.FindSickById(sick_type)
  18343. //if tempOrder.ID == 0 {
  18344. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18345. //}
  18346. if tempOrder.ID == 0 {
  18347. var result string
  18348. var requestLog string
  18349. var res2 ResultSix
  18350. var res3 GZResultSix
  18351. var ressix10265 ResultSix10265
  18352. if miConfig.MdtrtareaAdmvs == "421300" {
  18353. data := make(map[string]interface{})
  18354. client := &http.Client{}
  18355. data["psn_no"] = his.PsnNo
  18356. data["mdtrt_id"] = his.Number
  18357. data["opter"] = roles.UserName
  18358. data["org_name"] = miConfig.OrgName
  18359. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18360. data["doctor_id"] = doctor_info.DoctorNumber
  18361. data["doctor_name"] = doctor_info.UserName
  18362. data["department"] = department.Name
  18363. data["fixmedins_code"] = miConfig.Code
  18364. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18365. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18366. data["secret_key"] = miConfig.SecretKey
  18367. data["sick_code"] = sickConfig.CountryCode
  18368. data["sick_name"] = sickConfig.ClassName
  18369. data["dept"] = strconv.FormatInt(department.ID, 10)
  18370. data["config"] = config
  18371. data["begin_time"] = begin_time
  18372. bytesData, _ := json.Marshal(data)
  18373. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18374. resp, _ := client.Do(req)
  18375. defer resp.Body.Close()
  18376. body, ioErr := ioutil.ReadAll(resp.Body)
  18377. if ioErr != nil {
  18378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18380. return
  18381. }
  18382. var respJSON map[string]interface{}
  18383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18386. return
  18387. }
  18388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18389. userJSONBytes, _ := json.Marshal(respJSON)
  18390. fmt.Println("log")
  18391. fmt.Println(string(userJSONBytes))
  18392. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18393. utils.ErrorLog("解析失败:%v", err)
  18394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18395. return
  18396. }
  18397. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18398. data := make(map[string]interface{})
  18399. client := &http.Client{}
  18400. data["psn_no"] = his.PsnNo
  18401. data["mdtrt_id"] = his.Number
  18402. data["opter"] = roles.UserName
  18403. data["org_name"] = miConfig.OrgName
  18404. if reg_type == 11 && his.Insutype == "390" {
  18405. data["med_type"] = "110104"
  18406. } else {
  18407. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18408. }
  18409. data["doctor_id"] = doctor_info.DoctorNumber
  18410. data["doctor_name"] = doctor_info.UserName
  18411. data["department"] = department.Name
  18412. data["fixmedins_code"] = miConfig.Code
  18413. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18414. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18415. data["secret_key"] = miConfig.SecretKey
  18416. data["sick_code"] = sickConfig.CountryCode
  18417. data["sick_name"] = sickConfig.ClassName
  18418. data["dept"] = strconv.FormatInt(department.ID, 10)
  18419. data["config"] = config
  18420. data["begin_time"] = begin_time
  18421. bytesData, _ := json.Marshal(data)
  18422. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18423. resp, _ := client.Do(req)
  18424. defer resp.Body.Close()
  18425. body, ioErr := ioutil.ReadAll(resp.Body)
  18426. if ioErr != nil {
  18427. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18429. return
  18430. }
  18431. var respJSON map[string]interface{}
  18432. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18433. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18435. return
  18436. }
  18437. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18438. userJSONBytes, _ := json.Marshal(respJSON)
  18439. fmt.Println("log")
  18440. fmt.Println(string(userJSONBytes))
  18441. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18442. utils.ErrorLog("解析失败:%v", err)
  18443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18444. return
  18445. }
  18446. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18447. data := make(map[string]interface{})
  18448. client := &http.Client{}
  18449. data["psn_no"] = his.PsnNo
  18450. data["mdtrt_id"] = his.Number
  18451. data["opter"] = roles.UserName
  18452. data["org_name"] = miConfig.OrgName
  18453. if reg_type == 11 && his.Insutype == "390" {
  18454. data["med_type"] = "110104"
  18455. } else {
  18456. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18457. }
  18458. data["doctor_id"] = doctor_info.DoctorNumber
  18459. data["doctor_name"] = doctor_info.UserName
  18460. data["department"] = department.Name
  18461. data["fixmedins_code"] = miConfig.Code
  18462. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18463. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18464. data["secret_key"] = miConfig.SecretKey
  18465. data["sick_code"] = sickConfig.CountryCode
  18466. data["sick_name"] = sickConfig.ClassName
  18467. data["dept"] = strconv.FormatInt(department.ID, 10)
  18468. data["config"] = config
  18469. data["begin_time"] = begin_time
  18470. bytesData, _ := json.Marshal(data)
  18471. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18472. resp, _ := client.Do(req)
  18473. defer resp.Body.Close()
  18474. body, ioErr := ioutil.ReadAll(resp.Body)
  18475. if ioErr != nil {
  18476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18478. return
  18479. }
  18480. var respJSON map[string]interface{}
  18481. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18484. return
  18485. }
  18486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18487. userJSONBytes, _ := json.Marshal(respJSON)
  18488. fmt.Println("log")
  18489. fmt.Println(string(userJSONBytes))
  18490. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18491. utils.ErrorLog("解析失败:%v", err)
  18492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18493. return
  18494. }
  18495. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18496. data := make(map[string]interface{})
  18497. client := &http.Client{}
  18498. data["psn_no"] = his.PsnNo
  18499. data["mdtrt_id"] = his.Number
  18500. data["opter"] = roles.UserName
  18501. data["org_name"] = miConfig.OrgName
  18502. if reg_type == 11 && his.Insutype == "390" {
  18503. data["med_type"] = "110104"
  18504. } else {
  18505. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18506. }
  18507. data["doctor_id"] = doctor_info.DoctorNumber
  18508. data["doctor_name"] = doctor_info.UserName
  18509. data["department"] = department.Name
  18510. data["fixmedins_code"] = miConfig.Code
  18511. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18512. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18513. data["secret_key"] = miConfig.SecretKey
  18514. data["sick_code"] = sickConfig.CountryCode
  18515. data["sick_name"] = sickConfig.ClassName
  18516. data["dept"] = strconv.FormatInt(department.ID, 10)
  18517. data["config"] = config
  18518. data["begin_time"] = begin_time
  18519. bytesData, _ := json.Marshal(data)
  18520. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18521. resp, _ := client.Do(req)
  18522. defer resp.Body.Close()
  18523. body, ioErr := ioutil.ReadAll(resp.Body)
  18524. if ioErr != nil {
  18525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18527. return
  18528. }
  18529. var respJSON map[string]interface{}
  18530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18533. return
  18534. }
  18535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18536. userJSONBytes, _ := json.Marshal(respJSON)
  18537. fmt.Println("log")
  18538. fmt.Println(string(userJSONBytes))
  18539. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18540. utils.ErrorLog("解析失败:%v", err)
  18541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18542. return
  18543. }
  18544. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18545. data := make(map[string]interface{})
  18546. client := &http.Client{}
  18547. data["psn_no"] = his.PsnNo
  18548. data["mdtrt_id"] = his.Number
  18549. data["doctor"] = roles.UserName
  18550. data["department"] = department.Name
  18551. data["org_name"] = miConfig.OrgName
  18552. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18553. data["doctor_id"] = doctor_info.DoctorNumber
  18554. data["new_doctor_name"] = doctor_info.UserName
  18555. data["fixmedins_code"] = miConfig.Code
  18556. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18557. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18558. data["secret_key"] = miConfig.SecretKey
  18559. data["sick_code"] = sickConfig.CountryCode
  18560. data["sick_name"] = sickConfig.ClassName
  18561. data["url"] = miConfig.Url
  18562. data["ak"] = miConfig.AccessKey
  18563. data["begin_time"] = begin_time
  18564. data["cainfo"] = miConfig.Cainfo
  18565. data["dept"] = strconv.FormatInt(department.ID, 10)
  18566. data["config"] = config
  18567. bytesData, _ := json.Marshal(data)
  18568. var req *http.Request
  18569. if miConfig.MdtrtareaAdmvs == "320921" {
  18570. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18571. //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 +
  18572. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18573. } else {
  18574. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18575. }
  18576. resp, _ := client.Do(req)
  18577. defer resp.Body.Close()
  18578. body, ioErr := ioutil.ReadAll(resp.Body)
  18579. if ioErr != nil {
  18580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18582. return
  18583. }
  18584. var respJSON map[string]interface{}
  18585. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18588. return
  18589. }
  18590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18591. userJSONBytes, _ := json.Marshal(respJSON)
  18592. fmt.Println("log")
  18593. fmt.Println(string(userJSONBytes))
  18594. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18595. utils.ErrorLog("解析失败:%v", err)
  18596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18597. return
  18598. }
  18599. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18600. res2.Output = ressix10265.Output
  18601. res2.ErrMsg = ressix10265.ErrMsg
  18602. res2.Cainfo = ressix10265.Cainfo
  18603. res2.WarnMsg = ressix10265.WarnMsg
  18604. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18605. res2.Infcode = infocode
  18606. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18607. data := make(map[string]interface{})
  18608. client := &http.Client{}
  18609. data["psn_no"] = his.PsnNo
  18610. data["mdtrt_id"] = his.Number
  18611. data["doctor"] = roles.UserName
  18612. data["department"] = department.Name
  18613. data["org_name"] = miConfig.OrgName
  18614. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18615. data["doctor_id"] = doctor_info.DoctorNumber
  18616. data["new_doctor_name"] = doctor_info.UserName
  18617. data["fixmedins_code"] = miConfig.Code
  18618. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18619. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18620. data["secret_key"] = miConfig.SecretKey
  18621. data["sick_code"] = sickConfig.CountryCode
  18622. data["sick_name"] = sickConfig.ClassName
  18623. data["url"] = miConfig.Url
  18624. data["ak"] = miConfig.AccessKey
  18625. data["begin_time"] = begin_time
  18626. data["cainfo"] = miConfig.Cainfo
  18627. data["dept"] = strconv.FormatInt(department.ID, 10)
  18628. data["config"] = config
  18629. bytesData, _ := json.Marshal(data)
  18630. var req *http.Request
  18631. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18632. resp, _ := client.Do(req)
  18633. defer resp.Body.Close()
  18634. body, ioErr := ioutil.ReadAll(resp.Body)
  18635. if ioErr != nil {
  18636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18638. return
  18639. }
  18640. var respJSON map[string]interface{}
  18641. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18644. return
  18645. }
  18646. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18647. userJSONBytes, _ := json.Marshal(respJSON)
  18648. fmt.Println("log")
  18649. fmt.Println(string(userJSONBytes))
  18650. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18651. utils.ErrorLog("解析失败:%v", err)
  18652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18653. return
  18654. }
  18655. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18656. res2.Output = ressix10265.Output
  18657. res2.ErrMsg = ressix10265.ErrMsg
  18658. res2.Cainfo = ressix10265.Cainfo
  18659. res2.WarnMsg = ressix10265.WarnMsg
  18660. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18661. res2.Infcode = infocode
  18662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18663. 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)
  18664. saveLog(result, requestLog, "2203", "上传就诊信息")
  18665. var respJSON2 map[string]interface{}
  18666. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18669. return
  18670. }
  18671. userJSONBytes2, _ := json.Marshal(respJSON2)
  18672. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18673. utils.ErrorLog("解析失败:%v", err)
  18674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18675. return
  18676. }
  18677. 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)
  18678. fmt.Println(result2)
  18679. fmt.Println(src_request)
  18680. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18681. data := make(map[string]interface{})
  18682. client := &http.Client{}
  18683. data["psn_no"] = his.PsnNo
  18684. data["mdtrt_id"] = his.Number
  18685. data["doctor"] = roles.UserName
  18686. data["department"] = department.Name
  18687. data["org_name"] = miConfig.OrgName
  18688. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18689. data["doctor_id"] = doctor_info.DoctorNumber
  18690. data["new_doctor_name"] = doctor_info.UserName
  18691. data["fixmedins_code"] = miConfig.Code
  18692. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18693. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18694. data["secret_key"] = miConfig.SecretKey
  18695. data["sick_code"] = sickConfig.CountryCode
  18696. data["sick_name"] = sickConfig.ClassName
  18697. data["url"] = miConfig.Url
  18698. data["ak"] = miConfig.AccessKey
  18699. data["begin_time"] = begin_time
  18700. data["cainfo"] = miConfig.Cainfo
  18701. data["dept"] = strconv.FormatInt(department.ID, 10)
  18702. data["config"] = config
  18703. bytesData, _ := json.Marshal(data)
  18704. var req *http.Request
  18705. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18706. resp, _ := client.Do(req)
  18707. defer resp.Body.Close()
  18708. body, ioErr := ioutil.ReadAll(resp.Body)
  18709. if ioErr != nil {
  18710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18712. return
  18713. }
  18714. var respJSON map[string]interface{}
  18715. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18718. return
  18719. }
  18720. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18721. userJSONBytes, _ := json.Marshal(respJSON)
  18722. fmt.Println("log")
  18723. fmt.Println(string(userJSONBytes))
  18724. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18725. utils.ErrorLog("解析失败:%v", err)
  18726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18727. return
  18728. }
  18729. } else {
  18730. if miConfig.MdtrtareaAdmvs == "440781" { //
  18731. 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)
  18732. } else {
  18733. if miConfig.Code == "H15049901371" {
  18734. //赤峰地区国家医保医疗类别
  18735. //职工透析:医疗类别选特殊情况门诊990502
  18736. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18737. var med_type string
  18738. if his.Insutype == "390" {
  18739. if reg_type == 14 {
  18740. med_type = "9933"
  18741. } else if reg_type == 11 {
  18742. med_type = "11"
  18743. }
  18744. } else if his.Insutype == "310" {
  18745. if reg_type == 14 {
  18746. med_type = "990502"
  18747. } else if reg_type == 11 {
  18748. med_type = "11"
  18749. }
  18750. }
  18751. 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)
  18752. } else {
  18753. 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)
  18754. }
  18755. }
  18756. saveLog(result, requestLog, "2203", "上传就诊信息")
  18757. var respJSON2 map[string]interface{}
  18758. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18761. return
  18762. }
  18763. userJSONBytes2, _ := json.Marshal(respJSON2)
  18764. if miConfig.Code == "H15049901371" {
  18765. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18766. utils.ErrorLog("解析失败:%v", err)
  18767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18768. return
  18769. }
  18770. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18771. res2.Output = ressix10265.Output
  18772. res2.ErrMsg = ressix10265.ErrMsg
  18773. res2.Cainfo = ressix10265.Cainfo
  18774. res2.WarnMsg = ressix10265.WarnMsg
  18775. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18776. res2.Infcode = infocode
  18777. } else {
  18778. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18779. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18780. utils.ErrorLog("解析失败:%v", err)
  18781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18782. return
  18783. }
  18784. res2.Infcode = res3.Infcode
  18785. } else {
  18786. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18787. utils.ErrorLog("解析失败:%v", err)
  18788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18789. return
  18790. }
  18791. }
  18792. }
  18793. }
  18794. if res2.Infcode != 0 {
  18795. adminUser := c.GetAdminUserInfo()
  18796. errlog := &models.HisOrderError{
  18797. UserOrgId: adminUser.CurrentOrgId,
  18798. Ctime: time.Now().Unix(),
  18799. Mtime: time.Now().Unix(),
  18800. ErrMsg: res2.ErrMsg,
  18801. Status: 1,
  18802. PatientId: id,
  18803. RecordTime: recordDateTime,
  18804. Stage: 3,
  18805. }
  18806. service.CreateErrMsgLog(errlog)
  18807. c.ServeSuccessJSON(map[string]interface{}{
  18808. "failed_code": -10,
  18809. "msg": res2.ErrMsg,
  18810. })
  18811. return
  18812. } else {
  18813. his.Diagnosis = diagnosis_id
  18814. his.SickType = sickConfig.ID
  18815. //var p_type int64
  18816. //if reg_type == 1111 || reg_type == 1112 {
  18817. // p_type = 11
  18818. //
  18819. //}
  18820. his.PType = fmt.Sprintf("%d", reg_type)
  18821. service.UpdateHisPatientThree(&his)
  18822. data := make(map[string]interface{})
  18823. if settle_accounts_type == 1 { //日结
  18824. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18825. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18826. } else {
  18827. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18828. }
  18829. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18830. data["pre"] = prescriptions
  18831. } else { //月结
  18832. start_time_str := c.GetString("start_time")
  18833. end_time_str := c.GetString("end_time")
  18834. timeLayout := "2006-01-02"
  18835. loc, _ := time.LoadLocation("Local")
  18836. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18837. if err != nil {
  18838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18839. return
  18840. }
  18841. recordStartTime := theStartTime.Unix()
  18842. start_time = recordStartTime
  18843. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18844. if err != nil {
  18845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18846. return
  18847. }
  18848. recordEndTime := theEndTime.Unix()
  18849. end_time = recordEndTime
  18850. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18851. data["pre"] = prescriptions
  18852. }
  18853. timestamp := time.Now().Unix()
  18854. tempTime := time.Unix(timestamp, 0)
  18855. timeFormat := tempTime.Format("20060102150405")
  18856. chrgBchno := rand.Intn(100000) + 10000
  18857. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18858. strconv.FormatInt(his.PatientId, 10)
  18859. client := &http.Client{}
  18860. data["psn_no"] = his.PsnNo
  18861. data["mdtrt_id"] = his.Number
  18862. data["chrg_bchno"] = chrg_bchno
  18863. data["org_name"] = miConfig.OrgName
  18864. data["doctor"] = doctor_info.UserName
  18865. data["doctor_id"] = doctor_info.DoctorNumber
  18866. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18867. data["fixmedins_code"] = miConfig.Code
  18868. data["dept_code"] = department.Number
  18869. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18870. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18871. data["secret_key"] = miConfig.SecretKey
  18872. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18873. data["url"] = miConfig.Url
  18874. data["ak"] = miConfig.AccessKey
  18875. data["new_doctor_name"] = patientPrescription.Doctor
  18876. data["diag_code"] = sickConfig.CountryCode
  18877. data["cainfo"] = miConfig.Cainfo
  18878. data["opter"] = roles.UserName
  18879. var ids []int64
  18880. for _, item := range prescriptions {
  18881. ids = append(ids, item.ID)
  18882. }
  18883. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18884. if config.IsOpen == 1 { //对接了医保,走医保流程
  18885. var res ResultFour
  18886. var resFour10265 ResultFour10265
  18887. if miConfig.MdtrtareaAdmvs == "421300" {
  18888. bytesData, _ := json.Marshal(data)
  18889. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18890. resp, _ := client.Do(req)
  18891. defer resp.Body.Close()
  18892. body, ioErr := ioutil.ReadAll(resp.Body)
  18893. if ioErr != nil {
  18894. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18896. return
  18897. }
  18898. var respJSON map[string]interface{}
  18899. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18900. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18902. return
  18903. }
  18904. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18905. userJSONBytes, _ := json.Marshal(respJSON)
  18906. fmt.Println("log")
  18907. fmt.Println(string(userJSONBytes))
  18908. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18909. utils.ErrorLog("解析失败:%v", err)
  18910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18911. return
  18912. }
  18913. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18914. bytesData, _ := json.Marshal(data)
  18915. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18916. resp, _ := client.Do(req)
  18917. defer resp.Body.Close()
  18918. body, ioErr := ioutil.ReadAll(resp.Body)
  18919. if ioErr != nil {
  18920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18922. return
  18923. }
  18924. var respJSON map[string]interface{}
  18925. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18928. return
  18929. }
  18930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18931. userJSONBytes, _ := json.Marshal(respJSON)
  18932. fmt.Println("log")
  18933. fmt.Println(string(userJSONBytes))
  18934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18935. utils.ErrorLog("解析失败:%v", err)
  18936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18937. return
  18938. }
  18939. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18940. bytesData, _ := json.Marshal(data)
  18941. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18942. resp, _ := client.Do(req)
  18943. defer resp.Body.Close()
  18944. body, ioErr := ioutil.ReadAll(resp.Body)
  18945. if ioErr != nil {
  18946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18948. return
  18949. }
  18950. var respJSON map[string]interface{}
  18951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18954. return
  18955. }
  18956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18957. userJSONBytes, _ := json.Marshal(respJSON)
  18958. fmt.Println("log")
  18959. fmt.Println(string(userJSONBytes))
  18960. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18961. utils.ErrorLog("解析失败:%v", err)
  18962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18963. return
  18964. }
  18965. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18966. bytesData, _ := json.Marshal(data)
  18967. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18968. resp, _ := client.Do(req)
  18969. defer resp.Body.Close()
  18970. body, ioErr := ioutil.ReadAll(resp.Body)
  18971. if ioErr != nil {
  18972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18974. return
  18975. }
  18976. var respJSON map[string]interface{}
  18977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18980. return
  18981. }
  18982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18983. userJSONBytes, _ := json.Marshal(respJSON)
  18984. fmt.Println("log")
  18985. fmt.Println(string(userJSONBytes))
  18986. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18987. utils.ErrorLog("解析失败:%v", err)
  18988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18989. return
  18990. }
  18991. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18992. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18993. if result3101.Infcode == "0" {
  18994. if len(result3101.Output.Result) > 0 {
  18995. var errMsgs []string
  18996. for _, item := range result3101.Output.Result {
  18997. errMsgs = append(errMsgs, item.VolaCont)
  18998. }
  18999. c.ServeSuccessJSON(map[string]interface{}{
  19000. "failed_code": -10,
  19001. "msg": errMsgs,
  19002. })
  19003. return
  19004. }
  19005. }
  19006. bytesData, _ := json.Marshal(data)
  19007. var req *http.Request
  19008. if miConfig.MdtrtareaAdmvs == "320921" {
  19009. data["diag_code"] = sickConfig.CountryCode
  19010. fmt.Println(data)
  19011. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19012. } else {
  19013. data["diag_code"] = sickConfig.CountryCode
  19014. fmt.Println(data)
  19015. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19016. }
  19017. resp, _ := client.Do(req)
  19018. defer resp.Body.Close()
  19019. body, ioErr := ioutil.ReadAll(resp.Body)
  19020. if ioErr != nil {
  19021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19023. return
  19024. }
  19025. var respJSON map[string]interface{}
  19026. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19029. return
  19030. }
  19031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19032. userJSONBytes, _ := json.Marshal(respJSON)
  19033. fmt.Println("log")
  19034. fmt.Println(string(userJSONBytes))
  19035. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19036. utils.ErrorLog("解析失败:%v", err)
  19037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19038. return
  19039. }
  19040. res.InfRefmsgid = resFour10265.InfRefmsgid
  19041. res.Output = resFour10265.Output
  19042. res.ErrMsg = resFour10265.ErrMsg
  19043. res.Cainfo = resFour10265.Cainfo
  19044. res.WarnMsg = resFour10265.WarnMsg
  19045. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19046. res.Infcode = infocode
  19047. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19048. var pagesize int = 2
  19049. var start int = 1
  19050. var stop int
  19051. var pagecount int
  19052. var curpage int
  19053. var isSuccess bool = true
  19054. data["doctor_id"] = doctor_info.DoctorNumber
  19055. //总页数,向上取整,注意除之前要先转换类型为float64
  19056. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19057. for curpage = 1; curpage <= pagecount; curpage++ {
  19058. if curpage == 1 {
  19059. start = 1
  19060. } else {
  19061. start = (curpage-1)*pagesize + 1
  19062. }
  19063. stop = curpage * pagesize
  19064. if stop > len(prescriptions) {
  19065. stop = len(prescriptions)
  19066. }
  19067. //var requestLog string
  19068. data["pre"] = prescriptions[start-1 : stop]
  19069. fmt.Println(data["pre"])
  19070. bytesData, _ := json.Marshal(data)
  19071. var req *http.Request
  19072. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19073. resp, _ := client.Do(req)
  19074. defer resp.Body.Close()
  19075. body, ioErr := ioutil.ReadAll(resp.Body)
  19076. if ioErr != nil {
  19077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19079. return
  19080. }
  19081. var respJSON map[string]interface{}
  19082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19085. return
  19086. }
  19087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19088. userJSONBytes, _ := json.Marshal(respJSON)
  19089. fmt.Println("log")
  19090. fmt.Println(string(userJSONBytes))
  19091. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19092. utils.ErrorLog("解析失败:%v", err)
  19093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19094. return
  19095. }
  19096. res.InfRefmsgid = resFour10265.InfRefmsgid
  19097. res.Output = resFour10265.Output
  19098. res.ErrMsg = resFour10265.ErrMsg
  19099. res.Cainfo = resFour10265.Cainfo
  19100. res.WarnMsg = resFour10265.WarnMsg
  19101. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19102. res.Infcode = infocode
  19103. if infocode == 0 {
  19104. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19105. } else {
  19106. isSuccess = false
  19107. errlog := &models.HisOrderError{
  19108. UserOrgId: adminUser.CurrentOrgId,
  19109. Ctime: time.Now().Unix(),
  19110. Mtime: time.Now().Unix(),
  19111. Number: chrg_bchno,
  19112. ErrMsg: "",
  19113. Status: 1,
  19114. PatientId: id,
  19115. RecordTime: recordDateTime,
  19116. Stage: 4,
  19117. }
  19118. service.CreateErrMsgLog(errlog)
  19119. c.ServeSuccessJSON(map[string]interface{}{
  19120. "failed_code": -10,
  19121. "msg": res.ErrMsg,
  19122. })
  19123. return
  19124. }
  19125. }
  19126. if isSuccess {
  19127. res.Infcode = 0
  19128. }
  19129. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19130. 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)
  19131. var dat map[string]interface{}
  19132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19133. fmt.Println(dat)
  19134. } else {
  19135. fmt.Println(err)
  19136. }
  19137. saveLog(result, request_log, "2204", "上传费用明细")
  19138. userJSONBytes, _ := json.Marshal(dat)
  19139. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19140. utils.ErrorLog("解析失败:%v", err)
  19141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19142. return
  19143. }
  19144. res.InfRefmsgid = resFour10265.InfRefmsgid
  19145. res.Output = resFour10265.Output
  19146. res.ErrMsg = resFour10265.ErrMsg
  19147. res.Cainfo = resFour10265.Cainfo
  19148. res.WarnMsg = resFour10265.WarnMsg
  19149. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19150. res.Infcode = infocode
  19151. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19152. bytesData, _ := json.Marshal(data)
  19153. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19154. resp, _ := client.Do(req)
  19155. defer resp.Body.Close()
  19156. body, ioErr := ioutil.ReadAll(resp.Body)
  19157. if ioErr != nil {
  19158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19160. return
  19161. }
  19162. var respJSON map[string]interface{}
  19163. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19166. return
  19167. }
  19168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19169. userJSONBytes, _ := json.Marshal(respJSON)
  19170. fmt.Println("log")
  19171. fmt.Println(string(userJSONBytes))
  19172. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19173. utils.ErrorLog("解析失败:%v", err)
  19174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19175. return
  19176. }
  19177. } else {
  19178. if miConfig.Code == "H15049901371" {
  19179. 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)
  19180. var dat map[string]interface{}
  19181. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19182. fmt.Println(dat)
  19183. } else {
  19184. fmt.Println(err)
  19185. }
  19186. saveLog(result, request_log, "2204", "上传费用明细")
  19187. userJSONBytes, _ := json.Marshal(dat)
  19188. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19189. utils.ErrorLog("解析失败:%v", err)
  19190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19191. return
  19192. }
  19193. res.InfRefmsgid = resFour10265.InfRefmsgid
  19194. res.Output = resFour10265.Output
  19195. res.ErrMsg = resFour10265.ErrMsg
  19196. res.Cainfo = resFour10265.Cainfo
  19197. res.WarnMsg = resFour10265.WarnMsg
  19198. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19199. res.Infcode = infocode
  19200. } else {
  19201. 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)
  19202. var dat map[string]interface{}
  19203. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19204. fmt.Println(dat)
  19205. } else {
  19206. fmt.Println(err)
  19207. }
  19208. saveLog(result, request_log, "2204", "上传费用明细")
  19209. userJSONBytes, _ := json.Marshal(dat)
  19210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19211. utils.ErrorLog("解析失败:%v", err)
  19212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19213. return
  19214. }
  19215. }
  19216. }
  19217. if res.Infcode == 0 {
  19218. order := &models.HisOrder{
  19219. UserOrgId: adminUser.CurrentOrgId,
  19220. HisPatientId: his.ID,
  19221. PatientId: his.PatientId,
  19222. SettleAccountsDate: recordDateTime,
  19223. MdtrtId: his.Number,
  19224. PsnNo: his.PsnNo,
  19225. MedType: strconv.FormatInt(reg_type, 10),
  19226. Ctime: time.Now().Unix(),
  19227. Mtime: time.Now().Unix(),
  19228. Status: 1,
  19229. Number: chrg_bchno,
  19230. Infcode: res.Infcode,
  19231. WarnMsg: res.WarnMsg,
  19232. Cainfo: res.Cainfo,
  19233. ErrMsg: res.ErrMsg,
  19234. RespondTime: res.RefmsgTime,
  19235. InfRefmsgid: res.InfRefmsgid,
  19236. OrderStatus: 1,
  19237. PayWay: pay_way,
  19238. PayWays: pay_ways,
  19239. OthDesc: oth_desc,
  19240. PayPrice: pay_price,
  19241. PayCardNo: pay_card_no,
  19242. DiscountPrice: discount_price,
  19243. PreferentialPrice: preferential_price,
  19244. RealityPrice: reality_price,
  19245. FoundPrice: found_price,
  19246. MedicalInsurancePrice: medical_insurance_price,
  19247. PrivatePrice: private_price,
  19248. IsMedicineInsurance: 1,
  19249. SettleType: settle_accounts_type,
  19250. SettleStartTime: start_time,
  19251. SettleEndTime: end_time,
  19252. Creator: roles.AdminUserId,
  19253. Modify: roles.AdminUserId,
  19254. FaPiaoNumber: fapiao_number,
  19255. FaPiaoCode: fapiao_code,
  19256. PType: 2,
  19257. Diagnosis: diagnosis_id,
  19258. CashPay: cash_pay,
  19259. WechatPay: wechat_pay,
  19260. AliPay: ali_pay,
  19261. JifenPay: jifen_pay,
  19262. BandCardPay: band_card_pay,
  19263. }
  19264. err = service.CreateOrder(order)
  19265. if err != nil {
  19266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19267. return
  19268. }
  19269. for _, item := range res.Output.Result {
  19270. temp := strings.Split(item.FeedetlSn, "-")
  19271. var advice_id int64 = 0
  19272. var project_id int64 = 0
  19273. var types int64 = 0
  19274. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19275. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19276. if temp[1] == "1" {
  19277. advice_id = id
  19278. project_id = 0
  19279. } else if temp[1] == "2" {
  19280. advice_id = 0
  19281. project_id = id
  19282. }
  19283. if item.MedChrgitmType == "9" {
  19284. item.MedChrgitmType = "09"
  19285. }
  19286. info := &models.HisOrderInfo{
  19287. OrderNumber: order.Number,
  19288. FeedetlSn: item.FeedetlSn,
  19289. UploadDate: time.Now().Unix(),
  19290. AdviceId: advice_id,
  19291. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19292. Cnt: item.Cnt,
  19293. Pric: float64(item.Pric),
  19294. PatientId: his.PatientId,
  19295. PricUplmtAmt: item.PricUplmtAmt,
  19296. SelfpayProp: item.SelfpayProp,
  19297. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19298. OverlmtAmt: item.OverlmtAmt,
  19299. PreselfpayAmt: item.PreselfpayAmt,
  19300. BasMednFlag: item.BasMednFlag,
  19301. MedChrgitmType: item.MedChrgitmType,
  19302. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19303. Status: 1,
  19304. Memo: item.Memo,
  19305. Mtime: time.Now().Unix(),
  19306. InscpScpAmt: item.InscpScpAmt,
  19307. DrtReimFlag: item.DrtReimFlag,
  19308. Ctime: time.Now().Unix(),
  19309. ListSpItemFlag: item.ListSpItemFlag,
  19310. ChldMedcFlag: item.ChldMedcFlag,
  19311. LmtUsedFlag: item.LmtUsedFlag,
  19312. ChrgitmLv: item.ChrgitmLv,
  19313. UserOrgId: adminUser.CurrentOrgId,
  19314. HisPatientId: his.ID,
  19315. OrderId: order.ID,
  19316. ProjectId: project_id,
  19317. Type: types,
  19318. }
  19319. service.CreateOrderInfo(info)
  19320. }
  19321. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19322. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19323. var total float64
  19324. for _, item := range prescriptions {
  19325. if item.Type == 1 { //药品
  19326. for _, subItem := range item.HisDoctorAdviceInfo {
  19327. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19328. total_one := price * subItem.PrescribingNumber
  19329. total = total + total_one
  19330. }
  19331. }
  19332. if item.Type == 2 { //项目
  19333. for _, subItem := range item.HisPrescriptionProject {
  19334. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19335. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19336. total_one := price * cnt
  19337. total = total + total_one
  19338. }
  19339. }
  19340. }
  19341. allTotal := fmt.Sprintf("%.2f", total)
  19342. //if adminUser.CurrentOrgId == 9919 {
  19343. //
  19344. // allTotal = fmt.Sprintf("%.2f", total)
  19345. //
  19346. //} else {
  19347. //
  19348. // allTotal = fmt.Sprintf("%.2f", total)
  19349. //
  19350. //}
  19351. if res.Infcode == 0 {
  19352. var rf []*ResultFive
  19353. json.Unmarshal([]byte(his.Iinfo), &rf)
  19354. chrg_bchno := chrg_bchno
  19355. cert_no := his.Certno
  19356. var insutypes []string
  19357. var insutype string
  19358. var is390 int = 0
  19359. var is310 int = 0
  19360. for _, item := range rf {
  19361. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19362. insutypes = append(insutypes, item.Insutype)
  19363. }
  19364. }
  19365. if len(insutypes) == 1 {
  19366. insutype = insutypes[0]
  19367. } else {
  19368. for _, i := range insutypes {
  19369. if i == "390" {
  19370. is390 = 1
  19371. }
  19372. if i == "310" {
  19373. is310 = 1
  19374. }
  19375. }
  19376. }
  19377. if is390 == 1 {
  19378. insutype = "390"
  19379. }
  19380. if is310 == 1 {
  19381. insutype = "310"
  19382. }
  19383. if len(insutypes) == 0 {
  19384. insutype = "310"
  19385. }
  19386. if len(insutypes) == 2 {
  19387. insutype = strconv.FormatInt(his.SocialType, 10)
  19388. }
  19389. insutype = strconv.FormatInt(his.SocialType, 10)
  19390. //insutype = "390"
  19391. if his.IdCardType == 1 {
  19392. // cert_no = his.MedicalInsuranceNumber
  19393. cert_no = his.Certno
  19394. } else {
  19395. cert_no = his.Certno
  19396. }
  19397. var res ResultSeven
  19398. var resSeven10265 ResultSeven10265
  19399. var gzresSeven10265Two GZResultSeven10265Two
  19400. var src_resquest string
  19401. var result2 string
  19402. if miConfig.MdtrtareaAdmvs == "421300" {
  19403. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19404. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19405. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19406. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19407. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19408. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19409. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19410. resp, requestErr := http.Get(api)
  19411. if requestErr != nil {
  19412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19413. return
  19414. }
  19415. body, ioErr := ioutil.ReadAll(resp.Body)
  19416. if ioErr != nil {
  19417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19419. return
  19420. }
  19421. var respJSON map[string]interface{}
  19422. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19425. return
  19426. }
  19427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19428. result, _ := json.Marshal(respJSON)
  19429. if miConfig.Code == "H15049901371" {
  19430. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19431. utils.ErrorLog("解析失败:%v", err)
  19432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19433. return
  19434. }
  19435. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19436. res.Output = resSeven10265.Output
  19437. res.ErrMsg = resSeven10265.ErrMsg
  19438. res.Cainfo = resSeven10265.Cainfo
  19439. res.WarnMsg = resSeven10265.WarnMsg
  19440. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19441. res.Infcode = infocode
  19442. } else {
  19443. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19444. utils.ErrorLog("解析失败:%v", err)
  19445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19446. return
  19447. }
  19448. }
  19449. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19450. if reg_type == 11 && his.Insutype == "390" {
  19451. reg_type = 110104
  19452. }
  19453. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19454. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19455. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19456. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19457. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19458. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19459. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19460. resp, requestErr := http.Get(api)
  19461. if requestErr != nil {
  19462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19463. return
  19464. }
  19465. body, ioErr := ioutil.ReadAll(resp.Body)
  19466. if ioErr != nil {
  19467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19469. return
  19470. }
  19471. var respJSON map[string]interface{}
  19472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19475. return
  19476. }
  19477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19478. result, _ := json.Marshal(respJSON)
  19479. if miConfig.Code == "H15049901371" {
  19480. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19481. utils.ErrorLog("解析失败:%v", err)
  19482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19483. return
  19484. }
  19485. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19486. res.Output = resSeven10265.Output
  19487. res.ErrMsg = resSeven10265.ErrMsg
  19488. res.Cainfo = resSeven10265.Cainfo
  19489. res.WarnMsg = resSeven10265.WarnMsg
  19490. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19491. res.Infcode = infocode
  19492. } else {
  19493. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19494. utils.ErrorLog("解析失败:%v", err)
  19495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19496. return
  19497. }
  19498. }
  19499. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19500. if reg_type == 11 && his.Insutype == "390" {
  19501. reg_type = 110104
  19502. }
  19503. api := miConfig.Url+ "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19504. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19505. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19506. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19507. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19508. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19509. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19510. resp, requestErr := http.Get(api)
  19511. if requestErr != nil {
  19512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19513. return
  19514. }
  19515. body, ioErr := ioutil.ReadAll(resp.Body)
  19516. if ioErr != nil {
  19517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. var respJSON map[string]interface{}
  19522. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19525. return
  19526. }
  19527. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19528. result, _ := json.Marshal(respJSON)
  19529. if miConfig.Code == "H15049901371" {
  19530. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19531. utils.ErrorLog("解析失败:%v", err)
  19532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19533. return
  19534. }
  19535. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19536. res.Output = resSeven10265.Output
  19537. res.ErrMsg = resSeven10265.ErrMsg
  19538. res.Cainfo = resSeven10265.Cainfo
  19539. res.WarnMsg = resSeven10265.WarnMsg
  19540. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19541. res.Infcode = infocode
  19542. } else {
  19543. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19544. utils.ErrorLog("解析失败:%v", err)
  19545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19546. return
  19547. }
  19548. }
  19549. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19550. if reg_type == 11 && his.Insutype == "390" {
  19551. reg_type = 110104
  19552. }
  19553. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19554. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19555. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19557. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19558. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19559. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19560. resp, requestErr := http.Get(api)
  19561. if requestErr != nil {
  19562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19563. return
  19564. }
  19565. body, ioErr := ioutil.ReadAll(resp.Body)
  19566. if ioErr != nil {
  19567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19569. return
  19570. }
  19571. var respJSON map[string]interface{}
  19572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19575. return
  19576. }
  19577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19578. result, _ := json.Marshal(respJSON)
  19579. if miConfig.Code == "H15049901371" {
  19580. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19581. utils.ErrorLog("解析失败:%v", err)
  19582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19583. return
  19584. }
  19585. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19586. res.Output = resSeven10265.Output
  19587. res.ErrMsg = resSeven10265.ErrMsg
  19588. res.Cainfo = resSeven10265.Cainfo
  19589. res.WarnMsg = resSeven10265.WarnMsg
  19590. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19591. res.Infcode = infocode
  19592. } else {
  19593. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19594. utils.ErrorLog("解析失败:%v", err)
  19595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19596. return
  19597. }
  19598. }
  19599. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19600. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19601. if result3101.Infcode == "0" {
  19602. if len(result3101.Output.Result) > 0 {
  19603. var errMsgs []string
  19604. for _, item := range result3101.Output.Result {
  19605. errMsgs = append(errMsgs, item.VolaCont)
  19606. }
  19607. c.ServeSuccessJSON(map[string]interface{}{
  19608. "failed_code": -10,
  19609. "msg": errMsgs,
  19610. })
  19611. return
  19612. } else {
  19613. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19614. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19615. bas := strings.Split(psn_info.CardInfo, "|")
  19616. if his.IdCardType == 1 {
  19617. cert_no = bas[2]
  19618. } else if his.IdCardType == 3 {
  19619. cert_no = his.Certno
  19620. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19621. } else if his.IdCardType == 4 {
  19622. cert_no = his.Certno
  19623. psn_info.VerifyNumber = psn_info.VerifyNumber
  19624. }
  19625. var api string
  19626. if miConfig.MdtrtareaAdmvs == "320921" {
  19627. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19628. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19629. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19631. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19632. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19633. "&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
  19634. } else {
  19635. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19636. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19637. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19638. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19639. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19640. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19641. "&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
  19642. }
  19643. resp, requestErr := http.Get(api)
  19644. if requestErr != nil {
  19645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19646. return
  19647. }
  19648. body, ioErr := ioutil.ReadAll(resp.Body)
  19649. if ioErr != nil {
  19650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19652. return
  19653. }
  19654. var respJSON map[string]interface{}
  19655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19658. return
  19659. }
  19660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19661. result, _ := json.Marshal(respJSON)
  19662. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19663. utils.ErrorLog("解析失败:%v", err)
  19664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19665. return
  19666. }
  19667. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19668. res.Output = resSeven10265.Output
  19669. res.ErrMsg = resSeven10265.ErrMsg
  19670. res.Cainfo = resSeven10265.Cainfo
  19671. res.WarnMsg = resSeven10265.WarnMsg
  19672. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19673. res.Infcode = infocode
  19674. }
  19675. }
  19676. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19677. psn_info, _ := service.GetPsnByPatientId(id)
  19678. var verify_number string
  19679. if psn_info.IdCardType == 4 {
  19680. verify_number = psn_info.VerifyNumber
  19681. } else if psn_info.IdCardType == 1 {
  19682. bas := strings.Split(psn_info.CardInfo, "|")
  19683. cardNumber := bas[2]
  19684. verify_number = cardNumber
  19685. } else {
  19686. psn_info.IdCardType = 2
  19687. verify_number = psn_info.Certno
  19688. }
  19689. var api string
  19690. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19691. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19692. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19693. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19694. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19695. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19696. "&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
  19697. resp, requestErr := http.Get(api)
  19698. if requestErr != nil {
  19699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19700. return
  19701. }
  19702. body, ioErr := ioutil.ReadAll(resp.Body)
  19703. if ioErr != nil {
  19704. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19706. return
  19707. }
  19708. var respJSON map[string]interface{}
  19709. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19712. return
  19713. }
  19714. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19715. result, _ := json.Marshal(respJSON)
  19716. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19717. utils.ErrorLog("解析失败:%v", err)
  19718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19719. return
  19720. }
  19721. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19722. res.Output = resSeven10265.Output
  19723. res.ErrMsg = resSeven10265.ErrMsg
  19724. res.Cainfo = resSeven10265.Cainfo
  19725. res.WarnMsg = resSeven10265.WarnMsg
  19726. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19727. res.Infcode = infocode
  19728. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19729. var cert_no string
  19730. if his.IdCardType == 4 {
  19731. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19732. cert_no = psn_info.VerifyNumber
  19733. 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)
  19734. } else if his.IdCardType == 1 {
  19735. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19736. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19737. 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)
  19738. }
  19739. //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)
  19740. var dat map[string]interface{}
  19741. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19742. fmt.Println(dat)
  19743. } else {
  19744. fmt.Println(err)
  19745. }
  19746. saveLog(result2, src_resquest, "2207", "结算")
  19747. userJSONBytes, _ := json.Marshal(dat)
  19748. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19749. utils.ErrorLog("解析失败:%v", err)
  19750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19751. return
  19752. }
  19753. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19754. res.Output = resSeven10265.Output
  19755. res.ErrMsg = resSeven10265.ErrMsg
  19756. res.Cainfo = resSeven10265.Cainfo
  19757. res.WarnMsg = resSeven10265.WarnMsg
  19758. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19759. res.Infcode = infocode
  19760. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19761. res2 := c.GetoleInfo()
  19762. if res2.Infcode == 0 {
  19763. var result string
  19764. var request_log string
  19765. var result_log string
  19766. if res2.Output.MdtrtCertType == "02" {
  19767. 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)
  19768. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19769. } else if res2.Output.MdtrtCertType == "01" {
  19770. 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)
  19771. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19772. } else {
  19773. 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)
  19774. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19775. }
  19776. var dat map[string]interface{}
  19777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19778. fmt.Println(dat)
  19779. } else {
  19780. fmt.Println(err)
  19781. }
  19782. userJSONBytes, _ := json.Marshal(dat)
  19783. var res5 ResultTwo
  19784. //var resTwo10265 ResultTwo10265
  19785. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19786. utils.ErrorLog("解析失败:%v", err)
  19787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19788. return
  19789. }
  19790. if res5.Infcode == -1 {
  19791. c.ServeSuccessJSON(map[string]interface{}{
  19792. "failed_code": -10,
  19793. "msg": res5.ErrMsg,
  19794. })
  19795. return
  19796. }
  19797. var insutypes []string
  19798. var insutype string
  19799. var is390 int = 0
  19800. var is310 int = 0
  19801. for _, item := range res5.Output.Iinfo {
  19802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19803. insutypes = append(insutypes, item.Insutype)
  19804. }
  19805. }
  19806. if len(insutypes) == 1 {
  19807. insutype = insutypes[0]
  19808. } else {
  19809. for _, i := range insutypes {
  19810. if i == "390" {
  19811. is390 = 1
  19812. }
  19813. if i == "310" {
  19814. is310 = 1
  19815. }
  19816. }
  19817. }
  19818. if is390 == 1 {
  19819. insutype = "390"
  19820. }
  19821. if is310 == 1 {
  19822. insutype = "310"
  19823. }
  19824. if len(insutypes) == 0 {
  19825. insutype = "310"
  19826. }
  19827. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19828. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19829. infoStr := string(Iinfos)
  19830. idetinfoStr := string(Idetinfos)
  19831. psn := &models.HisPsn{
  19832. PsnNo: res5.Output.Baseinfo.PsnNo,
  19833. PatientId: id,
  19834. Certno: res5.Output.Baseinfo.Certno,
  19835. Gend: res5.Output.Baseinfo.Gend,
  19836. Naty: res5.Output.Baseinfo.Naty,
  19837. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19838. PsnName: res5.Output.Baseinfo.PsnName,
  19839. Idetinfo: idetinfoStr,
  19840. Insuinfo: infoStr,
  19841. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19842. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19843. VerifyNumber: res2.Output.EcToken,
  19844. }
  19845. if res2.Output.MdtrtCertType == "01" {
  19846. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19847. psn.VerifyNumber = res2.Output.EcToken
  19848. } else if res2.Output.MdtrtCertType == "02" {
  19849. psn.VerifyNumber = res2.Output.CardNo
  19850. } else {
  19851. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19852. }
  19853. service.CreateHisPsn(psn)
  19854. if res2.Output.MdtrtCertType == "01" {
  19855. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19856. token := res2.Output.EcToken
  19857. 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)
  19858. } else if res2.Output.MdtrtCertType == "02" {
  19859. 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)
  19860. } else {
  19861. 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)
  19862. }
  19863. var dat2 map[string]interface{}
  19864. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19865. fmt.Println(dat2)
  19866. } else {
  19867. fmt.Println(err)
  19868. }
  19869. userJSONBytes3, _ := json.Marshal(dat2)
  19870. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19871. utils.ErrorLog("解析失败:%v", err)
  19872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19873. return
  19874. }
  19875. saveLog(result2, src_resquest, "2207", "结算")
  19876. } else {
  19877. c.ServeSuccessJSON(map[string]interface{}{
  19878. "failed_code": -10,
  19879. "msg": res2.ErrMsg,
  19880. })
  19881. return
  19882. }
  19883. } else {
  19884. if miConfig.Code == "H15049901371" {
  19885. //赤峰地区国家医保医疗类别
  19886. //职工透析:医疗类别选特殊情况门诊990502
  19887. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19888. var med_type string
  19889. if his.Insutype == "390" {
  19890. if reg_type == 14 {
  19891. med_type = "9933"
  19892. } else if reg_type == 11 {
  19893. med_type = "11"
  19894. }
  19895. } else if his.Insutype == "310" {
  19896. if reg_type == 14 {
  19897. med_type = "990502"
  19898. } else if reg_type == 11 {
  19899. med_type = "11"
  19900. }
  19901. }
  19902. 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)
  19903. } else {
  19904. if his.IdCardType == 4 {
  19905. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19906. var token string
  19907. token = psn_info.VerifyNumber
  19908. 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)
  19909. } else {
  19910. if his.IdCardType == 1 {
  19911. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19912. bas := strings.Split(psn_info.CardInfo, "|")
  19913. basNumber := bas[2]
  19914. cert_no = basNumber
  19915. }
  19916. 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)
  19917. }
  19918. }
  19919. //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)
  19920. var dat map[string]interface{}
  19921. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19922. fmt.Println(dat)
  19923. } else {
  19924. fmt.Println(err)
  19925. }
  19926. saveLog(result2, src_resquest, "2207", "结算")
  19927. userJSONBytes, _ := json.Marshal(dat)
  19928. if miConfig.Code == "H15049901371" {
  19929. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19930. utils.ErrorLog("解析失败:%v", err)
  19931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19932. return
  19933. }
  19934. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19935. res.Output = resSeven10265.Output
  19936. res.ErrMsg = resSeven10265.ErrMsg
  19937. res.Cainfo = resSeven10265.Cainfo
  19938. res.WarnMsg = resSeven10265.WarnMsg
  19939. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19940. res.Infcode = infocode
  19941. } else {
  19942. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19943. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19944. utils.ErrorLog("解析失败:%v", err)
  19945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19946. return
  19947. }
  19948. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19949. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19950. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19951. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19952. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19953. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19954. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19955. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19956. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19957. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19958. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19959. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19960. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19961. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19962. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19963. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19964. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19965. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19966. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19967. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19968. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19969. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19970. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19971. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19972. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19973. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19974. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19975. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19976. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19977. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19978. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19979. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19980. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19981. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19982. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19983. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19984. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19985. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19986. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19987. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19988. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19989. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19990. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19991. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19992. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19993. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19994. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19995. res.Cainfo = gzresSeven10265Two.Cainfo
  19996. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19997. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19998. //res.Infcode = infocode
  19999. } else {
  20000. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20001. utils.ErrorLog("解析失败:%v", err)
  20002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20003. return
  20004. }
  20005. }
  20006. }
  20007. }
  20008. if res.Infcode == -1 {
  20009. errlog := &models.HisOrderError{
  20010. UserOrgId: adminUser.CurrentOrgId,
  20011. Ctime: time.Now().Unix(),
  20012. Mtime: time.Now().Unix(),
  20013. Number: chrg_bchno,
  20014. ErrMsg: res.ErrMsg,
  20015. Status: 1,
  20016. PatientId: id,
  20017. RecordTime: recordDateTime,
  20018. Stage: 6,
  20019. }
  20020. service.CreateErrMsgLog(errlog)
  20021. c.ServeSuccessJSON(map[string]interface{}{
  20022. "failed_code": -10,
  20023. "msg": res.ErrMsg,
  20024. })
  20025. return
  20026. } else {
  20027. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20028. order.OrderStatus = 2
  20029. order.Status = 1
  20030. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20031. order.SetlId = res.Output.Setlinfo.SetlID
  20032. order.PsnNo = res.Output.Setlinfo.PsnNo
  20033. order.PsnName = res.Output.Setlinfo.PsnName
  20034. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20035. order.Certno = res.Output.Setlinfo.Certno
  20036. order.Gend = res.Output.Setlinfo.Gend
  20037. order.Naty = res.Output.Setlinfo.Naty
  20038. order.Age = res.Output.Setlinfo.Age
  20039. order.Insutype = res.Output.Setlinfo.Insutype
  20040. order.PsnType = res.Output.Setlinfo.PsnType
  20041. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20042. order.SetlTime = res.Output.Setlinfo.SetlTime
  20043. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20044. if res.Output.Setlinfo.MedType == "140101" {
  20045. order.MedType = "14"
  20046. } else {
  20047. if res.Output.Setlinfo.MedType == "110104" {
  20048. order.MedType = "11"
  20049. } else {
  20050. order.MedType = res.Output.Setlinfo.MedType
  20051. }
  20052. }
  20053. if reg_type == 1112 {
  20054. order.MedType = "1112"
  20055. }
  20056. if reg_type == 1111 {
  20057. order.MedType = "1111"
  20058. }
  20059. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20060. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20061. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20062. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20063. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20064. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20065. order.HifpPay = res.Output.Setlinfo.HifpPay
  20066. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20067. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20068. order.HifesPay = res.Output.Setlinfo.HifesPay
  20069. order.HifobPay = res.Output.Setlinfo.HifobPay
  20070. order.MafPay = res.Output.Setlinfo.MafPay
  20071. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20072. order.OthPay = res.Output.Setlinfo.OthPay
  20073. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20074. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20075. order.AcctPay = res.Output.Setlinfo.AcctPay
  20076. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20077. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20078. order.Balc = res.Output.Setlinfo.Balc
  20079. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20080. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20081. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20082. order.ClrType = res.Output.Setlinfo.ClrType
  20083. order.ClrWay = res.Output.Setlinfo.ClrWay
  20084. order.Creator = order.Creator
  20085. order.Modify = roles.AdminUserId
  20086. order.RequestLog = src_resquest
  20087. order.FaPiaoNumber = fapiao_number
  20088. order.FaPiaoCode = fapiao_code
  20089. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20090. //detailStr := string(setlDetail)
  20091. //order.SetlDetail = detailStr
  20092. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20093. err = service.UpDateOrder(order)
  20094. if err == nil {
  20095. //判断是否使用了押金
  20096. if dec_way == "true" {
  20097. tmpstring := strconv.FormatInt(order.ID, 10)
  20098. order.Decimal = decimal
  20099. service.UpDateOrder(order)
  20100. //扣押金
  20101. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20102. if errmsg != nil {
  20103. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20104. return
  20105. }
  20106. }
  20107. c.ServeSuccessJSON(map[string]interface{}{
  20108. "msg": "结算成功",
  20109. })
  20110. } else {
  20111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20112. return
  20113. }
  20114. }
  20115. } else {
  20116. adminUser := c.GetAdminUserInfo()
  20117. errlog := &models.HisOrderError{
  20118. UserOrgId: adminUser.CurrentOrgId,
  20119. Ctime: time.Now().Unix(),
  20120. Mtime: time.Now().Unix(),
  20121. ErrMsg: res.ErrMsg,
  20122. Status: 1,
  20123. PatientId: id,
  20124. RecordTime: recordDateTime,
  20125. Stage: 4,
  20126. }
  20127. service.CreateErrMsgLog(errlog)
  20128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20129. return
  20130. }
  20131. } else {
  20132. adminUser := c.GetAdminUserInfo()
  20133. errlog := &models.HisOrderError{
  20134. UserOrgId: adminUser.CurrentOrgId,
  20135. Ctime: time.Now().Unix(),
  20136. Mtime: time.Now().Unix(),
  20137. ErrMsg: res.ErrMsg,
  20138. Status: 1,
  20139. PatientId: id,
  20140. RecordTime: recordDateTime,
  20141. Stage: 4,
  20142. }
  20143. service.CreateErrMsgLog(errlog)
  20144. c.ServeSuccessJSON(map[string]interface{}{
  20145. "failed_code": -10,
  20146. "msg": res.ErrMsg,
  20147. })
  20148. return
  20149. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20150. //return
  20151. }
  20152. }
  20153. }
  20154. } else if tempOrder.ID > 0 {
  20155. if tempOrder.IsPre == 1 {
  20156. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20157. var rf []*ResultFive
  20158. json.Unmarshal([]byte(his.Iinfo), &rf)
  20159. chrg_bchno := tempOrder.Number
  20160. cert_no := his.Certno
  20161. var insutypes []string
  20162. var insutype string
  20163. var is390 int = 0
  20164. var is310 int = 0
  20165. for _, item := range rf {
  20166. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20167. insutypes = append(insutypes, item.Insutype)
  20168. }
  20169. }
  20170. if len(insutypes) == 1 {
  20171. insutype = insutypes[0]
  20172. } else {
  20173. for _, i := range insutypes {
  20174. if i == "390" {
  20175. is390 = 1
  20176. }
  20177. if i == "310" {
  20178. is310 = 1
  20179. }
  20180. }
  20181. }
  20182. if is390 == 1 {
  20183. insutype = "390"
  20184. }
  20185. if is310 == 1 {
  20186. insutype = "310"
  20187. }
  20188. if len(insutypes) == 0 {
  20189. insutype = "310"
  20190. }
  20191. if len(insutypes) == 2 {
  20192. insutype = strconv.FormatInt(his.SocialType, 10)
  20193. }
  20194. //insutype = "390"
  20195. if his.IdCardType == 1 {
  20196. // cert_no = his.MedicalInsuranceNumber
  20197. cert_no = his.Certno
  20198. } else {
  20199. cert_no = his.Certno
  20200. }
  20201. var res ResultSeven
  20202. var ahres ResultSevenAH
  20203. var resSeven10265 ResultSeven10265
  20204. var gzresSeven10265Two GZResultSeven10265Two
  20205. var src_resquest string
  20206. var result2 string
  20207. if miConfig.MdtrtareaAdmvs == "450721" {
  20208. res2 := c.GetoleInfo()
  20209. if res2.Infcode == 0 {
  20210. var result string
  20211. var request_log string
  20212. var result_log string
  20213. if res2.Output.MdtrtCertType == "02" {
  20214. 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)
  20215. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20216. } else if res2.Output.MdtrtCertType == "01" {
  20217. 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)
  20218. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20219. } else {
  20220. 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)
  20221. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20222. }
  20223. var dat map[string]interface{}
  20224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20225. fmt.Println(dat)
  20226. } else {
  20227. fmt.Println(err)
  20228. }
  20229. userJSONBytes, _ := json.Marshal(dat)
  20230. var res5 ResultTwo
  20231. //var resTwo10265 ResultTwo10265
  20232. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20233. utils.ErrorLog("解析失败:%v", err)
  20234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20235. return
  20236. }
  20237. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20238. if res5.Infcode == -1 {
  20239. c.ServeSuccessJSON(map[string]interface{}{
  20240. "failed_code": -10,
  20241. "msg": res5.ErrMsg,
  20242. })
  20243. return
  20244. }
  20245. var insutypes []string
  20246. var insutype string
  20247. var is390 int = 0
  20248. var is310 int = 0
  20249. for _, item := range res5.Output.Iinfo {
  20250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20251. insutypes = append(insutypes, item.Insutype)
  20252. }
  20253. }
  20254. if len(insutypes) == 1 {
  20255. insutype = insutypes[0]
  20256. } else {
  20257. for _, i := range insutypes {
  20258. if i == "390" {
  20259. is390 = 1
  20260. }
  20261. if i == "310" {
  20262. is310 = 1
  20263. }
  20264. }
  20265. }
  20266. if is390 == 1 {
  20267. insutype = "390"
  20268. }
  20269. if is310 == 1 {
  20270. insutype = "310"
  20271. }
  20272. if len(insutypes) == 0 {
  20273. insutype = "310"
  20274. }
  20275. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20276. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20277. infoStr := string(Iinfos)
  20278. idetinfoStr := string(Idetinfos)
  20279. psn := &models.HisPsn{
  20280. PsnNo: res5.Output.Baseinfo.PsnNo,
  20281. PatientId: id,
  20282. Certno: res5.Output.Baseinfo.Certno,
  20283. Gend: res5.Output.Baseinfo.Gend,
  20284. Naty: res5.Output.Baseinfo.Naty,
  20285. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20286. PsnName: res5.Output.Baseinfo.PsnName,
  20287. Idetinfo: idetinfoStr,
  20288. Insuinfo: infoStr,
  20289. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20290. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20291. VerifyNumber: res2.Output.EcToken,
  20292. }
  20293. service.CreateHisPsn(psn)
  20294. if res2.Output.MdtrtCertType == "01" {
  20295. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20296. token := res2.Output.EcToken
  20297. 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)
  20298. } else if res2.Output.MdtrtCertType == "02" {
  20299. 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)
  20300. } else {
  20301. 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)
  20302. }
  20303. var dat2 map[string]interface{}
  20304. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20305. fmt.Println(dat2)
  20306. } else {
  20307. fmt.Println(err)
  20308. }
  20309. userJSONBytes3, _ := json.Marshal(dat2)
  20310. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20311. utils.ErrorLog("解析失败:%v", err)
  20312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20313. return
  20314. }
  20315. saveLog(result2, src_resquest, "2207", "结算")
  20316. } else {
  20317. c.ServeSuccessJSON(map[string]interface{}{
  20318. "failed_code": -10,
  20319. "msg": res2.ErrMsg,
  20320. })
  20321. return
  20322. }
  20323. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20324. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20325. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20326. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20328. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20329. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20330. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20331. resp, requestErr := http.Get(api)
  20332. if requestErr != nil {
  20333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20334. return
  20335. }
  20336. body, ioErr := ioutil.ReadAll(resp.Body)
  20337. if ioErr != nil {
  20338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20340. return
  20341. }
  20342. var respJSON map[string]interface{}
  20343. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20346. return
  20347. }
  20348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20349. result, _ := json.Marshal(respJSON)
  20350. fmt.Println("log")
  20351. fmt.Println(string(result))
  20352. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20353. utils.ErrorLog("解析失败:%v", err)
  20354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20355. return
  20356. }
  20357. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20358. if reg_type == 11 && his.Insutype == "390" {
  20359. reg_type = 110104
  20360. }
  20361. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20362. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20363. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20365. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20366. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20367. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20368. resp, requestErr := http.Get(api)
  20369. if requestErr != nil {
  20370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20371. return
  20372. }
  20373. body, ioErr := ioutil.ReadAll(resp.Body)
  20374. if ioErr != nil {
  20375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20377. return
  20378. }
  20379. var respJSON map[string]interface{}
  20380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20383. return
  20384. }
  20385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20386. result, _ := json.Marshal(respJSON)
  20387. fmt.Println("log")
  20388. fmt.Println(string(result))
  20389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20390. utils.ErrorLog("解析失败:%v", err)
  20391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20392. return
  20393. }
  20394. }else if miConfig.MdtrtareaAdmvs == "420902" {
  20395. if reg_type == 11 && his.Insutype == "390" {
  20396. reg_type = 110104
  20397. }
  20398. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20399. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20400. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20401. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20402. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20403. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20404. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20405. resp, requestErr := http.Get(api)
  20406. if requestErr != nil {
  20407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20408. return
  20409. }
  20410. body, ioErr := ioutil.ReadAll(resp.Body)
  20411. if ioErr != nil {
  20412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20414. return
  20415. }
  20416. var respJSON map[string]interface{}
  20417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20420. return
  20421. }
  20422. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20423. result, _ := json.Marshal(respJSON)
  20424. fmt.Println("log")
  20425. fmt.Println(string(result))
  20426. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20427. utils.ErrorLog("解析失败:%v", err)
  20428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20429. return
  20430. }
  20431. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20432. if reg_type == 11 && his.Insutype == "390" {
  20433. reg_type = 110104
  20434. }
  20435. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20436. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20437. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20438. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20439. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20440. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20441. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20442. resp, requestErr := http.Get(api)
  20443. if requestErr != nil {
  20444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20445. return
  20446. }
  20447. body, ioErr := ioutil.ReadAll(resp.Body)
  20448. if ioErr != nil {
  20449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20451. return
  20452. }
  20453. var respJSON map[string]interface{}
  20454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20457. return
  20458. }
  20459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20460. result, _ := json.Marshal(respJSON)
  20461. fmt.Println("log")
  20462. fmt.Println(string(result))
  20463. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20464. utils.ErrorLog("解析失败:%v", err)
  20465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20466. return
  20467. }
  20468. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20469. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20470. if result3101.Infcode == "0" {
  20471. if len(result3101.Output.Result) > 0 {
  20472. var errMsgs []string
  20473. for _, item := range result3101.Output.Result {
  20474. errMsgs = append(errMsgs, item.VolaCont)
  20475. }
  20476. c.ServeSuccessJSON(map[string]interface{}{
  20477. "failed_code": -10,
  20478. "msg": errMsgs,
  20479. })
  20480. return
  20481. } else {
  20482. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20483. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20484. bas := strings.Split(psn_info.CardInfo, "|")
  20485. if his.IdCardType == 1 {
  20486. cert_no = bas[2]
  20487. } else if his.IdCardType == 3 {
  20488. cert_no = his.Certno
  20489. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20490. } else if his.IdCardType == 4 {
  20491. cert_no = his.Certno
  20492. psn_info.VerifyNumber = psn_info.VerifyNumber
  20493. }
  20494. //江苏地区国家医保医疗类别
  20495. //职工透析:医疗类别选特殊情况门诊9933
  20496. //居民血透门慢: 医疗类别选门诊慢病1402
  20497. //var med_type string
  20498. //if his.Insutype == "310" {
  20499. // if reg_type == 14 {
  20500. // med_type = "9933"
  20501. // } else if reg_type == 11 {
  20502. // med_type = "11"
  20503. //
  20504. // }
  20505. //} else if his.Insutype == "390" {
  20506. // if reg_type == 14 {
  20507. // med_type = "1402"
  20508. // } else if reg_type == 11 {
  20509. // med_type = "11"
  20510. // }
  20511. //}
  20512. var api string
  20513. if miConfig.MdtrtareaAdmvs == "320921" {
  20514. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20515. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20516. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20517. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20518. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20519. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20520. "&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
  20521. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20522. } else {
  20523. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20524. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20525. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20526. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20527. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20528. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20529. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20530. "&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
  20531. }
  20532. resp, requestErr := http.Get(api)
  20533. if requestErr != nil {
  20534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20535. return
  20536. }
  20537. body, ioErr := ioutil.ReadAll(resp.Body)
  20538. if ioErr != nil {
  20539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20541. return
  20542. }
  20543. var respJSON map[string]interface{}
  20544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20547. return
  20548. }
  20549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20550. result, _ := json.Marshal(respJSON)
  20551. fmt.Println("log")
  20552. fmt.Println(string(result))
  20553. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20554. utils.ErrorLog("解析失败:%v", err)
  20555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20556. return
  20557. }
  20558. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20559. res.Output = resSeven10265.Output
  20560. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20561. res.ErrMsg = resSeven10265.ErrMsg
  20562. res.Cainfo = resSeven10265.Cainfo
  20563. res.WarnMsg = resSeven10265.WarnMsg
  20564. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20565. res.Infcode = infocode
  20566. }
  20567. }
  20568. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20569. psn_info, _ := service.GetPsnByPatientId(id)
  20570. var verify_number string
  20571. if psn_info.IdCardType == 4 {
  20572. verify_number = psn_info.VerifyNumber
  20573. } else if psn_info.IdCardType == 1 {
  20574. bas := strings.Split(psn_info.CardInfo, "|")
  20575. cardNumber := bas[2]
  20576. verify_number = cardNumber
  20577. } else {
  20578. verify_number = psn_info.Certno
  20579. psn_info.IdCardType = 2
  20580. }
  20581. var api string
  20582. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20583. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20584. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20585. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20586. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20587. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20588. "&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
  20589. resp, requestErr := http.Get(api)
  20590. if requestErr != nil {
  20591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20592. return
  20593. }
  20594. body, ioErr := ioutil.ReadAll(resp.Body)
  20595. if ioErr != nil {
  20596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20598. return
  20599. }
  20600. var respJSON map[string]interface{}
  20601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20604. return
  20605. }
  20606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20607. result, _ := json.Marshal(respJSON)
  20608. fmt.Println("log")
  20609. fmt.Println(string(result))
  20610. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20611. utils.ErrorLog("解析失败:%v", err)
  20612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20613. return
  20614. }
  20615. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20616. res.Output = resSeven10265.Output
  20617. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20618. res.ErrMsg = resSeven10265.ErrMsg
  20619. res.Cainfo = resSeven10265.Cainfo
  20620. res.WarnMsg = resSeven10265.WarnMsg
  20621. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20622. res.Infcode = infocode
  20623. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20624. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20625. var cert_no string
  20626. if his.IdCardType == 1 {
  20627. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20628. } else {
  20629. cert_no = psn_info.VerifyNumber
  20630. }
  20631. 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)
  20632. var dat map[string]interface{}
  20633. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20634. fmt.Println(dat)
  20635. } else {
  20636. fmt.Println(err)
  20637. }
  20638. saveLog(result2, src_resquest, "2207", "结算")
  20639. userJSONBytes, _ := json.Marshal(dat)
  20640. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20641. utils.ErrorLog("解析失败:%v", err)
  20642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20643. return
  20644. }
  20645. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20646. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20647. var cert_no string
  20648. var card_sn string
  20649. if his.IdCardType == 1 {
  20650. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20651. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20652. bas := strings.Split(psn_info.CardInfo, "|")
  20653. card_sn = bas[3]
  20654. } else if his.IdCardType == 2 {
  20655. cert_no = his.IdCardNo
  20656. } else {
  20657. cert_no = psn_info.VerifyNumber
  20658. }
  20659. var rf []*ResultFive
  20660. json.Unmarshal([]byte(his.Iinfo), &rf)
  20661. var psn_type string
  20662. for _, item := range rf {
  20663. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20664. psn_type = item.PsnType
  20665. }
  20666. }
  20667. 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)
  20668. var dat map[string]interface{}
  20669. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20670. fmt.Println(dat)
  20671. } else {
  20672. fmt.Println(err)
  20673. }
  20674. saveLog(result2, src_resquest, "2207", "结算")
  20675. userJSONBytes, _ := json.Marshal(dat)
  20676. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20677. utils.ErrorLog("解析失败:%v", err)
  20678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20679. return
  20680. }
  20681. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20682. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20683. if his.IdCardType == 1 {
  20684. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20685. bas := strings.Split(psn_info.CardInfo, "|")
  20686. cert_no = bas[2]
  20687. } else if his.IdCardType == 3 {
  20688. cert_no = his.Certno
  20689. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20690. } else if his.IdCardType == 4 {
  20691. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20692. cert_no = his.Certno
  20693. psn_info.VerifyNumber = psn_info.VerifyNumber
  20694. } else {
  20695. cert_no = his.Certno
  20696. psn_info.VerifyNumber = his.Certno
  20697. }
  20698. var api string
  20699. var med_type string
  20700. if his.Insutype == "390" {
  20701. if reg_type == 992102 {
  20702. med_type = "992102"
  20703. }
  20704. if reg_type == 140104 {
  20705. med_type = "140104"
  20706. }
  20707. if reg_type == 14 {
  20708. med_type = "14"
  20709. }
  20710. } else if his.Insutype == "310" {
  20711. if reg_type == 992102 {
  20712. med_type = "992102"
  20713. }
  20714. if reg_type == 14 {
  20715. med_type = "14"
  20716. }
  20717. }
  20718. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20719. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20720. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20722. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20723. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20724. "&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
  20725. resp, requestErr := http.Get(api)
  20726. if requestErr != nil {
  20727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20728. return
  20729. }
  20730. body, ioErr := ioutil.ReadAll(resp.Body)
  20731. if ioErr != nil {
  20732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20734. return
  20735. }
  20736. var respJSON map[string]interface{}
  20737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20740. return
  20741. }
  20742. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20743. if status == "0" {
  20744. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20745. c.ServeSuccessJSON(map[string]interface{}{
  20746. "failed_code": -10,
  20747. "msg": err_msg,
  20748. })
  20749. return
  20750. }
  20751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20752. result, _ := json.Marshal(respJSON)
  20753. fmt.Println("log")
  20754. fmt.Println(string(result))
  20755. if err := json.Unmarshal(result, &ahres); err != nil {
  20756. utils.ErrorLog("解析失败:%v", err)
  20757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20758. return
  20759. }
  20760. res.InfRefmsgid = ahres.InfRefmsgid
  20761. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20762. // 创建对应的Time类型
  20763. t := time.UnixMilli(timestamp)
  20764. // 格式化成指定的日期字符串
  20765. str := t.Format("2006-01-02 15:04:05")
  20766. res.Output.Setlinfo.SetlTime = str
  20767. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20768. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20769. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20770. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20771. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20772. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20773. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20774. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20775. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20776. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20777. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20778. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20779. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20780. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20781. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20782. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20783. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20784. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20785. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20786. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20787. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20788. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20789. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20790. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20791. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20792. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20793. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20794. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20795. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20796. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20797. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20798. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20799. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20800. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20801. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20802. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20803. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20804. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20805. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20806. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20807. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20808. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20809. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20810. res.Output.Setldetail = ahres.Output.Setldetail
  20811. res.ErrMsg = ahres.ErrMsg
  20812. res.Cainfo = ahres.Cainfo
  20813. res.WarnMsg = ahres.WarnMsg
  20814. res.Infcode = ahres.Infcode
  20815. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20816. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20817. var cert_no string
  20818. if his.IdCardType == 1 {
  20819. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20820. } else if his.IdCardType == 2 {
  20821. cert_no = his.IdCardNo
  20822. } else {
  20823. cert_no = psn_info.VerifyNumber
  20824. }
  20825. 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, "")
  20826. var dat map[string]interface{}
  20827. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20828. fmt.Println(dat)
  20829. } else {
  20830. fmt.Println(err)
  20831. }
  20832. saveLog(result2, src_resquest, "2207", "结算")
  20833. userJSONBytes, _ := json.Marshal(dat)
  20834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20835. utils.ErrorLog("解析失败:%v", err)
  20836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20837. return
  20838. }
  20839. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20840. psn_info, _ := service.GetPsnByPatientId(id)
  20841. var verify_number string
  20842. if psn_info.IdCardType == 4 {
  20843. verify_number = psn_info.VerifyNumber
  20844. } else if psn_info.IdCardType == 1 {
  20845. bas := strings.Split(psn_info.CardInfo, "|")
  20846. cardNumber := bas[2]
  20847. verify_number = cardNumber
  20848. } else {
  20849. verify_number = psn_info.Certno
  20850. psn_info.IdCardType = 2
  20851. }
  20852. var api string
  20853. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20854. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20855. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20856. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20857. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20858. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20859. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20860. resp, requestErr := http.Get(api)
  20861. if requestErr != nil {
  20862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20863. return
  20864. }
  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(string(body)), &respJSON); err != nil {
  20873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20875. return
  20876. }
  20877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20878. result, _ := json.Marshal(respJSON)
  20879. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20880. utils.ErrorLog("解析失败:%v", err)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. } else {
  20885. var src_resquest string
  20886. if miConfig.Code == "H15049901371" {
  20887. //赤峰地区国家医保医疗类别
  20888. //职工透析:医疗类别选特殊情况门诊990502
  20889. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20890. var med_type string
  20891. if his.Insutype == "390" {
  20892. if reg_type == 14 {
  20893. med_type = "9933"
  20894. } else if reg_type == 11 {
  20895. med_type = "11"
  20896. }
  20897. } else if his.Insutype == "310" {
  20898. if reg_type == 14 {
  20899. med_type = "990502"
  20900. } else if reg_type == 11 {
  20901. med_type = "11"
  20902. }
  20903. }
  20904. 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)
  20905. } else {
  20906. if his.IdCardType == 4 {
  20907. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20908. token := psn_info.VerifyNumber
  20909. 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)
  20910. } else {
  20911. 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)
  20912. }
  20913. }
  20914. var dat map[string]interface{}
  20915. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20916. fmt.Println(dat)
  20917. } else {
  20918. fmt.Println(err)
  20919. }
  20920. saveLog(result2, src_resquest, "2207", "结算")
  20921. userJSONBytes, _ := json.Marshal(dat)
  20922. if miConfig.Code == "H15049901371" {
  20923. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20924. utils.ErrorLog("解析失败:%v", err)
  20925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20926. return
  20927. }
  20928. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20929. res.Output = resSeven10265.Output
  20930. res.ErrMsg = resSeven10265.ErrMsg
  20931. res.Cainfo = resSeven10265.Cainfo
  20932. res.WarnMsg = resSeven10265.WarnMsg
  20933. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20934. res.Infcode = infocode
  20935. } else {
  20936. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20937. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20938. utils.ErrorLog("解析失败:%v", err)
  20939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20940. return
  20941. }
  20942. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20943. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20944. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20945. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20946. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20947. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20948. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20949. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20950. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20951. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20952. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20953. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20954. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20955. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20956. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20957. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20958. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20959. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20960. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20961. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20962. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20963. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20964. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20965. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20966. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20967. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20968. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20969. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20970. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20971. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20972. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20973. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20974. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20975. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20976. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20977. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20978. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20979. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20980. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20981. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20982. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20983. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20984. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20985. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20986. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20987. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20988. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20989. res.Cainfo = gzresSeven10265Two.Cainfo
  20990. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20991. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20992. //res.Infcode = infocode
  20993. } else {
  20994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20995. utils.ErrorLog("解析失败:%v", err)
  20996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20997. return
  20998. }
  20999. }
  21000. }
  21001. }
  21002. if res.Infcode != 0 {
  21003. errlog := &models.HisOrderError{
  21004. UserOrgId: adminUser.CurrentOrgId,
  21005. Ctime: time.Now().Unix(),
  21006. Mtime: time.Now().Unix(),
  21007. Number: chrg_bchno,
  21008. ErrMsg: res.ErrMsg,
  21009. Status: 1,
  21010. PatientId: id,
  21011. RecordTime: recordDateTime,
  21012. Stage: 6,
  21013. }
  21014. service.CreateErrMsgLog(errlog)
  21015. c.ServeSuccessJSON(map[string]interface{}{
  21016. "failed_code": -10,
  21017. "msg": res.ErrMsg,
  21018. })
  21019. return
  21020. } else {
  21021. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21022. order.OrderStatus = 2
  21023. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21024. order.SetlId = res.Output.Setlinfo.SetlID
  21025. order.PsnNo = res.Output.Setlinfo.PsnNo
  21026. order.PsnName = res.Output.Setlinfo.PsnName
  21027. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21028. order.Certno = res.Output.Setlinfo.Certno
  21029. order.Gend = res.Output.Setlinfo.Gend
  21030. order.Naty = res.Output.Setlinfo.Naty
  21031. order.Age = res.Output.Setlinfo.Age
  21032. order.Insutype = res.Output.Setlinfo.Insutype
  21033. order.PsnType = res.Output.Setlinfo.PsnType
  21034. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21035. order.SetlTime = res.Output.Setlinfo.SetlTime
  21036. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21037. order.PayWays = pay_ways
  21038. order.AcctUsedFlag = acct_used_flag
  21039. order.WechatPay = wechat_pay
  21040. order.AliPay = ali_pay
  21041. order.JifenPay = jifen_pay
  21042. order.BandCardPay = band_card_pay
  21043. order.CashPay = cash_pay
  21044. order.OthDesc = oth_desc
  21045. //order.MedType = res.Output.Setlinfo.MedType
  21046. if reg_type == 1112 {
  21047. order.MedType = "1112"
  21048. }
  21049. if reg_type == 1111 {
  21050. order.MedType = "1111"
  21051. }
  21052. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21053. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21054. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21055. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21056. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21057. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21058. order.HifpPay = res.Output.Setlinfo.HifpPay
  21059. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21060. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21061. order.HifesPay = res.Output.Setlinfo.HifesPay
  21062. order.HifobPay = res.Output.Setlinfo.HifobPay
  21063. order.MafPay = res.Output.Setlinfo.MafPay
  21064. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21065. order.OthPay = res.Output.Setlinfo.OthPay
  21066. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21067. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21068. order.AcctPay = res.Output.Setlinfo.AcctPay
  21069. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21070. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21071. order.Balc = res.Output.Setlinfo.Balc
  21072. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21073. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21074. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21075. order.ClrWay = res.Output.Setlinfo.ClrWay
  21076. order.Creator = order.Creator
  21077. order.ClrType = res.Output.Setlinfo.ClrType
  21078. order.Modify = roles.AdminUserId
  21079. order.RequestLog = src_resquest
  21080. order.Diagnosis = diagnosis_id
  21081. order.FaPiaoNumber = fapiao_number
  21082. order.FaPiaoCode = fapiao_code
  21083. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21084. detailStr := string(setlDetail)
  21085. order.SetlDetail = detailStr
  21086. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21087. err = service.UpDateOrder(order)
  21088. if err == nil {
  21089. //判断是否使用了押金
  21090. if dec_way == "true" {
  21091. tmpstring := strconv.FormatInt(order.ID, 10)
  21092. //扣押金
  21093. order.Decimal = decimal
  21094. service.UpDateOrder(order)
  21095. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21096. if errmsg != nil {
  21097. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21098. return
  21099. }
  21100. }
  21101. c.ServeSuccessJSON(map[string]interface{}{
  21102. "msg": "结算成功",
  21103. })
  21104. } else {
  21105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21106. return
  21107. }
  21108. }
  21109. }
  21110. }
  21111. }
  21112. // 上传明细-预结算-
  21113. func (c *HisApiController) GetPreUploadInfo() {
  21114. id, _ := c.GetInt64("id")
  21115. record_time := c.GetString("record_time")
  21116. his_patient_id, _ := c.GetInt64("his_patient_id")
  21117. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21118. admin_user_id, _ := c.GetInt64("admin_user_id")
  21119. diagnosis_id := c.GetString("diagnosis")
  21120. sick_type, _ := c.GetInt64("sick_type")
  21121. reg_type, _ := c.GetInt64("p_type")
  21122. begin_time := c.GetString("begin_time")
  21123. acct_used_flag := c.GetString("acct_used_flag")
  21124. id_str := c.GetString("ids")
  21125. ids_arr := strings.Split(id_str, ",")
  21126. timeLayout := "2006-01-02"
  21127. loc, _ := time.LoadLocation("Local")
  21128. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21129. if err != nil {
  21130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21131. return
  21132. }
  21133. recordDateTime := theTime.Unix()
  21134. adminUser := c.GetAdminUserInfo()
  21135. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21136. var config []*models.HisXtDiagnoseConfig
  21137. for _, item := range diagnosis_ids {
  21138. id, _ := strconv.ParseInt(item, 10, 64)
  21139. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21140. config = append(config, &diagnosisConfig)
  21141. }
  21142. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21143. sickConfig, _ := service.FindSickById(sick_type)
  21144. var prescriptions []*models.HisPrescription
  21145. var start_time int64
  21146. var end_time int64
  21147. var isSuccess bool = true
  21148. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21149. fmt.Println(his_patient_id)
  21150. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21151. timestamp := time.Now().Unix()
  21152. tempTime := time.Unix(timestamp, 0)
  21153. timeFormat := tempTime.Format("20060102150405")
  21154. chrgBchno := rand.Intn(100000) + 10000
  21155. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21156. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21157. var patientPrescription models.HisPrescriptionInfo
  21158. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21159. if patientPrescription.ID == 0 {
  21160. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21161. }
  21162. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21163. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21164. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21165. strconv.FormatInt(his.PatientId, 10)
  21166. var res2406 Result2406
  21167. //安徽单病种处理
  21168. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21169. data := make(map[string]interface{})
  21170. client := &http.Client{}
  21171. data["psn_no"] = his.PsnNo
  21172. data["mdtrt_id"] = his.Number
  21173. data["operator"] = roles.UserName
  21174. data["cert_no"] = his.IdCardNo
  21175. data["org_name"] = miConfig.OrgName
  21176. data["psn_name"] = his.Name
  21177. data["ipt_otp_no"] = his.IptOtpNo
  21178. data["ipt_psn_sp_flag_type"] = "0901"
  21179. data["ipt_psn_sp_flag"] = "1"
  21180. data["fixmedins_code"] = miConfig.Code
  21181. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21182. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21183. data["url"] = miConfig.Url
  21184. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21185. bytesData, _ := json.Marshal(data)
  21186. var req *http.Request
  21187. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21188. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21189. resp, _ := client.Do(req)
  21190. defer resp.Body.Close()
  21191. body, ioErr := ioutil.ReadAll(resp.Body)
  21192. if ioErr != nil {
  21193. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21195. return
  21196. }
  21197. var respJSON map[string]interface{}
  21198. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21199. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21201. return
  21202. }
  21203. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21204. if status == "0" {
  21205. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21206. c.ServeSuccessJSON(map[string]interface{}{
  21207. "failed_code": -10,
  21208. "msg": err_msg,
  21209. })
  21210. return
  21211. }
  21212. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21213. userJSONBytes, _ := json.Marshal(respJSON)
  21214. fmt.Println("log")
  21215. fmt.Println(string(userJSONBytes))
  21216. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21217. utils.ErrorLog("解析失败:%v", err)
  21218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21219. return
  21220. }
  21221. }
  21222. if res2406.Infcode != 0 {
  21223. adminUser := c.GetAdminUserInfo()
  21224. errlog := &models.HisOrderError{
  21225. UserOrgId: adminUser.CurrentOrgId,
  21226. Ctime: time.Now().Unix(),
  21227. Mtime: time.Now().Unix(),
  21228. ErrMsg: res2406.ErrMsg,
  21229. Status: 1,
  21230. PatientId: id,
  21231. RecordTime: recordDateTime,
  21232. Stage: 3,
  21233. }
  21234. service.CreateErrMsgLog(errlog)
  21235. c.ServeSuccessJSON(map[string]interface{}{
  21236. "failed_code": -10,
  21237. "msg": res2406.ErrMsg,
  21238. })
  21239. return
  21240. }
  21241. var res2 ResultSix
  21242. var res3 GZResultSix
  21243. var resSix10265 ResultSix10265
  21244. //var time_stamp string
  21245. if miConfig.MdtrtareaAdmvs == "421300" {
  21246. data := make(map[string]interface{})
  21247. client := &http.Client{}
  21248. data["psn_no"] = his.PsnNo
  21249. data["mdtrt_id"] = his.Number
  21250. data["department"] = department.Name
  21251. data["org_name"] = miConfig.OrgName
  21252. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21253. data["doctor_id"] = doctor_info.DoctorNumber
  21254. data["doctor_name"] = roles.UserName
  21255. data["fixmedins_code"] = miConfig.Code
  21256. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21257. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21258. data["secret_key"] = miConfig.SecretKey
  21259. data["sick_code"] = sickConfig.CountryCode
  21260. data["sick_name"] = sickConfig.ClassName
  21261. data["begin_time"] = begin_time
  21262. data["dept"] = strconv.FormatInt(department.ID, 10)
  21263. data["config"] = config
  21264. data["opter"] = roles.UserName
  21265. fmt.Println(data)
  21266. bytesData, _ := json.Marshal(data)
  21267. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21268. resp, _ := client.Do(req)
  21269. defer resp.Body.Close()
  21270. body, ioErr := ioutil.ReadAll(resp.Body)
  21271. if ioErr != nil {
  21272. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21274. return
  21275. }
  21276. var respJSON map[string]interface{}
  21277. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21280. return
  21281. }
  21282. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21283. userJSONBytes, _ := json.Marshal(respJSON)
  21284. fmt.Println("log")
  21285. fmt.Println(string(userJSONBytes))
  21286. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21287. utils.ErrorLog("解析失败:%v", err)
  21288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21289. return
  21290. }
  21291. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21292. data := make(map[string]interface{})
  21293. client := &http.Client{}
  21294. data["psn_no"] = his.PsnNo
  21295. data["mdtrt_id"] = his.Number
  21296. data["department"] = department.Name
  21297. data["org_name"] = miConfig.OrgName
  21298. if reg_type == 11 && his.Insutype == "390" {
  21299. data["med_type"] = "110104"
  21300. } else {
  21301. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21302. }
  21303. data["doctor_id"] = doctor_info.DoctorNumber
  21304. data["doctor_name"] = roles.UserName
  21305. data["fixmedins_code"] = miConfig.Code
  21306. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21307. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21308. data["secret_key"] = miConfig.SecretKey
  21309. data["sick_code"] = sickConfig.CountryCode
  21310. data["sick_name"] = sickConfig.ClassName
  21311. data["begin_time"] = begin_time
  21312. data["dept"] = strconv.FormatInt(department.ID, 10)
  21313. data["config"] = config
  21314. data["opter"] = roles.UserName
  21315. fmt.Println(data)
  21316. bytesData, _ := json.Marshal(data)
  21317. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21318. resp, _ := client.Do(req)
  21319. defer resp.Body.Close()
  21320. body, ioErr := ioutil.ReadAll(resp.Body)
  21321. if ioErr != nil {
  21322. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21324. return
  21325. }
  21326. var respJSON map[string]interface{}
  21327. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21328. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21330. return
  21331. }
  21332. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21333. userJSONBytes, _ := json.Marshal(respJSON)
  21334. fmt.Println("log")
  21335. fmt.Println(string(userJSONBytes))
  21336. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21337. utils.ErrorLog("解析失败:%v", err)
  21338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21339. return
  21340. }
  21341. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21342. data := make(map[string]interface{})
  21343. client := &http.Client{}
  21344. data["psn_no"] = his.PsnNo
  21345. data["mdtrt_id"] = his.Number
  21346. data["department"] = department.Name
  21347. data["org_name"] = miConfig.OrgName
  21348. if reg_type == 11 && his.Insutype == "390" {
  21349. data["med_type"] = "110104"
  21350. } else {
  21351. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21352. }
  21353. data["doctor_id"] = doctor_info.DoctorNumber
  21354. data["doctor_name"] = roles.UserName
  21355. data["fixmedins_code"] = miConfig.Code
  21356. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21357. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21358. data["secret_key"] = miConfig.SecretKey
  21359. data["sick_code"] = sickConfig.CountryCode
  21360. data["sick_name"] = sickConfig.ClassName
  21361. data["begin_time"] = begin_time
  21362. data["dept"] = strconv.FormatInt(department.ID, 10)
  21363. data["config"] = config
  21364. data["opter"] = roles.UserName
  21365. fmt.Println(data)
  21366. bytesData, _ := json.Marshal(data)
  21367. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21368. resp, _ := client.Do(req)
  21369. defer resp.Body.Close()
  21370. body, ioErr := ioutil.ReadAll(resp.Body)
  21371. if ioErr != nil {
  21372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21374. return
  21375. }
  21376. var respJSON map[string]interface{}
  21377. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21380. return
  21381. }
  21382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21383. userJSONBytes, _ := json.Marshal(respJSON)
  21384. fmt.Println("log")
  21385. fmt.Println(string(userJSONBytes))
  21386. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21387. utils.ErrorLog("解析失败:%v", err)
  21388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21389. return
  21390. }
  21391. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21392. data := make(map[string]interface{})
  21393. client := &http.Client{}
  21394. data["psn_no"] = his.PsnNo
  21395. data["mdtrt_id"] = his.Number
  21396. data["department"] = department.Name
  21397. data["org_name"] = miConfig.OrgName
  21398. if reg_type == 11 && his.Insutype == "390" {
  21399. data["med_type"] = "110104"
  21400. } else {
  21401. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21402. }
  21403. data["doctor_id"] = doctor_info.DoctorNumber
  21404. data["doctor_name"] = roles.UserName
  21405. data["fixmedins_code"] = miConfig.Code
  21406. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21407. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21408. data["secret_key"] = miConfig.SecretKey
  21409. data["sick_code"] = sickConfig.CountryCode
  21410. data["sick_name"] = sickConfig.ClassName
  21411. data["begin_time"] = begin_time
  21412. data["dept"] = strconv.FormatInt(department.ID, 10)
  21413. data["config"] = config
  21414. data["opter"] = roles.UserName
  21415. fmt.Println(data)
  21416. bytesData, _ := json.Marshal(data)
  21417. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21418. resp, _ := client.Do(req)
  21419. defer resp.Body.Close()
  21420. body, ioErr := ioutil.ReadAll(resp.Body)
  21421. if ioErr != nil {
  21422. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21424. return
  21425. }
  21426. var respJSON map[string]interface{}
  21427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21430. return
  21431. }
  21432. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21433. userJSONBytes, _ := json.Marshal(respJSON)
  21434. fmt.Println("log")
  21435. fmt.Println(string(userJSONBytes))
  21436. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21437. utils.ErrorLog("解析失败:%v", err)
  21438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21439. return
  21440. }
  21441. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21442. data := make(map[string]interface{})
  21443. client := &http.Client{}
  21444. data["psn_no"] = his.PsnNo
  21445. data["mdtrt_id"] = his.Number
  21446. data["doctor"] = roles.UserName
  21447. data["department"] = department.Name
  21448. data["org_name"] = miConfig.OrgName
  21449. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21450. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21451. data["fixmedins_code"] = miConfig.Code
  21452. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21453. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21454. data["secret_key"] = miConfig.SecretKey
  21455. data["sick_code"] = sickConfig.CountryCode
  21456. data["sick_name"] = sickConfig.ClassName
  21457. data["begin_time"] = begin_time
  21458. data["dept"] = strconv.FormatInt(department.ID, 10)
  21459. data["config"] = config
  21460. data["url"] = miConfig.Url
  21461. data["ak"] = miConfig.AccessKey
  21462. data["cainfo"] = miConfig.Cainfo
  21463. bytesData, _ := json.Marshal(data)
  21464. var req *http.Request
  21465. if miConfig.MdtrtareaAdmvs == "320921" {
  21466. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21467. } else {
  21468. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21469. }
  21470. resp, _ := client.Do(req)
  21471. defer resp.Body.Close()
  21472. body, ioErr := ioutil.ReadAll(resp.Body)
  21473. if ioErr != nil {
  21474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21476. return
  21477. }
  21478. var respJSON map[string]interface{}
  21479. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21482. return
  21483. }
  21484. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21485. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21486. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21488. userJSONBytes, _ := json.Marshal(respJSON)
  21489. fmt.Println("log")
  21490. fmt.Println(string(userJSONBytes))
  21491. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21492. utils.ErrorLog("解析失败:%v", err)
  21493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21494. return
  21495. }
  21496. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21497. res2.Output = resSix10265.Output
  21498. res2.ErrMsg = resSix10265.ErrMsg
  21499. res2.Cainfo = resSix10265.Cainfo
  21500. res2.WarnMsg = resSix10265.WarnMsg
  21501. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21502. res2.Infcode = infocode
  21503. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21504. data := make(map[string]interface{})
  21505. client := &http.Client{}
  21506. data["psn_no"] = his.PsnNo
  21507. data["mdtrt_id"] = his.Number
  21508. data["doctor"] = roles.UserName
  21509. data["department"] = department.Name
  21510. data["org_name"] = miConfig.OrgName
  21511. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21512. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21513. data["fixmedins_code"] = miConfig.Code
  21514. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21515. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21516. data["secret_key"] = miConfig.SecretKey
  21517. data["sick_code"] = sickConfig.CountryCode
  21518. data["sick_name"] = sickConfig.ClassName
  21519. data["begin_time"] = begin_time
  21520. data["dept"] = strconv.FormatInt(department.ID, 10)
  21521. data["config"] = config
  21522. //data["url"] = miConfig.Url
  21523. //data["ak"] = miConfig.AccessKey
  21524. data["cainfo"] = miConfig.Cainfo
  21525. fmt.Println(data)
  21526. bytesData, _ := json.Marshal(data)
  21527. var req *http.Request
  21528. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21529. resp, _ := client.Do(req)
  21530. defer resp.Body.Close()
  21531. body, ioErr := ioutil.ReadAll(resp.Body)
  21532. if ioErr != nil {
  21533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21535. return
  21536. }
  21537. var respJSON map[string]interface{}
  21538. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21541. return
  21542. }
  21543. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21544. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21545. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21547. userJSONBytes, _ := json.Marshal(respJSON)
  21548. fmt.Println("log")
  21549. fmt.Println(string(userJSONBytes))
  21550. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21551. utils.ErrorLog("解析失败:%v", err)
  21552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21553. return
  21554. }
  21555. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21556. res2.Output = resSix10265.Output
  21557. res2.ErrMsg = resSix10265.ErrMsg
  21558. res2.Cainfo = resSix10265.Cainfo
  21559. res2.WarnMsg = resSix10265.WarnMsg
  21560. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21561. res2.Infcode = infocode
  21562. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21563. 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)
  21564. saveLog(result, requestLog, "2203", "上传就诊信息")
  21565. var respJSON2 map[string]interface{}
  21566. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21569. return
  21570. }
  21571. userJSONBytes2, _ := json.Marshal(respJSON2)
  21572. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21573. utils.ErrorLog("解析失败:%v", err)
  21574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21575. return
  21576. }
  21577. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21578. var result string
  21579. var requestLog string
  21580. 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, "")
  21581. saveLog(result, requestLog, "2203", "上传就诊信息")
  21582. var respJSON2 map[string]interface{}
  21583. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21586. return
  21587. }
  21588. userJSONBytes2, _ := json.Marshal(respJSON2)
  21589. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21590. utils.ErrorLog("解析失败:%v", err)
  21591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21592. return
  21593. }
  21594. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21595. data := make(map[string]interface{})
  21596. client := &http.Client{}
  21597. data["psn_no"] = his.PsnNo
  21598. data["mdtrt_id"] = his.Number
  21599. data["operator"] = roles.UserName
  21600. data["department"] = department.Name
  21601. data["org_name"] = miConfig.OrgName
  21602. var med_type string
  21603. if his.Insutype == "390" {
  21604. if reg_type == 992102 {
  21605. med_type = "992102"
  21606. data["sick_code"] = "ZDZ940"
  21607. data["sick_name"] = "慢性肾衰竭"
  21608. }
  21609. if reg_type == 140104 {
  21610. med_type = "140104"
  21611. data["sick_code"] = sickConfig.CountryCode
  21612. data["sick_name"] = sickConfig.ClassName
  21613. }
  21614. if reg_type == 14 {
  21615. med_type = "140104"
  21616. data["sick_code"] = sickConfig.CountryCode
  21617. data["sick_name"] = sickConfig.ClassName
  21618. }
  21619. } else if his.Insutype == "310" {
  21620. if reg_type == 992102 {
  21621. med_type = "992102"
  21622. data["sick_code"] = "ZDZ940"
  21623. data["sick_name"] = "慢性肾衰竭"
  21624. }
  21625. if reg_type == 140104 {
  21626. med_type = "140104"
  21627. data["sick_code"] = sickConfig.CountryCode
  21628. data["sick_name"] = sickConfig.ClassName
  21629. }
  21630. if reg_type == 14 {
  21631. med_type = "14"
  21632. data["sick_code"] = sickConfig.CountryCode
  21633. data["sick_name"] = sickConfig.ClassName
  21634. }
  21635. }
  21636. data["med_type"] = med_type
  21637. data["doctor_number"] = doctor_info.DoctorNumber
  21638. data["doctor_name"] = doctor_info.UserName
  21639. data["fixmedins_code"] = miConfig.Code
  21640. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21641. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21642. data["secret_key"] = miConfig.SecretKey
  21643. data["begin_time"] = begin_time
  21644. data["dept"] = strconv.FormatInt(department.ID, 10)
  21645. data["config"] = config
  21646. data["url"] = miConfig.Url
  21647. data["ak"] = miConfig.AccessKey
  21648. data["cainfo"] = miConfig.Cainfo
  21649. bytesData, _ := json.Marshal(data)
  21650. var req *http.Request
  21651. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21652. resp, _ := client.Do(req)
  21653. defer resp.Body.Close()
  21654. body, ioErr := ioutil.ReadAll(resp.Body)
  21655. if ioErr != nil {
  21656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21658. return
  21659. }
  21660. var respJSON map[string]interface{}
  21661. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21664. return
  21665. }
  21666. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21667. if status == "0" {
  21668. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21669. c.ServeSuccessJSON(map[string]interface{}{
  21670. "failed_code": -10,
  21671. "msg": err_msg,
  21672. })
  21673. return
  21674. }
  21675. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21676. userJSONBytes, _ := json.Marshal(respJSON)
  21677. fmt.Println("log")
  21678. fmt.Println(string(userJSONBytes))
  21679. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21680. utils.ErrorLog("解析失败:%v", err)
  21681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21682. return
  21683. }
  21684. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21685. var result string
  21686. var requestLog string
  21687. 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, "")
  21688. saveLog(result, requestLog, "2203", "上传就诊信息")
  21689. var respJSON2 map[string]interface{}
  21690. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21693. return
  21694. }
  21695. userJSONBytes2, _ := json.Marshal(respJSON2)
  21696. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21697. utils.ErrorLog("解析失败:%v", err)
  21698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21699. return
  21700. }
  21701. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21702. data := make(map[string]interface{})
  21703. client := &http.Client{}
  21704. data["psn_no"] = his.PsnNo
  21705. data["mdtrt_id"] = his.Number
  21706. data["doctor"] = roles.UserName
  21707. data["department"] = department.Name
  21708. data["org_name"] = miConfig.OrgName
  21709. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21710. data["doctor_id"] = doctor_info.DoctorNumber
  21711. data["fixmedins_code"] = miConfig.Code
  21712. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21713. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21714. data["secret_key"] = miConfig.SecretKey
  21715. data["sick_code"] = sickConfig.CountryCode
  21716. data["sick_name"] = sickConfig.ClassName
  21717. data["begin_time"] = begin_time
  21718. data["new_doctor_name"] = doctor_info.UserName
  21719. data["dept"] = strconv.FormatInt(department.ID, 10)
  21720. data["config"] = config
  21721. bytesData, _ := json.Marshal(data)
  21722. var req *http.Request
  21723. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21724. resp, _ := client.Do(req)
  21725. defer resp.Body.Close()
  21726. body, ioErr := ioutil.ReadAll(resp.Body)
  21727. if ioErr != nil {
  21728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21730. return
  21731. }
  21732. var respJSON map[string]interface{}
  21733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21736. return
  21737. }
  21738. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21739. userJSONBytes, _ := json.Marshal(respJSON)
  21740. fmt.Println("log")
  21741. fmt.Println(string(userJSONBytes))
  21742. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21743. utils.ErrorLog("解析失败:%v", err)
  21744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21745. return
  21746. }
  21747. } else {
  21748. var result string
  21749. var requestLog string
  21750. if miConfig.MdtrtareaAdmvs == "440781" { //
  21751. 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)
  21752. } else {
  21753. if miConfig.Code == "H15049901371" {
  21754. //赤峰地区国家医保医疗类别
  21755. //职工透析:医疗类别选特殊情况门诊990502
  21756. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21757. var med_type string
  21758. if his.Insutype == "390" {
  21759. if reg_type == 14 {
  21760. med_type = "9933"
  21761. } else if reg_type == 11 {
  21762. med_type = "11"
  21763. }
  21764. } else if his.Insutype == "310" {
  21765. if reg_type == 14 {
  21766. med_type = "990502"
  21767. } else if reg_type == 11 {
  21768. med_type = "11"
  21769. }
  21770. }
  21771. 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)
  21772. } else {
  21773. 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)
  21774. }
  21775. saveLog(result, requestLog, "2203", "上传就诊信息")
  21776. var respJSON2 map[string]interface{}
  21777. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21780. return
  21781. }
  21782. userJSONBytes2, _ := json.Marshal(respJSON2)
  21783. if miConfig.Code == "H15049901371" {
  21784. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21785. utils.ErrorLog("解析失败:%v", err)
  21786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21787. return
  21788. }
  21789. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21790. res2.Output = resSix10265.Output
  21791. res2.ErrMsg = resSix10265.ErrMsg
  21792. res2.Cainfo = resSix10265.Cainfo
  21793. res2.WarnMsg = resSix10265.WarnMsg
  21794. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21795. res2.Infcode = infocode
  21796. } else {
  21797. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21798. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21799. utils.ErrorLog("解析失败:%v", err)
  21800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21801. return
  21802. }
  21803. res2.Infcode = res3.Infcode
  21804. } else {
  21805. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21806. utils.ErrorLog("解析失败:%v", err)
  21807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21808. return
  21809. }
  21810. }
  21811. }
  21812. }
  21813. }
  21814. if res2.Infcode == -1 {
  21815. adminUser := c.GetAdminUserInfo()
  21816. errlog := &models.HisOrderError{
  21817. UserOrgId: adminUser.CurrentOrgId,
  21818. Ctime: time.Now().Unix(),
  21819. Mtime: time.Now().Unix(),
  21820. ErrMsg: res2.ErrMsg,
  21821. Status: 1,
  21822. PatientId: id,
  21823. RecordTime: recordDateTime,
  21824. Stage: 3,
  21825. }
  21826. service.CreateErrMsgLog(errlog)
  21827. c.ServeSuccessJSON(map[string]interface{}{
  21828. "failed_code": -10,
  21829. "msg": res2.ErrMsg,
  21830. })
  21831. return
  21832. }
  21833. if res2.Infcode != 0 {
  21834. adminUser := c.GetAdminUserInfo()
  21835. errlog := &models.HisOrderError{
  21836. UserOrgId: adminUser.CurrentOrgId,
  21837. Ctime: time.Now().Unix(),
  21838. Mtime: time.Now().Unix(),
  21839. ErrMsg: res2.ErrMsg,
  21840. Status: 1,
  21841. PatientId: id,
  21842. RecordTime: recordDateTime,
  21843. Stage: 3,
  21844. }
  21845. service.CreateErrMsgLog(errlog)
  21846. c.ServeSuccessJSON(map[string]interface{}{
  21847. "failed_code": -10,
  21848. "msg": res2.ErrMsg,
  21849. })
  21850. return
  21851. } else {
  21852. his.Diagnosis = diagnosis_id
  21853. his.SickType = sickConfig.ID
  21854. his.PType = fmt.Sprintf("%d", reg_type)
  21855. service.UpdateHisPatientThree(&his)
  21856. data := make(map[string]interface{})
  21857. if settle_accounts_type == 1 { //日结
  21858. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21859. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21860. } else {
  21861. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21862. }
  21863. data["pre"] = prescriptions
  21864. } else { //月结
  21865. start_time_str := c.GetString("start_time")
  21866. end_time_str := c.GetString("end_time")
  21867. timeLayout := "2006-01-02"
  21868. loc, _ := time.LoadLocation("Local")
  21869. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21870. if err != nil {
  21871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21872. return
  21873. }
  21874. recordStartTime := theStartTime.Unix()
  21875. start_time = recordStartTime
  21876. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21877. if err != nil {
  21878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21879. return
  21880. }
  21881. recordEndTime := theEndTime.Unix()
  21882. end_time = recordEndTime
  21883. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21884. data["pre"] = prescriptions
  21885. }
  21886. client := &http.Client{}
  21887. data["psn_no"] = his.PsnNo
  21888. data["mdtrt_id"] = his.Number
  21889. data["chrg_bchno"] = chrg_bchno
  21890. data["org_name"] = miConfig.OrgName
  21891. data["doctor"] = doctor_info.UserName
  21892. data["doctor_id"] = doctor_info.DoctorNumber
  21893. data["dept"] = department.Name
  21894. data["fixmedins_code"] = miConfig.Code
  21895. data["opter"] = roles.UserName
  21896. data["dept_code"] = department.Number
  21897. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21899. data["secret_key"] = miConfig.SecretKey
  21900. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21901. data["url"] = miConfig.Url
  21902. data["ak"] = miConfig.AccessKey
  21903. data["new_doctor_name"] = patientPrescription.Doctor
  21904. if his.Insutype == "390" {
  21905. if reg_type == 992102 {
  21906. data["diag_code"] = "ZDZ940"
  21907. }
  21908. if reg_type == 140104 {
  21909. data["diag_code"] = sickConfig.CountryCode
  21910. }
  21911. if reg_type == 14 {
  21912. data["diag_code"] = sickConfig.CountryCode
  21913. }
  21914. } else if his.Insutype == "310" {
  21915. if reg_type == 992102 {
  21916. data["diag_code"] = "ZDZ940"
  21917. }
  21918. if reg_type == 14 {
  21919. data["diag_code"] = sickConfig.CountryCode
  21920. }
  21921. }
  21922. data["cainfo"] = miConfig.Cainfo
  21923. data["opter"] = roles.UserName
  21924. var ids []int64
  21925. for _, item := range prescriptions {
  21926. ids = append(ids, item.ID)
  21927. }
  21928. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21929. if config.IsOpen == 1 { //对接了医保,走医保流程
  21930. var res ResultFour
  21931. var resFour10265 ResultFour10265
  21932. if miConfig.MdtrtareaAdmvs == "421300" {
  21933. bytesData, _ := json.Marshal(data)
  21934. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21935. resp, _ := client.Do(req)
  21936. defer resp.Body.Close()
  21937. body, ioErr := ioutil.ReadAll(resp.Body)
  21938. if ioErr != nil {
  21939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21941. return
  21942. }
  21943. var respJSON map[string]interface{}
  21944. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21947. return
  21948. }
  21949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21950. userJSONBytes, _ := json.Marshal(respJSON)
  21951. fmt.Println("log")
  21952. fmt.Println(string(userJSONBytes))
  21953. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21954. utils.ErrorLog("解析失败:%v", err)
  21955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21956. return
  21957. }
  21958. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21959. bytesData, _ := json.Marshal(data)
  21960. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21961. resp, _ := client.Do(req)
  21962. defer resp.Body.Close()
  21963. body, ioErr := ioutil.ReadAll(resp.Body)
  21964. if ioErr != nil {
  21965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21967. return
  21968. }
  21969. var respJSON map[string]interface{}
  21970. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21973. return
  21974. }
  21975. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21976. userJSONBytes, _ := json.Marshal(respJSON)
  21977. fmt.Println("log")
  21978. fmt.Println(string(userJSONBytes))
  21979. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21980. utils.ErrorLog("解析失败:%v", err)
  21981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21982. return
  21983. }
  21984. }else if miConfig.MdtrtareaAdmvs == "420902" {
  21985. bytesData, _ := json.Marshal(data)
  21986. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21987. resp, _ := client.Do(req)
  21988. defer resp.Body.Close()
  21989. body, ioErr := ioutil.ReadAll(resp.Body)
  21990. if ioErr != nil {
  21991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21993. return
  21994. }
  21995. var respJSON map[string]interface{}
  21996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21999. return
  22000. }
  22001. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22002. userJSONBytes, _ := json.Marshal(respJSON)
  22003. fmt.Println("log")
  22004. fmt.Println(string(userJSONBytes))
  22005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22006. utils.ErrorLog("解析失败:%v", err)
  22007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22008. return
  22009. }
  22010. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22011. bytesData, _ := json.Marshal(data)
  22012. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22013. resp, _ := client.Do(req)
  22014. defer resp.Body.Close()
  22015. body, ioErr := ioutil.ReadAll(resp.Body)
  22016. if ioErr != nil {
  22017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22019. return
  22020. }
  22021. var respJSON map[string]interface{}
  22022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22025. return
  22026. }
  22027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22028. userJSONBytes, _ := json.Marshal(respJSON)
  22029. fmt.Println("log")
  22030. fmt.Println(string(userJSONBytes))
  22031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22032. utils.ErrorLog("解析失败:%v", err)
  22033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22034. return
  22035. }
  22036. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22037. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22038. if result3101.Infcode == "0" {
  22039. if len(result3101.Output.Result) > 0 {
  22040. var errMsgs []string
  22041. for _, item := range result3101.Output.Result {
  22042. errMsgs = append(errMsgs, item.VolaCont)
  22043. }
  22044. c.ServeSuccessJSON(map[string]interface{}{
  22045. "failed_code": -10,
  22046. "msg": errMsgs,
  22047. })
  22048. return
  22049. } else {
  22050. if miConfig.MdtrtareaAdmvs == "320921" {
  22051. data["doctor_id"] = "D320923012139"
  22052. } else {
  22053. data["doctor_id"] = "D371621008686"
  22054. }
  22055. bytesData, _ := json.Marshal(data)
  22056. var req *http.Request
  22057. if miConfig.MdtrtareaAdmvs == "320921" {
  22058. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22059. } else {
  22060. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22061. }
  22062. resp, _ := client.Do(req)
  22063. defer resp.Body.Close()
  22064. body, ioErr := ioutil.ReadAll(resp.Body)
  22065. if ioErr != nil {
  22066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22068. return
  22069. }
  22070. var respJSON map[string]interface{}
  22071. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22074. return
  22075. }
  22076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22077. userJSONBytes, _ := json.Marshal(respJSON)
  22078. fmt.Println("log")
  22079. fmt.Println(string(userJSONBytes))
  22080. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22081. utils.ErrorLog("解析失败:%v", err)
  22082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22083. return
  22084. }
  22085. res.InfRefmsgid = resFour10265.InfRefmsgid
  22086. res.Output = resFour10265.Output
  22087. res.ErrMsg = resFour10265.ErrMsg
  22088. res.Cainfo = resFour10265.Cainfo
  22089. res.WarnMsg = resFour10265.WarnMsg
  22090. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22091. res.Infcode = infocode
  22092. }
  22093. }
  22094. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22095. var pagesize int = 5
  22096. var start int = 1
  22097. var stop int
  22098. var pagecount int
  22099. var curpage int
  22100. data["doctor_id"] = doctor_info.DoctorNumber
  22101. var res2 ResultFour
  22102. //var result res.
  22103. //总页数,向上取整,注意除之前要先转换类型为float64
  22104. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22105. for curpage = 1; curpage <= pagecount; curpage++ {
  22106. if curpage == 1 {
  22107. start = 1
  22108. } else {
  22109. start = (curpage-1)*pagesize + 1
  22110. }
  22111. stop = curpage * pagesize
  22112. if stop > len(prescriptions) {
  22113. stop = len(prescriptions)
  22114. }
  22115. //var requestLog string
  22116. data["pre"] = prescriptions[start-1 : stop]
  22117. fmt.Println(data["pre"])
  22118. bytesData, _ := json.Marshal(data)
  22119. var req *http.Request
  22120. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22121. resp, _ := client.Do(req)
  22122. defer resp.Body.Close()
  22123. body, ioErr := ioutil.ReadAll(resp.Body)
  22124. if ioErr != nil {
  22125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22127. return
  22128. }
  22129. var respJSON map[string]interface{}
  22130. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22133. return
  22134. }
  22135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22136. userJSONBytes, _ := json.Marshal(respJSON)
  22137. fmt.Println("log")
  22138. fmt.Println(string(userJSONBytes))
  22139. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22140. utils.ErrorLog("解析失败:%v", err)
  22141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22142. return
  22143. }
  22144. res.InfRefmsgid = resFour10265.InfRefmsgid
  22145. res.Output = resFour10265.Output
  22146. res.ErrMsg = resFour10265.ErrMsg
  22147. res.Cainfo = resFour10265.Cainfo
  22148. res.WarnMsg = resFour10265.WarnMsg
  22149. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22150. res.Infcode = infocode
  22151. if infocode == 0 {
  22152. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22153. } else {
  22154. isSuccess = false
  22155. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22156. res.Infcode = -1
  22157. res.ErrMsg = resFour10265.ErrMsg
  22158. errlog := &models.HisOrderError{
  22159. UserOrgId: adminUser.CurrentOrgId,
  22160. Ctime: time.Now().Unix(),
  22161. Mtime: time.Now().Unix(),
  22162. Number: chrg_bchno,
  22163. ErrMsg: "",
  22164. Status: 1,
  22165. PatientId: id,
  22166. RecordTime: recordDateTime,
  22167. Stage: 4,
  22168. }
  22169. service.CreateErrMsgLog(errlog)
  22170. }
  22171. }
  22172. if isSuccess {
  22173. res.Infcode = 0
  22174. res.Output.Result = res2.Output.Result
  22175. } else {
  22176. order := &models.HisOrder{
  22177. UserOrgId: adminUser.CurrentOrgId,
  22178. HisPatientId: his.ID,
  22179. PatientId: his.PatientId,
  22180. SettleAccountsDate: recordDateTime,
  22181. Ctime: time.Now().Unix(),
  22182. Mtime: time.Now().Unix(),
  22183. MdtrtId: his.Number,
  22184. PsnNo: his.PsnNo,
  22185. MedType: strconv.FormatInt(reg_type, 10),
  22186. Status: 1,
  22187. Number: chrg_bchno,
  22188. Infcode: res.Infcode,
  22189. WarnMsg: res.WarnMsg,
  22190. Cainfo: res.Cainfo,
  22191. ErrMsg: res.ErrMsg,
  22192. RespondTime: res.RefmsgTime,
  22193. InfRefmsgid: res.InfRefmsgid,
  22194. OrderStatus: 1,
  22195. IsMedicineInsurance: 1,
  22196. SettleType: settle_accounts_type,
  22197. SettleStartTime: start_time,
  22198. SettleEndTime: end_time,
  22199. Creator: roles.AdminUserId,
  22200. Modify: roles.AdminUserId,
  22201. PType: 2,
  22202. Diagnosis: diagnosis_id,
  22203. }
  22204. err = service.CreateOrder(order)
  22205. if err != nil {
  22206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22207. return
  22208. }
  22209. c.ServeSuccessJSON(map[string]interface{}{
  22210. "failed_code": -10,
  22211. "msg": res2.ErrMsg,
  22212. })
  22213. return
  22214. }
  22215. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22216. 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)
  22217. var dat map[string]interface{}
  22218. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22219. fmt.Println(dat)
  22220. } else {
  22221. fmt.Println(err)
  22222. }
  22223. saveLog(result, request_log, "2204", "上传费用明细")
  22224. userJSONBytes, _ := json.Marshal(dat)
  22225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22226. utils.ErrorLog("解析失败:%v", err)
  22227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22228. return
  22229. }
  22230. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22231. 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, "", "")
  22232. var dat map[string]interface{}
  22233. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22234. fmt.Println(dat)
  22235. } else {
  22236. fmt.Println(err)
  22237. }
  22238. saveLog(result, request_log, "2204", "上传费用明细")
  22239. userJSONBytes, _ := json.Marshal(dat)
  22240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22241. utils.ErrorLog("解析失败:%v", err)
  22242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22243. return
  22244. }
  22245. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22246. bytesData, _ := json.Marshal(data)
  22247. var req *http.Request
  22248. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22249. resp, _ := client.Do(req)
  22250. defer resp.Body.Close()
  22251. body, ioErr := ioutil.ReadAll(resp.Body)
  22252. if ioErr != nil {
  22253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22255. return
  22256. }
  22257. var respJSON map[string]interface{}
  22258. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22261. return
  22262. }
  22263. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22264. if status == "0" {
  22265. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22266. c.ServeSuccessJSON(map[string]interface{}{
  22267. "failed_code": -10,
  22268. "msg": err_msg,
  22269. })
  22270. return
  22271. }
  22272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22273. userJSONBytes, _ := json.Marshal(respJSON)
  22274. fmt.Println("log")
  22275. fmt.Println(string(userJSONBytes))
  22276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22277. utils.ErrorLog("解析失败:%v", err)
  22278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22279. return
  22280. }
  22281. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22282. 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, "", "")
  22283. var dat map[string]interface{}
  22284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22285. fmt.Println(dat)
  22286. } else {
  22287. fmt.Println(err)
  22288. }
  22289. saveLog(result, request_log, "2204", "上传费用明细")
  22290. userJSONBytes, _ := json.Marshal(dat)
  22291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22292. utils.ErrorLog("解析失败:%v", err)
  22293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22294. return
  22295. }
  22296. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22297. bytesData, _ := json.Marshal(data)
  22298. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22299. resp, _ := client.Do(req)
  22300. defer resp.Body.Close()
  22301. body, ioErr := ioutil.ReadAll(resp.Body)
  22302. if ioErr != nil {
  22303. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22305. return
  22306. }
  22307. var respJSON map[string]interface{}
  22308. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22311. return
  22312. }
  22313. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22314. userJSONBytes, _ := json.Marshal(respJSON)
  22315. fmt.Println("log")
  22316. fmt.Println(string(userJSONBytes))
  22317. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22318. utils.ErrorLog("解析失败:%v", err)
  22319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22320. return
  22321. }
  22322. } else {
  22323. if miConfig.MdtrtareaAdmvs == "441202" {
  22324. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22325. if result3101.Infcode == 0 {
  22326. if len(result3101.Output.Result) > 0 {
  22327. var errMsgs []string
  22328. for _, item := range result3101.Output.Result {
  22329. errMsgs = append(errMsgs, item.VolaCont)
  22330. }
  22331. c.ServeSuccessJSON(map[string]interface{}{
  22332. "failed_code": -10,
  22333. "msg": errMsgs,
  22334. })
  22335. return
  22336. } else {
  22337. 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)
  22338. var dat map[string]interface{}
  22339. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22340. fmt.Println(dat)
  22341. } else {
  22342. fmt.Println(err)
  22343. }
  22344. saveLog(result, request_log, "2204", "上传费用明细")
  22345. userJSONBytes, _ := json.Marshal(dat)
  22346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22347. utils.ErrorLog("解析失败:%v", err)
  22348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22349. return
  22350. }
  22351. }
  22352. } else {
  22353. c.ServeSuccessJSON(map[string]interface{}{
  22354. "failed_code": -10,
  22355. "msg": result3101.ErrMsg,
  22356. })
  22357. return
  22358. }
  22359. } else {
  22360. if miConfig.Code == "H15049901371" {
  22361. 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)
  22362. var dat map[string]interface{}
  22363. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22364. fmt.Println(dat)
  22365. } else {
  22366. fmt.Println(err)
  22367. }
  22368. saveLog(result, request_log, "2204", "上传费用明细")
  22369. userJSONBytes, _ := json.Marshal(dat)
  22370. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22371. utils.ErrorLog("解析失败:%v", err)
  22372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22373. return
  22374. }
  22375. res.InfRefmsgid = resFour10265.InfRefmsgid
  22376. res.Output = resFour10265.Output
  22377. res.ErrMsg = resFour10265.ErrMsg
  22378. res.Cainfo = resFour10265.Cainfo
  22379. res.WarnMsg = resFour10265.WarnMsg
  22380. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22381. res.Infcode = infocode
  22382. } else {
  22383. 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)
  22384. var dat map[string]interface{}
  22385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22386. fmt.Println(dat)
  22387. } else {
  22388. fmt.Println(err)
  22389. }
  22390. saveLog(result, request_log, "2204", "上传费用明细")
  22391. userJSONBytes, _ := json.Marshal(dat)
  22392. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22393. utils.ErrorLog("解析失败:%v", err)
  22394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22395. return
  22396. }
  22397. }
  22398. }
  22399. }
  22400. var total_two float64
  22401. if res.Infcode == 0 {
  22402. order := &models.HisOrder{
  22403. UserOrgId: adminUser.CurrentOrgId,
  22404. HisPatientId: his.ID,
  22405. PatientId: his.PatientId,
  22406. SettleAccountsDate: recordDateTime,
  22407. Ctime: time.Now().Unix(),
  22408. Mtime: time.Now().Unix(),
  22409. MdtrtId: his.Number,
  22410. PsnNo: his.PsnNo,
  22411. MedType: strconv.FormatInt(reg_type, 10),
  22412. Status: 1,
  22413. Number: chrg_bchno,
  22414. Infcode: res.Infcode,
  22415. WarnMsg: res.WarnMsg,
  22416. Cainfo: res.Cainfo,
  22417. ErrMsg: res.ErrMsg,
  22418. RespondTime: res.RefmsgTime,
  22419. InfRefmsgid: res.InfRefmsgid,
  22420. OrderStatus: 1,
  22421. IsMedicineInsurance: 1,
  22422. SettleType: settle_accounts_type,
  22423. SettleStartTime: start_time,
  22424. SettleEndTime: end_time,
  22425. Creator: roles.AdminUserId,
  22426. Modify: roles.AdminUserId,
  22427. PType: 2,
  22428. Diagnosis: diagnosis_id,
  22429. }
  22430. err = service.CreateOrder(order)
  22431. if err != nil {
  22432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22433. return
  22434. }
  22435. for _, item := range res.Output.Result {
  22436. temp := strings.Split(item.FeedetlSn, "-")
  22437. var advice_id int64 = 0
  22438. var project_id int64 = 0
  22439. var types int64 = 0
  22440. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22441. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22442. if temp[1] == "1" {
  22443. advice_id = id
  22444. project_id = 0
  22445. } else if temp[1] == "2" {
  22446. advice_id = 0
  22447. project_id = id
  22448. }
  22449. total_two = total_two + item.DetItemFeeSumamt
  22450. info := &models.HisOrderInfo{
  22451. OrderNumber: order.Number,
  22452. FeedetlSn: item.FeedetlSn,
  22453. UploadDate: time.Now().Unix(),
  22454. AdviceId: advice_id,
  22455. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22456. Cnt: item.Cnt,
  22457. Pric: float64(item.Pric),
  22458. PatientId: his.PatientId,
  22459. PricUplmtAmt: item.PricUplmtAmt,
  22460. SelfpayProp: item.SelfpayProp,
  22461. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22462. OverlmtAmt: item.OverlmtAmt,
  22463. PreselfpayAmt: item.PreselfpayAmt,
  22464. BasMednFlag: item.BasMednFlag,
  22465. MedChrgitmType: item.MedChrgitmType,
  22466. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22467. Status: 1,
  22468. Memo: item.Memo,
  22469. Mtime: time.Now().Unix(),
  22470. InscpScpAmt: item.InscpScpAmt,
  22471. DrtReimFlag: item.DrtReimFlag,
  22472. Ctime: time.Now().Unix(),
  22473. ListSpItemFlag: item.ListSpItemFlag,
  22474. ChldMedcFlag: item.ChldMedcFlag,
  22475. LmtUsedFlag: item.LmtUsedFlag,
  22476. ChrgitmLv: item.ChrgitmLv,
  22477. UserOrgId: adminUser.CurrentOrgId,
  22478. HisPatientId: his.ID,
  22479. OrderId: order.ID,
  22480. ProjectId: project_id,
  22481. Type: types,
  22482. }
  22483. service.CreateOrderInfo(info)
  22484. }
  22485. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22486. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22487. var total float64
  22488. for _, item := range prescriptions {
  22489. if item.Type == 1 { //药品
  22490. for _, subItem := range item.HisDoctorAdviceInfo {
  22491. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22492. total_one := price * subItem.PrescribingNumber
  22493. fmt.Println("subItem")
  22494. fmt.Println(subItem.Price)
  22495. fmt.Println("price")
  22496. fmt.Println(price)
  22497. fmt.Println("total_one")
  22498. fmt.Println(total_one)
  22499. total = total + total_one
  22500. fmt.Println(total)
  22501. }
  22502. }
  22503. if item.Type == 2 { //项目
  22504. for _, subItem := range item.HisPrescriptionProject {
  22505. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22506. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22507. total_one := price * cnt
  22508. total = total + total_one
  22509. }
  22510. }
  22511. }
  22512. allTotal := fmt.Sprintf("%.2f", total)
  22513. if res.Infcode == 0 {
  22514. var rf []*ResultFive
  22515. json.Unmarshal([]byte(his.Iinfo), &rf)
  22516. chrg_bchno := chrg_bchno
  22517. cert_no := his.Certno
  22518. var insutypes []string
  22519. var insutype string
  22520. var is390 int = 0
  22521. var is310 int = 0
  22522. for _, item := range rf {
  22523. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22524. insutypes = append(insutypes, item.Insutype)
  22525. }
  22526. }
  22527. if len(insutypes) == 1 {
  22528. insutype = insutypes[0]
  22529. } else {
  22530. for _, i := range insutypes {
  22531. if i == "390" {
  22532. is390 = 1
  22533. }
  22534. if i == "310" {
  22535. is310 = 1
  22536. }
  22537. }
  22538. }
  22539. if is390 == 1 {
  22540. insutype = "390"
  22541. }
  22542. if is310 == 1 {
  22543. insutype = "310"
  22544. }
  22545. if len(insutypes) == 0 {
  22546. insutype = "390"
  22547. }
  22548. if len(insutypes) == 2 {
  22549. insutype = strconv.FormatInt(his.SocialType, 10)
  22550. }
  22551. //insutype = "390"
  22552. if his.IdCardType == 1 {
  22553. cert_no = his.MedicalInsuranceNumber
  22554. } else {
  22555. cert_no = his.Certno
  22556. }
  22557. var res ResultSeven
  22558. var ahres ResultSevenAH
  22559. var resSeven10265 ResultSeven10265
  22560. var resSeven10265Two ResultSeven10265Two
  22561. var gzresSeven10265Two GZResultSeven10265Two
  22562. if miConfig.MdtrtareaAdmvs == "421300" {
  22563. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22564. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22565. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22566. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22567. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22568. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22569. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22570. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22571. resp, requestErr := http.Get(api)
  22572. if requestErr != nil {
  22573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22574. return
  22575. }
  22576. body, ioErr := ioutil.ReadAll(resp.Body)
  22577. if ioErr != nil {
  22578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22580. return
  22581. }
  22582. var respJSON map[string]interface{}
  22583. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22586. return
  22587. }
  22588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22589. result, _ := json.Marshal(respJSON)
  22590. fmt.Println("log")
  22591. fmt.Println(string(result))
  22592. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22593. utils.ErrorLog("解析失败:%v", err)
  22594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22595. return
  22596. }
  22597. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22598. if reg_type == 11 && his.Insutype == "390" {
  22599. reg_type = 110104
  22600. }
  22601. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22602. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22603. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22604. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22605. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22606. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22607. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22608. resp, requestErr := http.Get(api)
  22609. if requestErr != nil {
  22610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22611. return
  22612. }
  22613. body, ioErr := ioutil.ReadAll(resp.Body)
  22614. if ioErr != nil {
  22615. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22617. return
  22618. }
  22619. var respJSON map[string]interface{}
  22620. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22621. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22623. return
  22624. }
  22625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22626. result, _ := json.Marshal(respJSON)
  22627. fmt.Println("log")
  22628. fmt.Println(string(result))
  22629. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22630. utils.ErrorLog("解析失败:%v", err)
  22631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22632. return
  22633. }
  22634. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22635. if reg_type == 11 && his.Insutype == "390" {
  22636. reg_type = 110104
  22637. }
  22638. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22639. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22640. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22641. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22642. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22643. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22644. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22645. resp, requestErr := http.Get(api)
  22646. if requestErr != nil {
  22647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22648. return
  22649. }
  22650. body, ioErr := ioutil.ReadAll(resp.Body)
  22651. if ioErr != nil {
  22652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22654. return
  22655. }
  22656. var respJSON map[string]interface{}
  22657. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22660. return
  22661. }
  22662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22663. result, _ := json.Marshal(respJSON)
  22664. fmt.Println("log")
  22665. fmt.Println(string(result))
  22666. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22667. utils.ErrorLog("解析失败:%v", err)
  22668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22669. return
  22670. }
  22671. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22672. if reg_type == 11 && his.Insutype == "390" {
  22673. reg_type = 110104
  22674. }
  22675. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22676. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22677. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22678. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22679. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22680. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22681. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22682. resp, requestErr := http.Get(api)
  22683. if requestErr != nil {
  22684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22685. return
  22686. }
  22687. body, ioErr := ioutil.ReadAll(resp.Body)
  22688. if ioErr != nil {
  22689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22691. return
  22692. }
  22693. var respJSON map[string]interface{}
  22694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22697. return
  22698. }
  22699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22700. result, _ := json.Marshal(respJSON)
  22701. fmt.Println("log")
  22702. fmt.Println(string(result))
  22703. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22704. utils.ErrorLog("解析失败:%v", err)
  22705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22706. return
  22707. }
  22708. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22709. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22710. if result3101.Infcode == "0" {
  22711. if len(result3101.Output.Result) > 0 {
  22712. var errMsgs []string
  22713. for _, item := range result3101.Output.Result {
  22714. errMsgs = append(errMsgs, item.VolaCont)
  22715. }
  22716. c.ServeSuccessJSON(map[string]interface{}{
  22717. "failed_code": -10,
  22718. "msg": errMsgs,
  22719. })
  22720. return
  22721. } else {
  22722. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22723. if his.IdCardType != 4 {
  22724. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22725. bas := strings.Split(psn_info.CardInfo, "|")
  22726. if his.IdCardType == 1 {
  22727. cert_no = bas[2]
  22728. } else {
  22729. cert_no = bas[1]
  22730. }
  22731. } else {
  22732. cert_no = his.Certno
  22733. }
  22734. //江苏地区国家医保医疗类别
  22735. //职工透析:医疗类别选特殊情况门诊9933
  22736. //居民血透门慢: 医疗类别选门诊慢病1402
  22737. //var med_type string
  22738. //if his.Insutype == "310" {
  22739. // if reg_type == 14 {
  22740. // med_type = "9933"
  22741. // } else if reg_type == 11 {
  22742. // med_type = "11"
  22743. //
  22744. // }
  22745. //} else if his.Insutype == "390" {
  22746. // if reg_type == 14 {
  22747. // med_type = "1402"
  22748. // } else if reg_type == 11 {
  22749. // med_type = "11"
  22750. // }
  22751. //}
  22752. var api string
  22753. if miConfig.MdtrtareaAdmvs == "320921" {
  22754. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22755. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22756. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22757. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22758. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22759. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22760. "&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
  22761. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22762. } else {
  22763. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22764. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22765. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22766. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22767. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22768. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22769. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22770. "&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
  22771. }
  22772. resp, requestErr := http.Get(api)
  22773. if requestErr != nil {
  22774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22775. return
  22776. }
  22777. body, ioErr := ioutil.ReadAll(resp.Body)
  22778. if ioErr != nil {
  22779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22781. return
  22782. }
  22783. var respJSON map[string]interface{}
  22784. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22787. return
  22788. }
  22789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22790. result, _ := json.Marshal(respJSON)
  22791. fmt.Println("log")
  22792. fmt.Println(string(result))
  22793. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22794. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22795. utils.ErrorLog("解析失败:%v", err)
  22796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22797. return
  22798. }
  22799. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22800. res.Output = resSeven10265.Output
  22801. res.ErrMsg = resSeven10265.ErrMsg
  22802. res.Cainfo = resSeven10265.Cainfo
  22803. res.WarnMsg = resSeven10265.WarnMsg
  22804. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22805. res.Infcode = infocode
  22806. } else {
  22807. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22808. utils.ErrorLog("解析失败:%v", err)
  22809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22810. return
  22811. }
  22812. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22813. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22814. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22815. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22816. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22817. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22818. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22819. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22820. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22821. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22822. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22823. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22824. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22825. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22826. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22827. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22828. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22829. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22830. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22831. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22832. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22833. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22834. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22835. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22836. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22837. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22838. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22839. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22840. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22841. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22842. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22843. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22844. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22845. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22846. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22847. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22848. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22849. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22850. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22851. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22852. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22853. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22854. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22855. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22856. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22857. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22858. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22859. res.ErrMsg = resSeven10265Two.ErrMsg
  22860. res.Cainfo = resSeven10265Two.Cainfo
  22861. res.WarnMsg = resSeven10265Two.WarnMsg
  22862. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22863. res.Infcode = infocode
  22864. }
  22865. }
  22866. }
  22867. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22868. psn_info, _ := service.GetPsnByPatientId(id)
  22869. var verify_number string
  22870. if psn_info.IdCardType == 4 {
  22871. verify_number = psn_info.VerifyNumber
  22872. } else if psn_info.IdCardType == 1 {
  22873. bas := strings.Split(psn_info.CardInfo, "|")
  22874. cardNumber := bas[2]
  22875. verify_number = cardNumber
  22876. } else {
  22877. psn_info.IdCardType = 2
  22878. verify_number = psn_info.Certno
  22879. }
  22880. var api string
  22881. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22882. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22883. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22885. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22886. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22887. "&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
  22888. resp, requestErr := http.Get(api)
  22889. if requestErr != nil {
  22890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22891. return
  22892. }
  22893. body, ioErr := ioutil.ReadAll(resp.Body)
  22894. if ioErr != nil {
  22895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22897. return
  22898. }
  22899. var respJSON map[string]interface{}
  22900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22903. return
  22904. }
  22905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22906. result, _ := json.Marshal(respJSON)
  22907. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22908. utils.ErrorLog("解析失败:%v", err)
  22909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22910. return
  22911. }
  22912. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22913. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22914. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22915. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22916. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22917. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22918. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22919. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22920. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22921. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22922. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22923. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22924. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22925. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22926. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22927. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22928. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22929. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22930. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22931. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22932. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22933. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22934. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22935. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22936. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22937. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22938. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22939. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22940. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22941. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22942. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22943. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22944. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22945. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22946. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22947. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22948. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22949. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22950. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22951. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22952. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22953. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22954. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22955. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22956. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22957. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22958. res.ErrMsg = resSeven10265.ErrMsg
  22959. res.Cainfo = resSeven10265.Cainfo
  22960. res.WarnMsg = resSeven10265.WarnMsg
  22961. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22962. res.Infcode = infocode
  22963. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22964. acct_used_flag := "1"
  22965. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22966. var result string
  22967. var request_log string
  22968. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22969. 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)
  22970. } else {
  22971. 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)
  22972. }
  22973. var dat map[string]interface{}
  22974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22975. fmt.Println(dat)
  22976. } else {
  22977. fmt.Println(err)
  22978. }
  22979. saveLog(result, request_log, "2206", "预结算")
  22980. userJSONBytes, _ := json.Marshal(dat)
  22981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22982. utils.ErrorLog("解析失败:%v", err)
  22983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22984. return
  22985. }
  22986. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22987. var result string
  22988. var request_log string
  22989. if his.IdCardType == 2 {
  22990. 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, "")
  22991. } else if his.IdCardType == 1 {
  22992. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22993. bas := strings.Split(psn_info.CardInfo, "|")
  22994. basNumber := bas[2]
  22995. card_sn := bas[3]
  22996. var rf []*ResultFive
  22997. json.Unmarshal([]byte(his.Iinfo), &rf)
  22998. var psn_type string
  22999. for _, item := range rf {
  23000. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23001. psn_type = item.PsnType
  23002. }
  23003. }
  23004. 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)
  23005. } else {
  23006. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23007. 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, "")
  23008. }
  23009. var dat map[string]interface{}
  23010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23011. fmt.Println(dat)
  23012. } else {
  23013. fmt.Println(err)
  23014. }
  23015. saveLog(result, request_log, "2206", "预结算")
  23016. userJSONBytes, _ := json.Marshal(dat)
  23017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23018. utils.ErrorLog("解析失败:%v", err)
  23019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23020. return
  23021. }
  23022. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23023. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23024. if his.IdCardType == 4 {
  23025. psn_info.VerifyNumber = psn_info.VerifyNumber
  23026. cert_no = psn_info.Certno
  23027. } else if his.IdCardType == 2 {
  23028. cert_no = psn_info.Certno
  23029. psn_info.VerifyNumber = psn_info.Certno
  23030. } else {
  23031. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23032. bas := strings.Split(psn_info.CardInfo, "|")
  23033. if his.IdCardType == 1 {
  23034. cert_no = bas[2]
  23035. } else {
  23036. cert_no = bas[1]
  23037. }
  23038. }
  23039. var api string
  23040. var med_type string
  23041. if his.Insutype == "390" {
  23042. if reg_type == 992102 {
  23043. med_type = "992102"
  23044. }
  23045. if reg_type == 140104 {
  23046. med_type = "140104"
  23047. }
  23048. if reg_type == 14 {
  23049. med_type = "140104"
  23050. }
  23051. } else if his.Insutype == "310" {
  23052. if reg_type == 992102 {
  23053. med_type = "992102"
  23054. }
  23055. if reg_type == 14 {
  23056. med_type = "14"
  23057. }
  23058. }
  23059. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23065. "&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
  23066. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23067. resp, requestErr := http.Get(api)
  23068. if requestErr != nil {
  23069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23070. return
  23071. }
  23072. body, ioErr := ioutil.ReadAll(resp.Body)
  23073. if ioErr != nil {
  23074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23076. return
  23077. }
  23078. var respJSON map[string]interface{}
  23079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23082. return
  23083. }
  23084. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23085. if status == "0" {
  23086. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23087. c.ServeSuccessJSON(map[string]interface{}{
  23088. "failed_code": -10,
  23089. "msg": err_msg,
  23090. })
  23091. return
  23092. }
  23093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23094. result, _ := json.Marshal(respJSON)
  23095. fmt.Println("log")
  23096. fmt.Println(string(result))
  23097. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23098. utils.ErrorLog("解析失败:%v", err)
  23099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23100. return
  23101. }
  23102. res.InfRefmsgid = ahres.InfRefmsgid
  23103. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23104. // 创建对应的Time类型
  23105. t := time.UnixMilli(timestamp)
  23106. // 格式化成指定的日期字符串
  23107. str := t.Format("2006-01-02 15:04:05")
  23108. res.Output.Setlinfo.SetlTime = str
  23109. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23110. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23111. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23112. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23113. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23114. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23115. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23116. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23117. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23118. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23119. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23120. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23121. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23122. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23123. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23124. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23125. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23126. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23127. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23128. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23129. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23130. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23131. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23132. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23133. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23134. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23135. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23136. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23137. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23138. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23139. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23140. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23141. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23142. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23143. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23144. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23145. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23146. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23147. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23148. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23149. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23150. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23151. //res.Output.Setldetail = ahres.Output.Setldetail
  23152. res.ErrMsg = ahres.ErrMsg
  23153. res.Cainfo = ahres.Cainfo
  23154. res.WarnMsg = ahres.WarnMsg
  23155. res.Infcode = ahres.Infcode
  23156. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23157. var result string
  23158. var request_log string
  23159. if his.IdCardType == 2 {
  23160. 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")
  23161. } else if his.IdCardType == 1 {
  23162. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23163. bas := strings.Split(psn_info.CardInfo, "|")
  23164. basNumber := bas[2]
  23165. card_sn := bas[3]
  23166. 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")
  23167. } else {
  23168. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23169. 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")
  23170. }
  23171. var dat map[string]interface{}
  23172. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23173. fmt.Println(dat)
  23174. } else {
  23175. fmt.Println(err)
  23176. }
  23177. saveLog(result, request_log, "2206", "预结算")
  23178. userJSONBytes, _ := json.Marshal(dat)
  23179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23180. utils.ErrorLog("解析失败:%v", err)
  23181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23182. return
  23183. }
  23184. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23185. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23186. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23187. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23189. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23190. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23191. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23192. resp, requestErr := http.Get(api)
  23193. if requestErr != nil {
  23194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23195. return
  23196. }
  23197. body, ioErr := ioutil.ReadAll(resp.Body)
  23198. if ioErr != nil {
  23199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23201. return
  23202. }
  23203. var respJSON map[string]interface{}
  23204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23207. return
  23208. }
  23209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23210. result, _ := json.Marshal(respJSON)
  23211. fmt.Println("log")
  23212. fmt.Println(string(result))
  23213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23214. utils.ErrorLog("解析失败:%v", err)
  23215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23216. return
  23217. }
  23218. } else {
  23219. if miConfig.MdtrtareaAdmvs == "441202" {
  23220. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23221. if result3101.Infcode == 0 {
  23222. if len(result3101.Output.Result) > 0 {
  23223. var errMsgs []string
  23224. for _, item := range result3101.Output.Result {
  23225. errMsgs = append(errMsgs, item.VolaCont)
  23226. }
  23227. c.ServeSuccessJSON(map[string]interface{}{
  23228. "failed_code": -10,
  23229. "msg": errMsgs,
  23230. })
  23231. return
  23232. } else {
  23233. var result string
  23234. var request_log string
  23235. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23236. allTotal = fmt.Sprintf("%.2f", total_two)
  23237. if his.IdCardType == 4 {
  23238. 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)
  23239. } else {
  23240. 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)
  23241. }
  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, request_log, "2206", "预结算")
  23249. //userJSONBytes, _ := json.Marshal(dat)
  23250. //
  23251. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23252. // utils.ErrorLog("解析失败:%v", err)
  23253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23254. // return
  23255. //}
  23256. userJSONBytes, _ := json.Marshal(dat)
  23257. if miConfig.Code == "H15049901371" {
  23258. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23259. utils.ErrorLog("解析失败:%v", err)
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23261. return
  23262. }
  23263. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23264. res.Output = resSeven10265.Output
  23265. res.ErrMsg = resSeven10265.ErrMsg
  23266. res.Cainfo = resSeven10265.Cainfo
  23267. res.WarnMsg = resSeven10265.WarnMsg
  23268. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23269. res.Infcode = infocode
  23270. } else {
  23271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23272. utils.ErrorLog("解析失败:%v", err)
  23273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23274. return
  23275. }
  23276. }
  23277. }
  23278. } else {
  23279. c.ServeSuccessJSON(map[string]interface{}{
  23280. "failed_code": -10,
  23281. "msg": result3101.ErrMsg,
  23282. })
  23283. return
  23284. }
  23285. } else {
  23286. var result string
  23287. var request_log string
  23288. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23289. allTotal = fmt.Sprintf("%.2f", total_two)
  23290. if his.IdCardType == 4 {
  23291. 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)
  23292. } else {
  23293. 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)
  23294. }
  23295. var dat map[string]interface{}
  23296. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23297. fmt.Println(dat)
  23298. } else {
  23299. fmt.Println(err)
  23300. }
  23301. saveLog(result, request_log, "2206", "预结算")
  23302. //userJSONBytes, _ := json.Marshal(dat)
  23303. //
  23304. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23305. // utils.ErrorLog("解析失败:%v", err)
  23306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23307. // return
  23308. //}
  23309. userJSONBytes, _ := json.Marshal(dat)
  23310. if miConfig.Code == "H15049901371" {
  23311. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23312. utils.ErrorLog("解析失败:%v", err)
  23313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23314. return
  23315. }
  23316. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23317. res.Output = resSeven10265.Output
  23318. res.ErrMsg = resSeven10265.ErrMsg
  23319. res.Cainfo = resSeven10265.Cainfo
  23320. res.WarnMsg = resSeven10265.WarnMsg
  23321. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23322. res.Infcode = infocode
  23323. } else {
  23324. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23325. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23326. utils.ErrorLog("解析失败:%v", err)
  23327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23328. return
  23329. }
  23330. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23331. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23332. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23333. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23334. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23335. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23336. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23337. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23338. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23339. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23340. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23341. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23342. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23343. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23344. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23345. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23346. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23347. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23348. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23349. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23350. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23351. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23352. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23353. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23354. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23355. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23356. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23357. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23358. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23359. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23360. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23361. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23362. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23363. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23364. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23365. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23366. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23367. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23368. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23369. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23370. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23371. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23372. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23373. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23374. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23375. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23376. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23377. res.Cainfo = gzresSeven10265Two.Cainfo
  23378. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23379. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23380. //res.Infcode = infocode
  23381. } else {
  23382. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23383. utils.ErrorLog("解析失败:%v", err)
  23384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23385. return
  23386. }
  23387. }
  23388. }
  23389. }
  23390. }
  23391. utils.ErrorLog("解析失败:%v", res.Infcode)
  23392. if res.Infcode == -1 {
  23393. errlog := &models.HisOrderError{
  23394. UserOrgId: adminUser.CurrentOrgId,
  23395. Ctime: time.Now().Unix(),
  23396. Mtime: time.Now().Unix(),
  23397. Number: chrg_bchno,
  23398. ErrMsg: res.ErrMsg,
  23399. Status: 1,
  23400. PatientId: id,
  23401. RecordTime: recordDateTime,
  23402. Stage: 20,
  23403. }
  23404. service.CreateErrMsgLog(errlog)
  23405. c.ServeSuccessJSON(map[string]interface{}{
  23406. "failed_code": -10,
  23407. "msg": res.ErrMsg,
  23408. })
  23409. return
  23410. }
  23411. if res.Infcode != 0 {
  23412. errlog := &models.HisOrderError{
  23413. UserOrgId: adminUser.CurrentOrgId,
  23414. Ctime: time.Now().Unix(),
  23415. Mtime: time.Now().Unix(),
  23416. Number: chrg_bchno,
  23417. ErrMsg: res.ErrMsg,
  23418. Status: 1,
  23419. PatientId: id,
  23420. RecordTime: recordDateTime,
  23421. Stage: 20,
  23422. }
  23423. service.CreateErrMsgLog(errlog)
  23424. c.ServeSuccessJSON(map[string]interface{}{
  23425. "failed_code": -10,
  23426. "msg": res.ErrMsg,
  23427. })
  23428. return
  23429. } else {
  23430. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23431. order.OrderStatus = 1
  23432. order.IsPre = 1
  23433. order.Status = 1
  23434. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23435. order.SetlId = res.Output.Setlinfo.SetlID
  23436. order.PsnNo = res.Output.Setlinfo.PsnNo
  23437. order.PsnName = res.Output.Setlinfo.PsnName
  23438. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23439. order.Certno = res.Output.Setlinfo.Certno
  23440. order.Gend = res.Output.Setlinfo.Gend
  23441. order.Naty = res.Output.Setlinfo.Naty
  23442. order.Age = res.Output.Setlinfo.Age
  23443. order.Insutype = res.Output.Setlinfo.Insutype
  23444. order.PsnType = res.Output.Setlinfo.PsnType
  23445. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23446. order.SetlTime = res.Output.Setlinfo.SetlTime
  23447. order.AcctUsedFlag = acct_used_flag
  23448. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23449. if res.Output.Setlinfo.MedType == "140101" {
  23450. order.MedType = "14"
  23451. } else {
  23452. if res.Output.Setlinfo.MedType == "110104" {
  23453. order.MedType = "11"
  23454. } else {
  23455. order.MedType = res.Output.Setlinfo.MedType
  23456. }
  23457. }
  23458. if res.Output.Setlinfo.MedType == "992102" {
  23459. order.MedType = "992102"
  23460. }
  23461. if res.Output.Setlinfo.MedType == "140104" {
  23462. order.MedType = "140104"
  23463. }
  23464. if res.Output.Setlinfo.MedType == "14" {
  23465. order.MedType = "14"
  23466. }
  23467. if reg_type == 1112 {
  23468. order.MedType = "1112"
  23469. }
  23470. if reg_type == 1111 {
  23471. order.MedType = "1111"
  23472. }
  23473. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23474. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23475. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23476. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23477. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23478. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23479. order.HifpPay = res.Output.Setlinfo.HifpPay
  23480. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23481. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23482. order.HifesPay = res.Output.Setlinfo.HifesPay
  23483. order.HifobPay = res.Output.Setlinfo.HifobPay
  23484. order.MafPay = res.Output.Setlinfo.MafPay
  23485. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23486. order.OthPay = res.Output.Setlinfo.OthPay
  23487. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23488. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23489. order.AcctPay = res.Output.Setlinfo.AcctPay
  23490. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23491. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23492. order.Balc = res.Output.Setlinfo.Balc
  23493. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23494. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23495. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23496. order.ClrWay = res.Output.Setlinfo.ClrWay
  23497. order.Creator = order.Creator
  23498. order.Modify = roles.AdminUserId
  23499. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23500. //detailStr := string(setlDetail)
  23501. //order.SetlDetail = detailStr
  23502. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23503. err = service.UpDateOrder(order)
  23504. if err == nil {
  23505. c.ServeSuccessJSON(map[string]interface{}{
  23506. "msg": "预结算成功",
  23507. })
  23508. } else {
  23509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23510. return
  23511. }
  23512. }
  23513. } else {
  23514. adminUser := c.GetAdminUserInfo()
  23515. errlog := &models.HisOrderError{
  23516. UserOrgId: adminUser.CurrentOrgId,
  23517. Ctime: time.Now().Unix(),
  23518. Mtime: time.Now().Unix(),
  23519. ErrMsg: res.ErrMsg,
  23520. Status: 1,
  23521. PatientId: id,
  23522. RecordTime: recordDateTime,
  23523. Stage: 4,
  23524. }
  23525. service.CreateErrMsgLog(errlog)
  23526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23527. return
  23528. }
  23529. } else {
  23530. if miConfig.MdtrtareaAdmvs == "150499" {
  23531. order := &models.HisOrder{
  23532. UserOrgId: adminUser.CurrentOrgId,
  23533. HisPatientId: his.ID,
  23534. PatientId: his.PatientId,
  23535. SettleAccountsDate: recordDateTime,
  23536. Ctime: time.Now().Unix(),
  23537. Mtime: time.Now().Unix(),
  23538. MdtrtId: his.Number,
  23539. PsnNo: his.PsnNo,
  23540. MedType: strconv.FormatInt(reg_type, 10),
  23541. Status: 1,
  23542. Number: chrg_bchno,
  23543. Infcode: res.Infcode,
  23544. WarnMsg: res.WarnMsg,
  23545. Cainfo: res.Cainfo,
  23546. ErrMsg: res.ErrMsg,
  23547. RespondTime: res.RefmsgTime,
  23548. InfRefmsgid: res.InfRefmsgid,
  23549. OrderStatus: 1,
  23550. IsMedicineInsurance: 1,
  23551. SettleType: settle_accounts_type,
  23552. SettleStartTime: start_time,
  23553. SettleEndTime: end_time,
  23554. Creator: roles.AdminUserId,
  23555. Modify: roles.AdminUserId,
  23556. PType: 2,
  23557. Diagnosis: diagnosis_id,
  23558. }
  23559. err = service.CreateOrder(order)
  23560. if err != nil {
  23561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23562. return
  23563. }
  23564. }
  23565. adminUser := c.GetAdminUserInfo()
  23566. errlog := &models.HisOrderError{
  23567. UserOrgId: adminUser.CurrentOrgId,
  23568. Ctime: time.Now().Unix(),
  23569. Mtime: time.Now().Unix(),
  23570. ErrMsg: res.ErrMsg,
  23571. Status: 1,
  23572. PatientId: id,
  23573. RecordTime: recordDateTime,
  23574. Stage: 4,
  23575. }
  23576. service.CreateErrMsgLog(errlog)
  23577. c.ServeSuccessJSON(map[string]interface{}{
  23578. "failed_code": -10,
  23579. "msg": res.ErrMsg,
  23580. })
  23581. return
  23582. }
  23583. }
  23584. }
  23585. }
  23586. // 退款
  23587. func (c *HisApiController) Refund() {
  23588. order_id, _ := c.GetInt64("order_id")
  23589. admin_user_id, _ := c.GetInt64("admin_user_id")
  23590. adminUser := c.GetAdminUserInfo()
  23591. var order models.HisOrder
  23592. order, _ = service.GetHisOrderByID(order_id)
  23593. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23594. if order.ID == 0 {
  23595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23596. return
  23597. }
  23598. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23599. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23600. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23601. if config.IsOpen == 1 { //对接了医保,走医保流程
  23602. var res ResultSixteen
  23603. var ahres ResultSevenAH
  23604. var resSixteen10265 ResultSixteen10265
  23605. var resSixteen10265Two ResultSixteen10265Two
  23606. var gz ResultgzSixteen10265Two
  23607. var src_resquest string
  23608. var result string
  23609. if miConfig.MdtrtareaAdmvs == "421300" {
  23610. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23611. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23612. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23613. resp3, requestErr3 := http.Get(api3)
  23614. if requestErr3 != nil {
  23615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23616. return
  23617. }
  23618. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23619. if ioErr3 != nil {
  23620. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23622. return
  23623. }
  23624. var respJSON3 map[string]interface{}
  23625. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23626. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23628. return
  23629. }
  23630. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23631. userJSONBytes3, _ := json.Marshal(respJSON3)
  23632. fmt.Println("log")
  23633. fmt.Println(string(userJSONBytes3))
  23634. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23635. utils.ErrorLog("解析失败:%v", err)
  23636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23637. return
  23638. }
  23639. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23640. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23641. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23642. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23643. resp3, requestErr3 := http.Get(api3)
  23644. if requestErr3 != nil {
  23645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23646. return
  23647. }
  23648. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23649. if ioErr3 != nil {
  23650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23652. return
  23653. }
  23654. var respJSON3 map[string]interface{}
  23655. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23658. return
  23659. }
  23660. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23661. userJSONBytes3, _ := json.Marshal(respJSON3)
  23662. fmt.Println("log")
  23663. fmt.Println(string(userJSONBytes3))
  23664. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23665. utils.ErrorLog("解析失败:%v", err)
  23666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23667. return
  23668. }
  23669. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23670. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23671. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23672. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23673. resp3, requestErr3 := http.Get(api3)
  23674. if requestErr3 != nil {
  23675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23676. return
  23677. }
  23678. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23679. if ioErr3 != nil {
  23680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23682. return
  23683. }
  23684. var respJSON3 map[string]interface{}
  23685. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23688. return
  23689. }
  23690. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23691. userJSONBytes3, _ := json.Marshal(respJSON3)
  23692. fmt.Println("log")
  23693. fmt.Println(string(userJSONBytes3))
  23694. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23695. utils.ErrorLog("解析失败:%v", err)
  23696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23697. return
  23698. }
  23699. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23700. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23701. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23702. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23703. resp3, requestErr3 := http.Get(api3)
  23704. if requestErr3 != nil {
  23705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23706. return
  23707. }
  23708. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23709. if ioErr3 != nil {
  23710. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23712. return
  23713. }
  23714. var respJSON3 map[string]interface{}
  23715. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23716. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23718. return
  23719. }
  23720. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23721. userJSONBytes3, _ := json.Marshal(respJSON3)
  23722. fmt.Println("log")
  23723. fmt.Println(string(userJSONBytes3))
  23724. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23725. utils.ErrorLog("解析失败:%v", err)
  23726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23727. return
  23728. }
  23729. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23730. var api3 string
  23731. if miConfig.MdtrtareaAdmvs == "320921" {
  23732. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23733. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23734. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23735. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23736. } else {
  23737. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23738. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23739. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23741. }
  23742. resp3, requestErr3 := http.Get(api3)
  23743. if requestErr3 != nil {
  23744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23745. return
  23746. }
  23747. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23748. if ioErr3 != nil {
  23749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23751. return
  23752. }
  23753. var respJSON3 map[string]interface{}
  23754. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23757. return
  23758. }
  23759. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23760. userJSONBytes3, _ := json.Marshal(respJSON3)
  23761. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23762. utils.ErrorLog("解析失败:%v", err)
  23763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23764. return
  23765. }
  23766. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23767. res.Output = resSixteen10265.Output
  23768. res.ErrMsg = resSixteen10265.ErrMsg
  23769. res.Cainfo = resSixteen10265.Cainfo
  23770. res.WarnMsg = resSixteen10265.WarnMsg
  23771. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23772. res.Infcode = infocode
  23773. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23774. var api3 string
  23775. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23776. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23777. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23778. resp3, requestErr3 := http.Get(api3)
  23779. if requestErr3 != nil {
  23780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23781. return
  23782. }
  23783. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23784. if ioErr3 != nil {
  23785. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23787. return
  23788. }
  23789. var respJSON3 map[string]interface{}
  23790. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23791. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23793. return
  23794. }
  23795. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23796. userJSONBytes3, _ := json.Marshal(respJSON3)
  23797. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23798. utils.ErrorLog("解析失败:%v", err)
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23803. res.Output = resSixteen10265.Output
  23804. res.ErrMsg = resSixteen10265.ErrMsg
  23805. res.Cainfo = resSixteen10265.Cainfo
  23806. res.WarnMsg = resSixteen10265.WarnMsg
  23807. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23808. res.Infcode = infocode
  23809. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23810. 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)
  23811. var dat map[string]interface{}
  23812. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23813. fmt.Println(dat)
  23814. } else {
  23815. fmt.Println(err)
  23816. }
  23817. saveLog(result, src_resquest, "2208", "退费")
  23818. userJSONBytes, _ := json.Marshal(dat)
  23819. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23820. utils.ErrorLog("解析失败:%v", err)
  23821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23822. return
  23823. }
  23824. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23825. 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, "")
  23826. var dat map[string]interface{}
  23827. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23828. fmt.Println(dat)
  23829. } else {
  23830. fmt.Println(err)
  23831. }
  23832. saveLog(result, src_resquest, "2208", "退费")
  23833. userJSONBytes, _ := json.Marshal(dat)
  23834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23835. utils.ErrorLog("解析失败:%v", err)
  23836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23837. return
  23838. }
  23839. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23840. var api3 string
  23841. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23842. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23843. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23844. resp3, requestErr3 := http.Get(api3)
  23845. if requestErr3 != nil {
  23846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23847. return
  23848. }
  23849. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23850. if ioErr3 != nil {
  23851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. var respJSON3 map[string]interface{}
  23856. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23859. return
  23860. }
  23861. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23862. if status == "0" {
  23863. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23864. c.ServeSuccessJSON(map[string]interface{}{
  23865. "failed_code": -10,
  23866. "msg": err_msg,
  23867. })
  23868. return
  23869. }
  23870. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23871. userJSONBytes3, _ := json.Marshal(respJSON3)
  23872. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23873. // utils.ErrorLog("解析失败:%v", err)
  23874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23875. // return
  23876. //}
  23877. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23878. utils.ErrorLog("解析失败:%v", err)
  23879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23880. return
  23881. }
  23882. res.InfRefmsgid = ahres.InfRefmsgid
  23883. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23884. // 创建对应的Time类型
  23885. t := time.UnixMilli(timestamp)
  23886. // 格式化成指定的日期字符串
  23887. str := t.Format("2006-01-02 15:04:05")
  23888. res.Output.Setlinfo.SetlTime = str
  23889. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23890. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23891. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23892. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23893. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23894. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23895. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23896. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23897. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23898. //
  23899. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23900. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23901. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23902. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23903. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23904. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23905. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23906. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23907. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23908. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23909. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23910. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23911. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23912. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23913. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23914. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23915. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23916. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23917. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23918. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23919. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23920. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23921. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23922. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23923. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23924. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23925. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23926. //res.Output.Setldetail = ahres.Output.Setldetail
  23927. res.ErrMsg = ahres.ErrMsg
  23928. res.Cainfo = ahres.Cainfo
  23929. res.WarnMsg = ahres.WarnMsg
  23930. res.Infcode = ahres.Infcode
  23931. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23932. 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, "")
  23933. var dat map[string]interface{}
  23934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23935. fmt.Println(dat)
  23936. } else {
  23937. fmt.Println(err)
  23938. }
  23939. saveLog(result, src_resquest, "2208", "退费")
  23940. userJSONBytes, _ := json.Marshal(dat)
  23941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23942. utils.ErrorLog("解析失败:%v", err)
  23943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23944. return
  23945. }
  23946. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23947. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23948. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23949. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23950. resp3, requestErr3 := http.Get(api3)
  23951. if requestErr3 != nil {
  23952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23953. return
  23954. }
  23955. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23956. if ioErr3 != nil {
  23957. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23959. return
  23960. }
  23961. var respJSON3 map[string]interface{}
  23962. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23963. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23965. return
  23966. }
  23967. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23968. userJSONBytes3, _ := json.Marshal(respJSON3)
  23969. fmt.Println("log")
  23970. fmt.Println(string(userJSONBytes3))
  23971. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23972. utils.ErrorLog("解析失败:%v", err)
  23973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23974. return
  23975. }
  23976. } else {
  23977. if miConfig.Code == "H15049901371" {
  23978. 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)
  23979. var dat map[string]interface{}
  23980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23981. fmt.Println(dat)
  23982. } else {
  23983. fmt.Println(err)
  23984. }
  23985. saveLog(result, src_resquest, "2208", "退费")
  23986. userJSONBytes, _ := json.Marshal(dat)
  23987. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23993. res.Output = resSixteen10265.Output
  23994. res.ErrMsg = resSixteen10265.ErrMsg
  23995. res.Cainfo = resSixteen10265.Cainfo
  23996. res.WarnMsg = resSixteen10265.WarnMsg
  23997. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23998. res.Infcode = infocode
  23999. } else {
  24000. 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)
  24001. var dat map[string]interface{}
  24002. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24003. fmt.Println(dat)
  24004. } else {
  24005. fmt.Println(err)
  24006. }
  24007. saveLog(result, src_resquest, "2208", "退费")
  24008. userJSONBytes, _ := json.Marshal(dat)
  24009. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24010. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24011. utils.ErrorLog("解析失败:%v", err)
  24012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24013. return
  24014. }
  24015. res.Infcode = gz.Infcode
  24016. } else {
  24017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24018. utils.ErrorLog("解析失败:%v", err)
  24019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24020. return
  24021. }
  24022. }
  24023. }
  24024. }
  24025. if res.Infcode == 0 {
  24026. var res2 ResultSix
  24027. var resSix10265 ResultSix10265
  24028. if miConfig.MdtrtareaAdmvs == "421300" {
  24029. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24030. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24031. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24032. resp3, requestErr3 := http.Get(api3)
  24033. if requestErr3 != nil {
  24034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24035. return
  24036. }
  24037. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24038. if ioErr3 != nil {
  24039. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24041. return
  24042. }
  24043. var respJSON3 map[string]interface{}
  24044. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24045. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24047. return
  24048. }
  24049. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24050. userJSONBytes3, _ := json.Marshal(respJSON3)
  24051. fmt.Println("log")
  24052. fmt.Println(string(userJSONBytes3))
  24053. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24054. utils.ErrorLog("解析失败:%v", err)
  24055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24056. return
  24057. }
  24058. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24059. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24060. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24061. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24062. resp3, requestErr3 := http.Get(api3)
  24063. if requestErr3 != nil {
  24064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24065. return
  24066. }
  24067. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24068. if ioErr3 != nil {
  24069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24071. return
  24072. }
  24073. var respJSON3 map[string]interface{}
  24074. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24077. return
  24078. }
  24079. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24080. userJSONBytes3, _ := json.Marshal(respJSON3)
  24081. fmt.Println("log")
  24082. fmt.Println(string(userJSONBytes3))
  24083. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24084. utils.ErrorLog("解析失败:%v", err)
  24085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24086. return
  24087. }
  24088. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24089. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24090. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24092. resp3, requestErr3 := http.Get(api3)
  24093. if requestErr3 != nil {
  24094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24095. return
  24096. }
  24097. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24098. if ioErr3 != nil {
  24099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24101. return
  24102. }
  24103. var respJSON3 map[string]interface{}
  24104. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24107. return
  24108. }
  24109. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24110. userJSONBytes3, _ := json.Marshal(respJSON3)
  24111. fmt.Println("log")
  24112. fmt.Println(string(userJSONBytes3))
  24113. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24114. utils.ErrorLog("解析失败:%v", err)
  24115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24116. return
  24117. }
  24118. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24119. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24120. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24121. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24122. resp3, requestErr3 := http.Get(api3)
  24123. if requestErr3 != nil {
  24124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24125. return
  24126. }
  24127. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24128. if ioErr3 != nil {
  24129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24131. return
  24132. }
  24133. var respJSON3 map[string]interface{}
  24134. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24137. return
  24138. }
  24139. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24140. userJSONBytes3, _ := json.Marshal(respJSON3)
  24141. fmt.Println("log")
  24142. fmt.Println(string(userJSONBytes3))
  24143. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24144. utils.ErrorLog("解析失败:%v", err)
  24145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24146. return
  24147. }
  24148. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24149. var api3 string
  24150. if miConfig.MdtrtareaAdmvs == "320921" {
  24151. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24152. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24153. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24154. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24155. } else {
  24156. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24157. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24158. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24159. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24160. }
  24161. resp3, requestErr3 := http.Get(api3)
  24162. if requestErr3 != nil {
  24163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24164. return
  24165. }
  24166. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24167. if ioErr3 != nil {
  24168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24170. return
  24171. }
  24172. var respJSON3 map[string]interface{}
  24173. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24176. return
  24177. }
  24178. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24179. userJSONBytes3, _ := json.Marshal(respJSON3)
  24180. fmt.Println("log")
  24181. fmt.Println(string(userJSONBytes3))
  24182. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24183. utils.ErrorLog("解析失败:%v", err)
  24184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24185. return
  24186. }
  24187. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24188. res2.Output = resSix10265.Output
  24189. res2.ErrMsg = resSix10265.ErrMsg
  24190. res2.Cainfo = resSix10265.Cainfo
  24191. res2.WarnMsg = resSix10265.WarnMsg
  24192. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24193. res2.Infcode = infocode
  24194. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24195. var api3 string
  24196. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24197. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24199. resp3, requestErr3 := http.Get(api3)
  24200. if requestErr3 != nil {
  24201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24202. return
  24203. }
  24204. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24205. if ioErr3 != nil {
  24206. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24208. return
  24209. }
  24210. var respJSON3 map[string]interface{}
  24211. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24212. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24214. return
  24215. }
  24216. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24217. userJSONBytes3, _ := json.Marshal(respJSON3)
  24218. fmt.Println("log")
  24219. fmt.Println(string(userJSONBytes3))
  24220. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24221. utils.ErrorLog("解析失败:%v", err)
  24222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24223. return
  24224. }
  24225. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24226. res2.Output = resSix10265.Output
  24227. res2.ErrMsg = resSix10265.ErrMsg
  24228. res2.Cainfo = resSix10265.Cainfo
  24229. res2.WarnMsg = resSix10265.WarnMsg
  24230. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24231. res2.Infcode = infocode
  24232. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24233. 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)
  24234. var dat map[string]interface{}
  24235. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24236. fmt.Println(dat)
  24237. } else {
  24238. fmt.Println(err)
  24239. }
  24240. saveLog(result2, src_request, "2205", "撤销明细")
  24241. userJSONBytes, _ := json.Marshal(dat)
  24242. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24243. utils.ErrorLog("解析失败:%v", err)
  24244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24245. return
  24246. }
  24247. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24248. 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, "")
  24249. var dat map[string]interface{}
  24250. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24251. fmt.Println(dat)
  24252. } else {
  24253. fmt.Println(err)
  24254. }
  24255. saveLog(result2, src_request, "2205", "撤销明细")
  24256. userJSONBytes, _ := json.Marshal(dat)
  24257. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24258. utils.ErrorLog("解析失败:%v", err)
  24259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24260. return
  24261. }
  24262. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24263. var api3 string
  24264. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24265. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24266. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24267. resp3, requestErr3 := http.Get(api3)
  24268. if requestErr3 != nil {
  24269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24270. return
  24271. }
  24272. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24273. if ioErr3 != nil {
  24274. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24276. return
  24277. }
  24278. var respJSON3 map[string]interface{}
  24279. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24280. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24282. return
  24283. }
  24284. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24285. if status == "0" {
  24286. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24287. c.ServeSuccessJSON(map[string]interface{}{
  24288. "failed_code": -10,
  24289. "msg": err_msg,
  24290. })
  24291. return
  24292. }
  24293. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24294. userJSONBytes3, _ := json.Marshal(respJSON3)
  24295. fmt.Println("log")
  24296. fmt.Println(string(userJSONBytes3))
  24297. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24298. utils.ErrorLog("解析失败:%v", err)
  24299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24300. return
  24301. }
  24302. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24303. 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, "")
  24304. var dat map[string]interface{}
  24305. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24306. fmt.Println(dat)
  24307. } else {
  24308. fmt.Println(err)
  24309. }
  24310. saveLog(result2, src_request, "2205", "撤销明细")
  24311. userJSONBytes, _ := json.Marshal(dat)
  24312. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24313. utils.ErrorLog("解析失败:%v", err)
  24314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24315. return
  24316. }
  24317. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24318. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24319. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24320. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24321. resp3, requestErr3 := http.Get(api3)
  24322. if requestErr3 != nil {
  24323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24324. return
  24325. }
  24326. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24327. if ioErr3 != nil {
  24328. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24330. return
  24331. }
  24332. var respJSON3 map[string]interface{}
  24333. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24334. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24336. return
  24337. }
  24338. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24339. userJSONBytes3, _ := json.Marshal(respJSON3)
  24340. fmt.Println("log")
  24341. fmt.Println(string(userJSONBytes3))
  24342. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24343. utils.ErrorLog("解析失败:%v", err)
  24344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24345. return
  24346. }
  24347. } else {
  24348. if miConfig.Code == "H15049901371" {
  24349. 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)
  24350. var dat map[string]interface{}
  24351. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24352. fmt.Println(dat)
  24353. } else {
  24354. fmt.Println(err)
  24355. }
  24356. saveLog(result2, src_request, "2205", "撤销明细")
  24357. userJSONBytes, _ := json.Marshal(dat)
  24358. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24359. utils.ErrorLog("解析失败:%v", err)
  24360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24361. return
  24362. }
  24363. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24364. res2.Output = resSix10265.Output
  24365. res2.ErrMsg = resSix10265.ErrMsg
  24366. res2.Cainfo = resSix10265.Cainfo
  24367. res2.WarnMsg = resSix10265.WarnMsg
  24368. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24369. res2.Infcode = infocode
  24370. } else {
  24371. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24372. res2.Infcode = 0
  24373. } else {
  24374. 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)
  24375. var dat map[string]interface{}
  24376. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24377. fmt.Println(dat)
  24378. } else {
  24379. fmt.Println(err)
  24380. }
  24381. saveLog(result2, src_request, "2205", "撤销明细")
  24382. userJSONBytes, _ := json.Marshal(dat)
  24383. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24384. utils.ErrorLog("解析失败:%v", err)
  24385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24386. return
  24387. }
  24388. }
  24389. }
  24390. }
  24391. if res2.Infcode == -1 {
  24392. c.ServeSuccessJSON(map[string]interface{}{
  24393. "failed_code": -10,
  24394. "msg": res2.ErrMsg,
  24395. })
  24396. return
  24397. }
  24398. if res2.Infcode == 0 {
  24399. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24400. if err == nil {
  24401. //当押金不为零时产生退费记录
  24402. if order.Decimal != 0 {
  24403. tmp := strconv.FormatInt(order.ID, 10)
  24404. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24405. if err != nil {
  24406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24407. return
  24408. }
  24409. }
  24410. c.ServeSuccessJSON(map[string]interface{}{
  24411. "msg": "退费成功",
  24412. })
  24413. } else {
  24414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24415. return
  24416. }
  24417. } else {
  24418. c.ServeSuccessJSON(map[string]interface{}{
  24419. "failed_code": -10,
  24420. "msg": res2.ErrMsg,
  24421. })
  24422. }
  24423. } else {
  24424. c.ServeSuccessJSON(map[string]interface{}{
  24425. "failed_code": -10,
  24426. "msg": res.ErrMsg,
  24427. })
  24428. }
  24429. }
  24430. }
  24431. func (c *HisApiController) RefundNumber() {
  24432. record_time := c.GetString("record_time")
  24433. //patient_id, _ := c.GetInt64("patient_id")
  24434. admin_user_id, _ := c.GetInt64("admin_user_id")
  24435. his_patient_id, _ := c.GetInt64("id")
  24436. timeLayout := "2006-01-02"
  24437. loc, _ := time.LoadLocation("Local")
  24438. adminUser := c.GetAdminUserInfo()
  24439. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24440. fmt.Println(err)
  24441. if err != nil {
  24442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24443. return
  24444. }
  24445. recordDateTime := theTime.Unix()
  24446. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24447. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24448. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24449. //order, _ := service.GetHisOrderByID(order_id)
  24450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24451. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24452. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24453. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24454. if count > 0 {
  24455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24456. return
  24457. }
  24458. if config.IsOpen == 1 { //对接了医保,走医保流程
  24459. var res2 ResultSix
  24460. var res3 GZResultSix
  24461. var resSix10265 ResultSix10265
  24462. if miConfig.MdtrtareaAdmvs == "421300" {
  24463. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24464. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24465. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24466. resp3, requestErr3 := http.Get(api3)
  24467. if requestErr3 != nil {
  24468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24469. return
  24470. }
  24471. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24472. if ioErr3 != nil {
  24473. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24475. return
  24476. }
  24477. var respJSON3 map[string]interface{}
  24478. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24479. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24481. return
  24482. }
  24483. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24484. userJSONBytes3, _ := json.Marshal(respJSON3)
  24485. fmt.Println("log")
  24486. fmt.Println(string(userJSONBytes3))
  24487. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24488. utils.ErrorLog("解析失败:%v", err)
  24489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24490. return
  24491. }
  24492. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24493. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24494. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24495. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24496. resp3, requestErr3 := http.Get(api3)
  24497. if requestErr3 != nil {
  24498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24499. return
  24500. }
  24501. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24502. if ioErr3 != nil {
  24503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24505. return
  24506. }
  24507. var respJSON3 map[string]interface{}
  24508. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24511. return
  24512. }
  24513. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24514. userJSONBytes3, _ := json.Marshal(respJSON3)
  24515. fmt.Println("log")
  24516. fmt.Println(string(userJSONBytes3))
  24517. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24518. utils.ErrorLog("解析失败:%v", err)
  24519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24520. return
  24521. }
  24522. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24523. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24524. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24525. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24526. resp3, requestErr3 := http.Get(api3)
  24527. if requestErr3 != nil {
  24528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24529. return
  24530. }
  24531. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24532. if ioErr3 != nil {
  24533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24535. return
  24536. }
  24537. var respJSON3 map[string]interface{}
  24538. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24541. return
  24542. }
  24543. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24544. userJSONBytes3, _ := json.Marshal(respJSON3)
  24545. fmt.Println("log")
  24546. fmt.Println(string(userJSONBytes3))
  24547. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24548. utils.ErrorLog("解析失败:%v", err)
  24549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24550. return
  24551. }
  24552. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24553. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24554. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24555. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24556. resp3, requestErr3 := http.Get(api3)
  24557. if requestErr3 != nil {
  24558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24559. return
  24560. }
  24561. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24562. if ioErr3 != nil {
  24563. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24565. return
  24566. }
  24567. var respJSON3 map[string]interface{}
  24568. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24569. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24571. return
  24572. }
  24573. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24574. userJSONBytes3, _ := json.Marshal(respJSON3)
  24575. fmt.Println("log")
  24576. fmt.Println(string(userJSONBytes3))
  24577. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24578. utils.ErrorLog("解析失败:%v", err)
  24579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24580. return
  24581. }
  24582. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24583. var api3 string
  24584. if miConfig.MdtrtareaAdmvs == "320921" {
  24585. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24586. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24587. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24588. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24589. } else {
  24590. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24591. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24592. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24593. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24594. }
  24595. resp3, requestErr3 := http.Get(api3)
  24596. if requestErr3 != nil {
  24597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24598. return
  24599. }
  24600. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24601. if ioErr3 != nil {
  24602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24604. return
  24605. }
  24606. var respJSON3 map[string]interface{}
  24607. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24610. return
  24611. }
  24612. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24613. userJSONBytes3, _ := json.Marshal(respJSON3)
  24614. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24615. utils.ErrorLog("解析失败:%v", err)
  24616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24617. return
  24618. }
  24619. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24620. res2.Output = resSix10265.Output
  24621. res2.ErrMsg = resSix10265.ErrMsg
  24622. res2.Cainfo = resSix10265.Cainfo
  24623. res2.WarnMsg = resSix10265.WarnMsg
  24624. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24625. res2.Infcode = infocode
  24626. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24627. var api3 string
  24628. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24629. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24631. resp3, requestErr3 := http.Get(api3)
  24632. if requestErr3 != nil {
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24634. return
  24635. }
  24636. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24637. if ioErr3 != nil {
  24638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24640. return
  24641. }
  24642. var respJSON3 map[string]interface{}
  24643. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24646. return
  24647. }
  24648. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24649. userJSONBytes3, _ := json.Marshal(respJSON3)
  24650. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24651. utils.ErrorLog("解析失败:%v", err)
  24652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24653. return
  24654. }
  24655. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24656. res2.Output = resSix10265.Output
  24657. res2.ErrMsg = resSix10265.ErrMsg
  24658. res2.Cainfo = resSix10265.Cainfo
  24659. res2.WarnMsg = resSix10265.WarnMsg
  24660. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24661. res2.Infcode = infocode
  24662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24663. 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)
  24664. var dat map[string]interface{}
  24665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24666. fmt.Println(dat)
  24667. } else {
  24668. fmt.Println(err)
  24669. }
  24670. saveLog(result, request, "2202", "退号")
  24671. userJSONBytes, _ := json.Marshal(dat)
  24672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24673. utils.ErrorLog("解析失败:%v", err)
  24674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24675. return
  24676. }
  24677. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24678. 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, "")
  24679. var dat map[string]interface{}
  24680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24681. fmt.Println(dat)
  24682. } else {
  24683. fmt.Println(err)
  24684. }
  24685. saveLog(result, request, "2202", "退号")
  24686. userJSONBytes, _ := json.Marshal(dat)
  24687. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24688. utils.ErrorLog("解析失败:%v", err)
  24689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24690. return
  24691. }
  24692. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24693. var api3 string
  24694. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24695. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24697. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24698. resp3, requestErr3 := http.Get(api3)
  24699. if requestErr3 != nil {
  24700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24701. return
  24702. }
  24703. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24704. if ioErr3 != nil {
  24705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24707. return
  24708. }
  24709. var respJSON3 map[string]interface{}
  24710. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24713. return
  24714. }
  24715. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24716. if status == "0" {
  24717. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24718. c.ServeSuccessJSON(map[string]interface{}{
  24719. "failed_code": -10,
  24720. "msg": err_msg,
  24721. })
  24722. return
  24723. }
  24724. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24725. userJSONBytes3, _ := json.Marshal(respJSON3)
  24726. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24727. utils.ErrorLog("解析失败:%v", err)
  24728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24729. return
  24730. }
  24731. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24732. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24733. 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, "")
  24734. var dat map[string]interface{}
  24735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24736. fmt.Println(dat)
  24737. } else {
  24738. fmt.Println(err)
  24739. }
  24740. saveLog(result, request, "2202", "退号")
  24741. userJSONBytes, _ := json.Marshal(dat)
  24742. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24743. utils.ErrorLog("解析失败:%v", err)
  24744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24745. return
  24746. }
  24747. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24748. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24749. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24750. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24751. resp3, requestErr3 := http.Get(api3)
  24752. if requestErr3 != nil {
  24753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24754. return
  24755. }
  24756. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24757. if ioErr3 != nil {
  24758. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24760. return
  24761. }
  24762. var respJSON3 map[string]interface{}
  24763. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24764. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24766. return
  24767. }
  24768. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24769. userJSONBytes3, _ := json.Marshal(respJSON3)
  24770. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24771. utils.ErrorLog("解析失败:%v", err)
  24772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24773. return
  24774. }
  24775. } else {
  24776. var api3 string
  24777. if miConfig.Code == "H15049901371" {
  24778. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24779. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24780. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24781. } else {
  24782. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24783. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24784. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24785. }
  24786. resp3, requestErr3 := http.Get(api3)
  24787. if requestErr3 != nil {
  24788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24789. return
  24790. }
  24791. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24792. if ioErr3 != nil {
  24793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24795. return
  24796. }
  24797. var respJSON3 map[string]interface{}
  24798. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24801. return
  24802. }
  24803. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24804. userJSONBytes3, _ := json.Marshal(respJSON3)
  24805. if miConfig.Code == "H15049901371" {
  24806. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24807. utils.ErrorLog("解析失败:%v", err)
  24808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24809. return
  24810. }
  24811. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24812. res2.Output = resSix10265.Output
  24813. res2.ErrMsg = resSix10265.ErrMsg
  24814. res2.Cainfo = resSix10265.Cainfo
  24815. res2.WarnMsg = resSix10265.WarnMsg
  24816. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24817. res2.Infcode = infocode
  24818. } else {
  24819. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24820. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24821. utils.ErrorLog("解析失败:%v", err)
  24822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24823. return
  24824. }
  24825. res2.Infcode = res3.Infcode
  24826. } else {
  24827. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24828. utils.ErrorLog("解析失败:%v", err)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. }
  24833. }
  24834. }
  24835. if res2.Infcode == -1 {
  24836. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24837. c.ServeSuccessJSON(map[string]interface{}{
  24838. "failed_code": -10,
  24839. "msg": res2.ErrMsg,
  24840. })
  24841. return
  24842. }
  24843. if res2.Infcode == 0 {
  24844. if err == nil {
  24845. c.ServeSuccessJSON(map[string]interface{}{
  24846. "msg": "退号成功",
  24847. })
  24848. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24849. } else {
  24850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24851. return
  24852. }
  24853. }
  24854. } else {
  24855. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24856. //if err == nil {
  24857. // c.ServeSuccessJSON(map[string]interface{}{
  24858. // "msg": "退费成功",
  24859. // })
  24860. //} else {
  24861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24862. // return
  24863. //}
  24864. }
  24865. }
  24866. func (c *HisApiController) RefundDetail() {
  24867. order_id, _ := c.GetInt64("order_id")
  24868. admin_user_id, _ := c.GetInt64("admin_user_id")
  24869. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24870. number := c.GetString("number")
  24871. record_time := c.GetString("record_time")
  24872. patient_id, _ := c.GetInt64("patient_id")
  24873. //med_type, _ := c.GetInt64("med_type")
  24874. timeLayout := "2006-01-02"
  24875. loc, _ := time.LoadLocation("Local")
  24876. adminUser := c.GetAdminUserInfo()
  24877. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24878. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24879. fmt.Println(err)
  24880. if err != nil {
  24881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24882. return
  24883. }
  24884. recordDateTime := theTime.Unix()
  24885. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24886. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24887. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24888. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24889. var order models.HisOrder
  24890. order, _ = service.GetHisOrderByID(order_id)
  24891. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24892. if config.IsOpen == 1 { //对接了医保,走医保流程
  24893. var res2 ResultSix
  24894. if miConfig.MdtrtareaAdmvs == "421300" {
  24895. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24896. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24897. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24898. resp3, requestErr3 := http.Get(api3)
  24899. if requestErr3 != nil {
  24900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24901. return
  24902. }
  24903. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24904. if ioErr3 != nil {
  24905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24907. return
  24908. }
  24909. var respJSON3 map[string]interface{}
  24910. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24913. return
  24914. }
  24915. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24916. userJSONBytes3, _ := json.Marshal(respJSON3)
  24917. fmt.Println("log")
  24918. fmt.Println(string(userJSONBytes3))
  24919. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24920. utils.ErrorLog("解析失败:%v", err)
  24921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24922. return
  24923. }
  24924. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24925. if err == nil {
  24926. c.ServeSuccessJSON(map[string]interface{}{
  24927. "msg": "撤销明细成功",
  24928. })
  24929. return
  24930. } else {
  24931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24932. return
  24933. }
  24934. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24935. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24936. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24938. resp3, requestErr3 := http.Get(api3)
  24939. if requestErr3 != nil {
  24940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24941. return
  24942. }
  24943. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24944. if ioErr3 != nil {
  24945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24947. return
  24948. }
  24949. var respJSON3 map[string]interface{}
  24950. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24953. return
  24954. }
  24955. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24956. userJSONBytes3, _ := json.Marshal(respJSON3)
  24957. fmt.Println("log")
  24958. fmt.Println(string(userJSONBytes3))
  24959. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24960. utils.ErrorLog("解析失败:%v", err)
  24961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24962. return
  24963. }
  24964. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24965. if err == nil {
  24966. c.ServeSuccessJSON(map[string]interface{}{
  24967. "msg": "撤销明细成功",
  24968. })
  24969. return
  24970. } else {
  24971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24972. return
  24973. }
  24974. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24975. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24976. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24978. resp3, requestErr3 := http.Get(api3)
  24979. if requestErr3 != nil {
  24980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24981. return
  24982. }
  24983. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24984. if ioErr3 != nil {
  24985. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24987. return
  24988. }
  24989. var respJSON3 map[string]interface{}
  24990. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24991. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24993. return
  24994. }
  24995. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24996. userJSONBytes3, _ := json.Marshal(respJSON3)
  24997. fmt.Println("log")
  24998. fmt.Println(string(userJSONBytes3))
  24999. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25000. utils.ErrorLog("解析失败:%v", err)
  25001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25002. return
  25003. }
  25004. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25005. if err == nil {
  25006. c.ServeSuccessJSON(map[string]interface{}{
  25007. "msg": "撤销明细成功",
  25008. })
  25009. return
  25010. } else {
  25011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25012. return
  25013. }
  25014. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25015. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25016. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25017. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25018. resp3, requestErr3 := http.Get(api3)
  25019. if requestErr3 != nil {
  25020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25021. return
  25022. }
  25023. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25024. if ioErr3 != nil {
  25025. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25027. return
  25028. }
  25029. var respJSON3 map[string]interface{}
  25030. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25031. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25033. return
  25034. }
  25035. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25036. userJSONBytes3, _ := json.Marshal(respJSON3)
  25037. fmt.Println("log")
  25038. fmt.Println(string(userJSONBytes3))
  25039. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25040. utils.ErrorLog("解析失败:%v", err)
  25041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25042. return
  25043. }
  25044. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25045. if err == nil {
  25046. c.ServeSuccessJSON(map[string]interface{}{
  25047. "msg": "撤销明细成功",
  25048. })
  25049. return
  25050. } else {
  25051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25052. return
  25053. }
  25054. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25055. var resSix10265 ResultSix10265
  25056. var api3 string
  25057. if miConfig.MdtrtareaAdmvs == "320921" {
  25058. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25059. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25060. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25061. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25062. } else {
  25063. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25064. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25065. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25067. }
  25068. resp3, requestErr3 := http.Get(api3)
  25069. utils.ErrorLog("接口: %v", requestErr3)
  25070. if requestErr3 != nil {
  25071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25072. return
  25073. }
  25074. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25075. if ioErr3 != nil {
  25076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25078. return
  25079. }
  25080. var respJSON3 map[string]interface{}
  25081. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25084. return
  25085. }
  25086. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25087. userJSONBytes3, _ := json.Marshal(respJSON3)
  25088. fmt.Println("log")
  25089. fmt.Println(string(userJSONBytes3))
  25090. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25091. utils.ErrorLog("解析失败:%v", err)
  25092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25093. return
  25094. }
  25095. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25096. res2.Output = resSix10265.Output
  25097. res2.ErrMsg = resSix10265.ErrMsg
  25098. res2.Cainfo = resSix10265.Cainfo
  25099. res2.WarnMsg = resSix10265.WarnMsg
  25100. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25101. res2.Infcode = infocode
  25102. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25103. if err == nil {
  25104. c.ServeSuccessJSON(map[string]interface{}{
  25105. "msg": "撤销明细成功",
  25106. })
  25107. return
  25108. } else {
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25113. var api3 string
  25114. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25115. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25117. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25118. resp3, requestErr3 := http.Get(api3)
  25119. utils.ErrorLog("接口: %v", requestErr3)
  25120. if requestErr3 != nil {
  25121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25122. return
  25123. }
  25124. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25125. if ioErr3 != nil {
  25126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25128. return
  25129. }
  25130. var respJSON3 map[string]interface{}
  25131. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25134. return
  25135. }
  25136. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25137. if status == "0" {
  25138. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25139. c.ServeSuccessJSON(map[string]interface{}{
  25140. "failed_code": -10,
  25141. "msg": err_msg,
  25142. })
  25143. return
  25144. }
  25145. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25146. userJSONBytes3, _ := json.Marshal(respJSON3)
  25147. fmt.Println("log")
  25148. fmt.Println(string(userJSONBytes3))
  25149. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25150. utils.ErrorLog("解析失败:%v", err)
  25151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25152. return
  25153. }
  25154. fmt.Println(res2.Infcode)
  25155. if res2.Infcode == -1 {
  25156. c.ServeSuccessJSON(map[string]interface{}{
  25157. "failed_code": -10,
  25158. "msg": res2.ErrMsg,
  25159. })
  25160. return
  25161. }
  25162. if res2.Infcode == 0 {
  25163. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25164. if err == nil {
  25165. c.ServeSuccessJSON(map[string]interface{}{
  25166. "msg": "撤销明细成功",
  25167. })
  25168. return
  25169. } else {
  25170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25171. return
  25172. }
  25173. } else {
  25174. c.ServeSuccessJSON(map[string]interface{}{
  25175. "failed_code": -10,
  25176. "msg": res2.ErrMsg,
  25177. })
  25178. }
  25179. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25180. if err == nil {
  25181. c.ServeSuccessJSON(map[string]interface{}{
  25182. "msg": "撤销明细成功",
  25183. })
  25184. return
  25185. } else {
  25186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25187. return
  25188. }
  25189. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25190. var resSix10265 ResultSix10265
  25191. var api3 string
  25192. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25193. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25194. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25195. resp3, requestErr3 := http.Get(api3)
  25196. if requestErr3 != nil {
  25197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25198. return
  25199. }
  25200. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25201. if ioErr3 != nil {
  25202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25204. return
  25205. }
  25206. var respJSON3 map[string]interface{}
  25207. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25210. return
  25211. }
  25212. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25213. userJSONBytes3, _ := json.Marshal(respJSON3)
  25214. fmt.Println("log")
  25215. fmt.Println(string(userJSONBytes3))
  25216. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25217. utils.ErrorLog("解析失败:%v", err)
  25218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25219. return
  25220. }
  25221. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25222. res2.Output = resSix10265.Output
  25223. res2.ErrMsg = resSix10265.ErrMsg
  25224. res2.Cainfo = resSix10265.Cainfo
  25225. res2.WarnMsg = resSix10265.WarnMsg
  25226. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25227. res2.Infcode = infocode
  25228. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25229. if err == nil {
  25230. c.ServeSuccessJSON(map[string]interface{}{
  25231. "msg": "撤销明细成功",
  25232. })
  25233. return
  25234. } else {
  25235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25236. return
  25237. }
  25238. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25239. 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)
  25240. var dat map[string]interface{}
  25241. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25242. fmt.Println(dat)
  25243. } else {
  25244. fmt.Println(err)
  25245. }
  25246. saveLog(result2, src_request, "2205", "撤销明细")
  25247. userJSONBytes, _ := json.Marshal(dat)
  25248. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25249. utils.ErrorLog("解析失败:%v", err)
  25250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25251. return
  25252. }
  25253. if res2.Infcode == 0 {
  25254. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25255. if err == nil {
  25256. c.ServeSuccessJSON(map[string]interface{}{
  25257. "msg": "撤销明细成功",
  25258. })
  25259. return
  25260. } else {
  25261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25262. return
  25263. }
  25264. } else {
  25265. c.ServeSuccessJSON(map[string]interface{}{
  25266. "failed_code": -10,
  25267. "msg": res2.ErrMsg,
  25268. })
  25269. }
  25270. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25271. 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, "")
  25272. var dat map[string]interface{}
  25273. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25274. fmt.Println(dat)
  25275. } else {
  25276. fmt.Println(err)
  25277. }
  25278. saveLog(result2, src_request, "2205", "撤销明细")
  25279. userJSONBytes, _ := json.Marshal(dat)
  25280. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25281. utils.ErrorLog("解析失败:%v", err)
  25282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25283. return
  25284. }
  25285. if res2.Infcode == 0 {
  25286. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25287. if err == nil {
  25288. c.ServeSuccessJSON(map[string]interface{}{
  25289. "msg": "撤销明细成功",
  25290. })
  25291. return
  25292. } else {
  25293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25294. return
  25295. }
  25296. } else {
  25297. c.ServeSuccessJSON(map[string]interface{}{
  25298. "failed_code": -10,
  25299. "msg": res2.ErrMsg,
  25300. })
  25301. }
  25302. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25303. 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, "")
  25304. var dat map[string]interface{}
  25305. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25306. fmt.Println(dat)
  25307. } else {
  25308. fmt.Println(err)
  25309. }
  25310. saveLog(result2, src_request, "2205", "撤销明细")
  25311. userJSONBytes, _ := json.Marshal(dat)
  25312. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25313. utils.ErrorLog("解析失败:%v", err)
  25314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25315. return
  25316. }
  25317. if res2.Infcode == 0 {
  25318. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25319. if err == nil {
  25320. c.ServeSuccessJSON(map[string]interface{}{
  25321. "msg": "撤销明细成功",
  25322. })
  25323. return
  25324. } else {
  25325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25326. return
  25327. }
  25328. } else {
  25329. c.ServeSuccessJSON(map[string]interface{}{
  25330. "failed_code": -10,
  25331. "msg": res2.ErrMsg,
  25332. })
  25333. }
  25334. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25335. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25336. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25337. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25338. resp2, requestErr2 := http.Get(api2)
  25339. if requestErr2 != nil {
  25340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25341. return
  25342. }
  25343. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25344. if ioErr2 != nil {
  25345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25347. return
  25348. }
  25349. var respJSON2 map[string]interface{}
  25350. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25353. return
  25354. }
  25355. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25356. userJSONBytes3, _ := json.Marshal(respJSON2)
  25357. fmt.Println("log")
  25358. fmt.Println(string(userJSONBytes3))
  25359. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25360. utils.ErrorLog("解析失败:%v", err)
  25361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25362. return
  25363. }
  25364. if res2.Infcode == 0 {
  25365. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25366. if err == nil {
  25367. c.ServeSuccessJSON(map[string]interface{}{
  25368. "msg": "撤销明细成功",
  25369. })
  25370. return
  25371. } else {
  25372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25373. return
  25374. }
  25375. } else {
  25376. c.ServeSuccessJSON(map[string]interface{}{
  25377. "failed_code": -10,
  25378. "msg": res2.ErrMsg,
  25379. })
  25380. }
  25381. } else {
  25382. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25383. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25384. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25385. resp2, requestErr2 := http.Get(api2)
  25386. if requestErr2 != nil {
  25387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25388. return
  25389. }
  25390. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25391. if ioErr2 != nil {
  25392. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25394. return
  25395. }
  25396. var respJSON2 map[string]interface{}
  25397. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25398. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25400. return
  25401. }
  25402. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25403. if err == nil {
  25404. c.ServeSuccessJSON(map[string]interface{}{
  25405. "msg": "撤销明细成功",
  25406. })
  25407. return
  25408. } else {
  25409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25410. return
  25411. }
  25412. }
  25413. } else {
  25414. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25415. if err == nil {
  25416. c.ServeSuccessJSON(map[string]interface{}{
  25417. "msg": "退费成功",
  25418. })
  25419. } else {
  25420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25421. return
  25422. }
  25423. }
  25424. }
  25425. // 对账
  25426. func (c *HisApiController) GetCheckAccount() {
  25427. start_time := c.GetString("start_time")
  25428. end_time := c.GetString("end_time")
  25429. insutype := c.GetString("insutype")
  25430. clr_type := c.GetString("clr_type")
  25431. clr_org := c.GetString("clr_optins")
  25432. admin_user_id, _ := c.GetInt64("admin_user_id")
  25433. adminUser := c.GetAdminUserInfo()
  25434. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25435. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25436. if len(clr_org) == 0 {
  25437. clr_org = miConfig.InsuplcAdmdvs
  25438. }
  25439. timeLayout := "2006-01-02"
  25440. loc, _ := time.LoadLocation("Local")
  25441. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25442. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25443. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25444. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25445. fixmedins_setl_cnt := int64(len(orders))
  25446. var medfee_sumamt float64
  25447. var acct_pay float64
  25448. var fund_pay_sumamt float64
  25449. for _, item := range orders {
  25450. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25451. acct_pay = acct_pay + item.AcctPay
  25452. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25453. }
  25454. var user_name string
  25455. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25456. if role.ID == 0 {
  25457. user_name = "xxx"
  25458. } else {
  25459. user_name = role.UserName
  25460. }
  25461. var res ResultEight
  25462. var res10188 ResultEightFor10188
  25463. if config.IsOpen == 1 {
  25464. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25465. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25466. "insutype=" + insutype +
  25467. "&clr_type=" + clr_type +
  25468. "&setl_optins=" + clr_org +
  25469. "&stmt_begndate=" + start_time +
  25470. "&stm_enddate=" + end_time +
  25471. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25472. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25473. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25474. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25475. "&fixmedins_code=" + miConfig.Code +
  25476. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25477. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25478. "&secret_key=" + miConfig.SecretKey +
  25479. "&org_name=" + miConfig.OrgName +
  25480. "&doctor=" + user_name +
  25481. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25482. fmt.Println(api)
  25483. resp, requestErr := http.Get(api)
  25484. if requestErr != nil {
  25485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25486. return
  25487. }
  25488. body, ioErr := ioutil.ReadAll(resp.Body)
  25489. fmt.Println(body)
  25490. if ioErr != nil {
  25491. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25493. return
  25494. }
  25495. var respJSON map[string]interface{}
  25496. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25497. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25499. return
  25500. }
  25501. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25502. userJSONBytes, _ := json.Marshal(respJSON)
  25503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25504. utils.ErrorLog("解析失败:%v", err)
  25505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25506. return
  25507. }
  25508. res.InfRefmsgid = res10188.InfRefmsgid
  25509. res.Output = res10188.Output
  25510. res.ErrMsg = res10188.ErrMsg
  25511. res.Cainfo = res10188.Cainfo
  25512. res.WarnMsg = res10188.WarnMsg
  25513. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25514. res.Infcode = infocode
  25515. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25516. if clr_type != "9903" {
  25517. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25518. }
  25519. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25520. "insutype=" + insutype +
  25521. "&clr_type=" + clr_type +
  25522. "&setl_optins=" + clr_org +
  25523. "&stmt_begndate=" + start_time +
  25524. "&stm_enddate=" + end_time +
  25525. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25526. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25527. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25528. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25529. "&fixmedins_code=" + miConfig.Code +
  25530. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25531. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25532. "&secret_key=" + miConfig.SecretKey +
  25533. "&org_name=" + miConfig.OrgName +
  25534. "&doctor=" + user_name
  25535. resp, requestErr := http.Get(api)
  25536. if requestErr != nil {
  25537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25538. return
  25539. }
  25540. body, ioErr := ioutil.ReadAll(resp.Body)
  25541. if ioErr != nil {
  25542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25544. return
  25545. }
  25546. var respJSON map[string]interface{}
  25547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25550. return
  25551. }
  25552. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25553. result, _ := json.Marshal(respJSON)
  25554. fmt.Println("log")
  25555. fmt.Println(string(result))
  25556. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25557. utils.ErrorLog("解析失败:%v", err)
  25558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25559. return
  25560. }
  25561. res.InfRefmsgid = res10188.InfRefmsgid
  25562. res.Output = res10188.Output
  25563. res.ErrMsg = res10188.ErrMsg
  25564. res.Cainfo = res10188.Cainfo
  25565. res.WarnMsg = res10188.WarnMsg
  25566. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25567. res.Infcode = infocode
  25568. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25569. var baseParams models.BaseParams
  25570. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25571. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25572. baseParams.SecretKey = miConfig.SecretKey
  25573. baseParams.OrgName = miConfig.OrgName
  25574. baseParams.FixmedinsCode = miConfig.Code
  25575. baseParams.EncKey = miConfig.EncKey
  25576. baseParams.AppSecret = miConfig.AppSecret
  25577. baseParams.SignKey = miConfig.SignKey
  25578. baseParams.AppID = miConfig.Code
  25579. baseParams.Doctor = role.UserName
  25580. baseParams.RequestUrl = miConfig.Url
  25581. businessParams := models.BusinessParams{
  25582. Insutype: insutype,
  25583. ClrType: clr_type,
  25584. SetlOptins: clr_org,
  25585. StmtBegndate: start_time,
  25586. StmtEnddate: end_time,
  25587. MedfeeSumamt: medfee_sumamt,
  25588. FundPaySumamt: fund_pay_sumamt,
  25589. AcctPay: acct_pay,
  25590. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25591. }
  25592. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25593. fmt.Println(requestLog)
  25594. fmt.Println(result)
  25595. fmt.Println(err_msg)
  25596. var dat map[string]interface{}
  25597. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25598. fmt.Println(dat)
  25599. } else {
  25600. fmt.Println(err)
  25601. }
  25602. userJSONBytes, _ := json.Marshal(dat)
  25603. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25604. utils.ErrorLog("解析失败:%v", err)
  25605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25606. return
  25607. }
  25608. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25609. var baseParams models.BaseParams
  25610. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25611. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25612. baseParams.SecretKey = miConfig.SecretKey
  25613. baseParams.OrgName = miConfig.OrgName
  25614. baseParams.FixmedinsCode = miConfig.Code
  25615. baseParams.EncKey = miConfig.EncKey
  25616. baseParams.AppSecret = miConfig.AppSecret
  25617. baseParams.SignKey = miConfig.SignKey
  25618. baseParams.AppID = miConfig.Code
  25619. baseParams.Doctor = role.UserName
  25620. baseParams.RequestUrl = miConfig.Url
  25621. baseParams.AccessKey = miConfig.AccessKey
  25622. businessParams := models.BusinessParams{
  25623. Insutype: insutype,
  25624. ClrType: clr_type,
  25625. SetlOptins: "430822",
  25626. StmtBegndate: start_time,
  25627. StmtEnddate: end_time,
  25628. MedfeeSumamt: medfee_sumamt,
  25629. FundPaySumamt: fund_pay_sumamt,
  25630. AcctPay: acct_pay,
  25631. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25632. }
  25633. 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)
  25634. fmt.Println(requestLog)
  25635. fmt.Println(result)
  25636. var dat map[string]interface{}
  25637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25638. fmt.Println(dat)
  25639. } else {
  25640. fmt.Println(err)
  25641. }
  25642. userJSONBytes, _ := json.Marshal(dat)
  25643. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25644. utils.ErrorLog("解析失败:%v", err)
  25645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25646. return
  25647. }
  25648. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25649. var baseParams models.BaseParams
  25650. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25651. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25652. baseParams.SecretKey = miConfig.SecretKey
  25653. baseParams.OrgName = miConfig.OrgName
  25654. baseParams.FixmedinsCode = miConfig.Code
  25655. baseParams.EncKey = miConfig.EncKey
  25656. baseParams.AppSecret = miConfig.AppSecret
  25657. baseParams.SignKey = miConfig.SignKey
  25658. baseParams.AppID = miConfig.Code
  25659. baseParams.Doctor = role.UserName
  25660. baseParams.RequestUrl = miConfig.Url
  25661. businessParams := models.BusinessParams{
  25662. Insutype: insutype,
  25663. ClrType: clr_type,
  25664. SetlOptins: clr_org,
  25665. StmtBegndate: start_time,
  25666. StmtEnddate: end_time,
  25667. MedfeeSumamt: medfee_sumamt,
  25668. FundPaySumamt: fund_pay_sumamt,
  25669. AcctPay: acct_pay,
  25670. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25671. }
  25672. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25673. fmt.Println(requestLog)
  25674. fmt.Println(result)
  25675. fmt.Println(err_msg)
  25676. var dat map[string]interface{}
  25677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25678. fmt.Println(dat)
  25679. } else {
  25680. fmt.Println(err)
  25681. }
  25682. userJSONBytes, _ := json.Marshal(dat)
  25683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25684. utils.ErrorLog("解析失败:%v", err)
  25685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25686. return
  25687. }
  25688. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25689. if len(clr_type) == 0 {
  25690. clr_type = "11"
  25691. }
  25692. api := miConfig.Url + "gdyb/ten?" +
  25693. "insutype=" + insutype +
  25694. "&clr_type=" + clr_type +
  25695. "&setl_optins=" + clr_org +
  25696. "&stmt_begndate=" + start_time +
  25697. "&stm_enddate=" + end_time +
  25698. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25699. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25700. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25701. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25702. "&fixmedins_code=" + miConfig.Code +
  25703. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25704. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25705. "&secret_key=" + miConfig.SecretKey +
  25706. "&org_name=" + miConfig.OrgName +
  25707. "&doctor=" + user_name
  25708. fmt.Println(api)
  25709. resp, requestErr := http.Get(api)
  25710. if requestErr != nil {
  25711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25712. return
  25713. }
  25714. body, ioErr := ioutil.ReadAll(resp.Body)
  25715. fmt.Println(body)
  25716. if ioErr != nil {
  25717. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25719. return
  25720. }
  25721. var respJSON map[string]interface{}
  25722. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25723. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25725. return
  25726. }
  25727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25728. userJSONBytes, _ := json.Marshal(respJSON)
  25729. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25730. utils.ErrorLog("解析失败:%v", err)
  25731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25732. return
  25733. }
  25734. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25735. var baseParams models.BaseParams
  25736. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25737. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25738. baseParams.SecretKey = miConfig.SecretKey
  25739. baseParams.OrgName = miConfig.OrgName
  25740. baseParams.FixmedinsCode = miConfig.Code
  25741. baseParams.EncKey = miConfig.EncKey
  25742. baseParams.AppSecret = miConfig.AppSecret
  25743. baseParams.SignKey = miConfig.SignKey
  25744. baseParams.AppID = miConfig.Code
  25745. baseParams.Doctor = role.UserName
  25746. baseParams.RequestUrl = miConfig.Url
  25747. if clr_type == "9903" {
  25748. clr_type = "9901"
  25749. }
  25750. businessParams := models.BusinessParams{
  25751. Insutype: insutype,
  25752. ClrType: clr_type,
  25753. SetlOptins: "360302",
  25754. StmtBegndate: start_time,
  25755. StmtEnddate: end_time,
  25756. MedfeeSumamt: 0,
  25757. FundPaySumamt: 0,
  25758. AcctPay: 0,
  25759. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25760. }
  25761. 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))
  25762. fmt.Println(requestLog)
  25763. fmt.Println(result)
  25764. var dat map[string]interface{}
  25765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25766. fmt.Println(dat)
  25767. } else {
  25768. fmt.Println(err)
  25769. }
  25770. userJSONBytes, _ := json.Marshal(dat)
  25771. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25772. utils.ErrorLog("解析失败:%v", err)
  25773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25774. return
  25775. }
  25776. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25777. var api string
  25778. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25779. "&clr_type=" + clr_type +
  25780. "&setl_optins=" + clr_org +
  25781. "&stmt_begndate=" + start_time +
  25782. "&stm_enddate=" + end_time +
  25783. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25784. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25785. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25786. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25787. "&fixmedins_code=" + miConfig.Code +
  25788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25789. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25790. "&secret_key=" + miConfig.SecretKey +
  25791. "&org_name=" + miConfig.OrgName +
  25792. "&doctor=" + user_name + "&url=" + miConfig.Url
  25793. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25794. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25795. resp, requestErr := http.Get(api)
  25796. if requestErr != nil {
  25797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25798. return
  25799. }
  25800. body, ioErr := ioutil.ReadAll(resp.Body)
  25801. if ioErr != nil {
  25802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25804. return
  25805. }
  25806. var respJSON map[string]interface{}
  25807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25810. return
  25811. }
  25812. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25813. if status == "0" {
  25814. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25815. c.ServeSuccessJSON(map[string]interface{}{
  25816. "failed_code": -10,
  25817. "msg": err_msg,
  25818. })
  25819. return
  25820. }
  25821. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25822. userJSONBytes, _ := json.Marshal(respJSON)
  25823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25824. utils.ErrorLog("解析失败:%v", err)
  25825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25826. return
  25827. }
  25828. } else {
  25829. if len(clr_type) == 0 {
  25830. clr_type = "11"
  25831. }
  25832. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25833. "insutype=" + insutype +
  25834. "&clr_type=" + clr_type +
  25835. "&setl_optins=" + clr_org +
  25836. "&stmt_begndate=" + start_time +
  25837. "&stm_enddate=" + end_time +
  25838. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25839. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25840. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25841. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25842. "&fixmedins_code=" + miConfig.Code +
  25843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25844. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25845. "&secret_key=" + miConfig.SecretKey +
  25846. "&org_name=" + miConfig.OrgName +
  25847. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25848. fmt.Println(api)
  25849. resp, requestErr := http.Get(api)
  25850. if requestErr != nil {
  25851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25852. return
  25853. }
  25854. body, ioErr := ioutil.ReadAll(resp.Body)
  25855. fmt.Println(body)
  25856. if ioErr != nil {
  25857. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25859. return
  25860. }
  25861. var respJSON map[string]interface{}
  25862. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25865. return
  25866. }
  25867. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25868. userJSONBytes, _ := json.Marshal(respJSON)
  25869. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25870. utils.ErrorLog("解析失败:%v", err)
  25871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25872. return
  25873. }
  25874. }
  25875. if res.Infcode == 0 {
  25876. if res.Output.Stmtinfo.StmtRslt == "0" {
  25877. micc := &models.MedicalInsuranceCostCompare{
  25878. StartTime: startime.Unix(),
  25879. EndTime: endtime.Unix(),
  25880. Insutype: insutype,
  25881. CheckType: 1,
  25882. Num: fixmedins_setl_cnt,
  25883. Mtime: time.Now().Unix(),
  25884. Status: 1,
  25885. UserOrgId: adminUser.CurrentOrgId,
  25886. CostTotal: medfee_sumamt,
  25887. FuncTotal: fund_pay_sumamt,
  25888. PsnPay: acct_pay,
  25889. Creator: admin_user_id,
  25890. Ctime: time.Now().Unix(),
  25891. ClrType: clr_type,
  25892. }
  25893. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25894. if err == nil {
  25895. c.ServeSuccessJSON(map[string]interface{}{
  25896. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25897. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25898. })
  25899. } else {
  25900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25901. }
  25902. } else {
  25903. c.ServeSuccessJSON(map[string]interface{}{
  25904. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25905. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25906. })
  25907. }
  25908. } else {
  25909. c.ServeSuccessJSON(map[string]interface{}{
  25910. "failed_code": -10,
  25911. "msg": res.ErrMsg,
  25912. })
  25913. }
  25914. }
  25915. }
  25916. func (c *HisApiController) Check310() {
  25917. adminUser := c.GetAdminUserInfo()
  25918. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25919. var user_name string
  25920. user_name = "高慧裕"
  25921. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25922. "insutype=" + "310" +
  25923. "&clr_type=" + "" +
  25924. "&setl_optins=" + "441202" +
  25925. "&stmt_begndate=" + "2022-03-01" +
  25926. "&stm_enddate=" + "2022-03-31" +
  25927. "&medfee_sumamt=" + "194930.12" +
  25928. "&fund_pay_sumamt=" + "188741.46" +
  25929. "&acct_pay=" + "0" +
  25930. "&fixmedins_setl_cnt=" + "452" +
  25931. "&fixmedins_code=" + miConfig.Code +
  25932. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25933. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25934. "&secret_key=" + miConfig.SecretKey +
  25935. "&org_name=" + miConfig.OrgName +
  25936. "&doctor=" + user_name
  25937. fmt.Println(api)
  25938. resp, requestErr := http.Get(api)
  25939. if requestErr != nil {
  25940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25941. return
  25942. }
  25943. body, ioErr := ioutil.ReadAll(resp.Body)
  25944. fmt.Println(body)
  25945. if ioErr != nil {
  25946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25948. return
  25949. }
  25950. var respJSON map[string]interface{}
  25951. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25954. return
  25955. }
  25956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25957. userJSONBytes, _ := json.Marshal(respJSON)
  25958. var res ResultEight
  25959. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25960. utils.ErrorLog("解析失败:%v", err)
  25961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25962. return
  25963. }
  25964. }
  25965. func (c *HisApiController) Check390() {
  25966. adminUser := c.GetAdminUserInfo()
  25967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25968. var user_name string
  25969. user_name = "高慧裕"
  25970. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25971. "insutype=" + "390" +
  25972. "&clr_type=" + "" +
  25973. "&setl_optins=" + "441202" +
  25974. "&stmt_begndate=" + "2022-03-01" +
  25975. "&stm_enddate=" + "2022-03-31" +
  25976. "&medfee_sumamt=" + "1068448.89" +
  25977. "&fund_pay_sumamt=" + "1014677.62" +
  25978. "&acct_pay=" + "0" +
  25979. "&fixmedins_setl_cnt=" + "1950" +
  25980. "&fixmedins_code=" + miConfig.Code +
  25981. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25982. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25983. "&secret_key=" + miConfig.SecretKey +
  25984. "&org_name=" + miConfig.OrgName +
  25985. "&doctor=" + user_name
  25986. fmt.Println(api)
  25987. resp, requestErr := http.Get(api)
  25988. if requestErr != nil {
  25989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25990. return
  25991. }
  25992. body, ioErr := ioutil.ReadAll(resp.Body)
  25993. fmt.Println(body)
  25994. if ioErr != nil {
  25995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25997. return
  25998. }
  25999. var respJSON map[string]interface{}
  26000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26003. return
  26004. }
  26005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26006. userJSONBytes, _ := json.Marshal(respJSON)
  26007. var res ResultEight
  26008. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26009. utils.ErrorLog("解析失败:%v", err)
  26010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26011. return
  26012. }
  26013. }
  26014. // 对账明细
  26015. func (c *HisApiController) GetCheckDetailAccount() {
  26016. start_time := c.GetString("start_time")
  26017. end_time := c.GetString("end_time")
  26018. admin_user_id, _ := c.GetInt64("admin_user_id")
  26019. adminUser := c.GetAdminUserInfo()
  26020. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26021. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26022. timeLayout := "2006-01-02"
  26023. loc, _ := time.LoadLocation("Local")
  26024. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26025. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26026. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26027. rand.Seed(time.Now().UnixNano())
  26028. num := rand.Intn(30000)
  26029. Mkdir(miConfig.OrgName)
  26030. file := strconv.FormatInt(int64(num), 10)
  26031. file_name := file + ".txt"
  26032. zip_name := file + ".zip"
  26033. zip_path := miConfig.OrgName + "/" + zip_name
  26034. file_path := miConfig.OrgName + "/" + file_name
  26035. decimal.DivisionPrecision = 2
  26036. var medfee_sumamt float64
  26037. var psn_cash_pay float64
  26038. var fund_pay_sumamt float64
  26039. fixmedins_setl_cnt := int64(len(orders))
  26040. for _, item := range orders {
  26041. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26042. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26043. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26044. }
  26045. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26046. defer f.Close()
  26047. if err != nil {
  26048. fmt.Println(err.Error())
  26049. } else {
  26050. for _, item := range orders {
  26051. var refd_setl_flag string
  26052. if item.OrderStatus == 2 {
  26053. refd_setl_flag = "0"
  26054. var str string
  26055. str = item.SetlId + " " +
  26056. item.MdtrtId + " " +
  26057. item.PsnNo + " " +
  26058. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26059. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26060. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26061. _, err = f.Write([]byte(str))
  26062. }
  26063. if item.OrderStatus == 3 {
  26064. var str string
  26065. str = item.SetlId + " " +
  26066. item.MdtrtId + " " +
  26067. item.PsnNo + " " +
  26068. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26069. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26070. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26071. _, err = f.Write([]byte(str))
  26072. var str2 string
  26073. str2 = item.SetlId + " " +
  26074. item.MdtrtId + " " +
  26075. item.PsnNo + " " +
  26076. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26077. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26078. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26079. _, err = f.Write([]byte(str2))
  26080. }
  26081. }
  26082. }
  26083. Zip(file_path, zip_path)
  26084. fmt.Println(ReadFile(zip_path))
  26085. fmt.Println(string(ReadFile(zip_path)))
  26086. if config.IsOpen == 1 {
  26087. var user_name string
  26088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26089. if role.ID == 0 {
  26090. user_name = "管理员"
  26091. } else {
  26092. user_name = role.UserName
  26093. }
  26094. baseParams := models.BaseParams{
  26095. SecretKey: miConfig.SecretKey,
  26096. FixmedinsCode: miConfig.Code,
  26097. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26098. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26099. OrgName: miConfig.OrgName,
  26100. Doctor: user_name,
  26101. }
  26102. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26103. var dat map[string]interface{}
  26104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26105. fmt.Println(dat)
  26106. } else {
  26107. fmt.Println(err)
  26108. }
  26109. userJSONBytes, _ := json.Marshal(dat)
  26110. var res ResultNine
  26111. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26112. utils.ErrorLog("解析失败:%v", err)
  26113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26114. return
  26115. }
  26116. if res.Infcode == 0 {
  26117. fileNo := res.Output.FileQuryNo
  26118. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26119. "file_qury_no=" + fileNo +
  26120. "&setl_optins=" + "定点医保中心" +
  26121. "&stmt_begndate=" + start_time +
  26122. "&stm_enddate=" + end_time +
  26123. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26124. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26125. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26126. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26127. "&fixmedins_code=" + miConfig.Code +
  26128. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26129. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26130. "&secret_key=" + miConfig.SecretKey +
  26131. "&org_name=" + miConfig.OrgName +
  26132. "&doctor=" + user_name
  26133. resp, requestErr := http.Get(api)
  26134. if requestErr != nil {
  26135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26136. return
  26137. }
  26138. body, ioErr := ioutil.ReadAll(resp.Body)
  26139. if ioErr != nil {
  26140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26142. return
  26143. }
  26144. var respJSON map[string]interface{}
  26145. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26148. return
  26149. }
  26150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26151. userJSONBytes, _ := json.Marshal(respJSON)
  26152. var res ResultTen
  26153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26154. utils.ErrorLog("解析失败:%v", err)
  26155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26156. return
  26157. }
  26158. if res.Infcode == 0 {
  26159. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26160. micc := &models.MedicalInsuranceCostCompare{
  26161. StartTime: startime.Unix(),
  26162. EndTime: endtime.Unix(),
  26163. Insutype: "0",
  26164. CheckType: 2,
  26165. Num: fixmedins_setl_cnt,
  26166. Mtime: time.Now().Unix(),
  26167. Status: 1,
  26168. UserOrgId: adminUser.CurrentOrgId,
  26169. CostTotal: medfee_sumamt,
  26170. FuncTotal: fund_pay_sumamt,
  26171. PsnPay: psn_cash_pay,
  26172. Creator: admin_user_id,
  26173. Ctime: time.Now().Unix(),
  26174. }
  26175. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26176. c.ServeSuccessJSON(map[string]interface{}{
  26177. "msg": "明细对账成功",
  26178. })
  26179. }
  26180. } else {
  26181. }
  26182. }
  26183. }
  26184. type CustomOrderInfo struct {
  26185. Name string
  26186. Spec string
  26187. Unit string
  26188. Count float64
  26189. Price float64
  26190. Total float64
  26191. }
  26192. func (c *HisApiController) GetBatchSettleAccounts() {
  26193. admin_user_id, _ := c.GetInt64("admin_user_id")
  26194. order_ids := c.GetString("order_ids")
  26195. order_ids_arr := strings.Split(order_ids, ",")
  26196. data3 := []map[string]interface{}{}
  26197. for _, item := range order_ids_arr {
  26198. id, _ := strconv.ParseInt(item, 10, 64)
  26199. order_id := id
  26200. adminUser := c.GetAdminUserInfo()
  26201. order, _ := service.GetHisOrderByID(order_id)
  26202. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26203. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26204. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26205. orderInfos = append(orderInfos, orderInfos_two...)
  26206. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26207. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26208. var diagnosis_ids []string
  26209. if his.ID > 0 {
  26210. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26211. } else {
  26212. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26213. }
  26214. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26215. var dia_config []*models.HisXtDiagnoseConfig
  26216. var name string
  26217. for _, item := range diagnosis_ids {
  26218. id, _ := strconv.ParseInt(item, 10, 64)
  26219. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26220. dia_config = append(dia_config, &diagnosisConfig)
  26221. if len(name) == 0 {
  26222. name = diagnosisConfig.ClassName
  26223. }
  26224. //} else {
  26225. // name = name + "," + diagnosisConfig.ClassName
  26226. //}
  26227. }
  26228. var bedCostTotal float64 = 0 //床位总费
  26229. var bedCostSelfTotal float64 = 0 //床位自费
  26230. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26231. var bedSelfTotal float64 = 0 //床位部分项目自费
  26232. var bedInscpTotal float64 = 0 //床位部分项目自费
  26233. var operationCostTotal float64 = 0 //手术费
  26234. var operationCostSelfTotal float64 = 0 //手术费
  26235. var operationCostPartSelfTotal float64 = 0 //手术费
  26236. var operationSelfTotal float64 = 0 //床位部分项目自费
  26237. var operationInscpTotal float64 = 0 //床位部分项目自费
  26238. var otherCostTotal float64 = 0 //其他费用
  26239. var otherCostSelfTotal float64 = 0 //其他费用
  26240. var otherCostPartSelfTotal float64 = 0 //其他费用
  26241. var otherSelfTotal float64 = 0 //床位部分项目自费
  26242. var otherInscpTotal float64 = 0 //床位部分项目自费
  26243. var materialCostTotal float64 = 0 //材料费
  26244. var materialCostSelfTotal float64 = 0 //材料费
  26245. var materialCostPartSelfTotal float64 = 0 //材料费
  26246. var materialSelfTotal float64 = 0 //床位部分项目自费
  26247. var materialInscpTotal float64 = 0 //床位部分项目自费
  26248. var westernMedicineCostTotal float64 = 0 //西药费
  26249. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26250. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26251. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26252. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26253. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26254. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26255. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26256. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26257. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26258. var checkCostTotal float64 = 0 //检查费
  26259. var checkCostSelfTotal float64 = 0 //检查费
  26260. var checkCostPartSelfTotal float64 = 0 //检查费
  26261. var checkSelfTotal float64 = 0 //床位部分项目自费
  26262. var checkInscpTotal float64 = 0 //床位部分项目自费
  26263. var laboratoryCostTotal float64 = 0 //化验费
  26264. var laboratoryCostSelfTotal float64 = 0 //化验费
  26265. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26266. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26267. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26268. var treatCostTotal float64 = 0 //治疗费用
  26269. var treatCostSelfTotal float64 = 0 //治疗费用
  26270. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26271. var treatSelfTotal float64 = 0 //床位部分项目自费
  26272. var treatInscpTotal float64 = 0 //床位部分项目自费
  26273. decimal.DivisionPrecision = 2
  26274. for _, item := range orderInfos {
  26275. if item.MedChrgitmType == "01" { //床位费
  26276. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26277. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26278. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26279. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26280. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26281. }
  26282. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26283. if item.MedChrgitmType == "03" { //检查费
  26284. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26285. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26286. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26287. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26288. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26289. }
  26290. } else {
  26291. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26292. fmt.Println("------------")
  26293. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26294. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26295. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26296. }
  26297. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26298. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26299. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26300. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26301. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26302. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26303. }
  26304. }
  26305. if item.MedChrgitmType == "04" { //化验费
  26306. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26307. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26308. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26309. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26310. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26311. }
  26312. if item.MedChrgitmType == "05" { //治疗费
  26313. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26314. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26315. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26316. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26317. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26318. }
  26319. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26320. fmt.Println("------------")
  26321. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26322. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26323. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26324. }
  26325. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26326. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26327. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26328. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26329. }
  26330. //if item.MedChrgitmType == "06" { //手术费
  26331. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26332. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26333. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26334. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26335. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26336. //
  26337. //}
  26338. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26339. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26340. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26341. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26342. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26343. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26344. }
  26345. if item.MedChrgitmType == "09" { //西药费
  26346. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26347. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26348. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26349. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26350. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26351. }
  26352. if item.MedChrgitmType == "11" { //中成费
  26353. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26354. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26355. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26356. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26357. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26358. }
  26359. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26360. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26361. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26362. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26363. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26364. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26365. }
  26366. }
  26367. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26368. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26369. var user_name string
  26370. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26371. if role.ID == 0 {
  26372. user_name = "管理员"
  26373. } else {
  26374. user_name = role.UserName
  26375. }
  26376. baseParams := models.BaseParams{
  26377. SecretKey: miConfig.SecretKey,
  26378. FixmedinsCode: miConfig.Code,
  26379. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26380. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26381. OrgName: miConfig.OrgName,
  26382. Doctor: user_name,
  26383. RequestUrl: miConfig.Url,
  26384. AccessKey: miConfig.AccessKey,
  26385. }
  26386. businessParams := models.BusinessParams{
  26387. PsnNo: order.PsnNo,
  26388. MdtrtId: order.MdtrtId,
  26389. SetlId: order.SetlId,
  26390. }
  26391. var res ResultEleven
  26392. var resEleven10265 ResultEleven10265
  26393. if config.IsOpen == 1 {
  26394. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26395. result := service.Gdyb5203(baseParams, businessParams)
  26396. service.Gdyb5204(baseParams, businessParams)
  26397. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26398. var dat map[string]interface{}
  26399. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26400. fmt.Println(dat)
  26401. } else {
  26402. fmt.Println(err)
  26403. }
  26404. userJSONBytes, _ := json.Marshal(dat)
  26405. if miConfig.Code == "H15049901371" {
  26406. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26407. utils.ErrorLog("解析失败:%v", err)
  26408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26409. return
  26410. }
  26411. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26412. res.Output = resEleven10265.Output
  26413. res.ErrMsg = resEleven10265.ErrMsg
  26414. res.Cainfo = resEleven10265.Cainfo
  26415. res.WarnMsg = resEleven10265.WarnMsg
  26416. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26417. res.Infcode = infocode
  26418. } else {
  26419. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26420. utils.ErrorLog("解析失败:%v", err)
  26421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26422. return
  26423. }
  26424. }
  26425. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26426. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26427. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26428. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26429. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26431. var doctor_name string
  26432. if roles.ID == 0 {
  26433. doctor_name = "管理员"
  26434. } else {
  26435. doctor_name = roles.UserName
  26436. }
  26437. yiliao_leibie := ""
  26438. switch order.MedType {
  26439. case "11":
  26440. yiliao_leibie = "普通门诊"
  26441. break
  26442. case "12":
  26443. yiliao_leibie = "门诊挂号"
  26444. break
  26445. case "13":
  26446. yiliao_leibie = "急诊"
  26447. break
  26448. case "14":
  26449. yiliao_leibie = "门诊特殊病"
  26450. break
  26451. case "15":
  26452. yiliao_leibie = "门诊统筹"
  26453. break
  26454. case "16":
  26455. yiliao_leibie = "门诊慢性病"
  26456. break
  26457. case "21":
  26458. yiliao_leibie = "普通住院"
  26459. break
  26460. }
  26461. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26462. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26463. if res.Infcode == 0 {
  26464. data2 := map[string]interface{}{
  26465. "diagnosis": name,
  26466. "order_infos": orderInfos,
  26467. "number": order.MdtrtId,
  26468. "date": order.SettleAccountsDate,
  26469. "charge_admin": charge_admin,
  26470. "printor_admin": printor_admin,
  26471. "info": res.Output.Setlinfo,
  26472. "order": order,
  26473. "bedCostTotal": bedCostTotal,
  26474. "bedCostSelfTotal": bedCostSelfTotal,
  26475. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26476. "bedSelfTotal": bedSelfTotal,
  26477. "bedInscpTotal": bedInscpTotal,
  26478. "operationCostTotal": operationCostTotal,
  26479. "operationCostSelfTotal": operationCostSelfTotal,
  26480. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26481. "operationSelfTotal": operationSelfTotal,
  26482. "operationInscpTotal": operationInscpTotal,
  26483. "otherCostTotal": otherCostTotal,
  26484. "otherCostSelfTotal": otherCostSelfTotal,
  26485. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26486. "otherSelfTotal": otherSelfTotal,
  26487. "otherInscpTotal": otherInscpTotal,
  26488. "materialCostTotal": materialCostTotal,
  26489. "materialCostSelfTotal": materialCostSelfTotal,
  26490. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26491. "materialSelfTotal": materialSelfTotal,
  26492. "materialInscpTotal": materialInscpTotal,
  26493. "westernMedicineCostTotal": westernMedicineCostTotal,
  26494. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26495. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26496. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26497. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26498. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26499. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26500. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26501. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26502. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26503. "checkCostTotal": checkCostTotal,
  26504. "checkCostSelfTotal": checkCostSelfTotal,
  26505. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26506. "checkSelfTotal": checkSelfTotal,
  26507. "checkInscpTotal": checkInscpTotal,
  26508. "laboratoryCostTotal": laboratoryCostTotal,
  26509. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26510. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26511. "laboratorySelfTotal": laboratorySelfTotal,
  26512. "laboratoryInscpTotal": laboratoryInscpTotal,
  26513. "treatCostTotal": treatCostTotal,
  26514. "treatCostSelfTotal": treatCostSelfTotal,
  26515. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26516. "treatSelfTotal": treatSelfTotal,
  26517. "treatInscpTotal": treatInscpTotal,
  26518. "doctor_info": doctor_info,
  26519. "doctor_code": adminRole_two.DoctorCode,
  26520. "doctor_name": doctor_name,
  26521. "health_card_no": order.PsnNo,
  26522. "department": departments.Name,
  26523. "yiliao_leibie": yiliao_leibie,
  26524. "after_money": order.AccountPrice,
  26525. "patient": patient,
  26526. "org_name": miConfig.OrgName,
  26527. "org_code": miConfig.Code,
  26528. "order_number": order.Number,
  26529. "his_hospital": his_hospital,
  26530. "his": his,
  26531. "dia_config": dia_config,
  26532. "psn_cash_pay": order.PsnCashPay,
  26533. //"check_order_info": cus_slice,
  26534. }
  26535. data3 = append(data3, data2)
  26536. }
  26537. }
  26538. }
  26539. c.ServeSuccessJSON(map[string]interface{}{
  26540. "infos": data3,
  26541. })
  26542. }
  26543. func (c *HisApiController) GetSettleAccounts() {
  26544. //id, _ := c.GetInt64("id")
  26545. //record_time := c.GetString("record_time")
  26546. order_id, _ := c.GetInt64("order_id")
  26547. admin_user_id, _ := c.GetInt64("admin_user_id")
  26548. //timeLayout := "2006-01-02"
  26549. //loc, _ := time.LoadLocation("Local")
  26550. //
  26551. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26552. //if err != nil {
  26553. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26554. // return
  26555. //}Hbyb5203
  26556. //recordDateTime := theTime.Unix()
  26557. adminUser := c.GetAdminUserInfo()
  26558. order, _ := service.GetHisOrderByID(order_id)
  26559. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26560. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26561. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26562. orderInfos = append(orderInfos, orderInfos_two...)
  26563. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26564. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26565. var diagnosis_ids []string
  26566. if his.ID > 0 {
  26567. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26568. } else {
  26569. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26570. }
  26571. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26572. var dia_config []*models.HisXtDiagnoseConfig
  26573. var name string
  26574. for _, item := range diagnosis_ids {
  26575. id, _ := strconv.ParseInt(item, 10, 64)
  26576. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26577. dia_config = append(dia_config, &diagnosisConfig)
  26578. if len(name) == 0 {
  26579. name = diagnosisConfig.ClassName
  26580. } else {
  26581. name = name + "," + diagnosisConfig.ClassName
  26582. }
  26583. }
  26584. if patient.UserOrgId == 10215 {
  26585. name = "慢性肾功能不全(血透治疗)"
  26586. }
  26587. var bedCostTotal float64 = 0 //床位总费
  26588. var bedCostSelfTotal float64 = 0 //床位自费
  26589. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26590. var bedSelfTotal float64 = 0 //床位部分项目自费
  26591. var bedInscpTotal float64 = 0 //床位部分项目自费
  26592. var operationCostTotal float64 = 0 //手术费
  26593. var operationCostSelfTotal float64 = 0 //手术费
  26594. var operationCostPartSelfTotal float64 = 0 //手术费
  26595. var operationSelfTotal float64 = 0 //床位部分项目自费
  26596. var operationInscpTotal float64 = 0 //床位部分项目自费
  26597. var otherCostTotal float64 = 0 //其他费用
  26598. var otherCostSelfTotal float64 = 0 //其他费用
  26599. var otherCostPartSelfTotal float64 = 0 //其他费用
  26600. var otherSelfTotal float64 = 0 //床位部分项目自费
  26601. var otherInscpTotal float64 = 0 //床位部分项目自费
  26602. var materialCostTotal float64 = 0 //材料费
  26603. var materialCostSelfTotal float64 = 0 //材料费
  26604. var materialCostPartSelfTotal float64 = 0 //材料费
  26605. var materialSelfTotal float64 = 0 //床位部分项目自费
  26606. var materialInscpTotal float64 = 0 //床位部分项目自费
  26607. var westernMedicineCostTotal float64 = 0 //西药费
  26608. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26609. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26610. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26611. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26612. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26613. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26614. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26615. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26616. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26617. var checkCostTotal float64 = 0 //检查费
  26618. var checkCostSelfTotal float64 = 0 //检查费
  26619. var checkCostPartSelfTotal float64 = 0 //检查费
  26620. var checkSelfTotal float64 = 0 //床位部分项目自费
  26621. var checkInscpTotal float64 = 0 //床位部分项目自费
  26622. var laboratoryCostTotal float64 = 0 //化验费
  26623. var laboratoryCostSelfTotal float64 = 0 //化验费
  26624. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26625. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26626. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26627. var treatCostTotal float64 = 0 //治疗费用
  26628. var treatCostSelfTotal float64 = 0 //治疗费用
  26629. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26630. var treatSelfTotal float64 = 0 //床位部分项目自费
  26631. var treatInscpTotal float64 = 0 //床位部分项目自费
  26632. decimal.DivisionPrecision = 2
  26633. for _, item := range orderInfos {
  26634. if item.MedChrgitmType == "01" { //床位费
  26635. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26636. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26637. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26638. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26639. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26640. }
  26641. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26642. if item.MedChrgitmType == "03" { //检查费
  26643. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26644. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26645. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26646. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26647. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26648. }
  26649. } else {
  26650. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26651. fmt.Println("------------")
  26652. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26653. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26654. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26655. }
  26656. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26657. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26658. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26659. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26660. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26661. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26662. }
  26663. }
  26664. if item.MedChrgitmType == "04" { //化验费
  26665. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26666. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26667. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26668. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26669. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26670. }
  26671. if item.MedChrgitmType == "05" { //治疗费
  26672. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26673. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26674. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26675. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26676. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26677. }
  26678. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26679. fmt.Println("------------")
  26680. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26681. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26682. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26683. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26684. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26685. }
  26686. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26687. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26688. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26689. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26690. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26691. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26692. }
  26693. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26694. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26695. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26696. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26697. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26698. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26699. }
  26700. if item.MedChrgitmType == "09" { //西药费
  26701. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26702. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26703. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26704. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26705. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26706. }
  26707. if item.MedChrgitmType == "11" { //中成费
  26708. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26709. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26710. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26711. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26712. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26713. }
  26714. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26715. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26716. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26717. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26718. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26719. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26720. }
  26721. }
  26722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26723. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26724. var user_name string
  26725. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26726. if role.ID == 0 {
  26727. user_name = "管理员"
  26728. } else {
  26729. user_name = role.UserName
  26730. }
  26731. baseParams := models.BaseParams{
  26732. SecretKey: miConfig.SecretKey,
  26733. FixmedinsCode: miConfig.Code,
  26734. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26735. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26736. OrgName: miConfig.OrgName,
  26737. Doctor: user_name,
  26738. RequestUrl: miConfig.Url,
  26739. AccessKey: miConfig.AccessKey,
  26740. }
  26741. businessParams := models.BusinessParams{
  26742. PsnNo: order.PsnNo,
  26743. MdtrtId: order.MdtrtId,
  26744. SetlId: order.SetlId,
  26745. }
  26746. var res ResultEleven
  26747. var resah ResultElevenah
  26748. var resEleven10265 ResultEleven10265
  26749. if config.IsOpen == 1 {
  26750. if miConfig.MdtrtareaAdmvs == "421300" {
  26751. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26752. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26754. resp, requestErr := http.Get(api)
  26755. if requestErr != nil {
  26756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26757. return
  26758. }
  26759. body, ioErr := ioutil.ReadAll(resp.Body)
  26760. if ioErr != nil {
  26761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26763. return
  26764. }
  26765. var respJSON map[string]interface{}
  26766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26769. return
  26770. }
  26771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26772. result, _ := json.Marshal(respJSON)
  26773. fmt.Println("log")
  26774. fmt.Println(string(result))
  26775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26776. utils.ErrorLog("解析失败:%v", err)
  26777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26778. return
  26779. }
  26780. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26781. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26782. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26783. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26784. resp, requestErr := http.Get(api)
  26785. if requestErr != nil {
  26786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26787. return
  26788. }
  26789. body, ioErr := ioutil.ReadAll(resp.Body)
  26790. if ioErr != nil {
  26791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26793. return
  26794. }
  26795. var respJSON map[string]interface{}
  26796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26799. return
  26800. }
  26801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26802. result, _ := json.Marshal(respJSON)
  26803. fmt.Println("log")
  26804. fmt.Println(string(result))
  26805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26806. utils.ErrorLog("解析失败:%v", err)
  26807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26808. return
  26809. }
  26810. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26811. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26812. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26813. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26814. resp, requestErr := http.Get(api)
  26815. if requestErr != nil {
  26816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26817. return
  26818. }
  26819. body, ioErr := ioutil.ReadAll(resp.Body)
  26820. if ioErr != nil {
  26821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26823. return
  26824. }
  26825. var respJSON map[string]interface{}
  26826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26829. return
  26830. }
  26831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26832. result, _ := json.Marshal(respJSON)
  26833. fmt.Println("log")
  26834. fmt.Println(string(result))
  26835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26836. utils.ErrorLog("解析失败:%v", err)
  26837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26838. return
  26839. }
  26840. }else if miConfig.MdtrtareaAdmvs == "421182" {
  26841. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26842. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26843. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  26844. resp, requestErr := http.Get(api)
  26845. if requestErr != nil {
  26846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26847. return
  26848. }
  26849. body, ioErr := ioutil.ReadAll(resp.Body)
  26850. if ioErr != nil {
  26851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26853. return
  26854. }
  26855. var respJSON map[string]interface{}
  26856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26859. return
  26860. }
  26861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26862. result, _ := json.Marshal(respJSON)
  26863. fmt.Println("log")
  26864. fmt.Println(string(result))
  26865. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26866. utils.ErrorLog("解析失败:%v", err)
  26867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26868. return
  26869. }
  26870. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26871. var api string
  26872. if miConfig.MdtrtareaAdmvs == "320921" {
  26873. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26874. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26875. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26876. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26877. } else {
  26878. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26879. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26880. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26881. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26882. }
  26883. resp, requestErr := http.Get(api)
  26884. if requestErr != nil {
  26885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26886. return
  26887. }
  26888. body, ioErr := ioutil.ReadAll(resp.Body)
  26889. if ioErr != nil {
  26890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26892. return
  26893. }
  26894. var respJSON map[string]interface{}
  26895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26898. return
  26899. }
  26900. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26901. result, _ := json.Marshal(respJSON)
  26902. fmt.Println("log")
  26903. fmt.Println(string(result))
  26904. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26905. utils.ErrorLog("解析失败:%v", err)
  26906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26907. return
  26908. }
  26909. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26910. res.Output = resEleven10265.Output
  26911. res.ErrMsg = resEleven10265.ErrMsg
  26912. res.Cainfo = resEleven10265.Cainfo
  26913. res.WarnMsg = resEleven10265.WarnMsg
  26914. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26915. res.Infcode = infocode
  26916. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26917. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26918. saveLog(result, requestLog, "5203", "结算单")
  26919. var dat map[string]interface{}
  26920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26921. fmt.Println(dat)
  26922. } else {
  26923. fmt.Println(err)
  26924. }
  26925. userJSONBytes, _ := json.Marshal(dat)
  26926. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26927. utils.ErrorLog("解析失败:%v", err)
  26928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26929. return
  26930. }
  26931. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26932. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26933. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26934. fmt.Println(result3)
  26935. fmt.Println(requestLog3)
  26936. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26937. fmt.Println(result2)
  26938. fmt.Println(requestLog2)
  26939. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26940. saveLog(result, requestLog, "5203", "结算单")
  26941. var dat map[string]interface{}
  26942. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26943. fmt.Println(dat)
  26944. } else {
  26945. fmt.Println(err)
  26946. }
  26947. userJSONBytes, _ := json.Marshal(dat)
  26948. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26949. utils.ErrorLog("解析失败:%v", err)
  26950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26951. return
  26952. }
  26953. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26954. var api string
  26955. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26956. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26957. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26958. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26959. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26960. resp, requestErr := http.Get(api)
  26961. if requestErr != nil {
  26962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26963. return
  26964. }
  26965. body, ioErr := ioutil.ReadAll(resp.Body)
  26966. if ioErr != nil {
  26967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26969. return
  26970. }
  26971. var respJSON map[string]interface{}
  26972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26975. return
  26976. }
  26977. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26978. if status == "0" {
  26979. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26980. c.ServeSuccessJSON(map[string]interface{}{
  26981. "failed_code": -10,
  26982. "msg": err_msg,
  26983. })
  26984. return
  26985. }
  26986. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26987. result, _ := json.Marshal(respJSON)
  26988. fmt.Println("log")
  26989. fmt.Println(string(result))
  26990. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26991. utils.ErrorLog("解析失败:%v", err)
  26992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26993. return
  26994. }
  26995. res.InfRefmsgid = resah.InfRefmsgid
  26996. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26997. // 创建对应的Time类型
  26998. t := time.UnixMilli(timestamp)
  26999. // 格式化成指定的日期字符串
  27000. str := t.Format("2006-01-02 15:04:05")
  27001. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27002. // 创建对应的Time类型
  27003. t3 := time.UnixMilli(timestamp2)
  27004. // 格式化成指定的日期字符串
  27005. str2 := t3.Format("2006-01-02 15:04:05")
  27006. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27007. // 创建对应的Time类型
  27008. t4 := time.UnixMilli(timestamp3)
  27009. // 格式化成指定的日期字符串
  27010. str3 := t4.Format("2006-01-02 15:04:05")
  27011. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27012. // 创建对应的Time类型
  27013. t5 := time.UnixMilli(timestamp4)
  27014. // 格式化成指定的日期字符串
  27015. str5 := t5.Format("2006-01-02 15:04:05")
  27016. res.Output.Setlinfo.Brdy = str2
  27017. res.Output.Setlinfo.SetlTime = str
  27018. res.Output.Setlinfo.Begndate = str3
  27019. res.Output.Setlinfo.Enddate = str5
  27020. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27021. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27022. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27023. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27024. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27025. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27026. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27027. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27028. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27029. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27030. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27031. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27032. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27033. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27034. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27035. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27036. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27037. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27038. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27039. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27040. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27041. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27042. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27043. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27044. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27045. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27046. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27047. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27048. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27049. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27050. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27051. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27052. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27053. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27054. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27055. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27056. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27057. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27058. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27059. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27060. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27061. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27062. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27063. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27064. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27065. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27066. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27067. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27068. //res.Output.Setldetail = resah.Output.Setldetail
  27069. res.ErrMsg = resah.ErrMsg
  27070. res.Cainfo = resah.Cainfo
  27071. res.WarnMsg = resah.WarnMsg
  27072. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27073. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27074. saveLog(result, requestLog, "5203", "结算单")
  27075. var dat map[string]interface{}
  27076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27077. fmt.Println(dat)
  27078. } else {
  27079. fmt.Println(err)
  27080. }
  27081. userJSONBytes, _ := json.Marshal(dat)
  27082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27083. utils.ErrorLog("解析失败:%v", err)
  27084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27085. return
  27086. }
  27087. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27088. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27089. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27090. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27091. resp, requestErr := http.Get(api)
  27092. if requestErr != nil {
  27093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27094. return
  27095. }
  27096. body, ioErr := ioutil.ReadAll(resp.Body)
  27097. if ioErr != nil {
  27098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27100. return
  27101. }
  27102. var respJSON map[string]interface{}
  27103. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27106. return
  27107. }
  27108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27109. result, _ := json.Marshal(respJSON)
  27110. fmt.Println("log")
  27111. fmt.Println(string(result))
  27112. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27113. utils.ErrorLog("解析失败:%v", err)
  27114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27115. return
  27116. }
  27117. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27118. res.Output = resEleven10265.Output
  27119. res.ErrMsg = resEleven10265.ErrMsg
  27120. res.Cainfo = resEleven10265.Cainfo
  27121. res.WarnMsg = resEleven10265.WarnMsg
  27122. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27123. res.Infcode = infocode
  27124. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27125. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27126. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27127. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27128. resp, requestErr := http.Get(api)
  27129. if requestErr != nil {
  27130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27131. return
  27132. }
  27133. body, ioErr := ioutil.ReadAll(resp.Body)
  27134. if ioErr != nil {
  27135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27137. return
  27138. }
  27139. var respJSON map[string]interface{}
  27140. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27143. return
  27144. }
  27145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27146. result, _ := json.Marshal(respJSON)
  27147. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27148. utils.ErrorLog("解析失败:%v", err)
  27149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27150. return
  27151. }
  27152. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27153. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27154. //return
  27155. } else {
  27156. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27157. if len(his.InsuplcAdmdvs) == 0 {
  27158. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27159. } else {
  27160. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27161. }
  27162. result := service.Gdyb5203(baseParams, businessParams)
  27163. //service.Gdyb5204(baseParams, businessParams)
  27164. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27165. var dat map[string]interface{}
  27166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27167. fmt.Println(dat)
  27168. } else {
  27169. fmt.Println(err)
  27170. }
  27171. userJSONBytes, _ := json.Marshal(dat)
  27172. if miConfig.Code == "H15049901371" {
  27173. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27174. utils.ErrorLog("解析失败:%v", err)
  27175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27176. return
  27177. }
  27178. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27179. res.Output = resEleven10265.Output
  27180. res.ErrMsg = resEleven10265.ErrMsg
  27181. res.Cainfo = resEleven10265.Cainfo
  27182. res.WarnMsg = resEleven10265.WarnMsg
  27183. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27184. res.Infcode = infocode
  27185. } else {
  27186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27187. utils.ErrorLog("解析失败:%v", err)
  27188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27189. return
  27190. }
  27191. }
  27192. }
  27193. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27194. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27195. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27196. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27197. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27198. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27199. var doctor_name string
  27200. if roles.ID == 0 {
  27201. doctor_name = "管理员"
  27202. } else {
  27203. doctor_name = roles.UserName
  27204. }
  27205. yiliao_leibie := ""
  27206. switch order.MedType {
  27207. case "11":
  27208. yiliao_leibie = "普通门诊"
  27209. break
  27210. case "12":
  27211. yiliao_leibie = "门诊挂号"
  27212. break
  27213. case "13":
  27214. yiliao_leibie = "急诊"
  27215. break
  27216. case "14":
  27217. yiliao_leibie = "门诊特殊病"
  27218. break
  27219. case "15":
  27220. yiliao_leibie = "门诊统筹"
  27221. break
  27222. case "16":
  27223. yiliao_leibie = "门诊慢性病"
  27224. break
  27225. case "21":
  27226. yiliao_leibie = "普通住院"
  27227. break
  27228. }
  27229. //var rf []CustomFundPay
  27230. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27231. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27232. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27233. if res.Infcode == 0 {
  27234. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27235. c.ServeSuccessJSON(map[string]interface{}{
  27236. "diagnosis": name,
  27237. "order_infos": orderInfos,
  27238. "number": order.MdtrtId,
  27239. "date": order.SettleAccountsDate,
  27240. "charge_admin": charge_admin,
  27241. "printor_admin": printor_admin,
  27242. "info": res.Output.Setlinfo,
  27243. "order": order,
  27244. "bedCostTotal": bedCostTotal,
  27245. "bedCostSelfTotal": bedCostSelfTotal,
  27246. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27247. "bedSelfTotal": bedSelfTotal,
  27248. "bedInscpTotal": bedInscpTotal,
  27249. "operationCostTotal": operationCostTotal,
  27250. "operationCostSelfTotal": operationCostSelfTotal,
  27251. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27252. "operationSelfTotal": operationSelfTotal,
  27253. "operationInscpTotal": operationInscpTotal,
  27254. "otherCostTotal": otherCostTotal,
  27255. "otherCostSelfTotal": otherCostSelfTotal,
  27256. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27257. "otherSelfTotal": otherSelfTotal,
  27258. "otherInscpTotal": otherInscpTotal,
  27259. "materialCostTotal": materialCostTotal,
  27260. "materialCostSelfTotal": materialCostSelfTotal,
  27261. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27262. "materialSelfTotal": materialSelfTotal,
  27263. "materialInscpTotal": materialInscpTotal,
  27264. "westernMedicineCostTotal": westernMedicineCostTotal,
  27265. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27266. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27267. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27268. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27269. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27270. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27271. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27272. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27273. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27274. "checkCostTotal": checkCostTotal,
  27275. "checkCostSelfTotal": checkCostSelfTotal,
  27276. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27277. "checkSelfTotal": checkSelfTotal,
  27278. "checkInscpTotal": checkInscpTotal,
  27279. "laboratoryCostTotal": laboratoryCostTotal,
  27280. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27281. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27282. "laboratorySelfTotal": laboratorySelfTotal,
  27283. "laboratoryInscpTotal": laboratoryInscpTotal,
  27284. "treatCostTotal": treatCostTotal,
  27285. "treatCostSelfTotal": treatCostSelfTotal,
  27286. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27287. "treatSelfTotal": treatSelfTotal,
  27288. "treatInscpTotal": treatInscpTotal,
  27289. "doctor_info": doctor_info,
  27290. "doctor_code": adminRole_two.DoctorCode,
  27291. "doctor_name": doctor_name,
  27292. "health_card_no": order.PsnNo,
  27293. "department": departments.Name,
  27294. "yiliao_leibie": yiliao_leibie,
  27295. "after_money": order.AccountPrice,
  27296. "patient": patient,
  27297. "org_name": miConfig.OrgName,
  27298. "org_code": miConfig.Code,
  27299. "order_number": order.Number,
  27300. "his_hospital": his_hospital,
  27301. "his": his,
  27302. "dia_config": dia_config,
  27303. "psn_cash_pay": order.PsnCashPay,
  27304. //"funds": rf,
  27305. //"check_order_info": cus_slice,
  27306. })
  27307. } else {
  27308. c.ServeSuccessJSON(map[string]interface{}{
  27309. "diagnosis": name,
  27310. "order_infos": orderInfos,
  27311. "number": order.MdtrtId,
  27312. "date": order.SettleAccountsDate,
  27313. "charge_admin": charge_admin,
  27314. "printor_admin": printor_admin,
  27315. "info": order,
  27316. "order": order,
  27317. "bedCostTotal": bedCostTotal,
  27318. "bedCostSelfTotal": bedCostSelfTotal,
  27319. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27320. "bedSelfTotal": bedSelfTotal,
  27321. "bedInscpTotal": bedInscpTotal,
  27322. "operationCostTotal": operationCostTotal,
  27323. "operationCostSelfTotal": operationCostSelfTotal,
  27324. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27325. "operationSelfTotal": operationSelfTotal,
  27326. "operationInscpTotal": operationInscpTotal,
  27327. "otherCostTotal": otherCostTotal,
  27328. "otherCostSelfTotal": otherCostSelfTotal,
  27329. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27330. "otherSelfTotal": otherSelfTotal,
  27331. "otherInscpTotal": otherInscpTotal,
  27332. "materialCostTotal": materialCostTotal,
  27333. "materialCostSelfTotal": materialCostSelfTotal,
  27334. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27335. "materialSelfTotal": materialSelfTotal,
  27336. "materialInscpTotal": materialInscpTotal,
  27337. "westernMedicineCostTotal": westernMedicineCostTotal,
  27338. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27339. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27340. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27341. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27342. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27343. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27344. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27345. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27346. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27347. "checkCostTotal": checkCostTotal,
  27348. "checkCostSelfTotal": checkCostSelfTotal,
  27349. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27350. "checkSelfTotal": checkSelfTotal,
  27351. "checkInscpTotal": checkInscpTotal,
  27352. "laboratoryCostTotal": laboratoryCostTotal,
  27353. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27354. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27355. "laboratorySelfTotal": laboratorySelfTotal,
  27356. "laboratoryInscpTotal": laboratoryInscpTotal,
  27357. "treatCostTotal": treatCostTotal,
  27358. "treatCostSelfTotal": treatCostSelfTotal,
  27359. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27360. "treatSelfTotal": treatSelfTotal,
  27361. "treatInscpTotal": treatInscpTotal,
  27362. "doctor_info": doctor_info,
  27363. "doctor_code": adminRole_two.DoctorCode,
  27364. "doctor_name": doctor_name,
  27365. "health_card_no": order.PsnNo,
  27366. "department": departments.Name,
  27367. "yiliao_leibie": yiliao_leibie,
  27368. "after_money": order.AccountPrice,
  27369. "patient": patient,
  27370. "org_name": miConfig.OrgName,
  27371. "org_code": miConfig.Code,
  27372. "order_number": order.Number,
  27373. "his_hospital": his_hospital,
  27374. "his": his,
  27375. "dia_config": dia_config,
  27376. "psn_cash_pay": order.PsnCashPay,
  27377. //"funds": rf,
  27378. //"check_order_info": cus_slice,
  27379. })
  27380. }
  27381. }
  27382. }
  27383. }
  27384. //func (c *HisApiController) CheckTreatment() {
  27385. // patient_id, _ := c.GetInt64("patient_id")
  27386. // id_card_no := c.GetString("id_card_no")
  27387. // insutype := c.GetString("insutype")
  27388. // med_type := c.GetString("med_type")
  27389. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27390. //
  27391. // adminUser := c.GetAdminUserInfo()
  27392. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27393. //
  27394. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27395. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27396. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27397. //
  27398. // if miConfig.MdtrtareaAdmvs == "421300" {
  27399. // var res ResultTwo
  27400. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27401. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27402. // "&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)
  27403. // resp, requestErr := http.Get(api)
  27404. // if requestErr != nil {
  27405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27406. // return
  27407. // }
  27408. //
  27409. // body, ioErr := ioutil.ReadAll(resp.Body)
  27410. // if ioErr != nil {
  27411. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27413. // return
  27414. // }
  27415. // var respJSON map[string]interface{}
  27416. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27417. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27419. // return
  27420. // }
  27421. //
  27422. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27423. // result, _ := json.Marshal(respJSON)
  27424. //
  27425. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27426. // utils.ErrorLog("解析失败:%v", err)
  27427. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27428. // return
  27429. // }
  27430. //
  27431. // if res.Infcode == 0 {
  27432. //
  27433. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27434. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27435. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27436. // resp, requestErr := http.Get(api)
  27437. // if requestErr != nil {
  27438. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27439. // return
  27440. // }
  27441. //
  27442. // body, ioErr := ioutil.ReadAll(resp.Body)
  27443. // if ioErr != nil {
  27444. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27446. // return
  27447. // }
  27448. // var respJSON map[string]interface{}
  27449. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27450. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27451. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27452. // return
  27453. // }
  27454. // var res Result2001
  27455. //
  27456. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27457. // result2, _ := json.Marshal(respJSON)
  27458. //
  27459. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27460. // utils.ErrorLog("解析失败:%v", err)
  27461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27462. // return
  27463. // }
  27464. //
  27465. // if res.Infcode == 0 {
  27466. // c.ServeSuccessJSON(map[string]interface{}{
  27467. // "msg": res.Output.Trtinfo,
  27468. // })
  27469. // }
  27470. //
  27471. // } else {
  27472. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27473. // return
  27474. // }
  27475. //
  27476. // } else {
  27477. //
  27478. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27479. // var dat map[string]interface{}
  27480. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27481. // fmt.Println(dat)
  27482. // } else {
  27483. // fmt.Println(err)
  27484. // }
  27485. // userJSONBytes, _ := json.Marshal(dat)
  27486. // var res ResultTwo
  27487. // var res10265 ResultTwo10265
  27488. // if miConfig.Code == "H15049901371" {
  27489. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27490. // utils.ErrorLog("解析失败:%v", err)
  27491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27492. // return
  27493. // }
  27494. // res.ErrMsg = res10265.ErrMsg
  27495. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27496. // res.Infcode = infocode
  27497. // res.Output = res10265.Output
  27498. // res.InfRefmsgid = res10265.InfRefmsgid
  27499. // } else {
  27500. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27501. // utils.ErrorLog("解析失败:%v", err)
  27502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27503. // return
  27504. // }
  27505. // }
  27506. //
  27507. // var user_name string
  27508. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27509. // if role.ID == 0 {
  27510. // user_name = "xxx"
  27511. // } else {
  27512. // user_name = role.UserName
  27513. // }
  27514. //
  27515. // baseParams := models.BaseParams{
  27516. // SecretKey: miConfig.SecretKey,
  27517. // FixmedinsCode: miConfig.Code,
  27518. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27519. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27520. // OrgName: miConfig.OrgName,
  27521. // Doctor: user_name,
  27522. // }
  27523. //
  27524. // if config.IsOpen == 1 {
  27525. // if miConfig.Code == "H15049901371" {
  27526. // if med_type == "14" {
  27527. // if insutype == "390" {
  27528. // med_type = "9933"
  27529. // } else if insutype == "310" {
  27530. // med_type = "990502"
  27531. // }
  27532. // } else if med_type == "11" {
  27533. // med_type = "11"
  27534. // }
  27535. // }
  27536. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27537. // var dat map[string]interface{}
  27538. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27539. // fmt.Println(dat)
  27540. // } else {
  27541. // fmt.Println(err)
  27542. // }
  27543. // var res Result2001
  27544. // var res10265 Result2001Org10265
  27545. // if miConfig.Code == "H15049901371" {
  27546. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27547. // utils.ErrorLog("解析失败:%v", err)
  27548. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27549. // return
  27550. // }
  27551. // res.ErrMsg = res10265.ErrMsg
  27552. // res.Output = res10265.Output
  27553. // res.InfRefmsgid = res10265.InfRefmsgid
  27554. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27555. // res.Infcode = infocode
  27556. // } else {
  27557. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27558. // utils.ErrorLog("解析失败:%v", err)
  27559. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27560. // return
  27561. // }
  27562. // }
  27563. // if res.Infcode == 0 {
  27564. // c.ServeSuccessJSON(map[string]interface{}{
  27565. // "msg": res.Output.Trtinfo,
  27566. // })
  27567. // }
  27568. // }
  27569. // }
  27570. //}
  27571. //func (c *HisApiController) PutRecord() {
  27572. // id, _ := c.GetInt64("id")
  27573. // record_time := c.GetString("record_time")
  27574. // timeLayout := "2006-01-02"
  27575. // loc, _ := time.LoadLocation("Local")
  27576. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27577. // if err != nil {
  27578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27579. // return
  27580. // }
  27581. // recordDateTime := theTime.Unix()
  27582. //
  27583. // adminInfo := c.GetAdminUserInfo()
  27584. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27585. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27586. //
  27587. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27588. //
  27589. // fmt.Println(miConfig.SecretKey)
  27590. //
  27591. // if patient == nil {
  27592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27593. // return
  27594. // }
  27595. // if len(patient.IdCardNo) == 0 {
  27596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27597. // return
  27598. // }
  27599. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27600. // if config.IsOpen == 1 {
  27601. // 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
  27602. // resp, requestErr := http.Get(api)
  27603. // if requestErr != nil {
  27604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27605. // return
  27606. // }
  27607. // defer resp.Body.Close()
  27608. // body, ioErr := ioutil.ReadAll(resp.Body)
  27609. // if ioErr != nil {
  27610. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27612. // return
  27613. // }
  27614. // var respJSON map[string]interface{}
  27615. //
  27616. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27617. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27619. // return
  27620. // }
  27621. //
  27622. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27623. // userJSONBytes, _ := json.Marshal(userJSON)
  27624. // var res ResultTwo
  27625. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27626. // utils.ErrorLog("解析失败:%v", err)
  27627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27628. // return
  27629. // }
  27630. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27631. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27632. // infoStr := string(Iinfos)
  27633. // idetinfoStr := string(Idetinfos)
  27634. //
  27635. // if res.Infcode == 0 {
  27636. // his := models.VMHisPatient{
  27637. // Status: 1,
  27638. // Ctime: time.Now().Unix(),
  27639. // Mtime: time.Now().Unix(),
  27640. // PsnNo: res.Output.Baseinfo.PsnNo,
  27641. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27642. // Certno: res.Output.Baseinfo.Certno,
  27643. // PsnName: res.Output.Baseinfo.PsnName,
  27644. // Gend: res.Output.Baseinfo.Gend,
  27645. // Naty: res.Output.Baseinfo.Naty,
  27646. // Brdy: res.Output.Baseinfo.Brdy,
  27647. // Age: res.Output.Baseinfo.Age,
  27648. // Iinfo: infoStr,
  27649. // Idetinfo: idetinfoStr,
  27650. // PatientId: patient.ID,
  27651. // RecordDate: theTime.Unix(),
  27652. // UserOrgId: adminInfo.CurrentOrgId,
  27653. // AdminUserId: adminInfo.AdminUser.Id,
  27654. // IsReturn: 1,
  27655. // }
  27656. //
  27657. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27658. // //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")
  27659. // //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")
  27660. //
  27661. // //var dat map[string]interface{}
  27662. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27663. // // fmt.Println(dat)
  27664. // //} else {
  27665. // // fmt.Println(err)
  27666. // //}
  27667. //
  27668. // var dat2 map[string]interface{}
  27669. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27670. // fmt.Println(dat2)
  27671. // } else {
  27672. // fmt.Println(err)
  27673. // }
  27674. //
  27675. // } else {
  27676. // adminUser := c.GetAdminUserInfo()
  27677. // errlog := &models.HisOrderError{
  27678. // UserOrgId: adminUser.CurrentOrgId,
  27679. // Ctime: time.Now().Unix(),
  27680. // Mtime: time.Now().Unix(),
  27681. // ErrMsg: res.ErrMsg,
  27682. // Status: 1,
  27683. // PatientId: id,
  27684. // RecordTime: recordDateTime,
  27685. // Stage: 1,
  27686. // }
  27687. // service.CreateErrMsgLog(errlog)
  27688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27689. // return
  27690. // }
  27691. // }
  27692. //
  27693. //}
  27694. //func (c *HisApiController) GetUploadDiag() {
  27695. // id, _ := c.GetInt64("id")
  27696. // record_time := c.GetString("record_time")
  27697. //
  27698. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27699. // sick_type, _ := c.GetInt64("sick_type")
  27700. // reg_type, _ := c.GetInt64("reg_type")
  27701. //
  27702. // timeLayout := "2006-01-02"
  27703. // loc, _ := time.LoadLocation("Local")
  27704. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27705. // if err != nil {
  27706. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27707. // return
  27708. // }
  27709. //
  27710. // var patientPrescription models.HisPrescriptionInfo
  27711. // recordDateTime := theTime.Unix()
  27712. // adminInfo := c.GetAdminUserInfo()
  27713. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27714. //
  27715. // if patientPrescription.ID == 0 {
  27716. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27717. // }
  27718. //
  27719. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27720. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27721. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27722. // sickConfig, _ := service.FindSickById(sick_type)
  27723. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27724. //
  27725. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27726. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27727. // "&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 +
  27728. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27729. // resp2, requestErr2 := http.Get(api2)
  27730. // if requestErr2 != nil {
  27731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27732. // return
  27733. // }
  27734. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27735. // if ioErr2 != nil {
  27736. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27737. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27738. // return
  27739. // }
  27740. // var respJSON2 map[string]interface{}
  27741. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27742. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27744. // return
  27745. // }
  27746. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27747. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27748. //
  27749. // var res2 ResultSix
  27750. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27751. // utils.ErrorLog("解析失败:%v", err)
  27752. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27753. // return
  27754. // }
  27755. // if res2.Infcode != 0 {
  27756. // adminUser := c.GetAdminUserInfo()
  27757. // errlog := &models.HisOrderError{
  27758. // UserOrgId: adminUser.CurrentOrgId,
  27759. // Ctime: time.Now().Unix(),
  27760. // Mtime: time.Now().Unix(),
  27761. // ErrMsg: res2.ErrMsg,
  27762. // Status: 1,
  27763. // PatientId: id,
  27764. // RecordTime: recordDateTime,
  27765. // Stage: 3,
  27766. // }
  27767. // service.CreateErrMsgLog(errlog)
  27768. //
  27769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27770. // return
  27771. // }
  27772. //
  27773. // c.ServeSuccessJSON(map[string]interface{}{
  27774. // "msg": "上传成功",
  27775. // })
  27776. //
  27777. //}
  27778. type QueryResult struct {
  27779. ID int64
  27780. Name string
  27781. Code string
  27782. List_type_code string
  27783. }
  27784. func (c *HisApiController) GetCheckCode() {
  27785. ids_str := c.GetString("ids")
  27786. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27787. ids_arr := strings.Split(ids_str, ",")
  27788. var queryResult []QueryResult
  27789. ids := make([]int64, 0)
  27790. for _, item := range ids_arr {
  27791. id, _ := strconv.ParseInt(item, 10, 64)
  27792. ids = append(ids, id)
  27793. }
  27794. if record_type == 1 {
  27795. drugs, _ := service.GetBatchDrugList(ids)
  27796. for _, item := range drugs {
  27797. result := QueryResult{
  27798. ID: item.ID,
  27799. Name: item.DrugName,
  27800. Code: item.MedicalInsuranceNumber,
  27801. List_type_code: "101",
  27802. }
  27803. queryResult = append(queryResult, result)
  27804. }
  27805. } else if record_type == 2 {
  27806. goods, _ := service.GetBatchGoodInformationList(ids)
  27807. fmt.Println(goods)
  27808. for _, item := range goods {
  27809. result := QueryResult{
  27810. ID: item.ID,
  27811. Name: item.GoodName,
  27812. Code: item.SocialSecurityDirectoryCode,
  27813. List_type_code: "301",
  27814. }
  27815. queryResult = append(queryResult, result)
  27816. }
  27817. } else if record_type == 3 {
  27818. projects, _ := service.GetBathchMyPorjecgList(ids)
  27819. for _, item := range projects {
  27820. result := QueryResult{
  27821. ID: item.ID,
  27822. Name: item.ProjectName,
  27823. Code: item.MedicalCode,
  27824. List_type_code: "201",
  27825. }
  27826. queryResult = append(queryResult, result)
  27827. }
  27828. }
  27829. admin_user_id, _ := c.GetInt64("admin_user_id")
  27830. adminUser := c.GetAdminUserInfo()
  27831. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27832. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27833. var user_name string
  27834. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27835. if role.ID == 0 {
  27836. user_name = "管理员"
  27837. } else {
  27838. user_name = role.UserName
  27839. }
  27840. baseParams := models.BaseParams{
  27841. SecretKey: miConfig.SecretKey,
  27842. FixmedinsCode: miConfig.Code,
  27843. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27844. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27845. OrgName: miConfig.OrgName,
  27846. Doctor: user_name,
  27847. }
  27848. var result string
  27849. if miConfig.MdtrtareaAdmvs == "430800" {
  27850. for _, item := range queryResult {
  27851. if record_type == 1 {
  27852. 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)
  27853. } else if record_type == 2 {
  27854. fmt.Println(item.Code)
  27855. 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)
  27856. } else if record_type == 3 {
  27857. 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)
  27858. }
  27859. var dat map[string]interface{}
  27860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27861. fmt.Println(dat)
  27862. } else {
  27863. fmt.Println(err)
  27864. }
  27865. userJSONBytes, _ := json.Marshal(dat)
  27866. var res ResultSix
  27867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27868. utils.ErrorLog("解析失败:%v", err)
  27869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27870. return
  27871. }
  27872. if res.Infcode == 0 {
  27873. if record_type == 1 {
  27874. service.UpdateBaseDrugById(item.ID)
  27875. } else if record_type == 2 {
  27876. service.UpdateGoodInformaitonByDetail(item.ID)
  27877. } else if record_type == 3 {
  27878. service.UpdateProjectById(item.ID)
  27879. }
  27880. c.ServeSuccessJSON(map[string]interface{}{
  27881. "failed_code": 0,
  27882. "msg": "目录对照成功",
  27883. })
  27884. } else {
  27885. c.ServeSuccessJSON(map[string]interface{}{
  27886. "failed_code": -10,
  27887. "msg": res.ErrMsg,
  27888. })
  27889. }
  27890. }
  27891. } else {
  27892. for _, item := range queryResult {
  27893. var result string
  27894. if record_type == 1 {
  27895. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27896. } else if record_type == 2 {
  27897. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27898. } else if record_type == 3 {
  27899. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27900. }
  27901. var dat map[string]interface{}
  27902. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27903. fmt.Println(dat)
  27904. } else {
  27905. fmt.Println(err)
  27906. }
  27907. userJSONBytes, _ := json.Marshal(dat)
  27908. var res ResultSix
  27909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27910. utils.ErrorLog("解析失败:%v", err)
  27911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27912. return
  27913. }
  27914. if res.Infcode == 0 {
  27915. if record_type == 1 {
  27916. service.UpdateBaseDrugById(item.ID)
  27917. } else if record_type == 2 {
  27918. service.UpdateGoodInformaitonByDetail(item.ID)
  27919. } else if record_type == 3 {
  27920. service.UpdateProjectById(item.ID)
  27921. }
  27922. c.ServeSuccessJSON(map[string]interface{}{
  27923. "failed_code": 0,
  27924. "msg": "目录对照成功",
  27925. })
  27926. } else {
  27927. c.ServeSuccessJSON(map[string]interface{}{
  27928. "failed_code": -10,
  27929. "msg": res.ErrMsg,
  27930. })
  27931. }
  27932. }
  27933. }
  27934. }
  27935. func (c *HisApiController) UnCheckCode() {
  27936. ids_str := c.GetString("ids")
  27937. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27938. admin_user_id, _ := c.GetInt64("admin_user_id")
  27939. ids_arr := strings.Split(ids_str, ",")
  27940. var queryResult []QueryResult
  27941. ids := make([]int64, 0)
  27942. for _, item := range ids_arr {
  27943. id, _ := strconv.ParseInt(item, 10, 64)
  27944. ids = append(ids, id)
  27945. }
  27946. if record_type == 1 {
  27947. drugs, _ := service.GetBatchDrugList(ids)
  27948. for _, item := range drugs {
  27949. result := QueryResult{
  27950. ID: item.ID,
  27951. Name: item.DrugName,
  27952. Code: item.MedicalInsuranceNumber,
  27953. List_type_code: "101",
  27954. }
  27955. queryResult = append(queryResult, result)
  27956. }
  27957. } else if record_type == 2 {
  27958. goods, _ := service.GetBatchGoodInformationList(ids)
  27959. for _, item := range goods {
  27960. result := QueryResult{
  27961. ID: item.ID,
  27962. Name: item.GoodName,
  27963. Code: item.SocialSecurityDirectoryCode,
  27964. List_type_code: "301",
  27965. }
  27966. queryResult = append(queryResult, result)
  27967. }
  27968. } else if record_type == 3 {
  27969. projects, _ := service.GetBathchMyPorjecgList(ids)
  27970. for _, item := range projects {
  27971. result := QueryResult{
  27972. ID: item.ID,
  27973. Name: item.ProjectName,
  27974. Code: item.MedicalCode,
  27975. List_type_code: "201",
  27976. }
  27977. queryResult = append(queryResult, result)
  27978. }
  27979. }
  27980. adminUser := c.GetAdminUserInfo()
  27981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27982. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27983. var user_name string
  27984. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27985. if role.ID == 0 {
  27986. user_name = "xxx"
  27987. } else {
  27988. user_name = role.UserName
  27989. }
  27990. baseParams := &models.BaseParams{
  27991. SecretKey: miConfig.SecretKey,
  27992. FixmedinsCode: miConfig.Code,
  27993. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27994. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27995. OrgName: miConfig.OrgName,
  27996. Doctor: user_name,
  27997. }
  27998. if config.IsOpen == 1 {
  27999. if miConfig.MdtrtareaAdmvs == "430800" {
  28000. for _, item := range queryResult {
  28001. var result string
  28002. if record_type == 1 {
  28003. 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)
  28004. } else if record_type == 2 {
  28005. fmt.Println(item.Code)
  28006. 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)
  28007. } else if record_type == 3 {
  28008. 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)
  28009. }
  28010. var dat map[string]interface{}
  28011. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28012. fmt.Println(dat)
  28013. } else {
  28014. fmt.Println(err)
  28015. }
  28016. userJSONBytes, _ := json.Marshal(dat)
  28017. var res ResultSix
  28018. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28019. utils.ErrorLog("解析失败:%v", err)
  28020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28021. return
  28022. }
  28023. if res.Infcode == 0 {
  28024. if record_type == 1 {
  28025. service.UpdateBaseDrugById(item.ID)
  28026. } else if record_type == 2 {
  28027. service.UpdateGoodInformaitonByDetail(item.ID)
  28028. } else if record_type == 3 {
  28029. service.UpdateProjectById(item.ID)
  28030. }
  28031. c.ServeSuccessJSON(map[string]interface{}{
  28032. "failed_code": 0,
  28033. "msg": "目录对照成功",
  28034. })
  28035. } else {
  28036. c.ServeSuccessJSON(map[string]interface{}{
  28037. "failed_code": -10,
  28038. "msg": res.ErrMsg,
  28039. })
  28040. }
  28041. }
  28042. } else {
  28043. for _, item := range queryResult {
  28044. var result string
  28045. if record_type == 1 {
  28046. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28047. } else if record_type == 2 {
  28048. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28049. } else if record_type == 3 {
  28050. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28051. }
  28052. var dat2 map[string]interface{}
  28053. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28054. fmt.Println(dat2)
  28055. } else {
  28056. fmt.Println(err)
  28057. }
  28058. userJSONBytes, _ := json.Marshal(dat2)
  28059. var res ResultSix
  28060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28061. utils.ErrorLog("解析失败:%v", err)
  28062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28063. return
  28064. }
  28065. if res.Infcode == 0 {
  28066. if record_type == 1 {
  28067. service.UpdateDrugByIdDetail(item.ID)
  28068. } else if record_type == 2 {
  28069. service.UpdateGoodInfoById(item.ID)
  28070. } else if record_type == 3 {
  28071. service.UpdateMyProjectById(item.ID)
  28072. }
  28073. c.ServeSuccessJSON(map[string]interface{}{
  28074. "failed_code": 0,
  28075. "msg": "撤销目录对照成功",
  28076. })
  28077. } else {
  28078. c.ServeSuccessJSON(map[string]interface{}{
  28079. "failed_code": -10,
  28080. "msg": res.ErrMsg,
  28081. })
  28082. }
  28083. }
  28084. }
  28085. }
  28086. }
  28087. func (c *HisApiController) GetPatientInfo() {
  28088. id_card_no := c.GetString("id_card_no")
  28089. admin_user_id, _ := c.GetInt64("admin_user_id")
  28090. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28091. if patient.ID == 0 {
  28092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28093. return
  28094. }
  28095. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28096. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28097. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28098. var res ResultTwo
  28099. var res10265 ResultTwo10265
  28100. if config.IsOpen == 1 {
  28101. if miConfig.MdtrtareaAdmvs == "150499" {
  28102. //请求内网数据
  28103. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28104. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28105. "&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
  28106. resp, requestErr := http.Get(api)
  28107. if requestErr != nil {
  28108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28109. return
  28110. }
  28111. body, ioErr := ioutil.ReadAll(resp.Body)
  28112. if ioErr != nil {
  28113. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28115. return
  28116. }
  28117. var respJSON map[string]interface{}
  28118. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28121. return
  28122. }
  28123. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28124. result_byte, _ := json.Marshal(respJSON)
  28125. result := string(result_byte)
  28126. var dat map[string]interface{}
  28127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28128. fmt.Println(dat)
  28129. } else {
  28130. fmt.Println(err)
  28131. }
  28132. userJSONBytes, _ := json.Marshal(dat)
  28133. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28134. utils.ErrorLog("解析失败:%v", err)
  28135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28136. return
  28137. }
  28138. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28139. res.Infcode = Infcode
  28140. res.ErrMsg = res10265.ErrMsg
  28141. res.Output = res10265.Output
  28142. res.InfRefmsgid = res10265.InfRefmsgid
  28143. res.RespondTime = res10265.RespondTime
  28144. res.WarnInfo = res10265.WarnInfo
  28145. } else {
  28146. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28147. var dat map[string]interface{}
  28148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28149. fmt.Println(dat)
  28150. } else {
  28151. fmt.Println(err)
  28152. }
  28153. userJSONBytes, _ := json.Marshal(dat)
  28154. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28155. utils.ErrorLog("解析失败:%v", err)
  28156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28157. return
  28158. }
  28159. }
  28160. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28161. // utils.ErrorLog("解析失败:%v", err)
  28162. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28163. // return
  28164. //}
  28165. for index, item := range res.Output.Iinfo {
  28166. if item.PsnInsuStas == "2" {
  28167. fmt.Println("--------")
  28168. res.Output.Iinfo[index].Insutype = "300"
  28169. res.Output.Iinfo[index].PsnInsuStas = "1"
  28170. }
  28171. }
  28172. fmt.Println(res.Output.Iinfo)
  28173. if res.Infcode != 0 {
  28174. c.ServeSuccessJSON(map[string]interface{}{
  28175. "failed_code": -10,
  28176. "msg": res.ErrMsg,
  28177. })
  28178. } else {
  28179. c.ServeSuccessJSON(map[string]interface{}{
  28180. "failed_code": 0,
  28181. "info": res,
  28182. })
  28183. }
  28184. }
  28185. }
  28186. func (c *HisApiController) PsnPutOnRecord() {
  28187. record_type, _ := c.GetInt64("type")
  28188. patient_id, _ := c.GetInt64("patient_id")
  28189. admin_user_id, _ := c.GetInt64("admin_user_id")
  28190. start_time := c.GetString("start_time")
  28191. end_time := c.GetString("end_time")
  28192. adminUser := c.GetAdminUserInfo()
  28193. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28194. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28195. var patients []*models.Patients
  28196. if record_type == 1 { //全部备案
  28197. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28198. patients = append(patients, patient...)
  28199. } else { //单个备案
  28200. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28201. patients = append(patients, patient)
  28202. }
  28203. var user_name string
  28204. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28205. if role.ID == 0 {
  28206. user_name = "xxx"
  28207. } else {
  28208. user_name = role.UserName
  28209. }
  28210. if config.IsOpen == 1 {
  28211. for _, item := range patients {
  28212. 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
  28213. resp, requestErr := http.Get(api)
  28214. if requestErr != nil {
  28215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28216. return
  28217. }
  28218. defer resp.Body.Close()
  28219. body, ioErr := ioutil.ReadAll(resp.Body)
  28220. if ioErr != nil {
  28221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28223. return
  28224. }
  28225. var respJSON map[string]interface{}
  28226. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28229. return
  28230. }
  28231. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28232. userJSONBytes, _ := json.Marshal(userJSON)
  28233. var res ResultTwo
  28234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28235. utils.ErrorLog("解析失败:%v", err)
  28236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28237. return
  28238. }
  28239. if res.Infcode == 0 {
  28240. 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)
  28241. var dat map[string]interface{}
  28242. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28243. fmt.Println(dat)
  28244. } else {
  28245. fmt.Println(err)
  28246. }
  28247. userJSONBytes, _ := json.Marshal(dat)
  28248. var res2 ResultThirteen
  28249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28250. utils.ErrorLog("解析失败:%v", err)
  28251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28252. return
  28253. }
  28254. if res2.Infcode == 0 {
  28255. psnResult := &models.GdybPsnRecord{
  28256. UserOrgId: adminUser.CurrentOrgId,
  28257. PatientId: item.ID,
  28258. PsnNo: res.Output.Baseinfo.PsnNo,
  28259. Ctime: time.Now().Unix(),
  28260. Mtime: time.Now().Unix(),
  28261. Status: 1,
  28262. IsCancel: 1,
  28263. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28264. }
  28265. service.CreatePsnRecord(psnResult)
  28266. } else {
  28267. c.ServeSuccessJSON(map[string]interface{}{
  28268. "failed_code": -10,
  28269. "msg": res2.ErrMsg,
  28270. })
  28271. return
  28272. }
  28273. }
  28274. }
  28275. }
  28276. }
  28277. func (c *HisApiController) PsnUnPutOnRecord() {
  28278. id, _ := c.GetInt64("id")
  28279. //record_type, _ := c.GetInt64("type")
  28280. admin_user_id, _ := c.GetInt64("admin_user_id")
  28281. adminUser := c.GetAdminUserInfo()
  28282. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28283. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28284. var user_name string
  28285. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28286. if role.ID == 0 {
  28287. user_name = "xxx"
  28288. } else {
  28289. user_name = role.UserName
  28290. }
  28291. psn_record, _ := service.GetPsnRecordById(id)
  28292. if psn_record.ID == 0 {
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28294. return
  28295. }
  28296. if config.IsOpen == 1 {
  28297. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28298. var dat map[string]interface{}
  28299. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28300. fmt.Println(dat)
  28301. } else {
  28302. fmt.Println(err)
  28303. }
  28304. userJSONBytes, _ := json.Marshal(dat)
  28305. var res ResultFourteen
  28306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28307. utils.ErrorLog("解析失败:%v", err)
  28308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28309. return
  28310. }
  28311. if res.Infcode == 0 {
  28312. psn_record.IsCancel = 2
  28313. service.CreatePsnRecord(&psn_record)
  28314. } else {
  28315. c.ServeSuccessJSON(map[string]interface{}{
  28316. "failed_code": -10,
  28317. "msg": res.ErrMsg,
  28318. })
  28319. return
  28320. }
  28321. }
  28322. }
  28323. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28324. patient_id, _ := c.GetInt64("patient_id")
  28325. insutype_two := c.GetString("insutype")
  28326. psn_no := c.GetString("psn_no")
  28327. doctor_id, _ := c.GetInt64("doctor_id")
  28328. sick_id, _ := c.GetInt64("sick_id")
  28329. department_id, _ := c.GetInt64("department_id")
  28330. start_time := c.GetString("start_time")
  28331. end_time := c.GetString("end_time")
  28332. check_time := c.GetString("check_time")
  28333. hospital_code := c.GetString("hospital_code")
  28334. hospital_name := c.GetString("hospital_name")
  28335. adminUser := c.GetAdminUserInfo()
  28336. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28337. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28338. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28339. sick, _ := service.FindSickById(sick_id)
  28340. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28341. if len(hospital_code) == 0 {
  28342. hospital_code = miConfig.Code
  28343. }
  28344. if len(hospital_name) == 0 {
  28345. hospital_name = miConfig.OrgName
  28346. }
  28347. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28348. var res ResultTwo
  28349. var res10265 ResultTwo10265
  28350. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28351. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28352. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28353. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28354. "&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
  28355. resp, requestErr := http.Get(api)
  28356. if requestErr != nil {
  28357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28358. return
  28359. }
  28360. body, ioErr := ioutil.ReadAll(resp.Body)
  28361. if ioErr != nil {
  28362. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28364. return
  28365. }
  28366. var respJSON map[string]interface{}
  28367. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28368. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28370. return
  28371. }
  28372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28373. result, _ := json.Marshal(respJSON)
  28374. fmt.Println("log")
  28375. fmt.Println(string(result))
  28376. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28377. utils.ErrorLog("解析失败:%v", err)
  28378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28379. return
  28380. }
  28381. res.ErrMsg = res10265.ErrMsg
  28382. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28383. res.Infcode = infocode
  28384. res.Output = res10265.Output
  28385. res.InfRefmsgid = res10265.InfRefmsgid
  28386. } else {
  28387. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28388. if miConfig.Code == "H15049901371" {
  28389. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28390. utils.ErrorLog("解析失败:%v", err)
  28391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28392. return
  28393. }
  28394. res.ErrMsg = res10265.ErrMsg
  28395. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28396. res.Infcode = infocode
  28397. res.Output = res10265.Output
  28398. res.InfRefmsgid = res10265.InfRefmsgid
  28399. } else {
  28400. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28401. utils.ErrorLog("解析失败:%v", err)
  28402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28403. return
  28404. }
  28405. }
  28406. }
  28407. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28408. infoStr := string(Iinfos)
  28409. var rf []*ResultFive
  28410. json.Unmarshal([]byte(infoStr), &rf)
  28411. var insuplc_admdvs string
  28412. var insutype string
  28413. var is390 int = 0
  28414. var is310 int = 0
  28415. var insutypes []*ResultFive
  28416. for _, item := range rf {
  28417. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28418. insutypes = append(insutypes, item)
  28419. }
  28420. }
  28421. if len(insutypes) == 1 {
  28422. insutype = insutypes[0].Insutype
  28423. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28424. } else {
  28425. for _, i := range insutypes {
  28426. if i.Insutype == "390" {
  28427. is390 = 1
  28428. }
  28429. if i.Insutype == "310" {
  28430. is310 = 1
  28431. }
  28432. }
  28433. }
  28434. if is390 == 1 {
  28435. insutype = "390"
  28436. }
  28437. if is310 == 1 {
  28438. insutype = "310"
  28439. }
  28440. if len(insutypes) == 2 {
  28441. insutype = insutype_two
  28442. }
  28443. if len(insutypes) == 0 {
  28444. insutype = "310"
  28445. }
  28446. insutype = insutype_two
  28447. fmt.Println(insutype)
  28448. for _, item := range rf {
  28449. fmt.Println(item.Insutype)
  28450. fmt.Println(insutype)
  28451. if item.Insutype == insutype {
  28452. fmt.Println(item.Insutype)
  28453. fmt.Println(insutype)
  28454. insuplc_admdvs = item.InsuplcAdmdvs
  28455. }
  28456. }
  28457. fmt.Println(insuplc_admdvs)
  28458. var res2 ResultThirteen
  28459. var res10265_2 ResultThirteen10265
  28460. if config.IsOpen == 1 {
  28461. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28462. } else {
  28463. if miConfig.MdtrtareaAdmvs == "150499" {
  28464. //
  28465. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28466. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28467. // "&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
  28468. //resp, requestErr := http.Get(api)
  28469. //if requestErr != nil {
  28470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28471. // return
  28472. //}
  28473. //
  28474. //body, ioErr := ioutil.ReadAll(resp.Body)
  28475. //if ioErr != nil {
  28476. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28478. // return
  28479. //}
  28480. //var respJSON map[string]interface{}
  28481. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28482. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28484. // return
  28485. //}
  28486. //
  28487. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28488. //result, _ := json.Marshal(respJSON)
  28489. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28490. // utils.ErrorLog("解析失败:%v", err)
  28491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28492. // return
  28493. //}
  28494. //infocode = resThree.Infcode
  28495. //result, _ := json.Marshal(respJSON)
  28496. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28497. // utils.ErrorLog("解析失败:%v", err)
  28498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28499. // return
  28500. //}
  28501. //
  28502. //resThree.ErrMsg = resThree10265.ErrMsg
  28503. //
  28504. //resThree.Output = resThree10265.Output
  28505. //
  28506. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28507. //
  28508. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28509. //
  28510. } else {
  28511. 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)
  28512. var dat map[string]interface{}
  28513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28514. fmt.Println(dat)
  28515. } else {
  28516. fmt.Println(err)
  28517. }
  28518. userJSONBytes, _ := json.Marshal(dat)
  28519. if miConfig.Code == "H15049901371" {
  28520. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28521. utils.ErrorLog("解析失败:%v", err)
  28522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28523. return
  28524. }
  28525. res2.ErrMsg = res10265_2.ErrMsg
  28526. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28527. res2.Infcode = infocode
  28528. res2.Output = res10265_2.Output
  28529. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28530. } else {
  28531. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28532. utils.ErrorLog("解析失败:%v", err)
  28533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28534. return
  28535. }
  28536. }
  28537. }
  28538. }
  28539. if res2.Infcode == 0 {
  28540. psnResult := &models.GdybPsnNcdsRecord{
  28541. UserOrgId: adminUser.CurrentOrgId,
  28542. PatientId: patient.ID,
  28543. PsnNo: psn_no,
  28544. DoctorId: doctor.AdminUserId,
  28545. DepartmentId: department_id,
  28546. SickType: sick_id,
  28547. Insutype: insutype,
  28548. Ctime: time.Now().Unix(),
  28549. Mtime: time.Now().Unix(),
  28550. Status: 1,
  28551. IsCancel: 1,
  28552. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28553. }
  28554. service.CreatePsnNCDSRecord(psnResult)
  28555. c.ServeSuccessJSON(map[string]interface{}{
  28556. "failed_code": 0,
  28557. "msg": "备案成功",
  28558. "result": psnResult,
  28559. })
  28560. } else {
  28561. c.ServeSuccessJSON(map[string]interface{}{
  28562. "failed_code": -10,
  28563. "msg": res2.ErrMsg,
  28564. })
  28565. return
  28566. }
  28567. }
  28568. }
  28569. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28570. id, _ := c.GetInt64("id")
  28571. admin_user_id, _ := c.GetInt64("admin_user_id")
  28572. adminUser := c.GetAdminUserInfo()
  28573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28574. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28575. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28576. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28577. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28578. //var user_name string
  28579. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28580. //if role.ID == 0 {
  28581. // user_name = "xxx"
  28582. //} else {
  28583. // user_name = role.UserName
  28584. //}
  28585. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28586. if psn_record.ID == 0 {
  28587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28588. return
  28589. }
  28590. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28591. var res ResultTwo
  28592. var res10265 ResultTwo10265
  28593. if miConfig.Code == "H15049901371" {
  28594. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28595. utils.ErrorLog("解析失败:%v", err)
  28596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28597. return
  28598. }
  28599. res.ErrMsg = res10265.ErrMsg
  28600. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28601. res.Infcode = infocode
  28602. res.Output = res10265.Output
  28603. res.InfRefmsgid = res10265.InfRefmsgid
  28604. } else {
  28605. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28606. utils.ErrorLog("解析失败:%v", err)
  28607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28608. return
  28609. }
  28610. }
  28611. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28612. infoStr := string(Iinfos)
  28613. var rf []*ResultFive
  28614. json.Unmarshal([]byte(infoStr), &rf)
  28615. var insuplc_admdvs string
  28616. var insutype string
  28617. var is390 int = 0
  28618. var is310 int = 0
  28619. var insutypes []*ResultFive
  28620. for _, item := range rf {
  28621. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28622. insutypes = append(insutypes, item)
  28623. }
  28624. }
  28625. if len(insutypes) == 1 {
  28626. insutype = insutypes[0].Insutype
  28627. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28628. } else {
  28629. for _, i := range insutypes {
  28630. if i.Insutype == "390" {
  28631. is390 = 1
  28632. }
  28633. if i.Insutype == "310" {
  28634. is310 = 1
  28635. }
  28636. }
  28637. }
  28638. if is390 == 1 {
  28639. insutype = "390"
  28640. }
  28641. if is310 == 1 {
  28642. insutype = "310"
  28643. }
  28644. if len(insutypes) == 0 {
  28645. insutype = "310"
  28646. }
  28647. insutype = psn_record.Insutype
  28648. for _, item := range rf {
  28649. if item.Insutype == insutype {
  28650. insuplc_admdvs = item.InsuplcAdmdvs
  28651. }
  28652. }
  28653. if config.IsOpen == 1 {
  28654. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28655. var dat map[string]interface{}
  28656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28657. fmt.Println(dat)
  28658. } else {
  28659. fmt.Println(err)
  28660. }
  28661. userJSONBytes, _ := json.Marshal(dat)
  28662. var res ResultFourteen
  28663. var res10265 ResultFourteen10265
  28664. if miConfig.Code == "H15049901371" {
  28665. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28666. utils.ErrorLog("解析失败:%v", err)
  28667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28668. return
  28669. }
  28670. res.ErrMsg = res10265.ErrMsg
  28671. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28672. res.Infcode = infocode
  28673. res.Output = res10265.Output
  28674. res.InfRefmsgid = res10265.InfRefmsgid
  28675. } else {
  28676. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28677. utils.ErrorLog("解析失败:%v", err)
  28678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28679. return
  28680. }
  28681. }
  28682. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28683. // utils.ErrorLog("解析失败:%v", err)
  28684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28685. // return
  28686. //}
  28687. if res.Infcode == 0 {
  28688. psn_record.IsCancel = 2
  28689. service.CreatePsnNCDSRecord(&psn_record)
  28690. c.ServeSuccessJSON(map[string]interface{}{
  28691. "failed_code": 0,
  28692. "msg": "撤销备案成功",
  28693. })
  28694. } else {
  28695. c.ServeSuccessJSON(map[string]interface{}{
  28696. "failed_code": -10,
  28697. "msg": res.ErrMsg,
  28698. })
  28699. return
  28700. }
  28701. }
  28702. }
  28703. func (c *HisApiController) TestTest() {
  28704. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28705. fmt.Println(patient.Iinfo)
  28706. }
  28707. type CustomData struct {
  28708. MsgId string
  28709. PsnNo string
  28710. Info string
  28711. }
  28712. func (c *HisApiController) ReversalData() {
  28713. var customData []*CustomData
  28714. custom := &CustomData{
  28715. MsgId: "H44022900158202103301714472004",
  28716. PsnNo: "44020000001101329945",
  28717. Info: "2207",
  28718. }
  28719. customData = append(customData, custom)
  28720. custom1 := &CustomData{
  28721. MsgId: "H4402290015820210330172057803",
  28722. PsnNo: "44020000001101161813",
  28723. Info: "2207",
  28724. }
  28725. customData = append(customData, custom1)
  28726. custom2 := &CustomData{
  28727. MsgId: "H44022900158202103301705198813",
  28728. PsnNo: "44190000133097375417",
  28729. Info: "2207",
  28730. }
  28731. customData = append(customData, custom2)
  28732. custom3 := &CustomData{
  28733. MsgId: "H44022900158202103301715524756",
  28734. PsnNo: "44020000001100187221",
  28735. Info: "2207",
  28736. }
  28737. customData = append(customData, custom3)
  28738. custom4 := &CustomData{
  28739. MsgId: "H44022900158202103301730376224",
  28740. PsnNo: "44020000001101959155",
  28741. Info: "2207",
  28742. }
  28743. customData = append(customData, custom4)
  28744. custom5 := &CustomData{
  28745. MsgId: "H44022900158202103301748008725",
  28746. PsnNo: "44020000001104246641",
  28747. Info: "2207",
  28748. }
  28749. customData = append(customData, custom5)
  28750. custom6 := &CustomData{
  28751. MsgId: "H44022900158202103301718096755",
  28752. PsnNo: "44020000001102211860",
  28753. Info: "2207",
  28754. }
  28755. customData = append(customData, custom6)
  28756. custom7 := &CustomData{
  28757. MsgId: "H44022900158202103301736551640",
  28758. PsnNo: "44020000001102687718",
  28759. Info: "2207",
  28760. }
  28761. customData = append(customData, custom7)
  28762. custom8 := &CustomData{
  28763. MsgId: "H44022900158202103301743097676",
  28764. PsnNo: "44020000001102127785",
  28765. Info: "2207",
  28766. }
  28767. customData = append(customData, custom8)
  28768. custom9 := &CustomData{
  28769. MsgId: "H44022900158202103301712304203",
  28770. PsnNo: "44020000001101518097",
  28771. Info: "2207",
  28772. }
  28773. customData = append(customData, custom9)
  28774. custom10 := &CustomData{
  28775. MsgId: "H44022900158202103301738448785",
  28776. PsnNo: "44020000001100500813",
  28777. Info: "2207",
  28778. }
  28779. customData = append(customData, custom10)
  28780. custom11 := &CustomData{
  28781. MsgId: "H44022900158202103301732455843",
  28782. PsnNo: "44020000001102690557",
  28783. Info: "2207",
  28784. }
  28785. customData = append(customData, custom11)
  28786. custom12 := &CustomData{
  28787. MsgId: "H44022900158202103301745421708",
  28788. PsnNo: "44020000001102211928",
  28789. Info: "2207",
  28790. }
  28791. customData = append(customData, custom12)
  28792. custom1212 := &CustomData{
  28793. MsgId: "H440229001582021033017351627",
  28794. PsnNo: "44020000001102481733",
  28795. Info: "2207",
  28796. }
  28797. customData = append(customData, custom1212)
  28798. custom13 := &CustomData{
  28799. MsgId: "H44022900158202103301740327951",
  28800. PsnNo: "44020000001103174866",
  28801. Info: "2207",
  28802. }
  28803. customData = append(customData, custom13)
  28804. custom14 := &CustomData{
  28805. MsgId: "H4402290015820210330174922668",
  28806. PsnNo: "44020000001102927272",
  28807. Info: "2207",
  28808. }
  28809. customData = append(customData, custom14)
  28810. custom15 := &CustomData{
  28811. MsgId: "H44022900158202103301752362273",
  28812. PsnNo: "44020000001102942890",
  28813. Info: "2207",
  28814. }
  28815. customData = append(customData, custom15)
  28816. custom16 := &CustomData{
  28817. MsgId: "H44022900158202103301751082917",
  28818. PsnNo: "44020000001101662162",
  28819. Info: "2207",
  28820. }
  28821. customData = append(customData, custom16)
  28822. custom17 := &CustomData{
  28823. MsgId: "H44022900158202103301754147728",
  28824. PsnNo: "44020000000229014511",
  28825. Info: "2207",
  28826. }
  28827. customData = append(customData, custom17)
  28828. adminUser := c.GetAdminUserInfo()
  28829. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28830. for _, item := range customData {
  28831. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28832. fmt.Println(result)
  28833. }
  28834. }
  28835. func (c *HisApiController) GetAllopatry() {
  28836. year := c.GetString("year")
  28837. month := c.GetString("month")
  28838. admin_user_id, _ := c.GetInt64("admin_user_id")
  28839. adminUser := c.GetAdminUserInfo()
  28840. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28841. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28842. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28843. var dat map[string]interface{}
  28844. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28845. fmt.Println(dat)
  28846. } else {
  28847. fmt.Println(err)
  28848. }
  28849. userJSONBytes, _ := json.Marshal(dat)
  28850. var res models.Result9001
  28851. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28852. utils.ErrorLog("解析失败:%v", err)
  28853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28854. return
  28855. }
  28856. fmt.Println(res.Output.Signinoutb)
  28857. fmt.Println(res.Output.Signinoutb.SignNo)
  28858. fmt.Println(string(userJSONBytes))
  28859. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28860. var dat3 map[string]interface{}
  28861. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  28862. fmt.Println(dat3)
  28863. } else {
  28864. fmt.Println(err)
  28865. }
  28866. userJSONBytes3, _ := json.Marshal(dat3)
  28867. var res3 models.Result3260
  28868. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  28869. utils.ErrorLog("解析失败:%v", err)
  28870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28871. return
  28872. }
  28873. var curpage int
  28874. var pagesize int = 100
  28875. var start int = 1
  28876. //var stop int
  28877. //pagecount := 10
  28878. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  28879. var res22 []models.Result3260
  28880. for curpage = 1; curpage <= pagecount; curpage++ {
  28881. if curpage == 1 {
  28882. start = 0
  28883. } else {
  28884. start = (curpage-1)*pagesize + 1
  28885. }
  28886. fmt.Println(start)
  28887. //stop = curpage * pagesize
  28888. //if stop > int(res3.Output.Totalrow) {
  28889. // stop =int(res3.Output.Totalrow)
  28890. //}
  28891. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28892. var dat2 map[string]interface{}
  28893. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28894. fmt.Println(dat)
  28895. } else {
  28896. fmt.Println(err)
  28897. }
  28898. userJSONBytes2, _ := json.Marshal(dat2)
  28899. var res2 models.Result3260
  28900. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28901. utils.ErrorLog("解析失败:%v", err)
  28902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28903. return
  28904. }
  28905. if res2.Infcode == 0 {
  28906. res22 = append(res22, res2)
  28907. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28908. //var dat2 map[string]interface{}
  28909. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28910. // fmt.Println(dat)
  28911. //} else {
  28912. // fmt.Println(err)
  28913. //}
  28914. //c.ServeSuccessJSON(map[string]interface{}{
  28915. // "list": res2.Output.Data,
  28916. //})
  28917. //continue
  28918. }
  28919. }
  28920. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28921. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28922. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28923. //var dat2 map[string]interface{}
  28924. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28925. // fmt.Println(dat)
  28926. //} else {
  28927. // fmt.Println(err)
  28928. //}
  28929. //userJSONBytes2, _ := json.Marshal(dat2)
  28930. //var res2 models.Result3260
  28931. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28932. // utils.ErrorLog("解析失败:%v", err)
  28933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28934. // return
  28935. //}
  28936. //if res2.Infcode == 0 {
  28937. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28938. // var dat2 map[string]interface{}
  28939. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28940. // fmt.Println(dat)
  28941. // } else {
  28942. // fmt.Println(err)
  28943. // }
  28944. // c.ServeSuccessJSON(map[string]interface{}{
  28945. // "list": res2.Output.Data,
  28946. // })
  28947. //}
  28948. }
  28949. func (c *HisApiController) ComfirmAllopatry() {
  28950. year := c.GetString("year")
  28951. month := c.GetString("month")
  28952. admin_user_id, _ := c.GetInt64("admin_user_id")
  28953. adminUser := c.GetAdminUserInfo()
  28954. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28955. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28956. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28957. var dat map[string]interface{}
  28958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28959. fmt.Println(dat)
  28960. } else {
  28961. fmt.Println(err)
  28962. }
  28963. userJSONBytes, _ := json.Marshal(dat)
  28964. var res models.Result9001
  28965. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28966. utils.ErrorLog("解析失败:%v", err)
  28967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28968. return
  28969. }
  28970. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28971. var dat2 map[string]interface{}
  28972. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28973. fmt.Println(dat)
  28974. } else {
  28975. fmt.Println(err)
  28976. }
  28977. userJSONBytes2, _ := json.Marshal(dat2)
  28978. var res2 models.Result3260
  28979. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28980. utils.ErrorLog("解析失败:%v", err)
  28981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28982. return
  28983. }
  28984. //if res2.Infcode == 0 {
  28985. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28986. // var dat map[string]interface{}
  28987. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28988. // fmt.Println(dat)
  28989. // } else {
  28990. // fmt.Println(err)
  28991. // }
  28992. // userJSONBytes, _ := json.Marshal(dat)
  28993. // var res3 models.Result3261
  28994. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  28995. // utils.ErrorLog("解析失败:%v", err)
  28996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28997. // return
  28998. // }
  28999. //
  29000. // if res3.Infcode == 0 {
  29001. // record := &models.HisYidiClearRecord{
  29002. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29003. // Ctime: time.Now().Unix(),
  29004. // Mtime: time.Now().Unix(),
  29005. // Status: 1,
  29006. // MsgId: msgId,
  29007. // }
  29008. // service.SaveClearRecord(record)
  29009. // c.ServeSuccessJSON(map[string]interface{}{
  29010. // "msg": "提取成功",
  29011. // })
  29012. // }
  29013. //}
  29014. }
  29015. func (c *HisApiController) RefundAllopatry() {
  29016. year := c.GetString("year")
  29017. month := c.GetString("month")
  29018. //id, _ := c.GetInt64("id")
  29019. admin_user_id, _ := c.GetInt64("admin_user_id")
  29020. adminUser := c.GetAdminUserInfo()
  29021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29022. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29023. //record, _ := service.GetClearRecordById(id)
  29024. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29025. var dat map[string]interface{}
  29026. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29027. fmt.Println(dat)
  29028. } else {
  29029. fmt.Println(err)
  29030. }
  29031. userJSONBytes, _ := json.Marshal(dat)
  29032. var res models.Result9001
  29033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29034. utils.ErrorLog("解析失败:%v", err)
  29035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29036. return
  29037. }
  29038. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29039. var dat2 map[string]interface{}
  29040. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29041. fmt.Println(dat)
  29042. } else {
  29043. fmt.Println(err)
  29044. }
  29045. userJSONBytes2, _ := json.Marshal(dat2)
  29046. var empty ResultFourteen
  29047. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29048. utils.ErrorLog("解析失败:%v", err)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. if empty.Infcode == 0 {
  29053. c.ServeSuccessJSON(map[string]interface{}{
  29054. "msg": "撤销成功",
  29055. })
  29056. return
  29057. }
  29058. }
  29059. func (c *HisApiController) ReversalOtherData() {
  29060. var customData []*CustomData
  29061. custom := &CustomData{
  29062. MsgId: "H44022900158202103301714472004",
  29063. PsnNo: "44020000001101329945",
  29064. Info: "2208",
  29065. }
  29066. customData = append(customData, custom)
  29067. custom1 := &CustomData{
  29068. MsgId: "H4402290015820210330172057803",
  29069. PsnNo: "44020000001101161813",
  29070. Info: "2208",
  29071. }
  29072. customData = append(customData, custom1)
  29073. custom2 := &CustomData{
  29074. MsgId: "H44022900158202103301705198813",
  29075. PsnNo: "44190000133097375417",
  29076. Info: "2208",
  29077. }
  29078. customData = append(customData, custom2)
  29079. custom3 := &CustomData{
  29080. MsgId: "H44022900158202103301715524756",
  29081. PsnNo: "44020000001100187221",
  29082. Info: "2208",
  29083. }
  29084. customData = append(customData, custom3)
  29085. custom4 := &CustomData{
  29086. MsgId: "H44022900158202103301730376224",
  29087. PsnNo: "44020000001101959155",
  29088. Info: "2208",
  29089. }
  29090. customData = append(customData, custom4)
  29091. custom5 := &CustomData{
  29092. MsgId: "H44022900158202103301748008725",
  29093. PsnNo: "44020000001104246641",
  29094. Info: "2208",
  29095. }
  29096. customData = append(customData, custom5)
  29097. custom6 := &CustomData{
  29098. MsgId: "H44022900158202103301718096755",
  29099. PsnNo: "44020000001102211860",
  29100. Info: "2208",
  29101. }
  29102. customData = append(customData, custom6)
  29103. custom7 := &CustomData{
  29104. MsgId: "H44022900158202103301736551640",
  29105. PsnNo: "44020000001102687718",
  29106. Info: "2208",
  29107. }
  29108. customData = append(customData, custom7)
  29109. custom8 := &CustomData{
  29110. MsgId: "H44022900158202103301743097676",
  29111. PsnNo: "44020000001102127785",
  29112. Info: "2208",
  29113. }
  29114. customData = append(customData, custom8)
  29115. custom9 := &CustomData{
  29116. MsgId: "H44022900158202103301712304203",
  29117. PsnNo: "44020000001101518097",
  29118. Info: "2208",
  29119. }
  29120. customData = append(customData, custom9)
  29121. custom10 := &CustomData{
  29122. MsgId: "H44022900158202103301738448785",
  29123. PsnNo: "44020000001100500813",
  29124. Info: "2208",
  29125. }
  29126. customData = append(customData, custom10)
  29127. custom11 := &CustomData{
  29128. MsgId: "H44022900158202103301732455843",
  29129. PsnNo: "44020000001102690557",
  29130. Info: "2208",
  29131. }
  29132. customData = append(customData, custom11)
  29133. custom12 := &CustomData{
  29134. MsgId: "H44022900158202103301745421708",
  29135. PsnNo: "44020000001102211928",
  29136. Info: "2208",
  29137. }
  29138. customData = append(customData, custom12)
  29139. custom1212 := &CustomData{
  29140. MsgId: "H440229001582021033017351627",
  29141. PsnNo: "44020000001102481733",
  29142. Info: "2208",
  29143. }
  29144. customData = append(customData, custom1212)
  29145. custom13 := &CustomData{
  29146. MsgId: "H44022900158202103301740327951",
  29147. PsnNo: "44020000001103174866",
  29148. Info: "2208",
  29149. }
  29150. customData = append(customData, custom13)
  29151. custom14 := &CustomData{
  29152. MsgId: "H4402290015820210330174922668",
  29153. PsnNo: "44020000001102927272",
  29154. Info: "2208",
  29155. }
  29156. customData = append(customData, custom14)
  29157. custom15 := &CustomData{
  29158. MsgId: "H44022900158202103301752362273",
  29159. PsnNo: "44020000001102942890",
  29160. Info: "2208",
  29161. }
  29162. customData = append(customData, custom15)
  29163. custom16 := &CustomData{
  29164. MsgId: "H44022900158202103301751082917",
  29165. PsnNo: "44020000001101662162",
  29166. Info: "2208",
  29167. }
  29168. customData = append(customData, custom16)
  29169. custom17 := &CustomData{
  29170. MsgId: "H44022900158202103301754147728",
  29171. PsnNo: "44020000000229014511",
  29172. Info: "2208",
  29173. }
  29174. customData = append(customData, custom17)
  29175. adminUser := c.GetAdminUserInfo()
  29176. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29177. for _, item := range customData {
  29178. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29179. fmt.Println(result)
  29180. }
  29181. }
  29182. func PathExists(path string) (bool, error) {
  29183. _, err := os.Stat(path)
  29184. if err == nil {
  29185. return true, nil
  29186. }
  29187. if os.IsNotExist(err) {
  29188. return false, nil
  29189. }
  29190. return false, err
  29191. }
  29192. // 创建文件夹
  29193. func Mkdir(dir string) {
  29194. // 创建文件夹
  29195. exist, err := PathExists(dir)
  29196. if err != nil {
  29197. fmt.Println(err.Error())
  29198. } else {
  29199. if exist {
  29200. fmt.Println(dir + "文件夹已存在!")
  29201. } else {
  29202. // 文件夹名称,权限
  29203. err := os.Mkdir(dir, os.ModePerm)
  29204. if err != nil {
  29205. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29206. } else {
  29207. fmt.Println(dir + "文件夹创建成功!")
  29208. }
  29209. }
  29210. }
  29211. }
  29212. // 压缩文件
  29213. func Zip(srcFile string, destZip string) error {
  29214. zipfile, err := os.Create(destZip)
  29215. if err != nil {
  29216. return err
  29217. }
  29218. defer zipfile.Close()
  29219. archive := zip.NewWriter(zipfile)
  29220. defer archive.Close()
  29221. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29222. if err != nil {
  29223. return err
  29224. }
  29225. header, err := zip.FileInfoHeader(info)
  29226. if err != nil {
  29227. return err
  29228. }
  29229. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29230. // header.Name = path
  29231. if info.IsDir() {
  29232. header.Name += "/"
  29233. } else {
  29234. header.Method = zip.Deflate
  29235. }
  29236. writer, err := archive.CreateHeader(header)
  29237. if err != nil {
  29238. return err
  29239. }
  29240. if !info.IsDir() {
  29241. file, err := os.Open(path)
  29242. if err != nil {
  29243. return err
  29244. }
  29245. defer file.Close()
  29246. _, err = io.Copy(writer, file)
  29247. }
  29248. return err
  29249. })
  29250. return err
  29251. }
  29252. func ReadFile(filePath string) []byte {
  29253. f, err := os.Open(filePath)
  29254. if err != nil {
  29255. fmt.Println("read file fail", err)
  29256. return nil
  29257. }
  29258. defer f.Close()
  29259. fd, err := ioutil.ReadAll(f)
  29260. if err != nil {
  29261. fmt.Println("read to fd fail", err)
  29262. return nil
  29263. }
  29264. return fd
  29265. }
  29266. func saveLogq(result string, request string, infno string, desc string) {
  29267. dir := "日志"
  29268. utils.Mkdir(dir)
  29269. month := time.Unix(1557042972, 0).Format("1")
  29270. year := time.Now().Format("2006")
  29271. month = time.Now().Format("01")
  29272. day := time.Now().Format("02")
  29273. hour := time.Now().Format("15")
  29274. min := time.Now().Format("04")
  29275. sec := time.Now().Format("05")
  29276. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29277. file := year + month + day + "_log"
  29278. file_name := file + ".txt"
  29279. file_path := "日志" + "/" + file_name
  29280. exist, _ := utils.PathExists(file_path)
  29281. if exist { //存在
  29282. fmt.Println("存在")
  29283. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29284. if err != nil {
  29285. fmt.Println("read fail")
  29286. }
  29287. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29288. n, _ := f.Seek(0, 2)
  29289. _, err = f.WriteAt([]byte(content), n)
  29290. } else { //不存在
  29291. fmt.Println("文件不存在,创建文件")
  29292. f, err := os.Create("日志" + "/" + file_name)
  29293. defer f.Close()
  29294. if err != nil {
  29295. } else {
  29296. _, err = f.Write([]byte("记录日志"))
  29297. }
  29298. }
  29299. }
  29300. func saveLog(result string, request string, infno string, desc string) {
  29301. org_id, _ := beego.AppConfig.Int64("org_id")
  29302. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29303. dir := miConfig.OrgName + "日志"
  29304. utils.Mkdir(dir)
  29305. month := time.Unix(1557042972, 0).Format("1")
  29306. year := time.Now().Format("2006")
  29307. month = time.Now().Format("01")
  29308. day := time.Now().Format("02")
  29309. hour := time.Now().Format("15")
  29310. min := time.Now().Format("04")
  29311. sec := time.Now().Format("05")
  29312. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29313. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29314. file_name := file + ".txt"
  29315. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29316. exist, _ := utils.PathExists(file_path)
  29317. if exist { //存在
  29318. fmt.Println("存在")
  29319. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29320. if err != nil {
  29321. fmt.Println("read fail")
  29322. }
  29323. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29324. n, _ := f.Seek(0, 2)
  29325. _, err = f.WriteAt([]byte(content), n)
  29326. } else { //不存在
  29327. fmt.Println("文件不存在,创建文件")
  29328. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29329. defer f.Close()
  29330. if err != nil {
  29331. } else {
  29332. _, err = f.Write([]byte("记录日志"))
  29333. }
  29334. }
  29335. }
  29336. type Charset string
  29337. const (
  29338. UTF8 = Charset("UTF-8")
  29339. GB18030 = Charset("GB18030")
  29340. )
  29341. func ConvertToString(src string, srcCode string, tagCode string) string {
  29342. srcCoder := mahonia.NewDecoder(srcCode)
  29343. srcResult := srcCoder.ConvertString(src)
  29344. tagCoder := mahonia.NewDecoder(tagCode)
  29345. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29346. result := string(cdata)
  29347. return result
  29348. }
  29349. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29350. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29351. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29352. var token string
  29353. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29354. var api string
  29355. if miConfig.MdtrtareaAdmvs == "320921" {
  29356. 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 +
  29357. "&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
  29358. fmt.Println(api)
  29359. } else {
  29360. 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 +
  29361. "&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
  29362. }
  29363. resp, requestErr := http.Get(api)
  29364. if requestErr != nil {
  29365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29366. return ""
  29367. }
  29368. body, ioErr := ioutil.ReadAll(resp.Body)
  29369. if ioErr != nil {
  29370. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29372. return ""
  29373. }
  29374. var respJSON map[string]interface{}
  29375. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29376. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29378. return ""
  29379. }
  29380. var status string
  29381. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29382. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29383. var res ResultTwo //1101结果
  29384. var res10265 ResultTwo10265 //1101结果
  29385. if status == "0" { //读卡成功
  29386. var card_info string //卡信息
  29387. var busi_card_info string
  29388. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29389. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29390. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29391. fmt.Println(card_info)
  29392. fmt.Println(busi_card_info)
  29393. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29394. result, _ := json.Marshal(respJSON)
  29395. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29396. utils.ErrorLog("解析失败:%v", err)
  29397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29398. return ""
  29399. }
  29400. res.ErrMsg = res10265.ErrMsg
  29401. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29402. res.Infcode = infocode
  29403. res.Output = res10265.Output
  29404. res.InfRefmsgid = res10265.InfRefmsgid
  29405. if res.Infcode == 0 {
  29406. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29407. if err == gorm.ErrRecordNotFound {
  29408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29409. return ""
  29410. } else if err != nil {
  29411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29412. return ""
  29413. } else {
  29414. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29415. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29416. infoStr := string(Iinfos)
  29417. idetinfoStr := string(Idetinfos)
  29418. psn := &models.HisPsn{
  29419. PsnNo: res.Output.Baseinfo.PsnNo,
  29420. PatientId: patient.ID,
  29421. Certno: res.Output.Baseinfo.Certno,
  29422. Gend: res.Output.Baseinfo.Gend,
  29423. Naty: res.Output.Baseinfo.Naty,
  29424. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29425. PsnName: res.Output.Baseinfo.PsnName,
  29426. Idetinfo: idetinfoStr,
  29427. Insuinfo: infoStr,
  29428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29429. CardInfo: card_info,
  29430. VerifyNumber: token,
  29431. }
  29432. service.CreateHisPsn(psn)
  29433. return token
  29434. }
  29435. }
  29436. } else {
  29437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29438. return ""
  29439. }
  29440. } else { //读卡失败
  29441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29442. return ""
  29443. }
  29444. return token
  29445. }
  29446. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29447. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29448. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29449. var token string
  29450. var api string
  29451. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29452. "&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
  29453. fmt.Println(api)
  29454. resp, requestErr := http.Get(api)
  29455. if requestErr != nil {
  29456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29457. return ""
  29458. }
  29459. body, ioErr := ioutil.ReadAll(resp.Body)
  29460. if ioErr != nil {
  29461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29463. return ""
  29464. }
  29465. var respJSON map[string]interface{}
  29466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29469. return ""
  29470. }
  29471. var status string
  29472. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29473. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29474. var res ResultTwo //1101结果
  29475. if status == "1" { //读卡成功
  29476. var card_info string //卡信息
  29477. var busi_card_info string
  29478. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29479. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29480. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29481. fmt.Println(card_info)
  29482. fmt.Println(busi_card_info)
  29483. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29484. result, _ := json.Marshal(respJSON)
  29485. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29486. utils.ErrorLog("解析失败:%v", err)
  29487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29488. return ""
  29489. }
  29490. if res.Infcode == 0 {
  29491. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29492. if err == gorm.ErrRecordNotFound {
  29493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29494. return ""
  29495. } else if err != nil {
  29496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29497. return ""
  29498. } else {
  29499. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29500. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29501. infoStr := string(Iinfos)
  29502. idetinfoStr := string(Idetinfos)
  29503. psn := &models.HisPsn{
  29504. PsnNo: res.Output.Baseinfo.PsnNo,
  29505. PatientId: patient.ID,
  29506. Certno: res.Output.Baseinfo.Certno,
  29507. Gend: res.Output.Baseinfo.Gend,
  29508. Naty: res.Output.Baseinfo.Naty,
  29509. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29510. PsnName: res.Output.Baseinfo.PsnName,
  29511. Idetinfo: idetinfoStr,
  29512. Insuinfo: infoStr,
  29513. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29514. CardInfo: card_info,
  29515. VerifyNumber: token,
  29516. }
  29517. service.CreateHisPsn(psn)
  29518. return token
  29519. }
  29520. }
  29521. } else {
  29522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29523. return ""
  29524. }
  29525. return token
  29526. }
  29527. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29528. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29529. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29530. var token string
  29531. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29532. var api string
  29533. if miConfig.MdtrtareaAdmvs == "320921" {
  29534. 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 +
  29535. "&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
  29536. fmt.Println(api)
  29537. } else {
  29538. 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 +
  29539. "&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
  29540. }
  29541. resp, requestErr := http.Get(api)
  29542. if requestErr != nil {
  29543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29544. return ""
  29545. }
  29546. body, ioErr := ioutil.ReadAll(resp.Body)
  29547. if ioErr != nil {
  29548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29550. return ""
  29551. }
  29552. var respJSON map[string]interface{}
  29553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29556. return ""
  29557. }
  29558. var status string
  29559. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29560. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29561. var res ResultTwo //1101结果
  29562. var res10265 ResultTwo10265 //1101结果
  29563. if status == "0" { //读卡成功
  29564. var card_info string //卡信息
  29565. var busi_card_info string
  29566. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29567. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29568. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29569. fmt.Println(card_info)
  29570. fmt.Println(busi_card_info)
  29571. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29572. result, _ := json.Marshal(respJSON)
  29573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29574. utils.ErrorLog("解析失败:%v", err)
  29575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29576. return ""
  29577. }
  29578. res.ErrMsg = res10265.ErrMsg
  29579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29580. res.Infcode = infocode
  29581. res.Output = res10265.Output
  29582. res.InfRefmsgid = res10265.InfRefmsgid
  29583. if res.Infcode == 0 {
  29584. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29585. if err == gorm.ErrRecordNotFound {
  29586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29587. return ""
  29588. } else if err != nil {
  29589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29590. return ""
  29591. } else {
  29592. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29593. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29594. infoStr := string(Iinfos)
  29595. idetinfoStr := string(Idetinfos)
  29596. psn := &models.HisPsn{
  29597. PsnNo: res.Output.Baseinfo.PsnNo,
  29598. PatientId: patient.ID,
  29599. Certno: res.Output.Baseinfo.Certno,
  29600. Gend: res.Output.Baseinfo.Gend,
  29601. Naty: res.Output.Baseinfo.Naty,
  29602. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29603. PsnName: res.Output.Baseinfo.PsnName,
  29604. Idetinfo: idetinfoStr,
  29605. Insuinfo: infoStr,
  29606. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29607. CardInfo: card_info,
  29608. VerifyNumber: token,
  29609. }
  29610. service.CreateHisPsn(psn)
  29611. return token
  29612. }
  29613. }
  29614. } else {
  29615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29616. return ""
  29617. }
  29618. } else { //读卡失败
  29619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29620. return ""
  29621. }
  29622. return token
  29623. }
  29624. func DeleteExtraSpaceTwo(s string) string {
  29625. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29626. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29627. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29628. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29629. s2 := make([]byte, len(s1)) //定义字符数组切片
  29630. copy(s2, s1) //将字符串复制到切片
  29631. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29632. for len(spc_index) > 0 { //找到适配项
  29633. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29634. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29635. }
  29636. return string(s2)
  29637. }
  29638. func Remove0000(s string) string {
  29639. str := make([]rune, 0, len(s))
  29640. for _, v := range []rune(s) {
  29641. if v == 0 {
  29642. continue
  29643. }
  29644. str = append(str, v)
  29645. }
  29646. return string(str)
  29647. }
  29648. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29649. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29650. readCard := DllDef.MustFindProc("EcQuery")
  29651. pCardInfo := make([]byte, 8192)
  29652. pBusiCardInfo := make([]byte, 8192)
  29653. data := make(map[string]interface{})
  29654. //pData := make(map[string]interface{})
  29655. inputData := make(map[string]interface{})
  29656. inputData["orgId"] = code
  29657. inputData["businessType"] = "01101"
  29658. inputData["operatorId"] = operator_id
  29659. inputData["operatorName"] = operator_name
  29660. inputData["officeId"] = "001"
  29661. inputData["officeName"] = "血透室"
  29662. //
  29663. data["data"] = inputData
  29664. data["transType"] = "ec.query"
  29665. data["orgId"] = code
  29666. bytesData, _ := json.Marshal(data)
  29667. pCardInfo = bytesData
  29668. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29669. fmt.Println(ret2)
  29670. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29671. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29672. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29673. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29674. if ret2 != 0 {
  29675. return "", ""
  29676. }
  29677. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29678. }
  29679. func DeleteExtraSpace(s string) string {
  29680. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29681. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29682. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29683. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29684. s2 := make([]byte, len(s1)) //定义字符数组切片
  29685. copy(s2, s1) //将字符串复制到切片
  29686. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29687. for len(spc_index) > 0 { //找到适配项
  29688. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29689. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29690. }
  29691. return string(s2)
  29692. }
  29693. // 对账
  29694. func (c *HisApiController) Post3202() {
  29695. start_time := c.GetString("start_time")
  29696. end_time := c.GetString("end_time")
  29697. //insutype := c.GetString("insutype")
  29698. clr_type := c.GetString("clr_type")
  29699. clr_org := c.GetString("clr_optins")
  29700. admin_user_id, _ := c.GetInt64("admin_user_id")
  29701. adminUser := c.GetAdminUserInfo()
  29702. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29703. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29704. if len(clr_org) == 0 {
  29705. clr_org = miConfig.MdtrtareaAdmvs
  29706. }
  29707. timeLayout := "2006-01-02"
  29708. loc, _ := time.LoadLocation("Local")
  29709. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29710. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29711. var orders []*models.HisOrder
  29712. if clr_org == "421300" {
  29713. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29714. } else {
  29715. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29716. }
  29717. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29718. //fixmedins_setl_cnt := int64(len(orders))
  29719. var medfee_sumamt float64
  29720. var acct_pay float64
  29721. var fund_pay_sumamt float64
  29722. for _, item := range orders {
  29723. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29724. acct_pay = acct_pay + item.AcctPay
  29725. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29726. }
  29727. //var medfee_sumamt_two float64
  29728. //var acct_pay_two float64
  29729. //var fund_pay_sumamt_two float64
  29730. //for _, item := range orders_two {
  29731. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29732. // acct_pay_two = acct_pay_two + item.AcctPay
  29733. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29734. //}
  29735. //var user_name string
  29736. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29737. //if role.ID == 0 {
  29738. // user_name = "xxx"
  29739. //} else {
  29740. // user_name = role.UserName
  29741. //}
  29742. var res ResultSix
  29743. if config.IsOpen == 1 {
  29744. var bps []*models.BusinessParamsTwo
  29745. var bp models.BusinessParamsTwo
  29746. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29747. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29748. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29749. bp.MedfeeSumamt = medfee_sumamt_str
  29750. bp.AcctPay = acct_pay_str
  29751. bp.FundPaySumamt = fund_pay_sumamt_str
  29752. bp.Insutype = ""
  29753. bp.StmtBegndate = start_time
  29754. bp.ClrType = clr_type
  29755. bp.SetlOptins = clr_org
  29756. bp.StmtEnddate = end_time
  29757. bps = append(bps, &bp)
  29758. data := make(map[string]interface{})
  29759. data["bps"] = bps
  29760. data["org_name"] = miConfig.OrgName
  29761. data["doctor"] = role.UserName
  29762. data["fixmedins_code"] = miConfig.Code
  29763. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29764. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29765. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29766. if miConfig.MdtrtareaAdmvs == "421300" {
  29767. client := &http.Client{}
  29768. bytesData, _ := json.Marshal(data)
  29769. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29770. resp, _ := client.Do(req)
  29771. defer resp.Body.Close()
  29772. body, ioErr := ioutil.ReadAll(resp.Body)
  29773. if ioErr != nil {
  29774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29776. return
  29777. }
  29778. var respJSON map[string]interface{}
  29779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29782. return
  29783. }
  29784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29785. userJSONBytes, _ := json.Marshal(respJSON)
  29786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29787. utils.ErrorLog("解析失败:%v", err)
  29788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29789. return
  29790. }
  29791. }
  29792. if miConfig.MdtrtareaAdmvs == "420200" {
  29793. client := &http.Client{}
  29794. bytesData, _ := json.Marshal(data)
  29795. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29796. resp, _ := client.Do(req)
  29797. defer resp.Body.Close()
  29798. body, ioErr := ioutil.ReadAll(resp.Body)
  29799. if ioErr != nil {
  29800. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29802. return
  29803. }
  29804. var respJSON map[string]interface{}
  29805. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29806. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29808. return
  29809. }
  29810. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29811. userJSONBytes, _ := json.Marshal(respJSON)
  29812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29813. utils.ErrorLog("解析失败:%v", err)
  29814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29815. return
  29816. }
  29817. }
  29818. if miConfig.MdtrtareaAdmvs == "421182" {
  29819. client := &http.Client{}
  29820. bytesData, _ := json.Marshal(data)
  29821. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  29822. resp, _ := client.Do(req)
  29823. defer resp.Body.Close()
  29824. body, ioErr := ioutil.ReadAll(resp.Body)
  29825. if ioErr != nil {
  29826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29828. return
  29829. }
  29830. var respJSON map[string]interface{}
  29831. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29834. return
  29835. }
  29836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29837. userJSONBytes, _ := json.Marshal(respJSON)
  29838. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29839. utils.ErrorLog("解析失败:%v", err)
  29840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29841. return
  29842. }
  29843. }
  29844. if res.Infcode == 0 {
  29845. c.ServeSuccessJSON(map[string]interface{}{
  29846. "msg": "发起成功",
  29847. })
  29848. } else {
  29849. c.ServeSuccessJSON(map[string]interface{}{
  29850. "failed_code": -10,
  29851. "msg": res.ErrMsg,
  29852. })
  29853. }
  29854. }
  29855. }
  29856. func (c *HisApiController) Post3202b() {
  29857. start_time := c.GetString("start_time")
  29858. end_time := c.GetString("end_time")
  29859. //insutype := c.GetString("insutype")
  29860. clr_type := c.GetString("clr_type")
  29861. clr_org := c.GetString("clr_optins")
  29862. admin_user_id, _ := c.GetInt64("admin_user_id")
  29863. adminUser := c.GetAdminUserInfo()
  29864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29865. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29866. if len(clr_org) == 0 {
  29867. clr_org = miConfig.MdtrtareaAdmvs
  29868. }
  29869. timeLayout := "2006-01-02"
  29870. loc, _ := time.LoadLocation("Local")
  29871. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29872. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29873. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29874. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29875. //fixmedins_setl_cnt := int64(len(orders))
  29876. var medfee_sumamt float64
  29877. var acct_pay float64
  29878. var fund_pay_sumamt float64
  29879. for _, item := range orders {
  29880. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29881. acct_pay = acct_pay + item.AcctPay
  29882. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29883. }
  29884. //var medfee_sumamt_two float64
  29885. //var acct_pay_two float64
  29886. //var fund_pay_sumamt_two float64
  29887. //for _, item := range orders_two {
  29888. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29889. // acct_pay_two = acct_pay_two + item.AcctPay
  29890. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29891. //}
  29892. //var user_name string
  29893. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29894. //if role.ID == 0 {
  29895. // user_name = "xxx"
  29896. //} else {
  29897. // user_name = role.UserName
  29898. //}
  29899. var res ResultSix
  29900. if config.IsOpen == 1 {
  29901. var bps []*models.BusinessParamsTwo
  29902. var bp models.BusinessParamsTwo
  29903. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29904. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29905. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29906. bp.MedfeeSumamt = medfee_sumamt_str
  29907. bp.AcctPay = acct_pay_str
  29908. bp.FundPaySumamt = fund_pay_sumamt_str
  29909. bp.Insutype = "390"
  29910. bp.StmtBegndate = start_time
  29911. bp.ClrType = clr_type
  29912. bp.SetlOptins = clr_org
  29913. bp.StmtEnddate = end_time
  29914. bps = append(bps, &bp)
  29915. data := make(map[string]interface{})
  29916. data["bps"] = bps
  29917. data["org_name"] = miConfig.OrgName
  29918. data["doctor"] = role.UserName
  29919. data["fixmedins_code"] = miConfig.Code
  29920. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29921. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29922. if miConfig.MdtrtareaAdmvs == "421300" {
  29923. client := &http.Client{}
  29924. bytesData, _ := json.Marshal(data)
  29925. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29926. resp, _ := client.Do(req)
  29927. defer resp.Body.Close()
  29928. body, ioErr := ioutil.ReadAll(resp.Body)
  29929. if ioErr != nil {
  29930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29932. return
  29933. }
  29934. var respJSON map[string]interface{}
  29935. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29938. return
  29939. }
  29940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29941. userJSONBytes, _ := json.Marshal(respJSON)
  29942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29943. utils.ErrorLog("解析失败:%v", err)
  29944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29945. return
  29946. }
  29947. }
  29948. if miConfig.MdtrtareaAdmvs == "420200" {
  29949. client := &http.Client{}
  29950. bytesData, _ := json.Marshal(data)
  29951. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29952. resp, _ := client.Do(req)
  29953. defer resp.Body.Close()
  29954. body, ioErr := ioutil.ReadAll(resp.Body)
  29955. if ioErr != nil {
  29956. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29958. return
  29959. }
  29960. var respJSON map[string]interface{}
  29961. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29962. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29964. return
  29965. }
  29966. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29967. userJSONBytes, _ := json.Marshal(respJSON)
  29968. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29969. utils.ErrorLog("解析失败:%v", err)
  29970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29971. return
  29972. }
  29973. }
  29974. if miConfig.MdtrtareaAdmvs == "421182" {
  29975. client := &http.Client{}
  29976. bytesData, _ := json.Marshal(data)
  29977. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29978. resp, _ := client.Do(req)
  29979. defer resp.Body.Close()
  29980. body, ioErr := ioutil.ReadAll(resp.Body)
  29981. if ioErr != nil {
  29982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29984. return
  29985. }
  29986. var respJSON map[string]interface{}
  29987. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29990. return
  29991. }
  29992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29993. userJSONBytes, _ := json.Marshal(respJSON)
  29994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29995. utils.ErrorLog("解析失败:%v", err)
  29996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29997. return
  29998. }
  29999. }
  30000. if res.Infcode == 0 {
  30001. c.ServeSuccessJSON(map[string]interface{}{
  30002. "msg": "发起成功",
  30003. })
  30004. } else {
  30005. c.ServeSuccessJSON(map[string]interface{}{
  30006. "failed_code": -10,
  30007. "msg": res.ErrMsg,
  30008. })
  30009. }
  30010. }
  30011. }
  30012. func (c *HisApiController) Post1608() {
  30013. start_time := c.GetString("start_time")
  30014. end_time := c.GetString("end_time")
  30015. admin_user_id, _ := c.GetInt64("admin_user_id")
  30016. adminUser := c.GetAdminUserInfo()
  30017. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30018. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30019. timeLayout := "2006-01-02"
  30020. loc, _ := time.LoadLocation("Local")
  30021. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30022. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30023. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30024. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30025. fixmedins_setl_cnt := int64(len(orders))
  30026. var medfee_sumamt float64
  30027. var func_smamt float64
  30028. for _, item := range orders {
  30029. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30030. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30031. }
  30032. times := strings.Split(start_time, "-")
  30033. time_tows := strings.Split(end_time, "-")
  30034. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30035. var res ResultSix
  30036. if config.IsOpen == 1 {
  30037. //var bps []*models.BusinessParamsTwo
  30038. //var bp models.BusinessParamsTwo
  30039. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30040. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30041. data := make(map[string]interface{})
  30042. data["org_name"] = miConfig.OrgName
  30043. data["doctor"] = role.UserName
  30044. data["func_smamt"] = func_smamt_str
  30045. data["fixmedins_code"] = miConfig.Code
  30046. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30047. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30048. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30049. data["medfee_sumamt"] = medfee_sumamt_str
  30050. data["start_time"] = times[0] + times[1] + times[2]
  30051. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30052. if miConfig.MdtrtareaAdmvs == "421300" {
  30053. client := &http.Client{}
  30054. bytesData, _ := json.Marshal(data)
  30055. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30056. resp, _ := client.Do(req)
  30057. defer resp.Body.Close()
  30058. body, ioErr := ioutil.ReadAll(resp.Body)
  30059. if ioErr != nil {
  30060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30062. return
  30063. }
  30064. var respJSON map[string]interface{}
  30065. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30068. return
  30069. }
  30070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30071. userJSONBytes, _ := json.Marshal(respJSON)
  30072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30073. utils.ErrorLog("解析失败:%v", err)
  30074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30075. return
  30076. }
  30077. }
  30078. if miConfig.MdtrtareaAdmvs == "420200" {
  30079. client := &http.Client{}
  30080. bytesData, _ := json.Marshal(data)
  30081. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30082. resp, _ := client.Do(req)
  30083. defer resp.Body.Close()
  30084. body, ioErr := ioutil.ReadAll(resp.Body)
  30085. if ioErr != nil {
  30086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30088. return
  30089. }
  30090. var respJSON map[string]interface{}
  30091. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30092. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30094. return
  30095. }
  30096. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30097. userJSONBytes, _ := json.Marshal(respJSON)
  30098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30099. utils.ErrorLog("解析失败:%v", err)
  30100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30101. return
  30102. }
  30103. }
  30104. if miConfig.MdtrtareaAdmvs == "421182" {
  30105. client := &http.Client{}
  30106. bytesData, _ := json.Marshal(data)
  30107. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30108. resp, _ := client.Do(req)
  30109. defer resp.Body.Close()
  30110. body, ioErr := ioutil.ReadAll(resp.Body)
  30111. if ioErr != nil {
  30112. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30114. return
  30115. }
  30116. var respJSON map[string]interface{}
  30117. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30118. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30120. return
  30121. }
  30122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30123. userJSONBytes, _ := json.Marshal(respJSON)
  30124. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30125. utils.ErrorLog("解析失败:%v", err)
  30126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30127. return
  30128. }
  30129. }
  30130. if res.Infcode == 0 {
  30131. c.ServeSuccessJSON(map[string]interface{}{
  30132. "msg": "发起成功",
  30133. })
  30134. } else {
  30135. c.ServeSuccessJSON(map[string]interface{}{
  30136. "failed_code": -10,
  30137. "msg": res.ErrMsg,
  30138. })
  30139. }
  30140. }
  30141. }
  30142. // 5.11.1.1【5262】结算信息按时间段查询
  30143. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30144. admin_user_id, _ := c.GetInt64("admin_user_id")
  30145. adminUser := c.GetAdminUserInfo()
  30146. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30147. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30148. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30149. var res Result5262
  30150. if config.IsOpen == 1 {
  30151. if miConfig.MdtrtareaAdmvs == "421300" {
  30152. data := make(map[string]interface{})
  30153. data["bps"] = bp
  30154. data["org_name"] = miConfig.OrgName
  30155. data["doctor"] = role.UserName
  30156. data["fixmedins_code"] = miConfig.Code
  30157. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30158. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30159. data["page"] = strconv.FormatInt(page, 10)
  30160. data["limit"] = strconv.FormatInt(limit, 10)
  30161. fmt.Println(data)
  30162. client := &http.Client{}
  30163. bytesData, _ := json.Marshal(data)
  30164. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30165. resp, _ := client.Do(req)
  30166. defer resp.Body.Close()
  30167. body, ioErr := ioutil.ReadAll(resp.Body)
  30168. if ioErr != nil {
  30169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30171. return
  30172. }
  30173. var respJSON map[string]interface{}
  30174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30177. return
  30178. }
  30179. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30180. userJSONBytes, _ := json.Marshal(respJSON)
  30181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30182. utils.ErrorLog("解析失败:%v", err)
  30183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30184. return
  30185. }
  30186. }
  30187. if miConfig.MdtrtareaAdmvs == "420200" {
  30188. data := make(map[string]interface{})
  30189. data["bps"] = bp
  30190. data["org_name"] = miConfig.OrgName
  30191. data["doctor"] = role.UserName
  30192. data["fixmedins_code"] = miConfig.Code
  30193. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30194. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30195. data["page"] = strconv.FormatInt(page, 10)
  30196. data["limit"] = strconv.FormatInt(limit, 10)
  30197. fmt.Println(data)
  30198. client := &http.Client{}
  30199. bytesData, _ := json.Marshal(data)
  30200. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30201. resp, _ := client.Do(req)
  30202. defer resp.Body.Close()
  30203. body, ioErr := ioutil.ReadAll(resp.Body)
  30204. if ioErr != nil {
  30205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30207. return
  30208. }
  30209. var respJSON map[string]interface{}
  30210. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30213. return
  30214. }
  30215. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30216. userJSONBytes, _ := json.Marshal(respJSON)
  30217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30218. utils.ErrorLog("解析失败:%v", err)
  30219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30220. return
  30221. }
  30222. }
  30223. if miConfig.MdtrtareaAdmvs == "421182" {
  30224. data := make(map[string]interface{})
  30225. data["bps"] = bp
  30226. data["org_name"] = miConfig.OrgName
  30227. data["doctor"] = role.UserName
  30228. data["fixmedins_code"] = miConfig.Code
  30229. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30230. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30231. data["page"] = strconv.FormatInt(page, 10)
  30232. data["limit"] = strconv.FormatInt(limit, 10)
  30233. fmt.Println(data)
  30234. client := &http.Client{}
  30235. bytesData, _ := json.Marshal(data)
  30236. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30237. resp, _ := client.Do(req)
  30238. defer resp.Body.Close()
  30239. body, ioErr := ioutil.ReadAll(resp.Body)
  30240. if ioErr != nil {
  30241. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30243. return
  30244. }
  30245. var respJSON map[string]interface{}
  30246. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30247. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30249. return
  30250. }
  30251. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30252. userJSONBytes, _ := json.Marshal(respJSON)
  30253. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30254. utils.ErrorLog("解析失败:%v", err)
  30255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30256. return
  30257. }
  30258. }
  30259. if res.Infcode == 0 {
  30260. c.ServeSuccessJSON(map[string]interface{}{
  30261. "order": res.Output.Result,
  30262. "total": res.Output.PageInfo.RecordCounts,
  30263. })
  30264. } else {
  30265. c.ServeSuccessJSON(map[string]interface{}{
  30266. "failed_code": -10,
  30267. "msg": res.ErrMsg,
  30268. })
  30269. }
  30270. }
  30271. }
  30272. // 5.11.1.2【5267】异地结算信息时间段查询
  30273. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30274. admin_user_id, _ := c.GetInt64("admin_user_id")
  30275. adminUser := c.GetAdminUserInfo()
  30276. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30277. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30278. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30279. var res Result5267
  30280. if config.IsOpen == 1 {
  30281. if miConfig.MdtrtareaAdmvs == "421300" {
  30282. data := make(map[string]interface{})
  30283. data["bps"] = bp
  30284. data["org_name"] = miConfig.OrgName
  30285. data["doctor"] = role.UserName
  30286. data["fixmedins_code"] = miConfig.Code
  30287. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30288. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30289. data["page"] = page
  30290. data["limit"] = limit
  30291. fmt.Println(data)
  30292. client := &http.Client{}
  30293. bytesData, _ := json.Marshal(data)
  30294. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30295. resp, _ := client.Do(req)
  30296. defer resp.Body.Close()
  30297. body, ioErr := ioutil.ReadAll(resp.Body)
  30298. if ioErr != nil {
  30299. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30301. return
  30302. }
  30303. var respJSON map[string]interface{}
  30304. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30305. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30307. return
  30308. }
  30309. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30310. userJSONBytes, _ := json.Marshal(respJSON)
  30311. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30312. utils.ErrorLog("解析失败:%v", err)
  30313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30314. return
  30315. }
  30316. }
  30317. if miConfig.MdtrtareaAdmvs == "420200" {
  30318. data := make(map[string]interface{})
  30319. data["bps"] = bp
  30320. data["org_name"] = miConfig.OrgName
  30321. data["doctor"] = role.UserName
  30322. data["fixmedins_code"] = miConfig.Code
  30323. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30324. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30325. data["page"] = page
  30326. data["limit"] = limit
  30327. fmt.Println(data)
  30328. client := &http.Client{}
  30329. bytesData, _ := json.Marshal(data)
  30330. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30331. resp, _ := client.Do(req)
  30332. defer resp.Body.Close()
  30333. body, ioErr := ioutil.ReadAll(resp.Body)
  30334. if ioErr != nil {
  30335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30337. return
  30338. }
  30339. var respJSON map[string]interface{}
  30340. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30343. return
  30344. }
  30345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30346. userJSONBytes, _ := json.Marshal(respJSON)
  30347. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30348. utils.ErrorLog("解析失败:%v", err)
  30349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30350. return
  30351. }
  30352. }
  30353. if miConfig.MdtrtareaAdmvs == "421182" {
  30354. data := make(map[string]interface{})
  30355. data["bps"] = bp
  30356. data["org_name"] = miConfig.OrgName
  30357. data["doctor"] = role.UserName
  30358. data["fixmedins_code"] = miConfig.Code
  30359. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30360. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30361. data["page"] = page
  30362. data["limit"] = limit
  30363. fmt.Println(data)
  30364. client := &http.Client{}
  30365. bytesData, _ := json.Marshal(data)
  30366. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30367. resp, _ := client.Do(req)
  30368. defer resp.Body.Close()
  30369. body, ioErr := ioutil.ReadAll(resp.Body)
  30370. if ioErr != nil {
  30371. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30373. return
  30374. }
  30375. var respJSON map[string]interface{}
  30376. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30377. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30379. return
  30380. }
  30381. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30382. userJSONBytes, _ := json.Marshal(respJSON)
  30383. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30384. utils.ErrorLog("解析失败:%v", err)
  30385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30386. return
  30387. }
  30388. }
  30389. if res.Infcode == 0 {
  30390. c.ServeSuccessJSON(map[string]interface{}{
  30391. "order": res.Output.Result,
  30392. "total": res.Output.PageInfo.RecordCounts,
  30393. })
  30394. } else {
  30395. c.ServeSuccessJSON(map[string]interface{}{
  30396. "failed_code": -10,
  30397. "msg": res.ErrMsg,
  30398. })
  30399. }
  30400. }
  30401. }
  30402. func (c *HisApiController) Post3501() {
  30403. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30404. data := make(map[string]interface{})
  30405. var struct3501s []models.Struct3501
  30406. var struct3501 models.Struct3501
  30407. struct3501.OrgName = miConfig.OrgName
  30408. struct3501.AccessKey = miConfig.AccessKey
  30409. struct3501.RequestUrl = miConfig.Url
  30410. struct3501.SecretKey = miConfig.SecretKey
  30411. struct3501.ManuDate = "2022-08-17"
  30412. struct3501.FixmedinsBchno = ""
  30413. struct3501.ManuLotnum = ""
  30414. struct3501.RxFlag = "0"
  30415. struct3501.ExpyEnd = "2022-08-17"
  30416. struct3501.Invdate = "2022-08-17"
  30417. struct3501.InvCnt = "20.25"
  30418. struct3501.Memo = ""
  30419. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30420. struct3501.FixmedinsHilistId = miConfig.Code
  30421. struct3501.FixmedinsHilistName = miConfig.OrgName
  30422. struct3501s = append(struct3501s, struct3501)
  30423. data["struct_3501s"] = struct3501s
  30424. client := &http.Client{}
  30425. bytesData, _ := json.Marshal(data)
  30426. var req *http.Request
  30427. if miConfig.MdtrtareaAdmvs == "320921" {
  30428. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30429. } else {
  30430. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30431. }
  30432. resp, _ := client.Do(req)
  30433. defer resp.Body.Close()
  30434. body, ioErr := ioutil.ReadAll(resp.Body)
  30435. if ioErr != nil {
  30436. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30438. return
  30439. }
  30440. var respJSON map[string]interface{}
  30441. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30442. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30444. return
  30445. }
  30446. var res ResultSix
  30447. var resSix10265 ResultSix10265 //1101结果
  30448. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30449. result, _ := json.Marshal(respJSON)
  30450. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30451. utils.ErrorLog("解析失败:%v", err)
  30452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30453. return
  30454. }
  30455. res.InfRefmsgid = resSix10265.InfRefmsgid
  30456. res.Output = resSix10265.Output
  30457. res.ErrMsg = resSix10265.ErrMsg
  30458. res.Cainfo = resSix10265.Cainfo
  30459. res.WarnMsg = resSix10265.WarnMsg
  30460. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30461. res.Infcode = infocode
  30462. if infocode == 0 {
  30463. c.ServeSuccessJSON(map[string]interface{}{
  30464. "msg": "上传成功",
  30465. })
  30466. return
  30467. } else {
  30468. c.ServeSuccessJSON(map[string]interface{}{
  30469. "failed_code": -10,
  30470. "msg": res.ErrMsg,
  30471. })
  30472. return
  30473. }
  30474. }
  30475. func (c *HisApiController) Post3502() {
  30476. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30477. data := make(map[string]interface{})
  30478. var struct3502s []models.Struct3502
  30479. var struct3502 models.Struct3502
  30480. struct3502.OrgName = miConfig.OrgName
  30481. struct3502.AccessKey = miConfig.AccessKey
  30482. struct3502.RequestUrl = miConfig.Url
  30483. struct3502.SecretKey = miConfig.SecretKey
  30484. struct3502.ManuDate = "2022-08-15"
  30485. struct3502.FixmedinsBchno = ""
  30486. struct3502.ManuLotnum = ""
  30487. struct3502.RxFlag = "0"
  30488. struct3502.ExpyEnd = "2022-08-15"
  30489. struct3502.Invdate = "2022-08-15"
  30490. struct3502.InvCnt = "20.25"
  30491. struct3502.Memo = ""
  30492. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30493. struct3502.FixmedinsHilistId = miConfig.Code
  30494. struct3502.FixmedinsHilistName = miConfig.OrgName
  30495. struct3502s = append(struct3502s, struct3502)
  30496. data["struct_3502s"] = struct3502s
  30497. client := &http.Client{}
  30498. bytesData, _ := json.Marshal(data)
  30499. var req *http.Request
  30500. if miConfig.MdtrtareaAdmvs == "320921" {
  30501. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30502. } else {
  30503. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30504. }
  30505. resp, _ := client.Do(req)
  30506. defer resp.Body.Close()
  30507. body, ioErr := ioutil.ReadAll(resp.Body)
  30508. if ioErr != nil {
  30509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30511. return
  30512. }
  30513. var respJSON map[string]interface{}
  30514. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30517. return
  30518. }
  30519. var res ResultSix
  30520. var resSix10265 ResultSix10265 //1101结果
  30521. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30522. result, _ := json.Marshal(respJSON)
  30523. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30524. utils.ErrorLog("解析失败:%v", err)
  30525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30526. return
  30527. }
  30528. res.InfRefmsgid = resSix10265.InfRefmsgid
  30529. res.Output = resSix10265.Output
  30530. res.ErrMsg = resSix10265.ErrMsg
  30531. res.Cainfo = resSix10265.Cainfo
  30532. res.WarnMsg = resSix10265.WarnMsg
  30533. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30534. res.Infcode = infocode
  30535. if infocode == 0 {
  30536. c.ServeSuccessJSON(map[string]interface{}{
  30537. "msg": "上传成功",
  30538. })
  30539. return
  30540. } else {
  30541. c.ServeSuccessJSON(map[string]interface{}{
  30542. "failed_code": -10,
  30543. "msg": res.ErrMsg,
  30544. })
  30545. return
  30546. }
  30547. }
  30548. func (c *HisApiController) Post3503() {
  30549. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30550. data := make(map[string]interface{})
  30551. var struct3501s []models.Struct3501
  30552. var struct3501 models.Struct3501
  30553. struct3501.OrgName = miConfig.OrgName
  30554. struct3501.AccessKey = miConfig.AccessKey
  30555. struct3501.RequestUrl = miConfig.Url
  30556. struct3501.SecretKey = miConfig.SecretKey
  30557. struct3501.ManuDate = "2022-08-15"
  30558. struct3501.FixmedinsBchno = ""
  30559. struct3501.ManuLotnum = ""
  30560. struct3501.RxFlag = "0"
  30561. struct3501.ExpyEnd = "2022-08-15"
  30562. struct3501.Invdate = "2022-08-15"
  30563. struct3501.InvCnt = "20.25"
  30564. struct3501.Memo = ""
  30565. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30566. struct3501.FixmedinsHilistId = miConfig.Code
  30567. struct3501.FixmedinsHilistName = miConfig.OrgName
  30568. struct3501s = append(struct3501s, struct3501)
  30569. data["struct_3501s"] = struct3501s
  30570. client := &http.Client{}
  30571. bytesData, _ := json.Marshal(data)
  30572. var req *http.Request
  30573. if miConfig.MdtrtareaAdmvs == "320921" {
  30574. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30575. } else {
  30576. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30577. }
  30578. resp, _ := client.Do(req)
  30579. defer resp.Body.Close()
  30580. body, ioErr := ioutil.ReadAll(resp.Body)
  30581. if ioErr != nil {
  30582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30584. return
  30585. }
  30586. var respJSON map[string]interface{}
  30587. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30590. return
  30591. }
  30592. var res ResultSix
  30593. var resSix10265 ResultSix10265 //1101结果
  30594. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30595. result, _ := json.Marshal(respJSON)
  30596. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30597. utils.ErrorLog("解析失败:%v", err)
  30598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30599. return
  30600. }
  30601. res.InfRefmsgid = resSix10265.InfRefmsgid
  30602. res.Output = resSix10265.Output
  30603. res.ErrMsg = resSix10265.ErrMsg
  30604. res.Cainfo = resSix10265.Cainfo
  30605. res.WarnMsg = resSix10265.WarnMsg
  30606. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30607. res.Infcode = infocode
  30608. if infocode == 0 {
  30609. c.ServeSuccessJSON(map[string]interface{}{
  30610. "msg": "上传成功",
  30611. })
  30612. return
  30613. } else {
  30614. c.ServeSuccessJSON(map[string]interface{}{
  30615. "failed_code": -10,
  30616. "msg": res.ErrMsg,
  30617. })
  30618. return
  30619. }
  30620. }
  30621. func (c *HisApiController) Post3504() {
  30622. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30623. data := make(map[string]interface{})
  30624. var struct3501s []models.Struct3501
  30625. var struct3501 models.Struct3501
  30626. struct3501.OrgName = miConfig.OrgName
  30627. struct3501.AccessKey = miConfig.AccessKey
  30628. struct3501.RequestUrl = miConfig.Url
  30629. struct3501.SecretKey = miConfig.SecretKey
  30630. struct3501.ManuDate = "2022-08-15"
  30631. struct3501.FixmedinsBchno = ""
  30632. struct3501.ManuLotnum = ""
  30633. struct3501.RxFlag = "0"
  30634. struct3501.ExpyEnd = "2022-08-15"
  30635. struct3501.Invdate = "2022-08-15"
  30636. struct3501.InvCnt = "20.25"
  30637. struct3501.Memo = ""
  30638. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30639. struct3501.FixmedinsHilistId = miConfig.Code
  30640. struct3501.FixmedinsHilistName = miConfig.OrgName
  30641. struct3501s = append(struct3501s, struct3501)
  30642. data["struct_3501s"] = struct3501s
  30643. client := &http.Client{}
  30644. bytesData, _ := json.Marshal(data)
  30645. var req *http.Request
  30646. if miConfig.MdtrtareaAdmvs == "320921" {
  30647. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30648. } else {
  30649. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30650. }
  30651. resp, _ := client.Do(req)
  30652. defer resp.Body.Close()
  30653. body, ioErr := ioutil.ReadAll(resp.Body)
  30654. if ioErr != nil {
  30655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30657. return
  30658. }
  30659. var respJSON map[string]interface{}
  30660. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30663. return
  30664. }
  30665. var res ResultSix
  30666. var resSix10265 ResultSix10265 //1101结果
  30667. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30668. result, _ := json.Marshal(respJSON)
  30669. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30670. utils.ErrorLog("解析失败:%v", err)
  30671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30672. return
  30673. }
  30674. res.InfRefmsgid = resSix10265.InfRefmsgid
  30675. res.Output = resSix10265.Output
  30676. res.ErrMsg = resSix10265.ErrMsg
  30677. res.Cainfo = resSix10265.Cainfo
  30678. res.WarnMsg = resSix10265.WarnMsg
  30679. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30680. res.Infcode = infocode
  30681. if infocode == 0 {
  30682. c.ServeSuccessJSON(map[string]interface{}{
  30683. "msg": "上传成功",
  30684. })
  30685. return
  30686. } else {
  30687. c.ServeSuccessJSON(map[string]interface{}{
  30688. "failed_code": -10,
  30689. "msg": res.ErrMsg,
  30690. })
  30691. return
  30692. }
  30693. }
  30694. func (c *HisApiController) Post3505() {
  30695. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30696. data := make(map[string]interface{})
  30697. var struct3501s []models.Struct3501
  30698. var struct3501 models.Struct3501
  30699. struct3501.OrgName = miConfig.OrgName
  30700. struct3501.AccessKey = miConfig.AccessKey
  30701. struct3501.RequestUrl = miConfig.Url
  30702. struct3501.SecretKey = miConfig.SecretKey
  30703. struct3501.ManuDate = "2022-08-15"
  30704. struct3501.FixmedinsBchno = ""
  30705. struct3501.ManuLotnum = ""
  30706. struct3501.RxFlag = "0"
  30707. struct3501.ExpyEnd = "2022-08-15"
  30708. struct3501.Invdate = "2022-08-15"
  30709. struct3501.InvCnt = "20.25"
  30710. struct3501.Memo = ""
  30711. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30712. struct3501.FixmedinsHilistId = miConfig.Code
  30713. struct3501.FixmedinsHilistName = miConfig.OrgName
  30714. struct3501s = append(struct3501s, struct3501)
  30715. data["struct_3501s"] = struct3501s
  30716. client := &http.Client{}
  30717. bytesData, _ := json.Marshal(data)
  30718. var req *http.Request
  30719. if miConfig.MdtrtareaAdmvs == "320921" {
  30720. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30721. } else {
  30722. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30723. }
  30724. resp, _ := client.Do(req)
  30725. defer resp.Body.Close()
  30726. body, ioErr := ioutil.ReadAll(resp.Body)
  30727. if ioErr != nil {
  30728. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30730. return
  30731. }
  30732. var respJSON map[string]interface{}
  30733. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30736. return
  30737. }
  30738. var res ResultSix
  30739. var resSix10265 ResultSix10265 //1101结果
  30740. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30741. result, _ := json.Marshal(respJSON)
  30742. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30743. utils.ErrorLog("解析失败:%v", err)
  30744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30745. return
  30746. }
  30747. res.InfRefmsgid = resSix10265.InfRefmsgid
  30748. res.Output = resSix10265.Output
  30749. res.ErrMsg = resSix10265.ErrMsg
  30750. res.Cainfo = resSix10265.Cainfo
  30751. res.WarnMsg = resSix10265.WarnMsg
  30752. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30753. res.Infcode = infocode
  30754. if infocode == 0 {
  30755. c.ServeSuccessJSON(map[string]interface{}{
  30756. "msg": "上传成功",
  30757. })
  30758. return
  30759. } else {
  30760. c.ServeSuccessJSON(map[string]interface{}{
  30761. "failed_code": -10,
  30762. "msg": res.ErrMsg,
  30763. })
  30764. return
  30765. }
  30766. }
  30767. func (c *HisApiController) Post3506() {
  30768. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30769. data := make(map[string]interface{})
  30770. var struct3501s []models.Struct3501
  30771. var struct3501 models.Struct3501
  30772. struct3501.OrgName = miConfig.OrgName
  30773. struct3501.AccessKey = miConfig.AccessKey
  30774. struct3501.RequestUrl = miConfig.Url
  30775. struct3501.SecretKey = miConfig.SecretKey
  30776. struct3501.ManuDate = "2022-08-15"
  30777. struct3501.FixmedinsBchno = ""
  30778. struct3501.ManuLotnum = ""
  30779. struct3501.RxFlag = "0"
  30780. struct3501.ExpyEnd = "2022-08-15"
  30781. struct3501.Invdate = "2022-08-15"
  30782. struct3501.InvCnt = "20.25"
  30783. struct3501.Memo = ""
  30784. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30785. struct3501.FixmedinsHilistId = miConfig.Code
  30786. struct3501.FixmedinsHilistName = miConfig.OrgName
  30787. struct3501s = append(struct3501s, struct3501)
  30788. data["struct_3501s"] = struct3501s
  30789. client := &http.Client{}
  30790. bytesData, _ := json.Marshal(data)
  30791. var req *http.Request
  30792. if miConfig.MdtrtareaAdmvs == "320921" {
  30793. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30794. } else {
  30795. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30796. }
  30797. resp, _ := client.Do(req)
  30798. defer resp.Body.Close()
  30799. body, ioErr := ioutil.ReadAll(resp.Body)
  30800. if ioErr != nil {
  30801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30803. return
  30804. }
  30805. var respJSON map[string]interface{}
  30806. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30809. return
  30810. }
  30811. var res ResultSix
  30812. var resSix10265 ResultSix10265 //1101结果
  30813. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30814. result, _ := json.Marshal(respJSON)
  30815. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30816. utils.ErrorLog("解析失败:%v", err)
  30817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30818. return
  30819. }
  30820. res.InfRefmsgid = resSix10265.InfRefmsgid
  30821. res.Output = resSix10265.Output
  30822. res.ErrMsg = resSix10265.ErrMsg
  30823. res.Cainfo = resSix10265.Cainfo
  30824. res.WarnMsg = resSix10265.WarnMsg
  30825. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30826. res.Infcode = infocode
  30827. if infocode == 0 {
  30828. c.ServeSuccessJSON(map[string]interface{}{
  30829. "msg": "上传成功",
  30830. })
  30831. return
  30832. } else {
  30833. c.ServeSuccessJSON(map[string]interface{}{
  30834. "failed_code": -10,
  30835. "msg": res.ErrMsg,
  30836. })
  30837. return
  30838. }
  30839. }
  30840. func (c *HisApiController) Post3507() {
  30841. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30842. data := make(map[string]interface{})
  30843. var struct3501s []models.Struct3501
  30844. var struct3501 models.Struct3501
  30845. struct3501.OrgName = miConfig.OrgName
  30846. struct3501.AccessKey = miConfig.AccessKey
  30847. struct3501.RequestUrl = miConfig.Url
  30848. struct3501.SecretKey = miConfig.SecretKey
  30849. struct3501.ManuDate = "2022-08-15"
  30850. struct3501.FixmedinsBchno = ""
  30851. struct3501.ManuLotnum = ""
  30852. struct3501.RxFlag = "0"
  30853. struct3501.ExpyEnd = "2022-08-15"
  30854. struct3501.Invdate = "2022-08-15"
  30855. struct3501.InvCnt = "20.25"
  30856. struct3501.Memo = ""
  30857. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30858. struct3501.FixmedinsHilistId = miConfig.Code
  30859. struct3501.FixmedinsHilistName = miConfig.OrgName
  30860. struct3501s = append(struct3501s, struct3501)
  30861. data["struct_3501s"] = struct3501s
  30862. client := &http.Client{}
  30863. bytesData, _ := json.Marshal(data)
  30864. var req *http.Request
  30865. if miConfig.MdtrtareaAdmvs == "320921" {
  30866. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30867. } else {
  30868. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30869. }
  30870. resp, _ := client.Do(req)
  30871. defer resp.Body.Close()
  30872. body, ioErr := ioutil.ReadAll(resp.Body)
  30873. if ioErr != nil {
  30874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30876. return
  30877. }
  30878. var respJSON map[string]interface{}
  30879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30882. return
  30883. }
  30884. var res ResultSix
  30885. var resSix10265 ResultSix10265 //1101结果
  30886. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30887. result, _ := json.Marshal(respJSON)
  30888. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30889. utils.ErrorLog("解析失败:%v", err)
  30890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30891. return
  30892. }
  30893. res.InfRefmsgid = resSix10265.InfRefmsgid
  30894. res.Output = resSix10265.Output
  30895. res.ErrMsg = resSix10265.ErrMsg
  30896. res.Cainfo = resSix10265.Cainfo
  30897. res.WarnMsg = resSix10265.WarnMsg
  30898. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30899. res.Infcode = infocode
  30900. if infocode == 0 {
  30901. c.ServeSuccessJSON(map[string]interface{}{
  30902. "msg": "上传成功",
  30903. })
  30904. return
  30905. } else {
  30906. c.ServeSuccessJSON(map[string]interface{}{
  30907. "failed_code": -10,
  30908. "msg": res.ErrMsg,
  30909. })
  30910. return
  30911. }
  30912. }
  30913. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30914. // WebSocket服务器地址
  30915. serverURL := "ws://127.0.0.1:8899"
  30916. // 解析WebSocket服务器地址
  30917. u, err := url.Parse(serverURL)
  30918. if err != nil {
  30919. }
  30920. // 建立WebSocket连接
  30921. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30922. if err != nil {
  30923. }
  30924. defer conn.Close()
  30925. input2 := make(map[string]interface{})
  30926. input := make(map[string]interface{})
  30927. inputData := make(map[string]interface{})
  30928. inputData["orgId"] = code
  30929. inputData["businessType"] = "01101"
  30930. inputData["operatorId"] = operator_id
  30931. inputData["operatorName"] = operator_name
  30932. inputData["officeId"] = "001"
  30933. inputData["officeName"] = "血透室"
  30934. inputData["deviceType"] = ""
  30935. input["data"] = inputData
  30936. input["orgId"] = code
  30937. input["transType"] = "ec.query"
  30938. //if md == ""
  30939. if md[:4] == "4403" {
  30940. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30941. } else if md[:4] == "4401" {
  30942. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30943. } else {
  30944. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30945. }
  30946. input2["indata"] = input
  30947. fmt.Println(input2)
  30948. bytesData, _ := json.Marshal(input2)
  30949. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30950. if err != nil {
  30951. fmt.Println(err)
  30952. }
  30953. // 接收消息
  30954. _, receivedMessage, err := conn.ReadMessage()
  30955. if err != nil {
  30956. fmt.Println(err)
  30957. }
  30958. return "", string(receivedMessage)
  30959. }
  30960. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30961. // WebSocket服务器地址
  30962. serverURL := "ws://127.0.0.1:8899"
  30963. // 解析WebSocket服务器地址
  30964. u, err := url.Parse(serverURL)
  30965. if err != nil {
  30966. }
  30967. // 建立WebSocket连接
  30968. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30969. if err != nil {
  30970. }
  30971. defer conn.Close()
  30972. input2 := make(map[string]interface{})
  30973. input := make(map[string]interface{})
  30974. inputData := make(map[string]interface{})
  30975. inputData["orgId"] = code
  30976. inputData["businessType"] = "01103"
  30977. inputData["operatorId"] = operator_id
  30978. inputData["operatorName"] = operator_name
  30979. inputData["officeId"] = "001"
  30980. inputData["officeName"] = "血透室"
  30981. inputData["deviceType"] = ""
  30982. input["data"] = inputData
  30983. input["orgId"] = code
  30984. input["transType"] = "ec.query"
  30985. //if md ==
  30986. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30987. input2["indata"] = input
  30988. fmt.Println(input2)
  30989. bytesData, _ := json.Marshal(input2)
  30990. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30991. if err != nil {
  30992. fmt.Println(err)
  30993. }
  30994. // 接收消息
  30995. _, receivedMessage, err := conn.ReadMessage()
  30996. if err != nil {
  30997. fmt.Println(err)
  30998. }
  30999. return "", string(receivedMessage)
  31000. }
  31001. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31002. // WebSocket服务器地址
  31003. serverURL := "ws://127.0.0.1:8899"
  31004. // 解析WebSocket服务器地址
  31005. u, err := url.Parse(serverURL)
  31006. if err != nil {
  31007. }
  31008. // 建立WebSocket连接
  31009. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31010. if err != nil {
  31011. }
  31012. defer conn.Close()
  31013. input2 := make(map[string]interface{})
  31014. input := make(map[string]interface{})
  31015. inputData := make(map[string]interface{})
  31016. inputData["orgId"] = code
  31017. inputData["businessType"] = "01101"
  31018. inputData["operatorId"] = operator_id
  31019. inputData["operatorName"] = operator_name
  31020. inputData["officeId"] = "001"
  31021. inputData["officeName"] = "血透室"
  31022. inputData["deviceType"] = ""
  31023. input["data"] = inputData
  31024. input["orgId"] = code
  31025. input["transType"] = "ec.query"
  31026. //if md == ""
  31027. if md[:4] == "4403" {
  31028. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31029. } else if md[:4] == "4401" {
  31030. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31031. } else {
  31032. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31033. }
  31034. input2["indata"] = input
  31035. fmt.Println(input2)
  31036. bytesData, _ := json.Marshal(input2)
  31037. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31038. if err != nil {
  31039. fmt.Println(err)
  31040. }
  31041. // 接收消息
  31042. _, receivedMessage, err := conn.ReadMessage()
  31043. if err != nil {
  31044. fmt.Println(err)
  31045. }
  31046. return "", string(receivedMessage)
  31047. }
  31048. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31049. // WebSocket服务器地址
  31050. serverURL := "ws://127.0.0.1:8899"
  31051. // 解析WebSocket服务器地址
  31052. u, err := url.Parse(serverURL)
  31053. if err != nil {
  31054. }
  31055. // 建立WebSocket连接
  31056. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31057. if err != nil {
  31058. }
  31059. defer conn.Close()
  31060. input2 := make(map[string]interface{})
  31061. input := make(map[string]interface{})
  31062. inputData := make(map[string]interface{})
  31063. inputData["orgId"] = code
  31064. inputData["businessType"] = "01301"
  31065. inputData["operatorId"] = operator_id
  31066. inputData["operatorName"] = operator_name
  31067. inputData["officeId"] = "001"
  31068. inputData["officeName"] = "血透室"
  31069. inputData["deviceType"] = ""
  31070. input["data"] = inputData
  31071. input["orgId"] = code
  31072. input["transType"] = "ec.query"
  31073. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31074. input2["indata"] = input
  31075. bytesData, _ := json.Marshal(input2)
  31076. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31077. if err != nil {
  31078. fmt.Println(err)
  31079. }
  31080. // 接收消息
  31081. _, receivedMessage, err := conn.ReadMessage()
  31082. if err != nil {
  31083. fmt.Println(err)
  31084. }
  31085. return "", string(receivedMessage)
  31086. }
  31087. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31088. newArr = make([]string, 0)
  31089. for i := 0; i < len(arr); i++ {
  31090. repeat := false
  31091. for j := i + 1; j < len(arr); j++ {
  31092. if arr[i] == arr[j] {
  31093. repeat = true
  31094. break
  31095. }
  31096. }
  31097. if !repeat {
  31098. newArr = append(newArr, arr[i])
  31099. }
  31100. }
  31101. return
  31102. }
  31103. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31104. if len(idNumber) != 18 {
  31105. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31106. }
  31107. // 提取出生日期
  31108. year, err := strconv.Atoi(idNumber[6:10])
  31109. if err != nil {
  31110. return "", 0, err
  31111. }
  31112. month, err := strconv.Atoi(idNumber[10:12])
  31113. if err != nil {
  31114. return "", 0, err
  31115. }
  31116. day, err := strconv.Atoi(idNumber[12:14])
  31117. if err != nil {
  31118. return "", 0, err
  31119. }
  31120. // 格式化生日字符串
  31121. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31122. birthdateFormatted := birthdate.Format("2006-01-02")
  31123. // 计算年龄
  31124. today := time.Now()
  31125. age := today.Year() - birthdate.Year()
  31126. if today.YearDay() < birthdate.YearDay() {
  31127. age--
  31128. }
  31129. return birthdateFormatted, age, nil
  31130. }