his_api_controller.go 1.2MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582
  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. admin_user_id, _ := c.GetInt64("admin_user_id")
  161. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  162. id_arr := strings.Split(ids, ",")
  163. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  164. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  165. //库盘
  166. for _, drug := range drugs {
  167. if drug.IsPc == 0 && drug.IsBg == 0 {
  168. var struct3501 models.Struct3501
  169. struct3501.OrgName = miConfig.OrgName
  170. struct3501.AccessKey = miConfig.AccessKey
  171. struct3501.Opter = roles.UserName
  172. struct3501.RequestUrl = miConfig.Url
  173. struct3501.Url = miConfig.Url
  174. struct3501.AppId = miConfig.Cainfo
  175. struct3501.AppSecret = miConfig.AppSecret
  176. struct3501.Enckey = miConfig.EncKey
  177. struct3501.SignKey = miConfig.SignKey
  178. struct3501.SecretKey = miConfig.SecretKey
  179. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  180. struct3501.FixmedinsHilistId = miConfig.Code
  181. struct3501.FixmedinsHilistName = miConfig.OrgName
  182. struct3501.RxFlag = "0"
  183. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  184. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  185. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  186. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  187. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02 15:04:05")
  188. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  189. memo := make(map[string]interface{})
  190. memo["pric"] = drug.Price
  191. bytesData, _ := json.Marshal(memo)
  192. struct3501.Memo = string(bytesData)
  193. result1, result2, result3 := service.FJyb3501(struct3501)
  194. fmt.Println(result1)
  195. fmt.Println(result2)
  196. fmt.Println(result3)
  197. var struct3502 models.Struct3502
  198. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  199. struct3502.FixmedinsHilistId = miConfig.Code
  200. struct3502.FixmedinsHilistName = miConfig.OrgName
  201. struct3502.FixmedinsCode = miConfig.Code
  202. struct3502.RxFlag = "0"
  203. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  204. struct3502.OrgName = miConfig.OrgName
  205. struct3502.AccessKey = miConfig.AccessKey
  206. struct3502.RequestUrl = miConfig.Url
  207. struct3502.SecretKey = miConfig.SecretKey
  208. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  209. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  210. struct3502.Url = miConfig.Url
  211. struct3502.AppId = miConfig.Cainfo
  212. struct3502.AppSecret = miConfig.AppSecret
  213. struct3502.Enckey = miConfig.EncKey
  214. struct3502.SignKey = miConfig.SignKey
  215. struct3502.SecretKey = miConfig.SecretKey
  216. struct3502.Memo = ""
  217. struct3502.InvChgType = "108"
  218. struct3501.FixmedinsBchno = strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3502"
  219. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  220. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  221. result11, result22, result33 := service.FJyb3502(struct3502)
  222. fmt.Println(result11)
  223. fmt.Println(result22)
  224. fmt.Println(result33)
  225. }
  226. //变更
  227. if drug.IsPc == 1 && drug.IsBg == 0 {
  228. var struct3502 models.Struct3502
  229. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  230. struct3502.FixmedinsHilistId = miConfig.Code
  231. struct3502.FixmedinsHilistName = miConfig.OrgName
  232. struct3502.FixmedinsCode = miConfig.Code
  233. struct3502.RxFlag = "0"
  234. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  235. struct3502.OrgName = miConfig.OrgName
  236. struct3502.AccessKey = miConfig.AccessKey
  237. struct3502.RequestUrl = miConfig.Url
  238. struct3502.SecretKey = miConfig.SecretKey
  239. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  240. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  241. struct3502.InvChgType = "108"
  242. struct3502.Url = miConfig.Url
  243. struct3502.AppId = miConfig.Cainfo
  244. struct3502.AppSecret = miConfig.AppSecret
  245. struct3502.Enckey = miConfig.EncKey
  246. struct3502.SignKey = miConfig.SignKey
  247. struct3502.SecretKey = miConfig.SecretKey
  248. struct3502.FixmedinsBchno = ""
  249. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  250. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  251. result1, result2, result3 := service.FJyb3502(struct3502)
  252. fmt.Println(result1)
  253. fmt.Println(result2)
  254. fmt.Println(result3)
  255. }
  256. }
  257. }
  258. func (c *HisApiController) DeletePCandBG() {
  259. ids := c.getString("ids")
  260. id_arr := strings.Split(ids, ",")
  261. admin_user_id, _ := c.GetInt64("admin_user_id")
  262. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  263. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  264. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  265. for _, item := range drugs {
  266. if item.IsPc == 1 && item.IsBg == 1 {
  267. var struct3507 models.Struct3507
  268. struct3507.FixmedinsBchno = ""
  269. struct3507.InvDataType = "1"
  270. struct3507.Opter = roles.UserName
  271. struct3507.OrgName = miConfig.OrgName
  272. struct3507.AccessKey = miConfig.AccessKey
  273. struct3507.RequestUrl = miConfig.Url
  274. struct3507.SecretKey = miConfig.SecretKey
  275. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  276. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  277. struct3507.Url = miConfig.Url
  278. struct3507.AppId = miConfig.Cainfo
  279. struct3507.AppSecret = miConfig.AppSecret
  280. struct3507.Enckey = miConfig.EncKey
  281. struct3507.SignKey = miConfig.SignKey
  282. struct3507.SecretKey = miConfig.SecretKey
  283. service.FJyb3507(struct3507)
  284. var struct3507_2 models.Struct3507
  285. struct3507_2.OrgName = miConfig.OrgName
  286. struct3507_2.AccessKey = miConfig.AccessKey
  287. struct3507_2.RequestUrl = miConfig.Url
  288. struct3507_2.SecretKey = miConfig.SecretKey
  289. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  290. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  291. struct3507_2.Url = miConfig.Url
  292. struct3507_2.AppId = miConfig.Cainfo
  293. struct3507_2.AppSecret = miConfig.AppSecret
  294. struct3507_2.Enckey = miConfig.EncKey
  295. struct3507_2.SignKey = miConfig.SignKey
  296. struct3507_2.SecretKey = miConfig.SecretKey
  297. struct3507_2.FixmedinsBchno = ""
  298. struct3507_2.InvDataType = "2"
  299. service.FJyb3507(struct3507_2)
  300. }
  301. if item.IsPc == 1 && item.IsBg == 0 {
  302. var struct3507 models.Struct3507
  303. struct3507.OrgName = miConfig.OrgName
  304. struct3507.AccessKey = miConfig.AccessKey
  305. struct3507.RequestUrl = miConfig.Url
  306. struct3507.SecretKey = miConfig.SecretKey
  307. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  308. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  309. struct3507.Url = miConfig.Url
  310. struct3507.AppId = miConfig.Cainfo
  311. struct3507.AppSecret = miConfig.AppSecret
  312. struct3507.Enckey = miConfig.EncKey
  313. struct3507.SignKey = miConfig.SignKey
  314. struct3507.SecretKey = miConfig.SecretKey
  315. struct3507.FixmedinsBchno = ""
  316. struct3507.InvDataType = "1"
  317. service.FJyb3507(struct3507)
  318. }
  319. }
  320. }
  321. func (c *HisApiController) DeleteXSandBG() {
  322. ids := c.getString("ids")
  323. id_arr := strings.Split(ids, ",")
  324. admin_user_id, _ := c.GetInt64("admin_user_id")
  325. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  326. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  327. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  328. for _, item := range drugs {
  329. if item.IsPc == 1 && item.IsBg == 1 {
  330. var struct3507 models.Struct3507
  331. struct3507.FixmedinsBchno = ""
  332. struct3507.InvDataType = "1"
  333. struct3507.Opter = roles.UserName
  334. struct3507.OrgName = miConfig.OrgName
  335. struct3507.AccessKey = miConfig.AccessKey
  336. struct3507.RequestUrl = miConfig.Url
  337. struct3507.SecretKey = miConfig.SecretKey
  338. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  339. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  340. struct3507.Url = miConfig.Url
  341. struct3507.AppId = miConfig.Cainfo
  342. struct3507.AppSecret = miConfig.AppSecret
  343. struct3507.Enckey = miConfig.EncKey
  344. struct3507.SignKey = miConfig.SignKey
  345. struct3507.SecretKey = miConfig.SecretKey
  346. struct3507.FixmedinsBchno = ""
  347. struct3507.InvDataType = "1"
  348. service.FJyb3507(struct3507)
  349. var struct3507_2 models.Struct3507
  350. struct3507_2.OrgName = miConfig.OrgName
  351. struct3507_2.AccessKey = miConfig.AccessKey
  352. struct3507_2.RequestUrl = miConfig.Url
  353. struct3507_2.SecretKey = miConfig.SecretKey
  354. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  355. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  356. struct3507_2.FixmedinsBchno = ""
  357. struct3507_2.InvDataType = "2"
  358. struct3507_2.Url = miConfig.Url
  359. struct3507_2.AppId = miConfig.Cainfo
  360. struct3507_2.AppSecret = miConfig.AppSecret
  361. struct3507_2.Enckey = miConfig.EncKey
  362. struct3507_2.SignKey = miConfig.SignKey
  363. struct3507_2.SecretKey = miConfig.SecretKey
  364. struct3507_2.FixmedinsBchno = ""
  365. struct3507_2.InvDataType = "1"
  366. service.FJyb3507(struct3507_2)
  367. }
  368. if item.IsPc == 1 && item.IsBg == 0 {
  369. var struct3507 models.Struct3507
  370. struct3507.OrgName = miConfig.OrgName
  371. struct3507.AccessKey = miConfig.AccessKey
  372. struct3507.RequestUrl = miConfig.Url
  373. struct3507.SecretKey = miConfig.SecretKey
  374. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  375. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  376. struct3507.FixmedinsBchno = ""
  377. struct3507.InvDataType = "1"
  378. service.FJyb3507(struct3507)
  379. }
  380. }
  381. }
  382. func (c *HisApiController) ChangeDrug() {
  383. ids := c.getString("ids")
  384. id_arr := strings.Split(ids, ",")
  385. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  386. admin_user_id, _ := c.GetInt64("admin_user_id")
  387. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  388. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  389. for _, item := range flows {
  390. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  391. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  392. if prescription.OrderStatus == 2 { //已经结算
  393. //判断是否已经销售
  394. if item.IsSale == 1 { //是否已经销售,1是 0否
  395. //是否已经变更 1是 0否
  396. if item.IsChange == 0 { //没变更,进行变更操作
  397. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  398. }
  399. } else { //没销售,
  400. //进行商品销售接口
  401. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  402. if item.IsChange == 0 { //没变更,进行变更操作
  403. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  404. }
  405. }
  406. } else { //还没结算
  407. if item.IsChange == 0 { //没变更,进行变更操作
  408. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  409. }
  410. }
  411. } else if item.ConsumableType == 7 {
  412. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  413. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  414. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  415. //判断是否已经销售
  416. if item.IsSale == 1 { //是否已经销售,1是 0否
  417. //是否已经变更 1是 0否
  418. if item.IsChange == 0 { //没变更,进行变更操作
  419. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  420. }
  421. } else { //没销售,
  422. //进行商品销售退货接口
  423. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  424. if item.IsChange == 0 { //没变更,进行变更操作
  425. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  426. }
  427. }
  428. } else { //还没结算
  429. if item.IsChange == 0 { //没变更,进行变更操作
  430. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  431. }
  432. }
  433. } else { //其他方式
  434. if item.IsChange == 0 { //没变更,进行变更操作
  435. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  436. }
  437. }
  438. }
  439. }
  440. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  441. var struct3502 models.Struct3502
  442. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  443. struct3502.FixmedinsHilistId = miConfig.Code
  444. struct3502.FixmedinsHilistName = miConfig.OrgName
  445. struct3502.FixmedinsCode = miConfig.Code
  446. struct3502.Opter = role.UserName
  447. struct3502.RxFlag = "0"
  448. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  449. struct3502.OrgName = miConfig.OrgName
  450. struct3502.AccessKey = miConfig.AccessKey
  451. struct3502.RequestUrl = miConfig.Url
  452. struct3502.SecretKey = miConfig.SecretKey
  453. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  454. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  455. struct3502.Url = miConfig.Url
  456. struct3502.AppId = miConfig.Cainfo
  457. struct3502.AppSecret = miConfig.AppSecret
  458. struct3502.Enckey = miConfig.EncKey
  459. struct3502.SignKey = miConfig.SignKey
  460. struct3502.SecretKey = miConfig.SecretKey
  461. struct3502.InvChgType = chgType
  462. struct3502.FixmedinsBchno = ""
  463. struct3502.Cnt = strconv.FormatInt(count, 10)
  464. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  465. result1, result2, result3 := service.FJyb3502(struct3502)
  466. fmt.Println(result1)
  467. fmt.Println(result2)
  468. fmt.Println(result3)
  469. }
  470. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  471. var struct3505 models.Struct3505
  472. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  473. struct3505.FixmedinsHilistId = miConfig.Code
  474. struct3505.FixmedinsHilistName = miConfig.OrgName
  475. struct3505.FixmedinsCode = miConfig.Code
  476. struct3505.FixmedinsBchno = ""
  477. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  478. struct3505.PrscDrName = roles.UserName
  479. struct3505.PharName = ""
  480. struct3505.PharPracCertNo = ""
  481. order := service.GetHisOrderByNumber(pre.BatchNumber)
  482. struct3505.SetlId = order.SetlId
  483. struct3505.MdtrtSn = order.MdtrtId
  484. struct3505.ManuLotnum = ""
  485. struct3505.ManuDate = ""
  486. struct3505.ExpyEnd = ""
  487. struct3505.RxFlag = "0"
  488. struct3505.TrdnFlag = "1"
  489. struct3505.Url = miConfig.Url
  490. struct3505.AppId = miConfig.Cainfo
  491. struct3505.AppSecret = miConfig.AppSecret
  492. struct3505.Enckey = miConfig.EncKey
  493. struct3505.SignKey = miConfig.SignKey
  494. struct3505.SecretKey = miConfig.SecretKey
  495. struct3505.RtalDocno = order.Number
  496. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  497. struct3505.SelRetnCnt = strValue
  498. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  499. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  500. struct3505.SelRetnOpterName = roles_two.UserName
  501. if order.IsMedicineInsurance == 1 {
  502. struct3505.MdtrtSetlType = "1"
  503. } else {
  504. struct3505.MdtrtSetlType = "2"
  505. }
  506. struct3505.OrgName = miConfig.OrgName
  507. struct3505.AccessKey = miConfig.AccessKey
  508. struct3505.RequestUrl = miConfig.Url
  509. struct3505.SecretKey = miConfig.SecretKey
  510. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  511. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  512. result1, result2, result3 := service.FJyb3505(struct3505)
  513. fmt.Println(result1)
  514. fmt.Println(result2)
  515. fmt.Println(result3)
  516. }
  517. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  518. var struct3506 models.Struct3506
  519. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  520. struct3506.FixmedinsHilistId = miConfig.Code
  521. struct3506.FixmedinsHilistName = miConfig.OrgName
  522. struct3506.FixmedinsCode = miConfig.Code
  523. struct3506.FixmedinsBchno = ""
  524. order := service.GetHisOrderByNumber(pre.BatchNumber)
  525. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  526. struct3506.ManuLotnum = ""
  527. struct3506.ManuDate = ""
  528. struct3506.MdtrtSn = order.MdtrtId
  529. struct3506.ExpyEnd = ""
  530. struct3506.RxFlag = "0"
  531. struct3506.TrdnFlag = "1"
  532. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  533. struct3506.SelRetnCnt = strValue
  534. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  535. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  536. struct3506.SelRetnOpterName = roles_two.UserName
  537. struct3506.OrgName = miConfig.OrgName
  538. struct3506.AccessKey = miConfig.AccessKey
  539. struct3506.RequestUrl = miConfig.Url
  540. struct3506.SecretKey = miConfig.SecretKey
  541. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  542. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  543. struct3506.Url = miConfig.Url
  544. struct3506.AppId = miConfig.Cainfo
  545. struct3506.AppSecret = miConfig.AppSecret
  546. struct3506.Enckey = miConfig.EncKey
  547. struct3506.SignKey = miConfig.SignKey
  548. struct3506.SecretKey = miConfig.SecretKey
  549. result1, result2, result3 := service.FJyb3506(struct3506)
  550. fmt.Println(result1)
  551. fmt.Println(result2)
  552. fmt.Println(result3)
  553. }
  554. func (c *HisApiController) Get1318() {
  555. adminUser := c.GetAdminUserInfo()
  556. admin_user_id, _ := c.GetInt64("admin_user_id")
  557. code := c.GetString("code")
  558. code = ""
  559. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  560. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  561. api := ""
  562. if miConfig.MdtrtareaAdmvs == "320921" {
  563. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  564. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  565. } else {
  566. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  567. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  568. }
  569. resp, requestErr := http.Get(api)
  570. if requestErr != nil {
  571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  572. return
  573. }
  574. body, ioErr := ioutil.ReadAll(resp.Body)
  575. if ioErr != nil {
  576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. var respJSON map[string]interface{}
  581. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  584. return
  585. }
  586. //var res Result2406
  587. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  588. result, _ := json.Marshal(respJSON)
  589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  590. utils.ErrorLog("解析失败:%v", err)
  591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. if res.Infcode == "0" {
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "result": "",
  597. })
  598. } else {
  599. c.ServeSuccessJSON(map[string]interface{}{
  600. "failed_code": -10,
  601. "msg": res.ErrMsg,
  602. })
  603. */return
  604. //}
  605. }
  606. func (c *HisApiController) Get2503() {
  607. adminUser := c.GetAdminUserInfo()
  608. admin_user_id, _ := c.GetInt64("admin_user_id")
  609. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  610. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  611. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  612. }
  613. func (c *HisApiController) Get2406() {
  614. id, _ := c.GetInt64("id")
  615. record_time := c.GetString("record_time")
  616. his_patient_id, _ := c.GetInt64("his_patient_id")
  617. admin_user_id, _ := c.GetInt64("admin_user_id")
  618. diagnosis_id := c.GetString("diagnosis")
  619. timeLayout := "2006-01-02"
  620. loc, _ := time.LoadLocation("Local")
  621. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  622. if err != nil {
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  624. return
  625. }
  626. recordDateTime := theTime.Unix()
  627. adminUser := c.GetAdminUserInfo()
  628. diagnosis_ids := strings.Split(diagnosis_id, ",")
  629. var config []*models.HisXtDiagnoseConfig
  630. for _, item := range diagnosis_ids {
  631. id, _ := strconv.ParseInt(item, 10, 64)
  632. diagnosisConfig, _ := service.FindDiagnoseById(id)
  633. config = append(config, &diagnosisConfig)
  634. }
  635. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  636. fmt.Println(his_patient_id)
  637. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  638. //timestamp := time.Now().Unix()
  639. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  640. var patientPrescription models.HisPrescriptionInfo
  641. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  642. if patientPrescription.ID == 0 {
  643. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  644. }
  645. var res2 Result2406
  646. if miConfig.MdtrtareaAdmvs == "341203" {
  647. data := make(map[string]interface{})
  648. client := &http.Client{}
  649. data["psn_no"] = his.PsnNo
  650. data["mdtrt_id"] = his.Number
  651. data["operator"] = roles.UserName
  652. data["cert_no"] = his.IdCardNo
  653. data["org_name"] = miConfig.OrgName
  654. data["psn_name"] = his.Name
  655. data["ipt_otp_no"] = his.IptOtpNo
  656. data["ipt_psn_sp_flag_type"] = "0901"
  657. data["ipt_psn_sp_flag"] = "1"
  658. data["fixmedins_code"] = miConfig.Code
  659. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  660. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  661. data["url"] = miConfig.Url
  662. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  663. bytesData, _ := json.Marshal(data)
  664. var req *http.Request
  665. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  666. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  667. resp, _ := client.Do(req)
  668. defer resp.Body.Close()
  669. body, ioErr := ioutil.ReadAll(resp.Body)
  670. if ioErr != nil {
  671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  673. return
  674. }
  675. var respJSON map[string]interface{}
  676. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  679. return
  680. }
  681. status := respJSON["data"].(map[string]interface{})["status"].(string)
  682. if status == "0" {
  683. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  684. c.ServeSuccessJSON(map[string]interface{}{
  685. "failed_code": -10,
  686. "msg": err_msg,
  687. })
  688. return
  689. }
  690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  691. userJSONBytes, _ := json.Marshal(respJSON)
  692. fmt.Println("log")
  693. fmt.Println(string(userJSONBytes))
  694. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  695. utils.ErrorLog("解析失败:%v", err)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. }
  700. if res2.Infcode != 0 {
  701. adminUser := c.GetAdminUserInfo()
  702. errlog := &models.HisOrderError{
  703. UserOrgId: adminUser.CurrentOrgId,
  704. Ctime: time.Now().Unix(),
  705. Mtime: time.Now().Unix(),
  706. ErrMsg: res2.ErrMsg,
  707. Status: 1,
  708. PatientId: id,
  709. RecordTime: recordDateTime,
  710. Stage: 3,
  711. }
  712. service.CreateErrMsgLog(errlog)
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "failed_code": -10,
  715. "msg": res2.ErrMsg,
  716. })
  717. return
  718. } else {
  719. c.ServeSuccessJSON(map[string]interface{}{
  720. "msg": "上传成功",
  721. })
  722. return
  723. }
  724. }
  725. func (c *HisApiController) Get4105() {
  726. }
  727. func (c *HisApiController) Post5302() {
  728. patient_id, _ := c.GetInt64("id")
  729. admin_user_id, _ := c.GetInt64("admin_user_id")
  730. p, _ := service.GetHisPatientById(patient_id)
  731. adminUser := c.GetAdminUserInfo()
  732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  733. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  734. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  735. }
  736. func (c *HisApiController) Get4104() {
  737. }
  738. type Output struct {
  739. CertNo string `json:"certno"`
  740. PsnName string `json:"psn_name"`
  741. CardNo string `json:"card_no"`
  742. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  743. CardSN string `json:"card_sn"`
  744. PsnCertType string `json:"psn_cert_type"`
  745. MdtrtCertNo string `json:"mdtrt_cert_no"`
  746. MdtrtCertType string `json:"mdtrt_cert_type"`
  747. QRCode string `json:"qrCode"`
  748. EcToken string `json:"ecToken"`
  749. }
  750. type AHResponse struct {
  751. Body AHBody `json:"body"`
  752. Code int `json:"code"`
  753. CSBCode int `json:"csbCode"`
  754. Message string `json:"message"`
  755. RequestID string `json:"requestId"`
  756. State struct{} `json:"state"`
  757. }
  758. type AHBody struct {
  759. ErrMsg string `json:"err_msg"`
  760. InfRefMsgID string `json:"inf_refmsgid"`
  761. InfCode int `json:"infcode"`
  762. Output struct {
  763. Result []struct {
  764. BasMednFlag string `json:"bas_medn_flag"`
  765. ChldMedcFlag string `json:"chld_medc_flag"`
  766. ChrgitmLv string `json:"chrgitm_lv"`
  767. Cnt float64 `json:"cnt"`
  768. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  769. DrtReimFlag string `json:"drt_reim_flag"`
  770. FeedetlSn string `json:"feedetl_sn"`
  771. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  772. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  773. InscpScpAmt float64 `json:"inscp_scp_amt"`
  774. ListSpItemFlag string `json:"list_sp_item_flag"`
  775. LmtUsedFlag string `json:"lmt_used_flag"`
  776. MedChrgitmType string `json:"med_chrgitm_type"`
  777. Memo string `json:"memo"`
  778. OverlmtAmt float64 `json:"overlmt_amt"`
  779. PreselfpayAmt float64 `json:"preselfpay_amt"`
  780. Pric float64 `json:"pric"`
  781. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  782. SelfpayProp float64 `json:"selfpay_prop"`
  783. } `json:"result"`
  784. } `json:"output"`
  785. }
  786. type Response struct {
  787. Output Output `json:"output"`
  788. Infcode int `json:"infcode"`
  789. InfRefMsgID string `json:"inf_refmsgid"`
  790. RefMsgTime string `json:"refmsg_time"`
  791. RespondTime string `json:"respond_time"`
  792. ErrMsg string `json:"err_msg"`
  793. WarnMsg string `json:"warn_msg"`
  794. SignType string `json:"signtype"`
  795. CAInfo string `json:"cainfo"`
  796. }
  797. func (c *HisApiController) Getquerydata() {
  798. query_type, _ := c.GetInt64("type")
  799. refd_setl_flag := c.GetString("refd_setl_flag")
  800. med_type := c.GetString("med_type")
  801. //admin_user_id,_ := c.GetInt64("admin_user_id")
  802. cert_no := c.GetString("cert_no")
  803. psn_no := c.GetString("psn_no")
  804. start_time := c.GetString("start_time")
  805. end_time := c.GetString("end_time")
  806. page, _ := c.GetInt64("page")
  807. limit, _ := c.GetInt64("limit")
  808. var bp models.BusinessParams5262
  809. bp.RefdSetlFlag = refd_setl_flag
  810. bp.MedType = med_type
  811. bp.Certno = cert_no
  812. bp.Psnno = psn_no
  813. bp.QBegntime = start_time
  814. bp.QEndtime = end_time
  815. if query_type == 1 { //本地
  816. Post5262(c, bp, page, limit)
  817. } else { //异地
  818. Post5267(c, bp, page, limit)
  819. }
  820. }
  821. func (c *HisApiController) Drugscheck() {
  822. admin_user_id, _ := c.GetInt64("admin_user_id")
  823. adminUser := c.GetAdminUserInfo()
  824. var queryResult []QueryResult
  825. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  826. for _, item := range drugs {
  827. result := QueryResult{
  828. ID: item.ID,
  829. Name: item.DrugName,
  830. Code: item.MedicalInsuranceNumber,
  831. List_type_code: "101",
  832. }
  833. queryResult = append(queryResult, result)
  834. }
  835. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  836. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  837. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  838. for _, item := range queryResult {
  839. 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)
  840. }
  841. }
  842. func (c *HisApiController) Goodcheck() {
  843. admin_user_id, _ := c.GetInt64("admin_user_id")
  844. adminUser := c.GetAdminUserInfo()
  845. var queryResult []QueryResult
  846. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  847. for _, item := range goods {
  848. result := QueryResult{
  849. ID: item.ID,
  850. Name: item.GoodName,
  851. Code: item.SocialSecurityDirectoryCode,
  852. List_type_code: "301",
  853. }
  854. queryResult = append(queryResult, result)
  855. }
  856. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  857. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  858. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  859. for _, item := range queryResult {
  860. 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)
  861. //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)
  862. }
  863. }
  864. func (c *HisApiController) Projectcheck() {
  865. admin_user_id, _ := c.GetInt64("admin_user_id")
  866. adminUser := c.GetAdminUserInfo()
  867. var queryResult []QueryResult
  868. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  869. for _, item := range projects {
  870. result := QueryResult{
  871. ID: item.ID,
  872. Name: item.ProjectName,
  873. Code: item.MedicalCode,
  874. List_type_code: "201",
  875. }
  876. queryResult = append(queryResult, result)
  877. }
  878. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  879. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  880. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  881. for _, item := range queryResult {
  882. 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)
  883. }
  884. }
  885. //func (c *HisApiController)CancleDia(){
  886. //
  887. // id, _ := c.GetInt64("id")
  888. // record_time := c.GetString("record_time")
  889. // his_patient_id, _ := c.GetInt64("his_patient_id")
  890. //
  891. // admin_user_id, _ := c.GetInt64("admin_user_id")
  892. //
  893. // diagnosis_id := c.GetString("diagnosis")
  894. // sick_type, _ := c.GetInt64("sick_type")
  895. // reg_type, _ := c.GetInt64("p_type")
  896. // begin_time := c.GetString("begin_time")
  897. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  898. //
  899. //
  900. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  901. //
  902. // fmt.Println(acct_used_flag)
  903. //
  904. //
  905. // timeLayout := "2006-01-02"
  906. // loc, _ := time.LoadLocation("Local")
  907. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  908. // if err != nil {
  909. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  910. // return
  911. // }
  912. // recordDateTime := theTime.Unix()
  913. // adminUser := c.GetAdminUserInfo()
  914. //
  915. //
  916. //
  917. //
  918. //
  919. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  920. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  921. // var patientPrescription models.HisPrescriptionInfo
  922. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  923. // if patientPrescription.ID == 0 {
  924. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  925. // }
  926. // //if patientPrescription.Do
  927. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  928. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  929. //
  930. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  931. //
  932. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  933. //
  934. // var config []*models.HisXtDiagnoseConfig
  935. // for _, item := range diagnosis_ids {
  936. // id, _ := strconv.ParseInt(item, 10, 64)
  937. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  938. // config = append(config, &diagnosisConfig)
  939. // }
  940. //
  941. // sickConfig, _ := service.FindSickById(sick_type)
  942. //
  943. //
  944. // data := make(map[string]interface{})
  945. // client := &http.Client{}
  946. // data["psn_no"] = his.PsnNo
  947. // data["mdtrt_id"] = his.Number
  948. // data["doctor"] = roles.UserName
  949. // data["department"] = department.Name
  950. // data["org_name"] = miConfig.OrgName
  951. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  952. // data["doctor_id"] = doctor_info.DoctorNumber
  953. // data["new_doctor_name"] = doctor_info.UserName
  954. // data["fixmedins_code"] = miConfig.Code
  955. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  956. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  957. // data["secret_key"] = miConfig.SecretKey
  958. // data["sick_code"] = sickConfig.CountryCode
  959. // data["sick_name"] = sickConfig.ClassName
  960. // data["url"] = miConfig.Url
  961. // data["ak"] = miConfig.AccessKey
  962. // data["begin_time"] = begin_time
  963. // data["cainfo"] = miConfig.Cainfo
  964. // data["is_vaild"] = "0"
  965. //
  966. // data["dept"] = strconv.FormatInt(department.ID, 10)
  967. // data["config"] = config
  968. // bytesData, _ := json.Marshal(data)
  969. //
  970. // var req *http.Request
  971. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  972. // resp, _ := client.Do(req)
  973. // defer resp.Body.Close()
  974. // body, ioErr := ioutil.ReadAll(resp.Body)
  975. // if ioErr != nil {
  976. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  978. // return
  979. // }
  980. // var respJSON map[string]interface{}
  981. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  982. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. // return
  985. // }
  986. //
  987. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  988. // userJSONBytes, _ := json.Marshal(respJSON)
  989. // fmt.Println("log")
  990. // fmt.Println(string(userJSONBytes))
  991. //
  992. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  993. // utils.ErrorLog("解析失败:%v", err)
  994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  995. // return
  996. // }
  997. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  998. // res2.Output = ressix10265.Output
  999. // res2.ErrMsg = ressix10265.ErrMsg
  1000. // res2.Cainfo = ressix10265.Cainfo
  1001. // res2.WarnMsg = ressix10265.WarnMsg
  1002. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1003. // res2.Infcode = infocode
  1004. //
  1005. //}
  1006. func (c *HisApiController) Get4102() {
  1007. order_id, _ := c.GetInt64("order_id")
  1008. admin_user_id, _ := c.GetInt64("admin_user_id")
  1009. stas_type := c.GetString("stas_type")
  1010. order, _ := service.GetHisOrderByIDTwo(order_id)
  1011. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1012. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1013. var pp models.PublicParams
  1014. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1015. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1016. pp.FixmedinsName = miConfig.OrgName
  1017. pp.FixmedinsCode = miConfig.Code
  1018. pp.RequestUrl = miConfig.Url
  1019. pp.Cainfo = miConfig.Cainfo
  1020. pp.SecretKey = miConfig.SecretKey
  1021. pp.AccessKey = miConfig.AccessKey
  1022. pp.OpterName = curRoles.UserName
  1023. if miConfig.MdtrtareaAdmvs == "350500" {
  1024. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1025. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1026. saveLog(result, request, "4102", "清单确认")
  1027. var dat map[string]interface{}
  1028. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1029. fmt.Println(dat)
  1030. } else {
  1031. fmt.Println(err)
  1032. }
  1033. var empty ResultFourteen
  1034. userJSONBytes, _ := json.Marshal(dat)
  1035. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. return
  1039. }
  1040. if empty.Infcode == 0 {
  1041. c.ServeSuccessJSON(map[string]interface{}{
  1042. "msg": "确认成功",
  1043. })
  1044. return
  1045. }
  1046. } else {
  1047. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1048. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1049. result3, request3 := service.Jxyb4105(pp)
  1050. saveLog(result, request, "4102", "清单确认")
  1051. saveLog(result2, request2, "4103", "清单确认")
  1052. saveLog(result3, request3, "4105", "清单统计")
  1053. var dat map[string]interface{}
  1054. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1055. fmt.Println(dat)
  1056. } else {
  1057. fmt.Println(err)
  1058. }
  1059. var empty ResultFourteen
  1060. userJSONBytes, _ := json.Marshal(dat)
  1061. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1062. utils.ErrorLog("解析失败:%v", err)
  1063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1064. return
  1065. }
  1066. if empty.Infcode == 0 {
  1067. c.ServeSuccessJSON(map[string]interface{}{
  1068. "msg": "确认成功",
  1069. })
  1070. return
  1071. }
  1072. }
  1073. }
  1074. // 对账权限查询
  1075. func (c *HisApiController) Get3260() {
  1076. admin_user_id, _ := c.GetInt64("admin_user_id")
  1077. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1078. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1079. var api string
  1080. var res models.JSResult3260
  1081. if miConfig.MdtrtareaAdmvs == "320921" {
  1082. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1083. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1084. } else {
  1085. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1086. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1106. result, _ := json.Marshal(respJSON)
  1107. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1108. utils.ErrorLog("解析失败:%v", err)
  1109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1110. return
  1111. }
  1112. if res.Infcode == "0" {
  1113. c.ServeSuccessJSON(map[string]interface{}{
  1114. "result": res.Output.Data,
  1115. })
  1116. } else {
  1117. c.ServeSuccessJSON(map[string]interface{}{
  1118. "failed_code": -10,
  1119. "msg": res.ErrMsg,
  1120. })
  1121. return
  1122. }
  1123. }
  1124. func (c *HisApiController) Get3261() {
  1125. admin_user_id, _ := c.GetInt64("admin_user_id")
  1126. //month := c.GetString("month")
  1127. startTime := c.GetString("start_time")
  1128. //endTime, _ := c.GetString("end_time")
  1129. times := strings.Split(startTime, "-")
  1130. stmt_mon := times[0] + times[1]
  1131. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1132. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1133. var api string
  1134. var res models.JSResult3261
  1135. //var res10265 Result5301For10265
  1136. if miConfig.MdtrtareaAdmvs == "320921" {
  1137. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1138. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1139. } else {
  1140. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1141. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1142. }
  1143. resp, requestErr := http.Get(api)
  1144. if requestErr != nil {
  1145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1146. return
  1147. }
  1148. body, ioErr := ioutil.ReadAll(resp.Body)
  1149. if ioErr != nil {
  1150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. return
  1153. }
  1154. var respJSON map[string]interface{}
  1155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1158. return
  1159. }
  1160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1161. result, _ := json.Marshal(respJSON)
  1162. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1163. utils.ErrorLog("解析失败:%v", err)
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1165. return
  1166. }
  1167. if res.Infcode == "0" {
  1168. c.ServeSuccessJSON(map[string]interface{}{
  1169. "result": res.Output,
  1170. })
  1171. } else {
  1172. c.ServeSuccessJSON(map[string]interface{}{
  1173. "failed_code": -10,
  1174. "msg": res.ErrMsg,
  1175. })
  1176. return
  1177. }
  1178. }
  1179. type TempFun struct {
  1180. FundKey string
  1181. FundCode string
  1182. }
  1183. func (c *HisApiController) Get3262() {
  1184. admin_user_id, _ := c.GetInt64("admin_user_id")
  1185. startTime := c.GetString("start_time")
  1186. endTime := c.GetString("end_time")
  1187. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1188. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1189. //timeLayout := "2006-01-02"
  1190. //loc, _ := time.LoadLocation("Local")
  1191. //var theStartTIme int64
  1192. //if len(startTime) > 0 {
  1193. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1194. // if err != nil {
  1195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1196. // return
  1197. // }
  1198. // theStartTIme = theTime.Unix()
  1199. //}
  1200. //var theEndtTIme int64
  1201. //if len(endTime) > 0 {
  1202. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1203. // if err != nil {
  1204. // utils.ErrorLog(err.Error())
  1205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1206. // return
  1207. // }
  1208. // theEndtTIme = theTime.Unix()
  1209. //}
  1210. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1211. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1212. for _, team := range datas {
  1213. fmt.Println(team.PsnTime)
  1214. for _, team_two := range datas_two {
  1215. fmt.Println(team_two.PsnTime)
  1216. if team.FundKey == team_two.FundKey {
  1217. fmt.Println(team_two.PsnTime)
  1218. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1219. fmt.Println(team.PsnTime)
  1220. }
  1221. }
  1222. }
  1223. fmt.Println("1111")
  1224. fmt.Println(datas)
  1225. fmt.Println("1111")
  1226. var twos []models.FixMonRecDetailFileInTwo
  1227. for _, team := range datas {
  1228. var two models.FixMonRecDetailFileInTwo
  1229. two.MedType = team.MedType
  1230. two.Insutype = team.Insutype
  1231. two.PsnType = team.PsnType
  1232. two.MedType = team.MedType
  1233. two.FixBlngAdmdvs = "999999"
  1234. two.InsuAdmdvs = "555555"
  1235. two.PsnTime = team.PsnTime
  1236. two.PsnCnt = team.PsnCnt
  1237. two.FundKey = team.FundKey
  1238. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1239. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1240. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1241. two.MedfeeSumAmt = ms
  1242. two.InscpAmt = ia
  1243. two.FundPaySumAmt = fps
  1244. twos = append(twos, two)
  1245. }
  1246. //startTime := c.GetString("start_time")
  1247. //endTime, _ := c.GetString("end_time")
  1248. times := strings.Split(startTime, "-")
  1249. stmt_mon := times[0] + times[1]
  1250. var funs []models.FundDetail
  1251. for _, item := range datas {
  1252. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1253. funs = append(funs, fun...)
  1254. }
  1255. var funInfos []models.Fund
  1256. //for _, item := range funs {
  1257. // var rf []models.FundInfo
  1258. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1259. // for _, subitem := range rf {
  1260. // var fund models.Fund
  1261. // fund.FundCode = subitem.FundPayType
  1262. // fund.FundName = subitem.FundPayTypeName
  1263. // fund.FundAmt = subitem.FundPayAmt
  1264. // fund.FundKey = item.FundKey
  1265. // fund.InsuAdmdvs = "555555"
  1266. // fund.FixBlngAdmdvs = "999999"
  1267. // funInfos = append(funInfos, fund)
  1268. // }
  1269. //}
  1270. var tempFuns []TempFun
  1271. for _, funInfo := range funInfos {
  1272. var tempFun TempFun
  1273. tempFun.FundKey = funInfo.FundKey
  1274. tempFun.FundCode = funInfo.FundCode
  1275. tempFuns = append(tempFuns, tempFun)
  1276. }
  1277. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1278. fmt.Println(tempFuns)
  1279. var funInfosTwo []models.Fund
  1280. decimal.DivisionPrecision = 2
  1281. for _, item := range tempFuns {
  1282. var fund models.Fund
  1283. for _, subItem := range funInfos {
  1284. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1285. fund.FundKey = subItem.FundKey
  1286. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1287. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1288. fund.FundName = subItem.FundName
  1289. fund.FundCode = subItem.FundCode
  1290. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1291. }
  1292. }
  1293. funInfosTwo = append(funInfosTwo, fund)
  1294. }
  1295. fmt.Println("funInfosTwo")
  1296. fmt.Println(funInfosTwo)
  1297. var upld_btch string
  1298. var empty models.JSResultEmpty
  1299. data := make(map[string]interface{})
  1300. data["org_name"] = miConfig.OrgName
  1301. data["doctor"] = curRoles.UserName
  1302. data["doctor_name"] = curRoles.UserName
  1303. data["fixmedins_code"] = miConfig.Code
  1304. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1305. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1306. data["secret_key"] = miConfig.SecretKey
  1307. data["url"] = miConfig.Url
  1308. data["ak"] = miConfig.AccessKey
  1309. data["cainfo"] = miConfig.Cainfo
  1310. data["datas"] = twos
  1311. data["fund"] = funInfosTwo
  1312. fmt.Println(twos)
  1313. month := time.Unix(1557042972, 0).Format("1")
  1314. year := time.Now().Format("2006")
  1315. month = time.Now().Format("01")
  1316. day := time.Now().Format("02")
  1317. hour := time.Now().Format("15")
  1318. min := time.Now().Format("04")
  1319. sec := time.Now().Format("05")
  1320. fix_fill_date := year + month + day + hour + min + sec
  1321. data["fix_fill_dept"] = miConfig.OrgName
  1322. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1323. data["fix_fill_psn"] = curRoles.UserName
  1324. data["fix_fill_date"] = fix_fill_date
  1325. data["stmt_loc"] = "2"
  1326. data["setl_mon"] = stmt_mon
  1327. upld_btch = "0"
  1328. data["upld_btch"] = upld_btch
  1329. //fmt.Println(data)
  1330. client := &http.Client{}
  1331. bytesData, _ := json.Marshal(data)
  1332. var req *http.Request
  1333. if miConfig.MdtrtareaAdmvs == "320921" {
  1334. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1335. } else {
  1336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1337. }
  1338. resp, _ := client.Do(req)
  1339. defer resp.Body.Close()
  1340. body, ioErr := ioutil.ReadAll(resp.Body)
  1341. if ioErr != nil {
  1342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1344. }
  1345. var respJSON map[string]interface{}
  1346. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1347. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1349. }
  1350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1351. //fmt.Println(respJSON)
  1352. result, _ := json.Marshal(respJSON)
  1353. //fmt.Println(result)
  1354. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1355. utils.ErrorLog("解析失败:%v", err)
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1357. }
  1358. if empty.Infcode != "0" {
  1359. c.ServeSuccessJSON(map[string]interface{}{
  1360. "failed_code": -10,
  1361. "msg": empty.ErrMsg,
  1362. })
  1363. return
  1364. } else {
  1365. c.ServeSuccessJSON(map[string]interface{}{
  1366. "msg": "上传成功",
  1367. })
  1368. return
  1369. }
  1370. }
  1371. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1372. newArr = make([]TempFun, 0)
  1373. for i := 0; i < len(arr); i++ {
  1374. repeat := false
  1375. for j := i + 1; j < len(arr); j++ {
  1376. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1377. repeat = true
  1378. break
  1379. }
  1380. }
  1381. if !repeat {
  1382. newArr = append(newArr, arr[i])
  1383. }
  1384. }
  1385. return
  1386. }
  1387. func (c *HisApiController) Get3263() {
  1388. admin_user_id, _ := c.GetInt64("admin_user_id")
  1389. startTime := c.GetString("start_time")
  1390. //endTime, _ := c.GetString("end_time")
  1391. times := strings.Split(startTime, "-")
  1392. setl_mon := times[0] + times[1]
  1393. upld_btch := "0"
  1394. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1396. var result3263 models.JSResult3263
  1397. data := make(map[string]interface{})
  1398. data["org_name"] = miConfig.OrgName
  1399. data["doctor"] = curRoles.UserName
  1400. data["doctor_name"] = curRoles.UserName
  1401. data["fixmedins_code"] = miConfig.Code
  1402. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1403. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1404. data["secret_key"] = miConfig.SecretKey
  1405. data["url"] = miConfig.Url
  1406. data["ak"] = miConfig.AccessKey
  1407. data["cainfo"] = miConfig.Cainfo
  1408. data["setl_mon"] = setl_mon
  1409. data["stmt_loc"] = "2"
  1410. data["upld_btch"] = upld_btch
  1411. client := &http.Client{}
  1412. bytesData, _ := json.Marshal(data)
  1413. var req *http.Request
  1414. if miConfig.MdtrtareaAdmvs == "320921" {
  1415. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1416. } else {
  1417. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1418. }
  1419. resp, _ := client.Do(req)
  1420. defer resp.Body.Close()
  1421. body, ioErr := ioutil.ReadAll(resp.Body)
  1422. if ioErr != nil {
  1423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. }
  1426. var respJSON map[string]interface{}
  1427. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1428. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1430. }
  1431. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1432. fmt.Println(respJSON)
  1433. result, _ := json.Marshal(respJSON)
  1434. fmt.Println(result)
  1435. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1436. utils.ErrorLog("解析失败:%v", err)
  1437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1438. }
  1439. if result3263.Infcode != "0" {
  1440. c.ServeSuccessJSON(map[string]interface{}{
  1441. "failed_code": -10,
  1442. "msg": result3263.ErrMsg,
  1443. })
  1444. return
  1445. } else {
  1446. c.ServeSuccessJSON(map[string]interface{}{
  1447. "list": result3263.Output,
  1448. })
  1449. return
  1450. }
  1451. }
  1452. func (c *HisApiController) Get3264() {
  1453. admin_user_id, _ := c.GetInt64("admin_user_id")
  1454. startTime := c.GetString("start_time")
  1455. //endTime, _ := c.GetString("end_time")
  1456. times := strings.Split(startTime, "-")
  1457. setl_mon := times[0] + times[1]
  1458. upld_btch := "0"
  1459. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1460. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1461. //solidify_id := []
  1462. var result3263 models.JSResult3263
  1463. data := make(map[string]interface{})
  1464. data["org_name"] = miConfig.OrgName
  1465. data["doctor"] = curRoles.UserName
  1466. data["doctor_name"] = curRoles.UserName
  1467. data["fixmedins_code"] = miConfig.Code
  1468. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1470. data["secret_key"] = miConfig.SecretKey
  1471. data["url"] = miConfig.Url
  1472. data["ak"] = miConfig.AccessKey
  1473. data["cainfo"] = miConfig.Cainfo
  1474. data["setl_mon"] = setl_mon
  1475. data["stmt_loc"] = "2"
  1476. data["upld_btch"] = upld_btch
  1477. client := &http.Client{}
  1478. bytesData, _ := json.Marshal(data)
  1479. var req3263 *http.Request
  1480. if miConfig.MdtrtareaAdmvs == "320921" {
  1481. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1482. } else {
  1483. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1484. }
  1485. resp, _ := client.Do(req3263)
  1486. defer resp.Body.Close()
  1487. body, ioErr := ioutil.ReadAll(resp.Body)
  1488. if ioErr != nil {
  1489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. }
  1492. var respJSON3263 map[string]interface{}
  1493. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1496. }
  1497. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1498. fmt.Println(respJSON3263)
  1499. result, _ := json.Marshal(respJSON3263)
  1500. fmt.Println(result)
  1501. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1502. utils.ErrorLog("解析失败:%v", err)
  1503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1504. }
  1505. var ids []string
  1506. for _, item := range result3263.Output {
  1507. ids = append(ids, item.SolidifyID)
  1508. }
  1509. var empty models.JSResultEmpty
  1510. data2 := make(map[string]interface{})
  1511. data2["org_name"] = miConfig.OrgName
  1512. data2["doctor"] = curRoles.UserName
  1513. data2["doctor_name"] = curRoles.UserName
  1514. data2["fixmedins_code"] = miConfig.Code
  1515. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1516. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1517. data2["secret_key"] = miConfig.SecretKey
  1518. data2["url"] = miConfig.Url
  1519. data2["ak"] = miConfig.AccessKey
  1520. data2["cainfo"] = miConfig.Cainfo
  1521. data2["setl_mon"] = setl_mon
  1522. data2["stmt_loc"] = "2"
  1523. data2["upld_btch"] = upld_btch
  1524. data2["solidify_id"] = ids
  1525. client2 := &http.Client{}
  1526. bytesData2, _ := json.Marshal(data2)
  1527. var req *http.Request
  1528. if miConfig.MdtrtareaAdmvs == "320921" {
  1529. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1530. } else {
  1531. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1532. }
  1533. resp2, _ := client2.Do(req)
  1534. defer resp.Body.Close()
  1535. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1536. if ioErr2 != nil {
  1537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. }
  1540. var respJSON map[string]interface{}
  1541. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1544. }
  1545. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1546. fmt.Println(respJSON)
  1547. result2, _ := json.Marshal(respJSON)
  1548. fmt.Println(result2)
  1549. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1550. utils.ErrorLog("解析失败:%v", err)
  1551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1552. }
  1553. if empty.Infcode != "0" {
  1554. c.ServeSuccessJSON(map[string]interface{}{
  1555. "failed_code": -10,
  1556. "msg": empty.ErrMsg,
  1557. })
  1558. return
  1559. } else {
  1560. c.ServeSuccessJSON(map[string]interface{}{
  1561. "msg": "",
  1562. })
  1563. return
  1564. }
  1565. }
  1566. func (c *HisApiController) Get3265() {
  1567. admin_user_id, _ := c.GetInt64("admin_user_id")
  1568. startTime := c.GetString("start_time")
  1569. //endTime, _ := c.GetString("end_time")
  1570. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1571. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1572. times := strings.Split(startTime, "-")
  1573. setl_mon := times[0] + times[1]
  1574. var upld_btch string
  1575. upld_btch = "0"
  1576. //var empty models.JSResultEmpty
  1577. var result3265 models.JSResult3264
  1578. var result3263 models.JSResult3263
  1579. data2 := make(map[string]interface{})
  1580. data2["org_name"] = miConfig.OrgName
  1581. data2["doctor"] = curRoles.UserName
  1582. data2["doctor_name"] = curRoles.UserName
  1583. data2["fixmedins_code"] = miConfig.Code
  1584. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1585. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1586. data2["secret_key"] = miConfig.SecretKey
  1587. data2["url"] = miConfig.Url
  1588. data2["ak"] = miConfig.AccessKey
  1589. data2["cainfo"] = miConfig.Cainfo
  1590. data2["setl_mon"] = setl_mon
  1591. data2["stmt_loc"] = "2"
  1592. data2["upld_btch"] = upld_btch
  1593. client2 := &http.Client{}
  1594. bytesData2, _ := json.Marshal(data2)
  1595. var req3263 *http.Request
  1596. if miConfig.MdtrtareaAdmvs == "320921" {
  1597. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1598. } else {
  1599. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1600. }
  1601. resp2, _ := client2.Do(req3263)
  1602. defer resp2.Body.Close()
  1603. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1604. if ioErr2 != nil {
  1605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1607. }
  1608. var respJSON3263 map[string]interface{}
  1609. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1612. }
  1613. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1614. fmt.Println(respJSON3263)
  1615. result2, _ := json.Marshal(respJSON3263)
  1616. fmt.Println(result2)
  1617. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1618. utils.ErrorLog("解析失败:%v", err)
  1619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1620. }
  1621. var ids []string
  1622. for _, item := range result3263.Output {
  1623. ids = append(ids, item.SolidifyID)
  1624. }
  1625. data := make(map[string]interface{})
  1626. data["org_name"] = miConfig.OrgName
  1627. data["doctor"] = curRoles.UserName
  1628. data["doctor_name"] = curRoles.UserName
  1629. data["fixmedins_code"] = miConfig.Code
  1630. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1631. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1632. data["secret_key"] = miConfig.SecretKey
  1633. data["url"] = miConfig.Url
  1634. data["ak"] = miConfig.AccessKey
  1635. data["cainfo"] = miConfig.Cainfo
  1636. data["setl_mon"] = setl_mon
  1637. data["solidify_id"] = ids
  1638. month := time.Unix(1557042972, 0).Format("1")
  1639. year := time.Now().Format("2006")
  1640. month = time.Now().Format("01")
  1641. day := time.Now().Format("02")
  1642. hour := time.Now().Format("15")
  1643. min := time.Now().Format("04")
  1644. sec := time.Now().Format("05")
  1645. fix_fill_date := year + month + day + hour + min + sec
  1646. data["fix_fill_dept"] = miConfig.OrgName
  1647. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1648. data["fix_fill_psn"] = curRoles.UserName
  1649. data["fix_fill_date"] = fix_fill_date
  1650. data["stmt_loc"] = "2"
  1651. data["upld_btch"] = upld_btch
  1652. client := &http.Client{}
  1653. bytesData, _ := json.Marshal(data)
  1654. var req *http.Request
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1657. } else {
  1658. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1659. }
  1660. resp, _ := client.Do(req)
  1661. defer resp.Body.Close()
  1662. body, ioErr := ioutil.ReadAll(resp.Body)
  1663. if ioErr != nil {
  1664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. }
  1667. var respJSON map[string]interface{}
  1668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1671. }
  1672. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1673. fmt.Println(respJSON)
  1674. result, _ := json.Marshal(respJSON)
  1675. fmt.Println(result)
  1676. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1677. utils.ErrorLog("解析失败:%v", err)
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1679. }
  1680. if result3265.Infcode != "0" {
  1681. c.ServeSuccessJSON(map[string]interface{}{
  1682. "failed_code": -10,
  1683. "msg": result3265.ErrMsg,
  1684. })
  1685. return
  1686. } else {
  1687. c.ServeSuccessJSON(map[string]interface{}{
  1688. "info": result3265.Output,
  1689. })
  1690. return
  1691. }
  1692. }
  1693. func (c *HisApiController) Get3266() {
  1694. admin_user_id, _ := c.GetInt64("admin_user_id")
  1695. startTime := c.GetString("start_time")
  1696. //endTime, _ := c.GetString("end_time")
  1697. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1699. times := strings.Split(startTime, "-")
  1700. stmt_mon := times[0] + times[1]
  1701. var upld_btch string
  1702. //var empty models.JSResultEmpty
  1703. var result3265 models.JSResult3264
  1704. data := make(map[string]interface{})
  1705. data["org_name"] = miConfig.OrgName
  1706. data["doctor"] = curRoles.UserName
  1707. data["doctor_name"] = curRoles.UserName
  1708. data["fixmedins_code"] = miConfig.Code
  1709. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1710. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1711. data["secret_key"] = miConfig.SecretKey
  1712. data["url"] = miConfig.Url
  1713. data["ak"] = miConfig.AccessKey
  1714. data["cainfo"] = miConfig.Cainfo
  1715. data["setl_mon"] = stmt_mon
  1716. month := time.Unix(1557042972, 0).Format("1")
  1717. year := time.Now().Format("2006")
  1718. month = time.Now().Format("01")
  1719. day := time.Now().Format("02")
  1720. hour := time.Now().Format("15")
  1721. min := time.Now().Format("04")
  1722. sec := time.Now().Format("05")
  1723. fix_fill_date := year + month + day + hour + min + sec
  1724. data["fix_fill_dept"] = miConfig.OrgName
  1725. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1726. data["fix_fill_psn"] = curRoles.UserName
  1727. data["fix_fill_date"] = fix_fill_date
  1728. data["stmt_loc"] = "2"
  1729. upld_btch = "0"
  1730. data["upld_btch"] = upld_btch
  1731. client := &http.Client{}
  1732. bytesData, _ := json.Marshal(data)
  1733. var req *http.Request
  1734. if miConfig.MdtrtareaAdmvs == "320921" {
  1735. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1736. } else {
  1737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1738. }
  1739. resp, _ := client.Do(req)
  1740. defer resp.Body.Close()
  1741. body, ioErr := ioutil.ReadAll(resp.Body)
  1742. if ioErr != nil {
  1743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1745. }
  1746. var respJSON map[string]interface{}
  1747. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1748. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1750. }
  1751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1752. fmt.Println(respJSON)
  1753. result, _ := json.Marshal(respJSON)
  1754. fmt.Println(result)
  1755. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1756. utils.ErrorLog("解析失败:%v", err)
  1757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1758. }
  1759. if result3265.Infcode != "0" {
  1760. c.ServeSuccessJSON(map[string]interface{}{
  1761. "failed_code": -10,
  1762. "msg": result3265.ErrMsg,
  1763. })
  1764. return
  1765. } else {
  1766. c.ServeSuccessJSON(map[string]interface{}{
  1767. "info": result3265.Output,
  1768. })
  1769. return
  1770. }
  1771. }
  1772. func (c *HisApiController) Get3267() {
  1773. admin_user_id, _ := c.GetInt64("admin_user_id")
  1774. startTime := c.GetString("start_time")
  1775. //endTime, _ := c.GetString("end_time")
  1776. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1777. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1778. times := strings.Split(startTime, "-")
  1779. setl_mon := times[0] + times[1]
  1780. var upld_btch string
  1781. //var empty models.JSResultEmpty
  1782. var result3265 models.JSResult3264
  1783. upld_btch = "0"
  1784. data := make(map[string]interface{})
  1785. data["org_name"] = miConfig.OrgName
  1786. data["doctor"] = curRoles.UserName
  1787. data["doctor_name"] = curRoles.UserName
  1788. data["fixmedins_code"] = miConfig.Code
  1789. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1790. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1791. data["secret_key"] = miConfig.SecretKey
  1792. data["url"] = miConfig.Url
  1793. data["ak"] = miConfig.AccessKey
  1794. data["cainfo"] = miConfig.Cainfo
  1795. data["setl_mon"] = setl_mon
  1796. data["stmt_loc"] = "2"
  1797. data["upld_btch"] = upld_btch
  1798. client := &http.Client{}
  1799. bytesData, _ := json.Marshal(data)
  1800. var req *http.Request
  1801. if miConfig.MdtrtareaAdmvs == "320921" {
  1802. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1803. } else {
  1804. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1805. }
  1806. resp, _ := client.Do(req)
  1807. defer resp.Body.Close()
  1808. body, ioErr := ioutil.ReadAll(resp.Body)
  1809. if ioErr != nil {
  1810. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1812. }
  1813. var respJSON map[string]interface{}
  1814. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1817. }
  1818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1819. fmt.Println(respJSON)
  1820. result, _ := json.Marshal(respJSON)
  1821. fmt.Println(result)
  1822. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1823. utils.ErrorLog("解析失败:%v", err)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. }
  1826. if result3265.Infcode != "0" {
  1827. c.ServeSuccessJSON(map[string]interface{}{
  1828. "failed_code": -10,
  1829. "msg": result3265.ErrMsg,
  1830. })
  1831. return
  1832. } else {
  1833. c.ServeSuccessJSON(map[string]interface{}{
  1834. "info": result3265.Output.Data,
  1835. })
  1836. return
  1837. }
  1838. }
  1839. func (c *HisApiController) Get3268() {
  1840. admin_user_id, _ := c.GetInt64("admin_user_id")
  1841. startTime := c.GetString("start_time")
  1842. endTime := c.GetString("end_time")
  1843. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. times := strings.Split(startTime, "-")
  1846. setl_mon := times[0] + times[1]
  1847. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1848. var twos []models.FixMonRecDetailFileInTwo
  1849. var funs []models.FundDetail
  1850. for _, item := range datas {
  1851. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1852. funs = append(funs, fun...)
  1853. }
  1854. var funInfos []models.Fund
  1855. //for _, item := range funs {
  1856. // var rf []models.FundInfo
  1857. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1858. // for _, subitem := range rf {
  1859. // var fund models.Fund
  1860. // fund.FundCode = subitem.FundPayType
  1861. // fund.FundName = subitem.FundPayTypeName
  1862. // fund.FundAmt = subitem.FundPayAmt
  1863. // fund.FundKey = item.FundKey
  1864. // fund.InsuAdmdvs = "555555"
  1865. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1866. // funInfos = append(funInfos, fund)
  1867. // }
  1868. //}
  1869. for _, team := range datas {
  1870. var two models.FixMonRecDetailFileInTwo
  1871. two.SetlDate = time.Now().Format("2006-01-02")
  1872. two.MedType = team.MedType
  1873. two.Insutype = team.Insutype
  1874. two.PsnType = team.PsnType
  1875. two.MedType = team.MedType
  1876. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1877. two.InsuAdmdvs = team.InsuAdmdvs
  1878. two.PsnTime = team.PsnTime
  1879. two.PsnCnt = team.PsnCnt
  1880. two.FundKey = team.FundKey
  1881. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1882. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1883. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1884. two.MedfeeSumAmt = ms
  1885. two.InscpAmt = ia
  1886. two.FundPaySumAmt = fps
  1887. twos = append(twos, two)
  1888. }
  1889. var upld_btch string
  1890. upld_btch = "0"
  1891. var empty models.JSResultEmpty
  1892. data := make(map[string]interface{})
  1893. data["org_name"] = miConfig.OrgName
  1894. data["doctor"] = curRoles.UserName
  1895. data["doctor_name"] = curRoles.UserName
  1896. data["fixmedins_code"] = miConfig.Code
  1897. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1898. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1899. data["secret_key"] = miConfig.SecretKey
  1900. data["url"] = miConfig.Url
  1901. data["ak"] = miConfig.AccessKey
  1902. data["cainfo"] = miConfig.Cainfo
  1903. data["datas"] = twos
  1904. data["fund"] = funInfos
  1905. data["setl_mon"] = setl_mon
  1906. month := time.Unix(1557042972, 0).Format("1")
  1907. year := time.Now().Format("2006")
  1908. month = time.Now().Format("01")
  1909. day := time.Now().Format("02")
  1910. hour := time.Now().Format("15")
  1911. min := time.Now().Format("04")
  1912. sec := time.Now().Format("05")
  1913. fix_fill_date := year + month + day + hour + min + sec
  1914. data["fix_fill_dept"] = miConfig.OrgName
  1915. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1916. data["fix_fill_psn"] = curRoles.UserName
  1917. data["fix_fill_date"] = fix_fill_date
  1918. data["stmt_loc"] = "2"
  1919. data["upld_btch"] = upld_btch
  1920. client := &http.Client{}
  1921. bytesData, _ := json.Marshal(data)
  1922. var req *http.Request
  1923. if miConfig.MdtrtareaAdmvs == "320921" {
  1924. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1925. } else {
  1926. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1927. }
  1928. resp, _ := client.Do(req)
  1929. defer resp.Body.Close()
  1930. body, ioErr := ioutil.ReadAll(resp.Body)
  1931. if ioErr != nil {
  1932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1934. }
  1935. var respJSON map[string]interface{}
  1936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1939. }
  1940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1941. fmt.Println(respJSON)
  1942. result, _ := json.Marshal(respJSON)
  1943. fmt.Println(result)
  1944. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1945. utils.ErrorLog("解析失败:%v", err)
  1946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1947. }
  1948. if empty.Infcode != "0" {
  1949. c.ServeSuccessJSON(map[string]interface{}{
  1950. "failed_code": -10,
  1951. "msg": empty.ErrMsg,
  1952. })
  1953. return
  1954. } else {
  1955. c.ServeSuccessJSON(map[string]interface{}{
  1956. "msg": "上传成功",
  1957. })
  1958. return
  1959. }
  1960. }
  1961. func (c *HisApiController) Get3269() {
  1962. admin_user_id, _ := c.GetInt64("admin_user_id")
  1963. startTime := c.GetString("start_time")
  1964. //endTime, _ := c.GetString("end_time")
  1965. times := strings.Split(startTime, "-")
  1966. setl_mon := times[0] + times[1]
  1967. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1969. var result3263 models.JSResult3263
  1970. data := make(map[string]interface{})
  1971. data["org_name"] = miConfig.OrgName
  1972. data["doctor"] = curRoles.UserName
  1973. data["doctor_name"] = curRoles.UserName
  1974. data["fixmedins_code"] = miConfig.Code
  1975. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1976. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1977. data["secret_key"] = miConfig.SecretKey
  1978. data["url"] = miConfig.Url
  1979. data["ak"] = miConfig.AccessKey
  1980. data["cainfo"] = miConfig.Cainfo
  1981. data["setl_mon"] = setl_mon
  1982. data["stmt_loc"] = "2"
  1983. client := &http.Client{}
  1984. bytesData, _ := json.Marshal(data)
  1985. var req *http.Request
  1986. if miConfig.MdtrtareaAdmvs == "320921" {
  1987. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1988. } else {
  1989. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1990. }
  1991. resp, _ := client.Do(req)
  1992. defer resp.Body.Close()
  1993. body, ioErr := ioutil.ReadAll(resp.Body)
  1994. if ioErr != nil {
  1995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1997. }
  1998. var respJSON map[string]interface{}
  1999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2002. }
  2003. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2004. fmt.Println(respJSON)
  2005. result, _ := json.Marshal(respJSON)
  2006. fmt.Println(result)
  2007. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2008. utils.ErrorLog("解析失败:%v", err)
  2009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2010. }
  2011. if result3263.Infcode != "0" {
  2012. c.ServeSuccessJSON(map[string]interface{}{
  2013. "failed_code": -10,
  2014. "msg": result3263.ErrMsg,
  2015. })
  2016. return
  2017. } else {
  2018. c.ServeSuccessJSON(map[string]interface{}{
  2019. "msg": "上传成功",
  2020. })
  2021. return
  2022. }
  2023. }
  2024. func (c *HisApiController) Get3270() {
  2025. admin_user_id, _ := c.GetInt64("admin_user_id")
  2026. startTime := c.GetString("start_time")
  2027. //endTime, _ := c.GetString("end_time")
  2028. times := strings.Split(startTime, "-")
  2029. setl_mon := times[0] + times[1]
  2030. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2032. var result3263 models.JSResult3263
  2033. data2 := make(map[string]interface{})
  2034. data2["org_name"] = miConfig.OrgName
  2035. data2["doctor"] = curRoles.UserName
  2036. data2["doctor_name"] = curRoles.UserName
  2037. data2["fixmedins_code"] = miConfig.Code
  2038. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2039. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2040. data2["secret_key"] = miConfig.SecretKey
  2041. data2["url"] = miConfig.Url
  2042. data2["ak"] = miConfig.AccessKey
  2043. data2["cainfo"] = miConfig.Cainfo
  2044. data2["setl_mon"] = setl_mon
  2045. data2["stmt_loc"] = "2"
  2046. client2 := &http.Client{}
  2047. bytesData2, _ := json.Marshal(data2)
  2048. var req3263 *http.Request
  2049. if miConfig.MdtrtareaAdmvs == "320921" {
  2050. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2051. } else {
  2052. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2053. }
  2054. resp2, _ := client2.Do(req3263)
  2055. defer resp2.Body.Close()
  2056. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2057. if ioErr2 != nil {
  2058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2060. }
  2061. var respJSON3263 map[string]interface{}
  2062. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. }
  2066. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2067. fmt.Println(respJSON3263)
  2068. result2, _ := json.Marshal(respJSON3263)
  2069. fmt.Println(result2)
  2070. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2071. utils.ErrorLog("解析失败:%v", err)
  2072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2073. }
  2074. var ids []string
  2075. for _, item := range result3263.Output {
  2076. ids = append(ids, item.SolidifyID)
  2077. }
  2078. var result3264 models.JSResult3264
  2079. data := make(map[string]interface{})
  2080. data["org_name"] = miConfig.OrgName
  2081. data["doctor"] = curRoles.UserName
  2082. data["doctor_name"] = curRoles.UserName
  2083. data["fixmedins_code"] = miConfig.Code
  2084. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2085. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2086. data["secret_key"] = miConfig.SecretKey
  2087. data["url"] = miConfig.Url
  2088. data["ak"] = miConfig.AccessKey
  2089. data["cainfo"] = miConfig.Cainfo
  2090. data["setl_mon"] = setl_mon
  2091. data["stmt_loc"] = "2"
  2092. data["solidify_id"] = ids
  2093. client := &http.Client{}
  2094. bytesData, _ := json.Marshal(data)
  2095. var req *http.Request
  2096. if miConfig.MdtrtareaAdmvs == "320921" {
  2097. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2098. } else {
  2099. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2100. }
  2101. resp, _ := client.Do(req)
  2102. defer resp.Body.Close()
  2103. body, ioErr := ioutil.ReadAll(resp.Body)
  2104. if ioErr != nil {
  2105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2107. }
  2108. var respJSON map[string]interface{}
  2109. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2112. }
  2113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2114. fmt.Println(respJSON)
  2115. result, _ := json.Marshal(respJSON)
  2116. fmt.Println(result)
  2117. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2118. utils.ErrorLog("解析失败:%v", err)
  2119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2120. }
  2121. if result3264.Infcode != "0" {
  2122. c.ServeSuccessJSON(map[string]interface{}{
  2123. "failed_code": -10,
  2124. "msg": result3264.ErrMsg,
  2125. })
  2126. return
  2127. } else {
  2128. c.ServeSuccessJSON(map[string]interface{}{
  2129. "info": result3264.Output,
  2130. })
  2131. return
  2132. }
  2133. }
  2134. func (c *HisApiController) Get3271() {
  2135. admin_user_id, _ := c.GetInt64("admin_user_id")
  2136. startTime := c.GetString("start_time")
  2137. //endTime, _ := c.GetString("end_time")
  2138. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2139. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2140. times := strings.Split(startTime, "-")
  2141. setl_mon := times[0] + times[1]
  2142. //var empty models.JSResultEmpty
  2143. var result3265 models.JSResult3264
  2144. var result3263 models.JSResult3263
  2145. data2 := make(map[string]interface{})
  2146. data2["org_name"] = miConfig.OrgName
  2147. data2["doctor"] = curRoles.UserName
  2148. data2["doctor_name"] = curRoles.UserName
  2149. data2["fixmedins_code"] = miConfig.Code
  2150. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2151. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2152. data2["secret_key"] = miConfig.SecretKey
  2153. data2["url"] = miConfig.Url
  2154. data2["ak"] = miConfig.AccessKey
  2155. data2["cainfo"] = miConfig.Cainfo
  2156. data2["setl_mon"] = setl_mon
  2157. data2["stmt_loc"] = "2"
  2158. client2 := &http.Client{}
  2159. bytesData2, _ := json.Marshal(data2)
  2160. var req3263 *http.Request
  2161. if miConfig.MdtrtareaAdmvs == "320921" {
  2162. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2163. } else {
  2164. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2165. }
  2166. resp2, _ := client2.Do(req3263)
  2167. defer resp2.Body.Close()
  2168. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2169. if ioErr2 != nil {
  2170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2172. }
  2173. var respJSON3263 map[string]interface{}
  2174. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2177. }
  2178. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2179. fmt.Println(respJSON3263)
  2180. result2, _ := json.Marshal(respJSON3263)
  2181. fmt.Println(result2)
  2182. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2183. utils.ErrorLog("解析失败:%v", err)
  2184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2185. }
  2186. var ids []string
  2187. for _, item := range result3263.Output {
  2188. ids = append(ids, item.SolidifyID)
  2189. }
  2190. data := make(map[string]interface{})
  2191. data["org_name"] = miConfig.OrgName
  2192. data["doctor"] = curRoles.UserName
  2193. data["doctor_name"] = curRoles.UserName
  2194. data["fixmedins_code"] = miConfig.Code
  2195. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2196. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2197. data["secret_key"] = miConfig.SecretKey
  2198. data["url"] = miConfig.Url
  2199. data["ak"] = miConfig.AccessKey
  2200. data["cainfo"] = miConfig.Cainfo
  2201. data["setl_mon"] = setl_mon
  2202. data["solidify_id"] = ids
  2203. month := time.Unix(1557042972, 0).Format("1")
  2204. year := time.Now().Format("2006")
  2205. month = time.Now().Format("01")
  2206. day := time.Now().Format("02")
  2207. hour := time.Now().Format("15")
  2208. min := time.Now().Format("04")
  2209. sec := time.Now().Format("05")
  2210. fix_fill_date := year + month + day + hour + min + sec
  2211. data["fix_fill_dept"] = miConfig.OrgName
  2212. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2213. data["fix_fill_psn"] = curRoles.UserName
  2214. data["fix_fill_date"] = fix_fill_date
  2215. data["stmt_loc"] = "2"
  2216. client := &http.Client{}
  2217. bytesData, _ := json.Marshal(data)
  2218. var req *http.Request
  2219. if miConfig.MdtrtareaAdmvs == "320921" {
  2220. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2221. } else {
  2222. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2223. }
  2224. resp, _ := client.Do(req)
  2225. defer resp.Body.Close()
  2226. body, ioErr := ioutil.ReadAll(resp.Body)
  2227. if ioErr != nil {
  2228. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2230. }
  2231. var respJSON map[string]interface{}
  2232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2235. }
  2236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2237. fmt.Println(respJSON)
  2238. result, _ := json.Marshal(respJSON)
  2239. fmt.Println(result)
  2240. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2241. utils.ErrorLog("解析失败:%v", err)
  2242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. }
  2244. if result3265.Infcode != "0" {
  2245. c.ServeSuccessJSON(map[string]interface{}{
  2246. "failed_code": -10,
  2247. "msg": result3265.ErrMsg,
  2248. })
  2249. return
  2250. } else {
  2251. c.ServeSuccessJSON(map[string]interface{}{
  2252. "info": result3265.Output.Data,
  2253. })
  2254. return
  2255. }
  2256. }
  2257. func (c *HisApiController) Get3272() {
  2258. admin_user_id, _ := c.GetInt64("admin_user_id")
  2259. startTime := c.GetString("start_time")
  2260. //endTime, _ := c.GetString("end_time")
  2261. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2263. times := strings.Split(startTime, "-")
  2264. setl_mon := times[0] + times[1]
  2265. var upld_btch string
  2266. //var empty models.JSResultEmpty
  2267. var result3265 models.JSResult3264
  2268. data := make(map[string]interface{})
  2269. data["org_name"] = miConfig.OrgName
  2270. data["doctor"] = curRoles.UserName
  2271. data["doctor_name"] = curRoles.UserName
  2272. data["fixmedins_code"] = miConfig.Code
  2273. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2274. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2275. data["secret_key"] = miConfig.SecretKey
  2276. data["url"] = miConfig.Url
  2277. data["ak"] = miConfig.AccessKey
  2278. data["cainfo"] = miConfig.Cainfo
  2279. data["setl_mon"] = setl_mon
  2280. month := time.Unix(1557042972, 0).Format("1")
  2281. year := time.Now().Format("2006")
  2282. month = time.Now().Format("01")
  2283. day := time.Now().Format("02")
  2284. hour := time.Now().Format("15")
  2285. min := time.Now().Format("04")
  2286. sec := time.Now().Format("05")
  2287. fix_fill_date := year + month + day + hour + min + sec
  2288. data["fix_fill_dept"] = miConfig.OrgName
  2289. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2290. data["fix_fill_psn"] = curRoles.UserName
  2291. data["fix_fill_date"] = fix_fill_date
  2292. data["stmt_loc"] = "2"
  2293. data["upld_btch"] = upld_btch
  2294. client := &http.Client{}
  2295. bytesData, _ := json.Marshal(data)
  2296. var req *http.Request
  2297. if miConfig.MdtrtareaAdmvs == "320921" {
  2298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2299. } else {
  2300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2301. }
  2302. resp, _ := client.Do(req)
  2303. defer resp.Body.Close()
  2304. body, ioErr := ioutil.ReadAll(resp.Body)
  2305. if ioErr != nil {
  2306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2308. }
  2309. var respJSON map[string]interface{}
  2310. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2313. }
  2314. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2315. fmt.Println(respJSON)
  2316. result, _ := json.Marshal(respJSON)
  2317. fmt.Println(result)
  2318. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2319. utils.ErrorLog("解析失败:%v", err)
  2320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2321. }
  2322. if result3265.Infcode != "0" {
  2323. c.ServeSuccessJSON(map[string]interface{}{
  2324. "failed_code": -10,
  2325. "msg": result3265.ErrMsg,
  2326. })
  2327. return
  2328. } else {
  2329. c.ServeSuccessJSON(map[string]interface{}{
  2330. "info": result3265.Output,
  2331. })
  2332. return
  2333. }
  2334. }
  2335. func (c *HisApiController) Get3273() {
  2336. admin_user_id, _ := c.GetInt64("admin_user_id")
  2337. startTime := c.GetString("start_time")
  2338. //endTime, _ := c.GetString("end_time")
  2339. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2340. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2341. times := strings.Split(startTime, "-")
  2342. setl_mon := times[0] + times[1]
  2343. var result3265 models.JSResult3264
  2344. data := make(map[string]interface{})
  2345. data["org_name"] = miConfig.OrgName
  2346. data["doctor"] = curRoles.UserName
  2347. data["doctor_name"] = curRoles.UserName
  2348. data["fixmedins_code"] = miConfig.Code
  2349. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2350. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2351. data["secret_key"] = miConfig.SecretKey
  2352. data["url"] = miConfig.Url
  2353. data["ak"] = miConfig.AccessKey
  2354. data["cainfo"] = miConfig.Cainfo
  2355. data["setl_mon"] = setl_mon
  2356. data["stmt_loc"] = "2"
  2357. client := &http.Client{}
  2358. bytesData, _ := json.Marshal(data)
  2359. var req *http.Request
  2360. if miConfig.MdtrtareaAdmvs == "320921" {
  2361. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2362. } else {
  2363. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2364. }
  2365. resp, _ := client.Do(req)
  2366. defer resp.Body.Close()
  2367. body, ioErr := ioutil.ReadAll(resp.Body)
  2368. if ioErr != nil {
  2369. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2371. }
  2372. var respJSON map[string]interface{}
  2373. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2374. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2376. }
  2377. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2378. fmt.Println(respJSON)
  2379. result, _ := json.Marshal(respJSON)
  2380. fmt.Println(result)
  2381. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2382. utils.ErrorLog("解析失败:%v", err)
  2383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2384. }
  2385. if result3265.Infcode != "0" {
  2386. c.ServeSuccessJSON(map[string]interface{}{
  2387. "failed_code": -10,
  2388. "msg": result3265.ErrMsg,
  2389. })
  2390. return
  2391. } else {
  2392. c.ServeSuccessJSON(map[string]interface{}{
  2393. "info": result3265.Output.Data,
  2394. })
  2395. return
  2396. }
  2397. }
  2398. func (c *HisApiController) Get3274() {
  2399. //if miConfig.MdtrtareaAdmvs == "320921" {
  2400. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2401. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2402. // "&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
  2403. //
  2404. //} else {
  2405. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2406. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2407. // "&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
  2408. //
  2409. //}
  2410. }
  2411. func (c *HisApiController) Get3275() {
  2412. //if miConfig.MdtrtareaAdmvs == "320921" {
  2413. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2414. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2415. // "&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
  2416. //
  2417. //} else {
  2418. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2419. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2420. // "&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
  2421. //
  2422. //}
  2423. }
  2424. func (c *HisApiController) Get3276() {
  2425. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2426. //month := c.GetString("month")
  2427. //
  2428. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2429. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2430. //var api string
  2431. //var res Result5301
  2432. //
  2433. //if miConfig.MdtrtareaAdmvs == "320921" {
  2434. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2435. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2436. //} else {
  2437. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2438. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2439. //}
  2440. //
  2441. //resp, requestErr := http.Get(api)
  2442. //if requestErr != nil {
  2443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2444. // return
  2445. //}
  2446. //
  2447. //body, ioErr := ioutil.ReadAll(resp.Body)
  2448. //if ioErr != nil {
  2449. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2451. // return
  2452. //}
  2453. //var respJSON map[string]interface{}
  2454. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2455. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2457. // return
  2458. //}
  2459. //
  2460. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2461. //result, _ := json.Marshal(respJSON)
  2462. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2463. // utils.ErrorLog("解析失败:%v", err)
  2464. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2465. // return
  2466. //}
  2467. }
  2468. func (c *HisApiController) Get3277() {
  2469. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2470. //month := c.GetString("month")
  2471. //
  2472. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2473. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2474. //var api string
  2475. //var res Result5301
  2476. //
  2477. //if miConfig.MdtrtareaAdmvs == "320921" {
  2478. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2479. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2480. //} else {
  2481. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2482. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2483. //}
  2484. //
  2485. //resp, requestErr := http.Get(api)
  2486. //if requestErr != nil {
  2487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2488. // return
  2489. //}
  2490. //
  2491. //body, ioErr := ioutil.ReadAll(resp.Body)
  2492. //if ioErr != nil {
  2493. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2495. // return
  2496. //}
  2497. //var respJSON map[string]interface{}
  2498. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2499. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2501. // return
  2502. //}
  2503. //
  2504. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2505. //result, _ := json.Marshal(respJSON)
  2506. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2507. // utils.ErrorLog("解析失败:%v", err)
  2508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2509. // return
  2510. //}
  2511. }
  2512. func (c *HisApiController) GetCFYLJG001() {
  2513. admin_user_id, _ := c.GetInt64("admin_user_id")
  2514. patient_id, _ := c.GetInt64("patient_id")
  2515. his_patient_id, _ := c.GetInt64("his_patient_id")
  2516. record_time := c.GetString("record_time")
  2517. admin_user_id = 3626
  2518. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2519. psn, _ := service.GetPsnByPatientId(patient_id)
  2520. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2522. var cFYLJG001 models.CFYLJG001
  2523. timeLayout := "2006-01-02"
  2524. loc, _ := time.LoadLocation("Local")
  2525. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2526. if err != nil {
  2527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2528. return
  2529. }
  2530. recordDateTime := theTime.Unix()
  2531. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2532. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2533. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2534. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2535. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2536. for _, item := range prescriptions {
  2537. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2538. if his.IdCardType == 1 {
  2539. bas := strings.Split(psn.CardInfo, "|")
  2540. basNumber := bas[1]
  2541. fmt.Println(basNumber)
  2542. card_sn := bas[3]
  2543. card_no := bas[2]
  2544. cFYLJG001.MdtrtCertType = "03"
  2545. cFYLJG001.CardSn = card_sn
  2546. cFYLJG001.MdtrtCertNo = card_no
  2547. cFYLJG001.EcToken = ""
  2548. cFYLJG001.AuthNo = ""
  2549. } else if his.IdCardType == 2 {
  2550. cFYLJG001.MdtrtCertType = "02"
  2551. cFYLJG001.CardSn = ""
  2552. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2553. cFYLJG001.EcToken = ""
  2554. cFYLJG001.AuthNo = ""
  2555. } else if his.IdCardType == 4 {
  2556. cFYLJG001.MdtrtCertType = "01"
  2557. cFYLJG001.CardSn = ""
  2558. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2559. cFYLJG001.EcToken = psn.VerifyNumber
  2560. cFYLJG001.AuthNo = ""
  2561. }
  2562. cFYLJG001.BizTypeCode = "01"
  2563. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2564. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2565. cFYLJG001.RxTypeCode = "1"
  2566. tempTime := time.Unix(item.PreTime, 0)
  2567. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2568. cFYLJG001.PrscTime = timeFormatOne
  2569. var count float64
  2570. if item.Type == 1 {
  2571. for _, sumItem := range item.HisDoctorAdviceInfo {
  2572. count = count + sumItem.PrescribingNumber
  2573. }
  2574. }
  2575. cFYLJG001.RxDrugCnt = count
  2576. cFYLJG001.ValiDays = "5"
  2577. ts := time.Unix(item.PreTime, 0)
  2578. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2579. tempTime3 := time.Unix(record_time2, 0)
  2580. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2581. cFYLJG001.ValiEndTime = timeFormat3
  2582. cFYLJG001.RxCotnFlag = "0"
  2583. for _, subItem := range item.HisDoctorAdviceInfo {
  2584. var drug models.RxDrug
  2585. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2586. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2587. drug.RxItemTypeCode = "11"
  2588. drug.DrugDosform = "乳膏剂" //TODO
  2589. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2590. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2591. }
  2592. drug.MedcWayDscr = subItem.DeliveryWay
  2593. tempTime2 := time.Unix(subItem.StartTime, 0)
  2594. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2595. drug.MedcBegntime = timeFormatTwo
  2596. if subItem.Day > 0 {
  2597. ts := time.Unix(subItem.StartTime, 0)
  2598. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2599. tempTime4 := time.Unix(record_time, 0)
  2600. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2601. drug.MedcEndtime = timeFormat5
  2602. } else {
  2603. tempTime2 := time.Unix(subItem.StartTime, 0)
  2604. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2605. drug.MedcEndtime = timeFormatTwo
  2606. }
  2607. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2608. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2609. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2610. drug.DrugCnt = subItem.PrescribingNumber
  2611. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2612. drug.DrugGenname = subItem.AdviceName
  2613. drug.MedcWayCodg = subItem.DeliveryWay
  2614. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2615. drug.SinDoscnt = subItem.SingleDose
  2616. drug.SinDosunt = subItem.SingleDoseUnit
  2617. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2618. drug.UsedFrquName = subItem.ExecutionFrequency
  2619. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2620. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2621. drug.HospApprFlag = "1"
  2622. cFYLJG001.List = append(cFYLJG001.List, drug)
  2623. }
  2624. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2625. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2626. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2627. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2628. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2629. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2630. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2631. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2632. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2633. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2634. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2635. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2636. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2637. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2638. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2639. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2640. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2641. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2642. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2643. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2644. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2645. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2646. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2647. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2648. tempTime2 := time.Now().Unix()
  2649. tempTime6 := time.Unix(tempTime2, 0)
  2650. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2651. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2652. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2653. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2654. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2655. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2656. //memo := make(map[string]interface{})
  2657. //inputData := make(map[string]interface{}, 0)
  2658. //type MyData struct {
  2659. // Insutype string `json:"insutype"`
  2660. //}
  2661. //
  2662. // data := MyData{
  2663. // Insutype: his.Insutype,
  2664. //}
  2665. //
  2666. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2667. var config []*models.HisXtDiagnoseConfig
  2668. for _, item := range diagnosis_ids {
  2669. id, _ := strconv.ParseInt(item, 10, 64)
  2670. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2671. config = append(config, &diagnosisConfig)
  2672. }
  2673. for index, subitem := range config {
  2674. if index == 0 {
  2675. var dia models.DiseInfo
  2676. dia.DiagType = "1"
  2677. dia.MaindiagFlag = "1"
  2678. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2679. dia.DiagCode = subitem.CountryCode
  2680. dia.DiagName = subitem.ClassName
  2681. dia.DiagDept = "肾内科"
  2682. dia.DiagDrNo = doctor.DoctorNumber
  2683. dia.DiagDrName = doctor.UserName
  2684. tempTime3 := time.Unix(item.PreTime, 0)
  2685. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2686. dia.DiagTime = timeFormatTwo
  2687. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2688. } else {
  2689. var dia models.DiseInfo
  2690. dia.DiagType = "1"
  2691. dia.MaindiagFlag = "0"
  2692. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2693. dia.DiagCode = subitem.CountryCode
  2694. dia.DiagName = subitem.ClassName
  2695. dia.DiagDept = "肾内科"
  2696. dia.DiagDrNo = doctor.DoctorNumber
  2697. dia.DiagDrName = doctor.UserName
  2698. tempTime3 := time.Unix(item.PreTime, 0)
  2699. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2700. dia.DiagTime = timeFormatTwo
  2701. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2702. }
  2703. }
  2704. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2705. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2706. var res ResultCFYLJG001
  2707. var respJSON2 map[string]interface{}
  2708. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2711. return
  2712. }
  2713. userJSONBytes2, _ := json.Marshal(respJSON2)
  2714. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2715. utils.ErrorLog("解析失败:%v", err)
  2716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2717. return
  2718. }
  2719. if res.Infcode == -1 {
  2720. c.ServeSuccessJSON(map[string]interface{}{
  2721. "failed_code": -10,
  2722. "msg": res.ErrMsg,
  2723. })
  2724. return
  2725. } else {
  2726. var flow models.HisPrescriptionFlow
  2727. flow.Ctime = time.Now().Unix()
  2728. flow.SignDigest = ""
  2729. flow.RxTraceCode = res.Output.RxTraceCode
  2730. flow.HiRxno = res.Output.HiRxno
  2731. flow.MID = his.Number
  2732. flow.Status = 1
  2733. flow.DCode = doctor_info.DoctorNumber
  2734. flow.OriginalRxFile = ""
  2735. flow.OriginalValue = ""
  2736. flow.SignCertDn = ""
  2737. flow.UserOrgId = 10454
  2738. flow.SignCertSn = ""
  2739. flow.Mtime = time.Now().Unix()
  2740. service.Createflow(&flow)
  2741. c.ServeSuccessJSON(map[string]interface{}{
  2742. "msg": "上传成功",
  2743. })
  2744. }
  2745. }
  2746. }
  2747. func (c *HisApiController) GetCFYLJG002() {
  2748. admin_user_id, _ := c.GetInt64("admin_user_id")
  2749. his_patient_id, _ := c.GetInt64("his_patient_id")
  2750. record_time := c.GetString("record_time")
  2751. admin_user_id = 3626
  2752. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2753. //id, _ := c.GetInt64("id")
  2754. admin_user_id = 3626
  2755. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2756. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2757. flow, _ := service.Getflowtwo(his.Number)
  2758. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2759. //record_time := c.GetString("record_time")
  2760. patient_id, _ := c.GetInt64("patient_id")
  2761. //patient_id = 23834
  2762. //record_time = "2023-09-18"
  2763. timeLayout := "2006-01-02"
  2764. loc, _ := time.LoadLocation("Local")
  2765. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2766. if err != nil {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2768. return
  2769. }
  2770. recordDateTime := theTime.Unix()
  2771. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2772. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2773. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2774. dept, _ := service.GetDepartMentDetail(info.Departments)
  2775. inputData := make(map[string]interface{})
  2776. inputData["rxTraceCode"] = flow.RxTraceCode
  2777. inputData["hiRxno"] = flow.HiRxno
  2778. inputData["mdtrtId"] = flow.MID
  2779. inputData["patnName"] = his.PsnName
  2780. inputData["psnCertType"] = his.PsnCertType
  2781. inputData["certno"] = his.Certno
  2782. inputData["fixmedinsName"] = miConfig.OrgName
  2783. inputData["fixmedinsCode"] = miConfig.Code
  2784. inputData["drCode"] = doctor_info.DoctorNumber
  2785. inputData["prscDrName"] = doctor_info.UserName
  2786. inputData["pharDeptName"] = dept.Name
  2787. inputData["pharDeptCode"] = dept.Number
  2788. inputData["pharProfttlCodg"] = dept.Name
  2789. inputData["pharProfttlName"] = ""
  2790. inputData["pharCode"] = "HY440309002107"
  2791. inputData["pharCertType"] = "01"
  2792. inputData["pharCertno"] = "430482199408260023"
  2793. inputData["pharName"] = "彭斯遥"
  2794. inputData["pharPracCertNo"] = ""
  2795. tempTime2 := time.Unix(info.Ctime, 0)
  2796. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2797. inputData["pharChkTime"] = timeFormatTwo
  2798. bytesData, _ := json.Marshal(inputData)
  2799. fmt.Println(string(bytesData))
  2800. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2801. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2802. if err != nil {
  2803. fmt.Println("Error reading PDF file:", err)
  2804. return
  2805. }
  2806. // 将 PDF 文件内容进行 Base64 编码
  2807. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2808. fmt.Println(err)
  2809. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2810. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2811. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2812. var res2 Result002
  2813. var respJSON2 map[string]interface{}
  2814. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2817. return
  2818. }
  2819. userJSONBytes2, _ := json.Marshal(respJSON2)
  2820. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2821. utils.ErrorLog("解析失败:%v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. if res2.Infcode == 0 {
  2826. flow.Ctime = time.Now().Unix()
  2827. flow.SignDigest = res2.Output.SignDigest
  2828. flow.RxFile = res2.Output.RxFile
  2829. flow.MID = his.Number
  2830. flow.Status = 1
  2831. flow.DCode = doctor_info.DoctorNumber
  2832. flow.OriginalRxFile = rx_encoded
  2833. flow.OriginalValue = encoded
  2834. flow.SignCertDn = res2.Output.SignCertDn
  2835. flow.SignCertSn = res2.Output.SignCertSn
  2836. flow.Mtime = time.Now().Unix()
  2837. service.Saveflow(flow)
  2838. c.ServeSuccessJSON(map[string]interface{}{
  2839. "msg": "预签名成功",
  2840. })
  2841. } else {
  2842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2843. return
  2844. }
  2845. }
  2846. func (c *HisApiController) GetCFYLJG003() {
  2847. admin_user_id, _ := c.GetInt64("admin_user_id")
  2848. his_patient_id, _ := c.GetInt64("his_patient_id")
  2849. record_time := c.GetString("record_time")
  2850. admin_user_id = 3626
  2851. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2852. //id, _ := c.GetInt64("id")
  2853. admin_user_id = 3626
  2854. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2855. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2856. flow, _ := service.Getflowtwo(his.Number)
  2857. //id = 3
  2858. patient_id, _ := c.GetInt64("patient_id")
  2859. //patient_id = 23834
  2860. //record_time = "2023-09-18"
  2861. timeLayout := "2006-01-02"
  2862. loc, _ := time.LoadLocation("Local")
  2863. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2864. if err != nil {
  2865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2866. return
  2867. }
  2868. recordDateTime := theTime.Unix()
  2869. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2870. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2871. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2872. dept, _ := service.GetDepartMentDetail(info.Departments)
  2873. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2874. var cFYLJG003 models.CFYLJG003
  2875. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2876. cFYLJG003.HiRxno = flow.HiRxno
  2877. cFYLJG003.MdtrtID = flow.MID
  2878. cFYLJG003.PatnName = his.Name
  2879. cFYLJG003.Certno = his.Certno
  2880. cFYLJG003.FixmedinsName = miConfig.OrgName
  2881. cFYLJG003.FixmedinsCode = miConfig.Code
  2882. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2883. cFYLJG003.PrscDrName = doctor_info.UserName
  2884. cFYLJG003.PharDeptName = dept.Name
  2885. cFYLJG003.PharDeptCode = dept.Number
  2886. cFYLJG003.PharCode = "HY440309002107"
  2887. cFYLJG003.PharCertType = "01"
  2888. cFYLJG003.PharCertno = "430482199408260023"
  2889. cFYLJG003.PharName = "彭斯遥"
  2890. cFYLJG003.PsnCertType = "01"
  2891. cFYLJG003.RxFile = flow.RxFile
  2892. cFYLJG003.SignDigest = flow.SignDigest
  2893. cFYLJG003.FixmedinsCode = miConfig.Code
  2894. cFYLJG003.PsnCertType = "01"
  2895. cFYLJG003.PharProfttlCodg = dept.Name
  2896. //inputData["pharProfttlCodg"] =dept.Name
  2897. tempTime2 := time.Unix(info.Ctime, 0)
  2898. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2899. cFYLJG003.PharChkTime = timeFormatTwo
  2900. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2901. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2902. var res ResultCFYLJG003
  2903. var respJSON2 map[string]interface{}
  2904. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2907. return
  2908. }
  2909. userJSONBytes2, _ := json.Marshal(respJSON2)
  2910. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2911. utils.ErrorLog("解析失败:%v", err)
  2912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2913. return
  2914. }
  2915. if res.Infcode == -1 {
  2916. c.ServeSuccessJSON(map[string]interface{}{
  2917. "failed_code": -10,
  2918. "msg": res.ErrMsg,
  2919. })
  2920. return
  2921. } else {
  2922. c.ServeSuccessJSON(map[string]interface{}{
  2923. "info": res.Output,
  2924. })
  2925. }
  2926. }
  2927. func (c *HisApiController) GetCFYLJG004() {
  2928. admin_user_id, _ := c.GetInt64("admin_user_id")
  2929. his_patient_id, _ := c.GetInt64("his_patient_id")
  2930. record_time := c.GetString("record_time")
  2931. admin_user_id = 3626
  2932. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2933. //id, _ := c.GetInt64("id")
  2934. admin_user_id = 3626
  2935. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2936. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2937. flow, _ := service.Getflowtwo(his.Number)
  2938. //id = 3
  2939. patient_id, _ := c.GetInt64("patient_id")
  2940. //patient_id = 23834
  2941. //record_time = "2023-09-18"
  2942. timeLayout := "2006-01-02"
  2943. loc, _ := time.LoadLocation("Local")
  2944. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2945. if err != nil {
  2946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2947. return
  2948. }
  2949. recordDateTime := theTime.Unix()
  2950. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2951. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2952. var cFYLJG004 models.CFYLJG004
  2953. cFYLJG004.HiRxno = flow.HiRxno
  2954. cFYLJG004.FixmedinsCode = miConfig.Code
  2955. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2956. cFYLJG004.UndoDrCertType = "01"
  2957. cFYLJG004.UndoRea = "撤销处方"
  2958. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2959. cFYLJG004.UndoDrName = doctor_info.UserName
  2960. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2961. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2962. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2963. var res ResultCFYLJG004
  2964. var respJSON2 map[string]interface{}
  2965. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2966. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2968. return
  2969. }
  2970. userJSONBytes2, _ := json.Marshal(respJSON2)
  2971. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2972. utils.ErrorLog("解析失败:%v", err)
  2973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2974. return
  2975. }
  2976. if res.Infcode == -1 {
  2977. c.ServeSuccessJSON(map[string]interface{}{
  2978. "failed_code": -10,
  2979. "msg": res.ErrMsg,
  2980. })
  2981. return
  2982. } else {
  2983. flow.Status = 0
  2984. service.Saveflow(flow)
  2985. c.ServeSuccessJSON(map[string]interface{}{
  2986. "msg": "撤销成功",
  2987. })
  2988. return
  2989. }
  2990. }
  2991. func (c *HisApiController) GetCFYLJG005() {
  2992. admin_user_id, _ := c.GetInt64("admin_user_id")
  2993. his_patient_id, _ := c.GetInt64("his_patient_id")
  2994. //record_time := c.GetString("record_time")
  2995. admin_user_id = 3626
  2996. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2997. //id, _ := c.GetInt64("id")
  2998. admin_user_id = 3626
  2999. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3000. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3001. flow, _ := service.Getflowtwo(his.Number)
  3002. //id = 3
  3003. var cFYLJG005 models.CFYLJG005
  3004. //patient_id, _ := c.GetInt64("patient_id")
  3005. cFYLJG005.HiRxno = flow.HiRxno
  3006. cFYLJG005.MdtrtID = flow.MID
  3007. cFYLJG005.EcToken = ""
  3008. cFYLJG005.PsnName = his.Name
  3009. cFYLJG005.PsnCertType = "01"
  3010. cFYLJG005.Certno = his.IdCardNo
  3011. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3012. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3013. var res ResultCFYLJG005
  3014. var respJSON2 map[string]interface{}
  3015. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3016. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3018. return
  3019. }
  3020. userJSONBytes2, _ := json.Marshal(respJSON2)
  3021. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3022. utils.ErrorLog("解析失败:%v", err)
  3023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3024. return
  3025. }
  3026. if res.Infcode == -1 {
  3027. c.ServeSuccessJSON(map[string]interface{}{
  3028. "failed_code": -10,
  3029. "msg": res.ErrMsg,
  3030. })
  3031. return
  3032. } else {
  3033. c.ServeSuccessJSON(map[string]interface{}{
  3034. "info": res.Output,
  3035. })
  3036. return
  3037. }
  3038. }
  3039. func (c *HisApiController) GetCFYLJG006() {
  3040. admin_user_id, _ := c.GetInt64("admin_user_id")
  3041. his_patient_id, _ := c.GetInt64("his_patient_id")
  3042. admin_user_id = 3626
  3043. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3044. //id, _ := c.GetInt64("id")
  3045. admin_user_id = 3626
  3046. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3047. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3048. flow, _ := service.Getflowtwo(his.Number)
  3049. //id = 3
  3050. patient_id, _ := c.GetInt64("patient_id")
  3051. var cFYLJG006 models.CFYLJG006
  3052. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3053. cFYLJG006.HiRxno = flow.HiRxno
  3054. cFYLJG006.MdtrtID = flow.MID
  3055. cFYLJG006.PsnName = patient.Name
  3056. cFYLJG006.PsnCertType = "01"
  3057. cFYLJG006.Certno = patient.IdCardNo
  3058. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3059. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3060. var res ResultCFYLJG006
  3061. var respJSON2 map[string]interface{}
  3062. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3065. return
  3066. }
  3067. userJSONBytes2, _ := json.Marshal(respJSON2)
  3068. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3069. utils.ErrorLog("解析失败:%v", err)
  3070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3071. return
  3072. }
  3073. if res.Infcode == -1 {
  3074. c.ServeSuccessJSON(map[string]interface{}{
  3075. "failed_code": -10,
  3076. "msg": res.ErrMsg,
  3077. })
  3078. return
  3079. } else {
  3080. c.ServeSuccessJSON(map[string]interface{}{
  3081. "info": res.Output,
  3082. })
  3083. return
  3084. }
  3085. }
  3086. func (c *HisApiController) GetCFYLJG007() {
  3087. admin_user_id, _ := c.GetInt64("admin_user_id")
  3088. his_patient_id, _ := c.GetInt64("his_patient_id")
  3089. admin_user_id = 3626
  3090. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3091. //id, _ := c.GetInt64("id")
  3092. admin_user_id = 3626
  3093. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3094. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3095. flow, _ := service.Getflowtwo(his.Number)
  3096. //id = 3
  3097. patient_id, _ := c.GetInt64("patient_id")
  3098. var cFYLJG007 models.CFYLJG007
  3099. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3100. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3101. cFYLJG007.HiRxno = flow.HiRxno
  3102. cFYLJG007.MdtrtID = flow.MID
  3103. cFYLJG007.PsnNo = his.PsnNo
  3104. cFYLJG007.PsnCertType = "01"
  3105. cFYLJG007.Certno = patient.IdCardNo
  3106. cFYLJG007.PsnName = patient.Name
  3107. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3108. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3109. var res ResultCFYLJG007
  3110. var respJSON2 map[string]interface{}
  3111. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3112. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3114. return
  3115. }
  3116. userJSONBytes2, _ := json.Marshal(respJSON2)
  3117. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3118. utils.ErrorLog("解析失败:%v", err)
  3119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3120. return
  3121. }
  3122. if res.Infcode == -1 {
  3123. c.ServeSuccessJSON(map[string]interface{}{
  3124. "failed_code": -10,
  3125. "msg": res.ErrMsg,
  3126. })
  3127. return
  3128. } else {
  3129. c.ServeSuccessJSON(map[string]interface{}{
  3130. "info": res,
  3131. })
  3132. return
  3133. }
  3134. }
  3135. func (c *HisApiController) GetCFYLJG008() {
  3136. admin_user_id, _ := c.GetInt64("admin_user_id")
  3137. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3139. var cFYLJG008 models.CFYLJG008
  3140. //id, _ := c.GetInt64("id")
  3141. patient_id, _ := c.GetInt64("patient_id")
  3142. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3143. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3144. //id = 3
  3145. //flow, _ := service.Getflow(id)
  3146. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3147. //
  3148. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3149. //patient_id, _ := c.GetInt64("patient_id")
  3150. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3151. record_time := c.GetString("record_time")
  3152. admin_user_id = 3626
  3153. patient_id = 19424
  3154. //his_patient_id = 263947
  3155. record_time = "2023-08-29"
  3156. timeLayout := "2006-01-02"
  3157. loc, _ := time.LoadLocation("Local")
  3158. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3159. if err != nil {
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3161. return
  3162. }
  3163. recordDateTime := theTime.Unix()
  3164. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3165. cFYLJG008.FixmedinsName = ""
  3166. cFYLJG008.Lat = ""
  3167. cFYLJG008.Lng = ""
  3168. cFYLJG008.OrderType = "1"
  3169. cFYLJG008.PoolareaNo = ""
  3170. cFYLJG008.Lng = ""
  3171. cFYLJG008.PageNum = 1
  3172. cFYLJG008.PageSize = 10
  3173. var MPI models.MedinsProdInvChgDDTO
  3174. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3175. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3176. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3177. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3178. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3179. var res ResultCFYLJG008
  3180. var respJSON2 map[string]interface{}
  3181. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. return
  3185. }
  3186. userJSONBytes2, _ := json.Marshal(respJSON2)
  3187. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3188. utils.ErrorLog("解析失败:%v", err)
  3189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3190. return
  3191. }
  3192. if res.Infcode == -1 {
  3193. c.ServeSuccessJSON(map[string]interface{}{
  3194. "failed_code": -10,
  3195. "msg": res.ErrMsg,
  3196. })
  3197. return
  3198. } else {
  3199. c.ServeSuccessJSON(map[string]interface{}{
  3200. "info": res.Output,
  3201. })
  3202. return
  3203. }
  3204. }
  3205. func (c *HisApiController) GetBL4201A() {
  3206. order_id, _ := c.GetInt64("order_id")
  3207. admin_user_id, _ := c.GetInt64("admin_user_id")
  3208. order, _ := service.GetHisOrderByIDTwo(order_id)
  3209. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3210. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3211. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3212. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3213. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3214. department, _ := service.GetDepartMentDetail(his.Departments)
  3215. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3216. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3217. if order.ID == 0 {
  3218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3219. return
  3220. }
  3221. var struct4201A models.Struct4201A
  3222. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3223. for _, items := range order_info {
  3224. memo := make(map[string]interface{})
  3225. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3226. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3227. fsiOPFLD.MedType = "14"
  3228. fsiOPFLD.BkkpSn = items.FeedetlSn
  3229. fsiOPFLD.FixmedinsCode = miConfig.Code
  3230. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3231. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3232. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3233. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3234. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3235. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3236. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3237. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3238. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3239. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3240. fsiOPFLD.BilgDeptName = department.Name
  3241. fsiOPFLD.BilgDeptCodg = department.Number
  3242. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3243. fsiOPFLD.BilgDrName = doctor.UserName
  3244. fsiOPFLD.MedChrgitmType = "09"
  3245. memo["hosp_appr_flag"] = "1"
  3246. memo["invoice_no"] = order.MdtrtId
  3247. memo["memo"] = "自费"
  3248. bytesData, _ := json.Marshal(memo)
  3249. fsiOPFLD.Memo = string(bytesData)
  3250. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3251. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3252. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3253. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3254. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3255. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3256. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3257. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3258. fsiOPFLD.BilgDeptName = department.Name
  3259. fsiOPFLD.BilgDeptCodg = department.Number
  3260. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3261. fsiOPFLD.BilgDrName = doctor.UserName
  3262. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3263. case 0:
  3264. break
  3265. case 1:
  3266. fsiOPFLD.MedChrgitmType = "14"
  3267. break
  3268. case 2:
  3269. fsiOPFLD.MedChrgitmType = "05"
  3270. break
  3271. case 3:
  3272. fsiOPFLD.MedChrgitmType = "03"
  3273. break
  3274. case 4:
  3275. fsiOPFLD.MedChrgitmType = "03"
  3276. break
  3277. case 5:
  3278. fsiOPFLD.MedChrgitmType = "08"
  3279. break
  3280. case 6:
  3281. fsiOPFLD.MedChrgitmType = "14"
  3282. break
  3283. case 7:
  3284. fsiOPFLD.MedChrgitmType = "14"
  3285. break
  3286. case 8:
  3287. fsiOPFLD.MedChrgitmType = "03"
  3288. break
  3289. case 9:
  3290. fsiOPFLD.MedChrgitmType = "14"
  3291. break
  3292. case 10:
  3293. fsiOPFLD.MedChrgitmType = "14"
  3294. break
  3295. case 11:
  3296. fsiOPFLD.MedChrgitmType = "06"
  3297. break
  3298. case 12:
  3299. fsiOPFLD.MedChrgitmType = "12"
  3300. break
  3301. case 13:
  3302. fsiOPFLD.MedChrgitmType = "01"
  3303. break
  3304. case 14:
  3305. fsiOPFLD.MedChrgitmType = "04"
  3306. break
  3307. case 15:
  3308. fsiOPFLD.MedChrgitmType = "14"
  3309. break
  3310. }
  3311. memo["hosp_appr_flag"] = "1"
  3312. memo["invoice_no"] = order.MdtrtId
  3313. memo["memo"] = "自费"
  3314. bytesData, _ := json.Marshal(memo)
  3315. fsiOPFLD.Memo = string(bytesData)
  3316. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3317. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3318. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3319. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3320. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3321. fsiOPFLD.BilgDeptName = department.Name
  3322. fsiOPFLD.BilgDeptCodg = department.Number
  3323. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3324. fsiOPFLD.BilgDrName = doctor.UserName
  3325. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3326. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3327. fsiOPFLD.MedChrgitmType = "08"
  3328. memo["hosp_appr_flag"] = "1"
  3329. memo["invoice_no"] = order.MdtrtId
  3330. memo["memo"] = "自费"
  3331. bytesData, _ := json.Marshal(memo)
  3332. fsiOPFLD.Memo = string(bytesData)
  3333. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3334. }
  3335. }
  3336. }
  3337. for _, items := range order_info_two {
  3338. memo := make(map[string]interface{})
  3339. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3340. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3341. fsiOPFLD.MedType = "14"
  3342. fsiOPFLD.BkkpSn = items.FeedetlSn
  3343. fsiOPFLD.FixmedinsCode = miConfig.Code
  3344. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3345. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3346. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3347. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3348. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3349. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3350. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3351. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3352. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3353. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3354. fsiOPFLD.BilgDeptName = department.Name
  3355. fsiOPFLD.BilgDeptCodg = department.Number
  3356. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3357. fsiOPFLD.BilgDrName = doctor.UserName
  3358. fsiOPFLD.MedChrgitmType = "09"
  3359. memo["hosp_appr_flag"] = "1"
  3360. memo["invoice_no"] = order.MdtrtId
  3361. memo["memo"] = "自费"
  3362. bytesData, _ := json.Marshal(memo)
  3363. fsiOPFLD.Memo = string(bytesData)
  3364. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3365. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3366. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3367. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3368. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3369. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3370. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3371. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3372. fsiOPFLD.BilgDeptName = department.Name
  3373. fsiOPFLD.BilgDeptCodg = department.Number
  3374. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3375. fsiOPFLD.BilgDrName = doctor.UserName
  3376. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3377. case 0:
  3378. break
  3379. case 1:
  3380. fsiOPFLD.MedChrgitmType = "14"
  3381. break
  3382. case 2:
  3383. fsiOPFLD.MedChrgitmType = "05"
  3384. break
  3385. case 3:
  3386. fsiOPFLD.MedChrgitmType = "03"
  3387. break
  3388. case 4:
  3389. fsiOPFLD.MedChrgitmType = "03"
  3390. break
  3391. case 5:
  3392. fsiOPFLD.MedChrgitmType = "08"
  3393. break
  3394. case 6:
  3395. fsiOPFLD.MedChrgitmType = "14"
  3396. break
  3397. case 7:
  3398. fsiOPFLD.MedChrgitmType = "14"
  3399. break
  3400. case 8:
  3401. fsiOPFLD.MedChrgitmType = "03"
  3402. break
  3403. case 9:
  3404. fsiOPFLD.MedChrgitmType = "14"
  3405. break
  3406. case 10:
  3407. fsiOPFLD.MedChrgitmType = "14"
  3408. break
  3409. case 11:
  3410. fsiOPFLD.MedChrgitmType = "06"
  3411. break
  3412. case 12:
  3413. fsiOPFLD.MedChrgitmType = "12"
  3414. break
  3415. case 13:
  3416. fsiOPFLD.MedChrgitmType = "01"
  3417. break
  3418. case 14:
  3419. fsiOPFLD.MedChrgitmType = "04"
  3420. break
  3421. case 15:
  3422. fsiOPFLD.MedChrgitmType = "14"
  3423. break
  3424. }
  3425. memo["hosp_appr_flag"] = "1"
  3426. memo["invoice_no"] = order.MdtrtId
  3427. memo["memo"] = "自费"
  3428. bytesData, _ := json.Marshal(memo)
  3429. fsiOPFLD.Memo = string(bytesData)
  3430. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3431. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3432. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3433. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3434. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3435. fsiOPFLD.BilgDeptName = department.Name
  3436. fsiOPFLD.BilgDeptCodg = department.Number
  3437. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3438. fsiOPFLD.BilgDrName = doctor.UserName
  3439. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3440. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3441. fsiOPFLD.MedChrgitmType = "08"
  3442. memo["hosp_appr_flag"] = "1"
  3443. memo["invoice_no"] = order.MdtrtId
  3444. memo["memo"] = "自费"
  3445. bytesData, _ := json.Marshal(memo)
  3446. fsiOPFLD.Memo = string(bytesData)
  3447. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3448. }
  3449. }
  3450. }
  3451. fmt.Println(fsiOPFLDs)
  3452. struct4201A.Fopfd = fsiOPFLDs
  3453. fmt.Println(struct4201A.Fopfd)
  3454. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3455. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3456. var res2 ResultSix
  3457. var respJSON2 map[string]interface{}
  3458. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. userJSONBytes2, _ := json.Marshal(respJSON2)
  3464. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3465. utils.ErrorLog("解析失败:%v", err)
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3467. return
  3468. }
  3469. if res2.Infcode != 0 {
  3470. c.ServeSuccessJSON(map[string]interface{}{
  3471. "failed_code": -10,
  3472. "msg": res2.ErrMsg,
  3473. })
  3474. return
  3475. } else {
  3476. order.IsUploadOrderInfo = 1
  3477. service.UpdateOrder(order)
  3478. c.ServeSuccessJSON(map[string]interface{}{
  3479. "msg": "上传成功",
  3480. })
  3481. }
  3482. }
  3483. func (c *HisApiController) Get2505() {
  3484. admin_user_id, _ := c.GetInt64("admin_user_id")
  3485. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3487. 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)
  3488. }
  3489. func (c *HisApiController) Get4201A() {
  3490. order_id, _ := c.GetInt64("order_id")
  3491. admin_user_id, _ := c.GetInt64("admin_user_id")
  3492. order, _ := service.GetHisOrderByIDTwo(order_id)
  3493. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3494. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3495. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3496. //order_info = append(order_info, order_info_two...)
  3497. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3498. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3499. department, _ := service.GetDepartMentDetail(his.Departments)
  3500. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3501. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3502. if order.ID == 0 {
  3503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3504. return
  3505. }
  3506. var struct4201A models.Struct4201A
  3507. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3508. for _, items := range order_info {
  3509. memo := make(map[string]interface{})
  3510. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3511. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3512. fsiOPFLD.MedType = "14"
  3513. fsiOPFLD.BkkpSn = items.FeedetlSn
  3514. fsiOPFLD.FixmedinsCode = miConfig.Code
  3515. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3516. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3517. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3518. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3519. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3520. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3521. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3522. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3523. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3524. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3525. fsiOPFLD.BilgDeptName = department.Name
  3526. fsiOPFLD.BilgDeptCodg = department.Number
  3527. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3528. fsiOPFLD.BilgDrName = doctor.UserName
  3529. fsiOPFLD.MedChrgitmType = "09"
  3530. memo["hosp_appr_flag"] = "1"
  3531. memo["invoice_no"] = order.MdtrtId
  3532. memo["memo"] = "自费"
  3533. bytesData, _ := json.Marshal(memo)
  3534. fsiOPFLD.Memo = string(bytesData)
  3535. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3536. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3537. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3538. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3539. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3540. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3541. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3542. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3543. fsiOPFLD.BilgDeptName = department.Name
  3544. fsiOPFLD.BilgDeptCodg = department.Number
  3545. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3546. fsiOPFLD.BilgDrName = doctor.UserName
  3547. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3548. case 0:
  3549. break
  3550. case 1:
  3551. fsiOPFLD.MedChrgitmType = "14"
  3552. break
  3553. case 2:
  3554. fsiOPFLD.MedChrgitmType = "05"
  3555. break
  3556. case 3:
  3557. fsiOPFLD.MedChrgitmType = "03"
  3558. break
  3559. case 4:
  3560. fsiOPFLD.MedChrgitmType = "03"
  3561. break
  3562. case 5:
  3563. fsiOPFLD.MedChrgitmType = "08"
  3564. break
  3565. case 6:
  3566. fsiOPFLD.MedChrgitmType = "14"
  3567. break
  3568. case 7:
  3569. fsiOPFLD.MedChrgitmType = "14"
  3570. break
  3571. case 8:
  3572. fsiOPFLD.MedChrgitmType = "03"
  3573. break
  3574. case 9:
  3575. fsiOPFLD.MedChrgitmType = "14"
  3576. break
  3577. case 10:
  3578. fsiOPFLD.MedChrgitmType = "14"
  3579. break
  3580. case 11:
  3581. fsiOPFLD.MedChrgitmType = "06"
  3582. break
  3583. case 12:
  3584. fsiOPFLD.MedChrgitmType = "12"
  3585. break
  3586. case 13:
  3587. fsiOPFLD.MedChrgitmType = "01"
  3588. break
  3589. case 14:
  3590. fsiOPFLD.MedChrgitmType = "04"
  3591. break
  3592. case 15:
  3593. fsiOPFLD.MedChrgitmType = "14"
  3594. break
  3595. }
  3596. memo["hosp_appr_flag"] = "1"
  3597. memo["invoice_no"] = order.MdtrtId
  3598. memo["memo"] = "自费"
  3599. bytesData, _ := json.Marshal(memo)
  3600. fsiOPFLD.Memo = string(bytesData)
  3601. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3602. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3603. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3604. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3605. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3606. fsiOPFLD.BilgDeptName = department.Name
  3607. fsiOPFLD.BilgDeptCodg = department.Number
  3608. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3609. fsiOPFLD.BilgDrName = doctor.UserName
  3610. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3611. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3612. fsiOPFLD.MedChrgitmType = "08"
  3613. memo["hosp_appr_flag"] = "1"
  3614. memo["invoice_no"] = order.MdtrtId
  3615. memo["memo"] = "自费"
  3616. bytesData, _ := json.Marshal(memo)
  3617. fsiOPFLD.Memo = string(bytesData)
  3618. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3619. }
  3620. }
  3621. }
  3622. for _, items := range order_info_two {
  3623. memo := make(map[string]interface{})
  3624. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3625. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3626. fsiOPFLD.MedType = "14"
  3627. fsiOPFLD.BkkpSn = items.FeedetlSn
  3628. fsiOPFLD.FixmedinsCode = miConfig.Code
  3629. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3630. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3631. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3632. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3633. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3634. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3635. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3636. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3637. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3638. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3639. fsiOPFLD.BilgDeptName = department.Name
  3640. fsiOPFLD.BilgDeptCodg = department.Number
  3641. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3642. fsiOPFLD.BilgDrName = doctor.UserName
  3643. fsiOPFLD.MedChrgitmType = "09"
  3644. memo["hosp_appr_flag"] = "1"
  3645. memo["invoice_no"] = order.MdtrtId
  3646. memo["memo"] = "自费"
  3647. bytesData, _ := json.Marshal(memo)
  3648. fsiOPFLD.Memo = string(bytesData)
  3649. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3650. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3651. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3652. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3653. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3654. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3655. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3656. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3657. fsiOPFLD.BilgDeptName = department.Name
  3658. fsiOPFLD.BilgDeptCodg = department.Number
  3659. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3660. fsiOPFLD.BilgDrName = doctor.UserName
  3661. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3662. case 0:
  3663. break
  3664. case 1:
  3665. fsiOPFLD.MedChrgitmType = "14"
  3666. break
  3667. case 2:
  3668. fsiOPFLD.MedChrgitmType = "05"
  3669. break
  3670. case 3:
  3671. fsiOPFLD.MedChrgitmType = "03"
  3672. break
  3673. case 4:
  3674. fsiOPFLD.MedChrgitmType = "03"
  3675. break
  3676. case 5:
  3677. fsiOPFLD.MedChrgitmType = "08"
  3678. break
  3679. case 6:
  3680. fsiOPFLD.MedChrgitmType = "14"
  3681. break
  3682. case 7:
  3683. fsiOPFLD.MedChrgitmType = "14"
  3684. break
  3685. case 8:
  3686. fsiOPFLD.MedChrgitmType = "03"
  3687. break
  3688. case 9:
  3689. fsiOPFLD.MedChrgitmType = "14"
  3690. break
  3691. case 10:
  3692. fsiOPFLD.MedChrgitmType = "14"
  3693. break
  3694. case 11:
  3695. fsiOPFLD.MedChrgitmType = "06"
  3696. break
  3697. case 12:
  3698. fsiOPFLD.MedChrgitmType = "12"
  3699. break
  3700. case 13:
  3701. fsiOPFLD.MedChrgitmType = "01"
  3702. break
  3703. case 14:
  3704. fsiOPFLD.MedChrgitmType = "04"
  3705. break
  3706. case 15:
  3707. fsiOPFLD.MedChrgitmType = "14"
  3708. break
  3709. }
  3710. memo["hosp_appr_flag"] = "1"
  3711. memo["invoice_no"] = order.MdtrtId
  3712. memo["memo"] = "自费"
  3713. bytesData, _ := json.Marshal(memo)
  3714. fsiOPFLD.Memo = string(bytesData)
  3715. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3716. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3717. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3718. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3719. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3720. fsiOPFLD.BilgDeptName = department.Name
  3721. fsiOPFLD.BilgDeptCodg = department.Number
  3722. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3723. fsiOPFLD.BilgDrName = doctor.UserName
  3724. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3725. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3726. fsiOPFLD.MedChrgitmType = "08"
  3727. memo["hosp_appr_flag"] = "1"
  3728. memo["invoice_no"] = order.MdtrtId
  3729. memo["memo"] = "自费"
  3730. bytesData, _ := json.Marshal(memo)
  3731. fsiOPFLD.Memo = string(bytesData)
  3732. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3733. }
  3734. }
  3735. }
  3736. fmt.Println(fsiOPFLDs)
  3737. struct4201A.Fopfd = fsiOPFLDs
  3738. fmt.Println(struct4201A.Fopfd)
  3739. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3740. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3741. var res2 ResultSix
  3742. var respJSON2 map[string]interface{}
  3743. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3746. return
  3747. }
  3748. userJSONBytes2, _ := json.Marshal(respJSON2)
  3749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3750. utils.ErrorLog("解析失败:%v", err)
  3751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. return
  3753. }
  3754. if res2.Infcode != 0 {
  3755. c.ServeSuccessJSON(map[string]interface{}{
  3756. "failed_code": -10,
  3757. "msg": res2.ErrMsg,
  3758. })
  3759. return
  3760. } else {
  3761. order.IsUploadOrderInfo = 1
  3762. service.UpdateOrder(order)
  3763. c.ServeSuccessJSON(map[string]interface{}{
  3764. "msg": "上传成功",
  3765. })
  3766. }
  3767. }
  3768. func (c *HisApiController) Get4202() {
  3769. order_id, _ := c.GetInt64("order_id")
  3770. admin_user_id, _ := c.GetInt64("admin_user_id")
  3771. order, _ := service.GetHisOrderByIDTwo(order_id)
  3772. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3773. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3775. if order.ID == 0 {
  3776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3777. return
  3778. }
  3779. var struct4202 models.Struct4202
  3780. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3781. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3782. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3783. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3784. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3785. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3786. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3787. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3788. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3789. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3790. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3791. var config []*models.HisXtDiagnoseConfig
  3792. for _, item := range diagnosis_ids {
  3793. id, _ := strconv.ParseInt(item, 10, 64)
  3794. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3795. config = append(config, &diagnosisConfig)
  3796. }
  3797. var tempDiaginfos []models.OwnPayPatnDiagListD
  3798. for index, item := range config {
  3799. if index == 0 {
  3800. var tempDiaginfo models.OwnPayPatnDiagListD
  3801. tempDiaginfo.InoutDiagType = "1"
  3802. tempDiaginfo.DiagCode = item.CountryCode
  3803. tempDiaginfo.DiagName = item.CountryContentName
  3804. tempDiaginfo.DiagType = "1"
  3805. tempDiaginfo.DiagSrtNo = "1"
  3806. tempDiaginfo.MaindiagFlag = "1"
  3807. tempDiaginfo.ValiFlag = "1"
  3808. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3809. } else {
  3810. var tempDiaginfo models.OwnPayPatnDiagListD
  3811. tempDiaginfo.DiagCode = item.CountryCode
  3812. tempDiaginfo.DiagName = item.CountryContentName
  3813. tempDiaginfo.DiagType = "2"
  3814. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3815. tempDiaginfo.MaindiagFlag = "0"
  3816. tempDiaginfo.ValiFlag = "1"
  3817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3818. }
  3819. }
  3820. struct4202.ODiagListD = tempDiaginfos
  3821. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3822. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3823. var res2 ResultSix
  3824. var respJSON2 map[string]interface{}
  3825. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3828. return
  3829. }
  3830. userJSONBytes2, _ := json.Marshal(respJSON2)
  3831. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3832. utils.ErrorLog("解析失败:%v", err)
  3833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3834. return
  3835. }
  3836. if res2.Infcode != 0 {
  3837. c.ServeSuccessJSON(map[string]interface{}{
  3838. "failed_code": -10,
  3839. "msg": res2.ErrMsg,
  3840. })
  3841. return
  3842. } else {
  3843. order.IsUploadDiagnose = 1
  3844. service.UpdateOrder(order)
  3845. c.ServeSuccessJSON(map[string]interface{}{
  3846. "msg": "上传成功",
  3847. })
  3848. }
  3849. }
  3850. func (c *HisApiController) Get4203() {
  3851. admin_user_id, _ := c.GetInt64("admin_user_id")
  3852. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3854. order_id, _ := c.GetInt64("order_id")
  3855. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3856. number := ""
  3857. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3858. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3859. if his.ID == 0 {
  3860. number = hospital.Number
  3861. } else {
  3862. number = his.Number
  3863. }
  3864. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3865. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3866. var res2 ResultSix
  3867. var respJSON2 map[string]interface{}
  3868. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3871. return
  3872. }
  3873. userJSONBytes2, _ := json.Marshal(respJSON2)
  3874. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3875. utils.ErrorLog("解析失败:%v", err)
  3876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3877. return
  3878. }
  3879. if res2.Infcode != 0 {
  3880. c.ServeSuccessJSON(map[string]interface{}{
  3881. "failed_code": -10,
  3882. "msg": res2.ErrMsg,
  3883. })
  3884. return
  3885. } else {
  3886. order.IsUploadSuccess = 1
  3887. service.UpdateOrderTwo(order)
  3888. c.ServeSuccessJSON(map[string]interface{}{
  3889. "msg": "上传成功",
  3890. })
  3891. }
  3892. }
  3893. func (c *HisApiController) Get4205() {
  3894. order_id, _ := c.GetInt64("order_id")
  3895. admin_user_id, _ := c.GetInt64("admin_user_id")
  3896. fapiao_code := c.GetString("fapiao_code")
  3897. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3898. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3899. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3900. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3901. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3902. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3903. //order_info = append(order_info, order_info_two...)
  3904. department, _ := service.GetDepartMentDetail(his.Departments)
  3905. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3906. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3907. if order.ID == 0 {
  3908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3909. return
  3910. }
  3911. var struct4201A models.Struct4201A
  3912. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3913. for _, items := range order_info {
  3914. memo := make(map[string]interface{})
  3915. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3916. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3917. fsiOPFLD.MedType = pre.MedType
  3918. fsiOPFLD.FixmedinsCode = miConfig.Code
  3919. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3920. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3921. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3922. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3923. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3924. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3925. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3926. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3927. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3928. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3929. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3930. fsiOPFLD.BilgDeptName = department.Name
  3931. fsiOPFLD.BilgDeptCodg = department.Number
  3932. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3933. fsiOPFLD.BilgDrName = doctor.UserName
  3934. fsiOPFLD.MedChrgitmType = "09"
  3935. memo["hosp_appr_flag"] = "1"
  3936. memo["invoice_no"] = fapiao_code
  3937. memo["memo"] = "自费"
  3938. bytesData, _ := json.Marshal(memo)
  3939. fsiOPFLD.Memo = string(bytesData)
  3940. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3941. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3942. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3943. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3944. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3945. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3946. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3947. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3948. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3949. fsiOPFLD.BilgDeptName = department.Name
  3950. fsiOPFLD.BilgDeptCodg = department.Number
  3951. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3952. fsiOPFLD.BilgDrName = doctor.UserName
  3953. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3954. case 0:
  3955. break
  3956. case 1:
  3957. fsiOPFLD.MedChrgitmType = "14"
  3958. break
  3959. case 2:
  3960. fsiOPFLD.MedChrgitmType = "05"
  3961. break
  3962. case 3:
  3963. fsiOPFLD.MedChrgitmType = "03"
  3964. break
  3965. case 4:
  3966. fsiOPFLD.MedChrgitmType = "03"
  3967. break
  3968. case 5:
  3969. fsiOPFLD.MedChrgitmType = "08"
  3970. break
  3971. case 6:
  3972. fsiOPFLD.MedChrgitmType = "14"
  3973. break
  3974. case 7:
  3975. fsiOPFLD.MedChrgitmType = "14"
  3976. break
  3977. case 8:
  3978. fsiOPFLD.MedChrgitmType = "03"
  3979. break
  3980. case 9:
  3981. fsiOPFLD.MedChrgitmType = "14"
  3982. break
  3983. case 10:
  3984. fsiOPFLD.MedChrgitmType = "14"
  3985. break
  3986. case 11:
  3987. fsiOPFLD.MedChrgitmType = "06"
  3988. break
  3989. case 12:
  3990. fsiOPFLD.MedChrgitmType = "12"
  3991. break
  3992. case 13:
  3993. fsiOPFLD.MedChrgitmType = "01"
  3994. break
  3995. case 14:
  3996. fsiOPFLD.MedChrgitmType = "04"
  3997. break
  3998. case 15:
  3999. fsiOPFLD.MedChrgitmType = "14"
  4000. break
  4001. }
  4002. memo["hosp_appr_flag"] = "1"
  4003. memo["invoice_no"] = fapiao_code
  4004. memo["memo"] = "自费"
  4005. bytesData, _ := json.Marshal(memo)
  4006. fsiOPFLD.Memo = string(bytesData)
  4007. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4008. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4009. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4010. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4011. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4012. fsiOPFLD.BilgDeptName = department.Name
  4013. fsiOPFLD.BilgDeptCodg = department.Number
  4014. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4015. fsiOPFLD.BilgDrName = doctor.UserName
  4016. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4017. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4018. fsiOPFLD.MedChrgitmType = "08"
  4019. memo["hosp_appr_flag"] = "1"
  4020. memo["invoice_no"] = fapiao_code
  4021. memo["memo"] = "自费"
  4022. bytesData, _ := json.Marshal(memo)
  4023. fsiOPFLD.Memo = string(bytesData)
  4024. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4025. }
  4026. }
  4027. }
  4028. for _, items := range order_info_two {
  4029. memo := make(map[string]interface{})
  4030. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4031. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4032. fsiOPFLD.MedType = pre.MedType
  4033. fsiOPFLD.BkkpSn = items.FeedetlSn
  4034. fsiOPFLD.FixmedinsCode = miConfig.Code
  4035. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4036. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4037. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4038. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4039. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4040. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4041. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4042. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4043. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4044. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4045. fsiOPFLD.BilgDeptName = department.Name
  4046. fsiOPFLD.BilgDeptCodg = department.Number
  4047. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4048. fsiOPFLD.BilgDrName = doctor.UserName
  4049. fsiOPFLD.MedChrgitmType = "09"
  4050. memo["hosp_appr_flag"] = "1"
  4051. memo["invoice_no"] = fapiao_code
  4052. memo["memo"] = "自费"
  4053. bytesData, _ := json.Marshal(memo)
  4054. fsiOPFLD.Memo = string(bytesData)
  4055. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4056. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4057. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4058. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4059. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4060. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4061. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4062. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4063. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4064. fsiOPFLD.BilgDeptName = department.Name
  4065. fsiOPFLD.BilgDeptCodg = department.Number
  4066. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4067. fsiOPFLD.BilgDrName = doctor.UserName
  4068. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4069. case 0:
  4070. break
  4071. case 1:
  4072. fsiOPFLD.MedChrgitmType = "14"
  4073. break
  4074. case 2:
  4075. fsiOPFLD.MedChrgitmType = "05"
  4076. break
  4077. case 3:
  4078. fsiOPFLD.MedChrgitmType = "03"
  4079. break
  4080. case 4:
  4081. fsiOPFLD.MedChrgitmType = "03"
  4082. break
  4083. case 5:
  4084. fsiOPFLD.MedChrgitmType = "08"
  4085. break
  4086. case 6:
  4087. fsiOPFLD.MedChrgitmType = "14"
  4088. break
  4089. case 7:
  4090. fsiOPFLD.MedChrgitmType = "14"
  4091. break
  4092. case 8:
  4093. fsiOPFLD.MedChrgitmType = "03"
  4094. break
  4095. case 9:
  4096. fsiOPFLD.MedChrgitmType = "14"
  4097. break
  4098. case 10:
  4099. fsiOPFLD.MedChrgitmType = "14"
  4100. break
  4101. case 11:
  4102. fsiOPFLD.MedChrgitmType = "06"
  4103. break
  4104. case 12:
  4105. fsiOPFLD.MedChrgitmType = "12"
  4106. break
  4107. case 13:
  4108. fsiOPFLD.MedChrgitmType = "01"
  4109. break
  4110. case 14:
  4111. fsiOPFLD.MedChrgitmType = "04"
  4112. break
  4113. case 15:
  4114. fsiOPFLD.MedChrgitmType = "14"
  4115. break
  4116. }
  4117. memo["hosp_appr_flag"] = "1"
  4118. memo["invoice_no"] = fapiao_code
  4119. memo["memo"] = "自费"
  4120. bytesData, _ := json.Marshal(memo)
  4121. fsiOPFLD.Memo = string(bytesData)
  4122. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4123. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4124. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4125. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4126. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4127. fsiOPFLD.BilgDeptName = department.Name
  4128. fsiOPFLD.BilgDeptCodg = department.Number
  4129. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4130. fsiOPFLD.BilgDrName = doctor.UserName
  4131. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4132. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4133. fsiOPFLD.MedChrgitmType = "08"
  4134. memo["hosp_appr_flag"] = "1"
  4135. memo["invoice_no"] = fapiao_code
  4136. memo["memo"] = "自费"
  4137. bytesData, _ := json.Marshal(memo)
  4138. fsiOPFLD.Memo = string(bytesData)
  4139. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4140. }
  4141. }
  4142. }
  4143. fmt.Println(fsiOPFLDs)
  4144. struct4201A.Fopfd = fsiOPFLDs
  4145. fmt.Println(struct4201A.Fopfd)
  4146. var struct4202 models.Struct4202
  4147. timeLayout := "2006-01-02 15:04:05"
  4148. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4149. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4150. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4151. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4152. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4153. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4154. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4155. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4156. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4157. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4158. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4159. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4160. var config []*models.HisXtDiagnoseConfig
  4161. for _, item := range diagnosis_ids {
  4162. id, _ := strconv.ParseInt(item, 10, 64)
  4163. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4164. config = append(config, &diagnosisConfig)
  4165. }
  4166. var tempDiaginfos []models.OwnPayPatnDiagListD
  4167. for index, item := range config {
  4168. if index == 0 {
  4169. var tempDiaginfo models.OwnPayPatnDiagListD
  4170. tempDiaginfo.InoutDiagType = "1"
  4171. tempDiaginfo.DiagCode = item.CountryCode
  4172. tempDiaginfo.DiagName = item.CountryContentName
  4173. tempDiaginfo.DiagType = "1"
  4174. tempDiaginfo.DiagSrtNo = "1"
  4175. tempDiaginfo.MaindiagFlag = "1"
  4176. tempDiaginfo.ValiFlag = "1"
  4177. tempDiaginfo.DiagDrName = doctor.UserName
  4178. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4179. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4180. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4181. } else {
  4182. var tempDiaginfo models.OwnPayPatnDiagListD
  4183. tempDiaginfo.DiagCode = item.CountryCode
  4184. tempDiaginfo.DiagName = item.CountryContentName
  4185. tempDiaginfo.DiagType = "2"
  4186. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4187. tempDiaginfo.MaindiagFlag = "0"
  4188. tempDiaginfo.ValiFlag = "1"
  4189. tempDiaginfo.DiagDrName = doctor.UserName
  4190. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4191. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4192. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4193. }
  4194. }
  4195. struct4202.ODiagListD = tempDiaginfos
  4196. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4197. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4198. var res2 ResultSix
  4199. var respJSON2 map[string]interface{}
  4200. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4203. return
  4204. }
  4205. userJSONBytes2, _ := json.Marshal(respJSON2)
  4206. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4207. utils.ErrorLog("解析失败:%v", err)
  4208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4209. return
  4210. }
  4211. if res2.Infcode != 0 {
  4212. c.ServeSuccessJSON(map[string]interface{}{
  4213. "failed_code": -10,
  4214. "msg": res2.ErrMsg,
  4215. })
  4216. return
  4217. } else {
  4218. order.IsUploadDiagnose = 1
  4219. order.IsUploadOrderInfo = 1
  4220. service.UpdateOrderTwo(order)
  4221. c.ServeSuccessJSON(map[string]interface{}{
  4222. "msg": "上传成功",
  4223. })
  4224. }
  4225. }
  4226. func (c *HisApiController) Get4207() {
  4227. admin_user_id, _ := c.GetInt64("admin_user_id")
  4228. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4229. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4230. order_id, _ := c.GetInt64("order_id")
  4231. order, _ := service.GetHisOrderByIDTwo(order_id)
  4232. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4233. var struct4207 models.Struct4207
  4234. struct4207.PageNum = "1"
  4235. struct4207.PageSize = "1000"
  4236. struct4207.FixmedinsCode = miConfig.Code
  4237. struct4207.FixmedinsMdtrtID = order.Number
  4238. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4239. saveLog(result, requestLog, "4207", "查询")
  4240. var res2 ResultSix
  4241. var respJSON2 map[string]interface{}
  4242. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4245. return
  4246. }
  4247. userJSONBytes2, _ := json.Marshal(respJSON2)
  4248. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4249. utils.ErrorLog("解析失败:%v", err)
  4250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4251. return
  4252. }
  4253. if res2.Infcode != 0 {
  4254. c.ServeSuccessJSON(map[string]interface{}{
  4255. "failed_code": -10,
  4256. "msg": res2.ErrMsg,
  4257. })
  4258. return
  4259. } else {
  4260. c.ServeSuccessJSON(map[string]interface{}{
  4261. "msg": "查询成功",
  4262. })
  4263. }
  4264. }
  4265. func (c *HisApiController) Get4208() {
  4266. admin_user_id, _ := c.GetInt64("admin_user_id")
  4267. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4269. order_id, _ := c.GetInt64("order_id")
  4270. order, _ := service.GetHisOrderByIDTwo(order_id)
  4271. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4272. var struct4208 models.Struct4208
  4273. struct4208.PageNum = "1"
  4274. struct4208.PageSize = "1000"
  4275. struct4208.PsnCertType = "01"
  4276. struct4208.Certno = his.Certno
  4277. struct4208.MedType = order.MedType
  4278. struct4208.PsnName = his.Name
  4279. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4280. saveLog(result, requestLog, "4208", "查询")
  4281. var res2 ResultSix
  4282. var respJSON2 map[string]interface{}
  4283. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4286. return
  4287. }
  4288. userJSONBytes2, _ := json.Marshal(respJSON2)
  4289. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4290. utils.ErrorLog("解析失败:%v", err)
  4291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4292. return
  4293. }
  4294. if res2.Infcode != 0 {
  4295. c.ServeSuccessJSON(map[string]interface{}{
  4296. "failed_code": -10,
  4297. "msg": res2.ErrMsg,
  4298. })
  4299. return
  4300. } else {
  4301. c.ServeSuccessJSON(map[string]interface{}{
  4302. "msg": "查询成功",
  4303. })
  4304. }
  4305. }
  4306. func (c *HisApiController) Get4209() {
  4307. admin_user_id, _ := c.GetInt64("admin_user_id")
  4308. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4310. order_id, _ := c.GetInt64("order_id")
  4311. order, _ := service.GetHisOrderByIDTwo(order_id)
  4312. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4313. var struct4209 models.Struct4209
  4314. struct4209.FixmedinsMdtrtID = order.Number
  4315. struct4209.FixmedinsCode = miConfig.Code
  4316. struct4209.PageSize = "1000"
  4317. struct4209.PageNum = "1"
  4318. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4319. saveLog(result, requestLog, "4209", "查询")
  4320. var res2 ResultSix
  4321. var respJSON2 map[string]interface{}
  4322. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4325. return
  4326. }
  4327. userJSONBytes2, _ := json.Marshal(respJSON2)
  4328. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4329. utils.ErrorLog("解析失败:%v", err)
  4330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4331. return
  4332. }
  4333. if res2.Infcode != 0 {
  4334. c.ServeSuccessJSON(map[string]interface{}{
  4335. "failed_code": -10,
  4336. "msg": res2.ErrMsg,
  4337. })
  4338. return
  4339. } else {
  4340. c.ServeSuccessJSON(map[string]interface{}{
  4341. "msg": "查询成功",
  4342. })
  4343. }
  4344. }
  4345. type Result3101 struct {
  4346. Infcode string `json:"infcode"`
  4347. InfRefmsgid string `json:"inf_refmsgid"`
  4348. RefmsgTime string `json:"refmsg_time"`
  4349. RespondTime string `json:"respond_time"`
  4350. Enctype string `json:"enctype"`
  4351. Signtype string `json:"signtype"`
  4352. ErrMsg string `json:"err_msg"`
  4353. Output struct {
  4354. Result []struct {
  4355. JudgeResultDetailDtos []struct {
  4356. VolaItemType string `json:"vola_item_type"`
  4357. MdtrtID string `json:"mdtrt_id"`
  4358. JrdID string `json:"jrd_id"`
  4359. PatnID string `json:"patn_id"`
  4360. RxID string `json:"rx_id"`
  4361. VolaAmt interface{} `json:"vola_amt"`
  4362. } `json:"judge_result_detail_dtos"`
  4363. RuleID string `json:"rule_id"`
  4364. VolaEvid string `json:"vola_evid"`
  4365. MdtrtID string `json:"mdtrt_id"`
  4366. RuleName string `json:"rule_name"`
  4367. VolaAmtStas string `json:"vola_amt_stas"`
  4368. JrID string `json:"jr_id"`
  4369. PatnID string `json:"patn_id"`
  4370. SevDeg string `json:"sev_deg"`
  4371. VolaAmt float64 `json:"vola_amt"`
  4372. VolaBhvrType string `json:"vola_bhvr_type"`
  4373. VolaCont string `json:"vola_cont"`
  4374. } `json:"result"`
  4375. } `json:"output"`
  4376. }
  4377. type Resultgd3101 struct {
  4378. Infcode int64 `json:"infcode"`
  4379. InfRefmsgid string `json:"inf_refmsgid"`
  4380. RefmsgTime string `json:"refmsg_time"`
  4381. RespondTime string `json:"respond_time"`
  4382. Enctype string `json:"enctype"`
  4383. Signtype string `json:"signtype"`
  4384. ErrMsg string `json:"err_msg"`
  4385. Output struct {
  4386. Result []struct {
  4387. JudgeResultDetailDtos []struct {
  4388. VolaItemType string `json:"vola_item_type"`
  4389. MdtrtID string `json:"mdtrt_id"`
  4390. JrdID string `json:"jrd_id"`
  4391. PatnID string `json:"patn_id"`
  4392. RxID string `json:"rx_id"`
  4393. VolaAmt interface{} `json:"vola_amt"`
  4394. } `json:"judge_result_detail_dtos"`
  4395. RuleID string `json:"rule_id"`
  4396. VolaEvid string `json:"vola_evid"`
  4397. MdtrtID string `json:"mdtrt_id"`
  4398. RuleName string `json:"rule_name"`
  4399. VolaAmtStas string `json:"vola_amt_stas"`
  4400. JrID string `json:"jr_id"`
  4401. PatnID string `json:"patn_id"`
  4402. SevDeg string `json:"sev_deg"`
  4403. VolaAmt float64 `json:"vola_amt"`
  4404. VolaBhvrType string `json:"vola_bhvr_type"`
  4405. VolaCont string `json:"vola_cont"`
  4406. } `json:"result"`
  4407. } `json:"output"`
  4408. }
  4409. func (c *HisApiController) ReadEleToken() {
  4410. admin_user_id, _ := c.GetInt64("admin_user_id")
  4411. his_patient_id, _ := c.GetInt64("his_patient_id")
  4412. adminUser := c.GetAdminUserInfo()
  4413. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4414. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4415. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4416. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4417. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4418. if len(tokens) > 0 {
  4419. c.ServeSuccessJSON(map[string]interface{}{
  4420. "msg": "读取成功",
  4421. })
  4422. } else {
  4423. c.ServeSuccessJSON(map[string]interface{}{
  4424. "failed_code": -10,
  4425. "msg": "读取失败",
  4426. })
  4427. }
  4428. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4429. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4430. if len(tokens) > 0 {
  4431. c.ServeSuccessJSON(map[string]interface{}{
  4432. "msg": "读取成功",
  4433. })
  4434. } else {
  4435. c.ServeSuccessJSON(map[string]interface{}{
  4436. "failed_code": -10,
  4437. "msg": "读取失败",
  4438. })
  4439. }
  4440. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4441. var api string
  4442. 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 +
  4443. "&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"
  4444. resp, requestErr := http.Get(api)
  4445. if requestErr != nil {
  4446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4447. }
  4448. body, ioErr := ioutil.ReadAll(resp.Body)
  4449. if ioErr != nil {
  4450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4452. }
  4453. var respJSON map[string]interface{}
  4454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4457. return
  4458. }
  4459. var status string
  4460. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4461. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4462. var token string
  4463. var res ResultTwo //1101结果
  4464. var res10265 ResultTwo10265 //1101结果
  4465. if status == "0" { //读卡成功
  4466. var card_info string //卡信息
  4467. var busi_card_info string
  4468. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4469. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4470. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4471. fmt.Println(card_info)
  4472. fmt.Println(busi_card_info)
  4473. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4474. result, _ := json.Marshal(respJSON)
  4475. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4476. utils.ErrorLog("解析失败:%v", err)
  4477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4478. return
  4479. }
  4480. res.ErrMsg = res10265.ErrMsg
  4481. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4482. res.Infcode = infocode
  4483. res.Output = res10265.Output
  4484. res.InfRefmsgid = res10265.InfRefmsgid
  4485. if res.Infcode == 0 {
  4486. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4487. if err == gorm.ErrRecordNotFound {
  4488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4489. return
  4490. } else if err != nil {
  4491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4492. return
  4493. } else {
  4494. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4495. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4496. infoStr := string(Iinfos)
  4497. idetinfoStr := string(Idetinfos)
  4498. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4499. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4500. psn := &models.HisPsn{
  4501. PsnNo: res.Output.Baseinfo.PsnNo,
  4502. PatientId: patient.ID,
  4503. Certno: res.Output.Baseinfo.Certno,
  4504. Gend: res.Output.Baseinfo.Gend,
  4505. Naty: res.Output.Baseinfo.Naty,
  4506. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4507. PsnName: res.Output.Baseinfo.PsnName,
  4508. Age: float64(age),
  4509. Brdy: b,
  4510. Idetinfo: idetinfoStr,
  4511. Insuinfo: infoStr,
  4512. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4513. CardInfo: card_info,
  4514. VerifyNumber: token,
  4515. IdCardType: 4,
  4516. }
  4517. var rf []*ResultFive
  4518. json.Unmarshal([]byte(infoStr), &rf)
  4519. var insutypes []*ResultFive
  4520. var insutype string
  4521. var is390 int = 0
  4522. var is310 int = 0
  4523. for _, item := range rf {
  4524. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4525. insutypes = append(insutypes, item)
  4526. }
  4527. }
  4528. if len(insutypes) == 1 {
  4529. insutype = insutypes[0].Insutype
  4530. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4531. } else {
  4532. for _, i := range insutypes {
  4533. if i.Insutype == "390" {
  4534. is390 = 1
  4535. }
  4536. if i.Insutype == "310" {
  4537. is310 = 1
  4538. }
  4539. }
  4540. }
  4541. if is390 == 1 {
  4542. insutype = "390"
  4543. }
  4544. if is310 == 1 {
  4545. insutype = "310"
  4546. }
  4547. if len(insutypes) == 0 {
  4548. insutype = "310"
  4549. }
  4550. service.CreateHisPsn(psn)
  4551. c.ServeSuccessJSON(map[string]interface{}{
  4552. "patient": patient,
  4553. "number": token,
  4554. "insutype": insutype,
  4555. })
  4556. }
  4557. } else {
  4558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4559. return
  4560. }
  4561. } else { //读卡失败
  4562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4563. return
  4564. }
  4565. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4566. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4567. if len(errMsg) == 0 {
  4568. type ELeData struct {
  4569. Data struct {
  4570. IdNo string `json:"idNo"`
  4571. IdType string `json:"idType"`
  4572. UserName string `json:"userName"`
  4573. EcToken string `json:"ecToken"`
  4574. InsuOrg string `json:"insuOrg"`
  4575. Gender string `json:"gender"`
  4576. Birthday string `json:"birthday"`
  4577. Nationality string `json:"nationality"`
  4578. Email string `json:"email"`
  4579. Extra string `json:"extra"`
  4580. } `json:"data"`
  4581. Code int `json:"code"`
  4582. Message string `json:"message"`
  4583. }
  4584. var ele ELeData
  4585. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4586. if err != nil {
  4587. utils.ErrorLog("解析失败:%v", err)
  4588. }
  4589. token := ele.Data.EcToken
  4590. if len(token) > 0 {
  4591. psn := &models.HisPsn{
  4592. PsnNo: his.PsnNo,
  4593. Age: 0,
  4594. PatientId: his.PatientId,
  4595. Certno: his.Certno,
  4596. Brdy: his.Brdy,
  4597. Gend: his.Gend,
  4598. Naty: his.Naty,
  4599. PsnCertType: his.PsnCertType,
  4600. PsnName: his.PsnName,
  4601. Idetinfo: his.Idetinfo,
  4602. Insuinfo: his.Iinfo,
  4603. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4604. CardInfo: outPutInfo,
  4605. VerifyNumber: token,
  4606. }
  4607. service.CreateHisPsn(psn)
  4608. }
  4609. if len(token) > 0 {
  4610. c.ServeSuccessJSON(map[string]interface{}{
  4611. "msg": "读取成功",
  4612. })
  4613. } else {
  4614. c.ServeSuccessJSON(map[string]interface{}{
  4615. "failed_code": -10,
  4616. "msg": "读取失败",
  4617. })
  4618. }
  4619. }
  4620. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4621. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4622. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4623. type ELeData struct {
  4624. Data struct {
  4625. IdNo string `json:"idNo"`
  4626. IdType string `json:"idType"`
  4627. UserName string `json:"userName"`
  4628. EcToken string `json:"ecToken"`
  4629. InsuOrg string `json:"insuOrg"`
  4630. Gender string `json:"gender"`
  4631. Birthday string `json:"birthday"`
  4632. Nationality string `json:"nationality"`
  4633. Email string `json:"email"`
  4634. Extra string `json:"extra"`
  4635. } `json:"data"`
  4636. Code int `json:"code"`
  4637. Message string `json:"message"`
  4638. }
  4639. var ele ELeData
  4640. err := json.Unmarshal([]byte(result), &ele)
  4641. if err != nil {
  4642. utils.ErrorLog("解析失败:%v", err)
  4643. }
  4644. token := ele.Data.EcToken
  4645. token = Remove0000(token)
  4646. fmt.Println(ele.Data.UserName)
  4647. 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)
  4648. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4649. var res ResultTwo
  4650. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4651. utils.ErrorLog("解析失败:%v", err)
  4652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4653. return
  4654. }
  4655. if res.Infcode == 0 {
  4656. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4657. if err == gorm.ErrRecordNotFound {
  4658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4659. return
  4660. } else if err != nil {
  4661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4662. return
  4663. } else {
  4664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4666. infoStr := string(Iinfos)
  4667. idetinfoStr := string(Idetinfos)
  4668. psn := &models.HisPsn{
  4669. PsnNo: res.Output.Baseinfo.PsnNo,
  4670. PatientId: patient.ID,
  4671. Certno: res.Output.Baseinfo.Certno,
  4672. Gend: res.Output.Baseinfo.Gend,
  4673. Naty: res.Output.Baseinfo.Naty,
  4674. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4675. PsnName: res.Output.Baseinfo.PsnName,
  4676. Idetinfo: idetinfoStr,
  4677. Insuinfo: infoStr,
  4678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4679. CardInfo: "",
  4680. VerifyNumber: token,
  4681. }
  4682. service.CreateHisPsn(psn)
  4683. c.ServeSuccessJSON(map[string]interface{}{
  4684. "patient": patient,
  4685. "number": token,
  4686. })
  4687. }
  4688. } else {
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4690. return
  4691. }
  4692. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4693. idNo := c.GetString("idNo")
  4694. userName := c.GetString("userName")
  4695. ecToken := c.GetString("ecToken")
  4696. insuOrg := c.GetString("insuOrg")
  4697. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4698. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4699. var res ResultTwo
  4700. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4701. utils.ErrorLog("解析失败:%v", err)
  4702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4703. return
  4704. }
  4705. if res.Infcode == 0 {
  4706. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4707. if err == gorm.ErrRecordNotFound {
  4708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4709. return
  4710. } else if err != nil {
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4712. return
  4713. } else {
  4714. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4715. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4716. infoStr := string(Iinfos)
  4717. idetinfoStr := string(Idetinfos)
  4718. psn := &models.HisPsn{
  4719. PsnNo: res.Output.Baseinfo.PsnNo,
  4720. PatientId: patient.ID,
  4721. Certno: res.Output.Baseinfo.Certno,
  4722. Gend: res.Output.Baseinfo.Gend,
  4723. Naty: res.Output.Baseinfo.Naty,
  4724. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4725. PsnName: res.Output.Baseinfo.PsnName,
  4726. Idetinfo: idetinfoStr,
  4727. Insuinfo: infoStr,
  4728. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4729. CardInfo: "",
  4730. VerifyNumber: ecToken,
  4731. InsuplcAdmdvs: insuOrg,
  4732. }
  4733. service.CreateHisPsn(psn)
  4734. c.ServeSuccessJSON(map[string]interface{}{
  4735. "patient": patient,
  4736. "number": ecToken,
  4737. })
  4738. }
  4739. } else {
  4740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4741. return
  4742. }
  4743. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4744. res := c.GetoleInfo()
  4745. if res.Infcode == 0 {
  4746. var result string
  4747. if res.Output.MdtrtCertType == "01" {
  4748. 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)
  4749. } else if res.Output.MdtrtCertType == "02" {
  4750. 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)
  4751. } else if res.Output.MdtrtCertType == "03" {
  4752. 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)
  4753. }
  4754. var dat map[string]interface{}
  4755. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4756. fmt.Println(dat)
  4757. } else {
  4758. fmt.Println(err)
  4759. }
  4760. userJSONBytes, _ := json.Marshal(dat)
  4761. var res2 ResultTwo
  4762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4763. utils.ErrorLog("解析失败:%v", err)
  4764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4765. return
  4766. }
  4767. if res2.Infcode == 0 {
  4768. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4769. if err == gorm.ErrRecordNotFound {
  4770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4771. return
  4772. } else if err != nil {
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4774. return
  4775. } else {
  4776. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4777. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4778. infoStr := string(Iinfos)
  4779. idetinfoStr := string(Idetinfos)
  4780. var rf []*ResultFive
  4781. json.Unmarshal([]byte(infoStr), &rf)
  4782. var insutypes []*ResultFive
  4783. var insutype string
  4784. var is390 int = 0
  4785. var is310 int = 0
  4786. //var insuplc_admdvs string
  4787. for _, item := range rf {
  4788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4789. insutypes = append(insutypes, item)
  4790. }
  4791. }
  4792. if len(insutypes) == 1 {
  4793. insutype = insutypes[0].Insutype
  4794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4795. } else {
  4796. for _, i := range insutypes {
  4797. if i.Insutype == "390" {
  4798. is390 = 1
  4799. }
  4800. if i.Insutype == "310" {
  4801. is310 = 1
  4802. }
  4803. }
  4804. }
  4805. if is390 == 1 {
  4806. insutype = "390"
  4807. }
  4808. if is310 == 1 {
  4809. insutype = "310"
  4810. }
  4811. if len(insutypes) == 0 {
  4812. insutype = "310"
  4813. }
  4814. psn := &models.HisPsn{
  4815. PsnNo: res2.Output.Baseinfo.PsnNo,
  4816. PatientId: patient.ID,
  4817. Certno: res2.Output.Baseinfo.Certno,
  4818. Gend: res2.Output.Baseinfo.Gend,
  4819. Naty: res2.Output.Baseinfo.Naty,
  4820. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4821. PsnName: res2.Output.Baseinfo.PsnName,
  4822. Idetinfo: idetinfoStr,
  4823. Insuinfo: infoStr,
  4824. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4825. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4826. VerifyNumber: res.Output.EcToken,
  4827. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4828. }
  4829. service.CreateHisPsn(psn)
  4830. c.ServeSuccessJSON(map[string]interface{}{
  4831. "patient": patient,
  4832. "number": res.Output.CardNo,
  4833. "insutype": insutype,
  4834. })
  4835. }
  4836. } else {
  4837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4838. return
  4839. }
  4840. } else {
  4841. c.ServeSuccessJSON(map[string]interface{}{
  4842. "failed_code": -10,
  4843. "msg": res.ErrMsg,
  4844. })
  4845. }
  4846. } else {
  4847. //if initFlag == 0 {
  4848. // c.TestGetBasBaseInit()
  4849. //}
  4850. //token := c.GetEleBaseInfo()
  4851. //token = Remove0000(token)
  4852. type ELeData struct {
  4853. Code string `json:"code"`
  4854. Data struct {
  4855. Aac002 string `json:"aac002"`
  4856. Aaz500 string `json:"aaz500"`
  4857. ActCardNo string `json:"actCardNo"`
  4858. Bab520 string `json:"bab520"`
  4859. Bkz543 string `json:"bkz543"`
  4860. BusinessType string `json:"businessType"`
  4861. CertfCodg string `json:"certfCodg"`
  4862. EcIndexNo string `json:"ecIndexNo"`
  4863. EcToken string `json:"ecToken"`
  4864. ID0000 string `json:"id0000"`
  4865. IDNo string `json:"idNo"`
  4866. IDType string `json:"idType"`
  4867. Idcode string `json:"idcode"`
  4868. IdentityToken string `json:"identity_token"`
  4869. InsuOrg string `json:"insuOrg"`
  4870. OfficeID string `json:"officeId"`
  4871. OfficeName string `json:"officeName"`
  4872. OperatorID string `json:"operatorId"`
  4873. OperatorName string `json:"operatorName"`
  4874. OrgID string `json:"orgId"`
  4875. UserName string `json:"userName"`
  4876. } `json:"data"`
  4877. Infno interface{} `json:"infno"`
  4878. Message string `json:"message"`
  4879. OrgID string `json:"orgId"`
  4880. TransType string `json:"transType"`
  4881. }
  4882. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4883. fmt.Println(result)
  4884. outPutInfo := Remove0000(result)
  4885. fmt.Println(outPutInfo)
  4886. var ele ELeData
  4887. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4888. if err != nil {
  4889. utils.ErrorLog("解析失败:%v", err)
  4890. }
  4891. token := ele.Data.EcToken
  4892. var result2 string
  4893. var requestLog2 string
  4894. if len(token) > 0 {
  4895. if strings.Contains(ele.Data.IDNo, "HKG") {
  4896. 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)
  4897. } else {
  4898. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4899. }
  4900. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4901. var res ResultTwo
  4902. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4903. utils.ErrorLog("解析失败:%v", err)
  4904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4905. return
  4906. }
  4907. if res.Infcode == 0 {
  4908. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4909. if err == gorm.ErrRecordNotFound {
  4910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4911. return
  4912. } else if err != nil {
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4914. return
  4915. } else {
  4916. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4917. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4918. infoStr := string(Iinfos)
  4919. idetinfoStr := string(Idetinfos)
  4920. psn := &models.HisPsn{
  4921. PsnNo: res.Output.Baseinfo.PsnNo,
  4922. PatientId: patient.ID,
  4923. Certno: res.Output.Baseinfo.Certno,
  4924. Gend: res.Output.Baseinfo.Gend,
  4925. Naty: res.Output.Baseinfo.Naty,
  4926. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4927. PsnName: res.Output.Baseinfo.PsnName,
  4928. Idetinfo: idetinfoStr,
  4929. Insuinfo: infoStr,
  4930. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4931. CardInfo: "",
  4932. VerifyNumber: token,
  4933. }
  4934. service.CreateHisPsn(psn)
  4935. c.ServeSuccessJSON(map[string]interface{}{
  4936. "msg": "读取成功",
  4937. })
  4938. }
  4939. } else {
  4940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4941. return
  4942. }
  4943. } else {
  4944. c.ServeSuccessJSON(map[string]interface{}{
  4945. "failed_code": -10,
  4946. "msg": "读取失败",
  4947. })
  4948. }
  4949. }
  4950. }
  4951. func (c *HisApiController) ReadEleFace() {
  4952. admin_user_id, _ := c.GetInt64("admin_user_id")
  4953. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4954. adminUser := c.GetAdminUserInfo()
  4955. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4956. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4957. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4958. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4959. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4960. if len(tokens) > 0 {
  4961. c.ServeSuccessJSON(map[string]interface{}{
  4962. "msg": "读取成功",
  4963. })
  4964. } else {
  4965. c.ServeSuccessJSON(map[string]interface{}{
  4966. "failed_code": -10,
  4967. "msg": "读取失败",
  4968. })
  4969. }
  4970. }
  4971. }
  4972. func (c *HisApiController) Get9001() {
  4973. adminUser := c.GetAdminUserInfo()
  4974. admin_user_id, _ := c.GetInt64("admin_user_id")
  4975. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4976. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4977. if miConfig.MdtrtareaAdmvs == "350500" {
  4978. service.GetFjAuthorizationInfo(miConfig.Code)
  4979. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4980. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4981. var dat map[string]interface{}
  4982. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4983. fmt.Println(dat)
  4984. } else {
  4985. fmt.Println(err)
  4986. }
  4987. userJSONBytes, _ := json.Marshal(dat)
  4988. var res models.Result9001
  4989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4990. utils.ErrorLog("解析失败:%v", err)
  4991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. return
  4993. }
  4994. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4995. fmt.Println(miConfig.SecretKey)
  4996. var res models.Result9001Two
  4997. 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 +
  4998. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4999. resp, requestErr := http.Get(api)
  5000. if requestErr != nil {
  5001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5002. return
  5003. }
  5004. body, ioErr := ioutil.ReadAll(resp.Body)
  5005. if ioErr != nil {
  5006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5008. return
  5009. }
  5010. var respJSON map[string]interface{}
  5011. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. return
  5015. }
  5016. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5017. if status == "0" {
  5018. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5019. c.ServeSuccessJSON(map[string]interface{}{
  5020. "failed_code": -10,
  5021. "msg": err_msg,
  5022. })
  5023. return
  5024. }
  5025. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5026. result, _ := json.Marshal(respJSON)
  5027. fmt.Println("log")
  5028. fmt.Println(string(result))
  5029. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5030. utils.ErrorLog("解析失败:%v", err)
  5031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5032. return
  5033. }
  5034. if res.Infcode == 0 {
  5035. sign := models.HisSignIn{
  5036. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5037. SignNo: res.Output.Signinoutb.SignNo,
  5038. SignTime: "",
  5039. Ctime: time.Now().Unix(),
  5040. Mtime: time.Now().Unix(),
  5041. Status: 1,
  5042. InputLog: "",
  5043. OutputLog: "",
  5044. FixmedinsCode: miConfig.Code,
  5045. }
  5046. err := service.CreateSignIn(&sign)
  5047. if err == nil {
  5048. c.ServeSuccessJSON(map[string]interface{}{
  5049. "msg": "签到成功",
  5050. })
  5051. }
  5052. } else {
  5053. c.ServeSuccessJSON(map[string]interface{}{
  5054. "failed_code": -10,
  5055. "msg": res.ErrMsg,
  5056. })
  5057. return
  5058. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5059. //return
  5060. }
  5061. } else {
  5062. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5063. var dat map[string]interface{}
  5064. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5065. fmt.Println(dat)
  5066. } else {
  5067. fmt.Println(err)
  5068. }
  5069. userJSONBytes, _ := json.Marshal(dat)
  5070. var res models.Result9001
  5071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5072. utils.ErrorLog("解析失败:%v", err)
  5073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5074. return
  5075. }
  5076. if res.Infcode == 0 {
  5077. sign := models.HisSignIn{
  5078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5079. SignNo: res.Output.Signinoutb.SignNo,
  5080. SignTime: res.Output.Signinoutb.SignTime,
  5081. Ctime: time.Now().Unix(),
  5082. Mtime: time.Now().Unix(),
  5083. Status: 1,
  5084. InputLog: "",
  5085. OutputLog: "",
  5086. FixmedinsCode: miConfig.Code,
  5087. }
  5088. err := service.CreateSignIn(&sign)
  5089. if err == nil {
  5090. c.ServeSuccessJSON(map[string]interface{}{
  5091. "msg": "签到成功",
  5092. })
  5093. }
  5094. }
  5095. }
  5096. }
  5097. 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) {
  5098. var res Result3101
  5099. adminUser := c.GetAdminUserInfo()
  5100. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5101. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5102. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5103. //record_time := c.GetString("record_time")
  5104. //trig_scen := c.GetString("trig_scen")
  5105. timeLayout := "2006-01-02"
  5106. loc, _ := time.LoadLocation("Local")
  5107. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5108. if err != nil {
  5109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5110. return res
  5111. }
  5112. recordDateTime := theTime.Unix()
  5113. var patientPrescription models.HisPrescriptionInfo
  5114. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5115. //if patientPrescription.ID == 0 {
  5116. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5117. //}
  5118. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5119. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5120. //
  5121. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5122. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5123. var pp models.PublicParams
  5124. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5125. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5126. pp.FixmedinsName = miConfig.OrgName
  5127. pp.FixmedinsCode = miConfig.Code
  5128. pp.RequestUrl = miConfig.Url
  5129. pp.Cainfo = miConfig.Cainfo
  5130. pp.SecretKey = miConfig.SecretKey
  5131. pp.AccessKey = miConfig.AccessKey
  5132. pp.OpterName = roles.UserName
  5133. var config []*models.HisXtDiagnoseConfig
  5134. for _, item := range diagnosis_ids {
  5135. id, _ := strconv.ParseInt(item, 10, 64)
  5136. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5137. config = append(config, &diagnosisConfig)
  5138. }
  5139. var pd models.PatientDtos
  5140. pd.PatnID = his.PsnNo
  5141. pd.PatnName = his.Name
  5142. pd.Gend = his.Gend
  5143. pd.Brdy = his.Brdy
  5144. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5145. pd.CurrMdtrtID = his.Number
  5146. var fed models.FsiEncounterDtos
  5147. fed.MdtrtID = his.Number
  5148. fed.MedinsID = miConfig.Code
  5149. fed.MedinsName = miConfig.OrgName
  5150. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5151. fed.MedMdtrtType = "1"
  5152. fed.MedinsType = "1"
  5153. fed.MedinsLv = "11"
  5154. tm := time.Unix(his.RecordDate, 0)
  5155. s_tm := tm.Format("2006-01-02 15:04:05")
  5156. fed.AdmDate = s_tm
  5157. fed.DscgDate = s_tm
  5158. fed.DscgMainDiseCodg = config[0].CountryCode
  5159. fed.DscgMainDiseName = config[0].CountryContentName
  5160. //诊断信息
  5161. var fdds []*models.FsiDiagnoseDtos
  5162. for index, item := range config {
  5163. if index == 0 {
  5164. var fdd models.FsiDiagnoseDtos
  5165. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5166. fdd.InoutDiseType = "1"
  5167. fdd.MaindiseFlag = "1"
  5168. fdd.DiseDate = s_tm
  5169. fdd.DiasSrtNo = "1"
  5170. fdd.DiseName = item.CountryContentName
  5171. fdd.DiseCodg = item.CountryCode
  5172. fdds = append(fdds, &fdd)
  5173. } else {
  5174. var fdd models.FsiDiagnoseDtos
  5175. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5176. fdd.InoutDiseType = "1"
  5177. fdd.MaindiseFlag = "1"
  5178. fdd.DiseDate = s_tm
  5179. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5180. fdd.DiseName = item.CountryContentName
  5181. fdd.DiseCodg = item.CountryCode
  5182. fdds = append(fdds, &fdd)
  5183. }
  5184. }
  5185. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5186. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5187. fed.AdmDeptName = department.Name
  5188. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5189. fed.DscgDeptName = department.Name
  5190. fed.MedMdtrtType = "1"
  5191. fed.MedType = "11"
  5192. //if his.Insutype == "390" {
  5193. // fed.MedType = "1402"
  5194. //} else {
  5195. // fed.MedType = "9933"
  5196. //}
  5197. var orders []*models.FsiOrderDtos
  5198. if trig_scen == "2" {
  5199. //处方医嘱信息
  5200. for _, item := range prescriptions {
  5201. for _, subItem := range item.HisDoctorAdviceInfo {
  5202. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5203. var order models.FsiOrderDtos
  5204. order.RxID = strconv.FormatInt(item.ID, 10)
  5205. order.Rxno = strconv.FormatInt(item.ID, 10)
  5206. order.LongDrordFlag = "0"
  5207. order.HilistType = "1"
  5208. order.ChrgType = "1"
  5209. order.DrordBhvr = "-"
  5210. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5211. order.HosplistName = subItem.BaseDrugLib.DrugName
  5212. order.HilistLv = "1"
  5213. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5214. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5215. order.HosplistName = subItem.BaseDrugLib.DrugName
  5216. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5217. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5218. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5219. order.OwnpayAmt = ""
  5220. order.SelfpayAmt = ""
  5221. order.Spec = ""
  5222. order.SpecUnt = ""
  5223. order.DrordBegnDate = s_tm
  5224. order.DrordStopDate = ""
  5225. order.DrordDrCodg = doctor_info.DoctorNumber
  5226. order.DrordDeptName = department.Name
  5227. order.DrordDeptCodg = department.Number
  5228. order.DrordDrName = doctor_info.UserName
  5229. order.DrordDrProfttl = "234"
  5230. order.CurrDrordFlag = "1"
  5231. orders = append(orders, &order)
  5232. }
  5233. }
  5234. for _, subItem := range item.HisPrescriptionProject {
  5235. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5236. var order models.FsiOrderDtos
  5237. order.RxID = strconv.FormatInt(item.ID, 10)
  5238. order.Rxno = strconv.FormatInt(item.ID, 10)
  5239. order.LongDrordFlag = "0"
  5240. order.HilistType = "1"
  5241. order.ChrgType = "1"
  5242. order.DrordBhvr = "-"
  5243. order.HilistCode = subItem.HisProject.MedicalCode
  5244. order.HosplistName = subItem.HisProject.ProjectName
  5245. order.HilistLv = "1"
  5246. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5247. order.HosplistCode = subItem.HisProject.MedicalCode
  5248. order.HosplistName = subItem.HisProject.ProjectName
  5249. order.Cnt = subItem.Count
  5250. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5252. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5253. order.OwnpayAmt = ""
  5254. order.SelfpayAmt = ""
  5255. order.Spec = ""
  5256. order.SpecUnt = ""
  5257. order.DrordBegnDate = s_tm
  5258. order.DrordStopDate = ""
  5259. order.DrordDrCodg = doctor_info.DoctorNumber
  5260. order.DrordDeptName = department.Name
  5261. order.DrordDeptCodg = department.Number
  5262. order.DrordDrName = doctor_info.UserName
  5263. order.DrordDrProfttl = "234"
  5264. order.CurrDrordFlag = "1"
  5265. orders = append(orders, &order)
  5266. }
  5267. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5268. var order models.FsiOrderDtos
  5269. order.RxID = strconv.FormatInt(item.ID, 10)
  5270. order.Rxno = strconv.FormatInt(item.ID, 10)
  5271. order.LongDrordFlag = "0"
  5272. order.HilistType = "1"
  5273. order.ChrgType = "1"
  5274. order.DrordBhvr = "-"
  5275. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5276. order.HosplistName = subItem.GoodInfo.GoodName
  5277. order.HilistLv = "1"
  5278. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5279. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5280. order.HosplistName = subItem.GoodInfo.GoodName
  5281. order.Cnt = subItem.Count
  5282. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5284. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5285. order.OwnpayAmt = ""
  5286. order.SelfpayAmt = ""
  5287. order.Spec = ""
  5288. order.SpecUnt = ""
  5289. order.DrordBegnDate = s_tm
  5290. order.DrordStopDate = ""
  5291. order.DrordDrCodg = doctor_info.DoctorNumber
  5292. order.DrordDeptName = department.Name
  5293. order.DrordDeptCodg = department.Number
  5294. order.DrordDrName = doctor_info.UserName
  5295. order.DrordDrProfttl = "234"
  5296. order.CurrDrordFlag = "1"
  5297. orders = append(orders, &order)
  5298. }
  5299. }
  5300. }
  5301. //处方医嘱信息
  5302. }
  5303. fed.MatnStas = "0"
  5304. fed.MedfeeSumamt = "0"
  5305. fed.OwnpayAmt = "0"
  5306. fed.SelfpayAmt = "0"
  5307. fed.AcctPayamt = "0"
  5308. fed.MaAmt = "0"
  5309. fed.HifpPayamt = "0"
  5310. fed.SetlTotlnum = "1"
  5311. fed.Insutype = his.Insutype
  5312. fed.ReimFlag = "0"
  5313. fed.OutSetlFlag = "0"
  5314. var fopd []*models.FsiOperationDtosData
  5315. data := make(map[string]interface{})
  5316. data["fed"] = fed
  5317. data["fdd"] = fdds
  5318. data["fod"] = orders
  5319. data["pd"] = pd
  5320. data["pp"] = pp
  5321. data["fopd"] = fopd
  5322. data["trig_scen"] = trig_scen
  5323. fmt.Println(data)
  5324. fmt.Println(fed)
  5325. fmt.Println(fdds)
  5326. fmt.Println(orders)
  5327. fmt.Println(pd)
  5328. fmt.Println(pp)
  5329. fmt.Println(fopd)
  5330. client := &http.Client{}
  5331. bytesData, _ := json.Marshal(data)
  5332. var req *http.Request
  5333. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5334. if miConfig.MdtrtareaAdmvs == "320921" {
  5335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5336. } else {
  5337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5338. }
  5339. resp, _ := client.Do(req)
  5340. defer resp.Body.Close()
  5341. body, ioErr := ioutil.ReadAll(resp.Body)
  5342. if ioErr != nil {
  5343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. return res
  5346. }
  5347. var respJSON map[string]interface{}
  5348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5351. return res
  5352. }
  5353. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5354. fmt.Println(respJSON)
  5355. result, _ := json.Marshal(respJSON)
  5356. fmt.Println(result)
  5357. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5358. utils.ErrorLog("解析失败:%v", err)
  5359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5360. return res
  5361. }
  5362. return res
  5363. } else {
  5364. //if miConfig.MdtrtareaAdmvs == "441202" {
  5365. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5366. saveLog(output, input, "3101", "事前")
  5367. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5368. utils.ErrorLog("解析失败:%v", err)
  5369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5370. return
  5371. }
  5372. return res
  5373. //}
  5374. }
  5375. }
  5376. 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) {
  5377. adminUser := c.GetAdminUserInfo()
  5378. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5379. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5380. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5381. //record_time := c.GetString("record_time")
  5382. //trig_scen := c.GetString("trig_scen")
  5383. timeLayout := "2006-01-02"
  5384. loc, _ := time.LoadLocation("Local")
  5385. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5386. if err != nil {
  5387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5388. return res
  5389. }
  5390. recordDateTime := theTime.Unix()
  5391. var patientPrescription models.HisPrescriptionInfo
  5392. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5393. if patientPrescription.ID == 0 {
  5394. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5395. }
  5396. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5397. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5398. //
  5399. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5400. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5401. var pp models.PublicParams
  5402. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5403. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5404. pp.FixmedinsName = miConfig.OrgName
  5405. pp.FixmedinsCode = miConfig.Code
  5406. pp.RequestUrl = miConfig.Url
  5407. pp.Cainfo = miConfig.Cainfo
  5408. pp.SecretKey = miConfig.SecretKey
  5409. pp.AccessKey = miConfig.AccessKey
  5410. pp.OpterName = roles.UserName
  5411. var config []*models.HisXtDiagnoseConfig
  5412. for _, item := range diagnosis_ids {
  5413. id, _ := strconv.ParseInt(item, 10, 64)
  5414. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5415. config = append(config, &diagnosisConfig)
  5416. }
  5417. var pd models.PatientDtos
  5418. pd.PatnID = his.PsnNo
  5419. pd.PatnName = his.Name
  5420. pd.Gend = his.Gend
  5421. pd.Brdy = his.Brdy
  5422. pd.Poolarea = his.InsuplcAdmdvs
  5423. pd.CurrMdtrtID = his.Number
  5424. var fed models.FsiEncounterDtos
  5425. fed.MdtrtID = his.Number
  5426. fed.MedinsID = miConfig.Code
  5427. fed.MedinsName = miConfig.OrgName
  5428. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5429. fed.MedMdtrtType = "1"
  5430. fed.MedinsType = "1"
  5431. fed.MedinsLv = "11"
  5432. tm := time.Unix(his.RecordDate, 0)
  5433. s_tm := tm.Format("2006-01-02 15:04:05")
  5434. fed.AdmDate = s_tm
  5435. fed.DscgDate = s_tm
  5436. fed.DscgMainDiseCodg = config[0].CountryCode
  5437. fed.DscgMainDiseName = config[0].CountryContentName
  5438. //诊断信息
  5439. var fdds []*models.FsiDiagnoseDtos
  5440. for index, item := range config {
  5441. if index == 0 {
  5442. var fdd models.FsiDiagnoseDtos
  5443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5444. fdd.InoutDiseType = "1"
  5445. fdd.MaindiseFlag = "1"
  5446. fdd.DiseDate = s_tm
  5447. fdd.DiasSrtNo = "1"
  5448. fdd.DiseName = item.CountryContentName
  5449. fdd.DiseCodg = item.CountryCode
  5450. fdds = append(fdds, &fdd)
  5451. } else {
  5452. var fdd models.FsiDiagnoseDtos
  5453. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5454. fdd.InoutDiseType = "1"
  5455. fdd.MaindiseFlag = "1"
  5456. fdd.DiseDate = s_tm
  5457. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5458. fdd.DiseName = item.CountryContentName
  5459. fdd.DiseCodg = item.CountryCode
  5460. fdds = append(fdds, &fdd)
  5461. }
  5462. }
  5463. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5464. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5465. fed.AdmDeptName = department.Name
  5466. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5467. fed.DscgDeptName = department.Name
  5468. fed.MedMdtrtType = "1"
  5469. fed.MedType = "11"
  5470. //if his.Insutype == "390" {
  5471. // fed.MedType = "1402"
  5472. //} else {
  5473. // fed.MedType = "9933"
  5474. //}
  5475. var orders []*models.FsiOrderDtos
  5476. if trig_scen == "2" {
  5477. //处方医嘱信息
  5478. for _, item := range prescriptions {
  5479. for _, subItem := range item.HisDoctorAdviceInfo {
  5480. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5481. var order models.FsiOrderDtos
  5482. order.RxID = strconv.FormatInt(item.ID, 10)
  5483. order.Rxno = strconv.FormatInt(item.ID, 10)
  5484. order.LongDrordFlag = "0"
  5485. order.HilistType = "1"
  5486. order.ChrgType = "1"
  5487. order.DrordBhvr = "-"
  5488. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5489. order.HosplistName = subItem.BaseDrugLib.DrugName
  5490. order.HilistLv = "1"
  5491. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5492. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5493. order.HosplistName = subItem.BaseDrugLib.DrugName
  5494. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5495. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5496. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5497. order.OwnpayAmt = ""
  5498. order.SelfpayAmt = ""
  5499. order.Spec = ""
  5500. order.SpecUnt = ""
  5501. order.DrordBegnDate = s_tm
  5502. order.DrordStopDate = ""
  5503. order.DrordDrCodg = doctor_info.DoctorNumber
  5504. order.DrordDeptName = department.Name
  5505. order.DrordDeptCodg = department.Number
  5506. order.DrordDrName = doctor_info.UserName
  5507. order.DrordDrProfttl = "234"
  5508. order.CurrDrordFlag = "1"
  5509. orders = append(orders, &order)
  5510. }
  5511. }
  5512. for _, subItem := range item.HisPrescriptionProject {
  5513. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5514. var order models.FsiOrderDtos
  5515. order.RxID = strconv.FormatInt(item.ID, 10)
  5516. order.Rxno = strconv.FormatInt(item.ID, 10)
  5517. order.LongDrordFlag = "0"
  5518. order.HilistType = "1"
  5519. order.ChrgType = "1"
  5520. order.DrordBhvr = "-"
  5521. order.HilistCode = subItem.HisProject.MedicalCode
  5522. order.HosplistName = subItem.HisProject.ProjectName
  5523. order.HilistLv = "1"
  5524. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5525. order.HosplistCode = subItem.HisProject.MedicalCode
  5526. order.HosplistName = subItem.HisProject.ProjectName
  5527. order.Cnt = subItem.Count
  5528. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5529. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5530. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5531. order.OwnpayAmt = ""
  5532. order.SelfpayAmt = ""
  5533. order.Spec = ""
  5534. order.SpecUnt = ""
  5535. order.DrordBegnDate = s_tm
  5536. order.DrordStopDate = ""
  5537. order.DrordDrCodg = doctor_info.DoctorNumber
  5538. order.DrordDeptName = department.Name
  5539. order.DrordDeptCodg = department.Number
  5540. order.DrordDrName = doctor_info.UserName
  5541. order.DrordDrProfttl = "234"
  5542. order.CurrDrordFlag = "1"
  5543. orders = append(orders, &order)
  5544. }
  5545. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5546. var order models.FsiOrderDtos
  5547. order.RxID = strconv.FormatInt(item.ID, 10)
  5548. order.Rxno = strconv.FormatInt(item.ID, 10)
  5549. order.LongDrordFlag = "0"
  5550. order.HilistType = "1"
  5551. order.ChrgType = "1"
  5552. order.DrordBhvr = "-"
  5553. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5554. order.HosplistName = subItem.GoodInfo.GoodName
  5555. order.HilistLv = "1"
  5556. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5557. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5558. order.HosplistName = subItem.GoodInfo.GoodName
  5559. order.Cnt = subItem.Count
  5560. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5561. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5562. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5563. order.OwnpayAmt = ""
  5564. order.SelfpayAmt = ""
  5565. order.Spec = ""
  5566. order.SpecUnt = ""
  5567. order.DrordBegnDate = s_tm
  5568. order.DrordStopDate = ""
  5569. order.DrordDrCodg = doctor_info.DoctorNumber
  5570. order.DrordDeptName = department.Name
  5571. order.DrordDeptCodg = department.Number
  5572. order.DrordDrName = doctor_info.UserName
  5573. order.DrordDrProfttl = "234"
  5574. order.CurrDrordFlag = "1"
  5575. orders = append(orders, &order)
  5576. }
  5577. }
  5578. }
  5579. //处方医嘱信息
  5580. }
  5581. fed.MatnStas = "0"
  5582. fed.MedfeeSumamt = "0"
  5583. fed.OwnpayAmt = "0"
  5584. fed.SelfpayAmt = "0"
  5585. fed.AcctPayamt = "0"
  5586. fed.MaAmt = "0"
  5587. fed.HifpPayamt = "0"
  5588. fed.SetlTotlnum = "1"
  5589. fed.Insutype = his.Insutype
  5590. fed.ReimFlag = "0"
  5591. fed.OutSetlFlag = "0"
  5592. var fopd []*models.FsiOperationDtosData
  5593. data := make(map[string]interface{})
  5594. data["fed"] = fed
  5595. data["fdd"] = fdds
  5596. data["fod"] = orders
  5597. data["pd"] = pd
  5598. data["pp"] = pp
  5599. data["fopd"] = fopd
  5600. data["trig_scen"] = trig_scen
  5601. fmt.Println(data)
  5602. fmt.Println(fed)
  5603. fmt.Println(fdds)
  5604. fmt.Println(orders)
  5605. fmt.Println(pd)
  5606. fmt.Println(pp)
  5607. fmt.Println(fopd)
  5608. client := &http.Client{}
  5609. bytesData, _ := json.Marshal(data)
  5610. var req *http.Request
  5611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5612. if miConfig.MdtrtareaAdmvs == "320921" {
  5613. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5614. } else {
  5615. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5616. }
  5617. resp, _ := client.Do(req)
  5618. defer resp.Body.Close()
  5619. body, ioErr := ioutil.ReadAll(resp.Body)
  5620. if ioErr != nil {
  5621. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5623. return res
  5624. }
  5625. var respJSON map[string]interface{}
  5626. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5627. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5629. return res
  5630. }
  5631. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5632. fmt.Println(respJSON)
  5633. result, _ := json.Marshal(respJSON)
  5634. fmt.Println(result)
  5635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5636. utils.ErrorLog("解析失败:%v", err)
  5637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5638. return res
  5639. }
  5640. return res
  5641. } else {
  5642. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5643. saveLog(output, input, "3101", "事前")
  5644. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5645. utils.ErrorLog("解析失败:%v", err)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return
  5648. }
  5649. return res
  5650. }
  5651. return res
  5652. }
  5653. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5654. ////patient_id, _ := c.GetInt64("patient_id")
  5655. //order_id, _ := c.GetInt64("order_id")
  5656. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5657. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5658. //trig_scen := c.GetString("trig_scen")
  5659. adminUser := c.GetAdminUserInfo()
  5660. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5661. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5662. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5663. record_time := c.GetString("record_time")
  5664. order, _ := service.GetHisOrderByID(order_id)
  5665. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5666. timeLayout := "2006-01-02"
  5667. loc, _ := time.LoadLocation("Local")
  5668. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5669. if err != nil {
  5670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5671. return
  5672. }
  5673. recordDateTime := theTime.Unix()
  5674. var patientPrescription models.HisPrescriptionInfo
  5675. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5676. if patientPrescription.ID == 0 {
  5677. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5678. }
  5679. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5680. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5681. //
  5682. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5683. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5684. var pp models.PublicParams
  5685. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5686. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5687. pp.FixmedinsName = miConfig.OrgName
  5688. pp.FixmedinsCode = miConfig.Code
  5689. pp.RequestUrl = miConfig.Url
  5690. pp.Cainfo = miConfig.Cainfo
  5691. pp.SecretKey = miConfig.SecretKey
  5692. pp.AccessKey = miConfig.AccessKey
  5693. pp.OpterName = roles.UserName
  5694. var config []*models.HisXtDiagnoseConfig
  5695. for _, item := range diagnosis_ids {
  5696. id, _ := strconv.ParseInt(item, 10, 64)
  5697. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5698. config = append(config, &diagnosisConfig)
  5699. }
  5700. var pd models.PatientDtos
  5701. pd.PatnID = his.PsnNo
  5702. pd.PatnName = his.Name
  5703. pd.Gend = his.Gend
  5704. pd.Brdy = psn_info.Brdy
  5705. pd.Poolarea = his.InsuplcAdmdvs
  5706. pd.CurrMdtrtID = his.Number
  5707. var fed models.FsiEncounterDtos
  5708. fed.MdtrtID = his.Number
  5709. fed.MedinsID = miConfig.Code
  5710. fed.MedinsName = miConfig.OrgName
  5711. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5712. fed.MedMdtrtType = "1"
  5713. fed.MedinsType = "1"
  5714. fed.MedinsLv = "11"
  5715. tm := time.Unix(his.RecordDate, 0)
  5716. s_tm := tm.Format("2006-01-02 15:04:05")
  5717. fed.AdmDate = s_tm
  5718. fed.DscgDate = s_tm
  5719. fed.DscgMainDiseCodg = config[0].CountryCode
  5720. fed.DscgMainDiseName = config[0].CountryContentName
  5721. //诊断信息
  5722. var fdds []*models.FsiDiagnoseDtos
  5723. for index, item := range config {
  5724. if index == 0 {
  5725. var fdd models.FsiDiagnoseDtos
  5726. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5727. fdd.InoutDiseType = "1"
  5728. fdd.MaindiseFlag = "1"
  5729. fdd.DiseDate = s_tm
  5730. fdd.DiasSrtNo = "1"
  5731. fdd.DiseName = item.CountryContentName
  5732. fdd.DiseCodg = item.CountryCode
  5733. fdds = append(fdds, &fdd)
  5734. } else {
  5735. var fdd models.FsiDiagnoseDtos
  5736. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5737. fdd.InoutDiseType = "1"
  5738. fdd.MaindiseFlag = "1"
  5739. fdd.DiseDate = s_tm
  5740. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5741. fdd.DiseName = item.CountryContentName
  5742. fdd.DiseCodg = item.CountryCode
  5743. fdds = append(fdds, &fdd)
  5744. }
  5745. }
  5746. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5747. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5748. fed.AdmDeptName = department.Name
  5749. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5750. fed.DscgDeptName = department.Name
  5751. fed.MedType = order.MedType
  5752. //处方医嘱信息
  5753. var orders []*models.FsiOrderDtos
  5754. //for _, item := range prescriptions {
  5755. // for _, subItem := range item.HisDoctorAdviceInfo {
  5756. // var order models.FsiOrderDtos
  5757. // order.RxID = strconv.FormatInt(item.ID, 10)
  5758. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5759. // order.LongDrordFlag = "0"
  5760. // order.HilistType = "1"
  5761. // order.ChrgType = "1"
  5762. // order.DrordBhvr = "-"
  5763. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5764. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5765. // order.HilistLv = "1"
  5766. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5767. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5768. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5769. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5770. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5771. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5772. // order.OwnpayAmt = ""
  5773. // order.SelfpayAmt = ""
  5774. // order.Spec = ""
  5775. // order.SpecUnt = ""
  5776. // order.DrordBegnDate = s_tm
  5777. // order.DrordStopDate = ""
  5778. // order.DrordDrCodg = "1"
  5779. // order.DrordDeptName = department.Name
  5780. // order.DrordDrCodg = "1"
  5781. // order.DrordDrName = doctor_info.UserName
  5782. // order.DrordDrProfttl = ""
  5783. // order.CurrDrordFlag = "1"
  5784. // orders = append(orders, &order)
  5785. // }
  5786. // for _, subItem := range item.HisPrescriptionProject {
  5787. // if subItem.Type == 2 {
  5788. // var order models.FsiOrderDtos
  5789. // order.RxID = strconv.FormatInt(item.ID, 10)
  5790. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5791. // order.LongDrordFlag = "0"
  5792. // order.HilistType = "1"
  5793. // order.ChrgType = "1"
  5794. // order.DrordBhvr = "-"
  5795. // order.HilistCode = subItem.HisProject.MedicalCode
  5796. // order.HosplistName = subItem.HisProject.ProjectName
  5797. // order.HilistLv = "1"
  5798. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5799. // order.HosplistCode = subItem.HisProject.MedicalCode
  5800. // order.HosplistName = subItem.HisProject.ProjectName
  5801. // order.Cnt = subItem.Count
  5802. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5803. //
  5804. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5805. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5806. // order.OwnpayAmt = ""
  5807. // order.SelfpayAmt = ""
  5808. // order.Spec = ""
  5809. // order.SpecUnt = ""
  5810. // order.DrordBegnDate = s_tm
  5811. // order.DrordStopDate = ""
  5812. // order.DrordDrCodg = "1"
  5813. // order.DrordDeptName = department.Name
  5814. // order.DrordDrCodg = "1"
  5815. // order.DrordDrName = doctor_info.UserName
  5816. // order.DrordDrProfttl = ""
  5817. // order.CurrDrordFlag = "1"
  5818. // orders = append(orders, &order)
  5819. //
  5820. // }
  5821. // if subItem.Type == 3 {
  5822. //
  5823. // var order models.FsiOrderDtos
  5824. // order.RxID = strconv.FormatInt(item.ID, 10)
  5825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5826. // order.LongDrordFlag = "0"
  5827. // order.HilistType = "1"
  5828. // order.ChrgType = "1"
  5829. // order.DrordBhvr = "-"
  5830. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5831. // order.HosplistName = subItem.GoodInfo.GoodName
  5832. // order.HilistLv = "1"
  5833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5834. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5835. // order.HosplistName = subItem.GoodInfo.GoodName
  5836. // order.Cnt = subItem.Count
  5837. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5838. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5839. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5840. // order.OwnpayAmt = ""
  5841. // order.SelfpayAmt = ""
  5842. // order.Spec = ""
  5843. // order.SpecUnt = ""
  5844. // order.DrordBegnDate = s_tm
  5845. // order.DrordStopDate = ""
  5846. // order.DrordDrCodg = "1"
  5847. // order.DrordDeptName = department.Name
  5848. // order.DrordDrCodg = "1"
  5849. // order.DrordDrName = doctor_info.UserName
  5850. // order.DrordDrProfttl = ""
  5851. // order.CurrDrordFlag = "1"
  5852. // orders = append(orders, &order)
  5853. //
  5854. // }
  5855. // }
  5856. //}
  5857. for _, item := range prescriptions {
  5858. for _, subItem := range item.HisDoctorAdviceInfo {
  5859. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5860. var order models.FsiOrderDtos
  5861. order.RxID = strconv.FormatInt(item.ID, 10)
  5862. order.Rxno = strconv.FormatInt(item.ID, 10)
  5863. order.LongDrordFlag = "0"
  5864. order.HilistType = "1"
  5865. order.ChrgType = "1"
  5866. order.DrordBhvr = "-"
  5867. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5868. order.HosplistName = subItem.BaseDrugLib.DrugName
  5869. order.HilistLv = "1"
  5870. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5871. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5872. order.HosplistName = subItem.BaseDrugLib.DrugName
  5873. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5874. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5875. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5876. order.OwnpayAmt = ""
  5877. order.SelfpayAmt = ""
  5878. order.Spec = ""
  5879. order.SpecUnt = ""
  5880. order.DrordBegnDate = s_tm
  5881. order.DrordStopDate = ""
  5882. order.DrordDrCodg = doctor_info.DoctorNumber
  5883. order.DrordDeptName = department.Name
  5884. order.DrordDeptCodg = department.Number
  5885. order.DrordDrName = doctor_info.UserName
  5886. order.DrordDrProfttl = "234"
  5887. order.CurrDrordFlag = "1"
  5888. orders = append(orders, &order)
  5889. }
  5890. }
  5891. for _, subItem := range item.HisPrescriptionProject {
  5892. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5893. var order models.FsiOrderDtos
  5894. order.RxID = strconv.FormatInt(item.ID, 10)
  5895. order.Rxno = strconv.FormatInt(item.ID, 10)
  5896. order.LongDrordFlag = "0"
  5897. order.HilistType = "1"
  5898. order.ChrgType = "1"
  5899. order.DrordBhvr = "-"
  5900. order.HilistCode = subItem.HisProject.MedicalCode
  5901. order.HosplistName = subItem.HisProject.ProjectName
  5902. order.HilistLv = "1"
  5903. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5904. order.HosplistCode = subItem.HisProject.MedicalCode
  5905. order.HosplistName = subItem.HisProject.ProjectName
  5906. order.Cnt = subItem.Count
  5907. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5908. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5909. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5910. order.OwnpayAmt = ""
  5911. order.SelfpayAmt = ""
  5912. order.Spec = ""
  5913. order.SpecUnt = ""
  5914. order.DrordBegnDate = s_tm
  5915. order.DrordStopDate = ""
  5916. order.DrordDrCodg = doctor_info.DoctorNumber
  5917. order.DrordDeptName = department.Name
  5918. order.DrordDeptCodg = department.Number
  5919. order.DrordDrName = doctor_info.UserName
  5920. order.DrordDrProfttl = "234"
  5921. order.CurrDrordFlag = "1"
  5922. orders = append(orders, &order)
  5923. }
  5924. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5925. var order models.FsiOrderDtos
  5926. order.RxID = strconv.FormatInt(item.ID, 10)
  5927. order.Rxno = strconv.FormatInt(item.ID, 10)
  5928. order.LongDrordFlag = "0"
  5929. order.HilistType = "1"
  5930. order.ChrgType = "1"
  5931. order.DrordBhvr = "0"
  5932. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5933. order.HosplistName = subItem.GoodInfo.GoodName
  5934. order.HilistLv = "1"
  5935. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5936. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5937. order.HosplistName = subItem.GoodInfo.GoodName
  5938. order.Cnt = subItem.Count
  5939. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5940. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5941. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5942. order.OwnpayAmt = ""
  5943. order.SelfpayAmt = ""
  5944. order.Spec = ""
  5945. order.SpecUnt = ""
  5946. order.DrordBegnDate = s_tm
  5947. order.DrordStopDate = ""
  5948. order.DrordDrCodg = doctor_info.DoctorNumber
  5949. order.DrordDeptName = department.Name
  5950. order.DrordDeptCodg = department.Number
  5951. order.DrordDrName = doctor_info.UserName
  5952. order.DrordDrProfttl = "234"
  5953. order.CurrDrordFlag = "1"
  5954. orders = append(orders, &order)
  5955. }
  5956. }
  5957. }
  5958. //处方医嘱信息
  5959. fed.MatnStas = "0"
  5960. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5961. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5962. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5963. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5964. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5965. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5966. fed.SetlTotlnum = "1"
  5967. fed.Insutype = his.Insutype
  5968. fed.ReimFlag = "0"
  5969. fed.OutSetlFlag = "0"
  5970. var fopd []*models.FsiOperationDtosData
  5971. data := make(map[string]interface{})
  5972. data["fed"] = fed
  5973. data["fdd"] = fdds
  5974. data["fod"] = orders
  5975. data["pd"] = pd
  5976. data["pp"] = pp
  5977. data["fopd"] = fopd
  5978. data["trig_scen"] = trig_scen
  5979. client := &http.Client{}
  5980. bytesData, _ := json.Marshal(data)
  5981. var req *http.Request
  5982. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5983. if miConfig.MdtrtareaAdmvs == "320921" {
  5984. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5985. } else {
  5986. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5987. }
  5988. resp, _ := client.Do(req)
  5989. defer resp.Body.Close()
  5990. body, ioErr := ioutil.ReadAll(resp.Body)
  5991. if ioErr != nil {
  5992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5994. return res
  5995. }
  5996. var respJSON map[string]interface{}
  5997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6000. return res
  6001. }
  6002. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6003. result, _ := json.Marshal(respJSON)
  6004. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6005. utils.ErrorLog("解析失败:%v", err)
  6006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6007. return res
  6008. }
  6009. return res
  6010. } else {
  6011. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6012. saveLog(output, input, "3102", "事中")
  6013. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return
  6017. }
  6018. return res
  6019. }
  6020. return res
  6021. }
  6022. 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) {
  6023. var res Resultgd3101
  6024. adminUser := c.GetAdminUserInfo()
  6025. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6026. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6027. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6028. //record_time := c.GetString("record_time")
  6029. //trig_scen := c.GetString("trig_scen")
  6030. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6031. timeLayout := "2006-01-02"
  6032. loc, _ := time.LoadLocation("Local")
  6033. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6034. if err != nil {
  6035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6036. return res
  6037. }
  6038. recordDateTime := theTime.Unix()
  6039. var patientPrescription models.HisPrescriptionInfo
  6040. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6041. //if patientPrescription.ID == 0 {
  6042. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6043. //}
  6044. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6045. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6046. //
  6047. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6048. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6049. var pp models.PublicParams
  6050. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6051. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6052. pp.FixmedinsName = miConfig.OrgName
  6053. pp.FixmedinsCode = miConfig.Code
  6054. pp.RequestUrl = miConfig.Url
  6055. pp.Cainfo = miConfig.Cainfo
  6056. pp.SecretKey = miConfig.SecretKey
  6057. pp.AccessKey = miConfig.AccessKey
  6058. pp.OpterName = roles.UserName
  6059. var config []*models.HisXtDiagnoseConfig
  6060. for _, item := range diagnosis_ids {
  6061. id, _ := strconv.ParseInt(item, 10, 64)
  6062. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6063. config = append(config, &diagnosisConfig)
  6064. }
  6065. var pd models.PatientDtos
  6066. pd.PatnID = his.PsnNo
  6067. pd.PatnName = his.Name
  6068. pd.Gend = his.Gend
  6069. pd.Brdy = psn_info.Brdy
  6070. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6071. pd.CurrMdtrtID = his.Number
  6072. var fed models.FsiEncounterDtos
  6073. fed.MdtrtID = his.Number
  6074. fed.MedinsID = miConfig.Code
  6075. fed.MedinsName = miConfig.OrgName
  6076. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6077. fed.MedMdtrtType = "1"
  6078. fed.MedinsType = "1"
  6079. fed.MedinsLv = "11"
  6080. tm := time.Unix(his.RecordDate, 0)
  6081. s_tm := tm.Format("2006-01-02 15:04:05")
  6082. fed.AdmDate = s_tm
  6083. fed.DscgDate = s_tm
  6084. fed.DscgMainDiseCodg = config[0].CountryCode
  6085. fed.DscgMainDiseName = config[0].CountryContentName
  6086. //诊断信息
  6087. var fdds []*models.FsiDiagnoseDtos
  6088. for index, item := range config {
  6089. if index == 0 {
  6090. var fdd models.FsiDiagnoseDtos
  6091. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6092. fdd.InoutDiseType = "1"
  6093. fdd.MaindiseFlag = "1"
  6094. fdd.DiseDate = s_tm
  6095. fdd.DiasSrtNo = "1"
  6096. fdd.DiseName = item.CountryContentName
  6097. fdd.DiseCodg = item.CountryCode
  6098. fdds = append(fdds, &fdd)
  6099. } else {
  6100. var fdd models.FsiDiagnoseDtos
  6101. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6102. fdd.InoutDiseType = "1"
  6103. fdd.MaindiseFlag = "1"
  6104. fdd.DiseDate = s_tm
  6105. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6106. fdd.DiseName = item.CountryContentName
  6107. fdd.DiseCodg = item.CountryCode
  6108. fdds = append(fdds, &fdd)
  6109. }
  6110. }
  6111. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6112. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6113. fed.AdmDeptName = department.Name
  6114. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6115. fed.DscgDeptName = department.Name
  6116. fed.MedMdtrtType = "1"
  6117. fed.MedType = "11"
  6118. //if his.Insutype == "390" {
  6119. // fed.MedType = "1402"
  6120. //} else {
  6121. // fed.MedType = "9933"
  6122. //}
  6123. var orders []*models.FsiOrderDtos
  6124. if trig_scen == "2" {
  6125. //处方医嘱信息
  6126. for _, item := range prescriptions {
  6127. for _, subItem := range item.HisDoctorAdviceInfo {
  6128. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6129. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6130. var order models.FsiOrderDtos
  6131. order.RxID = strconv.FormatInt(item.ID, 10)
  6132. order.Rxno = strconv.FormatInt(item.ID, 10)
  6133. order.LongDrordFlag = "0"
  6134. order.HilistType = "1"
  6135. order.ChrgType = "1"
  6136. order.DrordBhvr = "0"
  6137. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6138. order.HosplistName = subItem.BaseDrugLib.DrugName
  6139. order.HilistLv = "1"
  6140. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6141. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6142. order.HosplistName = subItem.BaseDrugLib.DrugName
  6143. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6144. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6145. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6146. order.OwnpayAmt = ""
  6147. order.SelfpayAmt = ""
  6148. order.Spec = spec
  6149. order.SpecUnt = subItem.PrescribingNumberUnit
  6150. order.DrordBegnDate = s_tm
  6151. order.DrordStopDate = ""
  6152. order.DrordDrCodg = doctor_info.DoctorNumber
  6153. order.DrordDeptName = department.Name
  6154. order.DrordDeptCodg = department.Number
  6155. order.DrordDrName = doctor_info.UserName
  6156. order.DrordDrProfttl = "234"
  6157. order.CurrDrordFlag = "1"
  6158. orders = append(orders, &order)
  6159. }
  6160. }
  6161. for _, subItem := range item.HisPrescriptionProject {
  6162. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6163. var order models.FsiOrderDtos
  6164. order.RxID = strconv.FormatInt(item.ID, 10)
  6165. order.Rxno = strconv.FormatInt(item.ID, 10)
  6166. order.LongDrordFlag = "0"
  6167. order.HilistType = "1"
  6168. order.ChrgType = "1"
  6169. order.DrordBhvr = "0"
  6170. order.HilistCode = subItem.HisProject.MedicalCode
  6171. order.HosplistName = subItem.HisProject.ProjectName
  6172. order.HilistLv = "1"
  6173. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6174. order.HosplistCode = subItem.HisProject.MedicalCode
  6175. order.HosplistName = subItem.HisProject.ProjectName
  6176. order.Cnt = subItem.Count
  6177. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6178. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6179. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6180. order.OwnpayAmt = ""
  6181. order.SelfpayAmt = ""
  6182. order.Spec = subItem.Unit
  6183. order.SpecUnt = subItem.Unit
  6184. order.DrordBegnDate = s_tm
  6185. order.DrordStopDate = ""
  6186. order.DrordDrCodg = doctor_info.DoctorNumber
  6187. order.DrordDeptName = department.Name
  6188. order.DrordDeptCodg = department.Number
  6189. order.DrordDrName = doctor_info.UserName
  6190. order.DrordDrProfttl = "234"
  6191. order.CurrDrordFlag = "1"
  6192. orders = append(orders, &order)
  6193. }
  6194. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6195. var order models.FsiOrderDtos
  6196. order.RxID = strconv.FormatInt(item.ID, 10)
  6197. order.Rxno = strconv.FormatInt(item.ID, 10)
  6198. order.LongDrordFlag = "0"
  6199. order.HilistType = "1"
  6200. order.ChrgType = "1"
  6201. order.DrordBhvr = "0"
  6202. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6203. order.HosplistName = subItem.GoodInfo.GoodName
  6204. order.HilistLv = "1"
  6205. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6206. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6207. order.HosplistName = subItem.GoodInfo.GoodName
  6208. order.Cnt = subItem.Count
  6209. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6210. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6211. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6212. order.OwnpayAmt = ""
  6213. order.SelfpayAmt = ""
  6214. order.Spec = subItem.GoodInfo.SpecificationName
  6215. order.SpecUnt = subItem.Unit
  6216. order.DrordBegnDate = s_tm
  6217. order.DrordStopDate = ""
  6218. order.DrordDrCodg = doctor_info.DoctorNumber
  6219. order.DrordDeptName = department.Name
  6220. order.DrordDeptCodg = department.Number
  6221. order.DrordDrName = doctor_info.UserName
  6222. order.DrordDrProfttl = "234"
  6223. order.CurrDrordFlag = "1"
  6224. orders = append(orders, &order)
  6225. }
  6226. }
  6227. }
  6228. //处方医嘱信息
  6229. }
  6230. fed.MatnStas = "0"
  6231. fed.MedfeeSumamt = "0"
  6232. fed.OwnpayAmt = "0"
  6233. fed.SelfpayAmt = "0"
  6234. fed.AcctPayamt = "0"
  6235. fed.MaAmt = "0"
  6236. fed.HifpPayamt = "0"
  6237. fed.SetlTotlnum = "1"
  6238. fed.Insutype = his.Insutype
  6239. fed.ReimFlag = "0"
  6240. fed.OutSetlFlag = "0"
  6241. var fopd []*models.FsiOperationDtosData
  6242. data := make(map[string]interface{})
  6243. data["fed"] = fed
  6244. data["fdd"] = fdds
  6245. data["fod"] = orders
  6246. data["pd"] = pd
  6247. data["pp"] = pp
  6248. data["fopd"] = fopd
  6249. data["trig_scen"] = trig_scen
  6250. fmt.Println(data)
  6251. fmt.Println(fed)
  6252. fmt.Println(fdds)
  6253. fmt.Println(orders)
  6254. fmt.Println(pd)
  6255. fmt.Println(pp)
  6256. fmt.Println(fopd)
  6257. client := &http.Client{}
  6258. bytesData, _ := json.Marshal(data)
  6259. var req *http.Request
  6260. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6261. if miConfig.MdtrtareaAdmvs == "320921" {
  6262. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6263. } else {
  6264. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6265. }
  6266. resp, _ := client.Do(req)
  6267. defer resp.Body.Close()
  6268. body, ioErr := ioutil.ReadAll(resp.Body)
  6269. if ioErr != nil {
  6270. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6272. return res
  6273. }
  6274. var respJSON map[string]interface{}
  6275. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6276. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return res
  6279. }
  6280. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6281. fmt.Println(respJSON)
  6282. result, _ := json.Marshal(respJSON)
  6283. fmt.Println(result)
  6284. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6285. utils.ErrorLog("解析失败:%v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return res
  6288. }
  6289. return res
  6290. } else {
  6291. //if miConfig.MdtrtareaAdmvs == "441202" {
  6292. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6293. saveLog(output, input, "3101", "事前")
  6294. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. return res
  6300. //}
  6301. }
  6302. }
  6303. 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) {
  6304. adminUser := c.GetAdminUserInfo()
  6305. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6306. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6307. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6308. //record_time := c.GetString("record_time")
  6309. //trig_scen := c.GetString("trig_scen")
  6310. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6311. timeLayout := "2006-01-02"
  6312. loc, _ := time.LoadLocation("Local")
  6313. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6314. if err != nil {
  6315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6316. return res
  6317. }
  6318. recordDateTime := theTime.Unix()
  6319. var patientPrescription models.HisPrescriptionInfo
  6320. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6321. if patientPrescription.ID == 0 {
  6322. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6323. }
  6324. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6325. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6326. //
  6327. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6328. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6329. var pp models.PublicParams
  6330. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6331. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6332. pp.FixmedinsName = miConfig.OrgName
  6333. pp.FixmedinsCode = miConfig.Code
  6334. pp.RequestUrl = miConfig.Url
  6335. pp.Cainfo = miConfig.Cainfo
  6336. pp.SecretKey = miConfig.SecretKey
  6337. pp.AccessKey = miConfig.AccessKey
  6338. pp.OpterName = roles.UserName
  6339. var config []*models.HisXtDiagnoseConfig
  6340. for _, item := range diagnosis_ids {
  6341. id, _ := strconv.ParseInt(item, 10, 64)
  6342. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6343. config = append(config, &diagnosisConfig)
  6344. }
  6345. var pd models.PatientDtos
  6346. pd.PatnID = his.PsnNo
  6347. pd.PatnName = his.Name
  6348. pd.Gend = his.Gend
  6349. pd.Brdy = psn_info.Brdy
  6350. pd.Poolarea = his.InsuplcAdmdvs
  6351. pd.CurrMdtrtID = his.Number
  6352. var fed models.FsiEncounterDtos
  6353. fed.MdtrtID = his.Number
  6354. fed.MedinsID = miConfig.Code
  6355. fed.MedinsName = miConfig.OrgName
  6356. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6357. fed.MedMdtrtType = "1"
  6358. fed.MedinsType = "1"
  6359. fed.MedinsLv = "11"
  6360. tm := time.Unix(his.RecordDate, 0)
  6361. s_tm := tm.Format("2006-01-02 15:04:05")
  6362. fed.AdmDate = s_tm
  6363. fed.DscgDate = s_tm
  6364. fed.DscgMainDiseCodg = config[0].CountryCode
  6365. fed.DscgMainDiseName = config[0].CountryContentName
  6366. //诊断信息
  6367. var fdds []*models.FsiDiagnoseDtos
  6368. for index, item := range config {
  6369. if index == 0 {
  6370. var fdd models.FsiDiagnoseDtos
  6371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6372. fdd.InoutDiseType = "1"
  6373. fdd.MaindiseFlag = "1"
  6374. fdd.DiseDate = s_tm
  6375. fdd.DiasSrtNo = "1"
  6376. fdd.DiseName = item.CountryContentName
  6377. fdd.DiseCodg = item.CountryCode
  6378. fdds = append(fdds, &fdd)
  6379. } else {
  6380. var fdd models.FsiDiagnoseDtos
  6381. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6382. fdd.InoutDiseType = "1"
  6383. fdd.MaindiseFlag = "1"
  6384. fdd.DiseDate = s_tm
  6385. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6386. fdd.DiseName = item.CountryContentName
  6387. fdd.DiseCodg = item.CountryCode
  6388. fdds = append(fdds, &fdd)
  6389. }
  6390. }
  6391. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6392. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6393. fed.AdmDeptName = department.Name
  6394. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6395. fed.DscgDeptName = department.Name
  6396. fed.MedMdtrtType = "1"
  6397. fed.MedType = "11"
  6398. //if his.Insutype == "390" {
  6399. // fed.MedType = "1402"
  6400. //} else {
  6401. // fed.MedType = "9933"
  6402. //}
  6403. var orders []*models.FsiOrderDtos
  6404. if trig_scen == "2" {
  6405. //处方医嘱信息
  6406. for _, item := range prescriptions {
  6407. for _, subItem := range item.HisDoctorAdviceInfo {
  6408. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6409. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6410. var order models.FsiOrderDtos
  6411. order.RxID = strconv.FormatInt(item.ID, 10)
  6412. order.Rxno = strconv.FormatInt(item.ID, 10)
  6413. order.LongDrordFlag = "0"
  6414. order.HilistType = "1"
  6415. order.ChrgType = "1"
  6416. order.DrordBhvr = "0"
  6417. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6418. order.HosplistName = subItem.BaseDrugLib.DrugName
  6419. order.HilistLv = "1"
  6420. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6421. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6422. order.HosplistName = subItem.BaseDrugLib.DrugName
  6423. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6424. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6425. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6426. order.OwnpayAmt = ""
  6427. order.SelfpayAmt = ""
  6428. order.Spec = spec
  6429. order.SpecUnt = subItem.PrescribingNumberUnit
  6430. order.DrordBegnDate = s_tm
  6431. order.DrordStopDate = ""
  6432. order.DrordDrCodg = doctor_info.DoctorNumber
  6433. order.DrordDeptName = department.Name
  6434. order.DrordDeptCodg = department.Number
  6435. order.DrordDrName = doctor_info.UserName
  6436. order.DrordDrProfttl = "234"
  6437. order.CurrDrordFlag = "1"
  6438. orders = append(orders, &order)
  6439. }
  6440. }
  6441. for _, subItem := range item.HisPrescriptionProject {
  6442. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6443. var order models.FsiOrderDtos
  6444. order.RxID = strconv.FormatInt(item.ID, 10)
  6445. order.Rxno = strconv.FormatInt(item.ID, 10)
  6446. order.LongDrordFlag = "0"
  6447. order.HilistType = "1"
  6448. order.ChrgType = "1"
  6449. order.DrordBhvr = "0"
  6450. order.HilistCode = subItem.HisProject.MedicalCode
  6451. order.HosplistName = subItem.HisProject.ProjectName
  6452. order.HilistLv = "1"
  6453. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6454. order.HosplistCode = subItem.HisProject.MedicalCode
  6455. order.HosplistName = subItem.HisProject.ProjectName
  6456. order.Cnt = subItem.Count
  6457. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6458. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6459. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6460. order.OwnpayAmt = ""
  6461. order.SelfpayAmt = ""
  6462. order.Spec = subItem.Unit
  6463. order.SpecUnt = subItem.Unit
  6464. order.DrordBegnDate = s_tm
  6465. order.DrordStopDate = ""
  6466. order.DrordDrCodg = doctor_info.DoctorNumber
  6467. order.DrordDeptName = department.Name
  6468. order.DrordDeptCodg = department.Number
  6469. order.DrordDrName = doctor_info.UserName
  6470. order.DrordDrProfttl = "234"
  6471. order.CurrDrordFlag = "1"
  6472. orders = append(orders, &order)
  6473. }
  6474. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6475. var order models.FsiOrderDtos
  6476. order.RxID = strconv.FormatInt(item.ID, 10)
  6477. order.Rxno = strconv.FormatInt(item.ID, 10)
  6478. order.LongDrordFlag = "0"
  6479. order.HilistType = "1"
  6480. order.ChrgType = "1"
  6481. order.DrordBhvr = "0"
  6482. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6483. order.HosplistName = subItem.GoodInfo.GoodName
  6484. order.HilistLv = "1"
  6485. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6486. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6487. order.HosplistName = subItem.GoodInfo.GoodName
  6488. order.Cnt = subItem.Count
  6489. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6490. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6491. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6492. order.OwnpayAmt = ""
  6493. order.SelfpayAmt = ""
  6494. order.Spec = subItem.GoodInfo.SpecificationName
  6495. order.SpecUnt = subItem.Unit
  6496. order.DrordBegnDate = s_tm
  6497. order.DrordStopDate = ""
  6498. order.DrordDrCodg = doctor_info.DoctorNumber
  6499. order.DrordDeptName = department.Name
  6500. order.DrordDeptCodg = department.Number
  6501. order.DrordDrName = doctor_info.UserName
  6502. order.DrordDrProfttl = "234"
  6503. order.CurrDrordFlag = "1"
  6504. orders = append(orders, &order)
  6505. }
  6506. }
  6507. }
  6508. //处方医嘱信息
  6509. }
  6510. fed.MatnStas = "0"
  6511. fed.MedfeeSumamt = "0"
  6512. fed.OwnpayAmt = "0"
  6513. fed.SelfpayAmt = "0"
  6514. fed.AcctPayamt = "0"
  6515. fed.MaAmt = "0"
  6516. fed.HifpPayamt = "0"
  6517. fed.SetlTotlnum = "1"
  6518. fed.Insutype = his.Insutype
  6519. fed.ReimFlag = "0"
  6520. fed.OutSetlFlag = "0"
  6521. var fopd []*models.FsiOperationDtosData
  6522. data := make(map[string]interface{})
  6523. data["fed"] = fed
  6524. data["fdd"] = fdds
  6525. data["fod"] = orders
  6526. data["pd"] = pd
  6527. data["pp"] = pp
  6528. data["fopd"] = fopd
  6529. data["trig_scen"] = trig_scen
  6530. fmt.Println(data)
  6531. fmt.Println(fed)
  6532. fmt.Println(fdds)
  6533. fmt.Println(orders)
  6534. fmt.Println(pd)
  6535. fmt.Println(pp)
  6536. fmt.Println(fopd)
  6537. client := &http.Client{}
  6538. bytesData, _ := json.Marshal(data)
  6539. var req *http.Request
  6540. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6541. if miConfig.MdtrtareaAdmvs == "320921" {
  6542. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6543. } else {
  6544. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6545. }
  6546. resp, _ := client.Do(req)
  6547. defer resp.Body.Close()
  6548. body, ioErr := ioutil.ReadAll(resp.Body)
  6549. if ioErr != nil {
  6550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6552. return res
  6553. }
  6554. var respJSON map[string]interface{}
  6555. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6558. return res
  6559. }
  6560. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6561. fmt.Println(respJSON)
  6562. result, _ := json.Marshal(respJSON)
  6563. fmt.Println(result)
  6564. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6565. utils.ErrorLog("解析失败:%v", err)
  6566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6567. return res
  6568. }
  6569. return res
  6570. } else {
  6571. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6572. saveLog(output, input, "3101", "事前")
  6573. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6574. utils.ErrorLog("解析失败:%v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. return
  6577. }
  6578. return res
  6579. }
  6580. return res
  6581. }
  6582. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6583. ////patient_id, _ := c.GetInt64("patient_id")
  6584. //order_id, _ := c.GetInt64("order_id")
  6585. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6586. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6587. //trig_scen := c.GetString("trig_scen")
  6588. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6589. utils.ErrorLog("解析失败:%v", psn_info)
  6590. adminUser := c.GetAdminUserInfo()
  6591. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6592. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6593. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6594. record_time := c.GetString("record_time")
  6595. order, _ := service.GetHisOrderByID(order_id)
  6596. timeLayout := "2006-01-02"
  6597. loc, _ := time.LoadLocation("Local")
  6598. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6599. if err != nil {
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6601. return
  6602. }
  6603. recordDateTime := theTime.Unix()
  6604. var patientPrescription models.HisPrescriptionInfo
  6605. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6606. if patientPrescription.ID == 0 {
  6607. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6608. }
  6609. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6610. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6611. //
  6612. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6613. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6614. var pp models.PublicParams
  6615. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6616. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6617. pp.FixmedinsName = miConfig.OrgName
  6618. pp.FixmedinsCode = miConfig.Code
  6619. pp.RequestUrl = miConfig.Url
  6620. pp.Cainfo = miConfig.Cainfo
  6621. pp.SecretKey = miConfig.SecretKey
  6622. pp.AccessKey = miConfig.AccessKey
  6623. pp.OpterName = roles.UserName
  6624. var config []*models.HisXtDiagnoseConfig
  6625. for _, item := range diagnosis_ids {
  6626. id, _ := strconv.ParseInt(item, 10, 64)
  6627. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6628. config = append(config, &diagnosisConfig)
  6629. }
  6630. var pd models.PatientDtos
  6631. pd.PatnID = his.PsnNo
  6632. pd.PatnName = his.Name
  6633. pd.Gend = his.Gend
  6634. pd.Brdy = psn_info.Brdy
  6635. pd.Poolarea = his.InsuplcAdmdvs
  6636. pd.CurrMdtrtID = his.Number
  6637. var fed models.FsiEncounterDtos
  6638. fed.MdtrtID = his.Number
  6639. fed.MedinsID = miConfig.Code
  6640. fed.MedinsName = miConfig.OrgName
  6641. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6642. fed.MedMdtrtType = "1"
  6643. fed.MedinsType = "1"
  6644. fed.MedinsLv = "11"
  6645. tm := time.Unix(his.RecordDate, 0)
  6646. s_tm := tm.Format("2006-01-02 15:04:05")
  6647. fed.AdmDate = s_tm
  6648. fed.DscgDate = s_tm
  6649. fed.DscgMainDiseCodg = config[0].CountryCode
  6650. fed.DscgMainDiseName = config[0].CountryContentName
  6651. //诊断信息
  6652. var fdds []*models.FsiDiagnoseDtos
  6653. for index, item := range config {
  6654. if index == 0 {
  6655. var fdd models.FsiDiagnoseDtos
  6656. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6657. fdd.InoutDiseType = "1"
  6658. fdd.MaindiseFlag = "1"
  6659. fdd.DiseDate = s_tm
  6660. fdd.DiasSrtNo = "1"
  6661. fdd.DiseName = item.CountryContentName
  6662. fdd.DiseCodg = item.CountryCode
  6663. fdds = append(fdds, &fdd)
  6664. } else {
  6665. var fdd models.FsiDiagnoseDtos
  6666. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6667. fdd.InoutDiseType = "1"
  6668. fdd.MaindiseFlag = "1"
  6669. fdd.DiseDate = s_tm
  6670. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6671. fdd.DiseName = item.CountryContentName
  6672. fdd.DiseCodg = item.CountryCode
  6673. fdds = append(fdds, &fdd)
  6674. }
  6675. }
  6676. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6677. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6678. fed.AdmDeptName = department.Name
  6679. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6680. fed.DscgDeptName = department.Name
  6681. fed.MedType = order.MedType
  6682. //处方医嘱信息
  6683. var orders []*models.FsiOrderDtos
  6684. //for _, item := range prescriptions {
  6685. // for _, subItem := range item.HisDoctorAdviceInfo {
  6686. // var order models.FsiOrderDtos
  6687. // order.RxID = strconv.FormatInt(item.ID, 10)
  6688. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6689. // order.LongDrordFlag = "0"
  6690. // order.HilistType = "1"
  6691. // order.ChrgType = "1"
  6692. // order.DrordBhvr = "-"
  6693. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6694. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6695. // order.HilistLv = "1"
  6696. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6697. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6698. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6699. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6700. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6701. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6702. // order.OwnpayAmt = ""
  6703. // order.SelfpayAmt = ""
  6704. // order.Spec = ""
  6705. // order.SpecUnt = ""
  6706. // order.DrordBegnDate = s_tm
  6707. // order.DrordStopDate = ""
  6708. // order.DrordDrCodg = "1"
  6709. // order.DrordDeptName = department.Name
  6710. // order.DrordDrCodg = "1"
  6711. // order.DrordDrName = doctor_info.UserName
  6712. // order.DrordDrProfttl = ""
  6713. // order.CurrDrordFlag = "1"
  6714. // orders = append(orders, &order)
  6715. // }
  6716. // for _, subItem := range item.HisPrescriptionProject {
  6717. // if subItem.Type == 2 {
  6718. // var order models.FsiOrderDtos
  6719. // order.RxID = strconv.FormatInt(item.ID, 10)
  6720. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6721. // order.LongDrordFlag = "0"
  6722. // order.HilistType = "1"
  6723. // order.ChrgType = "1"
  6724. // order.DrordBhvr = "-"
  6725. // order.HilistCode = subItem.HisProject.MedicalCode
  6726. // order.HosplistName = subItem.HisProject.ProjectName
  6727. // order.HilistLv = "1"
  6728. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6729. // order.HosplistCode = subItem.HisProject.MedicalCode
  6730. // order.HosplistName = subItem.HisProject.ProjectName
  6731. // order.Cnt = subItem.Count
  6732. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6733. //
  6734. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6735. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6736. // order.OwnpayAmt = ""
  6737. // order.SelfpayAmt = ""
  6738. // order.Spec = ""
  6739. // order.SpecUnt = ""
  6740. // order.DrordBegnDate = s_tm
  6741. // order.DrordStopDate = ""
  6742. // order.DrordDrCodg = "1"
  6743. // order.DrordDeptName = department.Name
  6744. // order.DrordDrCodg = "1"
  6745. // order.DrordDrName = doctor_info.UserName
  6746. // order.DrordDrProfttl = ""
  6747. // order.CurrDrordFlag = "1"
  6748. // orders = append(orders, &order)
  6749. //
  6750. // }
  6751. // if subItem.Type == 3 {
  6752. //
  6753. // var order models.FsiOrderDtos
  6754. // order.RxID = strconv.FormatInt(item.ID, 10)
  6755. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6756. // order.LongDrordFlag = "0"
  6757. // order.HilistType = "1"
  6758. // order.ChrgType = "1"
  6759. // order.DrordBhvr = "-"
  6760. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6761. // order.HosplistName = subItem.GoodInfo.GoodName
  6762. // order.HilistLv = "1"
  6763. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6764. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6765. // order.HosplistName = subItem.GoodInfo.GoodName
  6766. // order.Cnt = subItem.Count
  6767. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6768. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6769. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6770. // order.OwnpayAmt = ""
  6771. // order.SelfpayAmt = ""
  6772. // order.Spec = ""
  6773. // order.SpecUnt = ""
  6774. // order.DrordBegnDate = s_tm
  6775. // order.DrordStopDate = ""
  6776. // order.DrordDrCodg = "1"
  6777. // order.DrordDeptName = department.Name
  6778. // order.DrordDrCodg = "1"
  6779. // order.DrordDrName = doctor_info.UserName
  6780. // order.DrordDrProfttl = ""
  6781. // order.CurrDrordFlag = "1"
  6782. // orders = append(orders, &order)
  6783. //
  6784. // }
  6785. // }
  6786. //}
  6787. for _, item := range prescriptions {
  6788. for _, subItem := range item.HisDoctorAdviceInfo {
  6789. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6790. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6791. var order models.FsiOrderDtos
  6792. order.RxID = strconv.FormatInt(item.ID, 10)
  6793. order.Rxno = strconv.FormatInt(item.ID, 10)
  6794. order.LongDrordFlag = "0"
  6795. order.HilistType = "1"
  6796. order.ChrgType = "1"
  6797. order.DrordBhvr = "0"
  6798. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6799. order.HosplistName = subItem.BaseDrugLib.DrugName
  6800. order.HilistLv = "1"
  6801. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6802. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6803. order.HosplistName = subItem.BaseDrugLib.DrugName
  6804. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6805. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6806. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6807. order.OwnpayAmt = ""
  6808. order.SelfpayAmt = ""
  6809. order.Spec = spec
  6810. order.SpecUnt = subItem.PrescribingNumberUnit
  6811. order.DrordBegnDate = s_tm
  6812. order.DrordStopDate = ""
  6813. order.DrordDrCodg = doctor_info.DoctorNumber
  6814. order.DrordDeptName = department.Name
  6815. order.DrordDeptCodg = department.Number
  6816. order.DrordDrName = doctor_info.UserName
  6817. order.DrordDrProfttl = "234"
  6818. order.CurrDrordFlag = "1"
  6819. orders = append(orders, &order)
  6820. }
  6821. }
  6822. for _, subItem := range item.HisPrescriptionProject {
  6823. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6824. var order models.FsiOrderDtos
  6825. order.RxID = strconv.FormatInt(item.ID, 10)
  6826. order.Rxno = strconv.FormatInt(item.ID, 10)
  6827. order.LongDrordFlag = "0"
  6828. order.HilistType = "1"
  6829. order.ChrgType = "1"
  6830. order.DrordBhvr = "0"
  6831. order.HilistCode = subItem.HisProject.MedicalCode
  6832. order.HosplistName = subItem.HisProject.ProjectName
  6833. order.HilistLv = "1"
  6834. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6835. order.HosplistCode = subItem.HisProject.MedicalCode
  6836. order.HosplistName = subItem.HisProject.ProjectName
  6837. order.Cnt = subItem.Count
  6838. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6839. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6840. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6841. order.OwnpayAmt = ""
  6842. order.SelfpayAmt = ""
  6843. order.Spec = subItem.Unit
  6844. order.SpecUnt = subItem.Unit
  6845. order.DrordBegnDate = s_tm
  6846. order.DrordStopDate = ""
  6847. order.DrordDrCodg = doctor_info.DoctorNumber
  6848. order.DrordDeptName = department.Name
  6849. order.DrordDeptCodg = department.Number
  6850. order.DrordDrName = doctor_info.UserName
  6851. order.DrordDrProfttl = "234"
  6852. order.CurrDrordFlag = "1"
  6853. orders = append(orders, &order)
  6854. }
  6855. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6856. var order models.FsiOrderDtos
  6857. order.RxID = strconv.FormatInt(item.ID, 10)
  6858. order.Rxno = strconv.FormatInt(item.ID, 10)
  6859. order.LongDrordFlag = "0"
  6860. order.HilistType = "1"
  6861. order.ChrgType = "1"
  6862. order.DrordBhvr = "0"
  6863. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6864. order.HosplistName = subItem.GoodInfo.GoodName
  6865. order.HilistLv = "1"
  6866. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6867. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6868. order.HosplistName = subItem.GoodInfo.GoodName
  6869. order.Cnt = subItem.Count
  6870. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6871. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6872. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6873. order.OwnpayAmt = ""
  6874. order.SelfpayAmt = ""
  6875. order.Spec = subItem.GoodInfo.SpecificationName
  6876. order.SpecUnt = subItem.Unit
  6877. order.DrordBegnDate = s_tm
  6878. order.DrordStopDate = ""
  6879. order.DrordDrCodg = doctor_info.DoctorNumber
  6880. order.DrordDeptName = department.Name
  6881. order.DrordDeptCodg = department.Number
  6882. order.DrordDrName = doctor_info.UserName
  6883. order.DrordDrProfttl = "234"
  6884. order.CurrDrordFlag = "1"
  6885. orders = append(orders, &order)
  6886. }
  6887. }
  6888. }
  6889. //处方医嘱信息
  6890. fed.MatnStas = "0"
  6891. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6892. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6893. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6894. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6895. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6896. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6897. fed.SetlTotlnum = "1"
  6898. fed.Insutype = his.Insutype
  6899. fed.ReimFlag = "0"
  6900. fed.OutSetlFlag = "0"
  6901. var fopd []*models.FsiOperationDtosData
  6902. data := make(map[string]interface{})
  6903. data["fed"] = fed
  6904. data["fdd"] = fdds
  6905. data["fod"] = orders
  6906. data["pd"] = pd
  6907. data["pp"] = pp
  6908. data["fopd"] = fopd
  6909. data["trig_scen"] = trig_scen
  6910. client := &http.Client{}
  6911. bytesData, _ := json.Marshal(data)
  6912. var req *http.Request
  6913. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6914. if miConfig.MdtrtareaAdmvs == "320921" {
  6915. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6916. } else {
  6917. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6918. }
  6919. resp, _ := client.Do(req)
  6920. defer resp.Body.Close()
  6921. body, ioErr := ioutil.ReadAll(resp.Body)
  6922. if ioErr != nil {
  6923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return res
  6926. }
  6927. var respJSON map[string]interface{}
  6928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6931. return res
  6932. }
  6933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6934. result, _ := json.Marshal(respJSON)
  6935. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6936. utils.ErrorLog("解析失败:%v", err)
  6937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6938. return res
  6939. }
  6940. return res
  6941. } else {
  6942. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6943. saveLog(output, input, "3102", "事中")
  6944. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return
  6948. }
  6949. return res
  6950. }
  6951. return res
  6952. }
  6953. func (c *HisApiController) Check() {
  6954. psn_no := c.GetString("psn_no")
  6955. in := c.GetString("in")
  6956. mt := c.GetString("mt")
  6957. baseParams := models.BaseParams{
  6958. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6959. FixmedinsCode: "H15049901371",
  6960. InsuplcAdmdvs: "150499",
  6961. MdtrtareaAdmvs: "150499",
  6962. OrgName: "赤峰费森血液透析中心",
  6963. Doctor: "1111",
  6964. }
  6965. service.Gdyb2001(baseParams, psn_no, in, mt)
  6966. }
  6967. func (c *HisApiController) GetPsnNcdsInfo() {
  6968. admin_user_id, _ := c.GetInt64("admin_user_id")
  6969. patient_id, _ := c.GetInt64("patient_id")
  6970. id, _ := c.GetInt64("id")
  6971. adminUser := c.GetAdminUserInfo()
  6972. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6973. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6974. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6975. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6976. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6977. //
  6978. //if psn_record.ID == 0 {
  6979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6980. // return
  6981. //}
  6982. var res Result5301
  6983. var res10265 Result5301For10265
  6984. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6985. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6986. var api string
  6987. if miConfig.MdtrtareaAdmvs == "320921" {
  6988. 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 +
  6989. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6990. } else {
  6991. 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 +
  6992. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6993. }
  6994. resp, requestErr := http.Get(api)
  6995. if requestErr != nil {
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6997. return
  6998. }
  6999. body, ioErr := ioutil.ReadAll(resp.Body)
  7000. if ioErr != nil {
  7001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7003. return
  7004. }
  7005. var respJSON map[string]interface{}
  7006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7009. return
  7010. }
  7011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7012. result, _ := json.Marshal(respJSON)
  7013. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7014. utils.ErrorLog("解析失败:%v", err)
  7015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7016. return
  7017. }
  7018. res.ErrMsg = res10265.ErrMsg
  7019. res.Output = res10265.Output
  7020. res.InfRefmsgid = res10265.InfRefmsgid
  7021. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7022. res.Infcode = infocode
  7023. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7024. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7025. var api string
  7026. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7027. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7028. resp, requestErr := http.Get(api)
  7029. if requestErr != nil {
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. return
  7032. }
  7033. body, ioErr := ioutil.ReadAll(resp.Body)
  7034. if ioErr != nil {
  7035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7037. return
  7038. }
  7039. var respJSON map[string]interface{}
  7040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7043. return
  7044. }
  7045. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7046. if status == "0" {
  7047. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7048. c.ServeSuccessJSON(map[string]interface{}{
  7049. "failed_code": -10,
  7050. "msg": err_msg,
  7051. })
  7052. return
  7053. }
  7054. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7055. result, _ := json.Marshal(respJSON)
  7056. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7057. utils.ErrorLog("解析失败:%v", err)
  7058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7059. return
  7060. }
  7061. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7062. p, _ := service.GetHisPatientById(patient_id)
  7063. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7064. var dat map[string]interface{}
  7065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7066. fmt.Println(dat)
  7067. } else {
  7068. fmt.Println(err)
  7069. }
  7070. userJSONBytes, _ := json.Marshal(dat)
  7071. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7072. utils.ErrorLog("解析失败:%v", err)
  7073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7074. return
  7075. }
  7076. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7077. p, _ := service.GetHisPatientById(patient_id)
  7078. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7079. var dat map[string]interface{}
  7080. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7081. fmt.Println(dat)
  7082. } else {
  7083. fmt.Println(err)
  7084. }
  7085. userJSONBytes, _ := json.Marshal(dat)
  7086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7087. utils.ErrorLog("解析失败:%v", err)
  7088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7089. return
  7090. }
  7091. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7092. p, _ := service.GetHisPatientById(patient_id)
  7093. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7094. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7095. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7096. resp, requestErr := http.Get(api)
  7097. if requestErr != nil {
  7098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7099. return
  7100. }
  7101. body, ioErr := ioutil.ReadAll(resp.Body)
  7102. if ioErr != nil {
  7103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7105. return
  7106. }
  7107. var respJSON map[string]interface{}
  7108. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7111. return
  7112. }
  7113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7114. result, _ := json.Marshal(respJSON)
  7115. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7116. utils.ErrorLog("解析失败:%v", err)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. return
  7119. }
  7120. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7121. p, _ := service.GetHisPatientById(patient_id)
  7122. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7123. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7124. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7125. resp, requestErr := http.Get(api)
  7126. if requestErr != nil {
  7127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7128. return
  7129. }
  7130. body, ioErr := ioutil.ReadAll(resp.Body)
  7131. if ioErr != nil {
  7132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7134. return
  7135. }
  7136. var respJSON map[string]interface{}
  7137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. return
  7141. }
  7142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7143. result, _ := json.Marshal(respJSON)
  7144. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7145. utils.ErrorLog("解析失败:%v", err)
  7146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7147. return
  7148. }
  7149. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7150. p, _ := service.GetHisPatientById(patient_id)
  7151. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7152. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7153. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7154. resp, requestErr := http.Get(api)
  7155. if requestErr != nil {
  7156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7157. return
  7158. }
  7159. body, ioErr := ioutil.ReadAll(resp.Body)
  7160. if ioErr != nil {
  7161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7163. return
  7164. }
  7165. var respJSON map[string]interface{}
  7166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7169. return
  7170. }
  7171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7172. result, _ := json.Marshal(respJSON)
  7173. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7174. utils.ErrorLog("解析失败:%v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7179. p, _ := service.GetHisPatientById(patient_id)
  7180. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7181. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7182. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7183. resp, requestErr := http.Get(api)
  7184. if requestErr != nil {
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. body, ioErr := ioutil.ReadAll(resp.Body)
  7189. if ioErr != nil {
  7190. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7192. return
  7193. }
  7194. var respJSON map[string]interface{}
  7195. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7196. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7201. result, _ := json.Marshal(respJSON)
  7202. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7203. utils.ErrorLog("解析失败:%v", err)
  7204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7205. return
  7206. }
  7207. } else {
  7208. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7209. var dat map[string]interface{}
  7210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7211. fmt.Println(dat)
  7212. } else {
  7213. fmt.Println(err)
  7214. }
  7215. userJSONBytes, _ := json.Marshal(dat)
  7216. if miConfig.Code == "H15049901371" {
  7217. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7218. utils.ErrorLog("解析失败:%v", err)
  7219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7220. return
  7221. }
  7222. res.InfRefmsgid = res10265.InfRefmsgid
  7223. res.Output = res10265.Output
  7224. res.ErrMsg = res10265.ErrMsg
  7225. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7226. res.Infcode = infocode
  7227. } else {
  7228. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7229. utils.ErrorLog("解析失败:%v", err)
  7230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7231. return
  7232. }
  7233. }
  7234. }
  7235. if res.Infcode == 0 {
  7236. c.ServeSuccessJSON(map[string]interface{}{
  7237. "result": res.Output.Result,
  7238. })
  7239. }
  7240. }
  7241. func (c *HisApiController) CheckInsutype() {
  7242. his_patient_id, _ := c.GetInt64("his_patient_id")
  7243. admin_user_id, _ := c.GetInt64("admin_user_id")
  7244. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7245. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7246. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7247. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7248. var dat map[string]interface{}
  7249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7250. fmt.Println(dat)
  7251. } else {
  7252. fmt.Println(err)
  7253. }
  7254. userJSONBytes, _ := json.Marshal(dat)
  7255. var res Result90100
  7256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7257. utils.ErrorLog("解析失败:%v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. if res.Infcode != 0 {
  7262. c.ServeSuccessJSON(map[string]interface{}{
  7263. "failed_code": -10,
  7264. "msg": res.ErrMsg,
  7265. })
  7266. return
  7267. } else {
  7268. fmt.Println(res)
  7269. }
  7270. }
  7271. func (c *HisApiController) CheckCardPWD() {
  7272. card_pwd := c.GetString("card_pwd")
  7273. his_patient_id, _ := c.GetInt64("his_patient_id")
  7274. admin_user_id, _ := c.GetInt64("admin_user_id")
  7275. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7276. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7277. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7278. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7279. bas := strings.Split(psn.CardInfo, "|")
  7280. basNumber := bas[2]
  7281. if psn.InsuplcAdmdvs[:4] == "4403" {
  7282. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7283. var dat map[string]interface{}
  7284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7285. fmt.Println(dat)
  7286. } else {
  7287. fmt.Println(err)
  7288. }
  7289. userJSONBytes, _ := json.Marshal(dat)
  7290. var res Result90991
  7291. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7292. utils.ErrorLog("解析失败:%v", err)
  7293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7294. return
  7295. }
  7296. if res.Infcode != 0 {
  7297. c.ServeSuccessJSON(map[string]interface{}{
  7298. "failed_code": -10,
  7299. "msg": res.ErrMsg,
  7300. })
  7301. return
  7302. } else {
  7303. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7304. var msg string
  7305. switch res.Output.Result.CardStat {
  7306. case "00":
  7307. msg = "未激活"
  7308. break
  7309. case "10":
  7310. msg = "激活"
  7311. break
  7312. case "20":
  7313. msg = "窗口挂失"
  7314. break
  7315. case "21":
  7316. msg = "电话挂失"
  7317. break
  7318. case "22":
  7319. msg = "单位网上申报挂失"
  7320. break
  7321. case "23":
  7322. msg = "保健办挂失"
  7323. break
  7324. case "24":
  7325. msg = "个人网上挂失"
  7326. break
  7327. case "25":
  7328. msg = "网上服务大厅挂失"
  7329. break
  7330. case "30":
  7331. msg = "注销"
  7332. break
  7333. case "40":
  7334. msg = "回收"
  7335. break
  7336. case "99":
  7337. msg = "制卡中(无效卡)"
  7338. break
  7339. }
  7340. c.ServeSuccessJSON(map[string]interface{}{
  7341. "failed_code": -10,
  7342. "msg": msg,
  7343. })
  7344. return
  7345. } else {
  7346. c.ServeSuccessJSON(map[string]interface{}{
  7347. "msg": "校验成功",
  7348. })
  7349. return
  7350. }
  7351. }
  7352. } else {
  7353. c.ServeSuccessJSON(map[string]interface{}{
  7354. "msg": "校验成功",
  7355. })
  7356. return
  7357. }
  7358. }
  7359. func (c *HisApiController) CheckCardPWDTwo() {
  7360. //card_pwd := c.GetString("card_pwd")
  7361. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7362. admin_user_id, _ := c.GetInt64("admin_user_id")
  7363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7365. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7366. var dat map[string]interface{}
  7367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7368. fmt.Println(dat)
  7369. } else {
  7370. fmt.Println(err)
  7371. }
  7372. userJSONBytes, _ := json.Marshal(dat)
  7373. var res Result90991
  7374. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7375. utils.ErrorLog("解析失败:%v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. if res.Infcode != 0 {
  7380. c.ServeSuccessJSON(map[string]interface{}{
  7381. "failed_code": -10,
  7382. "msg": res.ErrMsg,
  7383. })
  7384. return
  7385. } else {
  7386. if res.Output.Result.SscnoCheckStat == "0" {
  7387. var msg string
  7388. switch res.Output.Result.CardStat {
  7389. case "00":
  7390. msg = "未激活"
  7391. break
  7392. case "10":
  7393. msg = "激活"
  7394. break
  7395. case "20":
  7396. msg = "窗口挂失"
  7397. break
  7398. case "21":
  7399. msg = "电话挂失"
  7400. break
  7401. case "22":
  7402. msg = "单位网上申报挂失"
  7403. break
  7404. case "23":
  7405. msg = "保健办挂失"
  7406. break
  7407. case "24":
  7408. msg = "个人网上挂失"
  7409. break
  7410. case "25":
  7411. msg = "网上服务大厅挂失"
  7412. break
  7413. case "30":
  7414. msg = "注销"
  7415. break
  7416. case "40":
  7417. msg = "回收"
  7418. break
  7419. case "99":
  7420. msg = "制卡中(无效卡)"
  7421. break
  7422. }
  7423. c.ServeSuccessJSON(map[string]interface{}{
  7424. "failed_code": -10,
  7425. "msg": msg,
  7426. })
  7427. return
  7428. } else {
  7429. c.ServeSuccessJSON(map[string]interface{}{
  7430. "msg": "校验成功",
  7431. })
  7432. return
  7433. }
  7434. }
  7435. }
  7436. type ELeCertData struct {
  7437. Data struct {
  7438. Extra string `json:"extra"`
  7439. IDNo string `json:"idNo"`
  7440. IDType string `json:"idType"`
  7441. EcToken string `json:"ecToken"`
  7442. InsuOrg string `json:"insuOrg"`
  7443. UserName string `json:"userName"`
  7444. EcIndexNo string `json:"ecIndexNo"`
  7445. Gender string `json:"gender"`
  7446. Birthday string `json:"birthday"`
  7447. Nationality string `json:"nationality"`
  7448. Email string `json:"email"`
  7449. } `json:"OutData"`
  7450. }
  7451. func (c *HisApiController) ReadCard() {
  7452. id_card_type, _ := c.GetInt64("id_card_type")
  7453. admin_user_id, _ := c.GetInt64("admin_user_id")
  7454. certificates, _ := c.GetInt64("certificates")
  7455. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7456. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7457. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7458. switch id_card_type {
  7459. case 1:
  7460. if miConfig.MdtrtareaAdmvs == "421300" {
  7461. var res ResultTwo
  7462. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7463. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7464. "&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)
  7465. resp, requestErr := http.Get(api)
  7466. if requestErr != nil {
  7467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7468. return
  7469. }
  7470. body, ioErr := ioutil.ReadAll(resp.Body)
  7471. if ioErr != nil {
  7472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7474. return
  7475. }
  7476. var respJSON map[string]interface{}
  7477. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7480. return
  7481. }
  7482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7483. result, _ := json.Marshal(respJSON)
  7484. fmt.Println("log")
  7485. fmt.Println(string(result))
  7486. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7487. utils.ErrorLog("解析失败:%v", err)
  7488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7489. return
  7490. }
  7491. if res.Infcode == 0 {
  7492. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7493. if err == gorm.ErrRecordNotFound {
  7494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7495. return
  7496. } else if err != nil {
  7497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7498. return
  7499. } else {
  7500. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7501. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7502. infoStr := string(Iinfos)
  7503. idetinfoStr := string(Idetinfos)
  7504. var rf []*ResultFive
  7505. json.Unmarshal([]byte(infoStr), &rf)
  7506. var insutypes []*ResultFive
  7507. var insutype string
  7508. var is390 int = 0
  7509. var is310 int = 0
  7510. for _, item := range rf {
  7511. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7512. insutypes = append(insutypes, item)
  7513. }
  7514. }
  7515. if len(insutypes) == 1 {
  7516. insutype = insutypes[0].Insutype
  7517. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7518. } else {
  7519. for _, i := range insutypes {
  7520. if i.Insutype == "390" {
  7521. is390 = 1
  7522. }
  7523. if i.Insutype == "310" {
  7524. is310 = 1
  7525. }
  7526. }
  7527. }
  7528. if is390 == 1 {
  7529. insutype = "390"
  7530. }
  7531. if is310 == 1 {
  7532. insutype = "310"
  7533. }
  7534. if len(insutypes) == 0 {
  7535. insutype = "390"
  7536. }
  7537. var insuplc_admdvs string
  7538. for _, item := range rf {
  7539. if item.Insutype == insutype {
  7540. insuplc_admdvs = item.InsuplcAdmdvs
  7541. }
  7542. }
  7543. if strings.Contains(insuplc_admdvs, "4213") {
  7544. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7545. }
  7546. psn := &models.HisPsn{
  7547. PsnNo: res.Output.Baseinfo.PsnNo,
  7548. PatientId: patient.ID,
  7549. Certno: res.Output.Baseinfo.Certno,
  7550. Gend: res.Output.Baseinfo.Gend,
  7551. Naty: res.Output.Baseinfo.Naty,
  7552. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7553. PsnName: res.Output.Baseinfo.PsnName,
  7554. Idetinfo: idetinfoStr,
  7555. Insuinfo: infoStr,
  7556. InsuplcAdmdvs: insuplc_admdvs,
  7557. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7558. }
  7559. service.CreateHisPsn(psn)
  7560. c.ServeSuccessJSON(map[string]interface{}{
  7561. "patient": patient,
  7562. "number": res.Output.Baseinfo.Certno,
  7563. })
  7564. }
  7565. } else {
  7566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7567. return
  7568. }
  7569. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7570. var res ResultTwo
  7571. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7572. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7573. "&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)
  7574. resp, requestErr := http.Get(api)
  7575. if requestErr != nil {
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7577. return
  7578. }
  7579. body, ioErr := ioutil.ReadAll(resp.Body)
  7580. if ioErr != nil {
  7581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7583. return
  7584. }
  7585. var respJSON map[string]interface{}
  7586. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7589. return
  7590. }
  7591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7592. result, _ := json.Marshal(respJSON)
  7593. fmt.Println("log")
  7594. fmt.Println(string(result))
  7595. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7596. utils.ErrorLog("解析失败:%v", err)
  7597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7598. return
  7599. }
  7600. if res.Infcode == 0 {
  7601. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7602. if err == gorm.ErrRecordNotFound {
  7603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7604. return
  7605. } else if err != nil {
  7606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7607. return
  7608. } else {
  7609. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7610. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7611. infoStr := string(Iinfos)
  7612. idetinfoStr := string(Idetinfos)
  7613. psn := &models.HisPsn{
  7614. PsnNo: res.Output.Baseinfo.PsnNo,
  7615. PatientId: patient.ID,
  7616. Certno: res.Output.Baseinfo.Certno,
  7617. Gend: res.Output.Baseinfo.Gend,
  7618. Naty: res.Output.Baseinfo.Naty,
  7619. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7620. PsnName: res.Output.Baseinfo.PsnName,
  7621. Idetinfo: idetinfoStr,
  7622. Insuinfo: infoStr,
  7623. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7624. }
  7625. service.CreateHisPsn(psn)
  7626. var rf []*ResultFive
  7627. json.Unmarshal([]byte(infoStr), &rf)
  7628. var insutypes []*ResultFive
  7629. var insutype string
  7630. var is390 int = 0
  7631. var is310 int = 0
  7632. for _, item := range rf {
  7633. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7634. insutypes = append(insutypes, item)
  7635. }
  7636. }
  7637. if len(insutypes) == 1 {
  7638. insutype = insutypes[0].Insutype
  7639. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7640. } else {
  7641. for _, i := range insutypes {
  7642. if i.Insutype == "390" {
  7643. is390 = 1
  7644. }
  7645. if i.Insutype == "310" {
  7646. is310 = 1
  7647. }
  7648. }
  7649. }
  7650. if is390 == 1 {
  7651. insutype = "390"
  7652. }
  7653. if is310 == 1 {
  7654. insutype = "310"
  7655. }
  7656. if len(insutypes) == 0 {
  7657. insutype = "310"
  7658. }
  7659. c.ServeSuccessJSON(map[string]interface{}{
  7660. "patient": patient,
  7661. "number": res.Output.Baseinfo.Certno,
  7662. "insutype": insutype,
  7663. })
  7664. }
  7665. } else {
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7667. return
  7668. }
  7669. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7670. var res ResultTwo
  7671. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7672. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7673. "&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)
  7674. resp, requestErr := http.Get(api)
  7675. if requestErr != nil {
  7676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7677. return
  7678. }
  7679. body, ioErr := ioutil.ReadAll(resp.Body)
  7680. if ioErr != nil {
  7681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7683. return
  7684. }
  7685. var respJSON map[string]interface{}
  7686. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7689. return
  7690. }
  7691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7692. result, _ := json.Marshal(respJSON)
  7693. fmt.Println("log")
  7694. fmt.Println(string(result))
  7695. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7696. utils.ErrorLog("解析失败:%v", err)
  7697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. return
  7699. }
  7700. if res.Infcode == 0 {
  7701. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7702. if err == gorm.ErrRecordNotFound {
  7703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7704. return
  7705. } else if err != nil {
  7706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7707. return
  7708. } else {
  7709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7711. infoStr := string(Iinfos)
  7712. idetinfoStr := string(Idetinfos)
  7713. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7714. psn := &models.HisPsn{
  7715. PsnNo: res.Output.Baseinfo.PsnNo,
  7716. PatientId: patient.ID,
  7717. Certno: res.Output.Baseinfo.Certno,
  7718. Brdy: b,
  7719. Age: float64(age),
  7720. Gend: res.Output.Baseinfo.Gend,
  7721. Naty: res.Output.Baseinfo.Naty,
  7722. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7723. PsnName: res.Output.Baseinfo.PsnName,
  7724. Idetinfo: idetinfoStr,
  7725. Insuinfo: infoStr,
  7726. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7727. }
  7728. service.CreateHisPsn(psn)
  7729. var rf []*ResultFive
  7730. json.Unmarshal([]byte(infoStr), &rf)
  7731. var insutypes []*ResultFive
  7732. var insutype string
  7733. var is390 int = 0
  7734. var is310 int = 0
  7735. for _, item := range rf {
  7736. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7737. insutypes = append(insutypes, item)
  7738. }
  7739. }
  7740. if len(insutypes) == 1 {
  7741. insutype = insutypes[0].Insutype
  7742. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7743. } else {
  7744. for _, i := range insutypes {
  7745. if i.Insutype == "390" {
  7746. is390 = 1
  7747. }
  7748. if i.Insutype == "310" {
  7749. is310 = 1
  7750. }
  7751. }
  7752. }
  7753. if is390 == 1 {
  7754. insutype = "390"
  7755. }
  7756. if is310 == 1 {
  7757. insutype = "310"
  7758. }
  7759. if len(insutypes) == 0 {
  7760. insutype = "310"
  7761. }
  7762. c.ServeSuccessJSON(map[string]interface{}{
  7763. "patient": patient,
  7764. "number": res.Output.Baseinfo.Certno,
  7765. "insutype": insutype,
  7766. })
  7767. }
  7768. } else {
  7769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7770. return
  7771. }
  7772. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7773. var api string
  7774. if miConfig.MdtrtareaAdmvs == "320921" {
  7775. 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 +
  7776. "&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
  7777. fmt.Println(api)
  7778. } else {
  7779. 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 +
  7780. "&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)
  7781. }
  7782. resp, requestErr := http.Get(api)
  7783. if requestErr != nil {
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. body, ioErr := ioutil.ReadAll(resp.Body)
  7788. if ioErr != nil {
  7789. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. var respJSON map[string]interface{}
  7794. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7795. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. var status string
  7800. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7801. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7802. //console.log()
  7803. fmt.Println("type===")
  7804. fmt.Println(card_type)
  7805. var token string
  7806. var res ResultTwo //1101结果
  7807. var res10265 ResultTwo10265 //1101结果
  7808. var card_info string //卡信息
  7809. var busi_card_info string
  7810. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7811. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7812. if status == "0" { //读卡成功
  7813. if card_type == "1" {
  7814. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7815. result, _ := json.Marshal(respJSON)
  7816. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7817. utils.ErrorLog("解析失败:%v", err)
  7818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7819. return
  7820. }
  7821. res.ErrMsg = res10265.ErrMsg
  7822. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7823. res.Infcode = infocode
  7824. res.Output = res10265.Output
  7825. res.InfRefmsgid = res10265.InfRefmsgid
  7826. } else {
  7827. //var card_info string //卡信息
  7828. //var busi_card_info string
  7829. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7830. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7831. //fmt.Println(card_info)
  7832. //fmt.Println(busi_card_info)
  7833. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7834. result, _ := json.Marshal(respJSON)
  7835. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7836. utils.ErrorLog("解析失败:%v", err)
  7837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7838. return
  7839. }
  7840. res.ErrMsg = res10265.ErrMsg
  7841. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7842. res.Infcode = infocode
  7843. res.Output = res10265.Output
  7844. res.InfRefmsgid = res10265.InfRefmsgid
  7845. }
  7846. if res.Infcode == 0 {
  7847. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7848. if err == gorm.ErrRecordNotFound {
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7850. return
  7851. } else if err != nil {
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7853. return
  7854. } else {
  7855. if card_type == "1" {
  7856. bas := strings.Split(card_info, "|")
  7857. basNumber := bas[2]
  7858. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7859. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7860. infoStr := string(Iinfos)
  7861. idetinfoStr := string(Idetinfos)
  7862. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7863. psn := &models.HisPsn{
  7864. PsnNo: res.Output.Baseinfo.PsnNo,
  7865. PatientId: patient.ID,
  7866. Certno: res.Output.Baseinfo.Certno,
  7867. Brdy: b,
  7868. Age: float64(age),
  7869. Gend: res.Output.Baseinfo.Gend,
  7870. Naty: res.Output.Baseinfo.Naty,
  7871. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7872. PsnName: res.Output.Baseinfo.PsnName,
  7873. Idetinfo: idetinfoStr,
  7874. Insuinfo: infoStr,
  7875. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7876. CardInfo: card_info,
  7877. VerifyNumber: busi_card_info,
  7878. }
  7879. service.CreateHisPsn(psn)
  7880. var rf []*ResultFive
  7881. json.Unmarshal([]byte(infoStr), &rf)
  7882. var insutypes []*ResultFive
  7883. var insutype string
  7884. var is390 int = 0
  7885. var is310 int = 0
  7886. for _, item := range rf {
  7887. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7888. insutypes = append(insutypes, item)
  7889. }
  7890. }
  7891. if len(insutypes) == 1 {
  7892. insutype = insutypes[0].Insutype
  7893. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7894. } else {
  7895. for _, i := range insutypes {
  7896. if i.Insutype == "390" {
  7897. is390 = 1
  7898. }
  7899. if i.Insutype == "310" {
  7900. is310 = 1
  7901. }
  7902. }
  7903. }
  7904. if is390 == 1 {
  7905. insutype = "390"
  7906. }
  7907. if is310 == 1 {
  7908. insutype = "310"
  7909. }
  7910. if len(insutypes) == 0 {
  7911. insutype = "310"
  7912. }
  7913. c.ServeSuccessJSON(map[string]interface{}{
  7914. "patient": patient,
  7915. "number": basNumber,
  7916. "insutype": insutype,
  7917. })
  7918. } else {
  7919. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7920. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7921. infoStr := string(Iinfos)
  7922. idetinfoStr := string(Idetinfos)
  7923. psn := &models.HisPsn{
  7924. PsnNo: res.Output.Baseinfo.PsnNo,
  7925. PatientId: patient.ID,
  7926. Certno: res.Output.Baseinfo.Certno,
  7927. Gend: res.Output.Baseinfo.Gend,
  7928. Naty: res.Output.Baseinfo.Naty,
  7929. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7930. PsnName: res.Output.Baseinfo.PsnName,
  7931. Idetinfo: idetinfoStr,
  7932. Insuinfo: infoStr,
  7933. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7934. CardInfo: card_info,
  7935. VerifyNumber: token,
  7936. }
  7937. service.CreateHisPsn(psn)
  7938. c.ServeSuccessJSON(map[string]interface{}{
  7939. "patient": patient,
  7940. "number": token,
  7941. })
  7942. }
  7943. }
  7944. } else {
  7945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7946. return
  7947. }
  7948. } else { //读卡失败
  7949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7950. return
  7951. }
  7952. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7953. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7954. cardnum = DeleteExtraSpaceTwo(cardnum)
  7955. cardCode = DeleteExtraSpaceTwo(cardCode)
  7956. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7957. name = DeleteExtraSpaceTwo(name)
  7958. errmsg = DeleteExtraSpaceTwo(errmsg)
  7959. cardnum = Remove0000(cardnum)
  7960. cardCode = Remove0000(cardCode)
  7961. id_card_no = Remove0000(id_card_no)
  7962. name = Remove0000(name)
  7963. errmsg = Remove0000(errmsg)
  7964. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7965. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7966. //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)
  7967. //fmt.Println(result2)
  7968. //fmt.Println(requestLog2)
  7969. //fmt.Println(errMsgLog2)
  7970. 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)
  7971. saveLog(result, requestLog, "1101", "获取人员信息")
  7972. fmt.Println(errMsgLog)
  7973. if len(errMsgLog) > 0 {
  7974. } else {
  7975. var dat map[string]interface{}
  7976. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7977. fmt.Println(dat)
  7978. } else {
  7979. fmt.Println(err)
  7980. }
  7981. userJSONBytes, _ := json.Marshal(dat)
  7982. var res ResultTwo
  7983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7984. utils.ErrorLog("解析失败:%v", err)
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. res.ErrMsg = errMsgLog
  7989. if res.Infcode == 0 {
  7990. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7991. if err == gorm.ErrRecordNotFound {
  7992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7993. return
  7994. } else if err != nil {
  7995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7996. return
  7997. } else {
  7998. fmt.Println(res)
  7999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8001. infoStr := string(Iinfos)
  8002. idetinfoStr := string(Idetinfos)
  8003. var rf []*ResultFive
  8004. json.Unmarshal([]byte(infoStr), &rf)
  8005. var insutypes []*ResultFive
  8006. var insutype string
  8007. var is390 int = 0
  8008. var is310 int = 0
  8009. for _, item := range rf {
  8010. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8011. insutypes = append(insutypes, item)
  8012. }
  8013. }
  8014. if len(insutypes) == 1 {
  8015. insutype = insutypes[0].Insutype
  8016. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8017. } else {
  8018. for _, i := range insutypes {
  8019. if i.Insutype == "390" {
  8020. is390 = 1
  8021. }
  8022. if i.Insutype == "310" {
  8023. is310 = 1
  8024. }
  8025. }
  8026. }
  8027. if is390 == 1 {
  8028. insutype = "390"
  8029. }
  8030. if is310 == 1 {
  8031. insutype = "310"
  8032. }
  8033. if len(insutypes) == 0 {
  8034. insutype = "390"
  8035. }
  8036. var insuplc_admdvs string
  8037. for _, item := range rf {
  8038. if item.Insutype == insutype {
  8039. insuplc_admdvs = item.InsuplcAdmdvs
  8040. }
  8041. }
  8042. psn := &models.HisPsn{
  8043. PsnNo: res.Output.Baseinfo.PsnNo,
  8044. PatientId: patient.ID,
  8045. Certno: res.Output.Baseinfo.Certno,
  8046. Gend: res.Output.Baseinfo.Gend,
  8047. Naty: res.Output.Baseinfo.Naty,
  8048. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8049. PsnName: res.Output.Baseinfo.PsnName,
  8050. Idetinfo: idetinfoStr,
  8051. Insuinfo: infoStr,
  8052. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8053. CardInfo: basStr,
  8054. VerifyNumber: "",
  8055. InsuplcAdmdvs: insuplc_admdvs,
  8056. }
  8057. service.CreateHisPsn(psn)
  8058. c.ServeSuccessJSON(map[string]interface{}{
  8059. "patient": patient,
  8060. "number": cardnum,
  8061. "insutype": insutype,
  8062. })
  8063. }
  8064. } else {
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8066. return
  8067. }
  8068. }
  8069. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8070. fmt.Println(initFlag)
  8071. fmt.Println("initFlag")
  8072. if initFlag == 0 {
  8073. c.TestGetJiangXiBasBaseInit()
  8074. }
  8075. basStr := c.GetBasBaseInfo()
  8076. if len(basStr) == 0 {
  8077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8078. return
  8079. }
  8080. fmt.Println(basStr)
  8081. bas := strings.Split(basStr, "|")
  8082. basNumber := bas[1]
  8083. fmt.Println(basNumber)
  8084. card_sn := bas[3]
  8085. fmt.Println(card_sn)
  8086. 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, "")
  8087. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8088. var dat map[string]interface{}
  8089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8090. fmt.Println(dat)
  8091. } else {
  8092. fmt.Println(err)
  8093. }
  8094. userJSONBytes, _ := json.Marshal(dat)
  8095. var res ResultTwo
  8096. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8097. utils.ErrorLog("解析失败:%v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. if res.Infcode == 0 {
  8102. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8103. if err == gorm.ErrRecordNotFound {
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8105. return
  8106. } else if err != nil {
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8108. return
  8109. } else {
  8110. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8111. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8112. infoStr := string(Iinfos)
  8113. idetinfoStr := string(Idetinfos)
  8114. var rf []*ResultFive
  8115. json.Unmarshal([]byte(infoStr), &rf)
  8116. var insutypes []*ResultFive
  8117. var insutype string
  8118. var is390 int = 0
  8119. var is310 int = 0
  8120. var insuplc_admdvs string
  8121. for _, item := range rf {
  8122. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8123. insutypes = append(insutypes, item)
  8124. }
  8125. }
  8126. if len(insutypes) == 1 {
  8127. insutype = insutypes[0].Insutype
  8128. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8129. } else {
  8130. for _, i := range insutypes {
  8131. if i.Insutype == "390" {
  8132. is390 = 1
  8133. }
  8134. if i.Insutype == "310" {
  8135. is310 = 1
  8136. }
  8137. }
  8138. }
  8139. if is390 == 1 {
  8140. insutype = "390"
  8141. }
  8142. if is310 == 1 {
  8143. insutype = "310"
  8144. }
  8145. if len(insutypes) == 0 {
  8146. insutype = "310"
  8147. }
  8148. for _, item := range rf {
  8149. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8150. insuplc_admdvs = item.InsuplcAdmdvs
  8151. }
  8152. }
  8153. psn := &models.HisPsn{
  8154. PsnNo: res.Output.Baseinfo.PsnNo,
  8155. PatientId: patient.ID,
  8156. Certno: res.Output.Baseinfo.Certno,
  8157. Gend: res.Output.Baseinfo.Gend,
  8158. Naty: res.Output.Baseinfo.Naty,
  8159. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8160. PsnName: res.Output.Baseinfo.PsnName,
  8161. Idetinfo: idetinfoStr,
  8162. Insuinfo: infoStr,
  8163. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8164. CardInfo: basStr,
  8165. InsuplcAdmdvs: insuplc_admdvs,
  8166. VerifyNumber: "",
  8167. }
  8168. service.CreateHisPsn(psn)
  8169. c.ServeSuccessJSON(map[string]interface{}{
  8170. "patient": patient,
  8171. "number": basNumber,
  8172. "insutype": insutype,
  8173. })
  8174. }
  8175. } else {
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8177. return
  8178. }
  8179. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8180. fmt.Println(initFlag)
  8181. fmt.Println("initFlag")
  8182. if initFlag == 0 {
  8183. c.TestGetHnBasBaseInit()
  8184. }
  8185. basStr := c.GetBasBaseInfo()
  8186. if len(basStr) == 0 {
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8188. return
  8189. }
  8190. fmt.Println(basStr)
  8191. bas := strings.Split(basStr, "|")
  8192. basNumber := bas[1]
  8193. fmt.Println(basNumber)
  8194. card_sn := bas[3]
  8195. card_no := bas[2]
  8196. fmt.Println(card_sn)
  8197. name := bas[4]
  8198. name = ConvertToString(name, "gbk", "utf-8")
  8199. 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)
  8200. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8201. var dat map[string]interface{}
  8202. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8203. fmt.Println(dat)
  8204. } else {
  8205. fmt.Println(err)
  8206. }
  8207. userJSONBytes, _ := json.Marshal(dat)
  8208. var res ResultTwo
  8209. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8210. utils.ErrorLog("解析失败:%v", err)
  8211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8212. return
  8213. }
  8214. if res.Infcode == 0 {
  8215. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8216. if err == gorm.ErrRecordNotFound {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8218. return
  8219. } else if err != nil {
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8221. return
  8222. } else {
  8223. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8224. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8225. infoStr := string(Iinfos)
  8226. idetinfoStr := string(Idetinfos)
  8227. psn := &models.HisPsn{
  8228. PsnNo: res.Output.Baseinfo.PsnNo,
  8229. PatientId: patient.ID,
  8230. Certno: res.Output.Baseinfo.Certno,
  8231. Gend: res.Output.Baseinfo.Gend,
  8232. Naty: res.Output.Baseinfo.Naty,
  8233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8234. PsnName: res.Output.Baseinfo.PsnName,
  8235. Idetinfo: idetinfoStr,
  8236. Insuinfo: infoStr,
  8237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8238. CardInfo: basStr,
  8239. VerifyNumber: "",
  8240. }
  8241. service.CreateHisPsn(psn)
  8242. var rf []*ResultFive
  8243. json.Unmarshal([]byte(infoStr), &rf)
  8244. var insutypes []*ResultFive
  8245. var insutype string
  8246. var is390 int = 0
  8247. var is310 int = 0
  8248. for _, item := range rf {
  8249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8250. insutypes = append(insutypes, item)
  8251. }
  8252. }
  8253. if len(insutypes) == 1 {
  8254. insutype = insutypes[0].Insutype
  8255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8256. } else {
  8257. for _, i := range insutypes {
  8258. if i.Insutype == "390" {
  8259. is390 = 1
  8260. }
  8261. if i.Insutype == "310" {
  8262. is310 = 1
  8263. }
  8264. }
  8265. }
  8266. if is390 == 1 {
  8267. insutype = "390"
  8268. }
  8269. if is310 == 1 {
  8270. insutype = "310"
  8271. }
  8272. if len(insutypes) == 0 {
  8273. insutype = "310"
  8274. }
  8275. c.ServeSuccessJSON(map[string]interface{}{
  8276. "patient": patient,
  8277. "number": basNumber,
  8278. "insutype": insutype,
  8279. })
  8280. }
  8281. } else {
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8283. return
  8284. }
  8285. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8286. var api string
  8287. 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 +
  8288. "&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
  8289. fmt.Println(api)
  8290. resp, requestErr := http.Get(api)
  8291. if requestErr != nil {
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. body, ioErr := ioutil.ReadAll(resp.Body)
  8296. if ioErr != nil {
  8297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. var respJSON map[string]interface{}
  8302. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. var res ResultTwo //1101结果
  8308. var res10265 ResultTwo10265 //1101结果
  8309. var card_info string //卡信息
  8310. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8311. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8312. result, _ := json.Marshal(respJSON)
  8313. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8314. utils.ErrorLog("解析失败:%v", err)
  8315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8316. return
  8317. }
  8318. res.ErrMsg = res10265.ErrMsg
  8319. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8320. res.Infcode = infocode
  8321. res.Output = res10265.Output
  8322. res.InfRefmsgid = res10265.InfRefmsgid
  8323. if res.Infcode == 0 {
  8324. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8325. if err == gorm.ErrRecordNotFound {
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8327. return
  8328. } else if err != nil {
  8329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8330. return
  8331. } else {
  8332. bas := strings.Split(card_info, "|")
  8333. basNumber := bas[2]
  8334. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8335. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8336. infoStr := string(Iinfos)
  8337. idetinfoStr := string(Idetinfos)
  8338. psn := &models.HisPsn{
  8339. PsnNo: res.Output.Baseinfo.PsnNo,
  8340. PatientId: patient.ID,
  8341. Certno: res.Output.Baseinfo.Certno,
  8342. Gend: res.Output.Baseinfo.Gend,
  8343. Naty: res.Output.Baseinfo.Naty,
  8344. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8345. PsnName: res.Output.Baseinfo.PsnName,
  8346. Idetinfo: idetinfoStr,
  8347. Insuinfo: infoStr,
  8348. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8349. CardInfo: card_info,
  8350. VerifyNumber: token,
  8351. }
  8352. service.CreateHisPsn(psn)
  8353. var rf []*ResultFive
  8354. json.Unmarshal([]byte(infoStr), &rf)
  8355. var insutypes []*ResultFive
  8356. var insutype string
  8357. var is390 int = 0
  8358. var is310 int = 0
  8359. for _, item := range rf {
  8360. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8361. insutypes = append(insutypes, item)
  8362. }
  8363. }
  8364. if len(insutypes) == 1 {
  8365. insutype = insutypes[0].Insutype
  8366. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8367. } else {
  8368. for _, i := range insutypes {
  8369. if i.Insutype == "390" {
  8370. is390 = 1
  8371. }
  8372. if i.Insutype == "310" {
  8373. is310 = 1
  8374. }
  8375. }
  8376. }
  8377. if is390 == 1 {
  8378. insutype = "390"
  8379. }
  8380. if is310 == 1 {
  8381. insutype = "310"
  8382. }
  8383. if len(insutypes) == 0 {
  8384. insutype = "310"
  8385. }
  8386. c.ServeSuccessJSON(map[string]interface{}{
  8387. "patient": patient,
  8388. "number": basNumber,
  8389. "insutype": insutype,
  8390. })
  8391. }
  8392. } else {
  8393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8394. return
  8395. }
  8396. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8397. res := c.GetoleInfo()
  8398. if res.Infcode == 0 {
  8399. var result string
  8400. if res.Output.MdtrtCertType == "01" {
  8401. 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)
  8402. } else if res.Output.MdtrtCertType == "02" {
  8403. 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)
  8404. } else if res.Output.MdtrtCertType == "03" {
  8405. 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)
  8406. }
  8407. var dat map[string]interface{}
  8408. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8409. fmt.Println(dat)
  8410. } else {
  8411. fmt.Println(err)
  8412. }
  8413. userJSONBytes, _ := json.Marshal(dat)
  8414. var res2 ResultTwo
  8415. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8416. utils.ErrorLog("解析失败:%v", err)
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. if res2.Infcode == 0 {
  8421. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8422. if err == gorm.ErrRecordNotFound {
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8424. return
  8425. } else if err != nil {
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8427. return
  8428. } else {
  8429. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8430. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8431. infoStr := string(Iinfos)
  8432. idetinfoStr := string(Idetinfos)
  8433. var rf []*ResultFive
  8434. json.Unmarshal([]byte(infoStr), &rf)
  8435. var insutypes []*ResultFive
  8436. var insutype string
  8437. var is390 int = 0
  8438. var is310 int = 0
  8439. //var insuplc_admdvs string
  8440. for _, item := range rf {
  8441. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8442. insutypes = append(insutypes, item)
  8443. }
  8444. }
  8445. if len(insutypes) == 1 {
  8446. insutype = insutypes[0].Insutype
  8447. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8448. } else {
  8449. for _, i := range insutypes {
  8450. if i.Insutype == "390" {
  8451. is390 = 1
  8452. }
  8453. if i.Insutype == "310" {
  8454. is310 = 1
  8455. }
  8456. }
  8457. }
  8458. if is390 == 1 {
  8459. insutype = "390"
  8460. }
  8461. if is310 == 1 {
  8462. insutype = "310"
  8463. }
  8464. if len(insutypes) == 0 {
  8465. insutype = "310"
  8466. }
  8467. psn := &models.HisPsn{
  8468. PsnNo: res2.Output.Baseinfo.PsnNo,
  8469. PatientId: patient.ID,
  8470. Certno: res2.Output.Baseinfo.Certno,
  8471. Gend: res2.Output.Baseinfo.Gend,
  8472. Naty: res2.Output.Baseinfo.Naty,
  8473. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8474. PsnName: res2.Output.Baseinfo.PsnName,
  8475. Idetinfo: idetinfoStr,
  8476. Insuinfo: infoStr,
  8477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8478. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8479. VerifyNumber: res.Output.EcToken,
  8480. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8481. }
  8482. if res.Output.MdtrtCertType == "01" {
  8483. psn.VerifyNumber = res.Output.EcToken
  8484. //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)
  8485. } else if res.Output.MdtrtCertType == "02" {
  8486. psn.VerifyNumber = res.Output.MdtrtCertNo
  8487. //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)
  8488. } else if res.Output.MdtrtCertType == "03" {
  8489. psn.VerifyNumber = res.Output.MdtrtCertNo
  8490. //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)
  8491. }
  8492. var balc float64
  8493. for _, item := range rf {
  8494. if item.Insutype == insutype {
  8495. balc = item.Balc
  8496. }
  8497. }
  8498. service.CreateHisPsn(psn)
  8499. c.ServeSuccessJSON(map[string]interface{}{
  8500. "patient": patient,
  8501. "number": res.Output.CardNo,
  8502. "insutype": insutype,
  8503. "blac": balc,
  8504. "desc": idetinfoStr,
  8505. })
  8506. }
  8507. } else {
  8508. c.ServeSuccessJSON(map[string]interface{}{
  8509. "failed_code": -10,
  8510. "msg": res2.ErrMsg,
  8511. })
  8512. }
  8513. } else {
  8514. c.ServeSuccessJSON(map[string]interface{}{
  8515. "failed_code": -10,
  8516. "msg": res.ErrMsg,
  8517. })
  8518. }
  8519. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8520. var api string
  8521. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8522. "&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
  8523. fmt.Println(api)
  8524. resp, requestErr := http.Get(api)
  8525. if requestErr != nil {
  8526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8527. return
  8528. }
  8529. body, ioErr := ioutil.ReadAll(resp.Body)
  8530. if ioErr != nil {
  8531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. return
  8534. }
  8535. var respJSON map[string]interface{}
  8536. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. var status string
  8542. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8543. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8544. //console.log()
  8545. fmt.Println("type===")
  8546. fmt.Println(card_type)
  8547. var token string
  8548. var res ResultTwo //1101结果
  8549. //var res10265 ResultTwoesultTwo10265 //1101结果
  8550. var card_info string //卡信息
  8551. var busi_card_info string
  8552. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8553. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8554. if status == "0" { //读卡成功
  8555. if card_type == "1" {
  8556. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8557. result, _ := json.Marshal(respJSON)
  8558. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8559. utils.ErrorLog("解析失败:%v", err)
  8560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8561. return
  8562. }
  8563. } else {
  8564. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8565. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8566. result, _ := json.Marshal(respJSON)
  8567. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8568. utils.ErrorLog("解析失败:%v", err)
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8570. return
  8571. }
  8572. }
  8573. if res.Infcode == 0 {
  8574. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8575. if err == gorm.ErrRecordNotFound {
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8577. return
  8578. } else if err != nil {
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8580. return
  8581. } else {
  8582. if card_type == "1" {
  8583. bas := strings.Split(card_info, "|")
  8584. basNumber := bas[2]
  8585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8587. infoStr := string(Iinfos)
  8588. idetinfoStr := string(Idetinfos)
  8589. psn := &models.HisPsn{
  8590. PsnNo: res.Output.Baseinfo.PsnNo,
  8591. PatientId: patient.ID,
  8592. Certno: res.Output.Baseinfo.Certno,
  8593. Gend: res.Output.Baseinfo.Gend,
  8594. Naty: res.Output.Baseinfo.Naty,
  8595. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8596. PsnName: res.Output.Baseinfo.PsnName,
  8597. Idetinfo: idetinfoStr,
  8598. Insuinfo: infoStr,
  8599. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8600. CardInfo: card_info,
  8601. VerifyNumber: busi_card_info,
  8602. }
  8603. service.CreateHisPsn(psn)
  8604. var rf []*ResultFive
  8605. json.Unmarshal([]byte(infoStr), &rf)
  8606. var insutypes []*ResultFive
  8607. var insutype string
  8608. var is390 int = 0
  8609. var is310 int = 0
  8610. for _, item := range rf {
  8611. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8612. insutypes = append(insutypes, item)
  8613. }
  8614. }
  8615. if len(insutypes) == 1 {
  8616. insutype = insutypes[0].Insutype
  8617. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8618. } else {
  8619. for _, i := range insutypes {
  8620. if i.Insutype == "390" {
  8621. is390 = 1
  8622. }
  8623. if i.Insutype == "310" {
  8624. is310 = 1
  8625. }
  8626. }
  8627. }
  8628. if is390 == 1 {
  8629. insutype = "390"
  8630. }
  8631. if is310 == 1 {
  8632. insutype = "310"
  8633. }
  8634. if len(insutypes) == 0 {
  8635. insutype = "310"
  8636. }
  8637. c.ServeSuccessJSON(map[string]interface{}{
  8638. "patient": patient,
  8639. "number": basNumber,
  8640. "insutype": insutype,
  8641. })
  8642. } else {
  8643. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8644. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8645. infoStr := string(Iinfos)
  8646. idetinfoStr := string(Idetinfos)
  8647. psn := &models.HisPsn{
  8648. PsnNo: res.Output.Baseinfo.PsnNo,
  8649. PatientId: patient.ID,
  8650. Certno: res.Output.Baseinfo.Certno,
  8651. Gend: res.Output.Baseinfo.Gend,
  8652. Naty: res.Output.Baseinfo.Naty,
  8653. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8654. PsnName: res.Output.Baseinfo.PsnName,
  8655. Idetinfo: idetinfoStr,
  8656. Insuinfo: infoStr,
  8657. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8658. CardInfo: card_info,
  8659. VerifyNumber: token,
  8660. }
  8661. service.CreateHisPsn(psn)
  8662. c.ServeSuccessJSON(map[string]interface{}{
  8663. "patient": patient,
  8664. "number": token,
  8665. })
  8666. }
  8667. }
  8668. } else {
  8669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8670. return
  8671. }
  8672. } else { //读卡失败
  8673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8674. return
  8675. }
  8676. } else {
  8677. if initFlag == 0 {
  8678. c.TestGetBasBaseInit()
  8679. }
  8680. basStr := c.GetBasBaseInfo()
  8681. if len(basStr) == 0 {
  8682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8683. return
  8684. }
  8685. fmt.Println(basStr)
  8686. bas := strings.Split(basStr, "|")
  8687. basNumber := bas[1]
  8688. fmt.Println(basNumber)
  8689. card_sn := bas[3]
  8690. fmt.Println(card_sn)
  8691. cardNumber := bas[2]
  8692. fmt.Println(cardNumber)
  8693. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8694. var result string
  8695. if bas[0][:2] == "44" {
  8696. 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)
  8697. } else {
  8698. 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)
  8699. }
  8700. var dat map[string]interface{}
  8701. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8702. fmt.Println(dat)
  8703. } else {
  8704. fmt.Println(err)
  8705. }
  8706. userJSONBytes, _ := json.Marshal(dat)
  8707. var res ResultTwo
  8708. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8709. utils.ErrorLog("解析失败:%v", err)
  8710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8711. return
  8712. }
  8713. if res.Infcode == 0 {
  8714. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8715. if err == gorm.ErrRecordNotFound {
  8716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8717. return
  8718. } else if err != nil {
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8720. return
  8721. } else {
  8722. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8723. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8724. infoStr := string(Iinfos)
  8725. idetinfoStr := string(Idetinfos)
  8726. var rf []*ResultFive
  8727. json.Unmarshal([]byte(infoStr), &rf)
  8728. var insutypes []*ResultFive
  8729. var insutype string
  8730. var is390 int = 0
  8731. var is310 int = 0
  8732. var insuplc_admdvs string
  8733. for _, item := range rf {
  8734. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8735. insutypes = append(insutypes, item)
  8736. }
  8737. }
  8738. if len(insutypes) == 1 {
  8739. insutype = insutypes[0].Insutype
  8740. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8741. } else {
  8742. for _, i := range insutypes {
  8743. if i.Insutype == "390" {
  8744. is390 = 1
  8745. }
  8746. if i.Insutype == "310" {
  8747. is310 = 1
  8748. }
  8749. }
  8750. }
  8751. if is390 == 1 {
  8752. insutype = "390"
  8753. }
  8754. if is310 == 1 {
  8755. insutype = "310"
  8756. }
  8757. if len(insutypes) == 0 {
  8758. insutype = "310"
  8759. }
  8760. for _, item := range rf {
  8761. if item.Insutype == insutype {
  8762. insuplc_admdvs = item.InsuplcAdmdvs
  8763. }
  8764. }
  8765. psn := &models.HisPsn{
  8766. PsnNo: res.Output.Baseinfo.PsnNo,
  8767. PatientId: patient.ID,
  8768. Certno: res.Output.Baseinfo.Certno,
  8769. Gend: res.Output.Baseinfo.Gend,
  8770. Naty: res.Output.Baseinfo.Naty,
  8771. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8772. PsnName: res.Output.Baseinfo.PsnName,
  8773. Idetinfo: idetinfoStr,
  8774. Insuinfo: infoStr,
  8775. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8776. CardInfo: basStr,
  8777. VerifyNumber: "",
  8778. InsuplcAdmdvs: insuplc_admdvs,
  8779. }
  8780. service.CreateHisPsn(psn)
  8781. c.ServeSuccessJSON(map[string]interface{}{
  8782. "patient": patient,
  8783. "number": basNumber,
  8784. })
  8785. }
  8786. } else {
  8787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8788. return
  8789. }
  8790. break
  8791. }
  8792. case 2:
  8793. if miConfig.MdtrtareaAdmvs == "430800" {
  8794. if initFlag == 0 {
  8795. c.TestGetHnBasBaseInit()
  8796. }
  8797. SFZStr := c.GetSFZBaseInfo()
  8798. if len(SFZStr) == 0 {
  8799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8800. return
  8801. }
  8802. fmt.Println(SFZStr)
  8803. id_card_str := strings.Split(SFZStr, "^")
  8804. card_no := id_card_str[0]
  8805. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8806. //name := id_card_str[1]
  8807. //name = ConvertToString(name, "gbk", "utf-8")
  8808. 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)
  8809. var dat map[string]interface{}
  8810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8811. fmt.Println(dat)
  8812. } else {
  8813. fmt.Println(err)
  8814. }
  8815. userJSONBytes, _ := json.Marshal(dat)
  8816. var res ResultTwo
  8817. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8818. utils.ErrorLog("解析失败:%v", err)
  8819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8820. return
  8821. }
  8822. if res.Infcode == 0 {
  8823. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8824. if err == gorm.ErrRecordNotFound {
  8825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8826. return
  8827. } else if err != nil {
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8829. return
  8830. } else {
  8831. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8832. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8833. infoStr := string(Iinfos)
  8834. idetinfoStr := string(Idetinfos)
  8835. var rf []*ResultFive
  8836. json.Unmarshal([]byte(infoStr), &rf)
  8837. var insutypes []*ResultFive
  8838. var insutype string
  8839. var is390 int = 0
  8840. var is310 int = 0
  8841. for _, item := range rf {
  8842. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8843. insutypes = append(insutypes, item)
  8844. }
  8845. }
  8846. if len(insutypes) == 1 {
  8847. insutype = insutypes[0].Insutype
  8848. } else {
  8849. for _, i := range insutypes {
  8850. if i.Insutype == "390" {
  8851. is390 = 1
  8852. }
  8853. if i.Insutype == "310" {
  8854. is310 = 1
  8855. }
  8856. }
  8857. }
  8858. if is390 == 1 {
  8859. insutype = "390"
  8860. }
  8861. if is310 == 1 {
  8862. insutype = "310"
  8863. }
  8864. if len(insutypes) == 0 {
  8865. insutype = "310"
  8866. }
  8867. var InsuplcAdmdvs string
  8868. for _, item := range rf {
  8869. if item.Insutype == insutype {
  8870. InsuplcAdmdvs = item.InsuplcAdmdvs
  8871. }
  8872. }
  8873. psn := &models.HisPsn{
  8874. PsnNo: res.Output.Baseinfo.PsnNo,
  8875. PatientId: patient.ID,
  8876. Certno: res.Output.Baseinfo.Certno,
  8877. Gend: res.Output.Baseinfo.Gend,
  8878. Naty: res.Output.Baseinfo.Naty,
  8879. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8880. PsnName: res.Output.Baseinfo.PsnName,
  8881. Idetinfo: idetinfoStr,
  8882. Insuinfo: infoStr,
  8883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8884. CardInfo: SFZStr,
  8885. VerifyNumber: "",
  8886. InsuplcAdmdvs: InsuplcAdmdvs,
  8887. }
  8888. service.CreateHisPsn(psn)
  8889. c.ServeSuccessJSON(map[string]interface{}{
  8890. "patient": patient,
  8891. "number": card_no,
  8892. "insutype": insutype,
  8893. })
  8894. }
  8895. } else {
  8896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8897. return
  8898. }
  8899. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8900. var res ResultTwo
  8901. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8902. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8903. "&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)
  8904. resp, requestErr := http.Get(api)
  8905. if requestErr != nil {
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. body, ioErr := ioutil.ReadAll(resp.Body)
  8910. if ioErr != nil {
  8911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. var respJSON map[string]interface{}
  8916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8919. return
  8920. }
  8921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8922. result, _ := json.Marshal(respJSON)
  8923. fmt.Println("log")
  8924. fmt.Println(string(result))
  8925. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8926. utils.ErrorLog("解析失败:%v", err)
  8927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8928. return
  8929. }
  8930. if res.Infcode == 0 {
  8931. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8932. if err == gorm.ErrRecordNotFound {
  8933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8934. return
  8935. } else if err != nil {
  8936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8937. return
  8938. } else {
  8939. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8940. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8941. infoStr := string(Iinfos)
  8942. idetinfoStr := string(Idetinfos)
  8943. psn := &models.HisPsn{
  8944. PsnNo: res.Output.Baseinfo.PsnNo,
  8945. PatientId: patient.ID,
  8946. Certno: res.Output.Baseinfo.Certno,
  8947. Gend: res.Output.Baseinfo.Gend,
  8948. Naty: res.Output.Baseinfo.Naty,
  8949. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8950. PsnName: res.Output.Baseinfo.PsnName,
  8951. Idetinfo: idetinfoStr,
  8952. Insuinfo: infoStr,
  8953. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8954. }
  8955. service.CreateHisPsn(psn)
  8956. c.ServeSuccessJSON(map[string]interface{}{
  8957. "patient": patient,
  8958. "number": res.Output.Baseinfo.Certno,
  8959. })
  8960. }
  8961. } else {
  8962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8963. return
  8964. }
  8965. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8966. var res ResultTwo
  8967. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8968. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8969. "&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)
  8970. resp, requestErr := http.Get(api)
  8971. if requestErr != nil {
  8972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8973. return
  8974. }
  8975. body, ioErr := ioutil.ReadAll(resp.Body)
  8976. if ioErr != nil {
  8977. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8979. return
  8980. }
  8981. var respJSON map[string]interface{}
  8982. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8983. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8985. return
  8986. }
  8987. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8988. result, _ := json.Marshal(respJSON)
  8989. fmt.Println("log")
  8990. fmt.Println(string(result))
  8991. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8992. utils.ErrorLog("解析失败:%v", err)
  8993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8994. return
  8995. }
  8996. if res.Infcode == 0 {
  8997. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8998. if err == gorm.ErrRecordNotFound {
  8999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9000. return
  9001. } else if err != nil {
  9002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9003. return
  9004. } else {
  9005. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9006. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9007. infoStr := string(Iinfos)
  9008. idetinfoStr := string(Idetinfos)
  9009. psn := &models.HisPsn{
  9010. PsnNo: res.Output.Baseinfo.PsnNo,
  9011. PatientId: patient.ID,
  9012. Certno: res.Output.Baseinfo.Certno,
  9013. Gend: res.Output.Baseinfo.Gend,
  9014. Naty: res.Output.Baseinfo.Naty,
  9015. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9016. PsnName: res.Output.Baseinfo.PsnName,
  9017. Idetinfo: idetinfoStr,
  9018. Insuinfo: infoStr,
  9019. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9020. }
  9021. service.CreateHisPsn(psn)
  9022. c.ServeSuccessJSON(map[string]interface{}{
  9023. "patient": patient,
  9024. "number": res.Output.Baseinfo.Certno,
  9025. })
  9026. }
  9027. } else {
  9028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9029. return
  9030. }
  9031. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9032. res := c.GetoleInfo()
  9033. if res.Infcode == 0 {
  9034. var result string
  9035. if res.Output.MdtrtCertType == "01" {
  9036. 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)
  9037. } else if res.Output.MdtrtCertType == "02" {
  9038. 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)
  9039. } else if res.Output.MdtrtCertType == "03" {
  9040. 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)
  9041. }
  9042. var dat map[string]interface{}
  9043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9044. fmt.Println(dat)
  9045. } else {
  9046. fmt.Println(err)
  9047. }
  9048. userJSONBytes, _ := json.Marshal(dat)
  9049. var res2 ResultTwo
  9050. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9051. utils.ErrorLog("解析失败:%v", err)
  9052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9053. return
  9054. }
  9055. if res2.Infcode == 0 {
  9056. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9057. if err == gorm.ErrRecordNotFound {
  9058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9059. return
  9060. } else if err != nil {
  9061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9062. return
  9063. } else {
  9064. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9065. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9066. infoStr := string(Iinfos)
  9067. idetinfoStr := string(Idetinfos)
  9068. var rf []*ResultFive
  9069. json.Unmarshal([]byte(infoStr), &rf)
  9070. var insutypes []*ResultFive
  9071. var insutype string
  9072. var is390 int = 0
  9073. var is310 int = 0
  9074. //var insuplc_admdvs string
  9075. for _, item := range rf {
  9076. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9077. insutypes = append(insutypes, item)
  9078. }
  9079. }
  9080. if len(insutypes) == 1 {
  9081. insutype = insutypes[0].Insutype
  9082. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9083. } else {
  9084. for _, i := range insutypes {
  9085. if i.Insutype == "390" {
  9086. is390 = 1
  9087. }
  9088. if i.Insutype == "310" {
  9089. is310 = 1
  9090. }
  9091. }
  9092. }
  9093. if is390 == 1 {
  9094. insutype = "390"
  9095. }
  9096. if is310 == 1 {
  9097. insutype = "310"
  9098. }
  9099. if len(insutypes) == 0 {
  9100. insutype = "310"
  9101. }
  9102. psn := &models.HisPsn{
  9103. PsnNo: res2.Output.Baseinfo.PsnNo,
  9104. PatientId: patient.ID,
  9105. //Brdy: res2.Output.Baseinfo.Brdy,
  9106. Certno: res2.Output.Baseinfo.Certno,
  9107. Gend: res2.Output.Baseinfo.Gend,
  9108. Naty: res2.Output.Baseinfo.Naty,
  9109. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9110. PsnName: res2.Output.Baseinfo.PsnName,
  9111. Idetinfo: idetinfoStr,
  9112. Insuinfo: infoStr,
  9113. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9114. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9115. VerifyNumber: res.Output.EcToken,
  9116. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9117. }
  9118. service.CreateHisPsn(psn)
  9119. var balc float64
  9120. for _, item := range rf {
  9121. if item.Insutype == insutype {
  9122. balc = item.Balc
  9123. }
  9124. }
  9125. c.ServeSuccessJSON(map[string]interface{}{
  9126. "patient": patient,
  9127. "number": res.Output.CardNo,
  9128. "insutype": insutype,
  9129. "blac": balc,
  9130. "desc": idetinfoStr,
  9131. })
  9132. }
  9133. } else {
  9134. c.ServeSuccessJSON(map[string]interface{}{
  9135. "failed_code": -10,
  9136. "msg": res2.ErrMsg,
  9137. })
  9138. }
  9139. } else {
  9140. c.ServeSuccessJSON(map[string]interface{}{
  9141. "failed_code": -10,
  9142. "msg": res.ErrMsg,
  9143. })
  9144. }
  9145. } else {
  9146. SFZStr := c.GetSFZBaseInfo()
  9147. id_card_str := strings.Split(SFZStr, "^")
  9148. id_card_number := id_card_str[0]
  9149. card_sn := ""
  9150. 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)
  9151. var dat map[string]interface{}
  9152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9153. fmt.Println(dat)
  9154. } else {
  9155. fmt.Println(err)
  9156. }
  9157. userJSONBytes, _ := json.Marshal(dat)
  9158. var res ResultTwo
  9159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9160. utils.ErrorLog("解析失败:%v", err)
  9161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9162. return
  9163. }
  9164. if res.Infcode == 0 {
  9165. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9166. if err == gorm.ErrRecordNotFound {
  9167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9168. return
  9169. } else if err != nil {
  9170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9171. return
  9172. } else {
  9173. c.ServeSuccessJSON(map[string]interface{}{
  9174. "patient": patient,
  9175. "number": id_card_number,
  9176. })
  9177. }
  9178. } else {
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9180. return
  9181. }
  9182. }
  9183. break
  9184. case 3:
  9185. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9186. var api string
  9187. if miConfig.MdtrtareaAdmvs == "320921" {
  9188. 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 +
  9189. "&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
  9190. fmt.Println(api)
  9191. } else {
  9192. 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 +
  9193. "&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)
  9194. }
  9195. resp, requestErr := http.Get(api)
  9196. if requestErr != nil {
  9197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9198. return
  9199. }
  9200. body, ioErr := ioutil.ReadAll(resp.Body)
  9201. if ioErr != nil {
  9202. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9204. return
  9205. }
  9206. var respJSON map[string]interface{}
  9207. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9208. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9210. return
  9211. }
  9212. var status string
  9213. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9214. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9215. var token string
  9216. var res ResultTwo //1101结果
  9217. var res10265 ResultTwo10265 //1101结果
  9218. var card_info string //卡信息
  9219. var busi_card_info string
  9220. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9221. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9222. if status == "0" { //读卡成功
  9223. if card_type == "1" {
  9224. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9225. result, _ := json.Marshal(respJSON)
  9226. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9227. utils.ErrorLog("解析失败:%v", err)
  9228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9229. return
  9230. }
  9231. res.ErrMsg = res10265.ErrMsg
  9232. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9233. res.Infcode = infocode
  9234. res.Output = res10265.Output
  9235. res.InfRefmsgid = res10265.InfRefmsgid
  9236. } else {
  9237. //var card_info string //卡信息
  9238. //var busi_card_info string
  9239. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9240. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9241. //fmt.Println(card_info)
  9242. //fmt.Println(busi_card_info)
  9243. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9244. result, _ := json.Marshal(respJSON)
  9245. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9246. utils.ErrorLog("解析失败:%v", err)
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9248. return
  9249. }
  9250. res.ErrMsg = res10265.ErrMsg
  9251. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9252. res.Infcode = infocode
  9253. res.Output = res10265.Output
  9254. res.InfRefmsgid = res10265.InfRefmsgid
  9255. }
  9256. if res.Infcode == 0 {
  9257. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9258. if err == gorm.ErrRecordNotFound {
  9259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9260. return
  9261. } else if err != nil {
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9263. return
  9264. } else {
  9265. if card_type == "1" {
  9266. bas := strings.Split(card_info, "|")
  9267. basNumber := bas[2]
  9268. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9269. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9270. infoStr := string(Iinfos)
  9271. idetinfoStr := string(Idetinfos)
  9272. psn := &models.HisPsn{
  9273. PsnNo: res.Output.Baseinfo.PsnNo,
  9274. PatientId: patient.ID,
  9275. Certno: res.Output.Baseinfo.Certno,
  9276. //Brdy: res.Output.Baseinfo.Brdy,
  9277. Gend: res.Output.Baseinfo.Gend,
  9278. Naty: res.Output.Baseinfo.Naty,
  9279. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9280. PsnName: res.Output.Baseinfo.PsnName,
  9281. Idetinfo: idetinfoStr,
  9282. Insuinfo: infoStr,
  9283. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9284. CardInfo: card_info,
  9285. VerifyNumber: busi_card_info,
  9286. }
  9287. service.CreateHisPsn(psn)
  9288. c.ServeSuccessJSON(map[string]interface{}{
  9289. "patient": patient,
  9290. "number": basNumber,
  9291. })
  9292. } else {
  9293. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9294. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9295. infoStr := string(Iinfos)
  9296. idetinfoStr := string(Idetinfos)
  9297. psn := &models.HisPsn{
  9298. PsnNo: res.Output.Baseinfo.PsnNo,
  9299. PatientId: patient.ID,
  9300. Certno: res.Output.Baseinfo.Certno,
  9301. Gend: res.Output.Baseinfo.Gend,
  9302. Naty: res.Output.Baseinfo.Naty,
  9303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9304. PsnName: res.Output.Baseinfo.PsnName,
  9305. Idetinfo: idetinfoStr,
  9306. Insuinfo: infoStr,
  9307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9308. CardInfo: card_info,
  9309. VerifyNumber: token,
  9310. }
  9311. service.CreateHisPsn(psn)
  9312. var rf []*ResultFive
  9313. json.Unmarshal([]byte(infoStr), &rf)
  9314. var insutypes []*ResultFive
  9315. var insutype string
  9316. var is390 int = 0
  9317. var is310 int = 0
  9318. for _, item := range rf {
  9319. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9320. insutypes = append(insutypes, item)
  9321. }
  9322. }
  9323. if len(insutypes) == 1 {
  9324. insutype = insutypes[0].Insutype
  9325. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9326. } else {
  9327. for _, i := range insutypes {
  9328. if i.Insutype == "390" {
  9329. is390 = 1
  9330. }
  9331. if i.Insutype == "310" {
  9332. is310 = 1
  9333. }
  9334. }
  9335. }
  9336. if is390 == 1 {
  9337. insutype = "390"
  9338. }
  9339. if is310 == 1 {
  9340. insutype = "310"
  9341. }
  9342. if len(insutypes) == 0 {
  9343. insutype = "310"
  9344. }
  9345. c.ServeSuccessJSON(map[string]interface{}{
  9346. "patient": patient,
  9347. "number": token,
  9348. "insutype": insutype,
  9349. })
  9350. }
  9351. }
  9352. } else {
  9353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9354. return
  9355. }
  9356. } else { //读卡失败
  9357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9358. return
  9359. }
  9360. }
  9361. break
  9362. case 4:
  9363. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9364. var api string
  9365. if miConfig.MdtrtareaAdmvs == "320921" {
  9366. 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 +
  9367. "&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
  9368. fmt.Println(api)
  9369. } else {
  9370. 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 +
  9371. "&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)
  9372. }
  9373. resp, requestErr := http.Get(api)
  9374. if requestErr != nil {
  9375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9376. return
  9377. }
  9378. body, ioErr := ioutil.ReadAll(resp.Body)
  9379. if ioErr != nil {
  9380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9382. return
  9383. }
  9384. var respJSON map[string]interface{}
  9385. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9388. return
  9389. }
  9390. var status string
  9391. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9392. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9393. var token string
  9394. var res ResultTwo //1101结果
  9395. var res10265 ResultTwo10265 //1101结果
  9396. if status == "0" { //读卡成功
  9397. var card_info string //卡信息
  9398. var busi_card_info string
  9399. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9400. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9401. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9402. fmt.Println(card_info)
  9403. fmt.Println(busi_card_info)
  9404. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9405. result, _ := json.Marshal(respJSON)
  9406. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9407. utils.ErrorLog("解析失败:%v", err)
  9408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9409. return
  9410. }
  9411. res.ErrMsg = res10265.ErrMsg
  9412. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9413. res.Infcode = infocode
  9414. res.Output = res10265.Output
  9415. res.InfRefmsgid = res10265.InfRefmsgid
  9416. if res.Infcode == 0 {
  9417. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9418. if err == gorm.ErrRecordNotFound {
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9420. return
  9421. } else if err != nil {
  9422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9423. return
  9424. } else {
  9425. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9426. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9427. infoStr := string(Iinfos)
  9428. idetinfoStr := string(Idetinfos)
  9429. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9430. psn := &models.HisPsn{
  9431. PsnNo: res.Output.Baseinfo.PsnNo,
  9432. PatientId: patient.ID,
  9433. Certno: res.Output.Baseinfo.Certno,
  9434. Brdy: b,
  9435. Age: float64(age),
  9436. //Brdy: res.Output.Baseinfo.Brdy,
  9437. Gend: res.Output.Baseinfo.Gend,
  9438. Naty: res.Output.Baseinfo.Naty,
  9439. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9440. PsnName: res.Output.Baseinfo.PsnName,
  9441. Idetinfo: idetinfoStr,
  9442. Insuinfo: infoStr,
  9443. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9444. CardInfo: card_info,
  9445. VerifyNumber: token,
  9446. }
  9447. var rf []*ResultFive
  9448. json.Unmarshal([]byte(infoStr), &rf)
  9449. var insutypes []*ResultFive
  9450. var insutype string
  9451. var is390 int = 0
  9452. var is310 int = 0
  9453. for _, item := range rf {
  9454. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9455. insutypes = append(insutypes, item)
  9456. }
  9457. }
  9458. if len(insutypes) == 1 {
  9459. insutype = insutypes[0].Insutype
  9460. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9461. } else {
  9462. for _, i := range insutypes {
  9463. if i.Insutype == "390" {
  9464. is390 = 1
  9465. }
  9466. if i.Insutype == "310" {
  9467. is310 = 1
  9468. }
  9469. }
  9470. }
  9471. if is390 == 1 {
  9472. insutype = "390"
  9473. }
  9474. if is310 == 1 {
  9475. insutype = "310"
  9476. }
  9477. if len(insutypes) == 0 {
  9478. insutype = "310"
  9479. }
  9480. service.CreateHisPsn(psn)
  9481. c.ServeSuccessJSON(map[string]interface{}{
  9482. "patient": patient,
  9483. "number": token,
  9484. "insutype": insutype,
  9485. })
  9486. }
  9487. } else {
  9488. c.ServeSuccessJSON(map[string]interface{}{
  9489. "failed_code": -10,
  9490. "msg": res.ErrMsg,
  9491. })
  9492. }
  9493. } else { //读卡失败
  9494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9495. return
  9496. }
  9497. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9498. var api string
  9499. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9500. "&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
  9501. resp, requestErr := http.Get(api)
  9502. if requestErr != nil {
  9503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9504. return
  9505. }
  9506. body, ioErr := ioutil.ReadAll(resp.Body)
  9507. if ioErr != nil {
  9508. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. var respJSON map[string]interface{}
  9513. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9514. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. var status string
  9519. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9520. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9521. var token string
  9522. var res ResultTwo //1101结果
  9523. if status == "1" { //读卡成功
  9524. var card_info string //卡信息
  9525. var busi_card_info string
  9526. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9527. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9528. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9529. fmt.Println(card_info)
  9530. fmt.Println(busi_card_info)
  9531. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9532. result, _ := json.Marshal(respJSON)
  9533. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9534. utils.ErrorLog("解析失败:%v", err)
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. return
  9537. }
  9538. if res.Infcode == 0 {
  9539. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9540. if err == gorm.ErrRecordNotFound {
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9542. return
  9543. } else if err != nil {
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9545. return
  9546. } else {
  9547. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9548. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9549. infoStr := string(Iinfos)
  9550. idetinfoStr := string(Idetinfos)
  9551. psn := &models.HisPsn{
  9552. PsnNo: res.Output.Baseinfo.PsnNo,
  9553. PatientId: patient.ID,
  9554. Certno: res.Output.Baseinfo.Certno,
  9555. Gend: res.Output.Baseinfo.Gend,
  9556. Naty: res.Output.Baseinfo.Naty,
  9557. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9558. PsnName: res.Output.Baseinfo.PsnName,
  9559. Idetinfo: idetinfoStr,
  9560. Insuinfo: infoStr,
  9561. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9562. CardInfo: card_info,
  9563. VerifyNumber: token,
  9564. }
  9565. var rf []*ResultFive
  9566. json.Unmarshal([]byte(infoStr), &rf)
  9567. var insutypes []*ResultFive
  9568. var insutype string
  9569. var is390 int = 0
  9570. var is310 int = 0
  9571. for _, item := range rf {
  9572. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9573. insutypes = append(insutypes, item)
  9574. }
  9575. }
  9576. if len(insutypes) == 1 {
  9577. insutype = insutypes[0].Insutype
  9578. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9579. } else {
  9580. for _, i := range insutypes {
  9581. if i.Insutype == "390" {
  9582. is390 = 1
  9583. }
  9584. if i.Insutype == "310" {
  9585. is310 = 1
  9586. }
  9587. }
  9588. }
  9589. if is390 == 1 {
  9590. insutype = "390"
  9591. }
  9592. if is310 == 1 {
  9593. insutype = "310"
  9594. }
  9595. if len(insutypes) == 0 {
  9596. insutype = "310"
  9597. }
  9598. service.CreateHisPsn(psn)
  9599. c.ServeSuccessJSON(map[string]interface{}{
  9600. "patient": patient,
  9601. "number": token,
  9602. "insutype": insutype,
  9603. })
  9604. }
  9605. } else {
  9606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9607. return
  9608. }
  9609. } else { //读卡失败
  9610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9611. return
  9612. }
  9613. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9614. idNo := c.GetString("idNo")
  9615. userName := c.GetString("userName")
  9616. ecToken := c.GetString("ecToken")
  9617. insuOrg := c.GetString("insuOrg")
  9618. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9619. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9620. var res ResultTwo
  9621. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9622. utils.ErrorLog("解析失败:%v", err)
  9623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9624. return
  9625. }
  9626. if res.Infcode == 0 {
  9627. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9628. if err == gorm.ErrRecordNotFound {
  9629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9630. return
  9631. } else if err != nil {
  9632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9633. return
  9634. } else {
  9635. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9636. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9637. infoStr := string(Iinfos)
  9638. idetinfoStr := string(Idetinfos)
  9639. psn := &models.HisPsn{
  9640. PsnNo: res.Output.Baseinfo.PsnNo,
  9641. PatientId: patient.ID,
  9642. Certno: res.Output.Baseinfo.Certno,
  9643. Gend: res.Output.Baseinfo.Gend,
  9644. Naty: res.Output.Baseinfo.Naty,
  9645. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9646. PsnName: res.Output.Baseinfo.PsnName,
  9647. Idetinfo: idetinfoStr,
  9648. Insuinfo: infoStr,
  9649. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9650. CardInfo: "",
  9651. Stage: "1",
  9652. VerifyNumber: ecToken,
  9653. InsuplcAdmdvs: insuOrg,
  9654. }
  9655. service.CreateHisPsn(psn)
  9656. var rf []*ResultFive
  9657. json.Unmarshal([]byte(infoStr), &rf)
  9658. var insutypes []*ResultFive
  9659. var insutype string
  9660. var is390 int = 0
  9661. var is310 int = 0
  9662. for _, item := range rf {
  9663. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9664. insutypes = append(insutypes, item)
  9665. }
  9666. }
  9667. if len(insutypes) == 1 {
  9668. insutype = insutypes[0].Insutype
  9669. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9670. } else {
  9671. for _, i := range insutypes {
  9672. if i.Insutype == "390" {
  9673. is390 = 1
  9674. }
  9675. if i.Insutype == "310" {
  9676. is310 = 1
  9677. }
  9678. }
  9679. }
  9680. if is390 == 1 {
  9681. insutype = "390"
  9682. }
  9683. if is310 == 1 {
  9684. insutype = "310"
  9685. }
  9686. if len(insutypes) == 0 {
  9687. insutype = "310"
  9688. }
  9689. c.ServeSuccessJSON(map[string]interface{}{
  9690. "patient": patient,
  9691. "number": ecToken,
  9692. "insutype": insutype,
  9693. })
  9694. }
  9695. } else {
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9697. return
  9698. }
  9699. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9700. //if initFlag == 0 {
  9701. //c.TestGetJiangXiBasBaseInit()
  9702. //}
  9703. //if initEleFlag == 0 {
  9704. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9705. //}
  9706. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9707. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9708. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9709. type ELeData struct {
  9710. Data struct {
  9711. IdNo string `json:"idNo"`
  9712. IdType string `json:"idType"`
  9713. UserName string `json:"userName"`
  9714. EcToken string `json:"ecToken"`
  9715. InsuOrg string `json:"insuOrg"`
  9716. Gender string `json:"gender"`
  9717. Birthday string `json:"birthday"`
  9718. Nationality string `json:"nationality"`
  9719. Email string `json:"email"`
  9720. Extra string `json:"extra"`
  9721. } `json:"data"`
  9722. Code int `json:"code"`
  9723. Message string `json:"message"`
  9724. }
  9725. var ele ELeData
  9726. err := json.Unmarshal([]byte(result), &ele)
  9727. if err != nil {
  9728. utils.ErrorLog("解析失败:%v", err)
  9729. }
  9730. token := ele.Data.EcToken
  9731. token = Remove0000(token)
  9732. 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)
  9733. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9734. var res ResultTwo
  9735. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9736. utils.ErrorLog("解析失败:%v", err)
  9737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9738. return
  9739. }
  9740. if res.Infcode == 0 {
  9741. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9742. if err == gorm.ErrRecordNotFound {
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9744. return
  9745. } else if err != nil {
  9746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9747. return
  9748. } else {
  9749. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9750. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9751. infoStr := string(Iinfos)
  9752. idetinfoStr := string(Idetinfos)
  9753. psn := &models.HisPsn{
  9754. PsnNo: res.Output.Baseinfo.PsnNo,
  9755. PatientId: patient.ID,
  9756. Certno: res.Output.Baseinfo.Certno,
  9757. Gend: res.Output.Baseinfo.Gend,
  9758. Naty: res.Output.Baseinfo.Naty,
  9759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9760. PsnName: res.Output.Baseinfo.PsnName,
  9761. Idetinfo: idetinfoStr,
  9762. Insuinfo: infoStr,
  9763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9764. CardInfo: "",
  9765. VerifyNumber: token,
  9766. }
  9767. service.CreateHisPsn(psn)
  9768. var rf []*ResultFive
  9769. json.Unmarshal([]byte(infoStr), &rf)
  9770. var insutypes []*ResultFive
  9771. var insutype string
  9772. var is390 int = 0
  9773. var is310 int = 0
  9774. for _, item := range rf {
  9775. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9776. insutypes = append(insutypes, item)
  9777. }
  9778. }
  9779. if len(insutypes) == 1 {
  9780. insutype = insutypes[0].Insutype
  9781. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9782. } else {
  9783. for _, i := range insutypes {
  9784. if i.Insutype == "390" {
  9785. is390 = 1
  9786. }
  9787. if i.Insutype == "310" {
  9788. is310 = 1
  9789. }
  9790. }
  9791. }
  9792. if is390 == 1 {
  9793. insutype = "390"
  9794. }
  9795. if is310 == 1 {
  9796. insutype = "310"
  9797. }
  9798. if len(insutypes) == 0 {
  9799. insutype = "310"
  9800. }
  9801. c.ServeSuccessJSON(map[string]interface{}{
  9802. "patient": patient,
  9803. "number": token,
  9804. "insutype": insutype,
  9805. })
  9806. }
  9807. } else {
  9808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9809. return
  9810. }
  9811. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9812. //if initFlag == 0 {
  9813. c.TestGetJiangXiBasBaseInit()
  9814. //}
  9815. //if initEleFlag == 0 {
  9816. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9817. //}
  9818. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9819. type ELeData struct {
  9820. Data struct {
  9821. IdNo string `json:"idNo"`
  9822. IdType string `json:"idType"`
  9823. UserName string `json:"userName"`
  9824. EcToken string `json:"ecToken"`
  9825. InsuOrg string `json:"insuOrg"`
  9826. Gender string `json:"gender"`
  9827. Birthday string `json:"birthday"`
  9828. Nationality string `json:"nationality"`
  9829. Email string `json:"email"`
  9830. Extra string `json:"extra"`
  9831. } `json:"data"`
  9832. Code int `json:"code"`
  9833. Message string `json:"message"`
  9834. }
  9835. var ele ELeData
  9836. err := json.Unmarshal([]byte(json_result), &ele)
  9837. if err != nil {
  9838. utils.ErrorLog("解析失败:%v", err)
  9839. }
  9840. token := ele.Data.EcToken
  9841. token = Remove0000(token)
  9842. 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)
  9843. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9844. var res ResultTwo
  9845. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9846. utils.ErrorLog("解析失败:%v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. if res.Infcode == 0 {
  9851. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9852. if err == gorm.ErrRecordNotFound {
  9853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9854. return
  9855. } else if err != nil {
  9856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9857. return
  9858. } else {
  9859. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9860. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9861. infoStr := string(Iinfos)
  9862. idetinfoStr := string(Idetinfos)
  9863. psn := &models.HisPsn{
  9864. PsnNo: res.Output.Baseinfo.PsnNo,
  9865. PatientId: patient.ID,
  9866. Certno: res.Output.Baseinfo.Certno,
  9867. Gend: res.Output.Baseinfo.Gend,
  9868. Naty: res.Output.Baseinfo.Naty,
  9869. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9870. PsnName: res.Output.Baseinfo.PsnName,
  9871. Idetinfo: idetinfoStr,
  9872. Insuinfo: infoStr,
  9873. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9874. CardInfo: "",
  9875. VerifyNumber: token,
  9876. }
  9877. service.CreateHisPsn(psn)
  9878. var rf []*ResultFive
  9879. json.Unmarshal([]byte(infoStr), &rf)
  9880. var insutypes []*ResultFive
  9881. var insutype string
  9882. var is390 int = 0
  9883. var is310 int = 0
  9884. for _, item := range rf {
  9885. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9886. insutypes = append(insutypes, item)
  9887. }
  9888. }
  9889. if len(insutypes) == 1 {
  9890. insutype = insutypes[0].Insutype
  9891. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9892. } else {
  9893. for _, i := range insutypes {
  9894. if i.Insutype == "390" {
  9895. is390 = 1
  9896. }
  9897. if i.Insutype == "310" {
  9898. is310 = 1
  9899. }
  9900. }
  9901. }
  9902. if is390 == 1 {
  9903. insutype = "390"
  9904. }
  9905. if is310 == 1 {
  9906. insutype = "310"
  9907. }
  9908. if len(insutypes) == 0 {
  9909. insutype = "310"
  9910. }
  9911. c.ServeSuccessJSON(map[string]interface{}{
  9912. "patient": patient,
  9913. "number": token,
  9914. "insutype": insutype,
  9915. })
  9916. }
  9917. } else {
  9918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9919. return
  9920. }
  9921. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9922. type ELeData struct {
  9923. Code string `json:"code"`
  9924. Data struct {
  9925. Aac002 string `json:"aac002"`
  9926. Aaz500 string `json:"aaz500"`
  9927. ActCardNo string `json:"actCardNo"`
  9928. Bab520 string `json:"bab520"`
  9929. Bkz543 string `json:"bkz543"`
  9930. BusinessType string `json:"businessType"`
  9931. CertfCodg string `json:"certfCodg"`
  9932. EcIndexNo string `json:"ecIndexNo"`
  9933. EcToken string `json:"ecToken"`
  9934. ID0000 string `json:"id0000"`
  9935. IDNo string `json:"idNo"`
  9936. IDType string `json:"idType"`
  9937. Idcode string `json:"idcode"`
  9938. IdentityToken string `json:"identity_token"`
  9939. InsuOrg string `json:"insuOrg"`
  9940. OfficeID string `json:"officeId"`
  9941. OfficeName string `json:"officeName"`
  9942. OperatorID string `json:"operatorId"`
  9943. OperatorName string `json:"operatorName"`
  9944. OrgID string `json:"orgId"`
  9945. UserName string `json:"userName"`
  9946. } `json:"data"`
  9947. Infno interface{} `json:"infno"`
  9948. Message string `json:"message"`
  9949. OrgID string `json:"orgId"`
  9950. TransType string `json:"transType"`
  9951. }
  9952. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9953. outPutInfo = Remove0000(outPutInfo)
  9954. if len(outPutInfo) > 0 {
  9955. var ele ELeData
  9956. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9957. if err != nil {
  9958. utils.ErrorLog("解析失败:%v", err)
  9959. }
  9960. token := ele.Data.EcToken
  9961. fmt.Println(inputInfo)
  9962. fmt.Println(outPutInfo)
  9963. 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)
  9964. saveLog(result, requestLog, "1101", "获取人员信息")
  9965. var dat map[string]interface{}
  9966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9967. fmt.Println(dat)
  9968. } else {
  9969. fmt.Println(err)
  9970. }
  9971. userJSONBytes, _ := json.Marshal(dat)
  9972. var res ResultTwo
  9973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9974. utils.ErrorLog("解析失败:%v", err)
  9975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9976. return
  9977. }
  9978. res.ErrMsg = errMsgLog
  9979. if res.Infcode == 0 {
  9980. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9981. if err == gorm.ErrRecordNotFound {
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9983. return
  9984. } else if err != nil {
  9985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9986. return
  9987. } else {
  9988. fmt.Println(res)
  9989. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9990. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9991. infoStr := string(Iinfos)
  9992. idetinfoStr := string(Idetinfos)
  9993. psn := &models.HisPsn{
  9994. PsnNo: res.Output.Baseinfo.PsnNo,
  9995. PatientId: patient.ID,
  9996. Certno: res.Output.Baseinfo.Certno,
  9997. Gend: res.Output.Baseinfo.Gend,
  9998. Naty: res.Output.Baseinfo.Naty,
  9999. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10000. PsnName: res.Output.Baseinfo.PsnName,
  10001. Idetinfo: idetinfoStr,
  10002. Insuinfo: infoStr,
  10003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10004. CardInfo: outPutInfo,
  10005. VerifyNumber: token,
  10006. InsuplcAdmdvs: ele.Data.InsuOrg,
  10007. }
  10008. service.CreateHisPsn(psn)
  10009. var rf []*ResultFive
  10010. json.Unmarshal([]byte(infoStr), &rf)
  10011. var insutypes []*ResultFive
  10012. var insutype string
  10013. var is390 int = 0
  10014. var is310 int = 0
  10015. for _, item := range rf {
  10016. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10017. insutypes = append(insutypes, item)
  10018. }
  10019. }
  10020. if len(insutypes) == 1 {
  10021. insutype = insutypes[0].Insutype
  10022. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10023. } else {
  10024. for _, i := range insutypes {
  10025. if i.Insutype == "390" {
  10026. is390 = 1
  10027. }
  10028. if i.Insutype == "310" {
  10029. is310 = 1
  10030. }
  10031. }
  10032. }
  10033. if is390 == 1 {
  10034. insutype = "390"
  10035. }
  10036. if is310 == 1 {
  10037. insutype = "310"
  10038. }
  10039. if len(insutypes) == 0 {
  10040. insutype = "310"
  10041. }
  10042. c.ServeSuccessJSON(map[string]interface{}{
  10043. "patient": patient,
  10044. "number": token,
  10045. "insutype": insutype,
  10046. })
  10047. }
  10048. } else {
  10049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10050. return
  10051. }
  10052. }
  10053. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10054. var api string
  10055. 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 +
  10056. "&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
  10057. resp, requestErr := http.Get(api)
  10058. if requestErr != nil {
  10059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10060. return
  10061. }
  10062. body, ioErr := ioutil.ReadAll(resp.Body)
  10063. if ioErr != nil {
  10064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10066. return
  10067. }
  10068. var respJSON map[string]interface{}
  10069. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10072. return
  10073. }
  10074. var status string
  10075. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10076. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10077. var token string
  10078. var res ResultTwo //1101结果
  10079. var res10265 ResultTwo10265 //1101结果
  10080. if status == "0" { //读卡成功
  10081. var card_info string //卡信息
  10082. var busi_card_info string
  10083. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10084. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10085. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10086. fmt.Println(card_info)
  10087. fmt.Println(busi_card_info)
  10088. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10089. result, _ := json.Marshal(respJSON)
  10090. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10091. utils.ErrorLog("解析失败:%v", err)
  10092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10093. return
  10094. }
  10095. res.ErrMsg = res10265.ErrMsg
  10096. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10097. res.Infcode = infocode
  10098. res.Output = res10265.Output
  10099. res.InfRefmsgid = res10265.InfRefmsgid
  10100. if res.Infcode == 0 {
  10101. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10102. if err == gorm.ErrRecordNotFound {
  10103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10104. return
  10105. } else if err != nil {
  10106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10107. return
  10108. } else {
  10109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10110. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10111. infoStr := string(Iinfos)
  10112. idetinfoStr := string(Idetinfos)
  10113. psn := &models.HisPsn{
  10114. PsnNo: res.Output.Baseinfo.PsnNo,
  10115. PatientId: patient.ID,
  10116. Certno: res.Output.Baseinfo.Certno,
  10117. Gend: res.Output.Baseinfo.Gend,
  10118. Naty: res.Output.Baseinfo.Naty,
  10119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10120. PsnName: res.Output.Baseinfo.PsnName,
  10121. Idetinfo: idetinfoStr,
  10122. Insuinfo: infoStr,
  10123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10124. CardInfo: card_info,
  10125. VerifyNumber: token,
  10126. }
  10127. var rf []*ResultFive
  10128. json.Unmarshal([]byte(infoStr), &rf)
  10129. var insutypes []*ResultFive
  10130. var insutype string
  10131. var is390 int = 0
  10132. var is310 int = 0
  10133. for _, item := range rf {
  10134. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10135. insutypes = append(insutypes, item)
  10136. }
  10137. }
  10138. if len(insutypes) == 1 {
  10139. insutype = insutypes[0].Insutype
  10140. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10141. } else {
  10142. for _, i := range insutypes {
  10143. if i.Insutype == "390" {
  10144. is390 = 1
  10145. }
  10146. if i.Insutype == "310" {
  10147. is310 = 1
  10148. }
  10149. }
  10150. }
  10151. if is390 == 1 {
  10152. insutype = "390"
  10153. }
  10154. if is310 == 1 {
  10155. insutype = "310"
  10156. }
  10157. if len(insutypes) == 0 {
  10158. insutype = "310"
  10159. }
  10160. service.CreateHisPsn(psn)
  10161. c.ServeSuccessJSON(map[string]interface{}{
  10162. "patient": patient,
  10163. "number": token,
  10164. "insutype": insutype,
  10165. })
  10166. }
  10167. } else {
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10169. return
  10170. }
  10171. } else { //读卡失败
  10172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10173. return
  10174. }
  10175. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10176. res := c.GetoleInfo()
  10177. if res.Infcode == 0 {
  10178. var result string
  10179. if res.Output.MdtrtCertType == "01" {
  10180. 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)
  10181. } else if res.Output.MdtrtCertType == "02" {
  10182. 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)
  10183. } else if res.Output.MdtrtCertType == "03" {
  10184. 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)
  10185. }
  10186. var dat map[string]interface{}
  10187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10188. fmt.Println(dat)
  10189. } else {
  10190. fmt.Println(err)
  10191. }
  10192. userJSONBytes, _ := json.Marshal(dat)
  10193. var res2 ResultTwo
  10194. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10195. utils.ErrorLog("解析失败:%v", err)
  10196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10197. return
  10198. }
  10199. if res2.Infcode == 0 {
  10200. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10201. if err == gorm.ErrRecordNotFound {
  10202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10203. return
  10204. } else if err != nil {
  10205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10206. return
  10207. } else {
  10208. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10209. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10210. infoStr := string(Iinfos)
  10211. idetinfoStr := string(Idetinfos)
  10212. var rf []*ResultFive
  10213. json.Unmarshal([]byte(infoStr), &rf)
  10214. var insutypes []*ResultFive
  10215. var insutype string
  10216. var is390 int = 0
  10217. var is310 int = 0
  10218. //var insuplc_admdvs string
  10219. for _, item := range rf {
  10220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10221. insutypes = append(insutypes, item)
  10222. }
  10223. }
  10224. if len(insutypes) == 1 {
  10225. insutype = insutypes[0].Insutype
  10226. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10227. } else {
  10228. for _, i := range insutypes {
  10229. if i.Insutype == "390" {
  10230. is390 = 1
  10231. }
  10232. if i.Insutype == "310" {
  10233. is310 = 1
  10234. }
  10235. }
  10236. }
  10237. if is390 == 1 {
  10238. insutype = "390"
  10239. }
  10240. if is310 == 1 {
  10241. insutype = "310"
  10242. }
  10243. if len(insutypes) == 0 {
  10244. insutype = "310"
  10245. }
  10246. psn := &models.HisPsn{
  10247. PsnNo: res2.Output.Baseinfo.PsnNo,
  10248. PatientId: patient.ID,
  10249. Certno: res2.Output.Baseinfo.Certno,
  10250. Gend: res2.Output.Baseinfo.Gend,
  10251. Naty: res2.Output.Baseinfo.Naty,
  10252. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10253. PsnName: res2.Output.Baseinfo.PsnName,
  10254. Idetinfo: idetinfoStr,
  10255. Insuinfo: infoStr,
  10256. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10257. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10258. VerifyNumber: res.Output.EcToken,
  10259. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10260. }
  10261. if res.Output.MdtrtCertType == "01" {
  10262. psn.VerifyNumber = res.Output.EcToken
  10263. //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)
  10264. } else if res.Output.MdtrtCertType == "02" {
  10265. psn.VerifyNumber = res.Output.CardNo
  10266. //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)
  10267. } else if res.Output.MdtrtCertType == "03" {
  10268. psn.VerifyNumber = res.Output.MdtrtCertNo
  10269. //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)
  10270. }
  10271. service.CreateHisPsn(psn)
  10272. var balc float64
  10273. for _, item := range rf {
  10274. if item.Insutype == insutype {
  10275. balc = item.Balc
  10276. }
  10277. }
  10278. c.ServeSuccessJSON(map[string]interface{}{
  10279. "patient": patient,
  10280. "number": res.Output.CardNo,
  10281. "insutype": insutype,
  10282. "blac": balc,
  10283. "desc": idetinfoStr,
  10284. })
  10285. }
  10286. } else {
  10287. c.ServeSuccessJSON(map[string]interface{}{
  10288. "failed_code": -10,
  10289. "msg": res2.ErrMsg,
  10290. })
  10291. }
  10292. } else {
  10293. c.ServeSuccessJSON(map[string]interface{}{
  10294. "failed_code": -10,
  10295. "msg": res.ErrMsg,
  10296. })
  10297. }
  10298. } else {
  10299. type ELeData struct {
  10300. Code string `json:"code"`
  10301. Data struct {
  10302. Aac002 string `json:"aac002"`
  10303. Aaz500 string `json:"aaz500"`
  10304. ActCardNo string `json:"actCardNo"`
  10305. Bab520 string `json:"bab520"`
  10306. Bkz543 string `json:"bkz543"`
  10307. BusinessType string `json:"businessType"`
  10308. CertfCodg string `json:"certfCodg"`
  10309. EcIndexNo string `json:"ecIndexNo"`
  10310. EcToken string `json:"ecToken"`
  10311. ID0000 string `json:"id0000"`
  10312. IDNo string `json:"idNo"`
  10313. IDType string `json:"idType"`
  10314. Idcode string `json:"idcode"`
  10315. IdentityToken string `json:"identity_token"`
  10316. InsuOrg string `json:"insuOrg"`
  10317. OfficeID string `json:"officeId"`
  10318. OfficeName string `json:"officeName"`
  10319. OperatorID string `json:"operatorId"`
  10320. OperatorName string `json:"operatorName"`
  10321. OrgID string `json:"orgId"`
  10322. UserName string `json:"userName"`
  10323. } `json:"data"`
  10324. Infno interface{} `json:"infno"`
  10325. Message string `json:"message"`
  10326. OrgID string `json:"orgId"`
  10327. TransType string `json:"transType"`
  10328. }
  10329. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10330. fmt.Println(result)
  10331. outPutInfo := Remove0000(result)
  10332. fmt.Println(outPutInfo)
  10333. if len(outPutInfo) > 0 {
  10334. var ele ELeData
  10335. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10336. if err != nil {
  10337. utils.ErrorLog("解析失败:%v", err)
  10338. }
  10339. token := ele.Data.EcToken
  10340. fmt.Println(outPutInfo)
  10341. 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)
  10342. saveLog(result, requestLog, "1101", "获取人员信息")
  10343. var dat map[string]interface{}
  10344. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10345. fmt.Println(dat)
  10346. } else {
  10347. fmt.Println(err)
  10348. }
  10349. userJSONBytes, _ := json.Marshal(dat)
  10350. var res ResultTwo
  10351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10352. utils.ErrorLog("解析失败:%v", err)
  10353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10354. return
  10355. }
  10356. if res.Infcode == 0 {
  10357. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10358. if err == gorm.ErrRecordNotFound {
  10359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10360. return
  10361. } else if err != nil {
  10362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10363. return
  10364. } else {
  10365. fmt.Println(res)
  10366. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10367. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10368. infoStr := string(Iinfos)
  10369. idetinfoStr := string(Idetinfos)
  10370. psn := &models.HisPsn{
  10371. PsnNo: res.Output.Baseinfo.PsnNo,
  10372. PatientId: patient.ID,
  10373. Certno: res.Output.Baseinfo.Certno,
  10374. Gend: res.Output.Baseinfo.Gend,
  10375. Naty: res.Output.Baseinfo.Naty,
  10376. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10377. PsnName: res.Output.Baseinfo.PsnName,
  10378. Idetinfo: idetinfoStr,
  10379. Insuinfo: infoStr,
  10380. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10381. CardInfo: outPutInfo,
  10382. VerifyNumber: token,
  10383. InsuplcAdmdvs: ele.Data.InsuOrg,
  10384. }
  10385. service.CreateHisPsn(psn)
  10386. var rf []*ResultFive
  10387. json.Unmarshal([]byte(infoStr), &rf)
  10388. var insutypes []*ResultFive
  10389. var insutype string
  10390. var is390 int = 0
  10391. var is310 int = 0
  10392. for _, item := range rf {
  10393. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10394. insutypes = append(insutypes, item)
  10395. }
  10396. }
  10397. if len(insutypes) == 1 {
  10398. insutype = insutypes[0].Insutype
  10399. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10400. } else {
  10401. for _, i := range insutypes {
  10402. if i.Insutype == "390" {
  10403. is390 = 1
  10404. }
  10405. if i.Insutype == "310" {
  10406. is310 = 1
  10407. }
  10408. }
  10409. }
  10410. if is390 == 1 {
  10411. insutype = "390"
  10412. }
  10413. if is310 == 1 {
  10414. insutype = "310"
  10415. }
  10416. if len(insutypes) == 0 {
  10417. insutype = "310"
  10418. }
  10419. c.ServeSuccessJSON(map[string]interface{}{
  10420. "patient": patient,
  10421. "number": token,
  10422. "insutype": insutype,
  10423. })
  10424. }
  10425. } else {
  10426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10427. return
  10428. }
  10429. }
  10430. //fmt.Println(result)
  10431. //
  10432. //if initFlag == 0 {
  10433. // c.TestGetBasBaseInit()
  10434. //}
  10435. //token := c.GetEleBaseInfo()
  10436. //
  10437. //token = Remove0000(token)
  10438. //
  10439. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10440. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10441. ////
  10442. //var res ResultTwo
  10443. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10444. // utils.ErrorLog("解析失败:%v", err)
  10445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10446. // return
  10447. //}
  10448. //
  10449. //if res.Infcode == 0 {
  10450. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10451. // if err == gorm.ErrRecordNotFound {
  10452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10453. // return
  10454. // } else if err != nil {
  10455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10456. // return
  10457. //
  10458. // } else {
  10459. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10460. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10461. // infoStr := string(Iinfos)
  10462. // idetinfoStr := string(Idetinfos)
  10463. //
  10464. //
  10465. //
  10466. //
  10467. // var rf []*ResultFive
  10468. // json.Unmarshal([]byte(infoStr), &rf)
  10469. //
  10470. // var insutypes []*ResultFive
  10471. // var insutype string
  10472. // var is390 int = 0
  10473. // var is310 int = 0
  10474. // var insuplc_admdvs string
  10475. //
  10476. // for _, item := range rf {
  10477. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10478. // insutypes = append(insutypes, item)
  10479. // }
  10480. // }
  10481. //
  10482. // if len(insutypes) == 1 {
  10483. // insutype = insutypes[0].Insutype
  10484. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10485. // } else {
  10486. // for _, i := range insutypes {
  10487. // if i.Insutype == "390" {
  10488. // is390 = 1
  10489. // }
  10490. //
  10491. // if i.Insutype == "310" {
  10492. // is310 = 1
  10493. // }
  10494. // }
  10495. // }
  10496. // if is390 == 1 {
  10497. // insutype = "390"
  10498. // }
  10499. //
  10500. // if is310 == 1 {
  10501. // insutype = "310"
  10502. // }
  10503. // if len(insutypes) == 0 {
  10504. // insutype = "310"
  10505. // }
  10506. // for _, item := range rf {
  10507. // if item.Insutype == insutype {
  10508. // insuplc_admdvs = item.InsuplcAdmdvs
  10509. // }
  10510. // }
  10511. // psn := &models.HisPsn{
  10512. // PsnNo: res.Output.Baseinfo.PsnNo,
  10513. // Age: res.Output.Baseinfo.Age,
  10514. // PatientId: patient.ID,
  10515. // Certno: res.Output.Baseinfo.Certno,
  10516. // Brdy: res.Output.Baseinfo.Brdy,
  10517. // Gend: res.Output.Baseinfo.Gend,
  10518. // Naty: res.Output.Baseinfo.Naty,
  10519. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10520. // PsnName: res.Output.Baseinfo.PsnName,
  10521. // Idetinfo: idetinfoStr,
  10522. // Insuinfo: infoStr,
  10523. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10524. // CardInfo: "",
  10525. // VerifyNumber: token,
  10526. // InsuplcAdmdvs: insuplc_admdvs,
  10527. // }
  10528. // service.CreateHisPsn(psn)
  10529. //
  10530. // c.ServeSuccessJSON(map[string]interface{}{
  10531. // "patient": patient,
  10532. // "number": token,
  10533. // })
  10534. // }
  10535. //} else {
  10536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10537. // return
  10538. //}
  10539. }
  10540. break
  10541. case 5:
  10542. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10543. var api string
  10544. if miConfig.MdtrtareaAdmvs == "320921" {
  10545. 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 +
  10546. "&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
  10547. fmt.Println(api)
  10548. } else {
  10549. 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 +
  10550. "&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)
  10551. }
  10552. resp, requestErr := http.Get(api)
  10553. if requestErr != nil {
  10554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10555. return
  10556. }
  10557. body, ioErr := ioutil.ReadAll(resp.Body)
  10558. if ioErr != nil {
  10559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10561. return
  10562. }
  10563. var respJSON map[string]interface{}
  10564. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10567. return
  10568. }
  10569. var status string
  10570. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10571. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10572. var token string
  10573. var res ResultTwo //1101结果
  10574. var res10265 ResultTwo10265 //1101结果
  10575. if status == "0" { //读卡成功
  10576. var card_info string //卡信息
  10577. //var busi_card_info string
  10578. var auth_info string
  10579. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10580. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10581. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10582. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10583. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10584. result, _ := json.Marshal(respJSON)
  10585. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10586. utils.ErrorLog("解析失败:%v", err)
  10587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10588. return
  10589. }
  10590. res.ErrMsg = res10265.ErrMsg
  10591. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10592. res.Infcode = infocode
  10593. res.Output = res10265.Output
  10594. res.InfRefmsgid = res10265.InfRefmsgid
  10595. if res.Infcode == 0 {
  10596. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10597. if err == gorm.ErrRecordNotFound {
  10598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10599. return
  10600. } else if err != nil {
  10601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10602. return
  10603. } else {
  10604. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10605. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10606. infoStr := string(Iinfos)
  10607. idetinfoStr := string(Idetinfos)
  10608. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10609. psn := &models.HisPsn{
  10610. PsnNo: res.Output.Baseinfo.PsnNo,
  10611. PatientId: patient.ID,
  10612. Certno: res.Output.Baseinfo.Certno,
  10613. Gend: res.Output.Baseinfo.Gend,
  10614. Brdy: b,
  10615. Age: float64(age),
  10616. Naty: res.Output.Baseinfo.Naty,
  10617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10618. PsnName: res.Output.Baseinfo.PsnName,
  10619. Idetinfo: idetinfoStr,
  10620. Insuinfo: infoStr,
  10621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10622. CardInfo: card_info,
  10623. VerifyNumber: token,
  10624. AuthInfo: auth_info,
  10625. }
  10626. var rf []*ResultFive
  10627. json.Unmarshal([]byte(infoStr), &rf)
  10628. var insutypes []*ResultFive
  10629. var insutype string
  10630. var is390 int = 0
  10631. var is310 int = 0
  10632. for _, item := range rf {
  10633. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10634. insutypes = append(insutypes, item)
  10635. }
  10636. }
  10637. if len(insutypes) == 1 {
  10638. insutype = insutypes[0].Insutype
  10639. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10640. } else {
  10641. for _, i := range insutypes {
  10642. if i.Insutype == "390" {
  10643. is390 = 1
  10644. }
  10645. if i.Insutype == "310" {
  10646. is310 = 1
  10647. }
  10648. }
  10649. }
  10650. if is390 == 1 {
  10651. insutype = "390"
  10652. }
  10653. if is310 == 1 {
  10654. insutype = "310"
  10655. }
  10656. if len(insutypes) == 0 {
  10657. insutype = "310"
  10658. }
  10659. service.CreateHisPsn(psn)
  10660. c.ServeSuccessJSON(map[string]interface{}{
  10661. "patient": patient,
  10662. "number": token,
  10663. "insutype": insutype,
  10664. })
  10665. }
  10666. } else {
  10667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10668. return
  10669. }
  10670. } else { //读卡失败
  10671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10672. return
  10673. }
  10674. }
  10675. break
  10676. }
  10677. }
  10678. var initFlag int64 = 0
  10679. var initEleFlag int64 = 0
  10680. func (c *HisApiController) TestGetBasBaseInit() {
  10681. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10682. Iinit := DllDef.MustFindProc("Init")
  10683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10684. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10685. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10686. if ret != 0 {
  10687. fmt.Println("SSCard的报错原因:", err)
  10688. fmt.Println("SSCard的运算结果为:", ret)
  10689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10690. return
  10691. }
  10692. result := int(ret)
  10693. fmt.Println("SSCard的运算结果为1:", result)
  10694. initFlag = 1
  10695. return
  10696. }
  10697. func (c *HisApiController) HandleJiangXiReadCard() {
  10698. fmt.Println("~~~~~~")
  10699. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10700. admin_user_id, _ := c.GetInt64("admin_user_id")
  10701. id_card_type, _ := c.GetInt64("id_card_type")
  10702. //certificates, _ := c.GetInt64("certificates")
  10703. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10704. if initFlag == 0 {
  10705. c.TestGetJiangXiBasBaseInit()
  10706. }
  10707. basStr := c.GetBasBaseInfo()
  10708. if len(basStr) == 0 {
  10709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10710. return
  10711. }
  10712. fmt.Println(basStr)
  10713. bas := strings.Split(basStr, "|")
  10714. basNumber := bas[1]
  10715. fmt.Println(basNumber)
  10716. card_sn := bas[3]
  10717. fmt.Println(card_sn)
  10718. 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, "")
  10719. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10720. var dat map[string]interface{}
  10721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10722. fmt.Println(dat)
  10723. } else {
  10724. fmt.Println(err)
  10725. }
  10726. userJSONBytes, _ := json.Marshal(dat)
  10727. var res ResultTwo
  10728. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10729. utils.ErrorLog("解析失败:%v", err)
  10730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10731. return
  10732. }
  10733. if res.Infcode == 0 {
  10734. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10735. if err == gorm.ErrRecordNotFound {
  10736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10737. return
  10738. } else if err != nil {
  10739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10740. return
  10741. } else {
  10742. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10743. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10744. infoStr := string(Iinfos)
  10745. idetinfoStr := string(Idetinfos)
  10746. psn := &models.HisPsn{
  10747. PsnNo: res.Output.Baseinfo.PsnNo,
  10748. PatientId: patient.ID,
  10749. Certno: res.Output.Baseinfo.Certno,
  10750. Gend: res.Output.Baseinfo.Gend,
  10751. Naty: res.Output.Baseinfo.Naty,
  10752. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10753. PsnName: res.Output.Baseinfo.PsnName,
  10754. Idetinfo: idetinfoStr,
  10755. Insuinfo: infoStr,
  10756. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10757. CardInfo: basStr,
  10758. VerifyNumber: "",
  10759. }
  10760. service.CreateHisPsn(psn)
  10761. c.ServeSuccessJSON(map[string]interface{}{
  10762. "patient": patient,
  10763. "number": basNumber,
  10764. })
  10765. }
  10766. } else {
  10767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10768. return
  10769. }
  10770. }
  10771. func (c *HisApiController) TestGetHnBasBaseInit() {
  10772. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10773. Iinit := DllDef.MustFindProc("Init")
  10774. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10775. //http://10.77.211.236/CSB/hsa-fsi-1303
  10776. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10777. if ret != 0 {
  10778. fmt.Println("SSCard的报错原因:", err)
  10779. fmt.Println("SSCard的运算结果为:", ret)
  10780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10781. return
  10782. }
  10783. result := int(ret)
  10784. fmt.Println("SSCard的运算结果为1:", result)
  10785. initFlag = 1
  10786. return
  10787. }
  10788. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10789. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10790. Iinit := DllDef.MustFindProc("Init")
  10791. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10792. //http://10.77.211.236/CSB/hsa-fsi-1303
  10793. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10794. if ret != 0 {
  10795. fmt.Println("SSCard的报错原因:", err)
  10796. fmt.Println("SSCard的运算结果为:", ret)
  10797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10798. return
  10799. }
  10800. result := int(ret)
  10801. fmt.Println("SSCard的运算结果为1:", result)
  10802. initFlag = 1
  10803. return
  10804. }
  10805. func (c *HisApiController) GetSFZBaseInfo() string {
  10806. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10807. readCard := DllDef.MustFindProc("ReadSFZ")
  10808. if readCard == nil {
  10809. fmt.Println("readcard is nil")
  10810. readCard = DllDef.MustFindProc("ReadSFZ")
  10811. }
  10812. str := make([]byte, 8096)
  10813. str1 := make([]byte, 8096)
  10814. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10815. fmt.Println(r)
  10816. return Remove0000(string(str))
  10817. }
  10818. func (c *HisApiController) GetEleBaseInfo() string {
  10819. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10820. readCard := DllDef.MustFindProc("GetQRBase")
  10821. fmt.Println(readCard)
  10822. if readCard == nil {
  10823. fmt.Println("readcard is nil")
  10824. readCard = DllDef.MustFindProc("GetQRBase")
  10825. }
  10826. str := make([]byte, 1024)
  10827. str1 := make([]byte, 1024)
  10828. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10829. fmt.Println(ret2)
  10830. fmt.Println(string(str1))
  10831. fmt.Println(string(str))
  10832. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10833. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10834. if ret2 != 0 {
  10835. return ""
  10836. }
  10837. return string(str)
  10838. }
  10839. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10840. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10841. readCard := DllDef.MustFindProc("NationEcTrans")
  10842. fmt.Println(readCard)
  10843. fmt.Println("!!!!!")
  10844. pBusiCardInfo := make([]byte, 2048)
  10845. input := make(map[string]interface{})
  10846. inputData := make(map[string]interface{})
  10847. inputData["orgId"] = code
  10848. inputData["businessType"] = "01101"
  10849. inputData["operatorId"] = "1"
  10850. inputData["operatorName"] = "admin"
  10851. inputData["officeId"] = "001"
  10852. inputData["officeName"] = "血透室"
  10853. inputData["deviceType"] = ""
  10854. input["data"] = inputData
  10855. input["orgId"] = code
  10856. input["transType"] = "ec.query"
  10857. bytesData, _ := json.Marshal(input)
  10858. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10859. fmt.Println(ret2)
  10860. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10861. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10862. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10863. }
  10864. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10865. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10866. readCard := DllDef.MustFindProc("NationEcTrans")
  10867. fmt.Println(readCard)
  10868. fmt.Println("!!!!!")
  10869. pBusiCardInfo := make([]byte, 2048)
  10870. input := make(map[string]interface{})
  10871. inputData := make(map[string]interface{})
  10872. inputData["orgId"] = code
  10873. inputData["businessType"] = "01101"
  10874. inputData["operatorId"] = "9"
  10875. inputData["operatorName"] = "admin"
  10876. inputData["officeId"] = "001"
  10877. inputData["officeName"] = "血透室"
  10878. inputData["deviceType"] = ""
  10879. input["data"] = inputData
  10880. input["orgId"] = code
  10881. input["transType"] = "ec.query"
  10882. bytesData, _ := json.Marshal(input)
  10883. 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])))
  10884. fmt.Println(ret2)
  10885. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10886. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10887. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10888. }
  10889. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10890. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10891. readCard := DllDef.MustFindProc("NationEcTrans")
  10892. fmt.Println(readCard)
  10893. fmt.Println("!!!!!")
  10894. pBusiCardInfo := make([]byte, 2048)
  10895. input := make(map[string]interface{})
  10896. inputData := make(map[string]interface{})
  10897. inputData["orgId"] = code
  10898. inputData["businessType"] = "01301"
  10899. inputData["operatorId"] = "9"
  10900. inputData["operatorName"] = "admin"
  10901. inputData["officeId"] = "001"
  10902. inputData["officeName"] = "血透室"
  10903. inputData["deviceType"] = ""
  10904. input["data"] = inputData
  10905. input["orgId"] = code
  10906. input["transType"] = "ec.query"
  10907. bytesData, _ := json.Marshal(input)
  10908. 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])))
  10909. fmt.Println(ret2)
  10910. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10911. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10912. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10913. }
  10914. func GetJxEleBaseInfo(org_id int64) string {
  10915. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10916. readCard := DllDef.MustFindProc("NationEcTrans")
  10917. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10918. if readCard == nil {
  10919. fmt.Println("readcard is nil")
  10920. readCard = DllDef.MustFindProc("NationEcTrans")
  10921. }
  10922. str1 := make([]byte, 1024)
  10923. data := make(map[string]interface{})
  10924. inputData := make(map[string]interface{})
  10925. inputData["orgId"] = miConfig.Code
  10926. inputData["businessType"] = "01101"
  10927. inputData["operatorId"] = "test001"
  10928. inputData["operatorName"] = "cn"
  10929. inputData["officeId"] = "32760"
  10930. inputData["officeName"] = "waike"
  10931. inputData["deviceType"] = ""
  10932. data["data"] = inputData
  10933. data["transType"] = "ec.query"
  10934. data["extra "] = ""
  10935. data["orgId"] = miConfig.Code
  10936. bytesData, _ := json.Marshal(data)
  10937. //bytesData, _ := json.Marshal(data)
  10938. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10939. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10940. fmt.Println(ret2)
  10941. fmt.Println(string(str1))
  10942. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10943. if ret2 != 0 {
  10944. return ""
  10945. }
  10946. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10947. }
  10948. func GetJxEleBaseInitInfo(org_id int64) string {
  10949. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10950. readCard := DllDef.MustFindProc("NationEcTrans")
  10951. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10952. if readCard == nil {
  10953. fmt.Println("readcard is nil")
  10954. readCard = DllDef.MustFindProc("NationEcTrans")
  10955. }
  10956. str1 := make([]byte, 2048)
  10957. data := make(map[string]interface{})
  10958. inputData := make(map[string]interface{})
  10959. inputData["orgId"] = miConfig.Code
  10960. inputData["businessType"] = "01101"
  10961. inputData["operatorId"] = "1"
  10962. inputData["operatorName"] = "huangchuang"
  10963. inputData["officeId"] = "101"
  10964. inputData["officeName"] = "xuetou"
  10965. inputData["deviceType"] = ""
  10966. data["data"] = inputData
  10967. data["transType"] = "ec.query"
  10968. data["orgId"] = miConfig.Code
  10969. bytesData, _ := json.Marshal(data)
  10970. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10971. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10972. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10973. fmt.Println(ret2)
  10974. fmt.Println(string(str1))
  10975. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10976. if ret2 != 0 {
  10977. return ""
  10978. }
  10979. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10980. initEleFlag = 1
  10981. }
  10982. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10983. }
  10984. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10985. // // 构建命令
  10986. // cmd := exec.Command("python", "b.py")
  10987. //
  10988. // // 执行命令并等待完成
  10989. // output, err := cmd.CombinedOutput()
  10990. // if err != nil {
  10991. // fmt.Println("Error executing Python script:", err)
  10992. // return
  10993. // }
  10994. //
  10995. // // 打印Python脚本的输出
  10996. // fmt.Println(string(output))
  10997. //}
  10998. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10999. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11000. readCard := DllDef.MustFindProc("gxyb_call")
  11001. if readCard == nil {
  11002. fmt.Println("readcard is nil")
  11003. readCard = DllDef.MustFindProc("gxyb_call")
  11004. }
  11005. str := make([]byte, 1024)
  11006. str1 := make([]byte, 1024)
  11007. //data := make(map[string]interface{})
  11008. currentTime := time.Now()
  11009. // 格式化时间为 "YYYYMMDDHH24MISS"
  11010. formattedTime := currentTime.Format("20060102150405")
  11011. inputData := make(map[string]interface{})
  11012. inputData2 := make(map[string]interface{})
  11013. inputData["transNo"] = "1401"
  11014. inputData["transType"] = "passwordCheck"
  11015. inputData["timestamp"] = formattedTime
  11016. inputData2["fixmedinsCode"] = code
  11017. inputData2["psnNo"] = ""
  11018. inputData["data"] = inputData2
  11019. jsonBytes, err := json.Marshal(inputData)
  11020. if err != nil {
  11021. fmt.Println("Error encoding map to JSON:", err)
  11022. }
  11023. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11024. fmt.Println(string(str1))
  11025. fmt.Println(string(str))
  11026. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11027. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11028. if ret2 != 0 {
  11029. return ""
  11030. }
  11031. return string(str)
  11032. }
  11033. func (c *HisApiController) GetoleInfo() Response {
  11034. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11035. defer ole.CoUninitialize()
  11036. // Replace with the ProgID or CLSID of your COM object
  11037. progID := "YinHai.XJ.Actual.Interface.New"
  11038. // Create COM object
  11039. unknown, err := oleutil.CreateObject(progID)
  11040. if err != nil {
  11041. fmt.Println("Unable to create COM object:", err)
  11042. }
  11043. defer unknown.Release()
  11044. // Query for the IDispatch interface
  11045. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11046. if err != nil {
  11047. fmt.Println("Unable to get IDispatch interface:", err)
  11048. }
  11049. defer dispatch.Release()
  11050. // Prepare parameters
  11051. transNo := "1401"
  11052. transType := "passwordCheck"
  11053. timestamp := time.Now().Unix()
  11054. fixmedinsCode := "H45072101171"
  11055. psnNo := ""
  11056. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11057. result2 := ""
  11058. // Call COM object's method using the IDispatch interface
  11059. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11060. fmt.Println(resulr)
  11061. fmt.Println(result2)
  11062. if err != nil {
  11063. fmt.Println("调用COM对象方法失败:", err)
  11064. }
  11065. var response Response
  11066. err2 := json.Unmarshal([]byte(result2), &response)
  11067. if err2 != nil {
  11068. fmt.Println("解析JSON失败:", err)
  11069. }
  11070. return response
  11071. }
  11072. func (c *HisApiController) GetBasBaseInfo() string {
  11073. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11074. readCard := DllDef.MustFindProc("ReadCardBas")
  11075. if readCard == nil {
  11076. fmt.Println("readcard is nil")
  11077. readCard = DllDef.MustFindProc("ReadCardBas")
  11078. }
  11079. str := make([]byte, 1024)
  11080. str1 := make([]byte, 1024)
  11081. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11082. fmt.Println(string(str1))
  11083. fmt.Println(string(str))
  11084. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11085. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11086. if ret2 != 0 {
  11087. return ""
  11088. }
  11089. return string(str)
  11090. }
  11091. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11092. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11093. readCard := DllDef.MustFindProc("read_cardinfo")
  11094. if readCard == nil {
  11095. fmt.Println("readcard is nil")
  11096. readCard = DllDef.MustFindProc("read_cardinfo")
  11097. }
  11098. str := make([]byte, 1024) //卡号
  11099. str1 := make([]byte, 1024) //卡识别码
  11100. str2 := make([]byte, 1024) //身份证号
  11101. str3 := make([]byte, 1024) //姓名
  11102. str4 := make([]byte, 1024) //错误信息
  11103. 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])))
  11104. fmt.Println(string(str1))
  11105. fmt.Println(string(str))
  11106. fmt.Println(string(str2))
  11107. fmt.Println(string(str3))
  11108. fmt.Println(string(str4))
  11109. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11110. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11111. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11112. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11113. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11114. if ret2 != 0 {
  11115. return "", "", "", "", ""
  11116. }
  11117. return string(str), string(str1), string(str2), string(str3), string(str4)
  11118. }
  11119. type CustomFundPay struct {
  11120. FundPayType string `json:"fund_pay_type"`
  11121. FundPayamt float64 `json:"fund_payamt"`
  11122. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11123. }
  11124. //func (c *HisApiController) GetBatchSettleList() {
  11125. // start_time_str := c.GetString("start_time")
  11126. // //end_time_str := c.GetString("end_time")
  11127. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11128. //
  11129. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11130. //
  11131. // for _, item := range orders {
  11132. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11133. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11134. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11135. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11136. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11137. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11138. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11139. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11140. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11141. //
  11142. // if order.ID == 0 {
  11143. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11144. // return
  11145. // }
  11146. //
  11147. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11148. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11149. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11150. // //fmt.Println(count)
  11151. // //var zero string
  11152. // //number := count + 1
  11153. // //if number >= 1000 {
  11154. // // zero = "0000" + strconv.FormatInt(number, 10)
  11155. // //} else if number >= 10000 {
  11156. // // zero = "000" + strconv.FormatInt(number, 10)
  11157. // //} else if number >= 100000 {
  11158. // // zero = "00" + strconv.FormatInt(number, 10)
  11159. // //} else if number >= 1000000 {
  11160. // // zero = "0" + strconv.FormatInt(number, 10)
  11161. // //} else {
  11162. // // zero = strconv.FormatInt(number, 10)
  11163. // //}
  11164. // //fmt.Println(zero)
  11165. //
  11166. // struct4101 := service.Struct4101{
  11167. // PsnNo: order.PsnNo,
  11168. // MdtrtId: order.MdtrtId,
  11169. // SetlId: order.SetlId,
  11170. // PsnName: order.PsnName,
  11171. // Gend: order.Gend,
  11172. // Brdy: his.Brdy,
  11173. // Age: his.Age,
  11174. // Naty: order.Naty,
  11175. // PatnCertType: "01",
  11176. // Certno: order.Certno,
  11177. // Prfs: "90",
  11178. // ConerName: roles[0].UserName,
  11179. // PatnRlts: "99",
  11180. // ConerAddr: miConfig.OrgName,
  11181. // ConerTel: admin.Mobile,
  11182. // HiType: order.Insutype,
  11183. // Insuplc: miConfig.InsuplcAdmdvs,
  11184. // MaindiagFlag: "1",
  11185. // BillCode: order.SetlId,
  11186. // BillNo: order.SetlId,
  11187. // BizSn: order.Number,
  11188. // PsnSelfPay: order.PsnPartAmt,
  11189. // PsnOwnPay: order.PsnPartAmt,
  11190. // AcctPay: order.AcctPay,
  11191. // PsnCashpay: order.PsnCashPay,
  11192. // HiPaymtd: "1",
  11193. // Hsorg: miConfig.InsuplcAdmdvs,
  11194. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11195. // MedinsFillPsn: curRoles.UserName,
  11196. // MedinsFillDept: miConfig.OrgName,
  11197. // IptMedType: "2",
  11198. // }
  11199. // struct4101.SetlBegnDate = order.SetlTime
  11200. // struct4101.SetlEndDate = order.SetlTime
  11201. // time_arr := strings.Split(order.SetlTime, " ")
  11202. // struct4101.AdmTime = time_arr[0]
  11203. // struct4101.AdmEndTime = time_arr[0]
  11204. //
  11205. // var rf []CustomFundPay
  11206. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11207. //
  11208. // var tempFunPays []service.CustomStruct
  11209. // for _, item := range rf {
  11210. // var tempFunPay service.CustomStruct
  11211. // tempFunPay.FundPayamt = item.FundPayamt
  11212. // tempFunPay.FundPayType = item.FundPayType
  11213. // tempFunPays = append(tempFunPays, tempFunPay)
  11214. // }
  11215. // struct4101.CustomStruct = tempFunPays
  11216. //
  11217. // var tempDiaginfos []service.DiaginfoStructTwo
  11218. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11219. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11220. //
  11221. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11222. // var config []*models.HisXtDiagnoseConfig
  11223. // for _, item := range diagnosis_ids {
  11224. // id, _ := strconv.ParseInt(item, 10, 64)
  11225. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11226. // config = append(config, &diagnosisConfig)
  11227. // }
  11228. //
  11229. // for index, item := range config {
  11230. // if index == 0 {
  11231. // var tempDiaginfo service.DiaginfoStructTwo
  11232. // tempDiaginfo.DiagCode = item.CountryCode
  11233. // tempDiaginfo.DiagName = item.CountryContentName
  11234. // tempDiaginfo.DiagType = "1"
  11235. // tempDiaginfo.MaindiagFlag = "1"
  11236. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11237. // } else {
  11238. // var tempDiaginfo service.DiaginfoStructTwo
  11239. // tempDiaginfo.DiagCode = item.CountryCode
  11240. // tempDiaginfo.DiagName = item.CountryContentName
  11241. // tempDiaginfo.DiagType = "1"
  11242. // tempDiaginfo.MaindiagFlag = "0"
  11243. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11244. // }
  11245. // }
  11246. // struct4101.Diseinfo = tempDiaginfos
  11247. //
  11248. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11249. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11250. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11251. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11252. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11253. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11254. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11255. //
  11256. // var iteminfo service.IteminfoStruct
  11257. //
  11258. // var bedCostTotal float64 = 0 //床位总费
  11259. // var bedCostSelfTotal float64 = 0 //床位自费
  11260. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11261. //
  11262. // var operationCostTotal float64 = 0 //手术费
  11263. // var operationCostSelfTotal float64 = 0 //手术费
  11264. // var operationCostPartSelfTotal float64 = 0 //手术费
  11265. //
  11266. // var otherCostTotal float64 = 0 //其他费用
  11267. // var otherCostSelfTotal float64 = 0 //其他费用
  11268. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11269. //
  11270. // var materialCostTotal float64 = 0 //材料费
  11271. // var materialCostSelfTotal float64 = 0 //材料费
  11272. // var materialCostPartSelfTotal float64 = 0 //材料费
  11273. //
  11274. // var westernMedicineCostTotal float64 = 0 //西药费
  11275. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11276. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11277. //
  11278. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11279. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11280. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11281. //
  11282. // var checkCostTotal float64 = 0 //检查费
  11283. // var checkCostSelfTotal float64 = 0 //检查费
  11284. // var checkCostPartSelfTotal float64 = 0 //检查费
  11285. //
  11286. // var laboratoryCostTotal float64 = 0 //化验费
  11287. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11288. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11289. //
  11290. // var treatCostTotal float64 = 0 //治疗费用
  11291. // var treatCostSelfTotal float64 = 0 //治疗费用
  11292. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11293. //
  11294. // decimal.DivisionPrecision = 2
  11295. //
  11296. // var bed_fulamt_ownpay_amt float64 = 0
  11297. // var operation_fulamt_ownpay_amt float64 = 0
  11298. // var other_fulamt_ownpay_amt float64 = 0
  11299. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11300. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11301. // var check_fulamt_ownpay_amt float64 = 0
  11302. // var material_fulamt_ownpay_amt float64 = 0
  11303. // var laboratory_fulamt_ownpay_amt float64 = 0
  11304. // var treat_fulamt_ownpay_amt float64 = 0
  11305. //
  11306. // var bed_claa_sunmfee float64 = 0
  11307. // var bed_clab_amt float64 = 0
  11308. // var bed_other_amt float64 = 0
  11309. //
  11310. // var operation_claa_sunmfee float64 = 0
  11311. // var operation_clab_amt float64 = 0
  11312. // var operation_other_amt float64 = 0
  11313. //
  11314. // var other_claa_sunmfee float64 = 0
  11315. // var other_clab_amt float64 = 0
  11316. // var other_other_amt float64 = 0
  11317. //
  11318. // var westernMedicine_claa_sunmfee float64 = 0
  11319. // var westernMedicine_clab_amt float64 = 0
  11320. // var westernMedicine_other_amt float64 = 0
  11321. //
  11322. // var chineseTraditional_claa_sunmfee float64 = 0
  11323. // var chineseTraditional_clab_amt float64 = 0
  11324. // var chineseTraditional_other_amt float64 = 0
  11325. //
  11326. // var check_claa_sunmfee float64 = 0
  11327. // var check_clab_amt float64 = 0
  11328. // var check_other_amt float64 = 0
  11329. //
  11330. // var material_claa_sunmfee float64 = 0
  11331. // var material_clab_amt float64 = 0
  11332. // var material_other_amt float64 = 0
  11333. //
  11334. // var laboratory_claa_sunmfee float64 = 0
  11335. // var laboratory_clab_amt float64 = 0
  11336. // var laboratory_other_amt float64 = 0
  11337. //
  11338. // var treat_claa_sunmfee float64 = 0
  11339. // var treat_clab_amt float64 = 0
  11340. // var treat_other_amt float64 = 0
  11341. //
  11342. // for _, item := range order.HisOrderInfo {
  11343. // if item.MedChrgitmType == "01" { //床位费
  11344. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11345. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11346. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11347. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11348. // if item.ChrgitmLv == "1" {
  11349. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11350. // }
  11351. // if item.ChrgitmLv == "2" {
  11352. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11353. //
  11354. // }
  11355. // if item.ChrgitmLv == "3" {
  11356. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11357. // }
  11358. //
  11359. // }
  11360. //
  11361. // if item.MedChrgitmType == "03" { //检查费
  11362. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11363. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11364. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11365. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11366. // if item.ChrgitmLv == "1" {
  11367. //
  11368. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11369. //
  11370. // }
  11371. // if item.ChrgitmLv == "2" {
  11372. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11373. //
  11374. // }
  11375. // if item.ChrgitmLv == "3" {
  11376. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11377. // }
  11378. // }
  11379. //
  11380. // if item.MedChrgitmType == "04" { //化验费
  11381. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11382. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11383. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11384. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11385. // if item.ChrgitmLv == "1" {
  11386. //
  11387. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11388. //
  11389. // }
  11390. // if item.ChrgitmLv == "2" {
  11391. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11392. //
  11393. // }
  11394. // if item.ChrgitmLv == "3" {
  11395. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11396. // }
  11397. // }
  11398. //
  11399. // if item.MedChrgitmType == "05" { //治疗费
  11400. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11401. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11402. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11403. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11404. // if item.ChrgitmLv == "1" {
  11405. //
  11406. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11407. //
  11408. // }
  11409. // if item.ChrgitmLv == "2" {
  11410. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11411. //
  11412. // }
  11413. // if item.ChrgitmLv == "3" {
  11414. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11415. // }
  11416. // }
  11417. //
  11418. // if item.MedChrgitmType == "06" { //手术费
  11419. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11420. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11421. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11422. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11423. //
  11424. // if item.ChrgitmLv == "1" {
  11425. //
  11426. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11427. //
  11428. // }
  11429. // if item.ChrgitmLv == "2" {
  11430. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11431. //
  11432. // }
  11433. // if item.ChrgitmLv == "3" {
  11434. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11435. // }
  11436. // }
  11437. //
  11438. // if item.MedChrgitmType == "08" { //材料费
  11439. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11440. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11441. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11442. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11443. // if item.ChrgitmLv == "1" {
  11444. //
  11445. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11446. //
  11447. // }
  11448. // if item.ChrgitmLv == "2" {
  11449. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11450. //
  11451. // }
  11452. // if item.ChrgitmLv == "3" {
  11453. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11454. // }
  11455. // }
  11456. //
  11457. // if item.MedChrgitmType == "09" { //西药费
  11458. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11459. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11460. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11461. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11462. // if item.ChrgitmLv == "1" {
  11463. //
  11464. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11465. //
  11466. // }
  11467. // if item.ChrgitmLv == "2" {
  11468. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11469. //
  11470. // }
  11471. // if item.ChrgitmLv == "3" {
  11472. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11473. // }
  11474. // }
  11475. //
  11476. // if item.MedChrgitmType == "11" { //中成费
  11477. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11478. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11479. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11480. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11481. // if item.ChrgitmLv == "1" {
  11482. //
  11483. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11484. //
  11485. // }
  11486. // if item.ChrgitmLv == "2" {
  11487. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11488. //
  11489. // }
  11490. // if item.ChrgitmLv == "3" {
  11491. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11492. // }
  11493. // }
  11494. //
  11495. // if item.MedChrgitmType == "14" { //其他费
  11496. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11497. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11498. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11499. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11500. // if item.ChrgitmLv == "1" {
  11501. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11502. //
  11503. // }
  11504. // if item.ChrgitmLv == "2" {
  11505. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11506. //
  11507. // }
  11508. // if item.ChrgitmLv == "3" {
  11509. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11510. // }
  11511. // }
  11512. //
  11513. // }
  11514. //
  11515. // var iteminfoStructs []service.IteminfoStruct
  11516. //
  11517. // if bedCostTotal != 0 {
  11518. // iteminfo.MedChrgitm = "01"
  11519. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11520. // iteminfo.Amt = bedCostTotal
  11521. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11522. // iteminfo.ClabAmt = bed_clab_amt
  11523. // iteminfo.OthAmt = bed_other_amt
  11524. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11525. // }
  11526. //
  11527. // if checkCostTotal != 0 {
  11528. // iteminfo.MedChrgitm = "03"
  11529. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11530. // iteminfo.Amt = checkCostTotal
  11531. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11532. // iteminfo.ClabAmt = check_clab_amt
  11533. // iteminfo.OthAmt = check_other_amt
  11534. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11535. //
  11536. // }
  11537. //
  11538. // if laboratoryCostTotal != 0 {
  11539. // iteminfo.MedChrgitm = "04"
  11540. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11541. // iteminfo.Amt = laboratoryCostTotal
  11542. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11543. // iteminfo.ClabAmt = laboratory_clab_amt
  11544. // iteminfo.OthAmt = laboratory_other_amt
  11545. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11546. //
  11547. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11548. //
  11549. // }
  11550. //
  11551. // if treatCostTotal != 0 {
  11552. // iteminfo.MedChrgitm = "05"
  11553. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11554. // iteminfo.Amt = treatCostTotal
  11555. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11556. // iteminfo.ClabAmt = treat_clab_amt
  11557. // iteminfo.OthAmt = treat_other_amt
  11558. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11559. // //(struct4101.IteminfoStruct, iteminfo)
  11560. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11561. // }
  11562. //
  11563. // if operationCostTotal != 0 {
  11564. // iteminfo.MedChrgitm = "06"
  11565. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11566. // iteminfo.Amt = operationCostTotal
  11567. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11568. // iteminfo.ClabAmt = operation_clab_amt
  11569. // iteminfo.OthAmt = operation_other_amt
  11570. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11571. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11572. // }
  11573. //
  11574. // if materialCostTotal != 0 {
  11575. // iteminfo.MedChrgitm = "08"
  11576. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11577. // iteminfo.Amt = materialCostTotal
  11578. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11579. // iteminfo.ClabAmt = material_clab_amt
  11580. // iteminfo.OthAmt = material_other_amt
  11581. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11582. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11583. // }
  11584. //
  11585. // if westernMedicineCostTotal != 0 {
  11586. // iteminfo.MedChrgitm = "09"
  11587. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11588. // iteminfo.Amt = westernMedicineCostTotal
  11589. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11590. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11591. // iteminfo.OthAmt = westernMedicine_other_amt
  11592. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11593. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11594. //
  11595. // }
  11596. // if chineseTraditionalMedicineCostTotal != 0 {
  11597. // iteminfo.MedChrgitm = "11"
  11598. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11599. // iteminfo.Amt = westernMedicineCostTotal
  11600. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11601. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11602. // iteminfo.OthAmt = westernMedicine_other_amt
  11603. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11604. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11605. //
  11606. // }
  11607. // if otherCostTotal != 0 {
  11608. // iteminfo.MedChrgitm = "14"
  11609. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11610. // iteminfo.Amt = otherCostTotal
  11611. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11612. // iteminfo.ClabAmt = other_clab_amt
  11613. // iteminfo.OthAmt = other_other_amt
  11614. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11615. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11616. //
  11617. // }
  11618. // struct4101.IteminfoStruct = iteminfoStructs
  11619. // struct4101.Ntly = "中国"
  11620. // struct4101.AdmCaty = "A03.06"
  11621. //
  11622. // struct4101.DoctorName = doctor.UserName
  11623. // struct4101.DoctorCode = doctor.DoctorNumber
  11624. //
  11625. // var res ResultSeventeen
  11626. //
  11627. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11628. // struct4101.BillCode = order.Number
  11629. // struct4101.BillNo = order.SetlId
  11630. // var resOther ResultSeventeenOther
  11631. // var pp models.PublicParams
  11632. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11633. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11634. // pp.FixmedinsName = miConfig.OrgName
  11635. // pp.FixmedinsCode = miConfig.Code
  11636. // pp.RequestUrl = miConfig.Url
  11637. // pp.Cainfo = miConfig.Cainfo
  11638. // pp.SecretKey = miConfig.SecretKey
  11639. // pp.AccessKey = miConfig.AccessKey
  11640. // pp.OpterName = curRoles.UserName
  11641. //
  11642. // client := &http.Client{}
  11643. // var req *http.Request
  11644. // data := make(map[string]interface{})
  11645. // data["struct4101"] = struct4101
  11646. // data["pp"] = pp
  11647. // bytesData, _ := json.Marshal(data)
  11648. // if miConfig.MdtrtareaAdmvs == "320921" {
  11649. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11650. // } else {
  11651. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11652. // }
  11653. // resp, _ := client.Do(req)
  11654. // defer resp.Body.Close()
  11655. // body, ioErr := ioutil.ReadAll(resp.Body)
  11656. // if ioErr != nil {
  11657. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11658. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11659. // return
  11660. // }
  11661. // var respJSON map[string]interface{}
  11662. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11663. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11664. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11665. // return
  11666. // }
  11667. //
  11668. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11669. // userJSONBytes, _ := json.Marshal(respJSON)
  11670. // fmt.Println("log")
  11671. // fmt.Println(string(userJSONBytes))
  11672. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11673. // utils.ErrorLog("解析失败:%v", err)
  11674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11675. // return
  11676. // }
  11677. // res.InfRefmsgid = resOther.InfRefmsgid
  11678. // res.Output = resOther.Output
  11679. // res.ErrMsg = resOther.ErrMsg
  11680. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11681. // res.Infcode = infocode
  11682. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11683. //
  11684. // var pp models.PublicParams
  11685. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11686. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11687. // pp.FixmedinsName = miConfig.OrgName
  11688. // pp.FixmedinsCode = miConfig.Code
  11689. // pp.RequestUrl = miConfig.Url
  11690. // pp.Cainfo = miConfig.Cainfo
  11691. // pp.SecretKey = miConfig.SecretKey
  11692. // pp.AccessKey = miConfig.AccessKey
  11693. // pp.OpterName = curRoles.UserName
  11694. // result, _ := service.Jxyb4101(struct4101, pp)
  11695. // var dat map[string]interface{}
  11696. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11697. // fmt.Println(dat)
  11698. // } else {
  11699. // fmt.Println(err)
  11700. // }
  11701. // userJSONBytes, _ := json.Marshal(dat)
  11702. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11703. // utils.ErrorLog("解析失败:%v", err)
  11704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11705. // return
  11706. // }
  11707. //
  11708. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11709. // var pp models.PublicParams
  11710. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11711. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11712. // pp.FixmedinsName = miConfig.OrgName
  11713. // pp.FixmedinsCode = miConfig.Code
  11714. // pp.RequestUrl = miConfig.Url
  11715. // pp.Cainfo = miConfig.Cainfo
  11716. // pp.SecretKey = miConfig.SecretKey
  11717. // pp.AccessKey = miConfig.AccessKey
  11718. // pp.OpterName = curRoles.UserName
  11719. // result, _ := service.Hnyb4101(struct4101, pp)
  11720. // var dat map[string]interface{}
  11721. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11722. // fmt.Println(dat)
  11723. // } else {
  11724. // fmt.Println(err)
  11725. // }
  11726. // userJSONBytes, _ := json.Marshal(dat)
  11727. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11728. // utils.ErrorLog("解析失败:%v", err)
  11729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11730. // return
  11731. // }
  11732. //
  11733. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11734. // var resOther ResultSeventeenOther
  11735. //
  11736. // var pp models.PublicParams
  11737. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11738. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11739. // pp.FixmedinsName = miConfig.OrgName
  11740. // pp.FixmedinsCode = miConfig.Code
  11741. // pp.RequestUrl = miConfig.Url
  11742. // pp.Cainfo = miConfig.Cainfo
  11743. // pp.SecretKey = miConfig.SecretKey
  11744. // pp.AccessKey = miConfig.AccessKey
  11745. // pp.OpterName = curRoles.UserName
  11746. // client := &http.Client{}
  11747. // var req *http.Request
  11748. // data := make(map[string]interface{})
  11749. // data["struct4101"] = struct4101
  11750. // data["pp"] = pp
  11751. // bytesData, _ := json.Marshal(data)
  11752. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11753. // resp, _ := client.Do(req)
  11754. // defer resp.Body.Close()
  11755. // body, ioErr := ioutil.ReadAll(resp.Body)
  11756. // if ioErr != nil {
  11757. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11758. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11759. // return
  11760. // }
  11761. // var respJSON map[string]interface{}
  11762. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11763. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11764. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11765. // return
  11766. // }
  11767. //
  11768. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11769. // userJSONBytes, _ := json.Marshal(respJSON)
  11770. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11771. // utils.ErrorLog("解析失败:%v", err)
  11772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11773. // return
  11774. // }
  11775. // res.InfRefmsgid = resOther.InfRefmsgid
  11776. // res.Output = resOther.Output
  11777. // res.ErrMsg = resOther.ErrMsg
  11778. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11779. // res.Infcode = infocode
  11780. //
  11781. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11782. // var pp models.PublicParams
  11783. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11784. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11785. // pp.FixmedinsName = miConfig.OrgName
  11786. // pp.FixmedinsCode = miConfig.Code
  11787. // pp.RequestUrl = miConfig.Url
  11788. // pp.Cainfo = miConfig.Cainfo
  11789. // pp.SecretKey = miConfig.SecretKey
  11790. // pp.AccessKey = miConfig.AccessKey
  11791. // pp.OpterName = curRoles.UserName
  11792. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11793. // fmt.Println(requestLog)
  11794. // fmt.Println(errMsgLog)
  11795. //
  11796. // saveLog(result, requestLog, "4101a", "上传清单")
  11797. //
  11798. // var dat map[string]interface{}
  11799. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11800. // fmt.Println(dat)
  11801. // } else {
  11802. // fmt.Println(err)
  11803. // }
  11804. // userJSONBytes, _ := json.Marshal(dat)
  11805. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11806. // utils.ErrorLog("解析失败:%v", err)
  11807. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11808. // return
  11809. // }
  11810. //
  11811. // } else {
  11812. //
  11813. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11814. // var dat map[string]interface{}
  11815. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11816. // fmt.Println(dat)
  11817. // } else {
  11818. // fmt.Println(err)
  11819. // }
  11820. // userJSONBytes, _ := json.Marshal(dat)
  11821. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11822. // utils.ErrorLog("解析失败:%v", err)
  11823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11824. // return
  11825. // }
  11826. // }
  11827. //
  11828. // if res.Infcode != 0 {
  11829. // adminUser := c.GetAdminUserInfo()
  11830. // errlog := &models.HisOrderError{
  11831. // UserOrgId: adminUser.CurrentOrgId,
  11832. // Ctime: time.Now().Unix(),
  11833. // Mtime: time.Now().Unix(),
  11834. // ErrMsg: res.ErrMsg,
  11835. // Status: 1,
  11836. // PatientId: order.ID,
  11837. // Stage: 10265,
  11838. // }
  11839. // service.CreateErrMsgLog(errlog)
  11840. // continue
  11841. // } else {
  11842. // //order.FaPiaoNumber = zero
  11843. // //order.FaPiaoCode = last_order.FaPiaoCode
  11844. // //service.UpdateOrder(order)
  11845. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11846. // Number: res.Output.SetlListId,
  11847. // Status: 1,
  11848. // Ctime: time.Now().Unix(),
  11849. // Mtime: time.Now().Unix(),
  11850. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11851. // IsUpload: 1,
  11852. // OrderId: order.ID,
  11853. // }
  11854. // service.CreateUploadRecord(hisFundSettleListResult)
  11855. // c.ServeSuccessJSON(map[string]interface{}{
  11856. // "msg": "上传成功",
  11857. // "result": hisFundSettleListResult,
  11858. // })
  11859. // continue
  11860. // }
  11861. // }
  11862. //}
  11863. func (c *HisApiController) GetbatchSettleList() {
  11864. //order_id, _ := c.GetInt64("order_id")
  11865. admin_user_id, _ := c.GetInt64("admin_user_id")
  11866. orders, _ := service.GetAllHisOrderTwo10485()
  11867. for _, item := range orders {
  11868. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11869. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11870. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11871. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11872. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11873. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11874. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11875. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11876. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11877. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11878. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11879. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11880. //fmt.Println(count)
  11881. //var zero string
  11882. //number := count + 1
  11883. //if number >= 1000 {
  11884. // zero = "0000" + strconv.FormatInt(number, 10)
  11885. //} else if number >= 10000 {
  11886. // zero = "000" + strconv.FormatInt(number, 10)
  11887. //} else if number >= 100000 {
  11888. // zero = "00" + strconv.FormatInt(number, 10)
  11889. //} else if number >= 1000000 {
  11890. // zero = "0" + strconv.FormatInt(number, 10)
  11891. //} else {
  11892. // zero = strconv.FormatInt(number, 10)
  11893. //}
  11894. //fmt.Println(zero)
  11895. struct4101 := service.Struct4101{
  11896. PsnNo: order.PsnNo,
  11897. MdtrtId: order.MdtrtId,
  11898. SetlId: order.SetlId,
  11899. PsnName: order.PsnName,
  11900. Gend: order.Gend,
  11901. Brdy: his.Brdy,
  11902. Age: his.Age,
  11903. Naty: order.Naty,
  11904. PatnCertType: "01",
  11905. Certno: order.Certno,
  11906. Prfs: "90",
  11907. ConerName: roles[0].UserName,
  11908. PatnRlts: "99",
  11909. ConerAddr: miConfig.OrgName,
  11910. ConerTel: admin.Mobile,
  11911. HiType: order.Insutype,
  11912. Insuplc: miConfig.InsuplcAdmdvs,
  11913. MaindiagFlag: "1",
  11914. BillCode: order.SetlId,
  11915. BillNo: order.SetlId,
  11916. BizSn: order.Number,
  11917. PsnSelfPay: order.PsnPartAmt,
  11918. PsnOwnPay: order.PsnPartAmt,
  11919. AcctPay: order.AcctPay,
  11920. PsnCashpay: order.PsnCashPay,
  11921. HiPaymtd: "1",
  11922. Hsorg: miConfig.InsuplcAdmdvs,
  11923. HsorgOpter: miConfig.InsuplcAdmdvs,
  11924. MedinsFillPsn: curRoles.UserName,
  11925. MedinsFillDept: miConfig.OrgName,
  11926. IptMedType: "2",
  11927. }
  11928. struct4101.SetlBegnDate = order.SetlTime
  11929. struct4101.SetlEndDate = order.SetlTime
  11930. time_arr := strings.Split(order.SetlTime, " ")
  11931. struct4101.AdmTime = time_arr[0]
  11932. struct4101.AdmEndTime = time_arr[0]
  11933. //var rf []CustomFundPay
  11934. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11935. //
  11936. //var tempFunPays []service.CustomStruct
  11937. //for _, item := range rf {
  11938. // var tempFunPay service.CustomStruct
  11939. // tempFunPay.FundPayamt = item.FundPayamt
  11940. // tempFunPay.FundPayType = item.FundPayType
  11941. // tempFunPays = append(tempFunPays, tempFunPay)
  11942. //}
  11943. //struct4101.CustomStruct = tempFunPays
  11944. var tempDiaginfos []service.DiaginfoStructTwo
  11945. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11946. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11947. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11948. var config []*models.HisXtDiagnoseConfig
  11949. for _, item := range diagnosis_ids {
  11950. id, _ := strconv.ParseInt(item, 10, 64)
  11951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11952. config = append(config, &diagnosisConfig)
  11953. }
  11954. for index, item := range config {
  11955. if index == 0 {
  11956. var tempDiaginfo service.DiaginfoStructTwo
  11957. tempDiaginfo.DiagCode = item.CountryCode
  11958. tempDiaginfo.DiagName = item.CountryContentName
  11959. tempDiaginfo.DiagType = "1"
  11960. tempDiaginfo.MaindiagFlag = "1"
  11961. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11962. } else {
  11963. var tempDiaginfo service.DiaginfoStructTwo
  11964. tempDiaginfo.DiagCode = item.CountryCode
  11965. tempDiaginfo.DiagName = item.CountryContentName
  11966. tempDiaginfo.DiagType = "1"
  11967. tempDiaginfo.MaindiagFlag = "0"
  11968. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11969. }
  11970. }
  11971. struct4101.Diseinfo = tempDiaginfos
  11972. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11973. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11974. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11975. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11976. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11977. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11978. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11979. var iteminfo service.IteminfoStruct
  11980. var bedCostTotal float64 = 0 //床位总费
  11981. var bedCostSelfTotal float64 = 0 //床位自费
  11982. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11983. var operationCostTotal float64 = 0 //手术费
  11984. var operationCostSelfTotal float64 = 0 //手术费
  11985. var operationCostPartSelfTotal float64 = 0 //手术费
  11986. var otherCostTotal float64 = 0 //其他费用
  11987. var otherCostSelfTotal float64 = 0 //其他费用
  11988. var otherCostPartSelfTotal float64 = 0 //其他费用
  11989. var materialCostTotal float64 = 0 //材料费
  11990. var materialCostSelfTotal float64 = 0 //材料费
  11991. var materialCostPartSelfTotal float64 = 0 //材料费
  11992. var westernMedicineCostTotal float64 = 0 //西药费
  11993. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11994. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11995. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11996. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11997. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11998. var checkCostTotal float64 = 0 //检查费
  11999. var checkCostSelfTotal float64 = 0 //检查费
  12000. var checkCostPartSelfTotal float64 = 0 //检查费
  12001. var laboratoryCostTotal float64 = 0 //化验费
  12002. var laboratoryCostSelfTotal float64 = 0 //化验费
  12003. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12004. var treatCostTotal float64 = 0 //治疗费用
  12005. var treatCostSelfTotal float64 = 0 //治疗费用
  12006. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12007. decimal.DivisionPrecision = 2
  12008. var bed_fulamt_ownpay_amt float64 = 0
  12009. var operation_fulamt_ownpay_amt float64 = 0
  12010. var other_fulamt_ownpay_amt float64 = 0
  12011. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12012. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12013. var check_fulamt_ownpay_amt float64 = 0
  12014. var material_fulamt_ownpay_amt float64 = 0
  12015. var laboratory_fulamt_ownpay_amt float64 = 0
  12016. var treat_fulamt_ownpay_amt float64 = 0
  12017. var bed_claa_sunmfee float64 = 0
  12018. var bed_clab_amt float64 = 0
  12019. var bed_other_amt float64 = 0
  12020. var operation_claa_sunmfee float64 = 0
  12021. var operation_clab_amt float64 = 0
  12022. var operation_other_amt float64 = 0
  12023. var other_claa_sunmfee float64 = 0
  12024. var other_clab_amt float64 = 0
  12025. var other_other_amt float64 = 0
  12026. var westernMedicine_claa_sunmfee float64 = 0
  12027. var westernMedicine_clab_amt float64 = 0
  12028. var westernMedicine_other_amt float64 = 0
  12029. var chineseTraditional_claa_sunmfee float64 = 0
  12030. var chineseTraditional_clab_amt float64 = 0
  12031. var chineseTraditional_other_amt float64 = 0
  12032. var check_claa_sunmfee float64 = 0
  12033. var check_clab_amt float64 = 0
  12034. var check_other_amt float64 = 0
  12035. var material_claa_sunmfee float64 = 0
  12036. var material_clab_amt float64 = 0
  12037. var material_other_amt float64 = 0
  12038. var laboratory_claa_sunmfee float64 = 0
  12039. var laboratory_clab_amt float64 = 0
  12040. var laboratory_other_amt float64 = 0
  12041. var treat_claa_sunmfee float64 = 0
  12042. var treat_clab_amt float64 = 0
  12043. var treat_other_amt float64 = 0
  12044. for _, item := range order.HisOrderInfo {
  12045. if item.MedChrgitmType == "01" { //床位费
  12046. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12047. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12048. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12049. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12050. if item.ChrgitmLv == "1" {
  12051. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12052. }
  12053. if item.ChrgitmLv == "2" {
  12054. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12055. }
  12056. if item.ChrgitmLv == "3" {
  12057. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12058. }
  12059. }
  12060. if item.MedChrgitmType == "03" { //检查费
  12061. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12062. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12063. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12064. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12065. if item.ChrgitmLv == "1" {
  12066. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12067. }
  12068. if item.ChrgitmLv == "2" {
  12069. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12070. }
  12071. if item.ChrgitmLv == "3" {
  12072. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12073. }
  12074. }
  12075. if item.MedChrgitmType == "04" { //化验费
  12076. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12077. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12078. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12079. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12080. if item.ChrgitmLv == "1" {
  12081. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12082. }
  12083. if item.ChrgitmLv == "2" {
  12084. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12085. }
  12086. if item.ChrgitmLv == "3" {
  12087. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12088. }
  12089. }
  12090. if item.MedChrgitmType == "05" { //治疗费
  12091. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12092. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12093. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12094. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12095. if item.ChrgitmLv == "1" {
  12096. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12097. }
  12098. if item.ChrgitmLv == "2" {
  12099. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12100. }
  12101. if item.ChrgitmLv == "3" {
  12102. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12103. }
  12104. }
  12105. if item.MedChrgitmType == "06" { //手术费
  12106. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12107. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12108. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12109. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12110. if item.ChrgitmLv == "1" {
  12111. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12112. }
  12113. if item.ChrgitmLv == "2" {
  12114. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12115. }
  12116. if item.ChrgitmLv == "3" {
  12117. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12118. }
  12119. }
  12120. if item.MedChrgitmType == "08" { //材料费
  12121. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12122. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12123. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12124. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12125. if item.ChrgitmLv == "1" {
  12126. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12127. }
  12128. if item.ChrgitmLv == "2" {
  12129. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12130. }
  12131. if item.ChrgitmLv == "3" {
  12132. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12133. }
  12134. }
  12135. if item.MedChrgitmType == "09" { //西药费
  12136. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12137. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12138. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12139. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12140. if item.ChrgitmLv == "1" {
  12141. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12142. }
  12143. if item.ChrgitmLv == "2" {
  12144. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12145. }
  12146. if item.ChrgitmLv == "3" {
  12147. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12148. }
  12149. }
  12150. if item.MedChrgitmType == "11" { //中成费
  12151. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12152. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12153. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12154. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12155. if item.ChrgitmLv == "1" {
  12156. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12157. }
  12158. if item.ChrgitmLv == "2" {
  12159. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12160. }
  12161. if item.ChrgitmLv == "3" {
  12162. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12163. }
  12164. }
  12165. if item.MedChrgitmType == "14" { //其他费
  12166. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12167. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12168. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12169. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12170. if item.ChrgitmLv == "1" {
  12171. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12172. }
  12173. if item.ChrgitmLv == "2" {
  12174. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12175. }
  12176. if item.ChrgitmLv == "3" {
  12177. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12178. }
  12179. }
  12180. }
  12181. var iteminfoStructs []service.IteminfoStruct
  12182. if bedCostTotal != 0 {
  12183. iteminfo.MedChrgitm = "01"
  12184. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12185. iteminfo.Amt = bedCostTotal
  12186. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12187. iteminfo.ClabAmt = bed_clab_amt
  12188. iteminfo.OthAmt = bed_other_amt
  12189. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12190. }
  12191. if checkCostTotal != 0 {
  12192. iteminfo.MedChrgitm = "03"
  12193. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12194. iteminfo.Amt = checkCostTotal
  12195. iteminfo.ClaaSumfee = check_claa_sunmfee
  12196. iteminfo.ClabAmt = check_clab_amt
  12197. iteminfo.OthAmt = check_other_amt
  12198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12199. }
  12200. if laboratoryCostTotal != 0 {
  12201. iteminfo.MedChrgitm = "04"
  12202. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12203. iteminfo.Amt = laboratoryCostTotal
  12204. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12205. iteminfo.ClabAmt = laboratory_clab_amt
  12206. iteminfo.OthAmt = laboratory_other_amt
  12207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12209. }
  12210. if treatCostTotal != 0 {
  12211. iteminfo.MedChrgitm = "05"
  12212. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12213. iteminfo.Amt = treatCostTotal
  12214. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12215. iteminfo.ClabAmt = treat_clab_amt
  12216. iteminfo.OthAmt = treat_other_amt
  12217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12218. //(struct4101.IteminfoStruct, iteminfo)
  12219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12220. }
  12221. if operationCostTotal != 0 {
  12222. iteminfo.MedChrgitm = "06"
  12223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12224. iteminfo.Amt = operationCostTotal
  12225. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12226. iteminfo.ClabAmt = operation_clab_amt
  12227. iteminfo.OthAmt = operation_other_amt
  12228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12230. }
  12231. if materialCostTotal != 0 {
  12232. iteminfo.MedChrgitm = "08"
  12233. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12234. iteminfo.Amt = materialCostTotal
  12235. iteminfo.ClaaSumfee = material_claa_sunmfee
  12236. iteminfo.ClabAmt = material_clab_amt
  12237. iteminfo.OthAmt = material_other_amt
  12238. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12239. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12240. }
  12241. if westernMedicineCostTotal != 0 {
  12242. iteminfo.MedChrgitm = "09"
  12243. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12244. iteminfo.Amt = westernMedicineCostTotal
  12245. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12246. iteminfo.ClabAmt = westernMedicine_clab_amt
  12247. iteminfo.OthAmt = westernMedicine_other_amt
  12248. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12249. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12250. }
  12251. if chineseTraditionalMedicineCostTotal != 0 {
  12252. iteminfo.MedChrgitm = "11"
  12253. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12254. iteminfo.Amt = westernMedicineCostTotal
  12255. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12256. iteminfo.ClabAmt = westernMedicine_clab_amt
  12257. iteminfo.OthAmt = westernMedicine_other_amt
  12258. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12259. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12260. }
  12261. if otherCostTotal != 0 {
  12262. iteminfo.MedChrgitm = "14"
  12263. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12264. iteminfo.Amt = otherCostTotal
  12265. iteminfo.ClaaSumfee = other_claa_sunmfee
  12266. iteminfo.ClabAmt = other_clab_amt
  12267. iteminfo.OthAmt = other_other_amt
  12268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12269. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12270. }
  12271. struct4101.IteminfoStruct = iteminfoStructs
  12272. struct4101.Ntly = "中国"
  12273. struct4101.AdmCaty = "A03.06"
  12274. struct4101.DoctorName = doctor.UserName
  12275. struct4101.DoctorCode = doctor.DoctorNumber
  12276. var res ResultSeventeen
  12277. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12278. struct4101.BillCode = order.Number
  12279. struct4101.BillNo = order.SetlId
  12280. var resOther ResultSeventeenOther
  12281. var pp models.PublicParams
  12282. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12283. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12284. pp.FixmedinsName = miConfig.OrgName
  12285. pp.FixmedinsCode = miConfig.Code
  12286. pp.RequestUrl = miConfig.Url
  12287. pp.Cainfo = miConfig.Cainfo
  12288. pp.SecretKey = miConfig.SecretKey
  12289. pp.AccessKey = miConfig.AccessKey
  12290. pp.OpterName = curRoles.UserName
  12291. client := &http.Client{}
  12292. var req *http.Request
  12293. data := make(map[string]interface{})
  12294. data["struct4101"] = struct4101
  12295. data["pp"] = pp
  12296. bytesData, _ := json.Marshal(data)
  12297. if miConfig.MdtrtareaAdmvs == "320921" {
  12298. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12299. } else {
  12300. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12301. }
  12302. resp, _ := client.Do(req)
  12303. defer resp.Body.Close()
  12304. body, ioErr := ioutil.ReadAll(resp.Body)
  12305. if ioErr != nil {
  12306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12308. return
  12309. }
  12310. var respJSON map[string]interface{}
  12311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12314. return
  12315. }
  12316. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12317. userJSONBytes, _ := json.Marshal(respJSON)
  12318. fmt.Println("log")
  12319. fmt.Println(string(userJSONBytes))
  12320. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12321. utils.ErrorLog("解析失败:%v", err)
  12322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12323. return
  12324. }
  12325. res.InfRefmsgid = resOther.InfRefmsgid
  12326. res.Output = resOther.Output
  12327. res.ErrMsg = resOther.ErrMsg
  12328. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12329. res.Infcode = infocode
  12330. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12331. var pp models.PublicParams
  12332. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12333. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12334. pp.FixmedinsName = miConfig.OrgName
  12335. pp.FixmedinsCode = miConfig.Code
  12336. pp.RequestUrl = miConfig.Url
  12337. pp.Cainfo = miConfig.Cainfo
  12338. pp.SecretKey = miConfig.SecretKey
  12339. pp.AccessKey = miConfig.AccessKey
  12340. pp.OpterName = curRoles.UserName
  12341. result, _ := service.Jxyb4101(struct4101, pp)
  12342. var dat map[string]interface{}
  12343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12344. fmt.Println(dat)
  12345. } else {
  12346. fmt.Println(err)
  12347. }
  12348. userJSONBytes, _ := json.Marshal(dat)
  12349. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12350. utils.ErrorLog("解析失败:%v", err)
  12351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12352. return
  12353. }
  12354. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12355. var pp models.PublicParams
  12356. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12357. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12358. pp.FixmedinsName = miConfig.OrgName
  12359. pp.FixmedinsCode = miConfig.Code
  12360. pp.RequestUrl = miConfig.Url
  12361. pp.Cainfo = miConfig.Cainfo
  12362. pp.SecretKey = miConfig.SecretKey
  12363. pp.AccessKey = miConfig.AccessKey
  12364. pp.OpterName = curRoles.UserName
  12365. result, _ := service.Hnyb4101(struct4101, pp)
  12366. var dat map[string]interface{}
  12367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12368. fmt.Println(dat)
  12369. } else {
  12370. fmt.Println(err)
  12371. }
  12372. userJSONBytes, _ := json.Marshal(dat)
  12373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12374. utils.ErrorLog("解析失败:%v", err)
  12375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12376. return
  12377. }
  12378. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12379. var resOther ResultSeventeenOther
  12380. var pp models.PublicParams
  12381. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12382. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12383. pp.FixmedinsName = miConfig.OrgName
  12384. pp.FixmedinsCode = miConfig.Code
  12385. pp.RequestUrl = miConfig.Url
  12386. pp.Cainfo = miConfig.Cainfo
  12387. pp.SecretKey = miConfig.SecretKey
  12388. pp.AccessKey = miConfig.AccessKey
  12389. pp.OpterName = curRoles.UserName
  12390. client := &http.Client{}
  12391. var req *http.Request
  12392. data := make(map[string]interface{})
  12393. data["struct4101"] = struct4101
  12394. data["pp"] = pp
  12395. bytesData, _ := json.Marshal(data)
  12396. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12397. resp, _ := client.Do(req)
  12398. defer resp.Body.Close()
  12399. body, ioErr := ioutil.ReadAll(resp.Body)
  12400. if ioErr != nil {
  12401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12403. return
  12404. }
  12405. var respJSON map[string]interface{}
  12406. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12409. return
  12410. }
  12411. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12412. userJSONBytes, _ := json.Marshal(respJSON)
  12413. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12414. utils.ErrorLog("解析失败:%v", err)
  12415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12416. return
  12417. }
  12418. res.InfRefmsgid = resOther.InfRefmsgid
  12419. res.Output = resOther.Output
  12420. res.ErrMsg = resOther.ErrMsg
  12421. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12422. res.Infcode = infocode
  12423. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12424. var pp models.PublicParams
  12425. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12426. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12427. pp.FixmedinsName = miConfig.OrgName
  12428. pp.FixmedinsCode = miConfig.Code
  12429. pp.RequestUrl = miConfig.Url
  12430. pp.Cainfo = miConfig.Cainfo
  12431. pp.SecretKey = miConfig.SecretKey
  12432. pp.AccessKey = miConfig.AccessKey
  12433. pp.OpterName = curRoles.UserName
  12434. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12435. fmt.Println(requestLog)
  12436. fmt.Println(errMsgLog)
  12437. saveLog(result, requestLog, "4101a", "上传清单")
  12438. var dat map[string]interface{}
  12439. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12440. fmt.Println(dat)
  12441. } else {
  12442. fmt.Println(err)
  12443. }
  12444. userJSONBytes, _ := json.Marshal(dat)
  12445. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12446. utils.ErrorLog("解析失败:%v", err)
  12447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12448. return
  12449. }
  12450. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12451. var pp models.PublicParams
  12452. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12453. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12454. pp.FixmedinsName = miConfig.OrgName
  12455. pp.FixmedinsCode = miConfig.Code
  12456. pp.RequestUrl = miConfig.Url
  12457. pp.Cainfo = miConfig.Cainfo
  12458. pp.SecretKey = miConfig.SecretKey
  12459. pp.AccessKey = miConfig.AccessKey
  12460. pp.OpterName = curRoles.UserName
  12461. client := &http.Client{}
  12462. var req *http.Request
  12463. data := make(map[string]interface{})
  12464. data["struct4101"] = struct4101
  12465. data["pp"] = pp
  12466. bytesData, _ := json.Marshal(data)
  12467. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12468. resp, _ := client.Do(req)
  12469. defer resp.Body.Close()
  12470. body, ioErr := ioutil.ReadAll(resp.Body)
  12471. if ioErr != nil {
  12472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12474. return
  12475. }
  12476. var respJSON map[string]interface{}
  12477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12480. return
  12481. }
  12482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12483. userJSONBytes, _ := json.Marshal(respJSON)
  12484. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12485. utils.ErrorLog("解析失败:%v", err)
  12486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12487. return
  12488. }
  12489. } else {
  12490. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12491. var dat map[string]interface{}
  12492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12493. fmt.Println(dat)
  12494. } else {
  12495. fmt.Println(err)
  12496. }
  12497. userJSONBytes, _ := json.Marshal(dat)
  12498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12499. utils.ErrorLog("解析失败:%v", err)
  12500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12501. return
  12502. }
  12503. }
  12504. if res.Infcode != 0 {
  12505. errlog := &models.HisOrderError{
  12506. UserOrgId: order.UserOrgId,
  12507. Ctime: time.Now().Unix(),
  12508. Mtime: time.Now().Unix(),
  12509. ErrMsg: res.ErrMsg + "解析失败",
  12510. Status: 1,
  12511. PatientId: order.ID,
  12512. Stage: 10485,
  12513. }
  12514. service.CreateErrMsgLog(errlog)
  12515. continue
  12516. //c.ServeSuccessJSON(map[string]interface{}{
  12517. // "failed_code": -10,
  12518. // "msg": res.ErrMsg,
  12519. //})
  12520. } else {
  12521. //order.FaPiaoNumber = zero
  12522. //order.FaPiaoCode = last_order.FaPiaoCode
  12523. //service.UpdateOrder(order)
  12524. hisFundSettleListResult := &models.HisFundSettleListResult{
  12525. Number: res.Output.SetlListId,
  12526. Status: 1,
  12527. Ctime: time.Now().Unix(),
  12528. Mtime: time.Now().Unix(),
  12529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12530. IsUpload: 1,
  12531. OrderId: order.ID,
  12532. }
  12533. service.CreateUploadRecord(hisFundSettleListResult)
  12534. continue
  12535. }
  12536. }
  12537. }
  12538. func (c *HisApiController) GetSettleList() {
  12539. order_id, _ := c.GetInt64("order_id")
  12540. admin_user_id, _ := c.GetInt64("admin_user_id")
  12541. order, _ := service.GetHisOrderByIDTwo(order_id)
  12542. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12543. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12544. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12545. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12546. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12547. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12548. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12549. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12550. if order.ID == 0 {
  12551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12552. return
  12553. }
  12554. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12555. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12556. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12557. //fmt.Println(count)
  12558. //var zero string
  12559. //number := count + 1
  12560. //if number >= 1000 {
  12561. // zero = "0000" + strconv.FormatInt(number, 10)
  12562. //} else if number >= 10000 {
  12563. // zero = "000" + strconv.FormatInt(number, 10)
  12564. //} else if number >= 100000 {
  12565. // zero = "00" + strconv.FormatInt(number, 10)
  12566. //} else if number >= 1000000 {
  12567. // zero = "0" + strconv.FormatInt(number, 10)
  12568. //} else {
  12569. // zero = strconv.FormatInt(number, 10)
  12570. //}
  12571. //fmt.Println(zero)
  12572. struct4101 := service.Struct4101{
  12573. PsnNo: order.PsnNo,
  12574. MdtrtId: order.MdtrtId,
  12575. SetlId: order.SetlId,
  12576. PsnName: order.PsnName,
  12577. Gend: order.Gend,
  12578. Brdy: his.Brdy,
  12579. Age: his.Age,
  12580. Naty: order.Naty,
  12581. PatnCertType: "01",
  12582. Certno: order.Certno,
  12583. Prfs: "90",
  12584. ConerName: roles[0].UserName,
  12585. PatnRlts: "99",
  12586. ConerAddr: miConfig.OrgName,
  12587. ConerTel: admin.Mobile,
  12588. HiType: order.Insutype,
  12589. Insuplc: miConfig.InsuplcAdmdvs,
  12590. MaindiagFlag: "1",
  12591. BillCode: order.SetlId,
  12592. BillNo: order.SetlId,
  12593. BizSn: order.Number,
  12594. PsnSelfPay: order.PsnPartAmt,
  12595. PsnOwnPay: order.PsnPartAmt,
  12596. AcctPay: order.AcctPay,
  12597. PsnCashpay: order.PsnCashPay,
  12598. HiPaymtd: "1",
  12599. Hsorg: miConfig.InsuplcAdmdvs,
  12600. HsorgOpter: miConfig.InsuplcAdmdvs,
  12601. MedinsFillPsn: curRoles.UserName,
  12602. MedinsFillDept: miConfig.OrgName,
  12603. IptMedType: "2",
  12604. }
  12605. struct4101.SetlBegnDate = order.SetlTime
  12606. struct4101.SetlEndDate = order.SetlTime
  12607. time_arr := strings.Split(order.SetlTime, " ")
  12608. struct4101.AdmTime = time_arr[0]
  12609. struct4101.AdmEndTime = time_arr[0]
  12610. //
  12611. //var rf []CustomFundPay
  12612. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12613. //
  12614. //var tempFunPays []service.CustomStruct
  12615. //for _, item := range rf {
  12616. // var tempFunPay service.CustomStruct
  12617. // tempFunPay.FundPayamt = item.FundPayamt
  12618. // tempFunPay.FundPayType = item.FundPayType
  12619. // tempFunPays = append(tempFunPays, tempFunPay)
  12620. //}
  12621. //struct4101.CustomStruct = tempFunPays
  12622. var tempDiaginfos []service.DiaginfoStructTwo
  12623. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12624. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12625. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12626. var config []*models.HisXtDiagnoseConfig
  12627. for _, item := range diagnosis_ids {
  12628. id, _ := strconv.ParseInt(item, 10, 64)
  12629. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12630. config = append(config, &diagnosisConfig)
  12631. }
  12632. if miConfig.Code == "H15049901371" {
  12633. //for _, item := range config {
  12634. // if item.ID == 138 {
  12635. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12636. var tempDiaginfo service.DiaginfoStructTwo
  12637. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12638. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12639. tempDiaginfo.DiagType = "1"
  12640. tempDiaginfo.MaindiagFlag = "1"
  12641. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12642. //}
  12643. //}
  12644. for _, item := range config {
  12645. if item.ID != 138 {
  12646. var tempDiaginfo service.DiaginfoStructTwo
  12647. tempDiaginfo.DiagCode = item.CountryCode
  12648. tempDiaginfo.DiagName = item.CountryContentName
  12649. tempDiaginfo.DiagType = "1"
  12650. tempDiaginfo.MaindiagFlag = "0"
  12651. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12652. }
  12653. }
  12654. } else {
  12655. for index, item := range config {
  12656. if index == 0 {
  12657. var tempDiaginfo service.DiaginfoStructTwo
  12658. tempDiaginfo.DiagCode = item.CountryCode
  12659. tempDiaginfo.DiagName = item.CountryContentName
  12660. tempDiaginfo.DiagType = "1"
  12661. tempDiaginfo.MaindiagFlag = "1"
  12662. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12663. } else {
  12664. var tempDiaginfo service.DiaginfoStructTwo
  12665. tempDiaginfo.DiagCode = item.CountryCode
  12666. tempDiaginfo.DiagName = item.CountryContentName
  12667. tempDiaginfo.DiagType = "1"
  12668. tempDiaginfo.MaindiagFlag = "0"
  12669. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12670. }
  12671. }
  12672. }
  12673. struct4101.Diseinfo = tempDiaginfos
  12674. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12675. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12676. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12677. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12678. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12679. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12680. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12681. var iteminfo service.IteminfoStruct
  12682. var bedCostTotal float64 = 0 //床位总费
  12683. var bedCostSelfTotal float64 = 0 //床位自费
  12684. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12685. var operationCostTotal float64 = 0 //手术费
  12686. var operationCostSelfTotal float64 = 0 //手术费
  12687. var operationCostPartSelfTotal float64 = 0 //手术费
  12688. var otherCostTotal float64 = 0 //其他费用
  12689. var otherCostSelfTotal float64 = 0 //其他费用
  12690. var otherCostPartSelfTotal float64 = 0 //其他费用
  12691. var materialCostTotal float64 = 0 //材料费
  12692. var materialCostSelfTotal float64 = 0 //材料费
  12693. var materialCostPartSelfTotal float64 = 0 //材料费
  12694. var westernMedicineCostTotal float64 = 0 //西药费
  12695. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12696. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12697. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12698. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12699. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12700. var checkCostTotal float64 = 0 //检查费
  12701. var checkCostSelfTotal float64 = 0 //检查费
  12702. var checkCostPartSelfTotal float64 = 0 //检查费
  12703. var laboratoryCostTotal float64 = 0 //化验费
  12704. var laboratoryCostSelfTotal float64 = 0 //化验费
  12705. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12706. var treatCostTotal float64 = 0 //治疗费用
  12707. var treatCostSelfTotal float64 = 0 //治疗费用
  12708. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12709. decimal.DivisionPrecision = 2
  12710. var bed_fulamt_ownpay_amt float64 = 0
  12711. var operation_fulamt_ownpay_amt float64 = 0
  12712. var other_fulamt_ownpay_amt float64 = 0
  12713. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12714. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12715. var check_fulamt_ownpay_amt float64 = 0
  12716. var material_fulamt_ownpay_amt float64 = 0
  12717. var laboratory_fulamt_ownpay_amt float64 = 0
  12718. var treat_fulamt_ownpay_amt float64 = 0
  12719. var bed_claa_sunmfee float64 = 0
  12720. var bed_clab_amt float64 = 0
  12721. var bed_other_amt float64 = 0
  12722. var operation_claa_sunmfee float64 = 0
  12723. var operation_clab_amt float64 = 0
  12724. var operation_other_amt float64 = 0
  12725. var other_claa_sunmfee float64 = 0
  12726. var other_clab_amt float64 = 0
  12727. var other_other_amt float64 = 0
  12728. var westernMedicine_claa_sunmfee float64 = 0
  12729. var westernMedicine_clab_amt float64 = 0
  12730. var westernMedicine_other_amt float64 = 0
  12731. var chineseTraditional_claa_sunmfee float64 = 0
  12732. var chineseTraditional_clab_amt float64 = 0
  12733. var chineseTraditional_other_amt float64 = 0
  12734. var check_claa_sunmfee float64 = 0
  12735. var check_clab_amt float64 = 0
  12736. var check_other_amt float64 = 0
  12737. var material_claa_sunmfee float64 = 0
  12738. var material_clab_amt float64 = 0
  12739. var material_other_amt float64 = 0
  12740. var laboratory_claa_sunmfee float64 = 0
  12741. var laboratory_clab_amt float64 = 0
  12742. var laboratory_other_amt float64 = 0
  12743. var treat_claa_sunmfee float64 = 0
  12744. var treat_clab_amt float64 = 0
  12745. var treat_other_amt float64 = 0
  12746. for _, item := range order.HisOrderInfo {
  12747. if item.MedChrgitmType == "01" { //床位费
  12748. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12749. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12750. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12751. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12752. if item.ChrgitmLv == "1" {
  12753. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12754. }
  12755. if item.ChrgitmLv == "2" {
  12756. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12757. }
  12758. if item.ChrgitmLv == "3" {
  12759. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12760. }
  12761. }
  12762. if item.MedChrgitmType == "03" { //检查费
  12763. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12764. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12765. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12766. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12767. if item.ChrgitmLv == "1" {
  12768. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12769. }
  12770. if item.ChrgitmLv == "2" {
  12771. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12772. }
  12773. if item.ChrgitmLv == "3" {
  12774. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12775. }
  12776. }
  12777. if item.MedChrgitmType == "04" { //化验费
  12778. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12779. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12780. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12781. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12782. if item.ChrgitmLv == "1" {
  12783. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12784. }
  12785. if item.ChrgitmLv == "2" {
  12786. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12787. }
  12788. if item.ChrgitmLv == "3" {
  12789. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12790. }
  12791. }
  12792. if item.MedChrgitmType == "05" { //治疗费
  12793. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12794. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12795. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12796. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12797. if item.ChrgitmLv == "1" {
  12798. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12799. }
  12800. if item.ChrgitmLv == "2" {
  12801. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12802. }
  12803. if item.ChrgitmLv == "3" {
  12804. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12805. }
  12806. }
  12807. if item.MedChrgitmType == "06" { //手术费
  12808. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12809. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12810. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12811. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12812. if item.ChrgitmLv == "1" {
  12813. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12814. }
  12815. if item.ChrgitmLv == "2" {
  12816. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12817. }
  12818. if item.ChrgitmLv == "3" {
  12819. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12820. }
  12821. }
  12822. if item.MedChrgitmType == "08" { //材料费
  12823. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12824. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12825. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12826. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12827. if item.ChrgitmLv == "1" {
  12828. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12829. }
  12830. if item.ChrgitmLv == "2" {
  12831. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12832. }
  12833. if item.ChrgitmLv == "3" {
  12834. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12835. }
  12836. }
  12837. if item.MedChrgitmType == "09" { //西药费
  12838. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12839. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12840. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12841. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12842. if item.ChrgitmLv == "1" {
  12843. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12844. }
  12845. if item.ChrgitmLv == "2" {
  12846. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12847. }
  12848. if item.ChrgitmLv == "3" {
  12849. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12850. }
  12851. }
  12852. if item.MedChrgitmType == "11" { //中成费
  12853. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12854. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12855. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12856. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12857. if item.ChrgitmLv == "1" {
  12858. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12859. }
  12860. if item.ChrgitmLv == "2" {
  12861. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12862. }
  12863. if item.ChrgitmLv == "3" {
  12864. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12865. }
  12866. }
  12867. if item.MedChrgitmType == "14" { //其他费
  12868. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12869. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12870. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12871. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12872. if item.ChrgitmLv == "1" {
  12873. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12874. }
  12875. if item.ChrgitmLv == "2" {
  12876. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12877. }
  12878. if item.ChrgitmLv == "3" {
  12879. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12880. }
  12881. }
  12882. }
  12883. var iteminfoStructs []service.IteminfoStruct
  12884. if bedCostTotal != 0 {
  12885. iteminfo.MedChrgitm = "01"
  12886. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12887. iteminfo.Amt = bedCostTotal
  12888. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12889. iteminfo.ClabAmt = bed_clab_amt
  12890. iteminfo.OthAmt = bed_other_amt
  12891. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12892. }
  12893. if checkCostTotal != 0 {
  12894. iteminfo.MedChrgitm = "03"
  12895. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12896. iteminfo.Amt = checkCostTotal
  12897. iteminfo.ClaaSumfee = check_claa_sunmfee
  12898. iteminfo.ClabAmt = check_clab_amt
  12899. iteminfo.OthAmt = check_other_amt
  12900. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12901. }
  12902. if laboratoryCostTotal != 0 {
  12903. iteminfo.MedChrgitm = "04"
  12904. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12905. iteminfo.Amt = laboratoryCostTotal
  12906. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12907. iteminfo.ClabAmt = laboratory_clab_amt
  12908. iteminfo.OthAmt = laboratory_other_amt
  12909. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12910. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12911. }
  12912. if treatCostTotal != 0 {
  12913. iteminfo.MedChrgitm = "05"
  12914. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12915. iteminfo.Amt = treatCostTotal
  12916. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12917. iteminfo.ClabAmt = treat_clab_amt
  12918. iteminfo.OthAmt = treat_other_amt
  12919. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12920. //(struct4101.IteminfoStruct, iteminfo)
  12921. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12922. }
  12923. if operationCostTotal != 0 {
  12924. iteminfo.MedChrgitm = "06"
  12925. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12926. iteminfo.Amt = operationCostTotal
  12927. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12928. iteminfo.ClabAmt = operation_clab_amt
  12929. iteminfo.OthAmt = operation_other_amt
  12930. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12931. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12932. }
  12933. if materialCostTotal != 0 {
  12934. iteminfo.MedChrgitm = "08"
  12935. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12936. iteminfo.Amt = materialCostTotal
  12937. iteminfo.ClaaSumfee = material_claa_sunmfee
  12938. iteminfo.ClabAmt = material_clab_amt
  12939. iteminfo.OthAmt = material_other_amt
  12940. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12941. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12942. }
  12943. if westernMedicineCostTotal != 0 {
  12944. iteminfo.MedChrgitm = "09"
  12945. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12946. iteminfo.Amt = westernMedicineCostTotal
  12947. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12948. iteminfo.ClabAmt = westernMedicine_clab_amt
  12949. iteminfo.OthAmt = westernMedicine_other_amt
  12950. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12951. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12952. }
  12953. if chineseTraditionalMedicineCostTotal != 0 {
  12954. iteminfo.MedChrgitm = "11"
  12955. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12956. iteminfo.Amt = westernMedicineCostTotal
  12957. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12958. iteminfo.ClabAmt = westernMedicine_clab_amt
  12959. iteminfo.OthAmt = westernMedicine_other_amt
  12960. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12961. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12962. }
  12963. if otherCostTotal != 0 {
  12964. iteminfo.MedChrgitm = "14"
  12965. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12966. iteminfo.Amt = otherCostTotal
  12967. iteminfo.ClaaSumfee = other_claa_sunmfee
  12968. iteminfo.ClabAmt = other_clab_amt
  12969. iteminfo.OthAmt = other_other_amt
  12970. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12971. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12972. }
  12973. struct4101.IteminfoStruct = iteminfoStructs
  12974. struct4101.Ntly = "中国"
  12975. struct4101.AdmCaty = "A03.06"
  12976. struct4101.DoctorName = doctor.UserName
  12977. struct4101.DoctorCode = doctor.DoctorNumber
  12978. var res ResultSeventeen
  12979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12980. struct4101.BillCode = order.Number
  12981. struct4101.BillNo = order.SetlId
  12982. var resOther ResultSeventeenOther
  12983. var pp models.PublicParams
  12984. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12985. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12986. pp.FixmedinsName = miConfig.OrgName
  12987. pp.FixmedinsCode = miConfig.Code
  12988. pp.RequestUrl = miConfig.Url
  12989. pp.Cainfo = miConfig.Cainfo
  12990. pp.SecretKey = miConfig.SecretKey
  12991. pp.AccessKey = miConfig.AccessKey
  12992. pp.OpterName = curRoles.UserName
  12993. client := &http.Client{}
  12994. var req *http.Request
  12995. data := make(map[string]interface{})
  12996. data["struct4101"] = struct4101
  12997. data["pp"] = pp
  12998. bytesData, _ := json.Marshal(data)
  12999. if miConfig.MdtrtareaAdmvs == "320921" {
  13000. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13001. } else {
  13002. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13003. }
  13004. resp, _ := client.Do(req)
  13005. defer resp.Body.Close()
  13006. body, ioErr := ioutil.ReadAll(resp.Body)
  13007. if ioErr != nil {
  13008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13010. return
  13011. }
  13012. var respJSON map[string]interface{}
  13013. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13016. return
  13017. }
  13018. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13019. userJSONBytes, _ := json.Marshal(respJSON)
  13020. fmt.Println("log")
  13021. fmt.Println(string(userJSONBytes))
  13022. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13023. utils.ErrorLog("解析失败:%v", err)
  13024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13025. return
  13026. }
  13027. res.InfRefmsgid = resOther.InfRefmsgid
  13028. res.Output = resOther.Output
  13029. res.ErrMsg = resOther.ErrMsg
  13030. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13031. res.Infcode = infocode
  13032. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13033. var pp models.PublicParams
  13034. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13035. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13036. pp.FixmedinsName = miConfig.OrgName
  13037. pp.FixmedinsCode = miConfig.Code
  13038. pp.RequestUrl = miConfig.Url
  13039. pp.Cainfo = miConfig.Cainfo
  13040. pp.SecretKey = miConfig.SecretKey
  13041. pp.AccessKey = miConfig.AccessKey
  13042. pp.OpterName = curRoles.UserName
  13043. result, _ := service.Jxyb4101(struct4101, pp)
  13044. var dat map[string]interface{}
  13045. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13046. fmt.Println(dat)
  13047. } else {
  13048. fmt.Println(err)
  13049. }
  13050. userJSONBytes, _ := json.Marshal(dat)
  13051. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13052. utils.ErrorLog("解析失败:%v", err)
  13053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13054. return
  13055. }
  13056. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13057. var pp models.PublicParams
  13058. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13059. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13060. pp.FixmedinsName = miConfig.OrgName
  13061. pp.FixmedinsCode = miConfig.Code
  13062. pp.RequestUrl = miConfig.Url
  13063. pp.Cainfo = miConfig.Cainfo
  13064. pp.SecretKey = miConfig.SecretKey
  13065. pp.AccessKey = miConfig.AccessKey
  13066. pp.OpterName = curRoles.UserName
  13067. result, _ := service.Hnyb4101(struct4101, pp)
  13068. var dat map[string]interface{}
  13069. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13070. fmt.Println(dat)
  13071. } else {
  13072. fmt.Println(err)
  13073. }
  13074. userJSONBytes, _ := json.Marshal(dat)
  13075. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13076. utils.ErrorLog("解析失败:%v", err)
  13077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13078. return
  13079. }
  13080. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13081. var resOther ResultSeventeenOther
  13082. var pp models.PublicParams
  13083. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13084. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13085. pp.FixmedinsName = miConfig.OrgName
  13086. pp.FixmedinsCode = miConfig.Code
  13087. pp.RequestUrl = miConfig.Url
  13088. pp.Cainfo = miConfig.Cainfo
  13089. pp.SecretKey = miConfig.SecretKey
  13090. pp.AccessKey = miConfig.AccessKey
  13091. pp.OpterName = curRoles.UserName
  13092. client := &http.Client{}
  13093. var req *http.Request
  13094. data := make(map[string]interface{})
  13095. data["struct4101"] = struct4101
  13096. data["pp"] = pp
  13097. bytesData, _ := json.Marshal(data)
  13098. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13099. resp, _ := client.Do(req)
  13100. defer resp.Body.Close()
  13101. body, ioErr := ioutil.ReadAll(resp.Body)
  13102. if ioErr != nil {
  13103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13105. return
  13106. }
  13107. var respJSON map[string]interface{}
  13108. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13111. return
  13112. }
  13113. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13114. userJSONBytes, _ := json.Marshal(respJSON)
  13115. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13116. utils.ErrorLog("解析失败:%v", err)
  13117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13118. return
  13119. }
  13120. res.InfRefmsgid = resOther.InfRefmsgid
  13121. res.Output = resOther.Output
  13122. res.ErrMsg = resOther.ErrMsg
  13123. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13124. res.Infcode = infocode
  13125. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13126. var pp models.PublicParams
  13127. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13128. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13129. pp.FixmedinsName = miConfig.OrgName
  13130. pp.FixmedinsCode = miConfig.Code
  13131. pp.RequestUrl = miConfig.Url
  13132. pp.Cainfo = miConfig.Cainfo
  13133. pp.SecretKey = miConfig.SecretKey
  13134. pp.AccessKey = miConfig.AccessKey
  13135. pp.OpterName = curRoles.UserName
  13136. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13137. fmt.Println(requestLog)
  13138. fmt.Println(errMsgLog)
  13139. saveLog(result, requestLog, "4101a", "上传清单")
  13140. var dat map[string]interface{}
  13141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13142. fmt.Println(dat)
  13143. } else {
  13144. fmt.Println(err)
  13145. }
  13146. userJSONBytes, _ := json.Marshal(dat)
  13147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13148. utils.ErrorLog("解析失败:%v", err)
  13149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13150. return
  13151. }
  13152. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13153. var pp models.PublicParams
  13154. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13155. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13156. pp.FixmedinsName = miConfig.OrgName
  13157. pp.FixmedinsCode = miConfig.Code
  13158. pp.RequestUrl = miConfig.Url
  13159. pp.Cainfo = miConfig.Cainfo
  13160. pp.SecretKey = miConfig.SecretKey
  13161. pp.AccessKey = miConfig.AccessKey
  13162. pp.OpterName = curRoles.UserName
  13163. client := &http.Client{}
  13164. var req *http.Request
  13165. data := make(map[string]interface{})
  13166. data["struct4101"] = struct4101
  13167. data["pp"] = pp
  13168. bytesData, _ := json.Marshal(data)
  13169. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13170. resp, _ := client.Do(req)
  13171. defer resp.Body.Close()
  13172. body, ioErr := ioutil.ReadAll(resp.Body)
  13173. if ioErr != nil {
  13174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13176. return
  13177. }
  13178. var respJSON map[string]interface{}
  13179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13182. return
  13183. }
  13184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13185. userJSONBytes, _ := json.Marshal(respJSON)
  13186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13187. utils.ErrorLog("解析失败:%v", err)
  13188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13189. return
  13190. }
  13191. } else {
  13192. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13193. var dat map[string]interface{}
  13194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13195. fmt.Println(dat)
  13196. } else {
  13197. fmt.Println(err)
  13198. }
  13199. userJSONBytes, _ := json.Marshal(dat)
  13200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13201. utils.ErrorLog("解析失败:%v", err)
  13202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13203. return
  13204. }
  13205. }
  13206. if res.Infcode != 0 {
  13207. c.ServeSuccessJSON(map[string]interface{}{
  13208. "failed_code": -10,
  13209. "msg": res.ErrMsg,
  13210. })
  13211. return
  13212. } else {
  13213. //order.FaPiaoNumber = zero
  13214. //order.FaPiaoCode = last_order.FaPiaoCode
  13215. //service.UpdateOrder(order)
  13216. hisFundSettleListResult := &models.HisFundSettleListResult{
  13217. Number: res.Output.SetlListId,
  13218. Status: 1,
  13219. Ctime: time.Now().Unix(),
  13220. Mtime: time.Now().Unix(),
  13221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13222. IsUpload: 1,
  13223. OrderId: order_id,
  13224. }
  13225. service.CreateUploadRecord(hisFundSettleListResult)
  13226. c.ServeSuccessJSON(map[string]interface{}{
  13227. "msg": "上传成功",
  13228. "result": hisFundSettleListResult,
  13229. })
  13230. return
  13231. }
  13232. }
  13233. func (c *HisApiController) GetSettleListHospital() {
  13234. order_id, _ := c.GetInt64("order_id")
  13235. admin_user_id, _ := c.GetInt64("admin_user_id")
  13236. order, _ := service.GetHisOrderByIDTwo(order_id)
  13237. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13238. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13239. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13240. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13241. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13242. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13243. if order.ID == 0 {
  13244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13245. return
  13246. }
  13247. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13248. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13249. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13250. fmt.Println(count)
  13251. var zero string
  13252. number := count + 1
  13253. if number >= 1000 {
  13254. zero = "0000" + strconv.FormatInt(number, 10)
  13255. } else if number >= 10000 {
  13256. zero = "000" + strconv.FormatInt(number, 10)
  13257. } else if number >= 100000 {
  13258. zero = "00" + strconv.FormatInt(number, 10)
  13259. } else if number >= 1000000 {
  13260. zero = "0" + strconv.FormatInt(number, 10)
  13261. } else {
  13262. zero = strconv.FormatInt(number, 10)
  13263. }
  13264. fmt.Println(zero)
  13265. struct4101 := service.Struct4101{
  13266. PsnNo: order.PsnNo,
  13267. MdtrtId: order.MdtrtId,
  13268. SetlId: order.SetlId,
  13269. PsnName: order.PsnName,
  13270. Gend: order.Gend,
  13271. Brdy: his.Brdy,
  13272. Age: int64(order.Age),
  13273. Naty: order.Naty,
  13274. PatnCertType: "01",
  13275. Certno: order.Certno,
  13276. Prfs: "90",
  13277. ConerName: roles[0].UserName,
  13278. PatnRlts: "99",
  13279. ConerAddr: miConfig.OrgName,
  13280. ConerTel: admin.Mobile,
  13281. HiType: order.Insutype,
  13282. Insuplc: miConfig.InsuplcAdmdvs,
  13283. MaindiagFlag: "1",
  13284. BillCode: order.SetlId,
  13285. BillNo: order.SetlId,
  13286. BizSn: order.Number,
  13287. PsnSelfPay: order.PsnPartAmt,
  13288. PsnOwnPay: order.PsnPartAmt,
  13289. AcctPay: order.AcctPay,
  13290. PsnCashpay: order.PsnCashPay,
  13291. HiPaymtd: "1",
  13292. Hsorg: miConfig.InsuplcAdmdvs,
  13293. HsorgOpter: miConfig.InsuplcAdmdvs,
  13294. MedinsFillPsn: curRoles.UserName,
  13295. MedinsFillDept: depart.Name,
  13296. IptMedType: "2",
  13297. AdmTime: his.InHosptialTime,
  13298. AdmEndTime: his.OutHosptialTime,
  13299. }
  13300. struct4101.SetlBegnDate = order.SetlTime
  13301. struct4101.SetlEndDate = order.SetlTime
  13302. //var rf []CustomFundPay
  13303. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13304. //
  13305. //var tempFunPays []service.CustomStruct
  13306. //for _, item := range rf {
  13307. // var tempFunPay service.CustomStruct
  13308. // tempFunPay.FundPayamt = item.FundPayamt
  13309. // tempFunPay.FundPayType = item.FundPayType
  13310. // tempFunPays = append(tempFunPays, tempFunPay)
  13311. //}
  13312. //struct4101.CustomStruct = tempFunPays
  13313. var tempDiaginfos []service.DiaginfoStructTwo
  13314. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13315. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13316. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13317. //for _, item := range infos {
  13318. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13319. //}
  13320. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13321. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13322. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13323. fmt.Println(diagnosis_ids_arr)
  13324. if order.UserOrgId == 10210 {
  13325. var diagnosis_ids_arr_two []int64
  13326. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13327. var config []*models.HisXtDiagnoseConfig
  13328. for _, id := range diagnosis_ids_arr_two {
  13329. //id, _ := strconv.ParseInt(item, 10, 64)
  13330. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13331. if diagnosisConfig.ID > 0 {
  13332. config = append(config, &diagnosisConfig)
  13333. }
  13334. }
  13335. for index, item := range config {
  13336. if item.ID > 0 {
  13337. if index == 0 {
  13338. var tempDiaginfo service.DiaginfoStructTwo
  13339. tempDiaginfo.DiagCode = item.CountryCode
  13340. tempDiaginfo.DiagName = item.CountryContentName
  13341. tempDiaginfo.DiagType = "1"
  13342. tempDiaginfo.MaindiagFlag = "1"
  13343. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13344. } else {
  13345. var tempDiaginfo service.DiaginfoStructTwo
  13346. tempDiaginfo.DiagCode = item.CountryCode
  13347. tempDiaginfo.DiagName = item.CountryContentName
  13348. tempDiaginfo.DiagType = "1"
  13349. tempDiaginfo.MaindiagFlag = "0"
  13350. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13351. }
  13352. }
  13353. }
  13354. struct4101.Diseinfo = tempDiaginfos
  13355. } else {
  13356. var config []*models.HisXtDiagnoseConfig
  13357. for _, item := range diagnosis_ids_arr {
  13358. id, _ := strconv.ParseInt(item, 10, 64)
  13359. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13360. if diagnosisConfig.ID > 0 {
  13361. config = append(config, &diagnosisConfig)
  13362. }
  13363. }
  13364. for index, item := range config {
  13365. if item.ID > 0 {
  13366. if index == 0 {
  13367. var tempDiaginfo service.DiaginfoStructTwo
  13368. tempDiaginfo.DiagCode = item.CountryCode
  13369. tempDiaginfo.DiagName = item.CountryContentName
  13370. tempDiaginfo.DiagType = "1"
  13371. tempDiaginfo.MaindiagFlag = "1"
  13372. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13373. } else {
  13374. var tempDiaginfo service.DiaginfoStructTwo
  13375. tempDiaginfo.DiagCode = item.CountryCode
  13376. tempDiaginfo.DiagName = item.CountryContentName
  13377. tempDiaginfo.DiagType = "1"
  13378. tempDiaginfo.MaindiagFlag = "0"
  13379. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13380. }
  13381. }
  13382. }
  13383. struct4101.Diseinfo = tempDiaginfos
  13384. }
  13385. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13386. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13387. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13388. tempOpspdiseinfo2.OprnOprtCode = ""
  13389. tempOpspdiseinfo2.OprnOprtName = ""
  13390. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13391. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13392. var iteminfo service.IteminfoStruct
  13393. var bedCostTotal float64 = 0 //床位总费
  13394. var bedCostSelfTotal float64 = 0 //床位自费
  13395. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13396. var operationCostTotal float64 = 0 //手术费
  13397. var operationCostSelfTotal float64 = 0 //手术费
  13398. var operationCostPartSelfTotal float64 = 0 //手术费
  13399. var otherCostTotal float64 = 0 //其他费用
  13400. var otherCostSelfTotal float64 = 0 //其他费用
  13401. var otherCostPartSelfTotal float64 = 0 //其他费用
  13402. var materialCostTotal float64 = 0 //材料费
  13403. var materialCostSelfTotal float64 = 0 //材料费
  13404. var materialCostPartSelfTotal float64 = 0 //材料费
  13405. var westernMedicineCostTotal float64 = 0 //西药费
  13406. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13407. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13408. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13409. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13410. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13411. var checkCostTotal float64 = 0 //检查费
  13412. var checkCostSelfTotal float64 = 0 //检查费
  13413. var checkCostPartSelfTotal float64 = 0 //检查费
  13414. var laboratoryCostTotal float64 = 0 //化验费
  13415. var laboratoryCostSelfTotal float64 = 0 //化验费
  13416. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13417. var treatCostTotal float64 = 0 //治疗费用
  13418. var treatCostSelfTotal float64 = 0 //治疗费用
  13419. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13420. decimal.DivisionPrecision = 2
  13421. var bed_fulamt_ownpay_amt float64 = 0
  13422. var operation_fulamt_ownpay_amt float64 = 0
  13423. var other_fulamt_ownpay_amt float64 = 0
  13424. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13425. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13426. var check_fulamt_ownpay_amt float64 = 0
  13427. var material_fulamt_ownpay_amt float64 = 0
  13428. var laboratory_fulamt_ownpay_amt float64 = 0
  13429. var treat_fulamt_ownpay_amt float64 = 0
  13430. var bed_claa_sunmfee float64 = 0
  13431. var bed_clab_amt float64 = 0
  13432. var bed_other_amt float64 = 0
  13433. var operation_claa_sunmfee float64 = 0
  13434. var operation_clab_amt float64 = 0
  13435. var operation_other_amt float64 = 0
  13436. var other_claa_sunmfee float64 = 0
  13437. var other_clab_amt float64 = 0
  13438. var other_other_amt float64 = 0
  13439. var westernMedicine_claa_sunmfee float64 = 0
  13440. var westernMedicine_clab_amt float64 = 0
  13441. var westernMedicine_other_amt float64 = 0
  13442. var chineseTraditional_claa_sunmfee float64 = 0
  13443. var chineseTraditional_clab_amt float64 = 0
  13444. var chineseTraditional_other_amt float64 = 0
  13445. var check_claa_sunmfee float64 = 0
  13446. var check_clab_amt float64 = 0
  13447. var check_other_amt float64 = 0
  13448. var material_claa_sunmfee float64 = 0
  13449. var material_clab_amt float64 = 0
  13450. var material_other_amt float64 = 0
  13451. var laboratory_claa_sunmfee float64 = 0
  13452. var laboratory_clab_amt float64 = 0
  13453. var laboratory_other_amt float64 = 0
  13454. var treat_claa_sunmfee float64 = 0
  13455. var treat_clab_amt float64 = 0
  13456. var treat_other_amt float64 = 0
  13457. for _, item := range order.HisOrderInfo {
  13458. if item.MedChrgitmType == "01" { //床位费
  13459. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13460. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13461. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13462. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13463. if item.ChrgitmLv == "1" {
  13464. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13465. }
  13466. if item.ChrgitmLv == "2" {
  13467. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13468. }
  13469. if item.ChrgitmLv == "3" {
  13470. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13471. }
  13472. }
  13473. if item.MedChrgitmType == "03" { //检查费
  13474. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13475. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13476. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13477. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13478. if item.ChrgitmLv == "1" {
  13479. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13480. }
  13481. if item.ChrgitmLv == "2" {
  13482. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13483. }
  13484. if item.ChrgitmLv == "3" {
  13485. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13486. }
  13487. }
  13488. if item.MedChrgitmType == "04" { //化验费
  13489. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13490. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13491. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13492. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13493. if item.ChrgitmLv == "1" {
  13494. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13495. }
  13496. if item.ChrgitmLv == "2" {
  13497. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13498. }
  13499. if item.ChrgitmLv == "3" {
  13500. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13501. }
  13502. }
  13503. if item.MedChrgitmType == "05" { //治疗费
  13504. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13505. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13506. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13507. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13508. if item.ChrgitmLv == "1" {
  13509. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13510. }
  13511. if item.ChrgitmLv == "2" {
  13512. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13513. }
  13514. if item.ChrgitmLv == "3" {
  13515. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13516. }
  13517. }
  13518. if item.MedChrgitmType == "06" { //手术费
  13519. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13520. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13521. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13522. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13523. if item.ChrgitmLv == "1" {
  13524. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13525. }
  13526. if item.ChrgitmLv == "2" {
  13527. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13528. }
  13529. if item.ChrgitmLv == "3" {
  13530. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13531. }
  13532. }
  13533. if item.MedChrgitmType == "08" { //材料费
  13534. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13535. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13536. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13537. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13538. if item.ChrgitmLv == "1" {
  13539. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13540. }
  13541. if item.ChrgitmLv == "2" {
  13542. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13543. }
  13544. if item.ChrgitmLv == "3" {
  13545. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13546. }
  13547. }
  13548. if item.MedChrgitmType == "09" { //西药费
  13549. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13550. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13551. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13552. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13553. if item.ChrgitmLv == "1" {
  13554. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13555. }
  13556. if item.ChrgitmLv == "2" {
  13557. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13558. }
  13559. if item.ChrgitmLv == "3" {
  13560. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13561. }
  13562. }
  13563. if item.MedChrgitmType == "11" { //中成费
  13564. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13565. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13566. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13567. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13568. if item.ChrgitmLv == "1" {
  13569. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13570. }
  13571. if item.ChrgitmLv == "2" {
  13572. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13573. }
  13574. if item.ChrgitmLv == "3" {
  13575. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13576. }
  13577. }
  13578. if item.MedChrgitmType == "14" { //其他费
  13579. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13580. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13581. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13582. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13583. if item.ChrgitmLv == "1" {
  13584. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13585. }
  13586. if item.ChrgitmLv == "2" {
  13587. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13588. }
  13589. if item.ChrgitmLv == "3" {
  13590. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13591. }
  13592. }
  13593. }
  13594. var iteminfoStructs []service.IteminfoStruct
  13595. if bedCostTotal != 0 {
  13596. iteminfo.MedChrgitm = "01"
  13597. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13598. iteminfo.Amt = bedCostTotal
  13599. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13600. iteminfo.ClabAmt = bed_clab_amt
  13601. iteminfo.OthAmt = bed_other_amt
  13602. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13603. }
  13604. if checkCostTotal != 0 {
  13605. iteminfo.MedChrgitm = "03"
  13606. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13607. iteminfo.Amt = checkCostTotal
  13608. iteminfo.ClaaSumfee = check_claa_sunmfee
  13609. iteminfo.ClabAmt = check_clab_amt
  13610. iteminfo.OthAmt = check_other_amt
  13611. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13612. }
  13613. if laboratoryCostTotal != 0 {
  13614. iteminfo.MedChrgitm = "04"
  13615. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13616. iteminfo.Amt = laboratoryCostTotal
  13617. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13618. iteminfo.ClabAmt = laboratory_clab_amt
  13619. iteminfo.OthAmt = laboratory_other_amt
  13620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13621. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13622. }
  13623. if treatCostTotal != 0 {
  13624. iteminfo.MedChrgitm = "05"
  13625. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13626. iteminfo.Amt = treatCostTotal
  13627. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13628. iteminfo.ClabAmt = treat_clab_amt
  13629. iteminfo.OthAmt = treat_other_amt
  13630. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13631. //(struct4101.IteminfoStruct, iteminfo)
  13632. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13633. }
  13634. if operationCostTotal != 0 {
  13635. iteminfo.MedChrgitm = "06"
  13636. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13637. iteminfo.Amt = operationCostTotal
  13638. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13639. iteminfo.ClabAmt = operation_clab_amt
  13640. iteminfo.OthAmt = operation_other_amt
  13641. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13643. }
  13644. if materialCostTotal != 0 {
  13645. iteminfo.MedChrgitm = "08"
  13646. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13647. iteminfo.Amt = materialCostTotal
  13648. iteminfo.ClaaSumfee = material_claa_sunmfee
  13649. iteminfo.ClabAmt = material_clab_amt
  13650. iteminfo.OthAmt = material_other_amt
  13651. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13652. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13653. }
  13654. if westernMedicineCostTotal != 0 {
  13655. iteminfo.MedChrgitm = "09"
  13656. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13657. iteminfo.Amt = westernMedicineCostTotal
  13658. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13659. iteminfo.ClabAmt = westernMedicine_clab_amt
  13660. iteminfo.OthAmt = westernMedicine_other_amt
  13661. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13662. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13663. }
  13664. if chineseTraditionalMedicineCostTotal != 0 {
  13665. iteminfo.MedChrgitm = "11"
  13666. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13667. iteminfo.Amt = westernMedicineCostTotal
  13668. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13669. iteminfo.ClabAmt = westernMedicine_clab_amt
  13670. iteminfo.OthAmt = westernMedicine_other_amt
  13671. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13673. }
  13674. if otherCostTotal != 0 {
  13675. iteminfo.MedChrgitm = "14"
  13676. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13677. iteminfo.Amt = otherCostTotal
  13678. iteminfo.ClaaSumfee = other_claa_sunmfee
  13679. iteminfo.ClabAmt = other_clab_amt
  13680. iteminfo.OthAmt = other_other_amt
  13681. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13682. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13683. }
  13684. struct4101.IteminfoStruct = iteminfoStructs
  13685. struct4101.Ntly = "中国"
  13686. struct4101.AdmCaty = "A03.06"
  13687. var resOther ResultSeventeenOther
  13688. var res ResultSeventeen
  13689. if miConfig.MdtrtareaAdmvs == "150499" {
  13690. var pp models.PublicParams
  13691. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13692. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13693. pp.FixmedinsName = miConfig.OrgName
  13694. pp.FixmedinsCode = miConfig.Code
  13695. pp.RequestUrl = miConfig.Url
  13696. pp.Cainfo = miConfig.Cainfo
  13697. pp.SecretKey = miConfig.SecretKey
  13698. pp.AccessKey = miConfig.AccessKey
  13699. pp.OpterName = curRoles.UserName
  13700. client := &http.Client{}
  13701. var req *http.Request
  13702. data := make(map[string]interface{})
  13703. data["struct4101"] = struct4101
  13704. data["pp"] = pp
  13705. bytesData, _ := json.Marshal(data)
  13706. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13707. resp, _ := client.Do(req)
  13708. defer resp.Body.Close()
  13709. body, ioErr := ioutil.ReadAll(resp.Body)
  13710. if ioErr != nil {
  13711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13713. return
  13714. }
  13715. var respJSON map[string]interface{}
  13716. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13719. return
  13720. }
  13721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13722. userJSONBytes, _ := json.Marshal(respJSON)
  13723. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13724. utils.ErrorLog("解析失败:%v", err)
  13725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13726. return
  13727. }
  13728. res.InfRefmsgid = resOther.InfRefmsgid
  13729. res.Output = resOther.Output
  13730. res.ErrMsg = resOther.ErrMsg
  13731. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13732. res.Infcode = infocode
  13733. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13734. var pp models.PublicParams
  13735. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13736. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13737. pp.FixmedinsName = miConfig.OrgName
  13738. pp.FixmedinsCode = miConfig.Code
  13739. pp.RequestUrl = miConfig.Url
  13740. pp.Cainfo = miConfig.Cainfo
  13741. pp.SecretKey = miConfig.SecretKey
  13742. pp.AccessKey = miConfig.AccessKey
  13743. pp.OpterName = curRoles.UserName
  13744. result, _ := service.Jxyb4101(struct4101, pp)
  13745. var dat map[string]interface{}
  13746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13747. fmt.Println(dat)
  13748. } else {
  13749. fmt.Println(err)
  13750. }
  13751. userJSONBytes, _ := json.Marshal(dat)
  13752. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13753. utils.ErrorLog("解析失败:%v", err)
  13754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13755. return
  13756. }
  13757. } else {
  13758. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13759. var dat map[string]interface{}
  13760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13761. fmt.Println(dat)
  13762. } else {
  13763. fmt.Println(err)
  13764. }
  13765. userJSONBytes, _ := json.Marshal(dat)
  13766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13767. utils.ErrorLog("解析失败:%v", err)
  13768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13769. return
  13770. }
  13771. }
  13772. if res.Infcode != 0 {
  13773. c.ServeSuccessJSON(map[string]interface{}{
  13774. "failed_code": -10,
  13775. "msg": res.ErrMsg,
  13776. })
  13777. return
  13778. } else {
  13779. if miConfig.MdtrtareaAdmvs != "150499" {
  13780. order.FaPiaoNumber = zero
  13781. order.FaPiaoCode = last_order.FaPiaoCode
  13782. service.UpdateOrder(order)
  13783. }
  13784. hisFundSettleListResult := &models.HisFundSettleListResult{
  13785. Number: res.Output.SetlListId,
  13786. Status: 1,
  13787. Ctime: time.Now().Unix(),
  13788. Mtime: time.Now().Unix(),
  13789. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13790. IsUpload: 1,
  13791. OrderId: order_id,
  13792. }
  13793. service.CreateUploadRecord(hisFundSettleListResult)
  13794. c.ServeSuccessJSON(map[string]interface{}{
  13795. "msg": "上传成功",
  13796. "result": hisFundSettleListResult,
  13797. })
  13798. return
  13799. }
  13800. }
  13801. //func (c *HisApiController) GetBatchSettleList() {
  13802. // orders, _ := service.GetAllHisOrder(10106)
  13803. // for _, item := range orders {
  13804. // order_id := item.ID
  13805. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13806. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13807. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13808. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13809. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13810. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13811. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13812. //
  13813. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13814. //
  13815. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13816. //
  13817. // if order.ID == 0 {
  13818. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13819. // return
  13820. // }
  13821. // if his.BalanceAccountsType == 2 {
  13822. // continue
  13823. // }
  13824. // struct4101 := service.Struct4101{
  13825. // PsnNo: order.PsnNo,
  13826. // MdtrtId: order.MdtrtId,
  13827. // SetlId: order.SetlId,
  13828. // PsnName: order.PsnName,
  13829. // Gend: order.Gend,
  13830. // Brdy: his.Brdy,
  13831. // Age: his.Age,
  13832. // Naty: order.Naty,
  13833. // PatnCertType: "01",
  13834. // Certno: order.Certno,
  13835. // Prfs: "90",
  13836. // ConerName: roles[0].UserName,
  13837. // PatnRlts: "99",
  13838. // ConerAddr: miConfig.OrgName,
  13839. // ConerTel: admin.Mobile,
  13840. // HiType: order.Insutype,
  13841. // Insuplc: his.InsuplcAdmdvs,
  13842. // MaindiagFlag: "1",
  13843. // BillCode: order.SetlId,
  13844. // BillNo: order.SetlId,
  13845. // BizSn: order.Number,
  13846. // PsnSelfPay: order.PsnPartAmt,
  13847. // PsnOwnPay: order.PsnPartAmt,
  13848. // AcctPay: order.AcctPay,
  13849. // PsnCashpay: order.PsnCashPay,
  13850. // HiPaymtd: "1",
  13851. // Hsorg: his.InsuplcAdmdvs,
  13852. // HsorgOpter: his.InsuplcAdmdvs,
  13853. // MedinsFillPsn: curRoles.UserName,
  13854. // MedinsFillDept: depart.Name,
  13855. // IptMedType: "2",
  13856. // }
  13857. // struct4101.SetlBegnDate = order.SetlTime
  13858. // struct4101.SetlEndDate = order.SetlTime
  13859. // //if order.SettleType == 1 {
  13860. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13861. // // dateStr := t.Format("2006-01-02")
  13862. // // struct4101.SetlBegnDate = dateStr
  13863. // // struct4101.SetlEndDate = dateStr
  13864. // //} else {
  13865. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13866. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13867. // // dateStartStr := t.Format("2006-01-02")
  13868. // // dateEndStr := t2.Format("2006-01-02")
  13869. // // struct4101.SetlBegnDate = dateStartStr
  13870. // // struct4101.SetlEndDate = dateEndStr
  13871. // //}
  13872. //
  13873. // var rf []CustomFundPay
  13874. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13875. //
  13876. // var tempFunPays []service.CustomStruct
  13877. // var tempFunPay610100 service.CustomStruct
  13878. //
  13879. // for _, item := range rf {
  13880. // if item.FundPayType == "610100" {
  13881. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13882. // tempFunPay610100.FundPayType = item.FundPayType
  13883. // } else {
  13884. // var tempFunPay service.CustomStruct
  13885. // tempFunPay.FundPayamt = item.FundPayamt
  13886. // tempFunPay.FundPayType = item.FundPayType
  13887. // tempFunPays = append(tempFunPays, tempFunPay)
  13888. // }
  13889. // }
  13890. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13891. // struct4101.CustomStruct = tempFunPays
  13892. //
  13893. // var tempDiaginfos []service.DiaginfoStructTwo
  13894. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13895. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13896. //
  13897. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13898. // var config []*models.HisXtDiagnoseConfig
  13899. // for _, item := range diagnosis_ids {
  13900. // id, _ := strconv.ParseInt(item, 10, 64)
  13901. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13902. // config = append(config, &diagnosisConfig)
  13903. // }
  13904. //
  13905. // for index, item := range config {
  13906. // if index == 0 {
  13907. // var tempDiaginfo service.DiaginfoStructTwo
  13908. // tempDiaginfo.DiagCode = item.CountryCode
  13909. // tempDiaginfo.DiagName = item.CountryContentName
  13910. // tempDiaginfo.DiagType = "1"
  13911. // tempDiaginfo.MaindiagFlag = "1"
  13912. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13913. // } else {
  13914. //
  13915. // var tempDiaginfo service.DiaginfoStructTwo
  13916. // tempDiaginfo.DiagCode = item.CountryCode
  13917. // tempDiaginfo.DiagName = item.CountryContentName
  13918. // tempDiaginfo.DiagType = "2"
  13919. // tempDiaginfo.MaindiagFlag = "0"
  13920. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13921. // }
  13922. // }
  13923. // struct4101.Diseinfo = tempDiaginfos
  13924. //
  13925. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13926. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13927. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13928. // tempOpspdiseinfo2.OprnOprtCode = ""
  13929. // tempOpspdiseinfo2.OprnOprtName = ""
  13930. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13931. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13932. //
  13933. // var iteminfo service.IteminfoStruct
  13934. //
  13935. // var bedCostTotal float64 = 0 //床位总费
  13936. // var bedCostSelfTotal float64 = 0 //床位自费
  13937. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13938. //
  13939. // var examineCostTotal float64 = 0 //诊查总费
  13940. // var examineCostSelfTotal float64 = 0 //诊查自费
  13941. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13942. //
  13943. // var nursingCostTotal float64 = 0 //护理总费
  13944. // var nursingCostSelfTotal float64 = 0 //护理自费
  13945. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13946. //
  13947. // var chineseMedicineCostTotal float64 = 0 //中成药
  13948. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13949. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13950. //
  13951. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13952. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13953. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13954. //
  13955. // var registerCostTotal float64 = 0 //一般诊疗费
  13956. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13957. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13958. //
  13959. // var operationCostTotal float64 = 0 //手术费
  13960. // var operationCostSelfTotal float64 = 0 //手术费
  13961. // var operationCostPartSelfTotal float64 = 0 //手术费
  13962. //
  13963. // var otherCostTotal float64 = 0 //其他费用
  13964. // var otherCostSelfTotal float64 = 0 //其他费用
  13965. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13966. //
  13967. // var materialCostTotal float64 = 0 //材料费
  13968. // var materialCostSelfTotal float64 = 0 //材料费
  13969. // var materialCostPartSelfTotal float64 = 0 //材料费
  13970. //
  13971. // var westernMedicineCostTotal float64 = 0 //西药费
  13972. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13973. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13974. //
  13975. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13976. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13977. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13978. //
  13979. // var checkCostTotal float64 = 0 //检查费
  13980. // var checkCostSelfTotal float64 = 0 //检查费
  13981. // var checkCostPartSelfTotal float64 = 0 //检查费
  13982. //
  13983. // var laboratoryCostTotal float64 = 0 //化验费
  13984. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13985. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13986. //
  13987. // var treatCostTotal float64 = 0 //治疗费用
  13988. // var treatCostSelfTotal float64 = 0 //治疗费用
  13989. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13990. //
  13991. // decimal.DivisionPrecision = 2
  13992. //
  13993. // var bed_fulamt_ownpay_amt float64 = 0
  13994. //
  13995. // var examine_fulamt_ownpay_amt float64 = 0
  13996. //
  13997. // var nursing_fulamt_ownpay_amt float64 = 0
  13998. //
  13999. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14000. //
  14001. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14002. //
  14003. // var register_fulamt_ownpay_amt float64 = 0
  14004. //
  14005. // var operation_fulamt_ownpay_amt float64 = 0
  14006. // var other_fulamt_ownpay_amt float64 = 0
  14007. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14008. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14009. // var check_fulamt_ownpay_amt float64 = 0
  14010. // var material_fulamt_ownpay_amt float64 = 0
  14011. // var laboratory_fulamt_ownpay_amt float64 = 0
  14012. // var treat_fulamt_ownpay_amt float64 = 0
  14013. //
  14014. // var bed_claa_sunmfee float64 = 0
  14015. // var bed_clab_amt float64 = 0
  14016. // var bed_other_amt float64 = 0
  14017. //
  14018. // var examine_claa_sunmfee float64 = 0
  14019. // var examine_clab_amt float64 = 0
  14020. // var examine_other_amt float64 = 0
  14021. //
  14022. // var nursing_claa_sunmfee float64 = 0
  14023. // var nursing_clab_amt float64 = 0
  14024. // var nursing_other_amt float64 = 0
  14025. //
  14026. // var chinese_medicine_claa_sunmfee float64 = 0
  14027. // var chinese_medicine_clab_amt float64 = 0
  14028. // var chinese_medicine_other_amt float64 = 0
  14029. //
  14030. // var commonly_treatment_claa_sunmfee float64 = 0
  14031. // var commonly_treatment_clab_amt float64 = 0
  14032. // var commonly_treatment_other_amt float64 = 0
  14033. //
  14034. // var operation_claa_sunmfee float64 = 0
  14035. // var operation_clab_amt float64 = 0
  14036. // var operation_other_amt float64 = 0
  14037. //
  14038. // var other_claa_sunmfee float64 = 0
  14039. // var other_clab_amt float64 = 0
  14040. // var other_other_amt float64 = 0
  14041. //
  14042. // var westernMedicine_claa_sunmfee float64 = 0
  14043. // var westernMedicine_clab_amt float64 = 0
  14044. // var westernMedicine_other_amt float64 = 0
  14045. //
  14046. // var chineseTraditional_claa_sunmfee float64 = 0
  14047. // var chineseTraditional_clab_amt float64 = 0
  14048. // var chineseTraditional_other_amt float64 = 0
  14049. //
  14050. // var check_claa_sunmfee float64 = 0
  14051. // var check_clab_amt float64 = 0
  14052. // var check_other_amt float64 = 0
  14053. //
  14054. // var material_claa_sunmfee float64 = 0
  14055. // var material_clab_amt float64 = 0
  14056. // var material_other_amt float64 = 0
  14057. //
  14058. // var laboratory_claa_sunmfee float64 = 0
  14059. // var laboratory_clab_amt float64 = 0
  14060. // var laboratory_other_amt float64 = 0
  14061. //
  14062. // var treat_claa_sunmfee float64 = 0
  14063. // var treat_clab_amt float64 = 0
  14064. // var treat_other_amt float64 = 0
  14065. //
  14066. // var register_claa_sunmfee float64 = 0
  14067. // var register_clab_amt float64 = 0
  14068. // var register_other_amt float64 = 0
  14069. //
  14070. // for _, item := range order.HisOrderInfo {
  14071. // if item.MedChrgitmType == "01" { //床位费
  14072. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14073. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14074. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14075. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14076. // if item.ChrgitmLv == "1" {
  14077. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14078. // }
  14079. // if item.ChrgitmLv == "2" {
  14080. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14081. //
  14082. // }
  14083. // if item.ChrgitmLv == "3" {
  14084. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14085. // }
  14086. //
  14087. // }
  14088. //
  14089. // if item.MedChrgitmType == "02" { //诊查
  14090. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14091. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14092. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14093. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14094. // if item.ChrgitmLv == "1" {
  14095. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14096. // }
  14097. // if item.ChrgitmLv == "2" {
  14098. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14099. //
  14100. // }
  14101. // if item.ChrgitmLv == "3" {
  14102. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14103. // }
  14104. //
  14105. // }
  14106. //
  14107. // if item.MedChrgitmType == "03" { //检查费
  14108. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14109. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14110. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14111. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14112. // if item.ChrgitmLv == "1" {
  14113. //
  14114. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14115. //
  14116. // }
  14117. // if item.ChrgitmLv == "2" {
  14118. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14119. //
  14120. // }
  14121. // if item.ChrgitmLv == "3" {
  14122. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14123. // }
  14124. // }
  14125. //
  14126. // if item.MedChrgitmType == "04" { //化验费
  14127. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14128. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14129. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14130. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14131. // if item.ChrgitmLv == "1" {
  14132. //
  14133. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14134. //
  14135. // }
  14136. // if item.ChrgitmLv == "2" {
  14137. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14138. //
  14139. // }
  14140. // if item.ChrgitmLv == "3" {
  14141. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14142. // }
  14143. // }
  14144. //
  14145. // if item.MedChrgitmType == "05" { //治疗费
  14146. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14147. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14148. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14149. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14150. // if item.ChrgitmLv == "1" {
  14151. //
  14152. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14153. //
  14154. // }
  14155. // if item.ChrgitmLv == "2" {
  14156. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14157. //
  14158. // }
  14159. // if item.ChrgitmLv == "3" {
  14160. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14161. // }
  14162. // }
  14163. //
  14164. // if item.MedChrgitmType == "06" { //手术费
  14165. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14166. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14167. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14168. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14169. //
  14170. // if item.ChrgitmLv == "1" {
  14171. //
  14172. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14173. //
  14174. // }
  14175. // if item.ChrgitmLv == "2" {
  14176. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14177. //
  14178. // }
  14179. // if item.ChrgitmLv == "3" {
  14180. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14181. // }
  14182. // }
  14183. //
  14184. // if item.MedChrgitmType == "07" { //手术费
  14185. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14186. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14187. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14188. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14189. //
  14190. // if item.ChrgitmLv == "1" {
  14191. //
  14192. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14193. //
  14194. // }
  14195. // if item.ChrgitmLv == "2" {
  14196. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14197. //
  14198. // }
  14199. // if item.ChrgitmLv == "3" {
  14200. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14201. // }
  14202. // }
  14203. //
  14204. // if item.MedChrgitmType == "08" { //材料费
  14205. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14206. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14207. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14208. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14209. // if item.ChrgitmLv == "1" {
  14210. //
  14211. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14212. //
  14213. // }
  14214. // if item.ChrgitmLv == "2" {
  14215. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14216. //
  14217. // }
  14218. // if item.ChrgitmLv == "3" {
  14219. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14220. // }
  14221. // }
  14222. // if item.MedChrgitmType == "09" { //西药费
  14223. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14224. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14225. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14226. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14227. // if item.ChrgitmLv == "1" {
  14228. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14229. // }
  14230. // if item.ChrgitmLv == "2" {
  14231. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14232. // }
  14233. // if item.ChrgitmLv == "3" {
  14234. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14235. // }
  14236. // }
  14237. // if item.MedChrgitmType == "10" { //中药饮片
  14238. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14239. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14240. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14241. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14242. // if item.ChrgitmLv == "1" {
  14243. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14244. // }
  14245. // if item.ChrgitmLv == "2" {
  14246. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14247. // }
  14248. // if item.ChrgitmLv == "3" {
  14249. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14250. // }
  14251. // }
  14252. //
  14253. // if item.MedChrgitmType == "11" { //中成费
  14254. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14255. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14256. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14257. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14258. // if item.ChrgitmLv == "1" {
  14259. //
  14260. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14261. //
  14262. // }
  14263. // if item.ChrgitmLv == "2" {
  14264. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14265. //
  14266. // }
  14267. // if item.ChrgitmLv == "3" {
  14268. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14269. // }
  14270. // }
  14271. //
  14272. // if item.MedChrgitmType == "12" { //中成费
  14273. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14274. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14275. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14276. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14277. // if item.ChrgitmLv == "1" {
  14278. //
  14279. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14280. //
  14281. // }
  14282. // if item.ChrgitmLv == "2" {
  14283. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14284. //
  14285. // }
  14286. // if item.ChrgitmLv == "3" {
  14287. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14288. // }
  14289. // }
  14290. //
  14291. // if item.MedChrgitmType == "13" { //中成费
  14292. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14293. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14294. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14295. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14296. // if item.ChrgitmLv == "1" {
  14297. //
  14298. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14299. //
  14300. // }
  14301. // if item.ChrgitmLv == "2" {
  14302. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14303. //
  14304. // }
  14305. // if item.ChrgitmLv == "3" {
  14306. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14307. // }
  14308. // }
  14309. //
  14310. // if item.MedChrgitmType == "14" { //其他费
  14311. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14312. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14313. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14314. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14315. // if item.ChrgitmLv == "1" {
  14316. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14317. //
  14318. // }
  14319. // if item.ChrgitmLv == "2" {
  14320. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14321. //
  14322. // }
  14323. // if item.ChrgitmLv == "3" {
  14324. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14325. // }
  14326. // }
  14327. //
  14328. // }
  14329. //
  14330. // var iteminfoStructs []service.IteminfoStruct
  14331. //
  14332. // if bedCostTotal != 0 {
  14333. // iteminfo.MedChrgitm = "01"
  14334. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14335. // iteminfo.Amt = bedCostTotal
  14336. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14337. // iteminfo.ClabAmt = bed_clab_amt
  14338. // iteminfo.OthAmt = bed_other_amt
  14339. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14340. // }
  14341. //
  14342. // if examineCostTotal != 0 {
  14343. // iteminfo.MedChrgitm = "02"
  14344. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14345. // iteminfo.Amt = examineCostTotal
  14346. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14347. // iteminfo.ClabAmt = examine_clab_amt
  14348. // iteminfo.OthAmt = examine_other_amt
  14349. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14350. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14351. // }
  14352. //
  14353. // if checkCostTotal != 0 {
  14354. // iteminfo.MedChrgitm = "03"
  14355. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14356. // iteminfo.Amt = checkCostTotal
  14357. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14358. // iteminfo.ClabAmt = check_clab_amt
  14359. // iteminfo.OthAmt = check_other_amt
  14360. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14361. //
  14362. // }
  14363. //
  14364. // if laboratoryCostTotal != 0 {
  14365. // iteminfo.MedChrgitm = "04"
  14366. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14367. // iteminfo.Amt = laboratoryCostTotal
  14368. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14369. // iteminfo.ClabAmt = laboratory_clab_amt
  14370. // iteminfo.OthAmt = laboratory_other_amt
  14371. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14372. //
  14373. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14374. //
  14375. // }
  14376. //
  14377. // if treatCostTotal != 0 {
  14378. // iteminfo.MedChrgitm = "05"
  14379. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14380. // iteminfo.Amt = treatCostTotal
  14381. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14382. // iteminfo.ClabAmt = treat_clab_amt
  14383. // iteminfo.OthAmt = treat_other_amt
  14384. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14385. // //(struct4101.IteminfoStruct, iteminfo)
  14386. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14387. // }
  14388. //
  14389. // if operationCostTotal != 0 {
  14390. // iteminfo.MedChrgitm = "06"
  14391. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14392. // iteminfo.Amt = operationCostTotal
  14393. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14394. // iteminfo.ClabAmt = operation_clab_amt
  14395. // iteminfo.OthAmt = operation_other_amt
  14396. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14397. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14398. // }
  14399. //
  14400. // if nursingCostTotal != 0 {
  14401. // iteminfo.MedChrgitm = "07"
  14402. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14403. // iteminfo.Amt = nursingCostTotal
  14404. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14405. // iteminfo.ClabAmt = nursing_clab_amt
  14406. // iteminfo.OthAmt = nursing_other_amt
  14407. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14408. // }
  14409. //
  14410. // if materialCostTotal != 0 {
  14411. // iteminfo.MedChrgitm = "08"
  14412. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14413. // iteminfo.Amt = materialCostTotal
  14414. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14415. // iteminfo.ClabAmt = material_clab_amt
  14416. // iteminfo.OthAmt = material_other_amt
  14417. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14418. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14419. // }
  14420. //
  14421. // if westernMedicineCostTotal != 0 {
  14422. // iteminfo.MedChrgitm = "09"
  14423. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14424. // iteminfo.Amt = westernMedicineCostTotal
  14425. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14426. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14427. // iteminfo.OthAmt = westernMedicine_other_amt
  14428. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14429. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14430. //
  14431. // }
  14432. //
  14433. // if chineseMedicineCostTotal != 0 {
  14434. // iteminfo.MedChrgitm = "10"
  14435. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14436. // iteminfo.Amt = chineseMedicineCostTotal
  14437. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14438. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14439. // iteminfo.OthAmt = chinese_medicine_other_amt
  14440. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14441. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14442. //
  14443. // }
  14444. //
  14445. // if chineseTraditionalMedicineCostTotal != 0 {
  14446. // iteminfo.MedChrgitm = "11"
  14447. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14448. // iteminfo.Amt = westernMedicineCostTotal
  14449. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14450. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14451. // iteminfo.OthAmt = westernMedicine_other_amt
  14452. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14453. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14454. //
  14455. // }
  14456. //
  14457. // if commonlyTreatmentCostTotal != 0 {
  14458. // iteminfo.MedChrgitm = "12"
  14459. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14460. // iteminfo.Amt = commonlyTreatmentCostTotal
  14461. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14462. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14463. // iteminfo.OthAmt = commonly_treatment_other_amt
  14464. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14465. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14466. //
  14467. // }
  14468. //
  14469. // if registerCostTotal != 0 {
  14470. // iteminfo.MedChrgitm = "13"
  14471. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14472. // iteminfo.Amt = registerCostTotal
  14473. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14474. // iteminfo.ClabAmt = register_clab_amt
  14475. // iteminfo.OthAmt = register_other_amt
  14476. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14477. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14478. //
  14479. // }
  14480. //
  14481. // if otherCostTotal != 0 {
  14482. // iteminfo.MedChrgitm = "14"
  14483. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14484. // iteminfo.Amt = otherCostTotal
  14485. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14486. // iteminfo.ClabAmt = other_clab_amt
  14487. // iteminfo.OthAmt = other_other_amt
  14488. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14489. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14490. //
  14491. // }
  14492. // struct4101.IteminfoStruct = iteminfoStructs
  14493. // time_arr := strings.Split(order.SetlTime, " ")
  14494. // struct4101.AdmTime = time_arr[0]
  14495. // struct4101.AdmEndTime = time_arr[0]
  14496. //
  14497. // struct4101.DoctorName = doctor.UserName
  14498. // struct4101.DoctorCode = doctor.DoctorNumber
  14499. //
  14500. // struct4101.Ntly = "中国"
  14501. // struct4101.AdmCaty = "A03.06"
  14502. // var res ResultSeventeen
  14503. // if miConfig.MdtrtareaAdmvs == "421300" {
  14504. // data := make(map[string]interface{})
  14505. // data["struct4101"] = struct4101
  14506. // data["secret_key"] = miConfig.SecretKey
  14507. // data["org_name"] = miConfig.OrgName
  14508. // data["opera"] = curRoles.UserName
  14509. // data["code"] = miConfig.Code
  14510. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14511. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14512. //
  14513. // client := &http.Client{}
  14514. // bytesData, _ := json.Marshal(data)
  14515. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14516. // resp, _ := client.Do(req)
  14517. // defer resp.Body.Close()
  14518. // body, ioErr := ioutil.ReadAll(resp.Body)
  14519. // if ioErr != nil {
  14520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14522. // return
  14523. // }
  14524. // var respJSON map[string]interface{}
  14525. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14526. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14528. // return
  14529. // }
  14530. //
  14531. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14532. // userJSONBytes, _ := json.Marshal(respJSON)
  14533. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14534. // utils.ErrorLog("解析失败:%v", err)
  14535. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14536. // adminUser := c.GetAdminUserInfo()
  14537. // errlog := &models.HisOrderError{
  14538. // UserOrgId: adminUser.CurrentOrgId,
  14539. // Ctime: time.Now().Unix(),
  14540. // Mtime: time.Now().Unix(),
  14541. // ErrMsg: res.ErrMsg + "解析失败",
  14542. // Status: 1,
  14543. // PatientId: order_id,
  14544. // Stage: 10088,
  14545. // }
  14546. // service.CreateErrMsgLog(errlog)
  14547. // continue
  14548. // }
  14549. //
  14550. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14551. // data := make(map[string]interface{})
  14552. // data["struct4101"] = struct4101
  14553. // data["secret_key"] = miConfig.SecretKey
  14554. // data["org_name"] = miConfig.OrgName
  14555. // data["opera"] = curRoles.UserName
  14556. // data["code"] = miConfig.Code
  14557. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14558. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14559. //
  14560. // client := &http.Client{}
  14561. // bytesData, _ := json.Marshal(data)
  14562. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14563. // resp, _ := client.Do(req)
  14564. // defer resp.Body.Close()
  14565. // body, ioErr := ioutil.ReadAll(resp.Body)
  14566. // if ioErr != nil {
  14567. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14568. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14569. // return
  14570. // }
  14571. // var respJSON map[string]interface{}
  14572. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14573. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14574. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14575. // return
  14576. // }
  14577. //
  14578. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14579. // userJSONBytes, _ := json.Marshal(respJSON)
  14580. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14581. // utils.ErrorLog("解析失败:%v", err)
  14582. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14583. // adminUser := c.GetAdminUserInfo()
  14584. // errlog := &models.HisOrderError{
  14585. // UserOrgId: adminUser.CurrentOrgId,
  14586. // Ctime: time.Now().Unix(),
  14587. // Mtime: time.Now().Unix(),
  14588. // ErrMsg: res.ErrMsg + "解析失败",
  14589. // Status: 1,
  14590. // PatientId: order_id,
  14591. // Stage: 10088,
  14592. // }
  14593. // service.CreateErrMsgLog(errlog)
  14594. // continue
  14595. // }
  14596. //
  14597. // } else {
  14598. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14599. // fmt.Println(result)
  14600. //
  14601. // var dat map[string]interface{}
  14602. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14603. // fmt.Println(dat)
  14604. // } else {
  14605. // fmt.Println(err)
  14606. // }
  14607. // userJSONBytes, _ := json.Marshal(dat)
  14608. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14609. // utils.ErrorLog("解析失败:%v", err)
  14610. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14611. // adminUser := c.GetAdminUserInfo()
  14612. // errlog := &models.HisOrderError{
  14613. // UserOrgId: adminUser.CurrentOrgId,
  14614. // Ctime: time.Now().Unix(),
  14615. // Mtime: time.Now().Unix(),
  14616. // ErrMsg: res.ErrMsg + "解析失败",
  14617. // Status: 1,
  14618. // PatientId: order_id,
  14619. // Stage: 10106,
  14620. // }
  14621. // service.CreateErrMsgLog(errlog)
  14622. // continue
  14623. // }
  14624. // }
  14625. //
  14626. // if res.Infcode != 0 {
  14627. // adminUser := c.GetAdminUserInfo()
  14628. // errlog := &models.HisOrderError{
  14629. // UserOrgId: adminUser.CurrentOrgId,
  14630. // Ctime: time.Now().Unix(),
  14631. // Mtime: time.Now().Unix(),
  14632. // ErrMsg: res.ErrMsg,
  14633. // Status: 1,
  14634. // PatientId: order_id,
  14635. // Stage: 10106,
  14636. // }
  14637. // service.CreateErrMsgLog(errlog)
  14638. // continue
  14639. // } else {
  14640. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14641. // Number: res.Output.SetlListId,
  14642. // Status: 1,
  14643. // Ctime: time.Now().Unix(),
  14644. // Mtime: time.Now().Unix(),
  14645. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14646. // IsUpload: 1,
  14647. // OrderId: order_id,
  14648. // }
  14649. // service.CreateUploadRecord(hisFundSettleListResult)
  14650. // continue
  14651. // }
  14652. // }
  14653. //}
  14654. func (c *HisApiController) GetOrgInfo() {
  14655. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14656. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14657. }
  14658. func (c *HisApiController) GetHisPatientInfo() {
  14659. medical_insurance_card := c.GetString("medical_insurance_card")
  14660. id_card_type, _ := c.GetInt64("id_card_type")
  14661. id_card := c.GetString("id_card")
  14662. adminInfo := c.GetAdminUserInfo()
  14663. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14664. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14665. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14666. IdCardNo := ""
  14667. if id_card_type == 1 {
  14668. IdCardNo = medical_insurance_card
  14669. } else if id_card_type == 2 {
  14670. IdCardNo = id_card
  14671. }
  14672. if config.IsOpen == 1 {
  14673. 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
  14674. resp, requestErr := http.Get(api)
  14675. if requestErr != nil {
  14676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14677. return
  14678. }
  14679. defer resp.Body.Close()
  14680. body, ioErr := ioutil.ReadAll(resp.Body)
  14681. if ioErr != nil {
  14682. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14684. return
  14685. }
  14686. var respJSON map[string]interface{}
  14687. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14690. return
  14691. }
  14692. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14693. userJSONBytes, _ := json.Marshal(userJSON)
  14694. var res ResultTwo
  14695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14696. utils.ErrorLog("解析失败:%v", err)
  14697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14698. return
  14699. }
  14700. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14701. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14702. infoStr := string(Iinfos)
  14703. idetinfoStr := string(Idetinfos)
  14704. if res.Infcode == 0 {
  14705. his := models.VMHisPatient{
  14706. Status: 1,
  14707. Ctime: time.Now().Unix(),
  14708. Mtime: time.Now().Unix(),
  14709. PsnNo: res.Output.Baseinfo.PsnNo,
  14710. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14711. Certno: res.Output.Baseinfo.Certno,
  14712. PsnName: res.Output.Baseinfo.PsnName,
  14713. Gend: res.Output.Baseinfo.Gend,
  14714. Naty: res.Output.Baseinfo.Naty,
  14715. Iinfo: infoStr,
  14716. Idetinfo: idetinfoStr,
  14717. UserOrgId: adminInfo.CurrentOrgId,
  14718. IsReturn: 1,
  14719. IdCardType: id_card_type,
  14720. }
  14721. c.ServeSuccessJSON(map[string]interface{}{
  14722. "info": his,
  14723. })
  14724. } else {
  14725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14726. return
  14727. }
  14728. }
  14729. }
  14730. //func GetBasBaseInfo() (jsonStr string, err error) {
  14731. //
  14732. // handle := syscall.NewLazyDLL("SSCard.dll")
  14733. // add := handle.NewProc("ReadCardBas")
  14734. // str := make([]byte, 1024)
  14735. // str1 := make([]byte, 1024)
  14736. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14737. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14738. //
  14739. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14740. //
  14741. // fmt.Println("> Add(4,5)的结果为:", ret)
  14742. // handle.Release()
  14743. //
  14744. // return "", nil
  14745. //
  14746. //}
  14747. //func GetQRBaseInfo() (jsonStr string, err error) {
  14748. // handle := syscall.LoadDLL("SSCard.dll")
  14749. // ReadCardBas := handle.FindProc("GetQRBase")
  14750. //
  14751. // str := make([]byte, 256)
  14752. // str1 := make([]byte, 256)
  14753. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14754. //
  14755. // fmt.Println(string(str))
  14756. // fmt.Println(r)
  14757. // return string(str), nil
  14758. //}
  14759. //func CardInit() int {
  14760. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14761. // add := DllTestDef.MustFindProc("Init")
  14762. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14763. // if err != nil {
  14764. // fmt.Println("SSCard的运算结果为:", ret)
  14765. // }
  14766. // result := int(ret)
  14767. // return result
  14768. //}
  14769. //func CardInit() int {
  14770. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14771. // if err != nil {
  14772. // fmt.Println("SSCard的运算结果为:", ret)
  14773. // }
  14774. // fmt.Println(err)
  14775. // result := int(ret)
  14776. // return result
  14777. //}
  14778. func IntPtr(n int) uintptr {
  14779. return uintptr(n)
  14780. }
  14781. func StrPtr(s string) uintptr {
  14782. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14783. }
  14784. type Result2001 struct {
  14785. Cainfo interface{} `json:"cainfo"`
  14786. ErrMsg string `json:"err_msg"`
  14787. InfRefmsgid string `json:"inf_refmsgid"`
  14788. Infcode int64 `json:"infcode"`
  14789. Output struct {
  14790. Trtinfo struct {
  14791. PsnNo string `json:"psn_no"`
  14792. TrtChkType string `json:"trt_chk_type"`
  14793. FundPayType string `json:"fund_pay_type"`
  14794. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14795. Begndate string `json:"begndate"`
  14796. Enddate string `json:"enddate"`
  14797. TrtChkRslt string `json:"trt_chk_rslt"`
  14798. } `json:"trtinfo"`
  14799. } `json:"output"`
  14800. RefmsgTime string `json:"refmsg_time"`
  14801. RespondTime string `json:"respond_time"`
  14802. Signtype interface{} `json:"signtype"`
  14803. WarnMsg interface{} `json:"warn_msg"`
  14804. }
  14805. type Result2001Org10265 struct {
  14806. Cainfo interface{} `json:"cainfo"`
  14807. ErrMsg string `json:"err_msg"`
  14808. InfRefmsgid string `json:"inf_refmsgid"`
  14809. Infcode string `json:"infcode"`
  14810. Output struct {
  14811. Trtinfo struct {
  14812. PsnNo string `json:"psn_no"`
  14813. TrtChkType string `json:"trt_chk_type"`
  14814. FundPayType string `json:"fund_pay_type"`
  14815. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14816. Begndate string `json:"begndate"`
  14817. Enddate string `json:"enddate"`
  14818. TrtChkRslt string `json:"trt_chk_rslt"`
  14819. } `json:"trtinfo"`
  14820. } `json:"output"`
  14821. RefmsgTime string `json:"refmsg_time"`
  14822. RespondTime string `json:"respond_time"`
  14823. Signtype interface{} `json:"signtype"`
  14824. WarnMsg interface{} `json:"warn_msg"`
  14825. }
  14826. type ResultTwo struct {
  14827. ErrMsg string `json:"err_msg"`
  14828. InfRefmsgid string `json:"inf_refmsgid"`
  14829. Infcode int64 `json:"infcode"`
  14830. Output struct {
  14831. Baseinfo struct {
  14832. //Brdy string `json:"brdy"`
  14833. Certno string `json:"certno"`
  14834. Gend string `json:"gend"`
  14835. Naty string `json:"naty"`
  14836. PsnCertType string `json:"psn_cert_type"`
  14837. PsnName string `json:"psn_name"`
  14838. PsnNo string `json:"psn_no"`
  14839. } `json:"baseinfo"`
  14840. Idetinfo []interface{} `json:"idetinfo"`
  14841. Iinfo []struct {
  14842. Balc float64 `json:"balc"`
  14843. CvlservFlag string `json:"cvlserv_flag"`
  14844. EmpName string `json:"emp_name"`
  14845. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14846. Insutype string `json:"insutype"`
  14847. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14848. //PausInsuDate string `json:"paus_insu_date"`
  14849. //PsnInsuDate string `json:"psn_insu_date"`
  14850. PsnInsuStas string `json:"psn_insu_stas"`
  14851. PsnType string `json:"psn_type"`
  14852. } `json:"insuinfo"`
  14853. } `json:"output"`
  14854. RefmsgTime string `json:"refmsg_time"`
  14855. RespondTime string `json:"respond_time"`
  14856. Signtype interface{} `json:"signtype"`
  14857. WarnInfo interface{} `json:"warn_info"`
  14858. }
  14859. type ResultTwo10265 struct {
  14860. ErrMsg string `json:"err_msg"`
  14861. InfRefmsgid string `json:"inf_refmsgid"`
  14862. Infcode string `json:"infcode"`
  14863. Output struct {
  14864. Baseinfo struct {
  14865. //Brdy string `json:"brdy"`
  14866. Certno string `json:"certno"`
  14867. Gend string `json:"gend"`
  14868. Naty string `json:"naty"`
  14869. PsnCertType string `json:"psn_cert_type"`
  14870. PsnName string `json:"psn_name"`
  14871. PsnNo string `json:"psn_no"`
  14872. } `json:"baseinfo"`
  14873. Idetinfo []interface{} `json:"idetinfo"`
  14874. Iinfo []struct {
  14875. Balc float64 `json:"balc"`
  14876. CvlservFlag string `json:"cvlserv_flag"`
  14877. EmpName string `json:"emp_name"`
  14878. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14879. Insutype string `json:"insutype"`
  14880. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14881. PsnInsuStas string `json:"psn_insu_stas"`
  14882. PsnType string `json:"psn_type"`
  14883. } `json:"insuinfo"`
  14884. } `json:"output"`
  14885. RefmsgTime string `json:"refmsg_time"`
  14886. RespondTime string `json:"respond_time"`
  14887. Signtype interface{} `json:"signtype"`
  14888. WarnInfo interface{} `json:"warn_info"`
  14889. }
  14890. type ResultThree struct {
  14891. Cainfo interface{} `json:"cainfo"`
  14892. ErrMsg string `json:"err_msg"`
  14893. InfRefmsgid string `json:"inf_refmsgid"`
  14894. Infcode int64 `json:"infcode"`
  14895. Output struct {
  14896. Data struct {
  14897. IptOtpNo string `json:"ipt_otp_no"`
  14898. MdtrtID string `json:"mdtrt_id"`
  14899. PsnNo string `json:"psn_no"`
  14900. } `json:"data"`
  14901. } `json:"output"`
  14902. RefmsgTime string `json:"refmsg_time"`
  14903. RespondTime string `json:"respond_time"`
  14904. Signtype interface{} `json:"signtype"`
  14905. WarnMsg interface{} `json:"warn_msg"`
  14906. }
  14907. type ResultThree10265 struct {
  14908. Cainfo interface{} `json:"cainfo"`
  14909. ErrMsg string `json:"err_msg"`
  14910. InfRefmsgid string `json:"inf_refmsgid"`
  14911. Infcode string `json:"infcode"`
  14912. Output struct {
  14913. Data struct {
  14914. IptOtpNo string `json:"ipt_otp_no"`
  14915. MdtrtID string `json:"mdtrt_id"`
  14916. PsnNo string `json:"psn_no"`
  14917. } `json:"data"`
  14918. } `json:"output"`
  14919. RefmsgTime string `json:"refmsg_time"`
  14920. RespondTime string `json:"respond_time"`
  14921. Signtype interface{} `json:"signtype"`
  14922. WarnMsg interface{} `json:"warn_msg"`
  14923. }
  14924. type ResultFour struct {
  14925. Cainfo string `json:"cainfo"`
  14926. ErrMsg string `json:"err_msg"`
  14927. InfRefmsgid string `json:"inf_refmsgid"`
  14928. Infcode int64 `json:"infcode"`
  14929. Output struct {
  14930. Result []struct {
  14931. BasMednFlag string `json:"bas_medn_flag"`
  14932. ChldMedcFlag string `json:"chld_medc_flag"`
  14933. ChrgitmLv string `json:"chrgitm_lv"`
  14934. Cnt float64 `json:"cnt"`
  14935. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14936. DrtReimFlag string `json:"drt_reim_flag"`
  14937. FeedetlSn string `json:"feedetl_sn"`
  14938. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14939. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14940. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14941. ListSpItemFlag string `json:"list_sp_item_flag"`
  14942. LmtUsedFlag string `json:"lmt_used_flag"`
  14943. MedChrgitmType string `json:"med_chrgitm_type"`
  14944. Memo string `json:"memo"`
  14945. OverlmtAmt float64 `json:"overlmt_amt"`
  14946. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14947. Pric float64 `json:"pric"`
  14948. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14949. SelfpayProp float64 `json:"selfpay_prop"`
  14950. } `json:"result"`
  14951. } `json:"output"`
  14952. RefmsgTime string `json:"refmsg_time"`
  14953. RespondTime string `json:"respond_time"`
  14954. Signtype string `json:"signtype"`
  14955. WarnMsg string `json:"warn_msg"`
  14956. }
  14957. type ResultFour10265 struct {
  14958. Cainfo string `json:"cainfo"`
  14959. ErrMsg string `json:"err_msg"`
  14960. InfRefmsgid string `json:"inf_refmsgid"`
  14961. Infcode string `json:"infcode"`
  14962. Output struct {
  14963. Result []struct {
  14964. BasMednFlag string `json:"bas_medn_flag"`
  14965. ChldMedcFlag string `json:"chld_medc_flag"`
  14966. ChrgitmLv string `json:"chrgitm_lv"`
  14967. Cnt float64 `json:"cnt"`
  14968. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14969. DrtReimFlag string `json:"drt_reim_flag"`
  14970. FeedetlSn string `json:"feedetl_sn"`
  14971. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14972. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14973. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14974. ListSpItemFlag string `json:"list_sp_item_flag"`
  14975. LmtUsedFlag string `json:"lmt_used_flag"`
  14976. MedChrgitmType string `json:"med_chrgitm_type"`
  14977. Memo string `json:"memo"`
  14978. OverlmtAmt float64 `json:"overlmt_amt"`
  14979. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14980. Pric float64 `json:"pric"`
  14981. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14982. SelfpayProp float64 `json:"selfpay_prop"`
  14983. } `json:"result"`
  14984. } `json:"output"`
  14985. RefmsgTime string `json:"refmsg_time"`
  14986. RespondTime string `json:"respond_time"`
  14987. Signtype string `json:"signtype"`
  14988. WarnMsg string `json:"warn_msg"`
  14989. }
  14990. type ResultMemo struct {
  14991. InsuAdmdvs string `json:"insuAdmdvs"`
  14992. }
  14993. // [{"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}]
  14994. type ResultIDInfo struct {
  14995. Begntime string `json:"begntime"`
  14996. Endtime string `json:"endtime"`
  14997. Memo string `json:"memo"`
  14998. }
  14999. type ResultFive struct {
  15000. Balc float64 `json:"balc"`
  15001. CvlservFlag string `json:"cvlserv_flag"`
  15002. EmpName string `json:"emp_name"`
  15003. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15004. Insutype string `json:"insutype"`
  15005. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15006. PausInsuDate string `json:"paus_insu_date"`
  15007. PsnInsuDate string `json:"psn_insu_date"`
  15008. PsnInsuStas string `json:"psn_insu_stas"`
  15009. PsnType string `json:"psn_type"`
  15010. }
  15011. type ResultSix struct {
  15012. Cainfo interface{} `json:"cainfo"`
  15013. ErrMsg string `json:"err_msg"`
  15014. InfRefmsgid string `json:"inf_refmsgid"`
  15015. Infcode int64 `json:"infcode"`
  15016. Output struct {
  15017. } `json:"output"`
  15018. RefmsgTime string `json:"refmsg_time"`
  15019. RespondTime string `json:"respond_time"`
  15020. Signtype interface{} `json:"signtype"`
  15021. WarnMsg interface{} `json:"warn_msg"`
  15022. }
  15023. type Result2406 struct {
  15024. Cainfo interface{} `json:"cainfo"`
  15025. ErrMsg string `json:"err_msg"`
  15026. InfRefmsgid string `json:"inf_refmsgid"`
  15027. Infcode int64 `json:"infcode"`
  15028. Output struct {
  15029. Result struct {
  15030. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15031. } `json:"result"`
  15032. } `json:"output"`
  15033. RefmsgTime string `json:"refmsg_time"`
  15034. RespondTime string `json:"respond_time"`
  15035. Signtype interface{} `json:"signtype"`
  15036. WarnMsg interface{} `json:"warn_msg"`
  15037. }
  15038. type GZResultSix struct {
  15039. Cainfo interface{} `json:"cainfo"`
  15040. ErrMsg string `json:"err_msg"`
  15041. InfRefmsgid string `json:"inf_refmsgid"`
  15042. Infcode int64 `json:"infcode"`
  15043. Output string `json:"output"`
  15044. RefmsgTime string `json:"refmsg_time"`
  15045. RespondTime string `json:"respond_time"`
  15046. Signtype interface{} `json:"signtype"`
  15047. WarnMsg interface{} `json:"warn_msg"`
  15048. }
  15049. type ResultSix10265 struct {
  15050. Cainfo interface{} `json:"cainfo"`
  15051. ErrMsg string `json:"err_msg"`
  15052. InfRefmsgid string `json:"inf_refmsgid"`
  15053. Infcode string `json:"infcode"`
  15054. Output struct {
  15055. } `json:"output"`
  15056. RefmsgTime string `json:"refmsg_time"`
  15057. RespondTime string `json:"respond_time"`
  15058. Signtype interface{} `json:"signtype"`
  15059. WarnMsg interface{} `json:"warn_msg"`
  15060. }
  15061. type ResultSeven struct {
  15062. Cainfo string `json:"cainfo"`
  15063. ErrMsg string `json:"err_msg"`
  15064. InfRefmsgid string `json:"inf_refmsgid"`
  15065. Infcode int64 `json:"infcode"`
  15066. Output struct {
  15067. Setlinfo struct {
  15068. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15069. AcctPay float64 `json:"acct_pay"`
  15070. ActPayDedc float64 `json:"act_pay_dedc"`
  15071. Age float64 `json:"age"`
  15072. Balc float64 `json:"balc"`
  15073. Certno string `json:"certno"`
  15074. ClrOptins string `json:"clr_optins"`
  15075. ClrType string `json:"clr_type"`
  15076. ClrWay string `json:"clr_way"`
  15077. CvlservFlag string `json:"cvlserv_flag"`
  15078. CvlservPay float64 `json:"cvlserv_pay"`
  15079. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15080. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15081. Gend string `json:"gend"`
  15082. HifesPay float64 `json:"hifes_pay"`
  15083. HifmiPay float64 `json:"hifmi_pay"`
  15084. HifpPay float64 `json:"hifp_pay"`
  15085. HospPartAmt float64 `json:"hosp_part_amt"`
  15086. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15087. Insutype string `json:"insutype"`
  15088. MafPay float64 `json:"maf_pay"`
  15089. MdtrtCertType string `json:"mdtrt_cert_type"`
  15090. HifobPay float64 `json:"hifob_pay"`
  15091. MdtrtID string `json:"mdtrt_id"`
  15092. MedType string `json:"med_type"`
  15093. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15094. MedinsSetlID string `json:"medins_setl_id"`
  15095. Naty string `json:"naty"`
  15096. OthPay float64 `json:"oth_pay"`
  15097. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15098. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15099. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15100. PsnCashPay float64 `json:"psn_cash_pay"`
  15101. PsnCertType string `json:"psn_cert_type"`
  15102. PsnName string `json:"psn_name"`
  15103. PsnNo string `json:"psn_no"`
  15104. PsnPartAmt float64 `json:"psn_part_amt"`
  15105. PsnType string `json:"psn_type"`
  15106. SetlID string `json:"setl_id"`
  15107. SetlTime string `json:"setl_time"`
  15108. } `json:"setlinfo"`
  15109. Setldetail interface{} `json:"setldetail"`
  15110. } `json:"output"`
  15111. RefmsgTime string `json:"refmsg_time"`
  15112. RespondTime string `json:"respond_time"`
  15113. Signtype interface{} `json:"signtype"`
  15114. WarnMsg interface{} `json:"warn_msg"`
  15115. }
  15116. type ResultSevenAH struct {
  15117. Cainfo string `json:"cainfo"`
  15118. ErrMsg string `json:"err_msg"`
  15119. InfRefmsgid string `json:"inf_refmsgid"`
  15120. Infcode int64 `json:"infcode"`
  15121. Output struct {
  15122. Setlinfo struct {
  15123. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15124. AcctPay float64 `json:"acct_pay"`
  15125. ActPayDedc float64 `json:"act_pay_dedc"`
  15126. Age float64 `json:"age"`
  15127. Balc float64 `json:"balc"`
  15128. Certno string `json:"certno"`
  15129. ClrOptins string `json:"clr_optins"`
  15130. ClrType string `json:"clr_type"`
  15131. ClrWay string `json:"clr_way"`
  15132. CvlservFlag string `json:"cvlserv_flag"`
  15133. CvlservPay float64 `json:"cvlserv_pay"`
  15134. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15135. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15136. Gend string `json:"gend"`
  15137. HifesPay float64 `json:"hifes_pay"`
  15138. HifmiPay float64 `json:"hifmi_pay"`
  15139. HifpPay float64 `json:"hifp_pay"`
  15140. HospPartAmt float64 `json:"hosp_part_amt"`
  15141. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15142. Insutype string `json:"insutype"`
  15143. MafPay float64 `json:"maf_pay"`
  15144. MdtrtCertType string `json:"mdtrt_cert_type"`
  15145. HifobPay float64 `json:"hifob_pay"`
  15146. MdtrtID string `json:"mdtrt_id"`
  15147. MedType string `json:"med_type"`
  15148. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15149. MedinsSetlID string `json:"medins_setl_id"`
  15150. Naty string `json:"naty"`
  15151. OthPay float64 `json:"oth_pay"`
  15152. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15153. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15154. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15155. PsnCashPay float64 `json:"psn_cash_pay"`
  15156. PsnCertType string `json:"psn_cert_type"`
  15157. PsnName string `json:"psn_name"`
  15158. PsnNo string `json:"psn_no"`
  15159. PsnPartAmt float64 `json:"psn_part_amt"`
  15160. PsnType string `json:"psn_type"`
  15161. SetlID string `json:"setl_id"`
  15162. SetlTime int64 `json:"setl_time"`
  15163. } `json:"setlinfo"`
  15164. Setldetail interface{} `json:"setldetail"`
  15165. } `json:"output"`
  15166. RefmsgTime string `json:"refmsg_time"`
  15167. RespondTime string `json:"respond_time"`
  15168. Signtype interface{} `json:"signtype"`
  15169. WarnMsg interface{} `json:"warn_msg"`
  15170. }
  15171. type ResultSeven10265 struct {
  15172. Cainfo string `json:"cainfo"`
  15173. ErrMsg string `json:"err_msg"`
  15174. InfRefmsgid string `json:"inf_refmsgid"`
  15175. Infcode string `json:"infcode"`
  15176. Output struct {
  15177. Setlinfo struct {
  15178. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15179. AcctPay float64 `json:"acct_pay"`
  15180. ActPayDedc float64 `json:"act_pay_dedc"`
  15181. Age float64 `json:"age"`
  15182. Balc float64 `json:"balc"`
  15183. Certno string `json:"certno"`
  15184. ClrOptins string `json:"clr_optins"`
  15185. ClrType string `json:"clr_type"`
  15186. ClrWay string `json:"clr_way"`
  15187. CvlservFlag string `json:"cvlserv_flag"`
  15188. CvlservPay float64 `json:"cvlserv_pay"`
  15189. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15190. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15191. Gend string `json:"gend"`
  15192. HifesPay float64 `json:"hifes_pay"`
  15193. HifmiPay float64 `json:"hifmi_pay"`
  15194. HifpPay float64 `json:"hifp_pay"`
  15195. HospPartAmt float64 `json:"hosp_part_amt"`
  15196. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15197. Insutype string `json:"insutype"`
  15198. MafPay float64 `json:"maf_pay"`
  15199. MdtrtCertType string `json:"mdtrt_cert_type"`
  15200. HifobPay float64 `json:"hifob_pay"`
  15201. MdtrtID string `json:"mdtrt_id"`
  15202. MedType string `json:"med_type"`
  15203. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15204. MedinsSetlID string `json:"medins_setl_id"`
  15205. Naty string `json:"naty"`
  15206. OthPay float64 `json:"oth_pay"`
  15207. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15208. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15209. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15210. PsnCashPay float64 `json:"psn_cash_pay"`
  15211. PsnCertType string `json:"psn_cert_type"`
  15212. PsnName string `json:"psn_name"`
  15213. PsnNo string `json:"psn_no"`
  15214. PsnPartAmt float64 `json:"psn_part_amt"`
  15215. PsnType string `json:"psn_type"`
  15216. SetlID string `json:"setl_id"`
  15217. SetlTime string `json:"setl_time"`
  15218. } `json:"setlinfo"`
  15219. Setldetail interface{} `json:"setldetail"`
  15220. } `json:"output"`
  15221. RefmsgTime string `json:"refmsg_time"`
  15222. RespondTime string `json:"respond_time"`
  15223. Signtype interface{} `json:"signtype"`
  15224. WarnMsg interface{} `json:"warn_msg"`
  15225. }
  15226. type ResultSeven10265Two struct {
  15227. Cainfo string `json:"cainfo"`
  15228. ErrMsg string `json:"err_msg"`
  15229. InfRefmsgid string `json:"inf_refmsgid"`
  15230. Infcode string `json:"infcode"`
  15231. Output struct {
  15232. Setlinfo struct {
  15233. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15234. AcctPay float64 `json:"acct_pay"`
  15235. ActPayDedc float64 `json:"act_pay_dedc"`
  15236. Age float64 `json:"age"`
  15237. Balc float64 `json:"balc"`
  15238. Certno string `json:"certno"`
  15239. ClrOptins string `json:"clr_optins"`
  15240. ClrType string `json:"clr_type"`
  15241. ClrWay string `json:"clr_way"`
  15242. CvlservFlag string `json:"cvlserv_flag"`
  15243. CvlservPay float64 `json:"cvlserv_pay"`
  15244. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15245. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15246. Gend string `json:"gend"`
  15247. HifesPay float64 `json:"hifes_pay"`
  15248. HifmiPay float64 `json:"hifmi_pay"`
  15249. HifpPay float64 `json:"hifp_pay"`
  15250. HospPartAmt string `json:"hosp_part_amt"`
  15251. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15252. Insutype string `json:"insutype"`
  15253. MafPay float64 `json:"maf_pay"`
  15254. MdtrtCertType string `json:"mdtrt_cert_type"`
  15255. HifobPay float64 `json:"hifob_pay"`
  15256. MdtrtID string `json:"mdtrt_id"`
  15257. MedType string `json:"med_type"`
  15258. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15259. MedinsSetlID string `json:"medins_setl_id"`
  15260. Naty string `json:"naty"`
  15261. OthPay float64 `json:"oth_pay"`
  15262. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15263. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15264. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15265. PsnCashPay float64 `json:"psn_cash_pay"`
  15266. PsnCertType string `json:"psn_cert_type"`
  15267. PsnName string `json:"psn_name"`
  15268. PsnNo string `json:"psn_no"`
  15269. PsnPartAmt float64 `json:"psn_part_amt"`
  15270. PsnType string `json:"psn_type"`
  15271. SetlID string `json:"setl_id"`
  15272. SetlTime string `json:"setl_time"`
  15273. } `json:"setlinfo"`
  15274. Setldetail interface{} `json:"setldetail"`
  15275. } `json:"output"`
  15276. RefmsgTime string `json:"refmsg_time"`
  15277. RespondTime string `json:"respond_time"`
  15278. Signtype interface{} `json:"signtype"`
  15279. WarnMsg interface{} `json:"warn_msg"`
  15280. }
  15281. type GZResultSeven10265Two struct {
  15282. Cainfo string `json:"cainfo"`
  15283. ErrMsg string `json:"err_msg"`
  15284. InfRefmsgid string `json:"inf_refmsgid"`
  15285. Infcode int64 `json:"infcode"`
  15286. Output struct {
  15287. Setlinfo struct {
  15288. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15289. AcctPay float64 `json:"acct_pay"`
  15290. ActPayDedc float64 `json:"act_pay_dedc"`
  15291. Age float64 `json:"age"`
  15292. Balc float64 `json:"balc"`
  15293. Certno string `json:"certno"`
  15294. ClrOptins string `json:"clr_optins"`
  15295. ClrType string `json:"clr_type"`
  15296. ClrWay string `json:"clr_way"`
  15297. CvlservFlag string `json:"cvlserv_flag"`
  15298. CvlservPay float64 `json:"cvlserv_pay"`
  15299. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15300. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15301. Gend string `json:"gend"`
  15302. HifesPay float64 `json:"hifes_pay"`
  15303. HifmiPay float64 `json:"hifmi_pay"`
  15304. HifpPay float64 `json:"hifp_pay"`
  15305. HospPartAmt float64 `json:"hosp_part_amt"`
  15306. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15307. Insutype string `json:"insutype"`
  15308. MafPay float64 `json:"maf_pay"`
  15309. MdtrtCertType string `json:"mdtrt_cert_type"`
  15310. HifobPay float64 `json:"hifob_pay"`
  15311. MdtrtID string `json:"mdtrt_id"`
  15312. MedType string `json:"med_type"`
  15313. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15314. MedinsSetlID string `json:"medins_setl_id"`
  15315. Naty string `json:"naty"`
  15316. OthPay float64 `json:"oth_pay"`
  15317. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15318. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15319. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15320. PsnCashPay float64 `json:"psn_cash_pay"`
  15321. PsnCertType string `json:"psn_cert_type"`
  15322. PsnName string `json:"psn_name"`
  15323. PsnNo string `json:"psn_no"`
  15324. PsnPartAmt float64 `json:"psn_part_amt"`
  15325. PsnType string `json:"psn_type"`
  15326. SetlID string `json:"setl_id"`
  15327. SetlTime string `json:"setl_time"`
  15328. } `json:"setlinfo"`
  15329. Setldetail interface{} `json:"setldetail"`
  15330. } `json:"output"`
  15331. RefmsgTime string `json:"refmsg_time"`
  15332. RespondTime string `json:"respond_time"`
  15333. Signtype interface{} `json:"signtype"`
  15334. WarnMsg interface{} `json:"warn_msg"`
  15335. }
  15336. type ResultEight struct {
  15337. Cainfo string `json:"cainfo"`
  15338. ErrMsg string `json:"err_msg"`
  15339. InfRefmsgid string `json:"inf_refmsgid"`
  15340. Infcode int64 `json:"infcode"`
  15341. Output struct {
  15342. Stmtinfo struct {
  15343. SetlOptins string `json:"setl_optins"`
  15344. StmtRslt string `json:"stmt_rslt"`
  15345. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15346. } `json:"stmtinfo"`
  15347. } `json:"output"`
  15348. RefmsgTime string `json:"refmsg_time"`
  15349. RespondTime string `json:"respond_time"`
  15350. Signtype interface{} `json:"signtype"`
  15351. WarnMsg interface{} `json:"warn_msg"`
  15352. }
  15353. type ResultEightFor10188 struct {
  15354. Cainfo string `json:"cainfo"`
  15355. ErrMsg string `json:"err_msg"`
  15356. InfRefmsgid string `json:"inf_refmsgid"`
  15357. Infcode string `json:"infcode"`
  15358. Output struct {
  15359. Stmtinfo struct {
  15360. SetlOptins string `json:"setl_optins"`
  15361. StmtRslt string `json:"stmt_rslt"`
  15362. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15363. } `json:"stmtinfo"`
  15364. } `json:"output"`
  15365. RefmsgTime string `json:"refmsg_time"`
  15366. RespondTime string `json:"respond_time"`
  15367. Signtype interface{} `json:"signtype"`
  15368. WarnMsg interface{} `json:"warn_msg"`
  15369. }
  15370. type ResultNine struct {
  15371. Cainfo string `json:"cainfo"`
  15372. ErrMsg string `json:"err_msg"`
  15373. InfRefmsgid string `json:"inf_refmsgid"`
  15374. Infcode int64 `json:"infcode"`
  15375. Output struct {
  15376. FileQuryNo string `json:"file_qury_no"`
  15377. } `json:"output"`
  15378. RefmsgTime string `json:"refmsg_time"`
  15379. RespondTime string `json:"respond_time"`
  15380. Signtype interface{} `json:"signtype"`
  15381. WarnMsg interface{} `json:"warn_msg"`
  15382. }
  15383. type ResultTen struct {
  15384. Cainfo string `json:"cainfo"`
  15385. ErrMsg string `json:"err_msg"`
  15386. InfRefmsgid string `json:"inf_refmsgid"`
  15387. Infcode int64 `json:"infcode"`
  15388. Output struct {
  15389. Fileinfo struct {
  15390. DldEndtime string `json:"dld_endtime"`
  15391. FileQuryNo string `json:"file_qury_no"`
  15392. Filename string `json:"filename"`
  15393. } `json:"fileinfo"`
  15394. } `json:"output"`
  15395. RefmsgTime string `json:"refmsg_time"`
  15396. RespondTime string `json:"respond_time"`
  15397. Signtype interface{} `json:"signtype"`
  15398. WarnMsg interface{} `json:"warn_msg"`
  15399. }
  15400. type Result5262 struct {
  15401. ErrMsg string `json:"err_msg"`
  15402. InfRefmsgid string `json:"inf_refmsgid"`
  15403. Infcode int64 `json:"infcode"`
  15404. Output struct {
  15405. PageInfo struct {
  15406. Size int `json:"size"`
  15407. RecordCounts int `json:"record_counts"`
  15408. } `json:"page_info"`
  15409. Idetinfo []interface{} `json:"idetinfo"`
  15410. Result []struct {
  15411. SetlID string `json:"setl_id"`
  15412. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15413. MdtrtID string `json:"mdtrt_id"`
  15414. InitSetlID string `json:"init_setl_id,omitempty"`
  15415. PsnNo string `json:"psn_no"`
  15416. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15417. PsnName string `json:"psn_name"`
  15418. PsnCertType string `json:"psn_cert_type"`
  15419. Certno string `json:"certno"`
  15420. Gend string `json:"gend,omitempty"`
  15421. Naty string `json:"naty,omitempty"`
  15422. Brdy string `json:"brdy,omitempty"`
  15423. Age float64 `json:"age,omitempty"`
  15424. Insutype string `json:"insutype,omitempty"`
  15425. PsnType string `json:"psn_type"`
  15426. CvlservFlag string `json:"cvlserv_flag"`
  15427. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15428. SpPsnType string `json:"sp_psn_type,omitempty"`
  15429. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15430. ClctGrde string `json:"clct_grde,omitempty"`
  15431. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15432. NwbFlag string `json:"nwb_flag,omitempty"`
  15433. InsuAdmdvs string `json:"insu_admdvs"`
  15434. EmpNo string `json:"emp_no,omitempty"`
  15435. EmpName string `json:"emp_name,omitempty"`
  15436. EmpType string `json:"emp_type,omitempty"`
  15437. EconType string `json:"econ_type,omitempty"`
  15438. AfilIndu string `json:"afil_indu,omitempty"`
  15439. AfilRlts string `json:"afil_rlts,omitempty"`
  15440. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15441. PayLoc string `json:"pay_loc,omitempty"`
  15442. FixmedinsCode string `json:"fixmedins_code"`
  15443. FixmedinsName string `json:"fixmedins_name"`
  15444. HospLv string `json:"hosp_lv,omitempty"`
  15445. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15446. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15447. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15448. Begndate string `json:"begndate"`
  15449. Enddate string `json:"enddate"`
  15450. SetlTime string `json:"setl_time"`
  15451. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15452. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15453. MedType string `json:"med_type"`
  15454. SetlType string `json:"setl_type,omitempty"`
  15455. ClrType string `json:"clr_type,omitempty"`
  15456. ClrWay string `json:"clr_way,omitempty"`
  15457. PsnSetlway string `json:"psn_setlway,omitempty"`
  15458. ClrOptins string `json:"clr_optins,omitempty"`
  15459. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15460. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15461. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15462. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15463. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15464. DedcStd float64 `json:"dedc_std,omitempty"`
  15465. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15466. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15467. HifpPay float64 `json:"hifp_pay,omitempty"`
  15468. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15469. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15470. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15471. HifesPay float64 `json:"hifes_pay,omitempty"`
  15472. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15473. HifobPay float64 `json:"hifob_pay,omitempty"`
  15474. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15475. MafPay float64 `json:"maf_pay,omitempty"`
  15476. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15477. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15478. PsnPay float64 `json:"psn_pay,omitempty"`
  15479. AcctPay float64 `json:"acct_pay,omitempty"`
  15480. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15481. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15482. Balc float64 `json:"balc,omitempty"`
  15483. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15484. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15485. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15486. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15487. Year string `json:"year,omitempty"`
  15488. DiseNo string `json:"dise_no,omitempty"`
  15489. DiseName string `json:"dise_name,omitempty"`
  15490. Invono string `json:"invono,omitempty"`
  15491. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15492. ValiFlag string `json:"vali_flag,omitempty"`
  15493. Memo string `json:"memo,omitempty"`
  15494. Rid string `json:"rid"`
  15495. UpdtTime string `json:"updt_time,omitempty"`
  15496. CrterID string `json:"crter_id,omitempty"`
  15497. CrterName string `json:"crter_name,omitempty"`
  15498. CrteTime string `json:"crte_time,omitempty"`
  15499. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15500. OpterID string `json:"opter_id,omitempty"`
  15501. OpterName string `json:"opter_name,omitempty"`
  15502. OptTime string `json:"opt_time,omitempty"`
  15503. OptinsNo string `json:"optins_no,omitempty"`
  15504. PoolareaNo string `json:"poolarea_no,omitempty"`
  15505. } `json:"result"`
  15506. } `json:"output"`
  15507. RefmsgTime string `json:"refmsg_time"`
  15508. RespondTime string `json:"respond_time"`
  15509. Signtype interface{} `json:"signtype"`
  15510. WarnInfo interface{} `json:"warn_info"`
  15511. }
  15512. type Result5267 struct {
  15513. ErrMsg string `json:"err_msg"`
  15514. InfRefmsgid string `json:"inf_refmsgid"`
  15515. Infcode int64 `json:"infcode"`
  15516. Output struct {
  15517. PageInfo struct {
  15518. Size int `json:"size"`
  15519. RecordCounts int `json:"record_counts"`
  15520. } `json:"pageinfo"`
  15521. Result []struct {
  15522. SetlID string `json:"setl_id"`
  15523. ClrOptins string `json:"clr_optins"`
  15524. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15525. MdtrtID string `json:"mdtrt_id"`
  15526. InitSetlID string `json:"init_setl_id,omitempty"`
  15527. PsnNo string `json:"psn_no"`
  15528. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15529. PsnName string `json:"psn_name"`
  15530. PsnCertType string `json:"psn_cert_type"`
  15531. Certno string `json:"certno"`
  15532. Gend string `json:"gend,omitempty"`
  15533. Naty string `json:"naty,omitempty"`
  15534. Brdy string `json:"brdy,omitempty"`
  15535. Age float64 `json:"age,omitempty"`
  15536. Insutype string `json:"insutype,omitempty"`
  15537. PsnType string `json:"psn_type"`
  15538. CvlservFlag string `json:"cvlserv_flag"`
  15539. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15540. SpPsnType string `json:"sp_psn_type,omitempty"`
  15541. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15542. ClctGrde string `json:"clct_grde,omitempty"`
  15543. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15544. NwbFlag string `json:"nwb_flag,omitempty"`
  15545. InsuAdmdvs string `json:"insu_admdvs"`
  15546. EmpNo string `json:"emp_no,omitempty"`
  15547. EmpName string `json:"emp_name,omitempty"`
  15548. EmpType string `json:"emp_type,omitempty"`
  15549. EconType string `json:"econ_type,omitempty"`
  15550. AfilIndu string `json:"afil_indu,omitempty"`
  15551. AfilRlts string `json:"afil_rlts,omitempty"`
  15552. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15553. PayLoc string `json:"pay_loc,omitempty"`
  15554. FixmedinsCode string `json:"fixmedins_code"`
  15555. FixmedinsName string `json:"fixmedins_name"`
  15556. HospLv string `json:"hosp_lv,omitempty"`
  15557. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15558. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15559. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15560. Begndate string `json:"begndate,omitempty"`
  15561. Enddate string `json:"enddate,omitempty"`
  15562. SetlTime string `json:"setl_time,omitempty"`
  15563. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15564. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15565. MedType string `json:"med_type"`
  15566. SetlType string `json:"setl_type,omitempty"`
  15567. ClrType string `json:"clr_type,omitempty"`
  15568. ClrWay string `json:"clr_way,omitempty"`
  15569. PsnSetlway string `json:"psn_setlway,omitempty"`
  15570. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15571. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15572. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15573. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15574. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15575. DedcStd float64 `json:"dedc_std,omitempty"`
  15576. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15577. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15578. HifpPay float64 `json:"hifp_pay,omitempty"`
  15579. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15580. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15581. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15582. HifesPay float64 `json:"hifes_pay,omitempty"`
  15583. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15584. HifobPay float64 `json:"hifob_pay,omitempty"`
  15585. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15586. MafPay float64 `json:"maf_pay,omitempty"`
  15587. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15588. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15589. PsnPay float64 `json:"psn_pay,omitempty"`
  15590. AcctPay float64 `json:"acct_pay,omitempty"`
  15591. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15592. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15593. Balc float64 `json:"balc,omitempty"`
  15594. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15595. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15596. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15597. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15598. Year string `json:"year,omitempty"`
  15599. DiseNo string `json:"dise_no,omitempty"`
  15600. DiseName string `json:"dise_name,omitempty"`
  15601. Invono string `json:"invono,omitempty"`
  15602. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15603. Memo string `json:"memo,omitempty"`
  15604. UpdtTime string `json:"updt_time,omitempty"`
  15605. OpterID string `json:"opter_id,omitempty"`
  15606. OpterName string `json:"opter_name,omitempty"`
  15607. OptTime string `json:"opt_time,omitempty"`
  15608. OptinsNo string `json:"optins_no,omitempty"`
  15609. PoolareaNo string `json:"poolarea_no,omitempty"`
  15610. } `json:"result"`
  15611. } `json:"output"`
  15612. RefmsgTime string `json:"refmsg_time"`
  15613. RespondTime string `json:"respond_time"`
  15614. Signtype interface{} `json:"signtype"`
  15615. WarnInfo interface{} `json:"warn_info"`
  15616. }
  15617. // type Autogenerated struct {
  15618. // Output struct {
  15619. // Setlinfo struct {
  15620. // SetlTime string `json:"setl_time"`
  15621. // CvlservPay float64 `json:"cvlserv_pay"`
  15622. // Year string `json:"year"`
  15623. // MedType string `json:"med_type"`
  15624. // PsnPay float64 `json:"psn_pay"`
  15625. // OpterID string `json:"opter_id"`
  15626. // Begndate string `json:"begndate"`
  15627. // FlxempeFlag string `json:"flxempe_flag"`
  15628. // HifmiPay float64 `json:"hifmi_pay"`
  15629. // PsnNo string `json:"psn_no"`
  15630. // ActPayDedc float64 `json:"act_pay_dedc"`
  15631. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15632. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15633. // ClrWay string `json:"clr_way"`
  15634. // OthPay float64 `json:"oth_pay"`
  15635. // Gend string `json:"gend"`
  15636. // MdtrtID string `json:"mdtrt_id"`
  15637. // AcctPay float64 `json:"acct_pay"`
  15638. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15639. // Insutype string `json:"insutype"`
  15640. // Invono interface{} `json:"invono"`
  15641. // Enddate string `json:"enddate"`
  15642. // CashPayamt float64 `json:"cash_payamt"`
  15643. // PsnType string `json:"psn_type"`
  15644. // FixmedinsName string `json:"fixmedins_name"`
  15645. // HifpPay float64 `json:"hifp_pay"`
  15646. // NewFlag interface{} `json:"new_flag"`
  15647. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15648. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15649. // PayLoc string `json:"pay_loc"`
  15650. // ClrType string `json:"clr_type"`
  15651. // RefdSetlFlag string `json:"refd_setl_flag"`
  15652. // CvlservFlag string `json:"cvlserv_flag"`
  15653. // EmpName string `json:"emp_name"`
  15654. // Brdy string `json:"brdy"`
  15655. // Naty string `json:"naty"`
  15656. // Certno string `json:"certno"`
  15657. // DiseCode string `json:"dise_code"`
  15658. // FixmedinsCode string `json:"fixmedins_code"`
  15659. // DedcHospLv string `json:"dedc_hosp_lv"`
  15660. // OpterName string `json:"opter_name"`
  15661. // Balc float64 `json:"balc"`
  15662. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15663. // PsnCertType string `json:"psn_cert_type"`
  15664. // HifobPay float64 `json:"hifob_pay"`
  15665. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15666. // HifesPay float64 `json:"hifes_pay"`
  15667. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15668. // OptTime string `json:"opt_time"`
  15669. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15670. // SetlID string `json:"setl_id"`
  15671. // MafPay float64 `json:"maf_pay"`
  15672. // PsnName string `json:"psn_name"`
  15673. // InsuOptins interface{} `json:"insu_optins"`
  15674. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15675. // ClrOptins string `json:"clr_optins"`
  15676. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15677. // DiseName string `json:"dise_name"`
  15678. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15679. // Age float64 `json:"age"`
  15680. // DtrtCertType string `json:"dtrt_cert_type"`
  15681. // HospLv string `json:"hosp_lv"`
  15682. // } `json:"setlinfo"`
  15683. // Setldetail []struct {
  15684. // FundPayType string `json:"fund_pay_type"`
  15685. // FundPayamt float64 `json:"fund_payamt"`
  15686. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15687. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15688. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15689. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15690. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15691. // } `json:"setldetail"`
  15692. // } `json:"output"`
  15693. // Infcode int `json:"infcode"`
  15694. // WarnMsg interface{} `json:"warn_msg"`
  15695. // Cainfo interface{} `json:"cainfo"`
  15696. // ErrMsg interface{} `json:"err_msg"`
  15697. // RefmsgTime string `json:"refmsg_time"`
  15698. // Signtype interface{} `json:"signtype"`
  15699. // RespondTime string `json:"respond_time"`
  15700. // InfRefmsgid string `json:"inf_refmsgid"`
  15701. // }
  15702. type Result002 struct {
  15703. Cainfo interface{} `json:"cainfo"`
  15704. ErrMsg string `json:"err_msg"`
  15705. InfRefmsgid string `json:"inf_refmsgid"`
  15706. Infcode int64 `json:"infcode"`
  15707. Output struct {
  15708. RxFile string `json:"rx_file"`
  15709. SignDigest string `json:"sign_digest"`
  15710. SignCertSn string `json:"sign_cert_sn"`
  15711. SignCertDn string `json:"sign_cert_dn"`
  15712. } `json:"output"`
  15713. RefmsgTime string `json:"refmsg_time"`
  15714. RespondTime string `json:"respond_time"`
  15715. Signtype interface{} `json:"signtype"`
  15716. WarnMsg interface{} `json:"warn_msg"`
  15717. }
  15718. type Result003 struct {
  15719. Cainfo interface{} `json:"cainfo"`
  15720. ErrMsg string `json:"err_msg"`
  15721. InfRefmsgid string `json:"inf_refmsgid"`
  15722. Infcode int64 `json:"infcode"`
  15723. Output struct {
  15724. HiRxno string `json:"hi_rxno"`
  15725. RxStasCodg string `json:"rx_stas_codg"`
  15726. RxStasName string `json:"rx_stas_name"`
  15727. } `json:"output"`
  15728. RefmsgTime string `json:"refmsg_time"`
  15729. RespondTime string `json:"respond_time"`
  15730. Signtype interface{} `json:"signtype"`
  15731. WarnMsg interface{} `json:"warn_msg"`
  15732. }
  15733. type ResultEleven struct {
  15734. Cainfo string `json:"cainfo"`
  15735. ErrMsg string `json:"err_msg"`
  15736. InfRefmsgid string `json:"inf_refmsgid"`
  15737. Infcode int64 `json:"infcode"`
  15738. Output struct {
  15739. Setlinfo struct {
  15740. SetlTime string `json:"setl_time"`
  15741. CvlservPay float64 `json:"cvlserv_pay"`
  15742. Year string `json:"year"`
  15743. MedType string `json:"med_type"`
  15744. PsnPay float64 `json:"psn_pay"`
  15745. OpterID string `json:"opter_id"`
  15746. Begndate string `json:"begndate"`
  15747. FlxempeFlag string `json:"flxempe_flag"`
  15748. HifmiPay float64 `json:"hifmi_pay"`
  15749. PsnNo string `json:"psn_no"`
  15750. ActPayDedc float64 `json:"act_pay_dedc"`
  15751. MedinsSetlID interface{} `json:"medins_setl_id"`
  15752. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15753. ClrWay string `json:"clr_way"`
  15754. OthPay float64 `json:"oth_pay"`
  15755. Gend string `json:"gend"`
  15756. MdtrtID string `json:"mdtrt_id"`
  15757. AcctPay float64 `json:"acct_pay"`
  15758. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15759. Insutype string `json:"insutype"`
  15760. Invono interface{} `json:"invono"`
  15761. Enddate string `json:"enddate"`
  15762. CashPayamt float64 `json:"cash_payamt"`
  15763. PsnType string `json:"psn_type"`
  15764. FixmedinsName string `json:"fixmedins_name"`
  15765. HifpPay float64 `json:"hifp_pay"`
  15766. NewFlag interface{} `json:"new_flag"`
  15767. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15768. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15769. PayLoc string `json:"pay_loc"`
  15770. ClrType string `json:"clr_type"`
  15771. RefdSetlFlag string `json:"refd_setl_flag"`
  15772. CvlservFlag string `json:"cvlserv_flag"`
  15773. EmpName string `json:"emp_name"`
  15774. Brdy string `json:"brdy"`
  15775. Naty string `json:"naty"`
  15776. Certno string `json:"certno"`
  15777. DiseCode string `json:"dise_code"`
  15778. FixmedinsCode string `json:"fixmedins_code"`
  15779. DedcHospLv string `json:"dedc_hosp_lv"`
  15780. OpterName string `json:"opter_name"`
  15781. Balc float64 `json:"balc"`
  15782. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15783. PsnCertType string `json:"psn_cert_type"`
  15784. HifobPay float64 `json:"hifob_pay"`
  15785. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15786. HifesPay float64 `json:"hifes_pay"`
  15787. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15788. OptTime string `json:"opt_time"`
  15789. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15790. SetlID string `json:"setl_id"`
  15791. MafPay float64 `json:"maf_pay"`
  15792. PsnName string `json:"psn_name"`
  15793. InsuOptins interface{} `json:"insu_optins"`
  15794. PrefFundPay interface{} `json:"pref_fund_pay"`
  15795. ClrOptins string `json:"clr_optins"`
  15796. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15797. DiseName string `json:"dise_name"`
  15798. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15799. Age float64 `json:"age"`
  15800. DtrtCertType string `json:"dtrt_cert_type"`
  15801. HospLv string `json:"hosp_lv"`
  15802. PsnCashPay float64 `json:"psn_cash_pay"`
  15803. } `json:"setlinfo"`
  15804. } `json:"output"`
  15805. RefmsgTime string `json:"refmsg_time"`
  15806. RespondTime string `json:"respond_time"`
  15807. Signtype interface{} `json:"signtype"`
  15808. WarnMsg interface{} `json:"warn_msg"`
  15809. }
  15810. type ResultElevenah struct {
  15811. Cainfo string `json:"cainfo"`
  15812. ErrMsg string `json:"err_msg"`
  15813. InfRefmsgid string `json:"inf_refmsgid"`
  15814. Infcode int64 `json:"infcode"`
  15815. Output struct {
  15816. Setlinfo struct {
  15817. SetlTime int64 `json:"setl_time"`
  15818. CvlservPay float64 `json:"cvlserv_pay"`
  15819. Year string `json:"year"`
  15820. MedType string `json:"med_type"`
  15821. PsnPay float64 `json:"psn_pay"`
  15822. OpterID string `json:"opter_id"`
  15823. Begndate int64 `json:"begndate"`
  15824. FlxempeFlag string `json:"flxempe_flag"`
  15825. HifmiPay float64 `json:"hifmi_pay"`
  15826. PsnNo string `json:"psn_no"`
  15827. ActPayDedc float64 `json:"act_pay_dedc"`
  15828. MedinsSetlID interface{} `json:"medins_setl_id"`
  15829. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15830. ClrWay string `json:"clr_way"`
  15831. OthPay float64 `json:"oth_pay"`
  15832. Gend string `json:"gend"`
  15833. MdtrtID string `json:"mdtrt_id"`
  15834. AcctPay float64 `json:"acct_pay"`
  15835. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15836. Insutype string `json:"insutype"`
  15837. Invono interface{} `json:"invono"`
  15838. Enddate int64 `json:"enddate"`
  15839. CashPayamt float64 `json:"cash_payamt"`
  15840. PsnType string `json:"psn_type"`
  15841. FixmedinsName string `json:"fixmedins_name"`
  15842. HifpPay float64 `json:"hifp_pay"`
  15843. NewFlag interface{} `json:"new_flag"`
  15844. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15846. PayLoc string `json:"pay_loc"`
  15847. ClrType string `json:"clr_type"`
  15848. RefdSetlFlag string `json:"refd_setl_flag"`
  15849. CvlservFlag string `json:"cvlserv_flag"`
  15850. EmpName string `json:"emp_name"`
  15851. Brdy int64 `json:"brdy"`
  15852. Naty string `json:"naty"`
  15853. Certno string `json:"certno"`
  15854. DiseCode string `json:"dise_code"`
  15855. FixmedinsCode string `json:"fixmedins_code"`
  15856. DedcHospLv string `json:"dedc_hosp_lv"`
  15857. OpterName string `json:"opter_name"`
  15858. Balc float64 `json:"balc"`
  15859. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15860. PsnCertType string `json:"psn_cert_type"`
  15861. HifobPay float64 `json:"hifob_pay"`
  15862. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15863. HifesPay float64 `json:"hifes_pay"`
  15864. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15865. OptTime int64 `json:"opt_time"`
  15866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15867. SetlID string `json:"setl_id"`
  15868. MafPay float64 `json:"maf_pay"`
  15869. PsnName string `json:"psn_name"`
  15870. InsuOptins interface{} `json:"insu_optins"`
  15871. PrefFundPay interface{} `json:"pref_fund_pay"`
  15872. ClrOptins string `json:"clr_optins"`
  15873. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15874. DiseName string `json:"dise_name"`
  15875. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15876. Age float64 `json:"age"`
  15877. DtrtCertType string `json:"dtrt_cert_type"`
  15878. HospLv string `json:"hosp_lv"`
  15879. PsnCashPay float64 `json:"psn_cash_pay"`
  15880. } `json:"setlinfo"`
  15881. } `json:"output"`
  15882. RefmsgTime string `json:"refmsg_time"`
  15883. RespondTime string `json:"respond_time"`
  15884. Signtype interface{} `json:"signtype"`
  15885. WarnMsg interface{} `json:"warn_msg"`
  15886. }
  15887. type ResultEleven10265 struct {
  15888. Cainfo string `json:"cainfo"`
  15889. ErrMsg string `json:"err_msg"`
  15890. InfRefmsgid string `json:"inf_refmsgid"`
  15891. Infcode string `json:"infcode"`
  15892. Output struct {
  15893. Setlinfo struct {
  15894. SetlTime string `json:"setl_time"`
  15895. CvlservPay float64 `json:"cvlserv_pay"`
  15896. Year string `json:"year"`
  15897. MedType string `json:"med_type"`
  15898. PsnPay float64 `json:"psn_pay"`
  15899. OpterID string `json:"opter_id"`
  15900. Begndate string `json:"begndate"`
  15901. FlxempeFlag string `json:"flxempe_flag"`
  15902. HifmiPay float64 `json:"hifmi_pay"`
  15903. PsnNo string `json:"psn_no"`
  15904. ActPayDedc float64 `json:"act_pay_dedc"`
  15905. MedinsSetlID interface{} `json:"medins_setl_id"`
  15906. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15907. ClrWay string `json:"clr_way"`
  15908. OthPay float64 `json:"oth_pay"`
  15909. Gend string `json:"gend"`
  15910. MdtrtID string `json:"mdtrt_id"`
  15911. AcctPay float64 `json:"acct_pay"`
  15912. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15913. Insutype string `json:"insutype"`
  15914. Invono interface{} `json:"invono"`
  15915. Enddate string `json:"enddate"`
  15916. CashPayamt float64 `json:"cash_payamt"`
  15917. PsnType string `json:"psn_type"`
  15918. FixmedinsName string `json:"fixmedins_name"`
  15919. HifpPay float64 `json:"hifp_pay"`
  15920. NewFlag interface{} `json:"new_flag"`
  15921. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15922. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15923. PayLoc string `json:"pay_loc"`
  15924. ClrType string `json:"clr_type"`
  15925. RefdSetlFlag string `json:"refd_setl_flag"`
  15926. CvlservFlag string `json:"cvlserv_flag"`
  15927. EmpName string `json:"emp_name"`
  15928. Brdy string `json:"brdy"`
  15929. Naty string `json:"naty"`
  15930. Certno string `json:"certno"`
  15931. DiseCode string `json:"dise_code"`
  15932. FixmedinsCode string `json:"fixmedins_code"`
  15933. DedcHospLv string `json:"dedc_hosp_lv"`
  15934. OpterName string `json:"opter_name"`
  15935. Balc float64 `json:"balc"`
  15936. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15937. PsnCertType string `json:"psn_cert_type"`
  15938. HifobPay float64 `json:"hifob_pay"`
  15939. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15940. HifesPay float64 `json:"hifes_pay"`
  15941. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15942. OptTime string `json:"opt_time"`
  15943. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15944. SetlID string `json:"setl_id"`
  15945. MafPay float64 `json:"maf_pay"`
  15946. PsnName string `json:"psn_name"`
  15947. InsuOptins interface{} `json:"insu_optins"`
  15948. PrefFundPay interface{} `json:"pref_fund_pay"`
  15949. ClrOptins string `json:"clr_optins"`
  15950. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15951. DiseName string `json:"dise_name"`
  15952. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15953. Age float64 `json:"age"`
  15954. DtrtCertType string `json:"dtrt_cert_type"`
  15955. HospLv string `json:"hosp_lv"`
  15956. PsnCashPay float64 `json:"psn_cash_pay"`
  15957. } `json:"setlinfo"`
  15958. } `json:"output"`
  15959. RefmsgTime string `json:"refmsg_time"`
  15960. RespondTime string `json:"respond_time"`
  15961. Signtype interface{} `json:"signtype"`
  15962. WarnMsg interface{} `json:"warn_msg"`
  15963. }
  15964. type ResultTwelve struct {
  15965. Cainfo string `json:"cainfo"`
  15966. ErrMsg string `json:"err_msg"`
  15967. InfRefmsgid string `json:"inf_refmsgid"`
  15968. Infcode int64 `json:"infcode"`
  15969. Output struct {
  15970. MdtrtId string `json:"mdtrt_id"`
  15971. ChrgBchno string `json:"chrg_bchno"`
  15972. PsnNo string `json:"psn_no"`
  15973. } `json:"output"`
  15974. RefmsgTime string `json:"refmsg_time"`
  15975. RespondTime string `json:"respond_time"`
  15976. Signtype interface{} `json:"signtype"`
  15977. WarnMsg interface{} `json:"warn_msg"`
  15978. }
  15979. type ResultThirteen struct {
  15980. ErrMsg string `json:"err_msg"`
  15981. InfRefmsgid string `json:"inf_refmsgid"`
  15982. Infcode int64 `json:"infcode"`
  15983. Output struct {
  15984. Result struct {
  15985. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15986. } `json:"result"`
  15987. } `json:"output"`
  15988. RefmsgTime string `json:"refmsg_time"`
  15989. RespondTime string `json:"respond_time"`
  15990. Signtype interface{} `json:"signtype"`
  15991. WarnInfo interface{} `json:"warn_info"`
  15992. }
  15993. type ResultThirteen10265 struct {
  15994. ErrMsg string `json:"err_msg"`
  15995. InfRefmsgid string `json:"inf_refmsgid"`
  15996. Infcode string `json:"infcode"`
  15997. Output struct {
  15998. Result struct {
  15999. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16000. } `json:"result"`
  16001. } `json:"output"`
  16002. RefmsgTime string `json:"refmsg_time"`
  16003. RespondTime string `json:"respond_time"`
  16004. Signtype interface{} `json:"signtype"`
  16005. WarnInfo interface{} `json:"warn_info"`
  16006. }
  16007. type ResultFourteen struct {
  16008. ErrMsg string `json:"err_msg"`
  16009. InfRefmsgid string `json:"inf_refmsgid"`
  16010. Infcode int64 `json:"infcode"`
  16011. Output struct {
  16012. } `json:"output"`
  16013. RefmsgTime string `json:"refmsg_time"`
  16014. RespondTime string `json:"respond_time"`
  16015. Signtype interface{} `json:"signtype"`
  16016. WarnInfo interface{} `json:"warn_info"`
  16017. }
  16018. type ResultCFYLJG001 struct {
  16019. ErrMsg string `json:"err_msg"`
  16020. InfRefmsgid string `json:"inf_refmsgid"`
  16021. Infcode int64 `json:"infcode"`
  16022. Output struct {
  16023. RxTraceCode string `json:"rx_trace_code"`
  16024. HiRxno string `json:"hi_rxno"`
  16025. } `json:"output"`
  16026. RefmsgTime string `json:"refmsg_time"`
  16027. RespondTime string `json:"respond_time"`
  16028. Signtype interface{} `json:"signtype"`
  16029. WarnInfo interface{} `json:"warn_info"`
  16030. }
  16031. type ResultCFYLJG007 struct {
  16032. ErrMsg string `json:"err_msg"`
  16033. InfRefmsgid string `json:"inf_refmsgid"`
  16034. Infcode int64 `json:"infcode"`
  16035. Output struct {
  16036. HiRxno string `json:"hi_rxno"`
  16037. RxStasName string `json:"rx_stas_name"`
  16038. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16039. Seltdelts []interface{} `json:"seltdelts"`
  16040. RxUsedStasName string `json:"rx_used_stas_name"`
  16041. RxStasCodg string `json:"rx_stas_codg"`
  16042. } `json:"output"`
  16043. RefmsgTime string `json:"refmsg_time"`
  16044. RespondTime string `json:"respond_time"`
  16045. Signtype interface{} `json:"signtype"`
  16046. WarnInfo interface{} `json:"warn_info"`
  16047. }
  16048. type ResultCFYLJG002 struct {
  16049. ErrMsg string `json:"err_msg"`
  16050. InfRefmsgid string `json:"inf_refmsgid"`
  16051. Infcode int64 `json:"infcode"`
  16052. Output struct {
  16053. RxFile string `json:"rx_file"`
  16054. SignDigest string `json:"sign_digest"`
  16055. SignCertSn string `json:"sign_cert_sn"`
  16056. SignCertDn string `json:"sign_cert_dn"`
  16057. } `json:"output"`
  16058. RefmsgTime string `json:"refmsg_time"`
  16059. RespondTime string `json:"respond_time"`
  16060. Signtype interface{} `json:"signtype"`
  16061. WarnInfo interface{} `json:"warn_info"`
  16062. }
  16063. type ResultCFYLJG003 struct {
  16064. ErrMsg string `json:"err_msg"`
  16065. InfRefmsgid string `json:"inf_refmsgid"`
  16066. Infcode int64 `json:"infcode"`
  16067. Output struct {
  16068. HiRxno string `json:"hi_rxno"`
  16069. RxStasCodg string `json:"rx_stas_codg"`
  16070. RxStasName string `json:"rx_stas_name"`
  16071. } `json:"output"`
  16072. RefmsgTime string `json:"refmsg_time"`
  16073. RespondTime string `json:"respond_time"`
  16074. Signtype interface{} `json:"signtype"`
  16075. WarnInfo interface{} `json:"warn_info"`
  16076. }
  16077. type ResultCFYLJG004 struct {
  16078. ErrMsg string `json:"err_msg"`
  16079. InfRefmsgid string `json:"inf_refmsgid"`
  16080. Infcode int64 `json:"infcode"`
  16081. Output struct {
  16082. HiRxno string `json:"hi_rxno"`
  16083. RxStasCodg string `json:"rx_stas_codg"`
  16084. RxStasName string `json:"rx_stas_name"`
  16085. } `json:"output"`
  16086. RefmsgTime string `json:"refmsg_time"`
  16087. RespondTime string `json:"respond_time"`
  16088. Signtype interface{} `json:"signtype"`
  16089. WarnInfo interface{} `json:"warn_info"`
  16090. }
  16091. type ResultCFYLJG008 struct {
  16092. ErrMsg string `json:"err_msg"`
  16093. InfRefmsgid string `json:"inf_refmsgid"`
  16094. Infcode int64 `json:"infcode"`
  16095. Output struct {
  16096. PoolareaNo string `json:"poolareaNo"`
  16097. AdmdvsName string `json:"admdvsName"`
  16098. Count string `json:"count"`
  16099. } `json:"output"`
  16100. RefmsgTime string `json:"refmsg_time"`
  16101. RespondTime string `json:"respond_time"`
  16102. Signtype interface{} `json:"signtype"`
  16103. WarnInfo interface{} `json:"warn_info"`
  16104. }
  16105. type ResultCFYLJG005 struct {
  16106. ErrMsg string `json:"err_msg"`
  16107. InfRefmsgid string `json:"inf_refmsgid"`
  16108. Infcode int64 `json:"infcode"`
  16109. Output struct {
  16110. HiRxNo string `json:"hi_rxno"`
  16111. FixMedinsCode string `json:"fixmedins_code"`
  16112. FixMedinsName string `json:"fixmedins_name"`
  16113. RxStasCodg string `json:"rx_stas_codg"`
  16114. RxStasName string `json:"rx_stas_name"`
  16115. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16116. RxUserdStasName string `json:"rx_userd_stas_name"`
  16117. PrscTime string `json:"prsc_time"`
  16118. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16119. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16120. RxUsedWayName string `json:"rx_used_way_name"`
  16121. RxFrquCodg string `json:"rx_frqu_codg"`
  16122. RxFrquName string `json:"rx_frqu_name"`
  16123. RxDosunt string `json:"rx_dosunt"`
  16124. RxDoscnt float64 `json:"rx_doscnt"`
  16125. RxDrordDscr string `json:"rx_drord_dscr"`
  16126. ValiDays int64 `json:"vali_days"`
  16127. ValiEndTime string `json:"vali_end_time"`
  16128. ReptFlag string `json:"rept_flag"`
  16129. MaxReptCnt int64 `json:"max_rept_cnt"`
  16130. ReptdCnt int64 `json:"reptd_cnt"`
  16131. MinInrvDays int64 `json:"min_inrv_days"`
  16132. RxTypeCode string `json:"rx_type_code"`
  16133. RxTypeName string `json:"rx_type_name"`
  16134. LongRxFlag string `json:"long_rx_flag"`
  16135. RxDetlList []struct {
  16136. MedListCodg string `json:"med_list_codg"`
  16137. MedinsListCodg string `json:"medins_list_codg"`
  16138. HospPrepFlag string `json:"hosp_prep_flag"`
  16139. RxItemTypeCode string `json:"rx_item_type_code"`
  16140. RxItemTypeName string `json:"rx_item_type_name"`
  16141. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16142. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16143. TcmHerbFoote string `json:"tcmherb_foote"`
  16144. MednTypeCode string `json:"medn_type_code"`
  16145. MednTypeName string `json:"medn_type_name"`
  16146. MainMedcFlag string `json:"main_medc_flag"`
  16147. UrgtFlag string `json:"urgt_flag"`
  16148. BasMednFlag string `json:"bas_medn_flag"`
  16149. ImpDrugFlag string `json:"imp_drug_flag"`
  16150. ProdBarc string `json:"prod_barc"`
  16151. DrugProdname string `json:"drug_prodname"`
  16152. GennameCodg string `json:"genname_codg"`
  16153. DrugGenname string `json:"drug_genname"`
  16154. DrugDosform string `json:"drug_dosform"`
  16155. DrugSpec string `json:"drug_spec"`
  16156. PrdrName string `json:"prdr_name"`
  16157. MedcWayCodg string `json:"medc_way_codg"`
  16158. MedcWayDscr string `json:"medc_way_dscr"`
  16159. MedcBegntime string `json:"medc_begntime"`
  16160. MedcEndtime string `json:"medc_endtime"`
  16161. MedcDays float64 `json:"medc_days"`
  16162. DrugPric float64 `json:"drug_pric"`
  16163. DrugSumamt float64 `json:"drug_sumamt"`
  16164. DrugCnt float64 `json:"drug_cnt"`
  16165. DrugDosunt string `json:"drug_dosunt"`
  16166. SinDoscnt float64 `json:"sin_doscnt"`
  16167. SinDosunt string `json:"sin_dosunt"`
  16168. UsedFrquCodg string `json:"used_frqu_codg"`
  16169. UsedFrquName string `json:"used_frqu_name"`
  16170. DrugTotlcnt string `json:"drug_totlcnt"`
  16171. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16172. DiseCodg string `json:"dise_codg"`
  16173. HospApprFlag string `json:"hosp_appr_flag"`
  16174. } `json:"rx_detl_list"`
  16175. RxOtpinfo struct {
  16176. MedType string `json:"med_type"`
  16177. IptOtpNo string `json:"ipt_otp_no"`
  16178. OtpIptFlag string `json:"otp_ipt_flag"`
  16179. PatnName string `json:"patn_name"`
  16180. PatnAge float64 `json:"patn_age"`
  16181. PatnHgt float64 `json:"patn_hgt"`
  16182. PatnWt float64 `json:"patn_wt"`
  16183. Gend string `json:"gend"`
  16184. GesoVal float64 `json:"geso_val"`
  16185. NwbFlag string `json:"nwb_flag"`
  16186. NwbAge string `json:"nwb_age"`
  16187. SuckPrdFlag string `json:"suck_prd_flag"`
  16188. AlgsHis string `json:"algs_his"`
  16189. Insutype string `json:"insutype"`
  16190. PrscDeptName string `json:"prsc_dept_name"`
  16191. PrscDrName string `json:"prsc_dr_name"`
  16192. PharName string `json:"phar_name"`
  16193. PharChkTime string `json:"phar_chk_time"`
  16194. MdtrtTime string `json:"mdtrt_time"`
  16195. DiseCodg string `json:"dise_codg"`
  16196. DiseName string `json:"dise_name"`
  16197. SpDiseFlag string `json:"sp_dise_flag"`
  16198. MaindiagCode string `json:"maindiag_code"`
  16199. MaindiagName string `json:"maindiag_name"`
  16200. DiseCondDscr string `json:"dise_cond_dscr"`
  16201. FstdiagFlag string `json:"fstdiag_flag"`
  16202. } `json:"rx_otpinfo"`
  16203. RxDiseList []struct {
  16204. DiagType string `json:"diag_type"`
  16205. MaindiagFlag string `json:"maindiag_flag"`
  16206. DiagSrtNo string `json:"diag_srt_no"`
  16207. DiagCode string `json:"diag_code"`
  16208. DiagName string `json:"diag_name"`
  16209. DiagDept string `json:"diag_dept"`
  16210. DiagDrNo string `json:"diag_dr_no"`
  16211. DiagDrName string `json:"diag_dr_name"`
  16212. DiagTime string `json:"diag_time"`
  16213. TcmDiseCode string `json:"tcm_dise_code"`
  16214. TcmDiseName string `json:"tcm_dise_name"`
  16215. TcmSympCode string `json:"tcmsymp_code"`
  16216. TcmSymp string `json:"tcmsymp"`
  16217. } `json:"rx_dise_list"`
  16218. } `json:"output"`
  16219. RefmsgTime string `json:"refmsg_time"`
  16220. RespondTime string `json:"respond_time"`
  16221. Signtype interface{} `json:"signtype"`
  16222. WarnInfo interface{} `json:"warn_info"`
  16223. }
  16224. type ResultCFYLJG006 struct {
  16225. ErrMsg string `json:"err_msg"`
  16226. InfRefmsgid string `json:"inf_refmsgid"`
  16227. Infcode int64 `json:"infcode"`
  16228. Output struct {
  16229. HiRxNo string `json:"hi_rxno"`
  16230. PharCode string `json:"phar_code"`
  16231. PharName string `json:"phar_name"`
  16232. RxChkOpnn string `json:"rx_chk_opnn"`
  16233. RxChkTime string `json:"rx_chk_time"`
  16234. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16235. RxChkStasName string `json:"rx_chk_stas_name"`
  16236. RxStasCodg string `json:"rx_stas_codg"`
  16237. RxStasName string `json:"rx_stas_name"`
  16238. } `json:"output"`
  16239. RefmsgTime string `json:"refmsg_time"`
  16240. RespondTime string `json:"respond_time"`
  16241. Signtype interface{} `json:"signtype"`
  16242. WarnInfo interface{} `json:"warn_info"`
  16243. }
  16244. type ResultFourteen10265 struct {
  16245. ErrMsg string `json:"err_msg"`
  16246. InfRefmsgid string `json:"inf_refmsgid"`
  16247. Infcode string `json:"infcode"`
  16248. Output struct {
  16249. } `json:"output"`
  16250. RefmsgTime string `json:"refmsg_time"`
  16251. RespondTime string `json:"respond_time"`
  16252. Signtype interface{} `json:"signtype"`
  16253. WarnInfo interface{} `json:"warn_info"`
  16254. }
  16255. type ResultSixteen struct {
  16256. Cainfo string `json:"cainfo"`
  16257. ErrMsg string `json:"err_msg"`
  16258. InfRefmsgid string `json:"inf_refmsgid"`
  16259. Infcode int64 `json:"infcode"`
  16260. Output struct {
  16261. Setlinfo struct {
  16262. MdtrtID string `json:"mdtrt_id"`
  16263. SetlID string `json:"setl_id"`
  16264. ClrOptins string `json:"clr_optins"`
  16265. SetlTime string `json:"setl_time"`
  16266. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16267. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16268. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16269. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16270. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16271. ActPayDedc float64 `json:"act_pay_dedc"`
  16272. HifpPay float64 `json:"hifp_pay"`
  16273. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16274. Lfpay float64 `json:"selfpay"`
  16275. CvlservPay float64 `json:"cvlserv_pay"`
  16276. HifesPay float64 `json:"hifes_pay"`
  16277. HifmiPay float64 `json:"hifmi_pay"`
  16278. HifobPay float64 `json:"hifob_pay"`
  16279. MafPay float64 `json:"maf_pay"`
  16280. OthPay float64 `json:"oth_pay"`
  16281. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16282. PsnPartAmt float64 `json:"psn_part_amt"`
  16283. AcctPay float64 `json:"acct_pay"`
  16284. Balc float64 `json:"balc"`
  16285. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16286. HospPartAmt float64 `json:"hosp_part_amt"`
  16287. MedinsSetlID string `json:"medins_setl_id"`
  16288. PdnCashPay string `json:"pdn_cash_pay"`
  16289. } `json:"setlinfo"`
  16290. } `json:"output"`
  16291. RefmsgTime string `json:"refmsg_time"`
  16292. RespondTime string `json:"respond_time"`
  16293. Signtype interface{} `json:"signtype"`
  16294. WarnMsg interface{} `json:"warn_msg"`
  16295. }
  16296. type ResultSixteen10265 struct {
  16297. Cainfo string `json:"cainfo"`
  16298. ErrMsg string `json:"err_msg"`
  16299. InfRefmsgid string `json:"inf_refmsgid"`
  16300. Infcode string `json:"infcode"`
  16301. Output struct {
  16302. Setlinfo struct {
  16303. MdtrtID string `json:"mdtrt_id"`
  16304. SetlID string `json:"setl_id"`
  16305. ClrOptins string `json:"clr_optins"`
  16306. SetlTime string `json:"setl_time"`
  16307. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16308. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16309. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16310. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16311. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16312. ActPayDedc float64 `json:"act_pay_dedc"`
  16313. HifpPay float64 `json:"hifp_pay"`
  16314. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16315. Lfpay float64 `json:"selfpay"`
  16316. CvlservPay float64 `json:"cvlserv_pay"`
  16317. HifesPay float64 `json:"hifes_pay"`
  16318. HifmiPay float64 `json:"hifmi_pay"`
  16319. HifobPay float64 `json:"hifob_pay"`
  16320. MafPay float64 `json:"maf_pay"`
  16321. OthPay float64 `json:"oth_pay"`
  16322. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16323. PsnPartAmt float64 `json:"psn_part_amt"`
  16324. AcctPay float64 `json:"acct_pay"`
  16325. Balc float64 `json:"balc"`
  16326. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16327. HospPartAmt float64 `json:"hosp_part_amt"`
  16328. MedinsSetlID string `json:"medins_setl_id"`
  16329. PdnCashPay string `json:"pdn_cash_pay"`
  16330. } `json:"setlinfo"`
  16331. } `json:"output"`
  16332. RefmsgTime string `json:"refmsg_time"`
  16333. RespondTime string `json:"respond_time"`
  16334. Signtype interface{} `json:"signtype"`
  16335. WarnMsg interface{} `json:"warn_msg"`
  16336. }
  16337. type ResultSixteen10265Two struct {
  16338. Cainfo string `json:"cainfo"`
  16339. ErrMsg string `json:"err_msg"`
  16340. InfRefmsgid string `json:"inf_refmsgid"`
  16341. Infcode string `json:"infcode"`
  16342. Output struct {
  16343. Setlinfo interface{} `json:"setlinfo"`
  16344. } `json:"output"`
  16345. RefmsgTime string `json:"refmsg_time"`
  16346. RespondTime string `json:"respond_time"`
  16347. Signtype interface{} `json:"signtype"`
  16348. WarnMsg interface{} `json:"warn_msg"`
  16349. }
  16350. type ResultgzSixteen10265Two struct {
  16351. Cainfo string `json:"cainfo"`
  16352. ErrMsg string `json:"err_msg"`
  16353. InfRefmsgid string `json:"inf_refmsgid"`
  16354. Infcode int64 `json:"infcode"`
  16355. Output struct {
  16356. Setlinfo interface{} `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 ResultSeventeen struct {
  16364. ErrMsg string `json:"err_msg"`
  16365. InfRefmsgid string `json:"inf_refmsgid"`
  16366. Infcode int64 `json:"infcode"`
  16367. Output struct {
  16368. SetlListId string `json:"setl_list_id"`
  16369. } `json:"output"`
  16370. RefmsgTime string `json:"refmsg_time"`
  16371. RespondTime string `json:"respond_time"`
  16372. Signtype string `json:"signtype"`
  16373. WarnInfo string `json:"warn_info"`
  16374. }
  16375. type ResultSeventeenOther struct {
  16376. ErrMsg string `json:"err_msg"`
  16377. InfRefmsgid string `json:"inf_refmsgid"`
  16378. Infcode string `json:"infcode"`
  16379. Output struct {
  16380. SetlListId string `json:"setl_list_id"`
  16381. } `json:"output"`
  16382. RefmsgTime string `json:"refmsg_time"`
  16383. RespondTime string `json:"respond_time"`
  16384. Signtype string `json:"signtype"`
  16385. WarnInfo string `json:"warn_info"`
  16386. }
  16387. type Result90991 struct {
  16388. ErrMsg string `json:"err_msg"`
  16389. InfRefmsgid string `json:"inf_refmsgid"`
  16390. Infcode int64 `json:"infcode"`
  16391. Output struct {
  16392. Result struct {
  16393. PsnNo string `json:"psn_no"`
  16394. CardStat string `json:"card_stat"`
  16395. Certno string `json:"certno"`
  16396. PsnName string `json:"psn_name"`
  16397. CheckStat string `json:"check_stat"`
  16398. SscnoCheckStat string `json:"sscno_check_stat"`
  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 Result90100 struct {
  16407. ErrMsg string `json:"err_msg"`
  16408. InfRefmsgid string `json:"inf_refmsgid"`
  16409. Infcode int64 `json:"infcode"`
  16410. Output struct {
  16411. PoolareaNo string `json:"poolarea_no"`
  16412. PoolareaNoName string `json:"poolarea_no_name"`
  16413. Insutype string `json:"insutype"`
  16414. InsutypeName string `json:"insutype_name"`
  16415. ClctType string `json:"clct_type"`
  16416. ClctTypeName string `json:"clct_type_name"`
  16417. ClctFlag string `json:"clct_flag"`
  16418. ClctFlagName string `json:"clct_flag_name"`
  16419. AccrymBegn string `json:"accrym_begn"`
  16420. AccrymEnd string `json:"accrym_end"`
  16421. ClctTime string `json:"clct_time"`
  16422. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16423. } `json:"output"`
  16424. RefmsgTime string `json:"refmsg_time"`
  16425. RespondTime string `json:"respond_time"`
  16426. Signtype interface{} `json:"signtype"`
  16427. WarnInfo interface{} `json:"warn_info"`
  16428. }
  16429. type Custom struct {
  16430. DetItemFeeSumamt string
  16431. Cut string
  16432. FeedetlSn string
  16433. Price string
  16434. MedListCodg string
  16435. Type int64
  16436. AdviceId int64
  16437. ProjectId int64
  16438. ItemId int64
  16439. }
  16440. type Result5301 struct {
  16441. ErrMsg string `json:"err_msg"`
  16442. InfRefmsgid string `json:"inf_refmsgid"`
  16443. Infcode int64 `json:"infcode"`
  16444. Output struct {
  16445. Result []struct {
  16446. OpspDiseCode string `json:"opsp_dise_code"`
  16447. OpspDiseName string `json:"opsp_dise_name"`
  16448. Begndate string `json:"begndate"`
  16449. Enddate string `json:"enddate"`
  16450. } `json:"feedetail"`
  16451. } `json:"output"`
  16452. RefmsgTime string `json:"refmsg_time"`
  16453. RespondTime string `json:"respond_time"`
  16454. Signtype interface{} `json:"signtype"`
  16455. WarnInfo interface{} `json:"warn_info"`
  16456. }
  16457. type Result5301For10265 struct {
  16458. ErrMsg string `json:"err_msg"`
  16459. InfRefmsgid string `json:"inf_refmsgid"`
  16460. Infcode string `json:"infcode"`
  16461. Output struct {
  16462. Result []struct {
  16463. OpspDiseCode string `json:"opsp_dise_code"`
  16464. OpspDiseName string `json:"opsp_dise_name"`
  16465. Begndate string `json:"begndate"`
  16466. Enddate string `json:"enddate"`
  16467. } `json:"feedetail"`
  16468. } `json:"output"`
  16469. RefmsgTime string `json:"refmsg_time"`
  16470. RespondTime string `json:"respond_time"`
  16471. Signtype interface{} `json:"signtype"`
  16472. WarnInfo interface{} `json:"warn_info"`
  16473. }
  16474. //获取个人信息----挂号-----上传就诊信息
  16475. func (c *HisApiController) GetRegisterInfo() {
  16476. id, _ := c.GetInt64("id")
  16477. record_time := c.GetString("record_time")
  16478. settlementValue, _ := c.GetInt64("settlement_value")
  16479. medical_insurance_card := c.GetString("medical_insurance_card")
  16480. name := c.GetString("name")
  16481. id_card_type, _ := c.GetInt64("id_card_type")
  16482. certificates, _ := c.GetInt64("certificates")
  16483. medical_care, _ := c.GetInt64("medical_care")
  16484. birthday := c.GetString("birthday")
  16485. id_card := c.GetString("id_card")
  16486. register_type, _ := c.GetInt64("register")
  16487. doctor, _ := c.GetInt64("doctor")
  16488. department, _ := c.GetInt64("department")
  16489. gender, _ := c.GetInt64("sex")
  16490. registration_fee, _ := c.GetFloat("registration_fee")
  16491. medical_expenses, _ := c.GetFloat("medical_expenses")
  16492. social_type, _ := c.GetInt64("social_type")
  16493. admin_user_id, _ := c.GetInt64("admin_user_id")
  16494. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16495. mdtrt_type := c.GetString("mdtrt_type")
  16496. if id_card_type == 5 {
  16497. id_card_type = 4
  16498. }
  16499. timeLayout := "2006-01-02"
  16500. loc, _ := time.LoadLocation("Local")
  16501. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16502. birthUnix := birthdays.Unix()
  16503. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16504. if err != nil {
  16505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16506. return
  16507. }
  16508. recordDateTime := theTime.Unix()
  16509. adminInfo := c.GetAdminUserInfo()
  16510. var patient service.Patients
  16511. if id == 0 {
  16512. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16513. } else {
  16514. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16515. }
  16516. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16517. if patientPrescription.ID == 0 {
  16518. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16519. }
  16520. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16521. if patient.ID == 0 {
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16523. return
  16524. }
  16525. if len(patient.IdCardNo) == 0 {
  16526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16527. return
  16528. }
  16529. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16530. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16531. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16532. //就诊结算未完成,不能进行二次挂号
  16533. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16534. //if len(his) >= 1 {
  16535. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16536. // if len(his) >= 1 && order.ID == 0 {
  16537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16538. // return
  16539. // }
  16540. //}
  16541. //var register_log string
  16542. if config.IsOpen == 1 {
  16543. var res ResultTwo
  16544. var res10265 ResultTwo10265
  16545. var PsnNo string
  16546. var PsnCertType string
  16547. var Certno string
  16548. var PsnName string
  16549. var Gend string
  16550. var Naty string
  16551. var Brdy string
  16552. var Age float64
  16553. var infoStr string
  16554. var idetinfoStr string
  16555. var infocode int64
  16556. var verify_number string
  16557. fmt.Println(verify_number)
  16558. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  16559. psn_info, _ := service.GetPsnByPatientId(id)
  16560. PsnNo = psn_info.PsnNo
  16561. PsnCertType = psn_info.PsnCertType
  16562. Certno = psn_info.Certno
  16563. PsnName = psn_info.PsnName
  16564. Gend = psn_info.Gend
  16565. Naty = psn_info.Naty
  16566. Brdy = psn_info.Brdy
  16567. Age = psn_info.Age
  16568. infoStr = psn_info.Insuinfo
  16569. idetinfoStr = psn_info.Idetinfo
  16570. infocode = 0
  16571. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16572. psn_info, _ := service.GetPsnByPatientId(id)
  16573. PsnNo = psn_info.PsnNo
  16574. PsnCertType = psn_info.PsnCertType
  16575. Certno = psn_info.Certno
  16576. PsnName = psn_info.PsnName
  16577. Gend = psn_info.Gend
  16578. Naty = psn_info.Naty
  16579. Brdy = psn_info.Brdy
  16580. Age = psn_info.Age
  16581. infoStr = psn_info.Insuinfo
  16582. idetinfoStr = psn_info.Idetinfo
  16583. infocode = 0
  16584. verify_number = psn_info.VerifyNumber
  16585. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16586. if id_card_type == 2 {
  16587. //请求内网数据
  16588. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16589. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16590. "&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
  16591. resp, requestErr := http.Get(api)
  16592. if requestErr != nil {
  16593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16594. return
  16595. }
  16596. body, ioErr := ioutil.ReadAll(resp.Body)
  16597. if ioErr != nil {
  16598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16600. return
  16601. }
  16602. var respJSON map[string]interface{}
  16603. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16606. return
  16607. }
  16608. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16609. result_byte, _ := json.Marshal(respJSON)
  16610. result := string(result_byte)
  16611. var dat map[string]interface{}
  16612. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16613. fmt.Println(dat)
  16614. } else {
  16615. fmt.Println(err)
  16616. }
  16617. userJSONBytes, _ := json.Marshal(dat)
  16618. var res ResultTwo
  16619. var resTwo10265 ResultTwo10265
  16620. if miConfig.Code == "H15049901371" {
  16621. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16622. utils.ErrorLog("解析失败:%v", err)
  16623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16624. return
  16625. }
  16626. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16627. res.Infcode = Infcode
  16628. res.ErrMsg = resTwo10265.ErrMsg
  16629. res.Output = resTwo10265.Output
  16630. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16631. res.RespondTime = resTwo10265.RespondTime
  16632. res.WarnInfo = resTwo10265.WarnInfo
  16633. } else {
  16634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16635. utils.ErrorLog("解析失败:%v", err)
  16636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16637. return
  16638. }
  16639. }
  16640. //var insutypes []string
  16641. //var insutype string
  16642. //var is390 int = 0
  16643. //var is310 int = 0
  16644. //for _, item := range res.Output.Iinfo {
  16645. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16646. // insutypes = append(insutypes, item.Insutype)
  16647. // }
  16648. //}
  16649. //if len(insutypes) == 1 {
  16650. // insutype = insutypes[0]
  16651. //} else {
  16652. // for _, i := range insutypes {
  16653. // if i == "390" {
  16654. // is390 = 1
  16655. // }
  16656. //
  16657. // if i == "310" {
  16658. // is310 = 1
  16659. // }
  16660. // }
  16661. //}
  16662. //if is390 == 1 {
  16663. // insutype = "390"
  16664. //}
  16665. //if is310 == 1 {
  16666. // insutype = "310"
  16667. //}
  16668. //if len(insutypes) == 0 {
  16669. // insutype = "310"
  16670. //}
  16671. PsnNo = res.Output.Baseinfo.PsnNo
  16672. PsnCertType = res.Output.Baseinfo.PsnCertType
  16673. Certno = res.Output.Baseinfo.Certno
  16674. PsnName = res.Output.Baseinfo.PsnName
  16675. Gend = res.Output.Baseinfo.Gend
  16676. Naty = res.Output.Baseinfo.Naty
  16677. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16678. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16679. infoStr = string(Iinfos)
  16680. idetinfoStr = string(Idetinfos)
  16681. infocode = res.Infcode
  16682. //infocode = 0
  16683. //verify_number = psn_info.VerifyNumber
  16684. } else {
  16685. psn_info, _ := service.GetPsnByPatientId(id)
  16686. PsnNo = psn_info.PsnNo
  16687. PsnCertType = psn_info.PsnCertType
  16688. Certno = psn_info.Certno
  16689. PsnName = psn_info.PsnName
  16690. Gend = psn_info.Gend
  16691. Naty = psn_info.Naty
  16692. Brdy = psn_info.Brdy
  16693. Age = psn_info.Age
  16694. infoStr = psn_info.Insuinfo
  16695. idetinfoStr = psn_info.Idetinfo
  16696. infocode = 0
  16697. verify_number = psn_info.VerifyNumber
  16698. }
  16699. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16700. if id_card_type == 1 {
  16701. psn_info, _ := service.GetPsnByPatientId(id)
  16702. PsnNo = psn_info.PsnNo
  16703. PsnCertType = psn_info.PsnCertType
  16704. Certno = psn_info.Certno
  16705. PsnName = psn_info.PsnName
  16706. Gend = psn_info.Gend
  16707. Naty = psn_info.Naty
  16708. Brdy = psn_info.Brdy
  16709. Age = psn_info.Age
  16710. infoStr = psn_info.Insuinfo
  16711. idetinfoStr = psn_info.Idetinfo
  16712. infocode = 0
  16713. verify_number = psn_info.VerifyNumber
  16714. } else if id_card_type == 2 {
  16715. 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)
  16716. fmt.Println(errMsgLog)
  16717. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16718. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16719. utils.ErrorLog("解析失败:%v", err)
  16720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16721. return
  16722. }
  16723. PsnNo = res.Output.Baseinfo.PsnNo
  16724. PsnCertType = res.Output.Baseinfo.PsnCertType
  16725. Certno = res.Output.Baseinfo.Certno
  16726. PsnName = res.Output.Baseinfo.PsnName
  16727. Gend = res.Output.Baseinfo.Gend
  16728. Naty = res.Output.Baseinfo.Naty
  16729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16730. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16731. infoStr = string(Iinfos)
  16732. idetinfoStr = string(Idetinfos)
  16733. infocode = res.Infcode
  16734. }
  16735. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16736. if id_card_type == 1 {
  16737. psn_info, _ := service.GetPsnByPatientId(id)
  16738. PsnNo = psn_info.PsnNo
  16739. PsnCertType = psn_info.PsnCertType
  16740. Certno = psn_info.Certno
  16741. PsnName = psn_info.PsnName
  16742. Gend = psn_info.Gend
  16743. Naty = psn_info.Naty
  16744. Brdy = psn_info.Brdy
  16745. Age = psn_info.Age
  16746. infoStr = psn_info.Insuinfo
  16747. idetinfoStr = psn_info.Idetinfo
  16748. infocode = 0
  16749. verify_number = psn_info.VerifyNumber
  16750. } else if id_card_type == 2 {
  16751. 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, "")
  16752. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16753. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16754. utils.ErrorLog("解析失败:%v", err)
  16755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16756. return
  16757. }
  16758. PsnNo = res.Output.Baseinfo.PsnNo
  16759. PsnCertType = res.Output.Baseinfo.PsnCertType
  16760. Certno = res.Output.Baseinfo.Certno
  16761. PsnName = res.Output.Baseinfo.PsnName
  16762. Gend = res.Output.Baseinfo.Gend
  16763. Naty = res.Output.Baseinfo.Naty
  16764. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16765. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16766. infoStr = string(Iinfos)
  16767. idetinfoStr = string(Idetinfos)
  16768. infocode = res.Infcode
  16769. } else {
  16770. psn_info, _ := service.GetPsnByPatientId(id)
  16771. PsnNo = psn_info.PsnNo
  16772. PsnCertType = psn_info.PsnCertType
  16773. Certno = psn_info.Certno
  16774. PsnName = psn_info.PsnName
  16775. Gend = psn_info.Gend
  16776. Naty = psn_info.Naty
  16777. Brdy = psn_info.Brdy
  16778. Age = psn_info.Age
  16779. infoStr = psn_info.Insuinfo
  16780. idetinfoStr = psn_info.Idetinfo
  16781. infocode = 0
  16782. verify_number = psn_info.VerifyNumber
  16783. }
  16784. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16785. psn_info, _ := service.GetPsnByPatientId(id)
  16786. PsnNo = psn_info.PsnNo
  16787. PsnCertType = psn_info.PsnCertType
  16788. Certno = psn_info.Certno
  16789. PsnName = psn_info.PsnName
  16790. Gend = psn_info.Gend
  16791. Naty = psn_info.Naty
  16792. Brdy = psn_info.Brdy
  16793. Age = psn_info.Age
  16794. infoStr = psn_info.Insuinfo
  16795. idetinfoStr = psn_info.Idetinfo
  16796. infocode = 0
  16797. verify_number = psn_info.VerifyNumber
  16798. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16799. if id_card_type == 1 {
  16800. psn_info, _ := service.GetPsnByPatientId(id)
  16801. PsnNo = psn_info.PsnNo
  16802. PsnCertType = psn_info.PsnCertType
  16803. Certno = psn_info.Certno
  16804. PsnName = psn_info.PsnName
  16805. Gend = psn_info.Gend
  16806. Naty = psn_info.Naty
  16807. Brdy = psn_info.Brdy
  16808. Age = psn_info.Age
  16809. infoStr = psn_info.Insuinfo
  16810. idetinfoStr = psn_info.Idetinfo
  16811. infocode = 0
  16812. verify_number = psn_info.VerifyNumber
  16813. } else if id_card_type == 2 {
  16814. 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)
  16815. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16816. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16817. utils.ErrorLog("解析失败:%v", err)
  16818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16819. return
  16820. }
  16821. PsnNo = res.Output.Baseinfo.PsnNo
  16822. PsnCertType = res.Output.Baseinfo.PsnCertType
  16823. Certno = res.Output.Baseinfo.Certno
  16824. PsnName = res.Output.Baseinfo.PsnName
  16825. Gend = res.Output.Baseinfo.Gend
  16826. Naty = res.Output.Baseinfo.Naty
  16827. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16828. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16829. infoStr = string(Iinfos)
  16830. idetinfoStr = string(Idetinfos)
  16831. infocode = res.Infcode
  16832. } else if id_card_type == 4 {
  16833. psn_info, _ := service.GetPsnByPatientId(id)
  16834. PsnNo = psn_info.PsnNo
  16835. PsnCertType = psn_info.PsnCertType
  16836. Certno = psn_info.Certno
  16837. PsnName = psn_info.PsnName
  16838. Gend = psn_info.Gend
  16839. Naty = psn_info.Naty
  16840. Brdy = psn_info.Brdy
  16841. Age = psn_info.Age
  16842. infoStr = psn_info.Insuinfo
  16843. idetinfoStr = psn_info.Idetinfo
  16844. infocode = 0
  16845. verify_number = psn_info.VerifyNumber
  16846. }
  16847. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16848. var result string
  16849. var requestLog string
  16850. 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), "")
  16851. if id_card_type == 4 {
  16852. psn_info, _ := service.GetPsnByPatientId(id)
  16853. PsnNo = psn_info.PsnNo
  16854. PsnCertType = psn_info.PsnCertType
  16855. Certno = psn_info.Certno
  16856. PsnName = psn_info.PsnName
  16857. Gend = psn_info.Gend
  16858. Naty = psn_info.Naty
  16859. Brdy = psn_info.Brdy
  16860. Age = psn_info.Age
  16861. infoStr = psn_info.Insuinfo
  16862. idetinfoStr = psn_info.Idetinfo
  16863. infocode = 0
  16864. verify_number = psn_info.VerifyNumber
  16865. } else {
  16866. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16867. if miConfig.Code == "H15049901371" {
  16868. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16869. utils.ErrorLog("解析失败:%v", err)
  16870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16871. return
  16872. }
  16873. res.ErrMsg = res10265.ErrMsg
  16874. res.Output = res10265.Output
  16875. res.InfRefmsgid = res10265.InfRefmsgid
  16876. } else {
  16877. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16878. utils.ErrorLog("解析失败:%v", err)
  16879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16880. return
  16881. }
  16882. }
  16883. PsnNo = res.Output.Baseinfo.PsnNo
  16884. PsnCertType = res.Output.Baseinfo.PsnCertType
  16885. Certno = res.Output.Baseinfo.Certno
  16886. PsnName = res.Output.Baseinfo.PsnName
  16887. Gend = res.Output.Baseinfo.Gend
  16888. Naty = res.Output.Baseinfo.Naty
  16889. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16890. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16891. infoStr = string(Iinfos)
  16892. idetinfoStr = string(Idetinfos)
  16893. if miConfig.Code == "H15049901371" {
  16894. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16895. } else {
  16896. infocode = res.Infcode
  16897. }
  16898. }
  16899. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16900. psn_info, _ := service.GetPsnByPatientId(id)
  16901. PsnNo = psn_info.PsnNo
  16902. PsnCertType = psn_info.PsnCertType
  16903. Certno = psn_info.Certno
  16904. PsnName = psn_info.PsnName
  16905. Gend = psn_info.Gend
  16906. Naty = psn_info.Naty
  16907. Brdy = psn_info.Brdy
  16908. Age = psn_info.Age
  16909. infoStr = psn_info.Insuinfo
  16910. idetinfoStr = psn_info.Idetinfo
  16911. infocode = 0
  16912. verify_number = psn_info.VerifyNumber
  16913. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16914. psn_info, _ := service.GetPsnByPatientId(id)
  16915. PsnNo = psn_info.PsnNo
  16916. PsnCertType = psn_info.PsnCertType
  16917. Certno = psn_info.Certno
  16918. PsnName = psn_info.PsnName
  16919. Gend = psn_info.Gend
  16920. Naty = psn_info.Naty
  16921. Brdy = psn_info.Brdy
  16922. Age = psn_info.Age
  16923. infoStr = psn_info.Insuinfo
  16924. idetinfoStr = psn_info.Idetinfo
  16925. infocode = 0
  16926. verify_number = psn_info.VerifyNumber
  16927. } else {
  16928. var result string
  16929. var requestLog string
  16930. //if miConfig.UserOrgId == 10138 {
  16931. if id_card_type != 4 || id_card_type != 1 {
  16932. var insa string
  16933. if len(patient.InsuplcAdmdvs) > 0 {
  16934. insa = patient.InsuplcAdmdvs
  16935. } else {
  16936. insa = miConfig.InsuplcAdmdvs
  16937. }
  16938. //psn_info, _ := service.GetPsnByPatientId(id)
  16939. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16940. 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)
  16941. }
  16942. //}
  16943. //else {
  16944. // var insa string
  16945. // if len(patient.InsuplcAdmdvs) > 0 {
  16946. // insa = patient.InsuplcAdmdvs
  16947. // } else {
  16948. // insa = miConfig.InsuplcAdmdvs
  16949. // }
  16950. // 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)
  16951. //}
  16952. if id_card_type == 4 || id_card_type == 1 {
  16953. psn_info, _ := service.GetPsnByPatientId(id)
  16954. PsnNo = psn_info.PsnNo
  16955. PsnCertType = psn_info.PsnCertType
  16956. Certno = psn_info.Certno
  16957. PsnName = psn_info.PsnName
  16958. Gend = psn_info.Gend
  16959. Naty = psn_info.Naty
  16960. Brdy = psn_info.Brdy
  16961. Age = psn_info.Age
  16962. infoStr = psn_info.Insuinfo
  16963. idetinfoStr = psn_info.Idetinfo
  16964. infocode = 0
  16965. verify_number = psn_info.VerifyNumber
  16966. } else {
  16967. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16968. if miConfig.Code == "H15049901371" {
  16969. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16970. utils.ErrorLog("解析失败:%v", err)
  16971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16972. return
  16973. }
  16974. res.ErrMsg = res10265.ErrMsg
  16975. res.Output = res10265.Output
  16976. res.InfRefmsgid = res10265.InfRefmsgid
  16977. } else {
  16978. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16979. utils.ErrorLog("解析失败:%v", err)
  16980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16981. return
  16982. }
  16983. }
  16984. PsnNo = res.Output.Baseinfo.PsnNo
  16985. PsnCertType = res.Output.Baseinfo.PsnCertType
  16986. Certno = res.Output.Baseinfo.Certno
  16987. PsnName = res.Output.Baseinfo.PsnName
  16988. Gend = res.Output.Baseinfo.Gend
  16989. Naty = res.Output.Baseinfo.Naty
  16990. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16991. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16992. infoStr = string(Iinfos)
  16993. idetinfoStr = string(Idetinfos)
  16994. if miConfig.Code == "H15049901371" {
  16995. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16996. } else {
  16997. infocode = res.Infcode
  16998. }
  16999. }
  17000. }
  17001. if infocode == 0 {
  17002. his := models.VMHisPatient{
  17003. Name: name,
  17004. Gender: gender,
  17005. Birthday: birthUnix,
  17006. MedicalTreatmentType: medical_care,
  17007. IdType: certificates,
  17008. IdCardNo: id_card,
  17009. BalanceAccountsType: settlementValue,
  17010. SocialType: social_type,
  17011. MedicalInsuranceNumber: medical_insurance_card,
  17012. RegisterType: register_type,
  17013. RegisterCost: registration_fee,
  17014. TreatmentCost: medical_expenses,
  17015. Status: 1,
  17016. Ctime: time.Now().Unix(),
  17017. Mtime: time.Now().Unix(),
  17018. PsnNo: PsnNo,
  17019. PsnCertType: PsnCertType,
  17020. Certno: Certno,
  17021. PsnName: PsnName,
  17022. Gend: Gend,
  17023. Naty: Naty,
  17024. Brdy: Brdy,
  17025. Age: Age,
  17026. Iinfo: infoStr,
  17027. Idetinfo: idetinfoStr,
  17028. PatientId: patient.ID,
  17029. RecordDate: theTime.Unix(),
  17030. UserOrgId: adminInfo.CurrentOrgId,
  17031. AdminUserId: admin_user_id,
  17032. IsReturn: 1,
  17033. IdCardType: id_card_type,
  17034. Doctor: doctor,
  17035. Departments: department,
  17036. MdtrtGrpType: mdtrt_type,
  17037. }
  17038. timestamp := time.Now().Unix()
  17039. tempTime := time.Unix(timestamp, 0)
  17040. timeFormat := tempTime.Format("20060102150405")
  17041. chrgBchno := rand.Intn(100000) + 10000
  17042. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17043. his.Number = ipt_otp_no
  17044. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17045. department, _ := service.GetDepartMentDetail(department)
  17046. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17047. IdCardNo := ""
  17048. if id_card_type == 1 {
  17049. // IdCardNo = medical_insurance_card
  17050. IdCardNo = patient.IdCardNo
  17051. } else {
  17052. IdCardNo = patient.IdCardNo
  17053. }
  17054. var rf []*ResultFive
  17055. json.Unmarshal([]byte(his.Iinfo), &rf)
  17056. var insutypes []*ResultFive
  17057. var insutype string
  17058. var insuplc_admdvs_temp string
  17059. var is390 int = 0
  17060. var is310 int = 0
  17061. for _, item := range rf {
  17062. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17063. insutypes = append(insutypes, item)
  17064. }
  17065. }
  17066. if len(insutypes) == 1 {
  17067. insutype = insutypes[0].Insutype
  17068. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17069. if insutype == "390" {
  17070. is390 = 1
  17071. }
  17072. if insutype == "310" {
  17073. is310 = 1
  17074. }
  17075. } else {
  17076. for _, i := range insutypes {
  17077. if i.Insutype == "390" {
  17078. is390 = 1
  17079. }
  17080. if i.Insutype == "310" {
  17081. is310 = 1
  17082. }
  17083. }
  17084. }
  17085. if is390 == 1 {
  17086. insutype = "390"
  17087. }
  17088. if is310 == 1 {
  17089. insutype = "310"
  17090. }
  17091. fmt.Println(social_type)
  17092. if social_type > 0 {
  17093. insutype = strconv.FormatInt(social_type, 10)
  17094. }
  17095. var infocode int64
  17096. var resThree ResultThree
  17097. var resThree10265 ResultThree10265
  17098. if len(insuplc_admdvs) == 0 {
  17099. psn_info, _ := service.GetPsnByPatientId(id)
  17100. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17101. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17102. //}
  17103. } else {
  17104. insuplc_admdvs_temp = insuplc_admdvs
  17105. }
  17106. if miConfig.MdtrtareaAdmvs == "421300" {
  17107. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17108. psn_info, _ := service.GetPsnByPatientId(id)
  17109. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17110. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17111. "&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
  17112. resp, requestErr := http.Get(api)
  17113. if requestErr != nil {
  17114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17115. return
  17116. }
  17117. body, ioErr := ioutil.ReadAll(resp.Body)
  17118. if ioErr != nil {
  17119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17121. return
  17122. }
  17123. var respJSON map[string]interface{}
  17124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17127. return
  17128. }
  17129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17130. result, _ := json.Marshal(respJSON)
  17131. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17132. utils.ErrorLog("解析失败:%v", err)
  17133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17134. return
  17135. }
  17136. infocode = resThree.Infcode
  17137. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17138. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17139. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17140. // insuplc_admdvs_temp =
  17141. //}
  17142. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17143. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17144. //}
  17145. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17146. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17147. "&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
  17148. resp, requestErr := http.Get(api)
  17149. if requestErr != nil {
  17150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17151. return
  17152. }
  17153. body, ioErr := ioutil.ReadAll(resp.Body)
  17154. if ioErr != nil {
  17155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17157. return
  17158. }
  17159. var respJSON map[string]interface{}
  17160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17163. return
  17164. }
  17165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17166. result, _ := json.Marshal(respJSON)
  17167. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17168. utils.ErrorLog("解析失败:%v", err)
  17169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17170. return
  17171. }
  17172. infocode = resThree.Infcode
  17173. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17174. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17175. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17176. // insuplc_admdvs_temp =
  17177. //}
  17178. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17179. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17180. //}
  17181. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17182. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17183. "&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
  17184. resp, requestErr := http.Get(api)
  17185. if requestErr != nil {
  17186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17187. return
  17188. }
  17189. body, ioErr := ioutil.ReadAll(resp.Body)
  17190. if ioErr != nil {
  17191. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17193. return
  17194. }
  17195. var respJSON map[string]interface{}
  17196. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17197. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17199. return
  17200. }
  17201. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17202. result, _ := json.Marshal(respJSON)
  17203. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17204. utils.ErrorLog("解析失败:%v", err)
  17205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17206. return
  17207. }
  17208. infocode = resThree.Infcode
  17209. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17210. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17211. psn_info, _ := service.GetPsnByPatientId(id)
  17212. var verify_number string
  17213. if id_card_type == 4 {
  17214. verify_number = psn_info.VerifyNumber
  17215. } else if id_card_type == 1 {
  17216. bas := strings.Split(psn_info.CardInfo, "|")
  17217. cardNumber := bas[2]
  17218. verify_number = cardNumber
  17219. }
  17220. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17221. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17222. "&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
  17223. resp, requestErr := http.Get(api)
  17224. if requestErr != nil {
  17225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17226. return
  17227. }
  17228. body, ioErr := ioutil.ReadAll(resp.Body)
  17229. if ioErr != nil {
  17230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17232. return
  17233. }
  17234. var respJSON map[string]interface{}
  17235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17238. return
  17239. }
  17240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17241. result, _ := json.Marshal(respJSON)
  17242. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17243. // utils.ErrorLog("解析失败:%v", err)
  17244. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17245. // return
  17246. //}
  17247. //infocode = resThree.Infcode
  17248. //result, _ := json.Marshal(respJSON)
  17249. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17250. utils.ErrorLog("解析失败:%v", err)
  17251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17252. return
  17253. }
  17254. resThree.ErrMsg = resThree10265.ErrMsg
  17255. resThree.Output = resThree10265.Output
  17256. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17257. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17258. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17259. psn_info, _ := service.GetPsnByPatientId(id)
  17260. his.PsnNo = psn_info.PsnNo
  17261. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17262. var cert_no string
  17263. if id_card_type == 3 {
  17264. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17265. cert_no = IdCardNo
  17266. } else if id_card_type == 4 {
  17267. cert_no = IdCardNo
  17268. psn_info.VerifyNumber = psn_info.VerifyNumber
  17269. } else {
  17270. bas := strings.Split(psn_info.CardInfo, "|")
  17271. cert_no = bas[2]
  17272. }
  17273. var hisPrescription []*models.HisPrescription
  17274. for _, item := range rf {
  17275. if item.Insutype == insutype {
  17276. //insuplc_admdvs = item.InsuplcAdmdvs
  17277. his.InsuplcAdmdvs = insuplc_admdvs
  17278. }
  17279. }
  17280. his.Insutype = insutype
  17281. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17282. fmt.Println(res3101)
  17283. fmt.Println(res3101.Infcode)
  17284. if res3101.Infcode == "0" {
  17285. fmt.Println("33333333")
  17286. if len(res3101.Output.Result) > 0 {
  17287. fmt.Println("222222")
  17288. for _, item := range res3101.Output.Result {
  17289. if len(res3101.ErrMsg) == 0 {
  17290. res3101.ErrMsg = item.VolaCont
  17291. } else {
  17292. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17293. }
  17294. }
  17295. c.ServeSuccessJSON(map[string]interface{}{
  17296. "failed_code": -10,
  17297. "msg": res3101.ErrMsg,
  17298. })
  17299. return
  17300. } else {
  17301. fmt.Println("11111")
  17302. var api string
  17303. if miConfig.MdtrtareaAdmvs == "320921" {
  17304. ipt_otp_no = timeFormat
  17305. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17306. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17307. "&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
  17308. } else {
  17309. ipt_otp_no = timeFormat
  17310. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17311. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17312. "&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
  17313. }
  17314. resp, requestErr := http.Get(api)
  17315. if requestErr != nil {
  17316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17317. return
  17318. }
  17319. body, ioErr := ioutil.ReadAll(resp.Body)
  17320. if ioErr != nil {
  17321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17323. return
  17324. }
  17325. var respJSON map[string]interface{}
  17326. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17329. return
  17330. }
  17331. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17332. result, _ := json.Marshal(respJSON)
  17333. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17334. utils.ErrorLog("解析失败:%v", err)
  17335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17336. return
  17337. }
  17338. resThree.ErrMsg = resThree10265.ErrMsg
  17339. resThree.Output = resThree10265.Output
  17340. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17341. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17342. }
  17343. } else if res3101.Infcode != "0" {
  17344. c.ServeSuccessJSON(map[string]interface{}{
  17345. "failed_code": -10,
  17346. "msg": res3101.ErrMsg,
  17347. })
  17348. return
  17349. }
  17350. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17351. psn_info, _ := service.GetPsnByPatientId(id)
  17352. var cert_no string
  17353. if id_card_type == 1 {
  17354. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17355. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17356. } else if id_card_type == 4 {
  17357. cert_no = psn_info.VerifyNumber
  17358. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17359. } else {
  17360. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17361. cert_no = psn_info.VerifyNumber
  17362. }
  17363. 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)
  17364. saveLog(result, requestLog, "2201", "挂号")
  17365. if miConfig.Code == "H15049901371" {
  17366. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17367. utils.ErrorLog("解析失败:%v", err)
  17368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17369. return
  17370. }
  17371. resThree.ErrMsg = resThree10265.ErrMsg
  17372. resThree.Output = resThree10265.Output
  17373. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17374. } else {
  17375. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17376. utils.ErrorLog("解析失败:%v", err)
  17377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17378. return
  17379. }
  17380. }
  17381. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17382. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17383. psn_info, _ := service.GetPsnByPatientId(id)
  17384. var result string
  17385. var requestLog string
  17386. if id_card_type == 1 {
  17387. bas := strings.Split(psn_info.CardInfo, "|")
  17388. basNumber := bas[2]
  17389. card_sn := bas[3]
  17390. 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)
  17391. saveLog(result, requestLog, "2201A", "挂号")
  17392. } else if id_card_type == 2 {
  17393. 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, "", "", "", "", "", "")
  17394. saveLog(result, requestLog, "2201A", "挂号")
  17395. } else {
  17396. 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)
  17397. saveLog(result, requestLog, "2201A", "挂号")
  17398. }
  17399. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17400. utils.ErrorLog("解析失败:%v", err)
  17401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17402. return
  17403. }
  17404. infocode = resThree.Infcode
  17405. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17406. psn_info, _ := service.GetPsnByPatientId(id)
  17407. his.PsnNo = psn_info.PsnNo
  17408. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17409. var cert_no string
  17410. if id_card_type == 1 {
  17411. bas := strings.Split(psn_info.CardInfo, "|")
  17412. cert_no = bas[2]
  17413. } else if id_card_type == 4 {
  17414. cert_no = IdCardNo
  17415. psn_info.VerifyNumber = psn_info.VerifyNumber
  17416. } else {
  17417. cert_no = IdCardNo
  17418. psn_info.VerifyNumber = cert_no
  17419. }
  17420. for _, item := range rf {
  17421. if item.Insutype == insutype {
  17422. his.InsuplcAdmdvs = insuplc_admdvs
  17423. }
  17424. }
  17425. his.Insutype = insutype
  17426. var api string
  17427. ipt_otp_no = timeFormat
  17428. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17429. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17430. "&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
  17431. resp, requestErr := http.Get(api)
  17432. if requestErr != nil {
  17433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17434. return
  17435. }
  17436. body, ioErr := ioutil.ReadAll(resp.Body)
  17437. if ioErr != nil {
  17438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17440. return
  17441. }
  17442. var respJSON map[string]interface{}
  17443. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17446. return
  17447. }
  17448. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17449. if status == "0" {
  17450. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17451. c.ServeSuccessJSON(map[string]interface{}{
  17452. "failed_code": -10,
  17453. "msg": err_msg,
  17454. })
  17455. return
  17456. }
  17457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17458. result, _ := json.Marshal(respJSON)
  17459. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17460. utils.ErrorLog("解析失败:%v", err)
  17461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17462. return
  17463. }
  17464. infocode = resThree.Infcode
  17465. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17466. psn_info, _ := service.GetPsnByPatientId(id)
  17467. var result string
  17468. var requestLog string
  17469. if id_card_type == 1 {
  17470. bas := strings.Split(psn_info.CardInfo, "|")
  17471. basNumber := bas[2]
  17472. card_sn := bas[3]
  17473. 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)
  17474. saveLog(result, requestLog, "2201A", "挂号")
  17475. } else if id_card_type == 2 {
  17476. 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, "", "")
  17477. saveLog(result, requestLog, "2201A", "挂号")
  17478. } else {
  17479. 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, "", "")
  17480. saveLog(result, requestLog, "2201A", "挂号")
  17481. }
  17482. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17483. utils.ErrorLog("解析失败:%v", err)
  17484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17485. return
  17486. }
  17487. infocode = resThree.Infcode
  17488. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17489. psn_info, _ := service.GetPsnByPatientId(id)
  17490. 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)
  17491. saveLog(result, requestLog, "2201A", "挂号")
  17492. if miConfig.Code == "H15049901371" {
  17493. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17494. utils.ErrorLog("解析失败:%v", err)
  17495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17496. return
  17497. }
  17498. resThree.ErrMsg = resThree10265.ErrMsg
  17499. resThree.Output = resThree10265.Output
  17500. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17501. } else {
  17502. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17503. utils.ErrorLog("解析失败:%v", err)
  17504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17505. return
  17506. }
  17507. }
  17508. if miConfig.Code == "H15049901371" {
  17509. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17510. } else {
  17511. infocode = resThree.Infcode
  17512. }
  17513. } else {
  17514. psn_info, _ := service.GetPsnByPatientId(id)
  17515. if id_card_type == 4 || id_card_type == 1 {
  17516. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17517. }
  17518. var rf []*ResultFive
  17519. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17520. var insutypes []*ResultFive
  17521. var insutype string
  17522. var is390 int = 0
  17523. var is310 int = 0
  17524. for _, item := range rf {
  17525. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17526. insutypes = append(insutypes, item)
  17527. }
  17528. }
  17529. if len(insutypes) == 1 {
  17530. insutype = insutypes[0].Insutype
  17531. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17532. } else {
  17533. for _, i := range insutypes {
  17534. if i.Insutype == "390" {
  17535. is390 = 1
  17536. }
  17537. if i.Insutype == "310" {
  17538. is310 = 1
  17539. }
  17540. }
  17541. }
  17542. if is390 == 1 {
  17543. insutype = "390"
  17544. }
  17545. if is310 == 1 {
  17546. insutype = "310"
  17547. }
  17548. fmt.Println(len(insutypes))
  17549. if len(insutypes) == 0 {
  17550. for index, item := range rf {
  17551. if index == 0 {
  17552. insutype = item.Insutype
  17553. insuplc_admdvs = item.InsuplcAdmdvs
  17554. }
  17555. }
  17556. fmt.Println(insutype)
  17557. fmt.Println(insuplc_admdvs)
  17558. }
  17559. if social_type > 0 {
  17560. insutype = strconv.FormatInt(social_type, 10)
  17561. }
  17562. fmt.Println("--------")
  17563. fmt.Println(psn_info)
  17564. fmt.Println(psn_info.PsnNo)
  17565. if miConfig.MdtrtareaAdmvs == "441202" {
  17566. var hisPrescription []*models.HisPrescription
  17567. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17568. if res3101.Infcode == 0 {
  17569. fmt.Println("33333333")
  17570. if len(res3101.Output.Result) > 0 {
  17571. fmt.Println("222222")
  17572. for _, item := range res3101.Output.Result {
  17573. if len(res3101.ErrMsg) == 0 {
  17574. res3101.ErrMsg = item.VolaCont
  17575. } else {
  17576. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17577. }
  17578. }
  17579. c.ServeSuccessJSON(map[string]interface{}{
  17580. "failed_code": -10,
  17581. "msg": res3101.ErrMsg,
  17582. })
  17583. return
  17584. } else {
  17585. hour := time.Now().Format("15")
  17586. min := time.Now().Format("04")
  17587. sec := time.Now().Format("05")
  17588. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17589. fmt.Println(record_time_two)
  17590. 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)
  17591. saveLog(result, requestLog, "2201A", "挂号")
  17592. if miConfig.Code == "H15049901371" {
  17593. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17594. utils.ErrorLog("解析失败:%v", err)
  17595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17596. return
  17597. }
  17598. resThree.ErrMsg = resThree10265.ErrMsg
  17599. resThree.Output = resThree10265.Output
  17600. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17601. } else {
  17602. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17603. utils.ErrorLog("解析失败:%v", err)
  17604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17605. return
  17606. }
  17607. }
  17608. if miConfig.Code == "H15049901371" {
  17609. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17610. } else {
  17611. infocode = resThree.Infcode
  17612. }
  17613. }
  17614. } else if res3101.Infcode != 0 {
  17615. c.ServeSuccessJSON(map[string]interface{}{
  17616. "failed_code": -10,
  17617. "msg": res3101.ErrMsg,
  17618. })
  17619. return
  17620. }
  17621. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17622. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17623. psn_info, _ := service.GetPsnByPatientId(id)
  17624. var verify_number string
  17625. if id_card_type == 4 {
  17626. verify_number = psn_info.VerifyNumber
  17627. } else if id_card_type == 1 {
  17628. bas := strings.Split(psn_info.CardInfo, "|")
  17629. cardNumber := bas[2]
  17630. verify_number = cardNumber
  17631. } else {
  17632. verify_number = psn_info.Certno
  17633. }
  17634. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17635. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17636. "&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
  17637. resp, requestErr := http.Get(api)
  17638. if requestErr != nil {
  17639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17640. return
  17641. }
  17642. body, ioErr := ioutil.ReadAll(resp.Body)
  17643. if ioErr != nil {
  17644. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17646. return
  17647. }
  17648. var respJSON map[string]interface{}
  17649. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17650. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17652. return
  17653. }
  17654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17655. result, _ := json.Marshal(respJSON)
  17656. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17657. utils.ErrorLog("解析失败:%v", err)
  17658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17659. return
  17660. }
  17661. infocode = resThree.Infcode
  17662. } else {
  17663. hour := time.Now().Format("15")
  17664. min := time.Now().Format("04")
  17665. sec := time.Now().Format("05")
  17666. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17667. if id_card_type == 1 {
  17668. for _, item := range rf {
  17669. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17670. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17671. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17672. } else if strconv.FormatInt(social_type, 10) == "390" {
  17673. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17674. } else {
  17675. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17676. }
  17677. }
  17678. }
  17679. }
  17680. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17681. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17682. }
  17683. if id_card_type == 1 {
  17684. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17685. bas := strings.Split(psn_info.CardInfo, "|")
  17686. basNumber := bas[1]
  17687. IdCardNo = basNumber
  17688. }
  17689. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17690. IdCardNo = psn_info.VerifyNumber
  17691. }
  17692. 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)
  17693. saveLog(result, requestLog, "2201A", "挂号")
  17694. if miConfig.Code == "H15049901371" {
  17695. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17696. utils.ErrorLog("解析失败:%v", err)
  17697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17698. return
  17699. }
  17700. resThree.ErrMsg = resThree10265.ErrMsg
  17701. resThree.Output = resThree10265.Output
  17702. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17703. } else {
  17704. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17705. utils.ErrorLog("解析失败:%v", err)
  17706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17707. return
  17708. }
  17709. }
  17710. if miConfig.Code == "H15049901371" {
  17711. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17712. } else {
  17713. infocode = resThree.Infcode
  17714. }
  17715. }
  17716. }
  17717. if infocode != 0 {
  17718. adminUser := c.GetAdminUserInfo()
  17719. errlog := &models.HisOrderError{
  17720. UserOrgId: adminUser.CurrentOrgId,
  17721. Ctime: time.Now().Unix(),
  17722. Mtime: time.Now().Unix(),
  17723. ErrMsg: resThree.ErrMsg,
  17724. Status: 1,
  17725. PatientId: id,
  17726. RecordTime: recordDateTime,
  17727. Stage: 2,
  17728. }
  17729. service.CreateErrMsgLog(errlog)
  17730. c.ServeSuccessJSON(map[string]interface{}{
  17731. "failed_code": -10,
  17732. "msg": resThree.ErrMsg,
  17733. })
  17734. return
  17735. }
  17736. his.Number = resThree.Output.Data.MdtrtID
  17737. his.PsnNo = resThree.Output.Data.PsnNo
  17738. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17739. his.IdCardNo = patient.IdCardNo
  17740. his.PhoneNumber = patient.Phone
  17741. his.UserOrgId = adminInfo.CurrentOrgId
  17742. his.Insutype = insutype
  17743. his.Ctime = time.Now().Unix()
  17744. his.Mtime = time.Now().Unix()
  17745. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17746. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17747. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17748. }
  17749. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17750. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17751. }
  17752. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17753. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17754. }
  17755. his.Status = 1
  17756. his.MdtrtGrpType = mdtrt_type
  17757. service.UpdateHisPatientStatus(&his)
  17758. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17759. c.ServeSuccessJSON(map[string]interface{}{
  17760. "his_info": his,
  17761. })
  17762. } else {
  17763. adminUser := c.GetAdminUserInfo()
  17764. errlog := &models.HisOrderError{
  17765. UserOrgId: adminUser.CurrentOrgId,
  17766. Ctime: time.Now().Unix(),
  17767. Mtime: time.Now().Unix(),
  17768. ErrMsg: res.ErrMsg,
  17769. Status: 1,
  17770. PatientId: id,
  17771. RecordTime: recordDateTime,
  17772. Stage: 1,
  17773. }
  17774. service.CreateErrMsgLog(errlog)
  17775. c.ServeSuccessJSON(map[string]interface{}{
  17776. "failed_code": -10,
  17777. "msg": res.ErrMsg,
  17778. })
  17779. return
  17780. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17781. }
  17782. }
  17783. }
  17784. func (c *HisApiController) GetUploadInfo() {
  17785. id, _ := c.GetInt64("id")
  17786. record_time := c.GetString("record_time")
  17787. his_patient_id, _ := c.GetInt64("his_patient_id")
  17788. order_id, _ := c.GetInt64("order_id")
  17789. pay_way, _ := c.GetInt64("pay_way")
  17790. pay_ways := c.GetString("pay_ways")
  17791. oth_desc := c.GetString("oth_desc")
  17792. pay_price, _ := c.GetFloat("pay_price")
  17793. pay_card_no := c.GetString("pay_card_no")
  17794. discount_price, _ := c.GetFloat("discount_price")
  17795. preferential_price, _ := c.GetFloat("preferential_price")
  17796. reality_price, _ := c.GetFloat("reality_price")
  17797. found_price, _ := c.GetFloat("found_price")
  17798. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17799. private_price, _ := c.GetFloat("private_price")
  17800. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17801. admin_user_id, _ := c.GetInt64("admin_user_id")
  17802. fapiao_code := c.GetString("fapiao_code")
  17803. fapiao_number := c.GetString("fapiao_number")
  17804. diagnosis_id := c.GetString("diagnosis")
  17805. sick_type, _ := c.GetInt64("sick_type")
  17806. reg_type, _ := c.GetInt64("p_type")
  17807. begin_time := c.GetString("begin_time")
  17808. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17809. cash_pay := c.GetString("cash_pay")
  17810. band_card_pay := c.GetString("band_card_pay")
  17811. wechat_pay := c.GetString("wechat_pay")
  17812. ali_pay := c.GetString("ali_pay")
  17813. jifen_pay := c.GetString("jifen_pay")
  17814. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17815. fmt.Println(acct_used_flag)
  17816. id_str := c.GetString("ids")
  17817. ids_arr := strings.Split(id_str, ",")
  17818. timeLayout := "2006-01-02"
  17819. loc, _ := time.LoadLocation("Local")
  17820. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17821. if err != nil {
  17822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17823. return
  17824. }
  17825. recordDateTime := theTime.Unix()
  17826. adminUser := c.GetAdminUserInfo()
  17827. var tempOrder models.HisOrder
  17828. tempOrder, _ = service.GetHisOrderByID(order_id)
  17829. var prescriptions []*models.HisPrescription
  17830. var start_time int64
  17831. var end_time int64
  17832. //押金模块
  17833. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17834. tmp_decimal := c.GetString("tmp_decimal")
  17835. var decimal float64 //本次使用的押金
  17836. var errmsg error
  17837. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17838. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17839. return
  17840. }
  17841. if len(tmp_decimal) > 0 {
  17842. if tmp_decimal[0] == 45 {
  17843. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17844. return
  17845. }
  17846. }
  17847. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17848. fmt.Println(errs)
  17849. decimal = tt
  17850. //if adminUser.CurrentOrgId == 10106{
  17851. // if len(fapiao_code) == 0{
  17852. // fapiao_code = "144072080589"
  17853. // }
  17854. // if len(fapiao_number) == 0{
  17855. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17856. // if order.ID == 0{
  17857. // fapiao_number = "00001520"
  17858. // }else{
  17859. // //fapiao_code = "00001520"
  17860. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17861. // var zero string
  17862. // if fpNumber >= 1000{
  17863. // zero = "0000" + strconv.Itoa(fpNumber)
  17864. // }else if fpNumber >= 10000{
  17865. // zero = "000" + strconv.Itoa(fpNumber)
  17866. // } else if fpNumber >= 100000{
  17867. // zero = "00" + strconv.Itoa(fpNumber)
  17868. // } else if fpNumber >= 1000000{
  17869. // zero = "0" + strconv.Itoa(fpNumber)
  17870. // }else {
  17871. // zero = strconv.Itoa(fpNumber)
  17872. // }
  17873. // fapiao_number = zero
  17874. // }
  17875. // }
  17876. //}
  17877. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17878. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17879. var patientPrescription models.HisPrescriptionInfo
  17880. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17881. if patientPrescription.ID == 0 {
  17882. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17883. }
  17884. //if patientPrescription.Do
  17885. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17886. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17887. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17888. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17889. var config []*models.HisXtDiagnoseConfig
  17890. for _, item := range diagnosis_ids {
  17891. id, _ := strconv.ParseInt(item, 10, 64)
  17892. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17893. config = append(config, &diagnosisConfig)
  17894. }
  17895. sickConfig, _ := service.FindSickById(sick_type)
  17896. //if tempOrder.ID == 0 {
  17897. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17898. //}
  17899. if tempOrder.ID == 0 {
  17900. var result string
  17901. var requestLog string
  17902. var res2 ResultSix
  17903. var res3 GZResultSix
  17904. var ressix10265 ResultSix10265
  17905. if miConfig.MdtrtareaAdmvs == "421300" {
  17906. data := make(map[string]interface{})
  17907. client := &http.Client{}
  17908. data["psn_no"] = his.PsnNo
  17909. data["mdtrt_id"] = his.Number
  17910. data["opter"] = roles.UserName
  17911. data["org_name"] = miConfig.OrgName
  17912. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17913. data["doctor_id"] = doctor_info.DoctorNumber
  17914. data["doctor_name"] = doctor_info.UserName
  17915. data["department"] = department.Name
  17916. data["fixmedins_code"] = miConfig.Code
  17917. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17918. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17919. data["secret_key"] = miConfig.SecretKey
  17920. data["sick_code"] = sickConfig.CountryCode
  17921. data["sick_name"] = sickConfig.ClassName
  17922. data["dept"] = strconv.FormatInt(department.ID, 10)
  17923. data["config"] = config
  17924. data["begin_time"] = begin_time
  17925. bytesData, _ := json.Marshal(data)
  17926. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17927. resp, _ := client.Do(req)
  17928. defer resp.Body.Close()
  17929. body, ioErr := ioutil.ReadAll(resp.Body)
  17930. if ioErr != nil {
  17931. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17933. return
  17934. }
  17935. var respJSON map[string]interface{}
  17936. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17937. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17939. return
  17940. }
  17941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17942. userJSONBytes, _ := json.Marshal(respJSON)
  17943. fmt.Println("log")
  17944. fmt.Println(string(userJSONBytes))
  17945. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17946. utils.ErrorLog("解析失败:%v", err)
  17947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17948. return
  17949. }
  17950. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17951. data := make(map[string]interface{})
  17952. client := &http.Client{}
  17953. data["psn_no"] = his.PsnNo
  17954. data["mdtrt_id"] = his.Number
  17955. data["opter"] = roles.UserName
  17956. data["org_name"] = miConfig.OrgName
  17957. if reg_type == 11 && his.Insutype == "390" {
  17958. data["med_type"] = "110104"
  17959. } else {
  17960. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17961. }
  17962. data["doctor_id"] = doctor_info.DoctorNumber
  17963. data["doctor_name"] = doctor_info.UserName
  17964. data["department"] = department.Name
  17965. data["fixmedins_code"] = miConfig.Code
  17966. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17967. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17968. data["secret_key"] = miConfig.SecretKey
  17969. data["sick_code"] = sickConfig.CountryCode
  17970. data["sick_name"] = sickConfig.ClassName
  17971. data["dept"] = strconv.FormatInt(department.ID, 10)
  17972. data["config"] = config
  17973. data["begin_time"] = begin_time
  17974. bytesData, _ := json.Marshal(data)
  17975. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17976. resp, _ := client.Do(req)
  17977. defer resp.Body.Close()
  17978. body, ioErr := ioutil.ReadAll(resp.Body)
  17979. if ioErr != nil {
  17980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17982. return
  17983. }
  17984. var respJSON map[string]interface{}
  17985. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17988. return
  17989. }
  17990. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17991. userJSONBytes, _ := json.Marshal(respJSON)
  17992. fmt.Println("log")
  17993. fmt.Println(string(userJSONBytes))
  17994. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17995. utils.ErrorLog("解析失败:%v", err)
  17996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17997. return
  17998. }
  17999. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18000. data := make(map[string]interface{})
  18001. client := &http.Client{}
  18002. data["psn_no"] = his.PsnNo
  18003. data["mdtrt_id"] = his.Number
  18004. data["opter"] = roles.UserName
  18005. data["org_name"] = miConfig.OrgName
  18006. if reg_type == 11 && his.Insutype == "390" {
  18007. data["med_type"] = "110104"
  18008. } else {
  18009. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18010. }
  18011. data["doctor_id"] = doctor_info.DoctorNumber
  18012. data["doctor_name"] = doctor_info.UserName
  18013. data["department"] = department.Name
  18014. data["fixmedins_code"] = miConfig.Code
  18015. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18016. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18017. data["secret_key"] = miConfig.SecretKey
  18018. data["sick_code"] = sickConfig.CountryCode
  18019. data["sick_name"] = sickConfig.ClassName
  18020. data["dept"] = strconv.FormatInt(department.ID, 10)
  18021. data["config"] = config
  18022. data["begin_time"] = begin_time
  18023. bytesData, _ := json.Marshal(data)
  18024. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18025. resp, _ := client.Do(req)
  18026. defer resp.Body.Close()
  18027. body, ioErr := ioutil.ReadAll(resp.Body)
  18028. if ioErr != nil {
  18029. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18031. return
  18032. }
  18033. var respJSON map[string]interface{}
  18034. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18035. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18037. return
  18038. }
  18039. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18040. userJSONBytes, _ := json.Marshal(respJSON)
  18041. fmt.Println("log")
  18042. fmt.Println(string(userJSONBytes))
  18043. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18044. utils.ErrorLog("解析失败:%v", err)
  18045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18046. return
  18047. }
  18048. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18049. data := make(map[string]interface{})
  18050. client := &http.Client{}
  18051. data["psn_no"] = his.PsnNo
  18052. data["mdtrt_id"] = his.Number
  18053. data["doctor"] = roles.UserName
  18054. data["department"] = department.Name
  18055. data["org_name"] = miConfig.OrgName
  18056. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18057. data["doctor_id"] = doctor_info.DoctorNumber
  18058. data["new_doctor_name"] = doctor_info.UserName
  18059. data["fixmedins_code"] = miConfig.Code
  18060. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18061. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18062. data["secret_key"] = miConfig.SecretKey
  18063. data["sick_code"] = sickConfig.CountryCode
  18064. data["sick_name"] = sickConfig.ClassName
  18065. data["url"] = miConfig.Url
  18066. data["ak"] = miConfig.AccessKey
  18067. data["begin_time"] = begin_time
  18068. data["cainfo"] = miConfig.Cainfo
  18069. data["dept"] = strconv.FormatInt(department.ID, 10)
  18070. data["config"] = config
  18071. bytesData, _ := json.Marshal(data)
  18072. var req *http.Request
  18073. if miConfig.MdtrtareaAdmvs == "320921" {
  18074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18075. //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 +
  18076. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18077. } else {
  18078. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18079. }
  18080. resp, _ := client.Do(req)
  18081. defer resp.Body.Close()
  18082. body, ioErr := ioutil.ReadAll(resp.Body)
  18083. if ioErr != nil {
  18084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18086. return
  18087. }
  18088. var respJSON map[string]interface{}
  18089. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18092. return
  18093. }
  18094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18095. userJSONBytes, _ := json.Marshal(respJSON)
  18096. fmt.Println("log")
  18097. fmt.Println(string(userJSONBytes))
  18098. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18099. utils.ErrorLog("解析失败:%v", err)
  18100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18101. return
  18102. }
  18103. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18104. res2.Output = ressix10265.Output
  18105. res2.ErrMsg = ressix10265.ErrMsg
  18106. res2.Cainfo = ressix10265.Cainfo
  18107. res2.WarnMsg = ressix10265.WarnMsg
  18108. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18109. res2.Infcode = infocode
  18110. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18111. data := make(map[string]interface{})
  18112. client := &http.Client{}
  18113. data["psn_no"] = his.PsnNo
  18114. data["mdtrt_id"] = his.Number
  18115. data["doctor"] = roles.UserName
  18116. data["department"] = department.Name
  18117. data["org_name"] = miConfig.OrgName
  18118. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18119. data["doctor_id"] = doctor_info.DoctorNumber
  18120. data["new_doctor_name"] = doctor_info.UserName
  18121. data["fixmedins_code"] = miConfig.Code
  18122. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18123. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18124. data["secret_key"] = miConfig.SecretKey
  18125. data["sick_code"] = sickConfig.CountryCode
  18126. data["sick_name"] = sickConfig.ClassName
  18127. data["url"] = miConfig.Url
  18128. data["ak"] = miConfig.AccessKey
  18129. data["begin_time"] = begin_time
  18130. data["cainfo"] = miConfig.Cainfo
  18131. data["dept"] = strconv.FormatInt(department.ID, 10)
  18132. data["config"] = config
  18133. bytesData, _ := json.Marshal(data)
  18134. var req *http.Request
  18135. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18136. resp, _ := client.Do(req)
  18137. defer resp.Body.Close()
  18138. body, ioErr := ioutil.ReadAll(resp.Body)
  18139. if ioErr != nil {
  18140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18142. return
  18143. }
  18144. var respJSON map[string]interface{}
  18145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18148. return
  18149. }
  18150. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18151. userJSONBytes, _ := json.Marshal(respJSON)
  18152. fmt.Println("log")
  18153. fmt.Println(string(userJSONBytes))
  18154. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18155. utils.ErrorLog("解析失败:%v", err)
  18156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18157. return
  18158. }
  18159. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18160. res2.Output = ressix10265.Output
  18161. res2.ErrMsg = ressix10265.ErrMsg
  18162. res2.Cainfo = ressix10265.Cainfo
  18163. res2.WarnMsg = ressix10265.WarnMsg
  18164. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18165. res2.Infcode = infocode
  18166. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18167. 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)
  18168. saveLog(result, requestLog, "2203", "上传就诊信息")
  18169. var respJSON2 map[string]interface{}
  18170. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18173. return
  18174. }
  18175. userJSONBytes2, _ := json.Marshal(respJSON2)
  18176. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18177. utils.ErrorLog("解析失败:%v", err)
  18178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18179. return
  18180. }
  18181. 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)
  18182. fmt.Println(result2)
  18183. fmt.Println(src_request)
  18184. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18185. data := make(map[string]interface{})
  18186. client := &http.Client{}
  18187. data["psn_no"] = his.PsnNo
  18188. data["mdtrt_id"] = his.Number
  18189. data["doctor"] = roles.UserName
  18190. data["department"] = department.Name
  18191. data["org_name"] = miConfig.OrgName
  18192. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18193. data["doctor_id"] = doctor_info.DoctorNumber
  18194. data["new_doctor_name"] = doctor_info.UserName
  18195. data["fixmedins_code"] = miConfig.Code
  18196. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18197. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18198. data["secret_key"] = miConfig.SecretKey
  18199. data["sick_code"] = sickConfig.CountryCode
  18200. data["sick_name"] = sickConfig.ClassName
  18201. data["url"] = miConfig.Url
  18202. data["ak"] = miConfig.AccessKey
  18203. data["begin_time"] = begin_time
  18204. data["cainfo"] = miConfig.Cainfo
  18205. data["dept"] = strconv.FormatInt(department.ID, 10)
  18206. data["config"] = config
  18207. bytesData, _ := json.Marshal(data)
  18208. var req *http.Request
  18209. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18210. resp, _ := client.Do(req)
  18211. defer resp.Body.Close()
  18212. body, ioErr := ioutil.ReadAll(resp.Body)
  18213. if ioErr != nil {
  18214. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18216. return
  18217. }
  18218. var respJSON map[string]interface{}
  18219. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18222. return
  18223. }
  18224. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18225. userJSONBytes, _ := json.Marshal(respJSON)
  18226. fmt.Println("log")
  18227. fmt.Println(string(userJSONBytes))
  18228. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18229. utils.ErrorLog("解析失败:%v", err)
  18230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18231. return
  18232. }
  18233. } else {
  18234. if miConfig.MdtrtareaAdmvs == "440781" { //
  18235. 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)
  18236. } else {
  18237. if miConfig.Code == "H15049901371" {
  18238. //赤峰地区国家医保医疗类别
  18239. //职工透析:医疗类别选特殊情况门诊990502
  18240. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18241. var med_type string
  18242. if his.Insutype == "390" {
  18243. if reg_type == 14 {
  18244. med_type = "9933"
  18245. } else if reg_type == 11 {
  18246. med_type = "11"
  18247. }
  18248. } else if his.Insutype == "310" {
  18249. if reg_type == 14 {
  18250. med_type = "990502"
  18251. } else if reg_type == 11 {
  18252. med_type = "11"
  18253. }
  18254. }
  18255. 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)
  18256. } else {
  18257. 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)
  18258. }
  18259. }
  18260. saveLog(result, requestLog, "2203", "上传就诊信息")
  18261. var respJSON2 map[string]interface{}
  18262. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18265. return
  18266. }
  18267. userJSONBytes2, _ := json.Marshal(respJSON2)
  18268. if miConfig.Code == "H15049901371" {
  18269. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18270. utils.ErrorLog("解析失败:%v", err)
  18271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18272. return
  18273. }
  18274. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18275. res2.Output = ressix10265.Output
  18276. res2.ErrMsg = ressix10265.ErrMsg
  18277. res2.Cainfo = ressix10265.Cainfo
  18278. res2.WarnMsg = ressix10265.WarnMsg
  18279. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18280. res2.Infcode = infocode
  18281. } else {
  18282. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18283. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18284. utils.ErrorLog("解析失败:%v", err)
  18285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18286. return
  18287. }
  18288. res2.Infcode = res3.Infcode
  18289. } else {
  18290. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18291. utils.ErrorLog("解析失败:%v", err)
  18292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18293. return
  18294. }
  18295. }
  18296. }
  18297. }
  18298. if res2.Infcode != 0 {
  18299. adminUser := c.GetAdminUserInfo()
  18300. errlog := &models.HisOrderError{
  18301. UserOrgId: adminUser.CurrentOrgId,
  18302. Ctime: time.Now().Unix(),
  18303. Mtime: time.Now().Unix(),
  18304. ErrMsg: res2.ErrMsg,
  18305. Status: 1,
  18306. PatientId: id,
  18307. RecordTime: recordDateTime,
  18308. Stage: 3,
  18309. }
  18310. service.CreateErrMsgLog(errlog)
  18311. c.ServeSuccessJSON(map[string]interface{}{
  18312. "failed_code": -10,
  18313. "msg": res2.ErrMsg,
  18314. })
  18315. return
  18316. } else {
  18317. his.Diagnosis = diagnosis_id
  18318. his.SickType = sickConfig.ID
  18319. //var p_type int64
  18320. //if reg_type == 1111 || reg_type == 1112 {
  18321. // p_type = 11
  18322. //
  18323. //}
  18324. his.PType = fmt.Sprintf("%d", reg_type)
  18325. service.UpdateHisPatientThree(&his)
  18326. data := make(map[string]interface{})
  18327. if settle_accounts_type == 1 { //日结
  18328. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18329. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18330. } else {
  18331. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18332. }
  18333. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18334. data["pre"] = prescriptions
  18335. } else { //月结
  18336. start_time_str := c.GetString("start_time")
  18337. end_time_str := c.GetString("end_time")
  18338. timeLayout := "2006-01-02"
  18339. loc, _ := time.LoadLocation("Local")
  18340. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18341. if err != nil {
  18342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18343. return
  18344. }
  18345. recordStartTime := theStartTime.Unix()
  18346. start_time = recordStartTime
  18347. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18348. if err != nil {
  18349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18350. return
  18351. }
  18352. recordEndTime := theEndTime.Unix()
  18353. end_time = recordEndTime
  18354. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18355. data["pre"] = prescriptions
  18356. }
  18357. timestamp := time.Now().Unix()
  18358. tempTime := time.Unix(timestamp, 0)
  18359. timeFormat := tempTime.Format("20060102150405")
  18360. chrgBchno := rand.Intn(100000) + 10000
  18361. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18362. strconv.FormatInt(his.PatientId, 10)
  18363. client := &http.Client{}
  18364. data["psn_no"] = his.PsnNo
  18365. data["mdtrt_id"] = his.Number
  18366. data["chrg_bchno"] = chrg_bchno
  18367. data["org_name"] = miConfig.OrgName
  18368. data["doctor"] = doctor_info.UserName
  18369. data["doctor_id"] = doctor_info.DoctorNumber
  18370. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18371. data["fixmedins_code"] = miConfig.Code
  18372. data["dept_code"] = department.Number
  18373. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18374. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18375. data["secret_key"] = miConfig.SecretKey
  18376. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18377. data["url"] = miConfig.Url
  18378. data["ak"] = miConfig.AccessKey
  18379. data["new_doctor_name"] = patientPrescription.Doctor
  18380. data["diag_code"] = sickConfig.CountryCode
  18381. data["cainfo"] = miConfig.Cainfo
  18382. data["opter"] = roles.UserName
  18383. var ids []int64
  18384. for _, item := range prescriptions {
  18385. ids = append(ids, item.ID)
  18386. }
  18387. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18388. if config.IsOpen == 1 { //对接了医保,走医保流程
  18389. var res ResultFour
  18390. var resFour10265 ResultFour10265
  18391. if miConfig.MdtrtareaAdmvs == "421300" {
  18392. bytesData, _ := json.Marshal(data)
  18393. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18394. resp, _ := client.Do(req)
  18395. defer resp.Body.Close()
  18396. body, ioErr := ioutil.ReadAll(resp.Body)
  18397. if ioErr != nil {
  18398. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18400. return
  18401. }
  18402. var respJSON map[string]interface{}
  18403. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18404. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18406. return
  18407. }
  18408. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18409. userJSONBytes, _ := json.Marshal(respJSON)
  18410. fmt.Println("log")
  18411. fmt.Println(string(userJSONBytes))
  18412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18413. utils.ErrorLog("解析失败:%v", err)
  18414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18415. return
  18416. }
  18417. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18418. bytesData, _ := json.Marshal(data)
  18419. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18420. resp, _ := client.Do(req)
  18421. defer resp.Body.Close()
  18422. body, ioErr := ioutil.ReadAll(resp.Body)
  18423. if ioErr != nil {
  18424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18426. return
  18427. }
  18428. var respJSON map[string]interface{}
  18429. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18432. return
  18433. }
  18434. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18435. userJSONBytes, _ := json.Marshal(respJSON)
  18436. fmt.Println("log")
  18437. fmt.Println(string(userJSONBytes))
  18438. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18439. utils.ErrorLog("解析失败:%v", err)
  18440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18441. return
  18442. }
  18443. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18444. bytesData, _ := json.Marshal(data)
  18445. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18446. resp, _ := client.Do(req)
  18447. defer resp.Body.Close()
  18448. body, ioErr := ioutil.ReadAll(resp.Body)
  18449. if ioErr != nil {
  18450. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18452. return
  18453. }
  18454. var respJSON map[string]interface{}
  18455. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18456. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18458. return
  18459. }
  18460. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18461. userJSONBytes, _ := json.Marshal(respJSON)
  18462. fmt.Println("log")
  18463. fmt.Println(string(userJSONBytes))
  18464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18465. utils.ErrorLog("解析失败:%v", err)
  18466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18467. return
  18468. }
  18469. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18470. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18471. if result3101.Infcode == "0" {
  18472. if len(result3101.Output.Result) > 0 {
  18473. var errMsgs []string
  18474. for _, item := range result3101.Output.Result {
  18475. errMsgs = append(errMsgs, item.VolaCont)
  18476. }
  18477. c.ServeSuccessJSON(map[string]interface{}{
  18478. "failed_code": -10,
  18479. "msg": errMsgs,
  18480. })
  18481. return
  18482. }
  18483. }
  18484. bytesData, _ := json.Marshal(data)
  18485. var req *http.Request
  18486. if miConfig.MdtrtareaAdmvs == "320921" {
  18487. data["diag_code"] = sickConfig.CountryCode
  18488. fmt.Println(data)
  18489. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18490. } else {
  18491. data["diag_code"] = sickConfig.CountryCode
  18492. fmt.Println(data)
  18493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18494. }
  18495. resp, _ := client.Do(req)
  18496. defer resp.Body.Close()
  18497. body, ioErr := ioutil.ReadAll(resp.Body)
  18498. if ioErr != nil {
  18499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18501. return
  18502. }
  18503. var respJSON map[string]interface{}
  18504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18507. return
  18508. }
  18509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18510. userJSONBytes, _ := json.Marshal(respJSON)
  18511. fmt.Println("log")
  18512. fmt.Println(string(userJSONBytes))
  18513. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18514. utils.ErrorLog("解析失败:%v", err)
  18515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18516. return
  18517. }
  18518. res.InfRefmsgid = resFour10265.InfRefmsgid
  18519. res.Output = resFour10265.Output
  18520. res.ErrMsg = resFour10265.ErrMsg
  18521. res.Cainfo = resFour10265.Cainfo
  18522. res.WarnMsg = resFour10265.WarnMsg
  18523. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18524. res.Infcode = infocode
  18525. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18526. var pagesize int = 2
  18527. var start int = 1
  18528. var stop int
  18529. var pagecount int
  18530. var curpage int
  18531. var isSuccess bool = true
  18532. data["doctor_id"] = doctor_info.DoctorNumber
  18533. //总页数,向上取整,注意除之前要先转换类型为float64
  18534. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18535. for curpage = 1; curpage <= pagecount; curpage++ {
  18536. if curpage == 1 {
  18537. start = 1
  18538. } else {
  18539. start = (curpage-1)*pagesize + 1
  18540. }
  18541. stop = curpage * pagesize
  18542. if stop > len(prescriptions) {
  18543. stop = len(prescriptions)
  18544. }
  18545. //var requestLog string
  18546. data["pre"] = prescriptions[start-1 : stop]
  18547. fmt.Println(data["pre"])
  18548. bytesData, _ := json.Marshal(data)
  18549. var req *http.Request
  18550. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18551. resp, _ := client.Do(req)
  18552. defer resp.Body.Close()
  18553. body, ioErr := ioutil.ReadAll(resp.Body)
  18554. if ioErr != nil {
  18555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18557. return
  18558. }
  18559. var respJSON map[string]interface{}
  18560. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18563. return
  18564. }
  18565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18566. userJSONBytes, _ := json.Marshal(respJSON)
  18567. fmt.Println("log")
  18568. fmt.Println(string(userJSONBytes))
  18569. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18570. utils.ErrorLog("解析失败:%v", err)
  18571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18572. return
  18573. }
  18574. res.InfRefmsgid = resFour10265.InfRefmsgid
  18575. res.Output = resFour10265.Output
  18576. res.ErrMsg = resFour10265.ErrMsg
  18577. res.Cainfo = resFour10265.Cainfo
  18578. res.WarnMsg = resFour10265.WarnMsg
  18579. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18580. res.Infcode = infocode
  18581. if infocode == 0 {
  18582. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  18583. } else {
  18584. isSuccess = false
  18585. errlog := &models.HisOrderError{
  18586. UserOrgId: adminUser.CurrentOrgId,
  18587. Ctime: time.Now().Unix(),
  18588. Mtime: time.Now().Unix(),
  18589. Number: chrg_bchno,
  18590. ErrMsg: "",
  18591. Status: 1,
  18592. PatientId: id,
  18593. RecordTime: recordDateTime,
  18594. Stage: 4,
  18595. }
  18596. service.CreateErrMsgLog(errlog)
  18597. c.ServeSuccessJSON(map[string]interface{}{
  18598. "failed_code": -10,
  18599. "msg": res.ErrMsg,
  18600. })
  18601. return
  18602. }
  18603. }
  18604. if isSuccess {
  18605. res.Infcode = 0
  18606. }
  18607. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18608. 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)
  18609. var dat map[string]interface{}
  18610. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18611. fmt.Println(dat)
  18612. } else {
  18613. fmt.Println(err)
  18614. }
  18615. saveLog(result, request_log, "2204", "上传费用明细")
  18616. userJSONBytes, _ := json.Marshal(dat)
  18617. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18618. utils.ErrorLog("解析失败:%v", err)
  18619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18620. return
  18621. }
  18622. res.InfRefmsgid = resFour10265.InfRefmsgid
  18623. res.Output = resFour10265.Output
  18624. res.ErrMsg = resFour10265.ErrMsg
  18625. res.Cainfo = resFour10265.Cainfo
  18626. res.WarnMsg = resFour10265.WarnMsg
  18627. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18628. res.Infcode = infocode
  18629. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18630. bytesData, _ := json.Marshal(data)
  18631. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", 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, &res); err != nil {
  18651. utils.ErrorLog("解析失败:%v", err)
  18652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18653. return
  18654. }
  18655. } else {
  18656. if miConfig.Code == "H15049901371" {
  18657. 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)
  18658. var dat map[string]interface{}
  18659. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18660. fmt.Println(dat)
  18661. } else {
  18662. fmt.Println(err)
  18663. }
  18664. saveLog(result, request_log, "2204", "上传费用明细")
  18665. userJSONBytes, _ := json.Marshal(dat)
  18666. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18667. utils.ErrorLog("解析失败:%v", err)
  18668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18669. return
  18670. }
  18671. res.InfRefmsgid = resFour10265.InfRefmsgid
  18672. res.Output = resFour10265.Output
  18673. res.ErrMsg = resFour10265.ErrMsg
  18674. res.Cainfo = resFour10265.Cainfo
  18675. res.WarnMsg = resFour10265.WarnMsg
  18676. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18677. res.Infcode = infocode
  18678. } else {
  18679. 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)
  18680. var dat map[string]interface{}
  18681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18682. fmt.Println(dat)
  18683. } else {
  18684. fmt.Println(err)
  18685. }
  18686. saveLog(result, request_log, "2204", "上传费用明细")
  18687. userJSONBytes, _ := json.Marshal(dat)
  18688. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18689. utils.ErrorLog("解析失败:%v", err)
  18690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18691. return
  18692. }
  18693. }
  18694. }
  18695. if res.Infcode == 0 {
  18696. order := &models.HisOrder{
  18697. UserOrgId: adminUser.CurrentOrgId,
  18698. HisPatientId: his.ID,
  18699. PatientId: his.PatientId,
  18700. SettleAccountsDate: recordDateTime,
  18701. MdtrtId: his.Number,
  18702. PsnNo: his.PsnNo,
  18703. MedType: strconv.FormatInt(reg_type, 10),
  18704. Ctime: time.Now().Unix(),
  18705. Mtime: time.Now().Unix(),
  18706. Status: 1,
  18707. Number: chrg_bchno,
  18708. Infcode: res.Infcode,
  18709. WarnMsg: res.WarnMsg,
  18710. Cainfo: res.Cainfo,
  18711. ErrMsg: res.ErrMsg,
  18712. RespondTime: res.RefmsgTime,
  18713. InfRefmsgid: res.InfRefmsgid,
  18714. OrderStatus: 1,
  18715. PayWay: pay_way,
  18716. PayWays: pay_ways,
  18717. OthDesc: oth_desc,
  18718. PayPrice: pay_price,
  18719. PayCardNo: pay_card_no,
  18720. DiscountPrice: discount_price,
  18721. PreferentialPrice: preferential_price,
  18722. RealityPrice: reality_price,
  18723. FoundPrice: found_price,
  18724. MedicalInsurancePrice: medical_insurance_price,
  18725. PrivatePrice: private_price,
  18726. IsMedicineInsurance: 1,
  18727. SettleType: settle_accounts_type,
  18728. SettleStartTime: start_time,
  18729. SettleEndTime: end_time,
  18730. Creator: roles.AdminUserId,
  18731. Modify: roles.AdminUserId,
  18732. FaPiaoNumber: fapiao_number,
  18733. FaPiaoCode: fapiao_code,
  18734. PType: 2,
  18735. Diagnosis: diagnosis_id,
  18736. CashPay: cash_pay,
  18737. WechatPay: wechat_pay,
  18738. AliPay: ali_pay,
  18739. JifenPay: jifen_pay,
  18740. BandCardPay: band_card_pay,
  18741. }
  18742. err = service.CreateOrder(order)
  18743. if err != nil {
  18744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18745. return
  18746. }
  18747. for _, item := range res.Output.Result {
  18748. temp := strings.Split(item.FeedetlSn, "-")
  18749. var advice_id int64 = 0
  18750. var project_id int64 = 0
  18751. var types int64 = 0
  18752. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18753. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18754. if temp[1] == "1" {
  18755. advice_id = id
  18756. project_id = 0
  18757. } else if temp[1] == "2" {
  18758. advice_id = 0
  18759. project_id = id
  18760. }
  18761. if item.MedChrgitmType == "9" {
  18762. item.MedChrgitmType = "09"
  18763. }
  18764. info := &models.HisOrderInfo{
  18765. OrderNumber: order.Number,
  18766. FeedetlSn: item.FeedetlSn,
  18767. UploadDate: time.Now().Unix(),
  18768. AdviceId: advice_id,
  18769. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18770. Cnt: item.Cnt,
  18771. Pric: float64(item.Pric),
  18772. PatientId: his.PatientId,
  18773. PricUplmtAmt: item.PricUplmtAmt,
  18774. SelfpayProp: item.SelfpayProp,
  18775. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18776. OverlmtAmt: item.OverlmtAmt,
  18777. PreselfpayAmt: item.PreselfpayAmt,
  18778. BasMednFlag: item.BasMednFlag,
  18779. MedChrgitmType: item.MedChrgitmType,
  18780. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18781. Status: 1,
  18782. Memo: item.Memo,
  18783. Mtime: time.Now().Unix(),
  18784. InscpScpAmt: item.InscpScpAmt,
  18785. DrtReimFlag: item.DrtReimFlag,
  18786. Ctime: time.Now().Unix(),
  18787. ListSpItemFlag: item.ListSpItemFlag,
  18788. ChldMedcFlag: item.ChldMedcFlag,
  18789. LmtUsedFlag: item.LmtUsedFlag,
  18790. ChrgitmLv: item.ChrgitmLv,
  18791. UserOrgId: adminUser.CurrentOrgId,
  18792. HisPatientId: his.ID,
  18793. OrderId: order.ID,
  18794. ProjectId: project_id,
  18795. Type: types,
  18796. }
  18797. service.CreateOrderInfo(info)
  18798. }
  18799. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18800. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18801. var total float64
  18802. for _, item := range prescriptions {
  18803. if item.Type == 1 { //药品
  18804. for _, subItem := range item.HisDoctorAdviceInfo {
  18805. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18806. total_one := price * subItem.PrescribingNumber
  18807. total = total + total_one
  18808. }
  18809. }
  18810. if item.Type == 2 { //项目
  18811. for _, subItem := range item.HisPrescriptionProject {
  18812. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18813. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18814. total_one := price * cnt
  18815. total = total + total_one
  18816. }
  18817. }
  18818. }
  18819. allTotal := fmt.Sprintf("%.2f", total)
  18820. //if adminUser.CurrentOrgId == 9919 {
  18821. //
  18822. // allTotal = fmt.Sprintf("%.2f", total)
  18823. //
  18824. //} else {
  18825. //
  18826. // allTotal = fmt.Sprintf("%.2f", total)
  18827. //
  18828. //}
  18829. if res.Infcode == 0 {
  18830. var rf []*ResultFive
  18831. json.Unmarshal([]byte(his.Iinfo), &rf)
  18832. chrg_bchno := chrg_bchno
  18833. cert_no := his.Certno
  18834. var insutypes []string
  18835. var insutype string
  18836. var is390 int = 0
  18837. var is310 int = 0
  18838. for _, item := range rf {
  18839. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18840. insutypes = append(insutypes, item.Insutype)
  18841. }
  18842. }
  18843. if len(insutypes) == 1 {
  18844. insutype = insutypes[0]
  18845. } else {
  18846. for _, i := range insutypes {
  18847. if i == "390" {
  18848. is390 = 1
  18849. }
  18850. if i == "310" {
  18851. is310 = 1
  18852. }
  18853. }
  18854. }
  18855. if is390 == 1 {
  18856. insutype = "390"
  18857. }
  18858. if is310 == 1 {
  18859. insutype = "310"
  18860. }
  18861. if len(insutypes) == 0 {
  18862. insutype = "310"
  18863. }
  18864. if len(insutypes) == 2 {
  18865. insutype = strconv.FormatInt(his.SocialType, 10)
  18866. }
  18867. insutype = strconv.FormatInt(his.SocialType, 10)
  18868. //insutype = "390"
  18869. if his.IdCardType == 1 {
  18870. // cert_no = his.MedicalInsuranceNumber
  18871. cert_no = his.Certno
  18872. } else {
  18873. cert_no = his.Certno
  18874. }
  18875. var res ResultSeven
  18876. var resSeven10265 ResultSeven10265
  18877. var gzresSeven10265Two GZResultSeven10265Two
  18878. var src_resquest string
  18879. var result2 string
  18880. if miConfig.MdtrtareaAdmvs == "421300" {
  18881. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18882. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18883. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18885. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18886. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18887. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18888. resp, requestErr := http.Get(api)
  18889. if requestErr != nil {
  18890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18891. return
  18892. }
  18893. body, ioErr := ioutil.ReadAll(resp.Body)
  18894. if ioErr != nil {
  18895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18897. return
  18898. }
  18899. var respJSON map[string]interface{}
  18900. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18903. return
  18904. }
  18905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18906. result, _ := json.Marshal(respJSON)
  18907. if miConfig.Code == "H15049901371" {
  18908. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18909. utils.ErrorLog("解析失败:%v", err)
  18910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18911. return
  18912. }
  18913. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18914. res.Output = resSeven10265.Output
  18915. res.ErrMsg = resSeven10265.ErrMsg
  18916. res.Cainfo = resSeven10265.Cainfo
  18917. res.WarnMsg = resSeven10265.WarnMsg
  18918. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18919. res.Infcode = infocode
  18920. } else {
  18921. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18922. utils.ErrorLog("解析失败:%v", err)
  18923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18924. return
  18925. }
  18926. }
  18927. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18928. if reg_type == 11 && his.Insutype == "390" {
  18929. reg_type = 110104
  18930. }
  18931. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18932. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18933. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18934. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18935. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18936. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18937. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18938. resp, requestErr := http.Get(api)
  18939. if requestErr != nil {
  18940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18941. return
  18942. }
  18943. body, ioErr := ioutil.ReadAll(resp.Body)
  18944. if ioErr != nil {
  18945. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18947. return
  18948. }
  18949. var respJSON map[string]interface{}
  18950. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18951. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18953. return
  18954. }
  18955. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18956. result, _ := json.Marshal(respJSON)
  18957. if miConfig.Code == "H15049901371" {
  18958. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18959. utils.ErrorLog("解析失败:%v", err)
  18960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18961. return
  18962. }
  18963. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18964. res.Output = resSeven10265.Output
  18965. res.ErrMsg = resSeven10265.ErrMsg
  18966. res.Cainfo = resSeven10265.Cainfo
  18967. res.WarnMsg = resSeven10265.WarnMsg
  18968. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18969. res.Infcode = infocode
  18970. } else {
  18971. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18972. utils.ErrorLog("解析失败:%v", err)
  18973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18974. return
  18975. }
  18976. }
  18977. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18978. if reg_type == 11 && his.Insutype == "390" {
  18979. reg_type = 110104
  18980. }
  18981. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18982. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18983. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18985. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18986. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18987. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18988. resp, requestErr := http.Get(api)
  18989. if requestErr != nil {
  18990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18991. return
  18992. }
  18993. body, ioErr := ioutil.ReadAll(resp.Body)
  18994. if ioErr != nil {
  18995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18997. return
  18998. }
  18999. var respJSON map[string]interface{}
  19000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19003. return
  19004. }
  19005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19006. result, _ := json.Marshal(respJSON)
  19007. if miConfig.Code == "H15049901371" {
  19008. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19009. utils.ErrorLog("解析失败:%v", err)
  19010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19011. return
  19012. }
  19013. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19014. res.Output = resSeven10265.Output
  19015. res.ErrMsg = resSeven10265.ErrMsg
  19016. res.Cainfo = resSeven10265.Cainfo
  19017. res.WarnMsg = resSeven10265.WarnMsg
  19018. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19019. res.Infcode = infocode
  19020. } else {
  19021. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19022. utils.ErrorLog("解析失败:%v", err)
  19023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19024. return
  19025. }
  19026. }
  19027. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19028. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19029. if result3101.Infcode == "0" {
  19030. if len(result3101.Output.Result) > 0 {
  19031. var errMsgs []string
  19032. for _, item := range result3101.Output.Result {
  19033. errMsgs = append(errMsgs, item.VolaCont)
  19034. }
  19035. c.ServeSuccessJSON(map[string]interface{}{
  19036. "failed_code": -10,
  19037. "msg": errMsgs,
  19038. })
  19039. return
  19040. } else {
  19041. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19042. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19043. bas := strings.Split(psn_info.CardInfo, "|")
  19044. if his.IdCardType == 1 {
  19045. cert_no = bas[2]
  19046. } else if his.IdCardType == 3 {
  19047. cert_no = his.Certno
  19048. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19049. } else if his.IdCardType == 4 {
  19050. cert_no = his.Certno
  19051. psn_info.VerifyNumber = psn_info.VerifyNumber
  19052. }
  19053. var api string
  19054. if miConfig.MdtrtareaAdmvs == "320921" {
  19055. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19056. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19057. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19058. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19059. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19060. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19061. "&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
  19062. } else {
  19063. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19064. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19065. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19067. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19068. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19069. "&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
  19070. }
  19071. resp, requestErr := http.Get(api)
  19072. if requestErr != nil {
  19073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19074. return
  19075. }
  19076. body, ioErr := ioutil.ReadAll(resp.Body)
  19077. if ioErr != nil {
  19078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19080. return
  19081. }
  19082. var respJSON map[string]interface{}
  19083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19086. return
  19087. }
  19088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19089. result, _ := json.Marshal(respJSON)
  19090. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19091. utils.ErrorLog("解析失败:%v", err)
  19092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19093. return
  19094. }
  19095. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19096. res.Output = resSeven10265.Output
  19097. res.ErrMsg = resSeven10265.ErrMsg
  19098. res.Cainfo = resSeven10265.Cainfo
  19099. res.WarnMsg = resSeven10265.WarnMsg
  19100. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19101. res.Infcode = infocode
  19102. }
  19103. }
  19104. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19105. psn_info, _ := service.GetPsnByPatientId(id)
  19106. var verify_number string
  19107. if psn_info.IdCardType == 4 {
  19108. verify_number = psn_info.VerifyNumber
  19109. } else if psn_info.IdCardType == 1 {
  19110. bas := strings.Split(psn_info.CardInfo, "|")
  19111. cardNumber := bas[2]
  19112. verify_number = cardNumber
  19113. } else {
  19114. psn_info.IdCardType = 2
  19115. verify_number = psn_info.Certno
  19116. }
  19117. var api string
  19118. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19119. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19120. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19121. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19122. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19123. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19124. "&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
  19125. resp, requestErr := http.Get(api)
  19126. if requestErr != nil {
  19127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19128. return
  19129. }
  19130. body, ioErr := ioutil.ReadAll(resp.Body)
  19131. if ioErr != nil {
  19132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19134. return
  19135. }
  19136. var respJSON map[string]interface{}
  19137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19140. return
  19141. }
  19142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19143. result, _ := json.Marshal(respJSON)
  19144. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19145. utils.ErrorLog("解析失败:%v", err)
  19146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19147. return
  19148. }
  19149. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19150. res.Output = resSeven10265.Output
  19151. res.ErrMsg = resSeven10265.ErrMsg
  19152. res.Cainfo = resSeven10265.Cainfo
  19153. res.WarnMsg = resSeven10265.WarnMsg
  19154. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19155. res.Infcode = infocode
  19156. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19157. var cert_no string
  19158. if his.IdCardType == 4 {
  19159. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19160. cert_no = psn_info.VerifyNumber
  19161. 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)
  19162. } else if his.IdCardType == 1 {
  19163. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19164. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19165. 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)
  19166. }
  19167. //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)
  19168. var dat map[string]interface{}
  19169. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19170. fmt.Println(dat)
  19171. } else {
  19172. fmt.Println(err)
  19173. }
  19174. saveLog(result2, src_resquest, "2207", "结算")
  19175. userJSONBytes, _ := json.Marshal(dat)
  19176. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19177. utils.ErrorLog("解析失败:%v", err)
  19178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19179. return
  19180. }
  19181. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19182. res.Output = resSeven10265.Output
  19183. res.ErrMsg = resSeven10265.ErrMsg
  19184. res.Cainfo = resSeven10265.Cainfo
  19185. res.WarnMsg = resSeven10265.WarnMsg
  19186. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19187. res.Infcode = infocode
  19188. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19189. res2 := c.GetoleInfo()
  19190. if res2.Infcode == 0 {
  19191. var result string
  19192. var request_log string
  19193. var result_log string
  19194. if res2.Output.MdtrtCertType == "02" {
  19195. 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)
  19196. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19197. } else if res2.Output.MdtrtCertType == "01" {
  19198. 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)
  19199. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19200. } else {
  19201. 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)
  19202. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19203. }
  19204. var dat map[string]interface{}
  19205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19206. fmt.Println(dat)
  19207. } else {
  19208. fmt.Println(err)
  19209. }
  19210. userJSONBytes, _ := json.Marshal(dat)
  19211. var res5 ResultTwo
  19212. //var resTwo10265 ResultTwo10265
  19213. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19214. utils.ErrorLog("解析失败:%v", err)
  19215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19216. return
  19217. }
  19218. if res5.Infcode == -1 {
  19219. c.ServeSuccessJSON(map[string]interface{}{
  19220. "failed_code": -10,
  19221. "msg": res5.ErrMsg,
  19222. })
  19223. return
  19224. }
  19225. var insutypes []string
  19226. var insutype string
  19227. var is390 int = 0
  19228. var is310 int = 0
  19229. for _, item := range res5.Output.Iinfo {
  19230. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19231. insutypes = append(insutypes, item.Insutype)
  19232. }
  19233. }
  19234. if len(insutypes) == 1 {
  19235. insutype = insutypes[0]
  19236. } else {
  19237. for _, i := range insutypes {
  19238. if i == "390" {
  19239. is390 = 1
  19240. }
  19241. if i == "310" {
  19242. is310 = 1
  19243. }
  19244. }
  19245. }
  19246. if is390 == 1 {
  19247. insutype = "390"
  19248. }
  19249. if is310 == 1 {
  19250. insutype = "310"
  19251. }
  19252. if len(insutypes) == 0 {
  19253. insutype = "310"
  19254. }
  19255. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19256. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19257. infoStr := string(Iinfos)
  19258. idetinfoStr := string(Idetinfos)
  19259. psn := &models.HisPsn{
  19260. PsnNo: res5.Output.Baseinfo.PsnNo,
  19261. PatientId: id,
  19262. Certno: res5.Output.Baseinfo.Certno,
  19263. Gend: res5.Output.Baseinfo.Gend,
  19264. Naty: res5.Output.Baseinfo.Naty,
  19265. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19266. PsnName: res5.Output.Baseinfo.PsnName,
  19267. Idetinfo: idetinfoStr,
  19268. Insuinfo: infoStr,
  19269. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19270. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19271. VerifyNumber: res2.Output.EcToken,
  19272. }
  19273. if res2.Output.MdtrtCertType == "01" {
  19274. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19275. psn.VerifyNumber = res2.Output.EcToken
  19276. } else if res2.Output.MdtrtCertType == "02" {
  19277. psn.VerifyNumber = res2.Output.CardNo
  19278. } else {
  19279. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19280. }
  19281. service.CreateHisPsn(psn)
  19282. if res2.Output.MdtrtCertType == "01" {
  19283. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19284. token := res2.Output.EcToken
  19285. 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)
  19286. } else if res2.Output.MdtrtCertType == "02" {
  19287. 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)
  19288. } else {
  19289. 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)
  19290. }
  19291. var dat2 map[string]interface{}
  19292. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19293. fmt.Println(dat2)
  19294. } else {
  19295. fmt.Println(err)
  19296. }
  19297. userJSONBytes3, _ := json.Marshal(dat2)
  19298. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19299. utils.ErrorLog("解析失败:%v", err)
  19300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19301. return
  19302. }
  19303. saveLog(result2, src_resquest, "2207", "结算")
  19304. } else {
  19305. c.ServeSuccessJSON(map[string]interface{}{
  19306. "failed_code": -10,
  19307. "msg": res2.ErrMsg,
  19308. })
  19309. return
  19310. }
  19311. } else {
  19312. if miConfig.Code == "H15049901371" {
  19313. //赤峰地区国家医保医疗类别
  19314. //职工透析:医疗类别选特殊情况门诊990502
  19315. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19316. var med_type string
  19317. if his.Insutype == "390" {
  19318. if reg_type == 14 {
  19319. med_type = "9933"
  19320. } else if reg_type == 11 {
  19321. med_type = "11"
  19322. }
  19323. } else if his.Insutype == "310" {
  19324. if reg_type == 14 {
  19325. med_type = "990502"
  19326. } else if reg_type == 11 {
  19327. med_type = "11"
  19328. }
  19329. }
  19330. 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)
  19331. } else {
  19332. if his.IdCardType == 4 {
  19333. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19334. var token string
  19335. token = psn_info.VerifyNumber
  19336. 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)
  19337. } else {
  19338. if his.IdCardType == 1 {
  19339. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19340. bas := strings.Split(psn_info.CardInfo, "|")
  19341. basNumber := bas[2]
  19342. cert_no = basNumber
  19343. }
  19344. 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)
  19345. }
  19346. }
  19347. //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)
  19348. var dat map[string]interface{}
  19349. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19350. fmt.Println(dat)
  19351. } else {
  19352. fmt.Println(err)
  19353. }
  19354. saveLog(result2, src_resquest, "2207", "结算")
  19355. userJSONBytes, _ := json.Marshal(dat)
  19356. if miConfig.Code == "H15049901371" {
  19357. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19358. utils.ErrorLog("解析失败:%v", err)
  19359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19360. return
  19361. }
  19362. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19363. res.Output = resSeven10265.Output
  19364. res.ErrMsg = resSeven10265.ErrMsg
  19365. res.Cainfo = resSeven10265.Cainfo
  19366. res.WarnMsg = resSeven10265.WarnMsg
  19367. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19368. res.Infcode = infocode
  19369. } else {
  19370. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19371. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19372. utils.ErrorLog("解析失败:%v", err)
  19373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19374. return
  19375. }
  19376. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19377. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19378. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19379. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19380. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19381. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19382. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19383. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19384. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19385. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19386. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19387. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19388. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19389. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19390. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19391. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19392. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19393. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19394. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19395. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19396. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19397. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19398. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19399. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19400. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19401. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19402. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19403. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19404. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19405. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19406. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19407. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19408. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19409. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19410. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19411. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19412. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19413. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19414. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19415. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19416. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19417. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19418. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19419. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19420. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19421. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19422. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19423. res.Cainfo = gzresSeven10265Two.Cainfo
  19424. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19425. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19426. //res.Infcode = infocode
  19427. } else {
  19428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19429. utils.ErrorLog("解析失败:%v", err)
  19430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19431. return
  19432. }
  19433. }
  19434. }
  19435. }
  19436. if res.Infcode == -1 {
  19437. errlog := &models.HisOrderError{
  19438. UserOrgId: adminUser.CurrentOrgId,
  19439. Ctime: time.Now().Unix(),
  19440. Mtime: time.Now().Unix(),
  19441. Number: chrg_bchno,
  19442. ErrMsg: res.ErrMsg,
  19443. Status: 1,
  19444. PatientId: id,
  19445. RecordTime: recordDateTime,
  19446. Stage: 6,
  19447. }
  19448. service.CreateErrMsgLog(errlog)
  19449. c.ServeSuccessJSON(map[string]interface{}{
  19450. "failed_code": -10,
  19451. "msg": res.ErrMsg,
  19452. })
  19453. return
  19454. } else {
  19455. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19456. order.OrderStatus = 2
  19457. order.Status = 1
  19458. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19459. order.SetlId = res.Output.Setlinfo.SetlID
  19460. order.PsnNo = res.Output.Setlinfo.PsnNo
  19461. order.PsnName = res.Output.Setlinfo.PsnName
  19462. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19463. order.Certno = res.Output.Setlinfo.Certno
  19464. order.Gend = res.Output.Setlinfo.Gend
  19465. order.Naty = res.Output.Setlinfo.Naty
  19466. order.Age = res.Output.Setlinfo.Age
  19467. order.Insutype = res.Output.Setlinfo.Insutype
  19468. order.PsnType = res.Output.Setlinfo.PsnType
  19469. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19470. order.SetlTime = res.Output.Setlinfo.SetlTime
  19471. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19472. if res.Output.Setlinfo.MedType == "140101" {
  19473. order.MedType = "14"
  19474. } else {
  19475. if res.Output.Setlinfo.MedType == "110104" {
  19476. order.MedType = "11"
  19477. } else {
  19478. order.MedType = res.Output.Setlinfo.MedType
  19479. }
  19480. }
  19481. if reg_type == 1112 {
  19482. order.MedType = "1112"
  19483. }
  19484. if reg_type == 1111 {
  19485. order.MedType = "1111"
  19486. }
  19487. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19488. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19489. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19490. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19491. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19492. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19493. order.HifpPay = res.Output.Setlinfo.HifpPay
  19494. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19495. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19496. order.HifesPay = res.Output.Setlinfo.HifesPay
  19497. order.HifobPay = res.Output.Setlinfo.HifobPay
  19498. order.MafPay = res.Output.Setlinfo.MafPay
  19499. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19500. order.OthPay = res.Output.Setlinfo.OthPay
  19501. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19502. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19503. order.AcctPay = res.Output.Setlinfo.AcctPay
  19504. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19505. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19506. order.Balc = res.Output.Setlinfo.Balc
  19507. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19508. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19509. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19510. order.ClrType = res.Output.Setlinfo.ClrType
  19511. order.ClrWay = res.Output.Setlinfo.ClrWay
  19512. order.Creator = order.Creator
  19513. order.Modify = roles.AdminUserId
  19514. order.RequestLog = src_resquest
  19515. order.FaPiaoNumber = fapiao_number
  19516. order.FaPiaoCode = fapiao_code
  19517. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19518. //detailStr := string(setlDetail)
  19519. //order.SetlDetail = detailStr
  19520. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19521. err = service.UpDateOrder(order)
  19522. if err == nil {
  19523. //判断是否使用了押金
  19524. if dec_way == "true" {
  19525. tmpstring := strconv.FormatInt(order.ID, 10)
  19526. order.Decimal = decimal
  19527. service.UpDateOrder(order)
  19528. //扣押金
  19529. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19530. if errmsg != nil {
  19531. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19532. return
  19533. }
  19534. }
  19535. c.ServeSuccessJSON(map[string]interface{}{
  19536. "msg": "结算成功",
  19537. })
  19538. } else {
  19539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19540. return
  19541. }
  19542. }
  19543. } else {
  19544. adminUser := c.GetAdminUserInfo()
  19545. errlog := &models.HisOrderError{
  19546. UserOrgId: adminUser.CurrentOrgId,
  19547. Ctime: time.Now().Unix(),
  19548. Mtime: time.Now().Unix(),
  19549. ErrMsg: res.ErrMsg,
  19550. Status: 1,
  19551. PatientId: id,
  19552. RecordTime: recordDateTime,
  19553. Stage: 4,
  19554. }
  19555. service.CreateErrMsgLog(errlog)
  19556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  19557. return
  19558. }
  19559. } else {
  19560. adminUser := c.GetAdminUserInfo()
  19561. errlog := &models.HisOrderError{
  19562. UserOrgId: adminUser.CurrentOrgId,
  19563. Ctime: time.Now().Unix(),
  19564. Mtime: time.Now().Unix(),
  19565. ErrMsg: res.ErrMsg,
  19566. Status: 1,
  19567. PatientId: id,
  19568. RecordTime: recordDateTime,
  19569. Stage: 4,
  19570. }
  19571. service.CreateErrMsgLog(errlog)
  19572. c.ServeSuccessJSON(map[string]interface{}{
  19573. "failed_code": -10,
  19574. "msg": res.ErrMsg,
  19575. })
  19576. return
  19577. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  19578. //return
  19579. }
  19580. }
  19581. }
  19582. } else if tempOrder.ID > 0 {
  19583. if tempOrder.IsPre == 1 {
  19584. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  19585. var rf []*ResultFive
  19586. json.Unmarshal([]byte(his.Iinfo), &rf)
  19587. chrg_bchno := tempOrder.Number
  19588. cert_no := his.Certno
  19589. var insutypes []string
  19590. var insutype string
  19591. var is390 int = 0
  19592. var is310 int = 0
  19593. for _, item := range rf {
  19594. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19595. insutypes = append(insutypes, item.Insutype)
  19596. }
  19597. }
  19598. if len(insutypes) == 1 {
  19599. insutype = insutypes[0]
  19600. } else {
  19601. for _, i := range insutypes {
  19602. if i == "390" {
  19603. is390 = 1
  19604. }
  19605. if i == "310" {
  19606. is310 = 1
  19607. }
  19608. }
  19609. }
  19610. if is390 == 1 {
  19611. insutype = "390"
  19612. }
  19613. if is310 == 1 {
  19614. insutype = "310"
  19615. }
  19616. if len(insutypes) == 0 {
  19617. insutype = "310"
  19618. }
  19619. if len(insutypes) == 2 {
  19620. insutype = strconv.FormatInt(his.SocialType, 10)
  19621. }
  19622. //insutype = "390"
  19623. if his.IdCardType == 1 {
  19624. // cert_no = his.MedicalInsuranceNumber
  19625. cert_no = his.Certno
  19626. } else {
  19627. cert_no = his.Certno
  19628. }
  19629. var res ResultSeven
  19630. var ahres ResultSevenAH
  19631. var resSeven10265 ResultSeven10265
  19632. var gzresSeven10265Two GZResultSeven10265Two
  19633. var src_resquest string
  19634. var result2 string
  19635. if miConfig.MdtrtareaAdmvs == "450721" {
  19636. res2 := c.GetoleInfo()
  19637. if res2.Infcode == 0 {
  19638. var result string
  19639. var request_log string
  19640. var result_log string
  19641. if res2.Output.MdtrtCertType == "02" {
  19642. 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)
  19643. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19644. } else if res2.Output.MdtrtCertType == "01" {
  19645. 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)
  19646. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19647. } else {
  19648. 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)
  19649. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19650. }
  19651. var dat map[string]interface{}
  19652. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19653. fmt.Println(dat)
  19654. } else {
  19655. fmt.Println(err)
  19656. }
  19657. userJSONBytes, _ := json.Marshal(dat)
  19658. var res5 ResultTwo
  19659. //var resTwo10265 ResultTwo10265
  19660. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19661. utils.ErrorLog("解析失败:%v", err)
  19662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19663. return
  19664. }
  19665. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19666. if res5.Infcode == -1 {
  19667. c.ServeSuccessJSON(map[string]interface{}{
  19668. "failed_code": -10,
  19669. "msg": res5.ErrMsg,
  19670. })
  19671. return
  19672. }
  19673. var insutypes []string
  19674. var insutype string
  19675. var is390 int = 0
  19676. var is310 int = 0
  19677. for _, item := range res5.Output.Iinfo {
  19678. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19679. insutypes = append(insutypes, item.Insutype)
  19680. }
  19681. }
  19682. if len(insutypes) == 1 {
  19683. insutype = insutypes[0]
  19684. } else {
  19685. for _, i := range insutypes {
  19686. if i == "390" {
  19687. is390 = 1
  19688. }
  19689. if i == "310" {
  19690. is310 = 1
  19691. }
  19692. }
  19693. }
  19694. if is390 == 1 {
  19695. insutype = "390"
  19696. }
  19697. if is310 == 1 {
  19698. insutype = "310"
  19699. }
  19700. if len(insutypes) == 0 {
  19701. insutype = "310"
  19702. }
  19703. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19704. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19705. infoStr := string(Iinfos)
  19706. idetinfoStr := string(Idetinfos)
  19707. psn := &models.HisPsn{
  19708. PsnNo: res5.Output.Baseinfo.PsnNo,
  19709. PatientId: id,
  19710. Certno: res5.Output.Baseinfo.Certno,
  19711. Gend: res5.Output.Baseinfo.Gend,
  19712. Naty: res5.Output.Baseinfo.Naty,
  19713. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19714. PsnName: res5.Output.Baseinfo.PsnName,
  19715. Idetinfo: idetinfoStr,
  19716. Insuinfo: infoStr,
  19717. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19718. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19719. VerifyNumber: res2.Output.EcToken,
  19720. }
  19721. service.CreateHisPsn(psn)
  19722. if res2.Output.MdtrtCertType == "01" {
  19723. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19724. token := res2.Output.EcToken
  19725. 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)
  19726. } else if res2.Output.MdtrtCertType == "02" {
  19727. 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)
  19728. } else {
  19729. 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)
  19730. }
  19731. var dat2 map[string]interface{}
  19732. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19733. fmt.Println(dat2)
  19734. } else {
  19735. fmt.Println(err)
  19736. }
  19737. userJSONBytes3, _ := json.Marshal(dat2)
  19738. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19739. utils.ErrorLog("解析失败:%v", err)
  19740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19741. return
  19742. }
  19743. saveLog(result2, src_resquest, "2207", "结算")
  19744. } else {
  19745. c.ServeSuccessJSON(map[string]interface{}{
  19746. "failed_code": -10,
  19747. "msg": res2.ErrMsg,
  19748. })
  19749. return
  19750. }
  19751. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19752. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19753. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19754. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19755. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19756. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19757. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19758. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19759. resp, requestErr := http.Get(api)
  19760. if requestErr != nil {
  19761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19762. return
  19763. }
  19764. body, ioErr := ioutil.ReadAll(resp.Body)
  19765. if ioErr != nil {
  19766. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19768. return
  19769. }
  19770. var respJSON map[string]interface{}
  19771. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19772. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19774. return
  19775. }
  19776. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19777. result, _ := json.Marshal(respJSON)
  19778. fmt.Println("log")
  19779. fmt.Println(string(result))
  19780. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19781. utils.ErrorLog("解析失败:%v", err)
  19782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19783. return
  19784. }
  19785. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19786. if reg_type == 11 && his.Insutype == "390" {
  19787. reg_type = 110104
  19788. }
  19789. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19790. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19791. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19792. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19793. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19794. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19795. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19796. resp, requestErr := http.Get(api)
  19797. if requestErr != nil {
  19798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19799. return
  19800. }
  19801. body, ioErr := ioutil.ReadAll(resp.Body)
  19802. if ioErr != nil {
  19803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19805. return
  19806. }
  19807. var respJSON map[string]interface{}
  19808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19811. return
  19812. }
  19813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19814. result, _ := json.Marshal(respJSON)
  19815. fmt.Println("log")
  19816. fmt.Println(string(result))
  19817. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19818. utils.ErrorLog("解析失败:%v", err)
  19819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19820. return
  19821. }
  19822. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19823. if reg_type == 11 && his.Insutype == "390" {
  19824. reg_type = 110104
  19825. }
  19826. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19827. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19828. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19829. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19830. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19831. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19832. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19833. resp, requestErr := http.Get(api)
  19834. if requestErr != nil {
  19835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19836. return
  19837. }
  19838. body, ioErr := ioutil.ReadAll(resp.Body)
  19839. if ioErr != nil {
  19840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19842. return
  19843. }
  19844. var respJSON map[string]interface{}
  19845. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19848. return
  19849. }
  19850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19851. result, _ := json.Marshal(respJSON)
  19852. fmt.Println("log")
  19853. fmt.Println(string(result))
  19854. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19855. utils.ErrorLog("解析失败:%v", err)
  19856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19857. return
  19858. }
  19859. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19860. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19861. if result3101.Infcode == "0" {
  19862. if len(result3101.Output.Result) > 0 {
  19863. var errMsgs []string
  19864. for _, item := range result3101.Output.Result {
  19865. errMsgs = append(errMsgs, item.VolaCont)
  19866. }
  19867. c.ServeSuccessJSON(map[string]interface{}{
  19868. "failed_code": -10,
  19869. "msg": errMsgs,
  19870. })
  19871. return
  19872. } else {
  19873. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19874. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19875. bas := strings.Split(psn_info.CardInfo, "|")
  19876. if his.IdCardType == 1 {
  19877. cert_no = bas[2]
  19878. } else if his.IdCardType == 3 {
  19879. cert_no = his.Certno
  19880. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19881. } else if his.IdCardType == 4 {
  19882. cert_no = his.Certno
  19883. psn_info.VerifyNumber = psn_info.VerifyNumber
  19884. }
  19885. //江苏地区国家医保医疗类别
  19886. //职工透析:医疗类别选特殊情况门诊9933
  19887. //居民血透门慢: 医疗类别选门诊慢病1402
  19888. //var med_type string
  19889. //if his.Insutype == "310" {
  19890. // if reg_type == 14 {
  19891. // med_type = "9933"
  19892. // } else if reg_type == 11 {
  19893. // med_type = "11"
  19894. //
  19895. // }
  19896. //} else if his.Insutype == "390" {
  19897. // if reg_type == 14 {
  19898. // med_type = "1402"
  19899. // } else if reg_type == 11 {
  19900. // med_type = "11"
  19901. // }
  19902. //}
  19903. var api string
  19904. if miConfig.MdtrtareaAdmvs == "320921" {
  19905. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19906. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19907. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19908. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19909. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19910. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19911. "&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
  19912. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19913. } else {
  19914. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19915. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19916. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19917. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19919. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19920. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19921. "&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
  19922. }
  19923. resp, requestErr := http.Get(api)
  19924. if requestErr != nil {
  19925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19926. return
  19927. }
  19928. body, ioErr := ioutil.ReadAll(resp.Body)
  19929. if ioErr != nil {
  19930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19932. return
  19933. }
  19934. var respJSON map[string]interface{}
  19935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19938. return
  19939. }
  19940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19941. result, _ := json.Marshal(respJSON)
  19942. fmt.Println("log")
  19943. fmt.Println(string(result))
  19944. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19945. utils.ErrorLog("解析失败:%v", err)
  19946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19947. return
  19948. }
  19949. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19950. res.Output = resSeven10265.Output
  19951. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19952. res.ErrMsg = resSeven10265.ErrMsg
  19953. res.Cainfo = resSeven10265.Cainfo
  19954. res.WarnMsg = resSeven10265.WarnMsg
  19955. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19956. res.Infcode = infocode
  19957. }
  19958. }
  19959. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19960. psn_info, _ := service.GetPsnByPatientId(id)
  19961. var verify_number string
  19962. if psn_info.IdCardType == 4 {
  19963. verify_number = psn_info.VerifyNumber
  19964. } else if psn_info.IdCardType == 1 {
  19965. bas := strings.Split(psn_info.CardInfo, "|")
  19966. cardNumber := bas[2]
  19967. verify_number = cardNumber
  19968. } else {
  19969. verify_number = psn_info.Certno
  19970. psn_info.IdCardType = 2
  19971. }
  19972. var api string
  19973. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19974. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19975. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19977. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19978. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19979. "&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
  19980. resp, requestErr := http.Get(api)
  19981. if requestErr != nil {
  19982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19983. return
  19984. }
  19985. body, ioErr := ioutil.ReadAll(resp.Body)
  19986. if ioErr != nil {
  19987. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19989. return
  19990. }
  19991. var respJSON map[string]interface{}
  19992. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19993. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19995. return
  19996. }
  19997. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19998. result, _ := json.Marshal(respJSON)
  19999. fmt.Println("log")
  20000. fmt.Println(string(result))
  20001. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20002. utils.ErrorLog("解析失败:%v", err)
  20003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20004. return
  20005. }
  20006. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20007. res.Output = resSeven10265.Output
  20008. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20009. res.ErrMsg = resSeven10265.ErrMsg
  20010. res.Cainfo = resSeven10265.Cainfo
  20011. res.WarnMsg = resSeven10265.WarnMsg
  20012. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20013. res.Infcode = infocode
  20014. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20015. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20016. var cert_no string
  20017. if his.IdCardType == 1 {
  20018. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20019. } else {
  20020. cert_no = psn_info.VerifyNumber
  20021. }
  20022. 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)
  20023. var dat map[string]interface{}
  20024. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20025. fmt.Println(dat)
  20026. } else {
  20027. fmt.Println(err)
  20028. }
  20029. saveLog(result2, src_resquest, "2207", "结算")
  20030. userJSONBytes, _ := json.Marshal(dat)
  20031. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20032. utils.ErrorLog("解析失败:%v", err)
  20033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20034. return
  20035. }
  20036. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20037. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20038. var cert_no string
  20039. var card_sn string
  20040. if his.IdCardType == 1 {
  20041. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20042. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20043. bas := strings.Split(psn_info.CardInfo, "|")
  20044. card_sn = bas[3]
  20045. } else if his.IdCardType == 2 {
  20046. cert_no = his.IdCardNo
  20047. } else {
  20048. cert_no = psn_info.VerifyNumber
  20049. }
  20050. var rf []*ResultFive
  20051. json.Unmarshal([]byte(his.Iinfo), &rf)
  20052. var psn_type string
  20053. for _, item := range rf {
  20054. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20055. psn_type = item.PsnType
  20056. }
  20057. }
  20058. 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)
  20059. var dat map[string]interface{}
  20060. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20061. fmt.Println(dat)
  20062. } else {
  20063. fmt.Println(err)
  20064. }
  20065. saveLog(result2, src_resquest, "2207", "结算")
  20066. userJSONBytes, _ := json.Marshal(dat)
  20067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20068. utils.ErrorLog("解析失败:%v", err)
  20069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20070. return
  20071. }
  20072. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20073. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20074. if his.IdCardType == 1 {
  20075. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20076. bas := strings.Split(psn_info.CardInfo, "|")
  20077. cert_no = bas[2]
  20078. } else if his.IdCardType == 3 {
  20079. cert_no = his.Certno
  20080. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20081. } else if his.IdCardType == 4 {
  20082. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20083. cert_no = his.Certno
  20084. psn_info.VerifyNumber = psn_info.VerifyNumber
  20085. } else {
  20086. cert_no = his.Certno
  20087. psn_info.VerifyNumber = his.Certno
  20088. }
  20089. var api string
  20090. var med_type string
  20091. if his.Insutype == "390" {
  20092. if reg_type == 992102 {
  20093. med_type = "992102"
  20094. }
  20095. if reg_type == 140104 {
  20096. med_type = "140104"
  20097. }
  20098. if reg_type == 14 {
  20099. med_type = "14"
  20100. }
  20101. } else if his.Insutype == "310" {
  20102. if reg_type == 992102 {
  20103. med_type = "992102"
  20104. }
  20105. if reg_type == 14 {
  20106. med_type = "14"
  20107. }
  20108. }
  20109. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20110. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20111. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20112. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20113. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20114. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20115. "&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
  20116. resp, requestErr := http.Get(api)
  20117. if requestErr != nil {
  20118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20119. return
  20120. }
  20121. body, ioErr := ioutil.ReadAll(resp.Body)
  20122. if ioErr != nil {
  20123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20125. return
  20126. }
  20127. var respJSON map[string]interface{}
  20128. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20131. return
  20132. }
  20133. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20134. if status == "0" {
  20135. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20136. c.ServeSuccessJSON(map[string]interface{}{
  20137. "failed_code": -10,
  20138. "msg": err_msg,
  20139. })
  20140. return
  20141. }
  20142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20143. result, _ := json.Marshal(respJSON)
  20144. fmt.Println("log")
  20145. fmt.Println(string(result))
  20146. if err := json.Unmarshal(result, &ahres); err != nil {
  20147. utils.ErrorLog("解析失败:%v", err)
  20148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20149. return
  20150. }
  20151. res.InfRefmsgid = ahres.InfRefmsgid
  20152. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20153. // 创建对应的Time类型
  20154. t := time.UnixMilli(timestamp)
  20155. // 格式化成指定的日期字符串
  20156. str := t.Format("2006-01-02 15:04:05")
  20157. res.Output.Setlinfo.SetlTime = str
  20158. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20159. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20160. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20161. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20162. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20163. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20164. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20165. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20166. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20167. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20168. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20169. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20170. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20171. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20172. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20173. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20174. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20175. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20176. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20177. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20178. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20179. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20180. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20181. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20182. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20183. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20184. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20185. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20186. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20187. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20188. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20189. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20190. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20191. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20192. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20193. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20194. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20195. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20196. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20197. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20198. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20199. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20200. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20201. res.Output.Setldetail = ahres.Output.Setldetail
  20202. res.ErrMsg = ahres.ErrMsg
  20203. res.Cainfo = ahres.Cainfo
  20204. res.WarnMsg = ahres.WarnMsg
  20205. res.Infcode = ahres.Infcode
  20206. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20207. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20208. var cert_no string
  20209. if his.IdCardType == 1 {
  20210. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20211. } else if his.IdCardType == 2 {
  20212. cert_no = his.IdCardNo
  20213. } else {
  20214. cert_no = psn_info.VerifyNumber
  20215. }
  20216. 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, "")
  20217. var dat map[string]interface{}
  20218. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20219. fmt.Println(dat)
  20220. } else {
  20221. fmt.Println(err)
  20222. }
  20223. saveLog(result2, src_resquest, "2207", "结算")
  20224. userJSONBytes, _ := json.Marshal(dat)
  20225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20226. utils.ErrorLog("解析失败:%v", err)
  20227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20228. return
  20229. }
  20230. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20231. psn_info, _ := service.GetPsnByPatientId(id)
  20232. var verify_number string
  20233. if psn_info.IdCardType == 4 {
  20234. verify_number = psn_info.VerifyNumber
  20235. } else if psn_info.IdCardType == 1 {
  20236. bas := strings.Split(psn_info.CardInfo, "|")
  20237. cardNumber := bas[2]
  20238. verify_number = cardNumber
  20239. } else {
  20240. verify_number = psn_info.Certno
  20241. psn_info.IdCardType = 2
  20242. }
  20243. var api string
  20244. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20245. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20246. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20247. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20248. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20249. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20250. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20251. resp, requestErr := http.Get(api)
  20252. if requestErr != nil {
  20253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20254. return
  20255. }
  20256. body, ioErr := ioutil.ReadAll(resp.Body)
  20257. if ioErr != nil {
  20258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20260. return
  20261. }
  20262. var respJSON map[string]interface{}
  20263. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20266. return
  20267. }
  20268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20269. result, _ := json.Marshal(respJSON)
  20270. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20271. utils.ErrorLog("解析失败:%v", err)
  20272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20273. return
  20274. }
  20275. } else {
  20276. var src_resquest string
  20277. if miConfig.Code == "H15049901371" {
  20278. //赤峰地区国家医保医疗类别
  20279. //职工透析:医疗类别选特殊情况门诊990502
  20280. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20281. var med_type string
  20282. if his.Insutype == "390" {
  20283. if reg_type == 14 {
  20284. med_type = "9933"
  20285. } else if reg_type == 11 {
  20286. med_type = "11"
  20287. }
  20288. } else if his.Insutype == "310" {
  20289. if reg_type == 14 {
  20290. med_type = "990502"
  20291. } else if reg_type == 11 {
  20292. med_type = "11"
  20293. }
  20294. }
  20295. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, med_type, his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  20296. } else {
  20297. if his.IdCardType == 4 {
  20298. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20299. token := psn_info.VerifyNumber
  20300. 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)
  20301. } else {
  20302. 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)
  20303. }
  20304. }
  20305. var dat map[string]interface{}
  20306. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20307. fmt.Println(dat)
  20308. } else {
  20309. fmt.Println(err)
  20310. }
  20311. saveLog(result2, src_resquest, "2207", "结算")
  20312. userJSONBytes, _ := json.Marshal(dat)
  20313. if miConfig.Code == "H15049901371" {
  20314. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20315. utils.ErrorLog("解析失败:%v", err)
  20316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20317. return
  20318. }
  20319. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20320. res.Output = resSeven10265.Output
  20321. res.ErrMsg = resSeven10265.ErrMsg
  20322. res.Cainfo = resSeven10265.Cainfo
  20323. res.WarnMsg = resSeven10265.WarnMsg
  20324. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20325. res.Infcode = infocode
  20326. } else {
  20327. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20328. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20329. utils.ErrorLog("解析失败:%v", err)
  20330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20331. return
  20332. }
  20333. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20334. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20335. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20336. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20337. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20338. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20339. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20340. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20341. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20342. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20343. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20344. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20345. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20346. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20347. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20348. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20349. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20350. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20351. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20352. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20353. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20354. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20355. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20356. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20357. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20358. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20359. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20360. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20361. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20362. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20363. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20364. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20365. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20366. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20367. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20368. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20369. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20370. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20371. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20372. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20373. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20374. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20375. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20376. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20377. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20378. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20379. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20380. res.Cainfo = gzresSeven10265Two.Cainfo
  20381. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20382. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20383. //res.Infcode = infocode
  20384. } else {
  20385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20386. utils.ErrorLog("解析失败:%v", err)
  20387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20388. return
  20389. }
  20390. }
  20391. }
  20392. }
  20393. if res.Infcode != 0 {
  20394. errlog := &models.HisOrderError{
  20395. UserOrgId: adminUser.CurrentOrgId,
  20396. Ctime: time.Now().Unix(),
  20397. Mtime: time.Now().Unix(),
  20398. Number: chrg_bchno,
  20399. ErrMsg: res.ErrMsg,
  20400. Status: 1,
  20401. PatientId: id,
  20402. RecordTime: recordDateTime,
  20403. Stage: 6,
  20404. }
  20405. service.CreateErrMsgLog(errlog)
  20406. c.ServeSuccessJSON(map[string]interface{}{
  20407. "failed_code": -10,
  20408. "msg": res.ErrMsg,
  20409. })
  20410. return
  20411. } else {
  20412. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20413. order.OrderStatus = 2
  20414. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20415. order.SetlId = res.Output.Setlinfo.SetlID
  20416. order.PsnNo = res.Output.Setlinfo.PsnNo
  20417. order.PsnName = res.Output.Setlinfo.PsnName
  20418. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20419. order.Certno = res.Output.Setlinfo.Certno
  20420. order.Gend = res.Output.Setlinfo.Gend
  20421. order.Naty = res.Output.Setlinfo.Naty
  20422. order.Age = res.Output.Setlinfo.Age
  20423. order.Insutype = res.Output.Setlinfo.Insutype
  20424. order.PsnType = res.Output.Setlinfo.PsnType
  20425. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20426. order.SetlTime = res.Output.Setlinfo.SetlTime
  20427. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20428. order.PayWays = pay_ways
  20429. order.AcctUsedFlag = acct_used_flag
  20430. order.WechatPay = wechat_pay
  20431. order.AliPay = ali_pay
  20432. order.JifenPay = jifen_pay
  20433. order.BandCardPay = band_card_pay
  20434. order.CashPay = cash_pay
  20435. order.OthDesc = oth_desc
  20436. //order.MedType = res.Output.Setlinfo.MedType
  20437. if reg_type == 1112 {
  20438. order.MedType = "1112"
  20439. }
  20440. if reg_type == 1111 {
  20441. order.MedType = "1111"
  20442. }
  20443. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20444. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20445. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20446. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20447. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20448. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20449. order.HifpPay = res.Output.Setlinfo.HifpPay
  20450. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20451. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20452. order.HifesPay = res.Output.Setlinfo.HifesPay
  20453. order.HifobPay = res.Output.Setlinfo.HifobPay
  20454. order.MafPay = res.Output.Setlinfo.MafPay
  20455. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20456. order.OthPay = res.Output.Setlinfo.OthPay
  20457. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20458. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20459. order.AcctPay = res.Output.Setlinfo.AcctPay
  20460. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20461. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20462. order.Balc = res.Output.Setlinfo.Balc
  20463. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20464. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20465. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20466. order.ClrWay = res.Output.Setlinfo.ClrWay
  20467. order.Creator = order.Creator
  20468. order.ClrType = res.Output.Setlinfo.ClrType
  20469. order.Modify = roles.AdminUserId
  20470. order.RequestLog = src_resquest
  20471. order.Diagnosis = diagnosis_id
  20472. order.FaPiaoNumber = fapiao_number
  20473. order.FaPiaoCode = fapiao_code
  20474. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20475. detailStr := string(setlDetail)
  20476. order.SetlDetail = detailStr
  20477. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20478. err = service.UpDateOrder(order)
  20479. if err == nil {
  20480. //判断是否使用了押金
  20481. if dec_way == "true" {
  20482. tmpstring := strconv.FormatInt(order.ID, 10)
  20483. //扣押金
  20484. order.Decimal = decimal
  20485. service.UpDateOrder(order)
  20486. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20487. if errmsg != nil {
  20488. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20489. return
  20490. }
  20491. }
  20492. c.ServeSuccessJSON(map[string]interface{}{
  20493. "msg": "结算成功",
  20494. })
  20495. } else {
  20496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20497. return
  20498. }
  20499. }
  20500. }
  20501. }
  20502. }
  20503. // 上传明细-预结算-
  20504. func (c *HisApiController) GetPreUploadInfo() {
  20505. id, _ := c.GetInt64("id")
  20506. record_time := c.GetString("record_time")
  20507. his_patient_id, _ := c.GetInt64("his_patient_id")
  20508. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  20509. admin_user_id, _ := c.GetInt64("admin_user_id")
  20510. diagnosis_id := c.GetString("diagnosis")
  20511. sick_type, _ := c.GetInt64("sick_type")
  20512. reg_type, _ := c.GetInt64("p_type")
  20513. begin_time := c.GetString("begin_time")
  20514. acct_used_flag := c.GetString("acct_used_flag")
  20515. id_str := c.GetString("ids")
  20516. ids_arr := strings.Split(id_str, ",")
  20517. timeLayout := "2006-01-02"
  20518. loc, _ := time.LoadLocation("Local")
  20519. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20520. if err != nil {
  20521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20522. return
  20523. }
  20524. recordDateTime := theTime.Unix()
  20525. adminUser := c.GetAdminUserInfo()
  20526. diagnosis_ids := strings.Split(diagnosis_id, ",")
  20527. var config []*models.HisXtDiagnoseConfig
  20528. for _, item := range diagnosis_ids {
  20529. id, _ := strconv.ParseInt(item, 10, 64)
  20530. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20531. config = append(config, &diagnosisConfig)
  20532. }
  20533. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  20534. sickConfig, _ := service.FindSickById(sick_type)
  20535. var prescriptions []*models.HisPrescription
  20536. var start_time int64
  20537. var end_time int64
  20538. var isSuccess bool = true
  20539. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20540. fmt.Println(his_patient_id)
  20541. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20542. timestamp := time.Now().Unix()
  20543. tempTime := time.Unix(timestamp, 0)
  20544. timeFormat := tempTime.Format("20060102150405")
  20545. chrgBchno := rand.Intn(100000) + 10000
  20546. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  20547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20548. var patientPrescription models.HisPrescriptionInfo
  20549. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20550. if patientPrescription.ID == 0 {
  20551. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  20552. }
  20553. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20554. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  20555. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  20556. strconv.FormatInt(his.PatientId, 10)
  20557. var res2406 Result2406
  20558. //安徽单病种处理
  20559. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  20560. data := make(map[string]interface{})
  20561. client := &http.Client{}
  20562. data["psn_no"] = his.PsnNo
  20563. data["mdtrt_id"] = his.Number
  20564. data["operator"] = roles.UserName
  20565. data["cert_no"] = his.IdCardNo
  20566. data["org_name"] = miConfig.OrgName
  20567. data["psn_name"] = his.Name
  20568. data["ipt_otp_no"] = his.IptOtpNo
  20569. data["ipt_psn_sp_flag_type"] = "0901"
  20570. data["ipt_psn_sp_flag"] = "1"
  20571. data["fixmedins_code"] = miConfig.Code
  20572. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20573. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20574. data["url"] = miConfig.Url
  20575. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  20576. bytesData, _ := json.Marshal(data)
  20577. var req *http.Request
  20578. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  20579. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  20580. resp, _ := client.Do(req)
  20581. defer resp.Body.Close()
  20582. body, ioErr := ioutil.ReadAll(resp.Body)
  20583. if ioErr != nil {
  20584. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20586. return
  20587. }
  20588. var respJSON map[string]interface{}
  20589. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20592. return
  20593. }
  20594. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20595. if status == "0" {
  20596. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20597. c.ServeSuccessJSON(map[string]interface{}{
  20598. "failed_code": -10,
  20599. "msg": err_msg,
  20600. })
  20601. return
  20602. }
  20603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20604. userJSONBytes, _ := json.Marshal(respJSON)
  20605. fmt.Println("log")
  20606. fmt.Println(string(userJSONBytes))
  20607. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  20608. utils.ErrorLog("解析失败:%v", err)
  20609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20610. return
  20611. }
  20612. }
  20613. if res2406.Infcode != 0 {
  20614. adminUser := c.GetAdminUserInfo()
  20615. errlog := &models.HisOrderError{
  20616. UserOrgId: adminUser.CurrentOrgId,
  20617. Ctime: time.Now().Unix(),
  20618. Mtime: time.Now().Unix(),
  20619. ErrMsg: res2406.ErrMsg,
  20620. Status: 1,
  20621. PatientId: id,
  20622. RecordTime: recordDateTime,
  20623. Stage: 3,
  20624. }
  20625. service.CreateErrMsgLog(errlog)
  20626. c.ServeSuccessJSON(map[string]interface{}{
  20627. "failed_code": -10,
  20628. "msg": res2406.ErrMsg,
  20629. })
  20630. return
  20631. }
  20632. var res2 ResultSix
  20633. var res3 GZResultSix
  20634. var resSix10265 ResultSix10265
  20635. //var time_stamp string
  20636. if miConfig.MdtrtareaAdmvs == "421300" {
  20637. data := make(map[string]interface{})
  20638. client := &http.Client{}
  20639. data["psn_no"] = his.PsnNo
  20640. data["mdtrt_id"] = his.Number
  20641. data["department"] = department.Name
  20642. data["org_name"] = miConfig.OrgName
  20643. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20644. data["doctor_id"] = doctor_info.DoctorNumber
  20645. data["doctor_name"] = roles.UserName
  20646. data["fixmedins_code"] = miConfig.Code
  20647. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20648. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20649. data["secret_key"] = miConfig.SecretKey
  20650. data["sick_code"] = sickConfig.CountryCode
  20651. data["sick_name"] = sickConfig.ClassName
  20652. data["begin_time"] = begin_time
  20653. data["dept"] = strconv.FormatInt(department.ID, 10)
  20654. data["config"] = config
  20655. data["opter"] = roles.UserName
  20656. fmt.Println(data)
  20657. bytesData, _ := json.Marshal(data)
  20658. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20659. resp, _ := client.Do(req)
  20660. defer resp.Body.Close()
  20661. body, ioErr := ioutil.ReadAll(resp.Body)
  20662. if ioErr != nil {
  20663. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20665. return
  20666. }
  20667. var respJSON map[string]interface{}
  20668. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20669. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20671. return
  20672. }
  20673. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20674. userJSONBytes, _ := json.Marshal(respJSON)
  20675. fmt.Println("log")
  20676. fmt.Println(string(userJSONBytes))
  20677. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20678. utils.ErrorLog("解析失败:%v", err)
  20679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20680. return
  20681. }
  20682. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20683. data := make(map[string]interface{})
  20684. client := &http.Client{}
  20685. data["psn_no"] = his.PsnNo
  20686. data["mdtrt_id"] = his.Number
  20687. data["department"] = department.Name
  20688. data["org_name"] = miConfig.OrgName
  20689. if reg_type == 11 && his.Insutype == "390" {
  20690. data["med_type"] = "110104"
  20691. } else {
  20692. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20693. }
  20694. data["doctor_id"] = doctor_info.DoctorNumber
  20695. data["doctor_name"] = roles.UserName
  20696. data["fixmedins_code"] = miConfig.Code
  20697. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20698. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20699. data["secret_key"] = miConfig.SecretKey
  20700. data["sick_code"] = sickConfig.CountryCode
  20701. data["sick_name"] = sickConfig.ClassName
  20702. data["begin_time"] = begin_time
  20703. data["dept"] = strconv.FormatInt(department.ID, 10)
  20704. data["config"] = config
  20705. data["opter"] = roles.UserName
  20706. fmt.Println(data)
  20707. bytesData, _ := json.Marshal(data)
  20708. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20709. resp, _ := client.Do(req)
  20710. defer resp.Body.Close()
  20711. body, ioErr := ioutil.ReadAll(resp.Body)
  20712. if ioErr != nil {
  20713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20715. return
  20716. }
  20717. var respJSON map[string]interface{}
  20718. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20721. return
  20722. }
  20723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20724. userJSONBytes, _ := json.Marshal(respJSON)
  20725. fmt.Println("log")
  20726. fmt.Println(string(userJSONBytes))
  20727. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20728. utils.ErrorLog("解析失败:%v", err)
  20729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20730. return
  20731. }
  20732. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20733. data := make(map[string]interface{})
  20734. client := &http.Client{}
  20735. data["psn_no"] = his.PsnNo
  20736. data["mdtrt_id"] = his.Number
  20737. data["department"] = department.Name
  20738. data["org_name"] = miConfig.OrgName
  20739. if reg_type == 11 && his.Insutype == "390" {
  20740. data["med_type"] = "110104"
  20741. } else {
  20742. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20743. }
  20744. data["doctor_id"] = doctor_info.DoctorNumber
  20745. data["doctor_name"] = roles.UserName
  20746. data["fixmedins_code"] = miConfig.Code
  20747. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20748. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20749. data["secret_key"] = miConfig.SecretKey
  20750. data["sick_code"] = sickConfig.CountryCode
  20751. data["sick_name"] = sickConfig.ClassName
  20752. data["begin_time"] = begin_time
  20753. data["dept"] = strconv.FormatInt(department.ID, 10)
  20754. data["config"] = config
  20755. data["opter"] = roles.UserName
  20756. fmt.Println(data)
  20757. bytesData, _ := json.Marshal(data)
  20758. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20759. resp, _ := client.Do(req)
  20760. defer resp.Body.Close()
  20761. body, ioErr := ioutil.ReadAll(resp.Body)
  20762. if ioErr != nil {
  20763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20765. return
  20766. }
  20767. var respJSON map[string]interface{}
  20768. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20771. return
  20772. }
  20773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20774. userJSONBytes, _ := json.Marshal(respJSON)
  20775. fmt.Println("log")
  20776. fmt.Println(string(userJSONBytes))
  20777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20778. utils.ErrorLog("解析失败:%v", err)
  20779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20780. return
  20781. }
  20782. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20783. data := make(map[string]interface{})
  20784. client := &http.Client{}
  20785. data["psn_no"] = his.PsnNo
  20786. data["mdtrt_id"] = his.Number
  20787. data["doctor"] = roles.UserName
  20788. data["department"] = department.Name
  20789. data["org_name"] = miConfig.OrgName
  20790. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20791. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20792. data["fixmedins_code"] = miConfig.Code
  20793. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20794. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20795. data["secret_key"] = miConfig.SecretKey
  20796. data["sick_code"] = sickConfig.CountryCode
  20797. data["sick_name"] = sickConfig.ClassName
  20798. data["begin_time"] = begin_time
  20799. data["dept"] = strconv.FormatInt(department.ID, 10)
  20800. data["config"] = config
  20801. data["url"] = miConfig.Url
  20802. data["ak"] = miConfig.AccessKey
  20803. data["cainfo"] = miConfig.Cainfo
  20804. bytesData, _ := json.Marshal(data)
  20805. var req *http.Request
  20806. if miConfig.MdtrtareaAdmvs == "320921" {
  20807. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20808. } else {
  20809. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20810. }
  20811. resp, _ := client.Do(req)
  20812. defer resp.Body.Close()
  20813. body, ioErr := ioutil.ReadAll(resp.Body)
  20814. if ioErr != nil {
  20815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20817. return
  20818. }
  20819. var respJSON map[string]interface{}
  20820. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20823. return
  20824. }
  20825. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20826. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20827. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20829. userJSONBytes, _ := json.Marshal(respJSON)
  20830. fmt.Println("log")
  20831. fmt.Println(string(userJSONBytes))
  20832. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20833. utils.ErrorLog("解析失败:%v", err)
  20834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20835. return
  20836. }
  20837. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20838. res2.Output = resSix10265.Output
  20839. res2.ErrMsg = resSix10265.ErrMsg
  20840. res2.Cainfo = resSix10265.Cainfo
  20841. res2.WarnMsg = resSix10265.WarnMsg
  20842. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20843. res2.Infcode = infocode
  20844. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20845. data := make(map[string]interface{})
  20846. client := &http.Client{}
  20847. data["psn_no"] = his.PsnNo
  20848. data["mdtrt_id"] = his.Number
  20849. data["doctor"] = roles.UserName
  20850. data["department"] = department.Name
  20851. data["org_name"] = miConfig.OrgName
  20852. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20853. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20854. data["fixmedins_code"] = miConfig.Code
  20855. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20856. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20857. data["secret_key"] = miConfig.SecretKey
  20858. data["sick_code"] = sickConfig.CountryCode
  20859. data["sick_name"] = sickConfig.ClassName
  20860. data["begin_time"] = begin_time
  20861. data["dept"] = strconv.FormatInt(department.ID, 10)
  20862. data["config"] = config
  20863. //data["url"] = miConfig.Url
  20864. //data["ak"] = miConfig.AccessKey
  20865. data["cainfo"] = miConfig.Cainfo
  20866. fmt.Println(data)
  20867. bytesData, _ := json.Marshal(data)
  20868. var req *http.Request
  20869. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20870. resp, _ := client.Do(req)
  20871. defer resp.Body.Close()
  20872. body, ioErr := ioutil.ReadAll(resp.Body)
  20873. if ioErr != nil {
  20874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20876. return
  20877. }
  20878. var respJSON map[string]interface{}
  20879. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20885. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20886. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20888. userJSONBytes, _ := json.Marshal(respJSON)
  20889. fmt.Println("log")
  20890. fmt.Println(string(userJSONBytes))
  20891. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20892. utils.ErrorLog("解析失败:%v", err)
  20893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20894. return
  20895. }
  20896. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20897. res2.Output = resSix10265.Output
  20898. res2.ErrMsg = resSix10265.ErrMsg
  20899. res2.Cainfo = resSix10265.Cainfo
  20900. res2.WarnMsg = resSix10265.WarnMsg
  20901. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20902. res2.Infcode = infocode
  20903. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20904. 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)
  20905. saveLog(result, requestLog, "2203", "上传就诊信息")
  20906. var respJSON2 map[string]interface{}
  20907. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20908. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20910. return
  20911. }
  20912. userJSONBytes2, _ := json.Marshal(respJSON2)
  20913. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20914. utils.ErrorLog("解析失败:%v", err)
  20915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20916. return
  20917. }
  20918. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20919. var result string
  20920. var requestLog string
  20921. 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, "")
  20922. saveLog(result, requestLog, "2203", "上传就诊信息")
  20923. var respJSON2 map[string]interface{}
  20924. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20927. return
  20928. }
  20929. userJSONBytes2, _ := json.Marshal(respJSON2)
  20930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20931. utils.ErrorLog("解析失败:%v", err)
  20932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20933. return
  20934. }
  20935. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20936. data := make(map[string]interface{})
  20937. client := &http.Client{}
  20938. data["psn_no"] = his.PsnNo
  20939. data["mdtrt_id"] = his.Number
  20940. data["operator"] = roles.UserName
  20941. data["department"] = department.Name
  20942. data["org_name"] = miConfig.OrgName
  20943. var med_type string
  20944. if his.Insutype == "390" {
  20945. if reg_type == 992102 {
  20946. med_type = "992102"
  20947. data["sick_code"] = "ZDZ940"
  20948. data["sick_name"] = "慢性肾衰竭"
  20949. }
  20950. if reg_type == 140104 {
  20951. med_type = "140104"
  20952. data["sick_code"] = sickConfig.CountryCode
  20953. data["sick_name"] = sickConfig.ClassName
  20954. }
  20955. if reg_type == 14 {
  20956. med_type = "140104"
  20957. data["sick_code"] = sickConfig.CountryCode
  20958. data["sick_name"] = sickConfig.ClassName
  20959. }
  20960. } else if his.Insutype == "310" {
  20961. if reg_type == 992102 {
  20962. med_type = "992102"
  20963. data["sick_code"] = "ZDZ940"
  20964. data["sick_name"] = "慢性肾衰竭"
  20965. }
  20966. if reg_type == 140104 {
  20967. med_type = "140104"
  20968. data["sick_code"] = sickConfig.CountryCode
  20969. data["sick_name"] = sickConfig.ClassName
  20970. }
  20971. if reg_type == 14 {
  20972. med_type = "14"
  20973. data["sick_code"] = sickConfig.CountryCode
  20974. data["sick_name"] = sickConfig.ClassName
  20975. }
  20976. }
  20977. data["med_type"] = med_type
  20978. data["doctor_number"] = doctor_info.DoctorNumber
  20979. data["doctor_name"] = doctor_info.UserName
  20980. data["fixmedins_code"] = miConfig.Code
  20981. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20982. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20983. data["secret_key"] = miConfig.SecretKey
  20984. data["begin_time"] = begin_time
  20985. data["dept"] = strconv.FormatInt(department.ID, 10)
  20986. data["config"] = config
  20987. data["url"] = miConfig.Url
  20988. data["ak"] = miConfig.AccessKey
  20989. data["cainfo"] = miConfig.Cainfo
  20990. bytesData, _ := json.Marshal(data)
  20991. var req *http.Request
  20992. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  20993. resp, _ := client.Do(req)
  20994. defer resp.Body.Close()
  20995. body, ioErr := ioutil.ReadAll(resp.Body)
  20996. if ioErr != nil {
  20997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20999. return
  21000. }
  21001. var respJSON map[string]interface{}
  21002. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21005. return
  21006. }
  21007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21008. if status == "0" {
  21009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21010. c.ServeSuccessJSON(map[string]interface{}{
  21011. "failed_code": -10,
  21012. "msg": err_msg,
  21013. })
  21014. return
  21015. }
  21016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21017. userJSONBytes, _ := json.Marshal(respJSON)
  21018. fmt.Println("log")
  21019. fmt.Println(string(userJSONBytes))
  21020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21021. utils.ErrorLog("解析失败:%v", err)
  21022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21023. return
  21024. }
  21025. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21026. var result string
  21027. var requestLog string
  21028. 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, "")
  21029. saveLog(result, requestLog, "2203", "上传就诊信息")
  21030. var respJSON2 map[string]interface{}
  21031. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21034. return
  21035. }
  21036. userJSONBytes2, _ := json.Marshal(respJSON2)
  21037. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21038. utils.ErrorLog("解析失败:%v", err)
  21039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21040. return
  21041. }
  21042. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21043. data := make(map[string]interface{})
  21044. client := &http.Client{}
  21045. data["psn_no"] = his.PsnNo
  21046. data["mdtrt_id"] = his.Number
  21047. data["doctor"] = roles.UserName
  21048. data["department"] = department.Name
  21049. data["org_name"] = miConfig.OrgName
  21050. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21051. data["doctor_id"] = doctor_info.DoctorNumber
  21052. data["fixmedins_code"] = miConfig.Code
  21053. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21054. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21055. data["secret_key"] = miConfig.SecretKey
  21056. data["sick_code"] = sickConfig.CountryCode
  21057. data["sick_name"] = sickConfig.ClassName
  21058. data["begin_time"] = begin_time
  21059. data["new_doctor_name"] = doctor_info.UserName
  21060. data["dept"] = strconv.FormatInt(department.ID, 10)
  21061. data["config"] = config
  21062. bytesData, _ := json.Marshal(data)
  21063. var req *http.Request
  21064. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21065. resp, _ := client.Do(req)
  21066. defer resp.Body.Close()
  21067. body, ioErr := ioutil.ReadAll(resp.Body)
  21068. if ioErr != nil {
  21069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21071. return
  21072. }
  21073. var respJSON map[string]interface{}
  21074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21077. return
  21078. }
  21079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21080. userJSONBytes, _ := json.Marshal(respJSON)
  21081. fmt.Println("log")
  21082. fmt.Println(string(userJSONBytes))
  21083. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21084. utils.ErrorLog("解析失败:%v", err)
  21085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21086. return
  21087. }
  21088. } else {
  21089. var result string
  21090. var requestLog string
  21091. if miConfig.MdtrtareaAdmvs == "440781" { //
  21092. 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)
  21093. } else {
  21094. if miConfig.Code == "H15049901371" {
  21095. //赤峰地区国家医保医疗类别
  21096. //职工透析:医疗类别选特殊情况门诊990502
  21097. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21098. var med_type string
  21099. if his.Insutype == "390" {
  21100. if reg_type == 14 {
  21101. med_type = "9933"
  21102. } else if reg_type == 11 {
  21103. med_type = "11"
  21104. }
  21105. } else if his.Insutype == "310" {
  21106. if reg_type == 14 {
  21107. med_type = "990502"
  21108. } else if reg_type == 11 {
  21109. med_type = "11"
  21110. }
  21111. }
  21112. 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)
  21113. } else {
  21114. 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)
  21115. }
  21116. saveLog(result, requestLog, "2203", "上传就诊信息")
  21117. var respJSON2 map[string]interface{}
  21118. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21121. return
  21122. }
  21123. userJSONBytes2, _ := json.Marshal(respJSON2)
  21124. if miConfig.Code == "H15049901371" {
  21125. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21126. utils.ErrorLog("解析失败:%v", err)
  21127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21128. return
  21129. }
  21130. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21131. res2.Output = resSix10265.Output
  21132. res2.ErrMsg = resSix10265.ErrMsg
  21133. res2.Cainfo = resSix10265.Cainfo
  21134. res2.WarnMsg = resSix10265.WarnMsg
  21135. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21136. res2.Infcode = infocode
  21137. } else {
  21138. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21139. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21140. utils.ErrorLog("解析失败:%v", err)
  21141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21142. return
  21143. }
  21144. res2.Infcode = res3.Infcode
  21145. } else {
  21146. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21147. utils.ErrorLog("解析失败:%v", err)
  21148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21149. return
  21150. }
  21151. }
  21152. }
  21153. }
  21154. }
  21155. if res2.Infcode == -1 {
  21156. adminUser := c.GetAdminUserInfo()
  21157. errlog := &models.HisOrderError{
  21158. UserOrgId: adminUser.CurrentOrgId,
  21159. Ctime: time.Now().Unix(),
  21160. Mtime: time.Now().Unix(),
  21161. ErrMsg: res2.ErrMsg,
  21162. Status: 1,
  21163. PatientId: id,
  21164. RecordTime: recordDateTime,
  21165. Stage: 3,
  21166. }
  21167. service.CreateErrMsgLog(errlog)
  21168. c.ServeSuccessJSON(map[string]interface{}{
  21169. "failed_code": -10,
  21170. "msg": res2.ErrMsg,
  21171. })
  21172. return
  21173. }
  21174. if res2.Infcode != 0 {
  21175. adminUser := c.GetAdminUserInfo()
  21176. errlog := &models.HisOrderError{
  21177. UserOrgId: adminUser.CurrentOrgId,
  21178. Ctime: time.Now().Unix(),
  21179. Mtime: time.Now().Unix(),
  21180. ErrMsg: res2.ErrMsg,
  21181. Status: 1,
  21182. PatientId: id,
  21183. RecordTime: recordDateTime,
  21184. Stage: 3,
  21185. }
  21186. service.CreateErrMsgLog(errlog)
  21187. c.ServeSuccessJSON(map[string]interface{}{
  21188. "failed_code": -10,
  21189. "msg": res2.ErrMsg,
  21190. })
  21191. return
  21192. } else {
  21193. his.Diagnosis = diagnosis_id
  21194. his.SickType = sickConfig.ID
  21195. his.PType = fmt.Sprintf("%d", reg_type)
  21196. service.UpdateHisPatientThree(&his)
  21197. data := make(map[string]interface{})
  21198. if settle_accounts_type == 1 { //日结
  21199. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21200. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21201. } else {
  21202. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21203. }
  21204. data["pre"] = prescriptions
  21205. } else { //月结
  21206. start_time_str := c.GetString("start_time")
  21207. end_time_str := c.GetString("end_time")
  21208. timeLayout := "2006-01-02"
  21209. loc, _ := time.LoadLocation("Local")
  21210. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21211. if err != nil {
  21212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21213. return
  21214. }
  21215. recordStartTime := theStartTime.Unix()
  21216. start_time = recordStartTime
  21217. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21218. if err != nil {
  21219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21220. return
  21221. }
  21222. recordEndTime := theEndTime.Unix()
  21223. end_time = recordEndTime
  21224. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21225. data["pre"] = prescriptions
  21226. }
  21227. client := &http.Client{}
  21228. data["psn_no"] = his.PsnNo
  21229. data["mdtrt_id"] = his.Number
  21230. data["chrg_bchno"] = chrg_bchno
  21231. data["org_name"] = miConfig.OrgName
  21232. data["doctor"] = doctor_info.UserName
  21233. data["doctor_id"] = doctor_info.DoctorNumber
  21234. data["dept"] = department.Name
  21235. data["fixmedins_code"] = miConfig.Code
  21236. data["opter"] = roles.UserName
  21237. data["dept_code"] = department.Number
  21238. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21239. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21240. data["secret_key"] = miConfig.SecretKey
  21241. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21242. data["url"] = miConfig.Url
  21243. data["ak"] = miConfig.AccessKey
  21244. data["new_doctor_name"] = patientPrescription.Doctor
  21245. if his.Insutype == "390" {
  21246. if reg_type == 992102 {
  21247. data["diag_code"] = "ZDZ940"
  21248. }
  21249. if reg_type == 140104 {
  21250. data["diag_code"] = sickConfig.CountryCode
  21251. }
  21252. if reg_type == 14 {
  21253. data["diag_code"] = sickConfig.CountryCode
  21254. }
  21255. } else if his.Insutype == "310" {
  21256. if reg_type == 992102 {
  21257. data["diag_code"] = "ZDZ940"
  21258. }
  21259. if reg_type == 14 {
  21260. data["diag_code"] = sickConfig.CountryCode
  21261. }
  21262. }
  21263. data["cainfo"] = miConfig.Cainfo
  21264. data["opter"] = roles.UserName
  21265. var ids []int64
  21266. for _, item := range prescriptions {
  21267. ids = append(ids, item.ID)
  21268. }
  21269. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21270. if config.IsOpen == 1 { //对接了医保,走医保流程
  21271. var res ResultFour
  21272. var resFour10265 ResultFour10265
  21273. if miConfig.MdtrtareaAdmvs == "421300" {
  21274. bytesData, _ := json.Marshal(data)
  21275. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21276. resp, _ := client.Do(req)
  21277. defer resp.Body.Close()
  21278. body, ioErr := ioutil.ReadAll(resp.Body)
  21279. if ioErr != nil {
  21280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21282. return
  21283. }
  21284. var respJSON map[string]interface{}
  21285. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21288. return
  21289. }
  21290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21291. userJSONBytes, _ := json.Marshal(respJSON)
  21292. fmt.Println("log")
  21293. fmt.Println(string(userJSONBytes))
  21294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21295. utils.ErrorLog("解析失败:%v", err)
  21296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21297. return
  21298. }
  21299. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21300. bytesData, _ := json.Marshal(data)
  21301. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21302. resp, _ := client.Do(req)
  21303. defer resp.Body.Close()
  21304. body, ioErr := ioutil.ReadAll(resp.Body)
  21305. if ioErr != nil {
  21306. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21308. return
  21309. }
  21310. var respJSON map[string]interface{}
  21311. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21312. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21314. return
  21315. }
  21316. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21317. userJSONBytes, _ := json.Marshal(respJSON)
  21318. fmt.Println("log")
  21319. fmt.Println(string(userJSONBytes))
  21320. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21321. utils.ErrorLog("解析失败:%v", err)
  21322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21323. return
  21324. }
  21325. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21326. bytesData, _ := json.Marshal(data)
  21327. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21328. resp, _ := client.Do(req)
  21329. defer resp.Body.Close()
  21330. body, ioErr := ioutil.ReadAll(resp.Body)
  21331. if ioErr != nil {
  21332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21334. return
  21335. }
  21336. var respJSON map[string]interface{}
  21337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21340. return
  21341. }
  21342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21343. userJSONBytes, _ := json.Marshal(respJSON)
  21344. fmt.Println("log")
  21345. fmt.Println(string(userJSONBytes))
  21346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21347. utils.ErrorLog("解析失败:%v", err)
  21348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21349. return
  21350. }
  21351. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21352. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21353. if result3101.Infcode == "0" {
  21354. if len(result3101.Output.Result) > 0 {
  21355. var errMsgs []string
  21356. for _, item := range result3101.Output.Result {
  21357. errMsgs = append(errMsgs, item.VolaCont)
  21358. }
  21359. c.ServeSuccessJSON(map[string]interface{}{
  21360. "failed_code": -10,
  21361. "msg": errMsgs,
  21362. })
  21363. return
  21364. } else {
  21365. if miConfig.MdtrtareaAdmvs == "320921" {
  21366. data["doctor_id"] = "D320923012139"
  21367. } else {
  21368. data["doctor_id"] = "D371621008686"
  21369. }
  21370. bytesData, _ := json.Marshal(data)
  21371. var req *http.Request
  21372. if miConfig.MdtrtareaAdmvs == "320921" {
  21373. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21374. } else {
  21375. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21376. }
  21377. resp, _ := client.Do(req)
  21378. defer resp.Body.Close()
  21379. body, ioErr := ioutil.ReadAll(resp.Body)
  21380. if ioErr != nil {
  21381. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21383. return
  21384. }
  21385. var respJSON map[string]interface{}
  21386. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21387. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21389. return
  21390. }
  21391. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21392. userJSONBytes, _ := json.Marshal(respJSON)
  21393. fmt.Println("log")
  21394. fmt.Println(string(userJSONBytes))
  21395. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21396. utils.ErrorLog("解析失败:%v", err)
  21397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21398. return
  21399. }
  21400. res.InfRefmsgid = resFour10265.InfRefmsgid
  21401. res.Output = resFour10265.Output
  21402. res.ErrMsg = resFour10265.ErrMsg
  21403. res.Cainfo = resFour10265.Cainfo
  21404. res.WarnMsg = resFour10265.WarnMsg
  21405. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21406. res.Infcode = infocode
  21407. }
  21408. }
  21409. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21410. var pagesize int = 5
  21411. var start int = 1
  21412. var stop int
  21413. var pagecount int
  21414. var curpage int
  21415. data["doctor_id"] = doctor_info.DoctorNumber
  21416. var res2 ResultFour
  21417. //var result res.
  21418. //总页数,向上取整,注意除之前要先转换类型为float64
  21419. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  21420. for curpage = 1; curpage <= pagecount; curpage++ {
  21421. if curpage == 1 {
  21422. start = 1
  21423. } else {
  21424. start = (curpage-1)*pagesize + 1
  21425. }
  21426. stop = curpage * pagesize
  21427. if stop > len(prescriptions) {
  21428. stop = len(prescriptions)
  21429. }
  21430. //var requestLog string
  21431. data["pre"] = prescriptions[start-1 : stop]
  21432. fmt.Println(data["pre"])
  21433. bytesData, _ := json.Marshal(data)
  21434. var req *http.Request
  21435. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  21436. resp, _ := client.Do(req)
  21437. defer resp.Body.Close()
  21438. body, ioErr := ioutil.ReadAll(resp.Body)
  21439. if ioErr != nil {
  21440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21442. return
  21443. }
  21444. var respJSON map[string]interface{}
  21445. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21448. return
  21449. }
  21450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21451. userJSONBytes, _ := json.Marshal(respJSON)
  21452. fmt.Println("log")
  21453. fmt.Println(string(userJSONBytes))
  21454. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21455. utils.ErrorLog("解析失败:%v", err)
  21456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21457. return
  21458. }
  21459. res.InfRefmsgid = resFour10265.InfRefmsgid
  21460. res.Output = resFour10265.Output
  21461. res.ErrMsg = resFour10265.ErrMsg
  21462. res.Cainfo = resFour10265.Cainfo
  21463. res.WarnMsg = resFour10265.WarnMsg
  21464. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21465. res.Infcode = infocode
  21466. if infocode == 0 {
  21467. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  21468. } else {
  21469. isSuccess = false
  21470. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  21471. res.Infcode = -1
  21472. res.ErrMsg = resFour10265.ErrMsg
  21473. errlog := &models.HisOrderError{
  21474. UserOrgId: adminUser.CurrentOrgId,
  21475. Ctime: time.Now().Unix(),
  21476. Mtime: time.Now().Unix(),
  21477. Number: chrg_bchno,
  21478. ErrMsg: "",
  21479. Status: 1,
  21480. PatientId: id,
  21481. RecordTime: recordDateTime,
  21482. Stage: 4,
  21483. }
  21484. service.CreateErrMsgLog(errlog)
  21485. }
  21486. }
  21487. if isSuccess {
  21488. res.Infcode = 0
  21489. res.Output.Result = res2.Output.Result
  21490. } else {
  21491. order := &models.HisOrder{
  21492. UserOrgId: adminUser.CurrentOrgId,
  21493. HisPatientId: his.ID,
  21494. PatientId: his.PatientId,
  21495. SettleAccountsDate: recordDateTime,
  21496. Ctime: time.Now().Unix(),
  21497. Mtime: time.Now().Unix(),
  21498. MdtrtId: his.Number,
  21499. PsnNo: his.PsnNo,
  21500. MedType: strconv.FormatInt(reg_type, 10),
  21501. Status: 1,
  21502. Number: chrg_bchno,
  21503. Infcode: res.Infcode,
  21504. WarnMsg: res.WarnMsg,
  21505. Cainfo: res.Cainfo,
  21506. ErrMsg: res.ErrMsg,
  21507. RespondTime: res.RefmsgTime,
  21508. InfRefmsgid: res.InfRefmsgid,
  21509. OrderStatus: 1,
  21510. IsMedicineInsurance: 1,
  21511. SettleType: settle_accounts_type,
  21512. SettleStartTime: start_time,
  21513. SettleEndTime: end_time,
  21514. Creator: roles.AdminUserId,
  21515. Modify: roles.AdminUserId,
  21516. PType: 2,
  21517. Diagnosis: diagnosis_id,
  21518. }
  21519. err = service.CreateOrder(order)
  21520. if err != nil {
  21521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21522. return
  21523. }
  21524. c.ServeSuccessJSON(map[string]interface{}{
  21525. "failed_code": -10,
  21526. "msg": res2.ErrMsg,
  21527. })
  21528. return
  21529. }
  21530. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21531. 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)
  21532. var dat map[string]interface{}
  21533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21534. fmt.Println(dat)
  21535. } else {
  21536. fmt.Println(err)
  21537. }
  21538. saveLog(result, request_log, "2204", "上传费用明细")
  21539. userJSONBytes, _ := json.Marshal(dat)
  21540. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21541. utils.ErrorLog("解析失败:%v", err)
  21542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21543. return
  21544. }
  21545. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21546. 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, "", "")
  21547. var dat map[string]interface{}
  21548. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21549. fmt.Println(dat)
  21550. } else {
  21551. fmt.Println(err)
  21552. }
  21553. saveLog(result, request_log, "2204", "上传费用明细")
  21554. userJSONBytes, _ := json.Marshal(dat)
  21555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21556. utils.ErrorLog("解析失败:%v", err)
  21557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21558. return
  21559. }
  21560. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21561. bytesData, _ := json.Marshal(data)
  21562. var req *http.Request
  21563. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  21564. resp, _ := client.Do(req)
  21565. defer resp.Body.Close()
  21566. body, ioErr := ioutil.ReadAll(resp.Body)
  21567. if ioErr != nil {
  21568. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21570. return
  21571. }
  21572. var respJSON map[string]interface{}
  21573. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21574. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21576. return
  21577. }
  21578. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21579. if status == "0" {
  21580. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21581. c.ServeSuccessJSON(map[string]interface{}{
  21582. "failed_code": -10,
  21583. "msg": err_msg,
  21584. })
  21585. return
  21586. }
  21587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21588. userJSONBytes, _ := json.Marshal(respJSON)
  21589. fmt.Println("log")
  21590. fmt.Println(string(userJSONBytes))
  21591. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21592. utils.ErrorLog("解析失败:%v", err)
  21593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21594. return
  21595. }
  21596. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21597. 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, "", "")
  21598. var dat map[string]interface{}
  21599. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21600. fmt.Println(dat)
  21601. } else {
  21602. fmt.Println(err)
  21603. }
  21604. saveLog(result, request_log, "2204", "上传费用明细")
  21605. userJSONBytes, _ := json.Marshal(dat)
  21606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21607. utils.ErrorLog("解析失败:%v", err)
  21608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21609. return
  21610. }
  21611. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21612. bytesData, _ := json.Marshal(data)
  21613. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  21614. resp, _ := client.Do(req)
  21615. defer resp.Body.Close()
  21616. body, ioErr := ioutil.ReadAll(resp.Body)
  21617. if ioErr != nil {
  21618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21620. return
  21621. }
  21622. var respJSON map[string]interface{}
  21623. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21626. return
  21627. }
  21628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21629. userJSONBytes, _ := json.Marshal(respJSON)
  21630. fmt.Println("log")
  21631. fmt.Println(string(userJSONBytes))
  21632. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21633. utils.ErrorLog("解析失败:%v", err)
  21634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21635. return
  21636. }
  21637. } else {
  21638. if miConfig.MdtrtareaAdmvs == "441202" {
  21639. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21640. if result3101.Infcode == 0 {
  21641. if len(result3101.Output.Result) > 0 {
  21642. var errMsgs []string
  21643. for _, item := range result3101.Output.Result {
  21644. errMsgs = append(errMsgs, item.VolaCont)
  21645. }
  21646. c.ServeSuccessJSON(map[string]interface{}{
  21647. "failed_code": -10,
  21648. "msg": errMsgs,
  21649. })
  21650. return
  21651. } else {
  21652. 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)
  21653. var dat map[string]interface{}
  21654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21655. fmt.Println(dat)
  21656. } else {
  21657. fmt.Println(err)
  21658. }
  21659. saveLog(result, request_log, "2204", "上传费用明细")
  21660. userJSONBytes, _ := json.Marshal(dat)
  21661. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21662. utils.ErrorLog("解析失败:%v", err)
  21663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21664. return
  21665. }
  21666. }
  21667. } else {
  21668. c.ServeSuccessJSON(map[string]interface{}{
  21669. "failed_code": -10,
  21670. "msg": result3101.ErrMsg,
  21671. })
  21672. return
  21673. }
  21674. } else {
  21675. if miConfig.Code == "H15049901371" {
  21676. 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)
  21677. var dat map[string]interface{}
  21678. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21679. fmt.Println(dat)
  21680. } else {
  21681. fmt.Println(err)
  21682. }
  21683. saveLog(result, request_log, "2204", "上传费用明细")
  21684. userJSONBytes, _ := json.Marshal(dat)
  21685. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21686. utils.ErrorLog("解析失败:%v", err)
  21687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21688. return
  21689. }
  21690. res.InfRefmsgid = resFour10265.InfRefmsgid
  21691. res.Output = resFour10265.Output
  21692. res.ErrMsg = resFour10265.ErrMsg
  21693. res.Cainfo = resFour10265.Cainfo
  21694. res.WarnMsg = resFour10265.WarnMsg
  21695. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21696. res.Infcode = infocode
  21697. } else {
  21698. 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)
  21699. var dat map[string]interface{}
  21700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21701. fmt.Println(dat)
  21702. } else {
  21703. fmt.Println(err)
  21704. }
  21705. saveLog(result, request_log, "2204", "上传费用明细")
  21706. userJSONBytes, _ := json.Marshal(dat)
  21707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21708. utils.ErrorLog("解析失败:%v", err)
  21709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21710. return
  21711. }
  21712. }
  21713. }
  21714. }
  21715. var total_two float64
  21716. if res.Infcode == 0 {
  21717. order := &models.HisOrder{
  21718. UserOrgId: adminUser.CurrentOrgId,
  21719. HisPatientId: his.ID,
  21720. PatientId: his.PatientId,
  21721. SettleAccountsDate: recordDateTime,
  21722. Ctime: time.Now().Unix(),
  21723. Mtime: time.Now().Unix(),
  21724. MdtrtId: his.Number,
  21725. PsnNo: his.PsnNo,
  21726. MedType: strconv.FormatInt(reg_type, 10),
  21727. Status: 1,
  21728. Number: chrg_bchno,
  21729. Infcode: res.Infcode,
  21730. WarnMsg: res.WarnMsg,
  21731. Cainfo: res.Cainfo,
  21732. ErrMsg: res.ErrMsg,
  21733. RespondTime: res.RefmsgTime,
  21734. InfRefmsgid: res.InfRefmsgid,
  21735. OrderStatus: 1,
  21736. IsMedicineInsurance: 1,
  21737. SettleType: settle_accounts_type,
  21738. SettleStartTime: start_time,
  21739. SettleEndTime: end_time,
  21740. Creator: roles.AdminUserId,
  21741. Modify: roles.AdminUserId,
  21742. PType: 2,
  21743. Diagnosis: diagnosis_id,
  21744. }
  21745. err = service.CreateOrder(order)
  21746. if err != nil {
  21747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21748. return
  21749. }
  21750. for _, item := range res.Output.Result {
  21751. temp := strings.Split(item.FeedetlSn, "-")
  21752. var advice_id int64 = 0
  21753. var project_id int64 = 0
  21754. var types int64 = 0
  21755. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21756. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21757. if temp[1] == "1" {
  21758. advice_id = id
  21759. project_id = 0
  21760. } else if temp[1] == "2" {
  21761. advice_id = 0
  21762. project_id = id
  21763. }
  21764. total_two = total_two + item.DetItemFeeSumamt
  21765. info := &models.HisOrderInfo{
  21766. OrderNumber: order.Number,
  21767. FeedetlSn: item.FeedetlSn,
  21768. UploadDate: time.Now().Unix(),
  21769. AdviceId: advice_id,
  21770. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21771. Cnt: item.Cnt,
  21772. Pric: float64(item.Pric),
  21773. PatientId: his.PatientId,
  21774. PricUplmtAmt: item.PricUplmtAmt,
  21775. SelfpayProp: item.SelfpayProp,
  21776. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21777. OverlmtAmt: item.OverlmtAmt,
  21778. PreselfpayAmt: item.PreselfpayAmt,
  21779. BasMednFlag: item.BasMednFlag,
  21780. MedChrgitmType: item.MedChrgitmType,
  21781. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21782. Status: 1,
  21783. Memo: item.Memo,
  21784. Mtime: time.Now().Unix(),
  21785. InscpScpAmt: item.InscpScpAmt,
  21786. DrtReimFlag: item.DrtReimFlag,
  21787. Ctime: time.Now().Unix(),
  21788. ListSpItemFlag: item.ListSpItemFlag,
  21789. ChldMedcFlag: item.ChldMedcFlag,
  21790. LmtUsedFlag: item.LmtUsedFlag,
  21791. ChrgitmLv: item.ChrgitmLv,
  21792. UserOrgId: adminUser.CurrentOrgId,
  21793. HisPatientId: his.ID,
  21794. OrderId: order.ID,
  21795. ProjectId: project_id,
  21796. Type: types,
  21797. }
  21798. service.CreateOrderInfo(info)
  21799. }
  21800. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21801. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21802. var total float64
  21803. for _, item := range prescriptions {
  21804. if item.Type == 1 { //药品
  21805. for _, subItem := range item.HisDoctorAdviceInfo {
  21806. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21807. total_one := price * subItem.PrescribingNumber
  21808. fmt.Println("subItem")
  21809. fmt.Println(subItem.Price)
  21810. fmt.Println("price")
  21811. fmt.Println(price)
  21812. fmt.Println("total_one")
  21813. fmt.Println(total_one)
  21814. total = total + total_one
  21815. fmt.Println(total)
  21816. }
  21817. }
  21818. if item.Type == 2 { //项目
  21819. for _, subItem := range item.HisPrescriptionProject {
  21820. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21821. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21822. total_one := price * cnt
  21823. total = total + total_one
  21824. }
  21825. }
  21826. }
  21827. allTotal := fmt.Sprintf("%.2f", total)
  21828. if res.Infcode == 0 {
  21829. var rf []*ResultFive
  21830. json.Unmarshal([]byte(his.Iinfo), &rf)
  21831. chrg_bchno := chrg_bchno
  21832. cert_no := his.Certno
  21833. var insutypes []string
  21834. var insutype string
  21835. var is390 int = 0
  21836. var is310 int = 0
  21837. for _, item := range rf {
  21838. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21839. insutypes = append(insutypes, item.Insutype)
  21840. }
  21841. }
  21842. if len(insutypes) == 1 {
  21843. insutype = insutypes[0]
  21844. } else {
  21845. for _, i := range insutypes {
  21846. if i == "390" {
  21847. is390 = 1
  21848. }
  21849. if i == "310" {
  21850. is310 = 1
  21851. }
  21852. }
  21853. }
  21854. if is390 == 1 {
  21855. insutype = "390"
  21856. }
  21857. if is310 == 1 {
  21858. insutype = "310"
  21859. }
  21860. if len(insutypes) == 0 {
  21861. insutype = "390"
  21862. }
  21863. if len(insutypes) == 2 {
  21864. insutype = strconv.FormatInt(his.SocialType, 10)
  21865. }
  21866. //insutype = "390"
  21867. if his.IdCardType == 1 {
  21868. cert_no = his.MedicalInsuranceNumber
  21869. } else {
  21870. cert_no = his.Certno
  21871. }
  21872. var res ResultSeven
  21873. var ahres ResultSevenAH
  21874. var resSeven10265 ResultSeven10265
  21875. var resSeven10265Two ResultSeven10265Two
  21876. var gzresSeven10265Two GZResultSeven10265Two
  21877. if miConfig.MdtrtareaAdmvs == "421300" {
  21878. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21879. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21880. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21881. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21883. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21884. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21885. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21886. resp, requestErr := http.Get(api)
  21887. if requestErr != nil {
  21888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21889. return
  21890. }
  21891. body, ioErr := ioutil.ReadAll(resp.Body)
  21892. if ioErr != nil {
  21893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21895. return
  21896. }
  21897. var respJSON map[string]interface{}
  21898. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21901. return
  21902. }
  21903. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21904. result, _ := json.Marshal(respJSON)
  21905. fmt.Println("log")
  21906. fmt.Println(string(result))
  21907. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21908. utils.ErrorLog("解析失败:%v", err)
  21909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21910. return
  21911. }
  21912. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21913. if reg_type == 11 && his.Insutype == "390" {
  21914. reg_type = 110104
  21915. }
  21916. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21917. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21918. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21919. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21920. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21921. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21922. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21923. resp, requestErr := http.Get(api)
  21924. if requestErr != nil {
  21925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21926. return
  21927. }
  21928. body, ioErr := ioutil.ReadAll(resp.Body)
  21929. if ioErr != nil {
  21930. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21932. return
  21933. }
  21934. var respJSON map[string]interface{}
  21935. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21936. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21938. return
  21939. }
  21940. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21941. result, _ := json.Marshal(respJSON)
  21942. fmt.Println("log")
  21943. fmt.Println(string(result))
  21944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21945. utils.ErrorLog("解析失败:%v", err)
  21946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21947. return
  21948. }
  21949. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21950. if reg_type == 11 && his.Insutype == "390" {
  21951. reg_type = 110104
  21952. }
  21953. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21954. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21955. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21957. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21958. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21959. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21960. resp, requestErr := http.Get(api)
  21961. if requestErr != nil {
  21962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21963. return
  21964. }
  21965. body, ioErr := ioutil.ReadAll(resp.Body)
  21966. if ioErr != nil {
  21967. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21969. return
  21970. }
  21971. var respJSON map[string]interface{}
  21972. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21973. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21975. return
  21976. }
  21977. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21978. result, _ := json.Marshal(respJSON)
  21979. fmt.Println("log")
  21980. fmt.Println(string(result))
  21981. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21982. utils.ErrorLog("解析失败:%v", err)
  21983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21984. return
  21985. }
  21986. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21987. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21988. if result3101.Infcode == "0" {
  21989. if len(result3101.Output.Result) > 0 {
  21990. var errMsgs []string
  21991. for _, item := range result3101.Output.Result {
  21992. errMsgs = append(errMsgs, item.VolaCont)
  21993. }
  21994. c.ServeSuccessJSON(map[string]interface{}{
  21995. "failed_code": -10,
  21996. "msg": errMsgs,
  21997. })
  21998. return
  21999. } else {
  22000. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22001. if his.IdCardType != 4 {
  22002. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22003. bas := strings.Split(psn_info.CardInfo, "|")
  22004. if his.IdCardType == 1 {
  22005. cert_no = bas[2]
  22006. } else {
  22007. cert_no = bas[1]
  22008. }
  22009. } else {
  22010. cert_no = his.Certno
  22011. }
  22012. //江苏地区国家医保医疗类别
  22013. //职工透析:医疗类别选特殊情况门诊9933
  22014. //居民血透门慢: 医疗类别选门诊慢病1402
  22015. //var med_type string
  22016. //if his.Insutype == "310" {
  22017. // if reg_type == 14 {
  22018. // med_type = "9933"
  22019. // } else if reg_type == 11 {
  22020. // med_type = "11"
  22021. //
  22022. // }
  22023. //} else if his.Insutype == "390" {
  22024. // if reg_type == 14 {
  22025. // med_type = "1402"
  22026. // } else if reg_type == 11 {
  22027. // med_type = "11"
  22028. // }
  22029. //}
  22030. var api string
  22031. if miConfig.MdtrtareaAdmvs == "320921" {
  22032. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22033. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22034. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22035. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22036. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22037. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22038. "&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
  22039. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22040. } else {
  22041. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22042. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22043. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22044. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22045. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22046. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22047. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22048. "&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
  22049. }
  22050. resp, requestErr := http.Get(api)
  22051. if requestErr != nil {
  22052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22053. return
  22054. }
  22055. body, ioErr := ioutil.ReadAll(resp.Body)
  22056. if ioErr != nil {
  22057. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22059. return
  22060. }
  22061. var respJSON map[string]interface{}
  22062. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22063. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22065. return
  22066. }
  22067. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22068. result, _ := json.Marshal(respJSON)
  22069. fmt.Println("log")
  22070. fmt.Println(string(result))
  22071. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22072. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22073. utils.ErrorLog("解析失败:%v", err)
  22074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22075. return
  22076. }
  22077. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22078. res.Output = resSeven10265.Output
  22079. res.ErrMsg = resSeven10265.ErrMsg
  22080. res.Cainfo = resSeven10265.Cainfo
  22081. res.WarnMsg = resSeven10265.WarnMsg
  22082. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22083. res.Infcode = infocode
  22084. } else {
  22085. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22086. utils.ErrorLog("解析失败:%v", err)
  22087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22088. return
  22089. }
  22090. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22091. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22092. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22093. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22094. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22095. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22096. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22097. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22098. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22099. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22100. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22101. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22102. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22103. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22104. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22105. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22106. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22107. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22108. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22109. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22110. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22111. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22112. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22113. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22114. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22115. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22116. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22117. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22118. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22119. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22120. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22121. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22122. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22123. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22124. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22125. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22126. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22127. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22128. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22129. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22130. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22131. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22132. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22133. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22134. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22135. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22136. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22137. res.ErrMsg = resSeven10265Two.ErrMsg
  22138. res.Cainfo = resSeven10265Two.Cainfo
  22139. res.WarnMsg = resSeven10265Two.WarnMsg
  22140. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22141. res.Infcode = infocode
  22142. }
  22143. }
  22144. }
  22145. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22146. psn_info, _ := service.GetPsnByPatientId(id)
  22147. var verify_number string
  22148. if psn_info.IdCardType == 4 {
  22149. verify_number = psn_info.VerifyNumber
  22150. } else if psn_info.IdCardType == 1 {
  22151. bas := strings.Split(psn_info.CardInfo, "|")
  22152. cardNumber := bas[2]
  22153. verify_number = cardNumber
  22154. } else {
  22155. psn_info.IdCardType = 2
  22156. verify_number = psn_info.Certno
  22157. }
  22158. var api string
  22159. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22160. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22161. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22162. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22163. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22164. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22165. "&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
  22166. resp, requestErr := http.Get(api)
  22167. if requestErr != nil {
  22168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22169. return
  22170. }
  22171. body, ioErr := ioutil.ReadAll(resp.Body)
  22172. if ioErr != nil {
  22173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22175. return
  22176. }
  22177. var respJSON map[string]interface{}
  22178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22181. return
  22182. }
  22183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22184. result, _ := json.Marshal(respJSON)
  22185. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22186. utils.ErrorLog("解析失败:%v", err)
  22187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22188. return
  22189. }
  22190. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22191. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22192. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22193. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22194. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22195. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22196. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22197. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22198. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22199. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22200. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22201. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22202. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22203. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22204. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22205. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22206. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22207. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22208. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22209. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22210. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22211. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22212. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22213. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22214. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22215. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22216. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22217. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22218. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22219. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22220. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22221. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22222. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22223. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22224. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22225. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22226. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22227. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22228. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22229. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22230. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22231. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22232. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22233. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22234. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22235. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22236. res.ErrMsg = resSeven10265.ErrMsg
  22237. res.Cainfo = resSeven10265.Cainfo
  22238. res.WarnMsg = resSeven10265.WarnMsg
  22239. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22240. res.Infcode = infocode
  22241. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22242. acct_used_flag := "1"
  22243. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22244. var result string
  22245. var request_log string
  22246. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22247. 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)
  22248. } else {
  22249. 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)
  22250. }
  22251. var dat map[string]interface{}
  22252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22253. fmt.Println(dat)
  22254. } else {
  22255. fmt.Println(err)
  22256. }
  22257. saveLog(result, request_log, "2206", "预结算")
  22258. userJSONBytes, _ := json.Marshal(dat)
  22259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22260. utils.ErrorLog("解析失败:%v", err)
  22261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22262. return
  22263. }
  22264. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22265. var result string
  22266. var request_log string
  22267. if his.IdCardType == 2 {
  22268. 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, "")
  22269. } else if his.IdCardType == 1 {
  22270. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22271. bas := strings.Split(psn_info.CardInfo, "|")
  22272. basNumber := bas[2]
  22273. card_sn := bas[3]
  22274. var rf []*ResultFive
  22275. json.Unmarshal([]byte(his.Iinfo), &rf)
  22276. var psn_type string
  22277. for _, item := range rf {
  22278. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  22279. psn_type = item.PsnType
  22280. }
  22281. }
  22282. 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)
  22283. } else {
  22284. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22285. 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, "")
  22286. }
  22287. var dat map[string]interface{}
  22288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22289. fmt.Println(dat)
  22290. } else {
  22291. fmt.Println(err)
  22292. }
  22293. saveLog(result, request_log, "2206", "预结算")
  22294. userJSONBytes, _ := json.Marshal(dat)
  22295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22296. utils.ErrorLog("解析失败:%v", err)
  22297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22298. return
  22299. }
  22300. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22301. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22302. if his.IdCardType == 4 {
  22303. psn_info.VerifyNumber = psn_info.VerifyNumber
  22304. cert_no = psn_info.Certno
  22305. } else if his.IdCardType == 2 {
  22306. cert_no = psn_info.Certno
  22307. psn_info.VerifyNumber = psn_info.Certno
  22308. } else {
  22309. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22310. bas := strings.Split(psn_info.CardInfo, "|")
  22311. if his.IdCardType == 1 {
  22312. cert_no = bas[2]
  22313. } else {
  22314. cert_no = bas[1]
  22315. }
  22316. }
  22317. var api string
  22318. var med_type string
  22319. if his.Insutype == "390" {
  22320. if reg_type == 992102 {
  22321. med_type = "992102"
  22322. }
  22323. if reg_type == 140104 {
  22324. med_type = "140104"
  22325. }
  22326. if reg_type == 14 {
  22327. med_type = "140104"
  22328. }
  22329. } else if his.Insutype == "310" {
  22330. if reg_type == 992102 {
  22331. med_type = "992102"
  22332. }
  22333. if reg_type == 14 {
  22334. med_type = "14"
  22335. }
  22336. }
  22337. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22338. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22339. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22340. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22341. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22342. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22343. "&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
  22344. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22345. resp, requestErr := http.Get(api)
  22346. if requestErr != nil {
  22347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22348. return
  22349. }
  22350. body, ioErr := ioutil.ReadAll(resp.Body)
  22351. if ioErr != nil {
  22352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22354. return
  22355. }
  22356. var respJSON map[string]interface{}
  22357. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22360. return
  22361. }
  22362. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22363. if status == "0" {
  22364. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22365. c.ServeSuccessJSON(map[string]interface{}{
  22366. "failed_code": -10,
  22367. "msg": err_msg,
  22368. })
  22369. return
  22370. }
  22371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22372. result, _ := json.Marshal(respJSON)
  22373. fmt.Println("log")
  22374. fmt.Println(string(result))
  22375. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  22376. utils.ErrorLog("解析失败:%v", err)
  22377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22378. return
  22379. }
  22380. res.InfRefmsgid = ahres.InfRefmsgid
  22381. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22382. // 创建对应的Time类型
  22383. t := time.UnixMilli(timestamp)
  22384. // 格式化成指定的日期字符串
  22385. str := t.Format("2006-01-02 15:04:05")
  22386. res.Output.Setlinfo.SetlTime = str
  22387. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22388. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22389. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22390. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22391. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22392. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22393. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22394. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22395. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22396. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22397. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22398. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22399. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22400. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22401. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22402. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22403. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22404. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22405. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22406. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22407. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22408. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22409. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22410. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22411. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22412. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22413. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22414. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22415. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22416. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22417. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22418. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22419. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22420. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  22421. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22422. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  22423. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  22424. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  22425. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  22426. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22427. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  22428. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22429. //res.Output.Setldetail = ahres.Output.Setldetail
  22430. res.ErrMsg = ahres.ErrMsg
  22431. res.Cainfo = ahres.Cainfo
  22432. res.WarnMsg = ahres.WarnMsg
  22433. res.Infcode = ahres.Infcode
  22434. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22435. var result string
  22436. var request_log string
  22437. if his.IdCardType == 2 {
  22438. 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")
  22439. } else if his.IdCardType == 1 {
  22440. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22441. bas := strings.Split(psn_info.CardInfo, "|")
  22442. basNumber := bas[2]
  22443. card_sn := bas[3]
  22444. 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")
  22445. } else {
  22446. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22447. 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")
  22448. }
  22449. var dat map[string]interface{}
  22450. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22451. fmt.Println(dat)
  22452. } else {
  22453. fmt.Println(err)
  22454. }
  22455. saveLog(result, request_log, "2206", "预结算")
  22456. userJSONBytes, _ := json.Marshal(dat)
  22457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22458. utils.ErrorLog("解析失败:%v", err)
  22459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22460. return
  22461. }
  22462. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22463. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22464. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22465. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22466. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22467. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22468. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22469. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22470. resp, requestErr := http.Get(api)
  22471. if requestErr != nil {
  22472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22473. return
  22474. }
  22475. body, ioErr := ioutil.ReadAll(resp.Body)
  22476. if ioErr != nil {
  22477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22479. return
  22480. }
  22481. var respJSON map[string]interface{}
  22482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22485. return
  22486. }
  22487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22488. result, _ := json.Marshal(respJSON)
  22489. fmt.Println("log")
  22490. fmt.Println(string(result))
  22491. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22492. utils.ErrorLog("解析失败:%v", err)
  22493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22494. return
  22495. }
  22496. } else {
  22497. if miConfig.MdtrtareaAdmvs == "441202" {
  22498. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22499. if result3101.Infcode == 0 {
  22500. if len(result3101.Output.Result) > 0 {
  22501. var errMsgs []string
  22502. for _, item := range result3101.Output.Result {
  22503. errMsgs = append(errMsgs, item.VolaCont)
  22504. }
  22505. c.ServeSuccessJSON(map[string]interface{}{
  22506. "failed_code": -10,
  22507. "msg": errMsgs,
  22508. })
  22509. return
  22510. } else {
  22511. var result string
  22512. var request_log string
  22513. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22514. allTotal = fmt.Sprintf("%.2f", total_two)
  22515. if his.IdCardType == 4 {
  22516. 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)
  22517. } else {
  22518. 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)
  22519. }
  22520. var dat map[string]interface{}
  22521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22522. fmt.Println(dat)
  22523. } else {
  22524. fmt.Println(err)
  22525. }
  22526. saveLog(result, request_log, "2206", "预结算")
  22527. //userJSONBytes, _ := json.Marshal(dat)
  22528. //
  22529. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22530. // utils.ErrorLog("解析失败:%v", err)
  22531. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22532. // return
  22533. //}
  22534. userJSONBytes, _ := json.Marshal(dat)
  22535. if miConfig.Code == "H15049901371" {
  22536. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22537. utils.ErrorLog("解析失败:%v", err)
  22538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22539. return
  22540. }
  22541. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22542. res.Output = resSeven10265.Output
  22543. res.ErrMsg = resSeven10265.ErrMsg
  22544. res.Cainfo = resSeven10265.Cainfo
  22545. res.WarnMsg = resSeven10265.WarnMsg
  22546. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22547. res.Infcode = infocode
  22548. } else {
  22549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22550. utils.ErrorLog("解析失败:%v", err)
  22551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22552. return
  22553. }
  22554. }
  22555. }
  22556. } else {
  22557. c.ServeSuccessJSON(map[string]interface{}{
  22558. "failed_code": -10,
  22559. "msg": result3101.ErrMsg,
  22560. })
  22561. return
  22562. }
  22563. } else {
  22564. var result string
  22565. var request_log string
  22566. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22567. allTotal = fmt.Sprintf("%.2f", total_two)
  22568. if his.IdCardType == 4 {
  22569. 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)
  22570. } else {
  22571. 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)
  22572. }
  22573. var dat map[string]interface{}
  22574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22575. fmt.Println(dat)
  22576. } else {
  22577. fmt.Println(err)
  22578. }
  22579. saveLog(result, request_log, "2206", "预结算")
  22580. //userJSONBytes, _ := json.Marshal(dat)
  22581. //
  22582. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22583. // utils.ErrorLog("解析失败:%v", err)
  22584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22585. // return
  22586. //}
  22587. userJSONBytes, _ := json.Marshal(dat)
  22588. if miConfig.Code == "H15049901371" {
  22589. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22590. utils.ErrorLog("解析失败:%v", err)
  22591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22592. return
  22593. }
  22594. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22595. res.Output = resSeven10265.Output
  22596. res.ErrMsg = resSeven10265.ErrMsg
  22597. res.Cainfo = resSeven10265.Cainfo
  22598. res.WarnMsg = resSeven10265.WarnMsg
  22599. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22600. res.Infcode = infocode
  22601. } else {
  22602. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22603. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22604. utils.ErrorLog("解析失败:%v", err)
  22605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22606. return
  22607. }
  22608. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22609. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22610. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22611. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22612. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22613. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22614. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22615. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22616. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22617. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22618. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22619. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22620. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22621. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22622. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22623. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22624. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22625. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22626. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22627. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22628. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22629. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22630. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22631. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22632. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22633. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22634. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22635. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22636. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22637. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22638. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22639. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22640. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22641. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22642. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22643. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22644. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22645. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22646. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22647. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22648. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22649. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22650. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22651. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22652. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22653. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22654. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22655. res.Cainfo = gzresSeven10265Two.Cainfo
  22656. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22657. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22658. //res.Infcode = infocode
  22659. } else {
  22660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22661. utils.ErrorLog("解析失败:%v", err)
  22662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22663. return
  22664. }
  22665. }
  22666. }
  22667. }
  22668. }
  22669. utils.ErrorLog("解析失败:%v", res.Infcode)
  22670. if res.Infcode == -1 {
  22671. errlog := &models.HisOrderError{
  22672. UserOrgId: adminUser.CurrentOrgId,
  22673. Ctime: time.Now().Unix(),
  22674. Mtime: time.Now().Unix(),
  22675. Number: chrg_bchno,
  22676. ErrMsg: res.ErrMsg,
  22677. Status: 1,
  22678. PatientId: id,
  22679. RecordTime: recordDateTime,
  22680. Stage: 20,
  22681. }
  22682. service.CreateErrMsgLog(errlog)
  22683. c.ServeSuccessJSON(map[string]interface{}{
  22684. "failed_code": -10,
  22685. "msg": res.ErrMsg,
  22686. })
  22687. return
  22688. }
  22689. if res.Infcode != 0 {
  22690. errlog := &models.HisOrderError{
  22691. UserOrgId: adminUser.CurrentOrgId,
  22692. Ctime: time.Now().Unix(),
  22693. Mtime: time.Now().Unix(),
  22694. Number: chrg_bchno,
  22695. ErrMsg: res.ErrMsg,
  22696. Status: 1,
  22697. PatientId: id,
  22698. RecordTime: recordDateTime,
  22699. Stage: 20,
  22700. }
  22701. service.CreateErrMsgLog(errlog)
  22702. c.ServeSuccessJSON(map[string]interface{}{
  22703. "failed_code": -10,
  22704. "msg": res.ErrMsg,
  22705. })
  22706. return
  22707. } else {
  22708. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22709. order.OrderStatus = 1
  22710. order.IsPre = 1
  22711. order.Status = 1
  22712. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22713. order.SetlId = res.Output.Setlinfo.SetlID
  22714. order.PsnNo = res.Output.Setlinfo.PsnNo
  22715. order.PsnName = res.Output.Setlinfo.PsnName
  22716. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22717. order.Certno = res.Output.Setlinfo.Certno
  22718. order.Gend = res.Output.Setlinfo.Gend
  22719. order.Naty = res.Output.Setlinfo.Naty
  22720. order.Age = res.Output.Setlinfo.Age
  22721. order.Insutype = res.Output.Setlinfo.Insutype
  22722. order.PsnType = res.Output.Setlinfo.PsnType
  22723. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22724. order.SetlTime = res.Output.Setlinfo.SetlTime
  22725. order.AcctUsedFlag = acct_used_flag
  22726. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22727. if res.Output.Setlinfo.MedType == "140101" {
  22728. order.MedType = "14"
  22729. } else {
  22730. if res.Output.Setlinfo.MedType == "110104" {
  22731. order.MedType = "11"
  22732. } else {
  22733. order.MedType = res.Output.Setlinfo.MedType
  22734. }
  22735. }
  22736. if res.Output.Setlinfo.MedType == "992102" {
  22737. order.MedType = "992102"
  22738. }
  22739. if res.Output.Setlinfo.MedType == "140104" {
  22740. order.MedType = "140104"
  22741. }
  22742. if res.Output.Setlinfo.MedType == "14" {
  22743. order.MedType = "14"
  22744. }
  22745. if reg_type == 1112 {
  22746. order.MedType = "1112"
  22747. }
  22748. if reg_type == 1111 {
  22749. order.MedType = "1111"
  22750. }
  22751. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22752. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22753. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22754. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22755. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22756. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22757. order.HifpPay = res.Output.Setlinfo.HifpPay
  22758. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22759. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22760. order.HifesPay = res.Output.Setlinfo.HifesPay
  22761. order.HifobPay = res.Output.Setlinfo.HifobPay
  22762. order.MafPay = res.Output.Setlinfo.MafPay
  22763. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22764. order.OthPay = res.Output.Setlinfo.OthPay
  22765. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22766. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22767. order.AcctPay = res.Output.Setlinfo.AcctPay
  22768. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22769. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22770. order.Balc = res.Output.Setlinfo.Balc
  22771. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22772. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22773. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22774. order.ClrWay = res.Output.Setlinfo.ClrWay
  22775. order.Creator = order.Creator
  22776. order.Modify = roles.AdminUserId
  22777. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22778. //detailStr := string(setlDetail)
  22779. //order.SetlDetail = detailStr
  22780. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22781. err = service.UpDateOrder(order)
  22782. if err == nil {
  22783. c.ServeSuccessJSON(map[string]interface{}{
  22784. "msg": "预结算成功",
  22785. })
  22786. } else {
  22787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22788. return
  22789. }
  22790. }
  22791. } else {
  22792. adminUser := c.GetAdminUserInfo()
  22793. errlog := &models.HisOrderError{
  22794. UserOrgId: adminUser.CurrentOrgId,
  22795. Ctime: time.Now().Unix(),
  22796. Mtime: time.Now().Unix(),
  22797. ErrMsg: res.ErrMsg,
  22798. Status: 1,
  22799. PatientId: id,
  22800. RecordTime: recordDateTime,
  22801. Stage: 4,
  22802. }
  22803. service.CreateErrMsgLog(errlog)
  22804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22805. return
  22806. }
  22807. } else {
  22808. if miConfig.MdtrtareaAdmvs == "150499" {
  22809. order := &models.HisOrder{
  22810. UserOrgId: adminUser.CurrentOrgId,
  22811. HisPatientId: his.ID,
  22812. PatientId: his.PatientId,
  22813. SettleAccountsDate: recordDateTime,
  22814. Ctime: time.Now().Unix(),
  22815. Mtime: time.Now().Unix(),
  22816. MdtrtId: his.Number,
  22817. PsnNo: his.PsnNo,
  22818. MedType: strconv.FormatInt(reg_type, 10),
  22819. Status: 1,
  22820. Number: chrg_bchno,
  22821. Infcode: res.Infcode,
  22822. WarnMsg: res.WarnMsg,
  22823. Cainfo: res.Cainfo,
  22824. ErrMsg: res.ErrMsg,
  22825. RespondTime: res.RefmsgTime,
  22826. InfRefmsgid: res.InfRefmsgid,
  22827. OrderStatus: 1,
  22828. IsMedicineInsurance: 1,
  22829. SettleType: settle_accounts_type,
  22830. SettleStartTime: start_time,
  22831. SettleEndTime: end_time,
  22832. Creator: roles.AdminUserId,
  22833. Modify: roles.AdminUserId,
  22834. PType: 2,
  22835. Diagnosis: diagnosis_id,
  22836. }
  22837. err = service.CreateOrder(order)
  22838. if err != nil {
  22839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22840. return
  22841. }
  22842. }
  22843. adminUser := c.GetAdminUserInfo()
  22844. errlog := &models.HisOrderError{
  22845. UserOrgId: adminUser.CurrentOrgId,
  22846. Ctime: time.Now().Unix(),
  22847. Mtime: time.Now().Unix(),
  22848. ErrMsg: res.ErrMsg,
  22849. Status: 1,
  22850. PatientId: id,
  22851. RecordTime: recordDateTime,
  22852. Stage: 4,
  22853. }
  22854. service.CreateErrMsgLog(errlog)
  22855. c.ServeSuccessJSON(map[string]interface{}{
  22856. "failed_code": -10,
  22857. "msg": res.ErrMsg,
  22858. })
  22859. return
  22860. }
  22861. }
  22862. }
  22863. }
  22864. // 退款
  22865. func (c *HisApiController) Refund() {
  22866. order_id, _ := c.GetInt64("order_id")
  22867. admin_user_id, _ := c.GetInt64("admin_user_id")
  22868. adminUser := c.GetAdminUserInfo()
  22869. var order models.HisOrder
  22870. order, _ = service.GetHisOrderByID(order_id)
  22871. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22872. if order.ID == 0 {
  22873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22874. return
  22875. }
  22876. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22878. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22879. if config.IsOpen == 1 { //对接了医保,走医保流程
  22880. var res ResultSixteen
  22881. var ahres ResultSevenAH
  22882. var resSixteen10265 ResultSixteen10265
  22883. var resSixteen10265Two ResultSixteen10265Two
  22884. var gz ResultgzSixteen10265Two
  22885. var src_resquest string
  22886. var result string
  22887. if miConfig.MdtrtareaAdmvs == "421300" {
  22888. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22889. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22890. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22891. resp3, requestErr3 := http.Get(api3)
  22892. if requestErr3 != nil {
  22893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22894. return
  22895. }
  22896. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22897. if ioErr3 != nil {
  22898. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22900. return
  22901. }
  22902. var respJSON3 map[string]interface{}
  22903. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22904. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22906. return
  22907. }
  22908. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22909. userJSONBytes3, _ := json.Marshal(respJSON3)
  22910. fmt.Println("log")
  22911. fmt.Println(string(userJSONBytes3))
  22912. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22913. utils.ErrorLog("解析失败:%v", err)
  22914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22915. return
  22916. }
  22917. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22918. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22919. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22920. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22921. resp3, requestErr3 := http.Get(api3)
  22922. if requestErr3 != nil {
  22923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22924. return
  22925. }
  22926. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22927. if ioErr3 != nil {
  22928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22930. return
  22931. }
  22932. var respJSON3 map[string]interface{}
  22933. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22936. return
  22937. }
  22938. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22939. userJSONBytes3, _ := json.Marshal(respJSON3)
  22940. fmt.Println("log")
  22941. fmt.Println(string(userJSONBytes3))
  22942. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22943. utils.ErrorLog("解析失败:%v", err)
  22944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22945. return
  22946. }
  22947. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22948. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22949. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22950. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22951. resp3, requestErr3 := http.Get(api3)
  22952. if requestErr3 != nil {
  22953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22954. return
  22955. }
  22956. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22957. if ioErr3 != nil {
  22958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22960. return
  22961. }
  22962. var respJSON3 map[string]interface{}
  22963. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22966. return
  22967. }
  22968. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22969. userJSONBytes3, _ := json.Marshal(respJSON3)
  22970. fmt.Println("log")
  22971. fmt.Println(string(userJSONBytes3))
  22972. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22973. utils.ErrorLog("解析失败:%v", err)
  22974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22975. return
  22976. }
  22977. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22978. var api3 string
  22979. if miConfig.MdtrtareaAdmvs == "320921" {
  22980. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22981. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22982. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22983. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22984. } else {
  22985. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22986. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22987. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22988. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22989. }
  22990. resp3, requestErr3 := http.Get(api3)
  22991. if requestErr3 != nil {
  22992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22993. return
  22994. }
  22995. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22996. if ioErr3 != nil {
  22997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22999. return
  23000. }
  23001. var respJSON3 map[string]interface{}
  23002. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23005. return
  23006. }
  23007. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23008. userJSONBytes3, _ := json.Marshal(respJSON3)
  23009. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23010. utils.ErrorLog("解析失败:%v", err)
  23011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23012. return
  23013. }
  23014. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23015. res.Output = resSixteen10265.Output
  23016. res.ErrMsg = resSixteen10265.ErrMsg
  23017. res.Cainfo = resSixteen10265.Cainfo
  23018. res.WarnMsg = resSixteen10265.WarnMsg
  23019. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23020. res.Infcode = infocode
  23021. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23022. var api3 string
  23023. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23024. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23025. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23026. resp3, requestErr3 := http.Get(api3)
  23027. if requestErr3 != nil {
  23028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23029. return
  23030. }
  23031. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23032. if ioErr3 != nil {
  23033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23035. return
  23036. }
  23037. var respJSON3 map[string]interface{}
  23038. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23041. return
  23042. }
  23043. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23044. userJSONBytes3, _ := json.Marshal(respJSON3)
  23045. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23046. utils.ErrorLog("解析失败:%v", err)
  23047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23048. return
  23049. }
  23050. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23051. res.Output = resSixteen10265.Output
  23052. res.ErrMsg = resSixteen10265.ErrMsg
  23053. res.Cainfo = resSixteen10265.Cainfo
  23054. res.WarnMsg = resSixteen10265.WarnMsg
  23055. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23056. res.Infcode = infocode
  23057. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23058. 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)
  23059. var dat map[string]interface{}
  23060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23061. fmt.Println(dat)
  23062. } else {
  23063. fmt.Println(err)
  23064. }
  23065. saveLog(result, src_resquest, "2208", "退费")
  23066. userJSONBytes, _ := json.Marshal(dat)
  23067. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23068. utils.ErrorLog("解析失败:%v", err)
  23069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23070. return
  23071. }
  23072. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23073. 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, "")
  23074. var dat map[string]interface{}
  23075. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23076. fmt.Println(dat)
  23077. } else {
  23078. fmt.Println(err)
  23079. }
  23080. saveLog(result, src_resquest, "2208", "退费")
  23081. userJSONBytes, _ := json.Marshal(dat)
  23082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23083. utils.ErrorLog("解析失败:%v", err)
  23084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23085. return
  23086. }
  23087. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23088. var api3 string
  23089. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23090. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23091. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23092. resp3, requestErr3 := http.Get(api3)
  23093. if requestErr3 != nil {
  23094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23095. return
  23096. }
  23097. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23098. if ioErr3 != nil {
  23099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23101. return
  23102. }
  23103. var respJSON3 map[string]interface{}
  23104. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23107. return
  23108. }
  23109. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23110. if status == "0" {
  23111. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23112. c.ServeSuccessJSON(map[string]interface{}{
  23113. "failed_code": -10,
  23114. "msg": err_msg,
  23115. })
  23116. return
  23117. }
  23118. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23119. userJSONBytes3, _ := json.Marshal(respJSON3)
  23120. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23121. // utils.ErrorLog("解析失败:%v", err)
  23122. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23123. // return
  23124. //}
  23125. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23126. utils.ErrorLog("解析失败:%v", err)
  23127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23128. return
  23129. }
  23130. res.InfRefmsgid = ahres.InfRefmsgid
  23131. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23132. // 创建对应的Time类型
  23133. t := time.UnixMilli(timestamp)
  23134. // 格式化成指定的日期字符串
  23135. str := t.Format("2006-01-02 15:04:05")
  23136. res.Output.Setlinfo.SetlTime = str
  23137. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23138. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23139. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23140. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23141. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23142. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23143. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23144. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23145. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23146. //
  23147. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23148. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23149. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23150. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23151. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23152. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23153. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23154. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23155. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23156. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23157. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23158. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23159. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23160. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23161. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23162. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23163. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23164. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23165. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23166. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23167. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23168. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23169. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23170. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23171. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23172. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23173. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23174. //res.Output.Setldetail = ahres.Output.Setldetail
  23175. res.ErrMsg = ahres.ErrMsg
  23176. res.Cainfo = ahres.Cainfo
  23177. res.WarnMsg = ahres.WarnMsg
  23178. res.Infcode = ahres.Infcode
  23179. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23180. 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, "")
  23181. var dat map[string]interface{}
  23182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23183. fmt.Println(dat)
  23184. } else {
  23185. fmt.Println(err)
  23186. }
  23187. saveLog(result, src_resquest, "2208", "退费")
  23188. userJSONBytes, _ := json.Marshal(dat)
  23189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23190. utils.ErrorLog("解析失败:%v", err)
  23191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23192. return
  23193. }
  23194. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23195. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23196. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23197. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23198. resp3, requestErr3 := http.Get(api3)
  23199. if requestErr3 != nil {
  23200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23201. return
  23202. }
  23203. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23204. if ioErr3 != nil {
  23205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23207. return
  23208. }
  23209. var respJSON3 map[string]interface{}
  23210. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23211. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23213. return
  23214. }
  23215. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23216. userJSONBytes3, _ := json.Marshal(respJSON3)
  23217. fmt.Println("log")
  23218. fmt.Println(string(userJSONBytes3))
  23219. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23220. utils.ErrorLog("解析失败:%v", err)
  23221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23222. return
  23223. }
  23224. } else {
  23225. if miConfig.Code == "H15049901371" {
  23226. 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)
  23227. var dat map[string]interface{}
  23228. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23229. fmt.Println(dat)
  23230. } else {
  23231. fmt.Println(err)
  23232. }
  23233. saveLog(result, src_resquest, "2208", "退费")
  23234. userJSONBytes, _ := json.Marshal(dat)
  23235. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23236. utils.ErrorLog("解析失败:%v", err)
  23237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23238. return
  23239. }
  23240. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23241. res.Output = resSixteen10265.Output
  23242. res.ErrMsg = resSixteen10265.ErrMsg
  23243. res.Cainfo = resSixteen10265.Cainfo
  23244. res.WarnMsg = resSixteen10265.WarnMsg
  23245. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23246. res.Infcode = infocode
  23247. } else {
  23248. 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)
  23249. var dat map[string]interface{}
  23250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23251. fmt.Println(dat)
  23252. } else {
  23253. fmt.Println(err)
  23254. }
  23255. saveLog(result, src_resquest, "2208", "退费")
  23256. userJSONBytes, _ := json.Marshal(dat)
  23257. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23258. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  23259. utils.ErrorLog("解析失败:%v", err)
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23261. return
  23262. }
  23263. res.Infcode = gz.Infcode
  23264. } else {
  23265. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23266. utils.ErrorLog("解析失败:%v", err)
  23267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23268. return
  23269. }
  23270. }
  23271. }
  23272. }
  23273. if res.Infcode == 0 {
  23274. var res2 ResultSix
  23275. var resSix10265 ResultSix10265
  23276. if miConfig.MdtrtareaAdmvs == "421300" {
  23277. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23278. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23279. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23280. resp3, requestErr3 := http.Get(api3)
  23281. if requestErr3 != nil {
  23282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23283. return
  23284. }
  23285. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23286. if ioErr3 != nil {
  23287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23289. return
  23290. }
  23291. var respJSON3 map[string]interface{}
  23292. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23295. return
  23296. }
  23297. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23298. userJSONBytes3, _ := json.Marshal(respJSON3)
  23299. fmt.Println("log")
  23300. fmt.Println(string(userJSONBytes3))
  23301. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23302. utils.ErrorLog("解析失败:%v", err)
  23303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23304. return
  23305. }
  23306. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23307. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23308. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23309. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23310. resp3, requestErr3 := http.Get(api3)
  23311. if requestErr3 != nil {
  23312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23313. return
  23314. }
  23315. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23316. if ioErr3 != nil {
  23317. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23319. return
  23320. }
  23321. var respJSON3 map[string]interface{}
  23322. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23323. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23325. return
  23326. }
  23327. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23328. userJSONBytes3, _ := json.Marshal(respJSON3)
  23329. fmt.Println("log")
  23330. fmt.Println(string(userJSONBytes3))
  23331. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23332. utils.ErrorLog("解析失败:%v", err)
  23333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23334. return
  23335. }
  23336. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23337. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23338. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23339. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23340. resp3, requestErr3 := http.Get(api3)
  23341. if requestErr3 != nil {
  23342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23343. return
  23344. }
  23345. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23346. if ioErr3 != nil {
  23347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23349. return
  23350. }
  23351. var respJSON3 map[string]interface{}
  23352. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23355. return
  23356. }
  23357. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23358. userJSONBytes3, _ := json.Marshal(respJSON3)
  23359. fmt.Println("log")
  23360. fmt.Println(string(userJSONBytes3))
  23361. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23362. utils.ErrorLog("解析失败:%v", err)
  23363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23364. return
  23365. }
  23366. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23367. var api3 string
  23368. if miConfig.MdtrtareaAdmvs == "320921" {
  23369. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23370. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23371. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23372. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23373. } else {
  23374. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23375. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23376. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23377. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23378. }
  23379. resp3, requestErr3 := http.Get(api3)
  23380. if requestErr3 != nil {
  23381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23382. return
  23383. }
  23384. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23385. if ioErr3 != nil {
  23386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23388. return
  23389. }
  23390. var respJSON3 map[string]interface{}
  23391. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23394. return
  23395. }
  23396. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23397. userJSONBytes3, _ := json.Marshal(respJSON3)
  23398. fmt.Println("log")
  23399. fmt.Println(string(userJSONBytes3))
  23400. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23401. utils.ErrorLog("解析失败:%v", err)
  23402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23403. return
  23404. }
  23405. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23406. res2.Output = resSix10265.Output
  23407. res2.ErrMsg = resSix10265.ErrMsg
  23408. res2.Cainfo = resSix10265.Cainfo
  23409. res2.WarnMsg = resSix10265.WarnMsg
  23410. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23411. res2.Infcode = infocode
  23412. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23413. var api3 string
  23414. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23415. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23416. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23417. resp3, requestErr3 := http.Get(api3)
  23418. if requestErr3 != nil {
  23419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23420. return
  23421. }
  23422. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23423. if ioErr3 != nil {
  23424. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23426. return
  23427. }
  23428. var respJSON3 map[string]interface{}
  23429. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23430. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23432. return
  23433. }
  23434. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23435. userJSONBytes3, _ := json.Marshal(respJSON3)
  23436. fmt.Println("log")
  23437. fmt.Println(string(userJSONBytes3))
  23438. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23439. utils.ErrorLog("解析失败:%v", err)
  23440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23441. return
  23442. }
  23443. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23444. res2.Output = resSix10265.Output
  23445. res2.ErrMsg = resSix10265.ErrMsg
  23446. res2.Cainfo = resSix10265.Cainfo
  23447. res2.WarnMsg = resSix10265.WarnMsg
  23448. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23449. res2.Infcode = infocode
  23450. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23451. 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)
  23452. var dat map[string]interface{}
  23453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23454. fmt.Println(dat)
  23455. } else {
  23456. fmt.Println(err)
  23457. }
  23458. saveLog(result2, src_request, "2205", "撤销明细")
  23459. userJSONBytes, _ := json.Marshal(dat)
  23460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23461. utils.ErrorLog("解析失败:%v", err)
  23462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23463. return
  23464. }
  23465. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23466. 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, "")
  23467. var dat map[string]interface{}
  23468. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23469. fmt.Println(dat)
  23470. } else {
  23471. fmt.Println(err)
  23472. }
  23473. saveLog(result2, src_request, "2205", "撤销明细")
  23474. userJSONBytes, _ := json.Marshal(dat)
  23475. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23476. utils.ErrorLog("解析失败:%v", err)
  23477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23478. return
  23479. }
  23480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23481. var api3 string
  23482. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23483. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23485. resp3, requestErr3 := http.Get(api3)
  23486. if requestErr3 != nil {
  23487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23488. return
  23489. }
  23490. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23491. if ioErr3 != nil {
  23492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23494. return
  23495. }
  23496. var respJSON3 map[string]interface{}
  23497. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23500. return
  23501. }
  23502. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23503. if status == "0" {
  23504. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23505. c.ServeSuccessJSON(map[string]interface{}{
  23506. "failed_code": -10,
  23507. "msg": err_msg,
  23508. })
  23509. return
  23510. }
  23511. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23512. userJSONBytes3, _ := json.Marshal(respJSON3)
  23513. fmt.Println("log")
  23514. fmt.Println(string(userJSONBytes3))
  23515. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23516. utils.ErrorLog("解析失败:%v", err)
  23517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23518. return
  23519. }
  23520. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23521. 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, "")
  23522. var dat map[string]interface{}
  23523. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23524. fmt.Println(dat)
  23525. } else {
  23526. fmt.Println(err)
  23527. }
  23528. saveLog(result2, src_request, "2205", "撤销明细")
  23529. userJSONBytes, _ := json.Marshal(dat)
  23530. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23531. utils.ErrorLog("解析失败:%v", err)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23536. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  23537. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23539. resp3, requestErr3 := http.Get(api3)
  23540. if requestErr3 != nil {
  23541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23542. return
  23543. }
  23544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23545. if ioErr3 != nil {
  23546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23548. return
  23549. }
  23550. var respJSON3 map[string]interface{}
  23551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23554. return
  23555. }
  23556. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23557. userJSONBytes3, _ := json.Marshal(respJSON3)
  23558. fmt.Println("log")
  23559. fmt.Println(string(userJSONBytes3))
  23560. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23561. utils.ErrorLog("解析失败:%v", err)
  23562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23563. return
  23564. }
  23565. } else {
  23566. if miConfig.Code == "H15049901371" {
  23567. 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)
  23568. var dat map[string]interface{}
  23569. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23570. fmt.Println(dat)
  23571. } else {
  23572. fmt.Println(err)
  23573. }
  23574. saveLog(result2, src_request, "2205", "撤销明细")
  23575. userJSONBytes, _ := json.Marshal(dat)
  23576. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  23577. utils.ErrorLog("解析失败:%v", err)
  23578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23579. return
  23580. }
  23581. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23582. res2.Output = resSix10265.Output
  23583. res2.ErrMsg = resSix10265.ErrMsg
  23584. res2.Cainfo = resSix10265.Cainfo
  23585. res2.WarnMsg = resSix10265.WarnMsg
  23586. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23587. res2.Infcode = infocode
  23588. } else {
  23589. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23590. res2.Infcode = 0
  23591. } else {
  23592. 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)
  23593. var dat map[string]interface{}
  23594. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23595. fmt.Println(dat)
  23596. } else {
  23597. fmt.Println(err)
  23598. }
  23599. saveLog(result2, src_request, "2205", "撤销明细")
  23600. userJSONBytes, _ := json.Marshal(dat)
  23601. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23602. utils.ErrorLog("解析失败:%v", err)
  23603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23604. return
  23605. }
  23606. }
  23607. }
  23608. }
  23609. if res2.Infcode == -1 {
  23610. c.ServeSuccessJSON(map[string]interface{}{
  23611. "failed_code": -10,
  23612. "msg": res2.ErrMsg,
  23613. })
  23614. return
  23615. }
  23616. if res2.Infcode == 0 {
  23617. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  23618. if err == nil {
  23619. //当押金不为零时产生退费记录
  23620. if order.Decimal != 0 {
  23621. tmp := strconv.FormatInt(order.ID, 10)
  23622. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  23623. if err != nil {
  23624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23625. return
  23626. }
  23627. }
  23628. c.ServeSuccessJSON(map[string]interface{}{
  23629. "msg": "退费成功",
  23630. })
  23631. } else {
  23632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23633. return
  23634. }
  23635. } else {
  23636. c.ServeSuccessJSON(map[string]interface{}{
  23637. "failed_code": -10,
  23638. "msg": res2.ErrMsg,
  23639. })
  23640. }
  23641. } else {
  23642. c.ServeSuccessJSON(map[string]interface{}{
  23643. "failed_code": -10,
  23644. "msg": res.ErrMsg,
  23645. })
  23646. }
  23647. }
  23648. }
  23649. func (c *HisApiController) RefundNumber() {
  23650. record_time := c.GetString("record_time")
  23651. //patient_id, _ := c.GetInt64("patient_id")
  23652. admin_user_id, _ := c.GetInt64("admin_user_id")
  23653. his_patient_id, _ := c.GetInt64("id")
  23654. timeLayout := "2006-01-02"
  23655. loc, _ := time.LoadLocation("Local")
  23656. adminUser := c.GetAdminUserInfo()
  23657. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23658. fmt.Println(err)
  23659. if err != nil {
  23660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23661. return
  23662. }
  23663. recordDateTime := theTime.Unix()
  23664. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23665. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23666. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23667. //order, _ := service.GetHisOrderByID(order_id)
  23668. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23669. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23670. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23671. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23672. if count > 0 {
  23673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23674. return
  23675. }
  23676. if config.IsOpen == 1 { //对接了医保,走医保流程
  23677. var res2 ResultSix
  23678. var res3 GZResultSix
  23679. var resSix10265 ResultSix10265
  23680. if miConfig.MdtrtareaAdmvs == "421300" {
  23681. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23682. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23683. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23684. resp3, requestErr3 := http.Get(api3)
  23685. if requestErr3 != nil {
  23686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23687. return
  23688. }
  23689. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23690. if ioErr3 != nil {
  23691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23693. return
  23694. }
  23695. var respJSON3 map[string]interface{}
  23696. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23699. return
  23700. }
  23701. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23702. userJSONBytes3, _ := json.Marshal(respJSON3)
  23703. fmt.Println("log")
  23704. fmt.Println(string(userJSONBytes3))
  23705. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23706. utils.ErrorLog("解析失败:%v", err)
  23707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23708. return
  23709. }
  23710. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23711. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23712. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23713. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23714. resp3, requestErr3 := http.Get(api3)
  23715. if requestErr3 != nil {
  23716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23717. return
  23718. }
  23719. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23720. if ioErr3 != nil {
  23721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23723. return
  23724. }
  23725. var respJSON3 map[string]interface{}
  23726. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23729. return
  23730. }
  23731. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23732. userJSONBytes3, _ := json.Marshal(respJSON3)
  23733. fmt.Println("log")
  23734. fmt.Println(string(userJSONBytes3))
  23735. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23736. utils.ErrorLog("解析失败:%v", err)
  23737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23738. return
  23739. }
  23740. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23741. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23742. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23743. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23744. resp3, requestErr3 := http.Get(api3)
  23745. if requestErr3 != nil {
  23746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23747. return
  23748. }
  23749. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23750. if ioErr3 != nil {
  23751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23753. return
  23754. }
  23755. var respJSON3 map[string]interface{}
  23756. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23759. return
  23760. }
  23761. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23762. userJSONBytes3, _ := json.Marshal(respJSON3)
  23763. fmt.Println("log")
  23764. fmt.Println(string(userJSONBytes3))
  23765. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23766. utils.ErrorLog("解析失败:%v", err)
  23767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23768. return
  23769. }
  23770. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23771. var api3 string
  23772. if miConfig.MdtrtareaAdmvs == "320921" {
  23773. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23774. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23775. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23776. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23777. } else {
  23778. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23779. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23780. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23781. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23782. }
  23783. resp3, requestErr3 := http.Get(api3)
  23784. if requestErr3 != nil {
  23785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23786. return
  23787. }
  23788. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23789. if ioErr3 != nil {
  23790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23792. return
  23793. }
  23794. var respJSON3 map[string]interface{}
  23795. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23798. return
  23799. }
  23800. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23801. userJSONBytes3, _ := json.Marshal(respJSON3)
  23802. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23803. utils.ErrorLog("解析失败:%v", err)
  23804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23805. return
  23806. }
  23807. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23808. res2.Output = resSix10265.Output
  23809. res2.ErrMsg = resSix10265.ErrMsg
  23810. res2.Cainfo = resSix10265.Cainfo
  23811. res2.WarnMsg = resSix10265.WarnMsg
  23812. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23813. res2.Infcode = infocode
  23814. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23815. var api3 string
  23816. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23817. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23818. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23819. resp3, requestErr3 := http.Get(api3)
  23820. if requestErr3 != nil {
  23821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23822. return
  23823. }
  23824. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23825. if ioErr3 != nil {
  23826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23828. return
  23829. }
  23830. var respJSON3 map[string]interface{}
  23831. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23834. return
  23835. }
  23836. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23837. userJSONBytes3, _ := json.Marshal(respJSON3)
  23838. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23839. utils.ErrorLog("解析失败:%v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23844. res2.Output = resSix10265.Output
  23845. res2.ErrMsg = resSix10265.ErrMsg
  23846. res2.Cainfo = resSix10265.Cainfo
  23847. res2.WarnMsg = resSix10265.WarnMsg
  23848. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23849. res2.Infcode = infocode
  23850. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23851. 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)
  23852. var dat map[string]interface{}
  23853. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23854. fmt.Println(dat)
  23855. } else {
  23856. fmt.Println(err)
  23857. }
  23858. saveLog(result, request, "2202", "退号")
  23859. userJSONBytes, _ := json.Marshal(dat)
  23860. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23861. utils.ErrorLog("解析失败:%v", err)
  23862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23863. return
  23864. }
  23865. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23866. 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, "")
  23867. var dat map[string]interface{}
  23868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23869. fmt.Println(dat)
  23870. } else {
  23871. fmt.Println(err)
  23872. }
  23873. saveLog(result, request, "2202", "退号")
  23874. userJSONBytes, _ := json.Marshal(dat)
  23875. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23876. utils.ErrorLog("解析失败:%v", err)
  23877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23878. return
  23879. }
  23880. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23881. var api3 string
  23882. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23883. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23884. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23885. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23886. resp3, requestErr3 := http.Get(api3)
  23887. if requestErr3 != nil {
  23888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23889. return
  23890. }
  23891. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23892. if ioErr3 != nil {
  23893. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23895. return
  23896. }
  23897. var respJSON3 map[string]interface{}
  23898. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23899. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23901. return
  23902. }
  23903. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23904. if status == "0" {
  23905. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23906. c.ServeSuccessJSON(map[string]interface{}{
  23907. "failed_code": -10,
  23908. "msg": err_msg,
  23909. })
  23910. return
  23911. }
  23912. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23913. userJSONBytes3, _ := json.Marshal(respJSON3)
  23914. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23915. utils.ErrorLog("解析失败:%v", err)
  23916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23917. return
  23918. }
  23919. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23920. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23921. 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, "")
  23922. var dat map[string]interface{}
  23923. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23924. fmt.Println(dat)
  23925. } else {
  23926. fmt.Println(err)
  23927. }
  23928. saveLog(result, request, "2202", "退号")
  23929. userJSONBytes, _ := json.Marshal(dat)
  23930. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23931. utils.ErrorLog("解析失败:%v", err)
  23932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23933. return
  23934. }
  23935. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23936. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23937. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23938. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23939. resp3, requestErr3 := http.Get(api3)
  23940. if requestErr3 != nil {
  23941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23942. return
  23943. }
  23944. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23945. if ioErr3 != nil {
  23946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23948. return
  23949. }
  23950. var respJSON3 map[string]interface{}
  23951. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23954. return
  23955. }
  23956. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23957. userJSONBytes3, _ := json.Marshal(respJSON3)
  23958. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23959. utils.ErrorLog("解析失败:%v", err)
  23960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23961. return
  23962. }
  23963. } else {
  23964. var api3 string
  23965. if miConfig.Code == "H15049901371" {
  23966. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23967. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23968. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23969. } else {
  23970. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23971. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23973. }
  23974. resp3, requestErr3 := http.Get(api3)
  23975. if requestErr3 != nil {
  23976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23977. return
  23978. }
  23979. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23980. if ioErr3 != nil {
  23981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23983. return
  23984. }
  23985. var respJSON3 map[string]interface{}
  23986. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23989. return
  23990. }
  23991. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23992. userJSONBytes3, _ := json.Marshal(respJSON3)
  23993. if miConfig.Code == "H15049901371" {
  23994. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23995. utils.ErrorLog("解析失败:%v", err)
  23996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23997. return
  23998. }
  23999. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24000. res2.Output = resSix10265.Output
  24001. res2.ErrMsg = resSix10265.ErrMsg
  24002. res2.Cainfo = resSix10265.Cainfo
  24003. res2.WarnMsg = resSix10265.WarnMsg
  24004. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24005. res2.Infcode = infocode
  24006. } else {
  24007. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24008. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24009. utils.ErrorLog("解析失败:%v", err)
  24010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24011. return
  24012. }
  24013. res2.Infcode = res3.Infcode
  24014. } else {
  24015. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24016. utils.ErrorLog("解析失败:%v", err)
  24017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24018. return
  24019. }
  24020. }
  24021. }
  24022. }
  24023. if res2.Infcode == -1 {
  24024. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24025. c.ServeSuccessJSON(map[string]interface{}{
  24026. "failed_code": -10,
  24027. "msg": res2.ErrMsg,
  24028. })
  24029. return
  24030. }
  24031. if res2.Infcode == 0 {
  24032. if err == nil {
  24033. c.ServeSuccessJSON(map[string]interface{}{
  24034. "msg": "退号成功",
  24035. })
  24036. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24037. } else {
  24038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24039. return
  24040. }
  24041. }
  24042. } else {
  24043. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24044. //if err == nil {
  24045. // c.ServeSuccessJSON(map[string]interface{}{
  24046. // "msg": "退费成功",
  24047. // })
  24048. //} else {
  24049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24050. // return
  24051. //}
  24052. }
  24053. }
  24054. func (c *HisApiController) RefundDetail() {
  24055. order_id, _ := c.GetInt64("order_id")
  24056. admin_user_id, _ := c.GetInt64("admin_user_id")
  24057. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24058. number := c.GetString("number")
  24059. record_time := c.GetString("record_time")
  24060. patient_id, _ := c.GetInt64("patient_id")
  24061. //med_type, _ := c.GetInt64("med_type")
  24062. timeLayout := "2006-01-02"
  24063. loc, _ := time.LoadLocation("Local")
  24064. adminUser := c.GetAdminUserInfo()
  24065. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24066. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24067. fmt.Println(err)
  24068. if err != nil {
  24069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24070. return
  24071. }
  24072. recordDateTime := theTime.Unix()
  24073. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24074. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24077. var order models.HisOrder
  24078. order, _ = service.GetHisOrderByID(order_id)
  24079. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24080. if config.IsOpen == 1 { //对接了医保,走医保流程
  24081. var res2 ResultSix
  24082. if miConfig.MdtrtareaAdmvs == "421300" {
  24083. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24084. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24085. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24086. resp3, requestErr3 := http.Get(api3)
  24087. if requestErr3 != nil {
  24088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24089. return
  24090. }
  24091. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24092. if ioErr3 != nil {
  24093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24095. return
  24096. }
  24097. var respJSON3 map[string]interface{}
  24098. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24101. return
  24102. }
  24103. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24104. userJSONBytes3, _ := json.Marshal(respJSON3)
  24105. fmt.Println("log")
  24106. fmt.Println(string(userJSONBytes3))
  24107. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24108. utils.ErrorLog("解析失败:%v", err)
  24109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24110. return
  24111. }
  24112. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24113. if err == nil {
  24114. c.ServeSuccessJSON(map[string]interface{}{
  24115. "msg": "撤销明细成功",
  24116. })
  24117. return
  24118. } else {
  24119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24120. return
  24121. }
  24122. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24123. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24124. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24126. resp3, requestErr3 := http.Get(api3)
  24127. if requestErr3 != nil {
  24128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24129. return
  24130. }
  24131. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24132. if ioErr3 != nil {
  24133. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24135. return
  24136. }
  24137. var respJSON3 map[string]interface{}
  24138. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24139. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24144. userJSONBytes3, _ := json.Marshal(respJSON3)
  24145. fmt.Println("log")
  24146. fmt.Println(string(userJSONBytes3))
  24147. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24148. utils.ErrorLog("解析失败:%v", err)
  24149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24150. return
  24151. }
  24152. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24153. if err == nil {
  24154. c.ServeSuccessJSON(map[string]interface{}{
  24155. "msg": "撤销明细成功",
  24156. })
  24157. return
  24158. } else {
  24159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24160. return
  24161. }
  24162. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24163. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24164. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24165. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24166. resp3, requestErr3 := http.Get(api3)
  24167. if requestErr3 != nil {
  24168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24169. return
  24170. }
  24171. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24172. if ioErr3 != nil {
  24173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24175. return
  24176. }
  24177. var respJSON3 map[string]interface{}
  24178. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24181. return
  24182. }
  24183. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24184. userJSONBytes3, _ := json.Marshal(respJSON3)
  24185. fmt.Println("log")
  24186. fmt.Println(string(userJSONBytes3))
  24187. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24188. utils.ErrorLog("解析失败:%v", err)
  24189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24190. return
  24191. }
  24192. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24193. if err == nil {
  24194. c.ServeSuccessJSON(map[string]interface{}{
  24195. "msg": "撤销明细成功",
  24196. })
  24197. return
  24198. } else {
  24199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24200. return
  24201. }
  24202. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24203. var resSix10265 ResultSix10265
  24204. var api3 string
  24205. if miConfig.MdtrtareaAdmvs == "320921" {
  24206. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24207. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24208. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24209. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24210. } else {
  24211. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24212. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24213. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24214. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24215. }
  24216. resp3, requestErr3 := http.Get(api3)
  24217. utils.ErrorLog("接口: %v", requestErr3)
  24218. if requestErr3 != nil {
  24219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24220. return
  24221. }
  24222. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24223. if ioErr3 != nil {
  24224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24226. return
  24227. }
  24228. var respJSON3 map[string]interface{}
  24229. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24232. return
  24233. }
  24234. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24235. userJSONBytes3, _ := json.Marshal(respJSON3)
  24236. fmt.Println("log")
  24237. fmt.Println(string(userJSONBytes3))
  24238. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24239. utils.ErrorLog("解析失败:%v", err)
  24240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24241. return
  24242. }
  24243. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24244. res2.Output = resSix10265.Output
  24245. res2.ErrMsg = resSix10265.ErrMsg
  24246. res2.Cainfo = resSix10265.Cainfo
  24247. res2.WarnMsg = resSix10265.WarnMsg
  24248. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24249. res2.Infcode = infocode
  24250. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24251. if err == nil {
  24252. c.ServeSuccessJSON(map[string]interface{}{
  24253. "msg": "撤销明细成功",
  24254. })
  24255. return
  24256. } else {
  24257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24258. return
  24259. }
  24260. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24261. var api3 string
  24262. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24263. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24264. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24265. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24266. resp3, requestErr3 := http.Get(api3)
  24267. utils.ErrorLog("接口: %v", requestErr3)
  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. fmt.Println(res2.Infcode)
  24303. if res2.Infcode == -1 {
  24304. c.ServeSuccessJSON(map[string]interface{}{
  24305. "failed_code": -10,
  24306. "msg": res2.ErrMsg,
  24307. })
  24308. return
  24309. }
  24310. if res2.Infcode == 0 {
  24311. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24312. if err == nil {
  24313. c.ServeSuccessJSON(map[string]interface{}{
  24314. "msg": "撤销明细成功",
  24315. })
  24316. return
  24317. } else {
  24318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24319. return
  24320. }
  24321. } else {
  24322. c.ServeSuccessJSON(map[string]interface{}{
  24323. "failed_code": -10,
  24324. "msg": res2.ErrMsg,
  24325. })
  24326. }
  24327. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24328. if err == nil {
  24329. c.ServeSuccessJSON(map[string]interface{}{
  24330. "msg": "撤销明细成功",
  24331. })
  24332. return
  24333. } else {
  24334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24335. return
  24336. }
  24337. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24338. var resSix10265 ResultSix10265
  24339. var api3 string
  24340. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24341. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24342. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24343. resp3, requestErr3 := http.Get(api3)
  24344. if requestErr3 != nil {
  24345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24346. return
  24347. }
  24348. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24349. if ioErr3 != nil {
  24350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. var respJSON3 map[string]interface{}
  24355. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24358. return
  24359. }
  24360. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24361. userJSONBytes3, _ := json.Marshal(respJSON3)
  24362. fmt.Println("log")
  24363. fmt.Println(string(userJSONBytes3))
  24364. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24365. utils.ErrorLog("解析失败:%v", err)
  24366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24367. return
  24368. }
  24369. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24370. res2.Output = resSix10265.Output
  24371. res2.ErrMsg = resSix10265.ErrMsg
  24372. res2.Cainfo = resSix10265.Cainfo
  24373. res2.WarnMsg = resSix10265.WarnMsg
  24374. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24375. res2.Infcode = infocode
  24376. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24377. if err == nil {
  24378. c.ServeSuccessJSON(map[string]interface{}{
  24379. "msg": "撤销明细成功",
  24380. })
  24381. return
  24382. } else {
  24383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24384. return
  24385. }
  24386. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24387. 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)
  24388. var dat map[string]interface{}
  24389. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24390. fmt.Println(dat)
  24391. } else {
  24392. fmt.Println(err)
  24393. }
  24394. saveLog(result2, src_request, "2205", "撤销明细")
  24395. userJSONBytes, _ := json.Marshal(dat)
  24396. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24397. utils.ErrorLog("解析失败:%v", err)
  24398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24399. return
  24400. }
  24401. if res2.Infcode == 0 {
  24402. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24403. if err == nil {
  24404. c.ServeSuccessJSON(map[string]interface{}{
  24405. "msg": "撤销明细成功",
  24406. })
  24407. return
  24408. } else {
  24409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24410. return
  24411. }
  24412. } else {
  24413. c.ServeSuccessJSON(map[string]interface{}{
  24414. "failed_code": -10,
  24415. "msg": res2.ErrMsg,
  24416. })
  24417. }
  24418. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24419. 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, "")
  24420. var dat map[string]interface{}
  24421. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24422. fmt.Println(dat)
  24423. } else {
  24424. fmt.Println(err)
  24425. }
  24426. saveLog(result2, src_request, "2205", "撤销明细")
  24427. userJSONBytes, _ := json.Marshal(dat)
  24428. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24429. utils.ErrorLog("解析失败:%v", err)
  24430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24431. return
  24432. }
  24433. if res2.Infcode == 0 {
  24434. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24435. if err == nil {
  24436. c.ServeSuccessJSON(map[string]interface{}{
  24437. "msg": "撤销明细成功",
  24438. })
  24439. return
  24440. } else {
  24441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24442. return
  24443. }
  24444. } else {
  24445. c.ServeSuccessJSON(map[string]interface{}{
  24446. "failed_code": -10,
  24447. "msg": res2.ErrMsg,
  24448. })
  24449. }
  24450. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24451. 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, "")
  24452. var dat map[string]interface{}
  24453. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24454. fmt.Println(dat)
  24455. } else {
  24456. fmt.Println(err)
  24457. }
  24458. saveLog(result2, src_request, "2205", "撤销明细")
  24459. userJSONBytes, _ := json.Marshal(dat)
  24460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24461. utils.ErrorLog("解析失败:%v", err)
  24462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24463. return
  24464. }
  24465. if res2.Infcode == 0 {
  24466. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24467. if err == nil {
  24468. c.ServeSuccessJSON(map[string]interface{}{
  24469. "msg": "撤销明细成功",
  24470. })
  24471. return
  24472. } else {
  24473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24474. return
  24475. }
  24476. } else {
  24477. c.ServeSuccessJSON(map[string]interface{}{
  24478. "failed_code": -10,
  24479. "msg": res2.ErrMsg,
  24480. })
  24481. }
  24482. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24483. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  24484. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24485. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24486. resp2, requestErr2 := http.Get(api2)
  24487. if requestErr2 != nil {
  24488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24489. return
  24490. }
  24491. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24492. if ioErr2 != nil {
  24493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24495. return
  24496. }
  24497. var respJSON2 map[string]interface{}
  24498. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24501. return
  24502. }
  24503. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24504. userJSONBytes3, _ := json.Marshal(respJSON2)
  24505. fmt.Println("log")
  24506. fmt.Println(string(userJSONBytes3))
  24507. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24508. utils.ErrorLog("解析失败:%v", err)
  24509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24510. return
  24511. }
  24512. if res2.Infcode == 0 {
  24513. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24514. if err == nil {
  24515. c.ServeSuccessJSON(map[string]interface{}{
  24516. "msg": "撤销明细成功",
  24517. })
  24518. return
  24519. } else {
  24520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24521. return
  24522. }
  24523. } else {
  24524. c.ServeSuccessJSON(map[string]interface{}{
  24525. "failed_code": -10,
  24526. "msg": res2.ErrMsg,
  24527. })
  24528. }
  24529. } else {
  24530. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  24531. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24532. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24533. resp2, requestErr2 := http.Get(api2)
  24534. if requestErr2 != nil {
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24536. return
  24537. }
  24538. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24539. if ioErr2 != nil {
  24540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24542. return
  24543. }
  24544. var respJSON2 map[string]interface{}
  24545. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24548. return
  24549. }
  24550. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24551. if err == nil {
  24552. c.ServeSuccessJSON(map[string]interface{}{
  24553. "msg": "撤销明细成功",
  24554. })
  24555. return
  24556. } else {
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. }
  24561. } else {
  24562. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24563. if err == nil {
  24564. c.ServeSuccessJSON(map[string]interface{}{
  24565. "msg": "退费成功",
  24566. })
  24567. } else {
  24568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24569. return
  24570. }
  24571. }
  24572. }
  24573. // 对账
  24574. func (c *HisApiController) GetCheckAccount() {
  24575. start_time := c.GetString("start_time")
  24576. end_time := c.GetString("end_time")
  24577. insutype := c.GetString("insutype")
  24578. clr_type := c.GetString("clr_type")
  24579. clr_org := c.GetString("clr_optins")
  24580. admin_user_id, _ := c.GetInt64("admin_user_id")
  24581. adminUser := c.GetAdminUserInfo()
  24582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24584. if len(clr_org) == 0 {
  24585. clr_org = miConfig.InsuplcAdmdvs
  24586. }
  24587. timeLayout := "2006-01-02"
  24588. loc, _ := time.LoadLocation("Local")
  24589. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24590. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24591. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24592. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24593. fixmedins_setl_cnt := int64(len(orders))
  24594. var medfee_sumamt float64
  24595. var acct_pay float64
  24596. var fund_pay_sumamt float64
  24597. for _, item := range orders {
  24598. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24599. acct_pay = acct_pay + item.AcctPay
  24600. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24601. }
  24602. var user_name string
  24603. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24604. if role.ID == 0 {
  24605. user_name = "xxx"
  24606. } else {
  24607. user_name = role.UserName
  24608. }
  24609. var res ResultEight
  24610. var res10188 ResultEightFor10188
  24611. if config.IsOpen == 1 {
  24612. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24613. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  24614. "insutype=" + insutype +
  24615. "&clr_type=" + clr_type +
  24616. "&setl_optins=" + clr_org +
  24617. "&stmt_begndate=" + start_time +
  24618. "&stm_enddate=" + end_time +
  24619. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24620. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24621. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24622. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24623. "&fixmedins_code=" + miConfig.Code +
  24624. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24625. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24626. "&secret_key=" + miConfig.SecretKey +
  24627. "&org_name=" + miConfig.OrgName +
  24628. "&doctor=" + user_name +
  24629. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24630. fmt.Println(api)
  24631. resp, requestErr := http.Get(api)
  24632. if requestErr != nil {
  24633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24634. return
  24635. }
  24636. body, ioErr := ioutil.ReadAll(resp.Body)
  24637. fmt.Println(body)
  24638. if ioErr != nil {
  24639. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24641. return
  24642. }
  24643. var respJSON map[string]interface{}
  24644. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24645. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24647. return
  24648. }
  24649. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24650. userJSONBytes, _ := json.Marshal(respJSON)
  24651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24652. utils.ErrorLog("解析失败:%v", err)
  24653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24654. return
  24655. }
  24656. res.InfRefmsgid = res10188.InfRefmsgid
  24657. res.Output = res10188.Output
  24658. res.ErrMsg = res10188.ErrMsg
  24659. res.Cainfo = res10188.Cainfo
  24660. res.WarnMsg = res10188.WarnMsg
  24661. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24662. res.Infcode = infocode
  24663. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24664. if clr_type != "9903" {
  24665. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24666. }
  24667. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24668. "insutype=" + insutype +
  24669. "&clr_type=" + clr_type +
  24670. "&setl_optins=" + clr_org +
  24671. "&stmt_begndate=" + start_time +
  24672. "&stm_enddate=" + end_time +
  24673. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24674. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24675. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24676. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24677. "&fixmedins_code=" + miConfig.Code +
  24678. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24679. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24680. "&secret_key=" + miConfig.SecretKey +
  24681. "&org_name=" + miConfig.OrgName +
  24682. "&doctor=" + user_name
  24683. resp, requestErr := http.Get(api)
  24684. if requestErr != nil {
  24685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24686. return
  24687. }
  24688. body, ioErr := ioutil.ReadAll(resp.Body)
  24689. if ioErr != nil {
  24690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24692. return
  24693. }
  24694. var respJSON map[string]interface{}
  24695. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24698. return
  24699. }
  24700. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24701. result, _ := json.Marshal(respJSON)
  24702. fmt.Println("log")
  24703. fmt.Println(string(result))
  24704. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24705. utils.ErrorLog("解析失败:%v", err)
  24706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24707. return
  24708. }
  24709. res.InfRefmsgid = res10188.InfRefmsgid
  24710. res.Output = res10188.Output
  24711. res.ErrMsg = res10188.ErrMsg
  24712. res.Cainfo = res10188.Cainfo
  24713. res.WarnMsg = res10188.WarnMsg
  24714. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24715. res.Infcode = infocode
  24716. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24717. var baseParams models.BaseParams
  24718. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24719. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24720. baseParams.SecretKey = miConfig.SecretKey
  24721. baseParams.OrgName = miConfig.OrgName
  24722. baseParams.FixmedinsCode = miConfig.Code
  24723. baseParams.EncKey = miConfig.EncKey
  24724. baseParams.AppSecret = miConfig.AppSecret
  24725. baseParams.SignKey = miConfig.SignKey
  24726. baseParams.AppID = miConfig.Code
  24727. baseParams.Doctor = role.UserName
  24728. baseParams.RequestUrl = miConfig.Url
  24729. businessParams := models.BusinessParams{
  24730. Insutype: insutype,
  24731. ClrType: clr_type,
  24732. SetlOptins: clr_org,
  24733. StmtBegndate: start_time,
  24734. StmtEnddate: end_time,
  24735. MedfeeSumamt: medfee_sumamt,
  24736. FundPaySumamt: fund_pay_sumamt,
  24737. AcctPay: acct_pay,
  24738. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24739. }
  24740. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24741. fmt.Println(requestLog)
  24742. fmt.Println(result)
  24743. fmt.Println(err_msg)
  24744. var dat map[string]interface{}
  24745. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24746. fmt.Println(dat)
  24747. } else {
  24748. fmt.Println(err)
  24749. }
  24750. userJSONBytes, _ := json.Marshal(dat)
  24751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24752. utils.ErrorLog("解析失败:%v", err)
  24753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24754. return
  24755. }
  24756. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24757. var baseParams models.BaseParams
  24758. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24759. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24760. baseParams.SecretKey = miConfig.SecretKey
  24761. baseParams.OrgName = miConfig.OrgName
  24762. baseParams.FixmedinsCode = miConfig.Code
  24763. baseParams.EncKey = miConfig.EncKey
  24764. baseParams.AppSecret = miConfig.AppSecret
  24765. baseParams.SignKey = miConfig.SignKey
  24766. baseParams.AppID = miConfig.Code
  24767. baseParams.Doctor = role.UserName
  24768. baseParams.RequestUrl = miConfig.Url
  24769. baseParams.AccessKey = miConfig.AccessKey
  24770. businessParams := models.BusinessParams{
  24771. Insutype: insutype,
  24772. ClrType: clr_type,
  24773. SetlOptins: "430822",
  24774. StmtBegndate: start_time,
  24775. StmtEnddate: end_time,
  24776. MedfeeSumamt: medfee_sumamt,
  24777. FundPaySumamt: fund_pay_sumamt,
  24778. AcctPay: acct_pay,
  24779. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24780. }
  24781. 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)
  24782. fmt.Println(requestLog)
  24783. fmt.Println(result)
  24784. var dat map[string]interface{}
  24785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24786. fmt.Println(dat)
  24787. } else {
  24788. fmt.Println(err)
  24789. }
  24790. userJSONBytes, _ := json.Marshal(dat)
  24791. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24792. utils.ErrorLog("解析失败:%v", err)
  24793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24794. return
  24795. }
  24796. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24797. var baseParams models.BaseParams
  24798. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24799. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24800. baseParams.SecretKey = miConfig.SecretKey
  24801. baseParams.OrgName = miConfig.OrgName
  24802. baseParams.FixmedinsCode = miConfig.Code
  24803. baseParams.EncKey = miConfig.EncKey
  24804. baseParams.AppSecret = miConfig.AppSecret
  24805. baseParams.SignKey = miConfig.SignKey
  24806. baseParams.AppID = miConfig.Code
  24807. baseParams.Doctor = role.UserName
  24808. baseParams.RequestUrl = miConfig.Url
  24809. businessParams := models.BusinessParams{
  24810. Insutype: insutype,
  24811. ClrType: clr_type,
  24812. SetlOptins: clr_org,
  24813. StmtBegndate: start_time,
  24814. StmtEnddate: end_time,
  24815. MedfeeSumamt: medfee_sumamt,
  24816. FundPaySumamt: fund_pay_sumamt,
  24817. AcctPay: acct_pay,
  24818. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24819. }
  24820. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24821. fmt.Println(requestLog)
  24822. fmt.Println(result)
  24823. fmt.Println(err_msg)
  24824. var dat map[string]interface{}
  24825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24826. fmt.Println(dat)
  24827. } else {
  24828. fmt.Println(err)
  24829. }
  24830. userJSONBytes, _ := json.Marshal(dat)
  24831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24832. utils.ErrorLog("解析失败:%v", err)
  24833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24834. return
  24835. }
  24836. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24837. if len(clr_type) == 0 {
  24838. clr_type = "11"
  24839. }
  24840. api := miConfig.Url + "gdyb/ten?" +
  24841. "insutype=" + insutype +
  24842. "&clr_type=" + clr_type +
  24843. "&setl_optins=" + clr_org +
  24844. "&stmt_begndate=" + start_time +
  24845. "&stm_enddate=" + end_time +
  24846. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24847. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24848. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24849. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24850. "&fixmedins_code=" + miConfig.Code +
  24851. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24852. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24853. "&secret_key=" + miConfig.SecretKey +
  24854. "&org_name=" + miConfig.OrgName +
  24855. "&doctor=" + user_name
  24856. fmt.Println(api)
  24857. resp, requestErr := http.Get(api)
  24858. if requestErr != nil {
  24859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24860. return
  24861. }
  24862. body, ioErr := ioutil.ReadAll(resp.Body)
  24863. fmt.Println(body)
  24864. if ioErr != nil {
  24865. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24867. return
  24868. }
  24869. var respJSON map[string]interface{}
  24870. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24871. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24873. return
  24874. }
  24875. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24876. userJSONBytes, _ := json.Marshal(respJSON)
  24877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24878. utils.ErrorLog("解析失败:%v", err)
  24879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24880. return
  24881. }
  24882. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24883. var baseParams models.BaseParams
  24884. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24885. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24886. baseParams.SecretKey = miConfig.SecretKey
  24887. baseParams.OrgName = miConfig.OrgName
  24888. baseParams.FixmedinsCode = miConfig.Code
  24889. baseParams.EncKey = miConfig.EncKey
  24890. baseParams.AppSecret = miConfig.AppSecret
  24891. baseParams.SignKey = miConfig.SignKey
  24892. baseParams.AppID = miConfig.Code
  24893. baseParams.Doctor = role.UserName
  24894. baseParams.RequestUrl = miConfig.Url
  24895. if clr_type == "9903" {
  24896. clr_type = "9901"
  24897. }
  24898. businessParams := models.BusinessParams{
  24899. Insutype: insutype,
  24900. ClrType: clr_type,
  24901. SetlOptins: "360302",
  24902. StmtBegndate: start_time,
  24903. StmtEnddate: end_time,
  24904. MedfeeSumamt: 0,
  24905. FundPaySumamt: 0,
  24906. AcctPay: 0,
  24907. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24908. }
  24909. 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))
  24910. fmt.Println(requestLog)
  24911. fmt.Println(result)
  24912. var dat map[string]interface{}
  24913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24914. fmt.Println(dat)
  24915. } else {
  24916. fmt.Println(err)
  24917. }
  24918. userJSONBytes, _ := json.Marshal(dat)
  24919. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24920. utils.ErrorLog("解析失败:%v", err)
  24921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24922. return
  24923. }
  24924. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24925. var api string
  24926. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24927. "&clr_type=" + clr_type +
  24928. "&setl_optins=" + clr_org +
  24929. "&stmt_begndate=" + start_time +
  24930. "&stm_enddate=" + end_time +
  24931. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24932. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24933. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24934. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24935. "&fixmedins_code=" + miConfig.Code +
  24936. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24937. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24938. "&secret_key=" + miConfig.SecretKey +
  24939. "&org_name=" + miConfig.OrgName +
  24940. "&doctor=" + user_name + "&url=" + miConfig.Url
  24941. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24942. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24943. resp, requestErr := http.Get(api)
  24944. if requestErr != nil {
  24945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24946. return
  24947. }
  24948. body, ioErr := ioutil.ReadAll(resp.Body)
  24949. if ioErr != nil {
  24950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24952. return
  24953. }
  24954. var respJSON map[string]interface{}
  24955. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24958. return
  24959. }
  24960. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24961. if status == "0" {
  24962. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24963. c.ServeSuccessJSON(map[string]interface{}{
  24964. "failed_code": -10,
  24965. "msg": err_msg,
  24966. })
  24967. return
  24968. }
  24969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24970. userJSONBytes, _ := json.Marshal(respJSON)
  24971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24972. utils.ErrorLog("解析失败:%v", err)
  24973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24974. return
  24975. }
  24976. } else {
  24977. if len(clr_type) == 0 {
  24978. clr_type = "11"
  24979. }
  24980. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24981. "insutype=" + insutype +
  24982. "&clr_type=" + clr_type +
  24983. "&setl_optins=" + clr_org +
  24984. "&stmt_begndate=" + start_time +
  24985. "&stm_enddate=" + end_time +
  24986. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24987. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24988. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24989. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24990. "&fixmedins_code=" + miConfig.Code +
  24991. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24992. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24993. "&secret_key=" + miConfig.SecretKey +
  24994. "&org_name=" + miConfig.OrgName +
  24995. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24996. fmt.Println(api)
  24997. resp, requestErr := http.Get(api)
  24998. if requestErr != nil {
  24999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25000. return
  25001. }
  25002. body, ioErr := ioutil.ReadAll(resp.Body)
  25003. fmt.Println(body)
  25004. if ioErr != nil {
  25005. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25007. return
  25008. }
  25009. var respJSON map[string]interface{}
  25010. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25011. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25013. return
  25014. }
  25015. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25016. userJSONBytes, _ := json.Marshal(respJSON)
  25017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25018. utils.ErrorLog("解析失败:%v", err)
  25019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25020. return
  25021. }
  25022. }
  25023. if res.Infcode == 0 {
  25024. if res.Output.Stmtinfo.StmtRslt == "0" {
  25025. micc := &models.MedicalInsuranceCostCompare{
  25026. StartTime: startime.Unix(),
  25027. EndTime: endtime.Unix(),
  25028. Insutype: insutype,
  25029. CheckType: 1,
  25030. Num: fixmedins_setl_cnt,
  25031. Mtime: time.Now().Unix(),
  25032. Status: 1,
  25033. UserOrgId: adminUser.CurrentOrgId,
  25034. CostTotal: medfee_sumamt,
  25035. FuncTotal: fund_pay_sumamt,
  25036. PsnPay: acct_pay,
  25037. Creator: admin_user_id,
  25038. Ctime: time.Now().Unix(),
  25039. ClrType: clr_type,
  25040. }
  25041. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25042. if err == nil {
  25043. c.ServeSuccessJSON(map[string]interface{}{
  25044. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25045. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25046. })
  25047. } else {
  25048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25049. }
  25050. } else {
  25051. c.ServeSuccessJSON(map[string]interface{}{
  25052. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25053. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25054. })
  25055. }
  25056. } else {
  25057. c.ServeSuccessJSON(map[string]interface{}{
  25058. "failed_code": -10,
  25059. "msg": res.ErrMsg,
  25060. })
  25061. }
  25062. }
  25063. }
  25064. func (c *HisApiController) Check310() {
  25065. adminUser := c.GetAdminUserInfo()
  25066. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25067. var user_name string
  25068. user_name = "高慧裕"
  25069. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25070. "insutype=" + "310" +
  25071. "&clr_type=" + "" +
  25072. "&setl_optins=" + "441202" +
  25073. "&stmt_begndate=" + "2022-03-01" +
  25074. "&stm_enddate=" + "2022-03-31" +
  25075. "&medfee_sumamt=" + "194930.12" +
  25076. "&fund_pay_sumamt=" + "188741.46" +
  25077. "&acct_pay=" + "0" +
  25078. "&fixmedins_setl_cnt=" + "452" +
  25079. "&fixmedins_code=" + miConfig.Code +
  25080. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25081. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25082. "&secret_key=" + miConfig.SecretKey +
  25083. "&org_name=" + miConfig.OrgName +
  25084. "&doctor=" + user_name
  25085. fmt.Println(api)
  25086. resp, requestErr := http.Get(api)
  25087. if requestErr != nil {
  25088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25089. return
  25090. }
  25091. body, ioErr := ioutil.ReadAll(resp.Body)
  25092. fmt.Println(body)
  25093. if ioErr != nil {
  25094. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25096. return
  25097. }
  25098. var respJSON map[string]interface{}
  25099. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25100. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25102. return
  25103. }
  25104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25105. userJSONBytes, _ := json.Marshal(respJSON)
  25106. var res ResultEight
  25107. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25108. utils.ErrorLog("解析失败:%v", err)
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. }
  25113. func (c *HisApiController) Check390() {
  25114. adminUser := c.GetAdminUserInfo()
  25115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25116. var user_name string
  25117. user_name = "高慧裕"
  25118. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25119. "insutype=" + "390" +
  25120. "&clr_type=" + "" +
  25121. "&setl_optins=" + "441202" +
  25122. "&stmt_begndate=" + "2022-03-01" +
  25123. "&stm_enddate=" + "2022-03-31" +
  25124. "&medfee_sumamt=" + "1068448.89" +
  25125. "&fund_pay_sumamt=" + "1014677.62" +
  25126. "&acct_pay=" + "0" +
  25127. "&fixmedins_setl_cnt=" + "1950" +
  25128. "&fixmedins_code=" + miConfig.Code +
  25129. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25130. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25131. "&secret_key=" + miConfig.SecretKey +
  25132. "&org_name=" + miConfig.OrgName +
  25133. "&doctor=" + user_name
  25134. fmt.Println(api)
  25135. resp, requestErr := http.Get(api)
  25136. if requestErr != nil {
  25137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25138. return
  25139. }
  25140. body, ioErr := ioutil.ReadAll(resp.Body)
  25141. fmt.Println(body)
  25142. if ioErr != nil {
  25143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25145. return
  25146. }
  25147. var respJSON map[string]interface{}
  25148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25151. return
  25152. }
  25153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25154. userJSONBytes, _ := json.Marshal(respJSON)
  25155. var res ResultEight
  25156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25157. utils.ErrorLog("解析失败:%v", err)
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. }
  25162. // 对账明细
  25163. func (c *HisApiController) GetCheckDetailAccount() {
  25164. start_time := c.GetString("start_time")
  25165. end_time := c.GetString("end_time")
  25166. admin_user_id, _ := c.GetInt64("admin_user_id")
  25167. adminUser := c.GetAdminUserInfo()
  25168. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25169. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25170. timeLayout := "2006-01-02"
  25171. loc, _ := time.LoadLocation("Local")
  25172. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25173. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25174. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  25175. rand.Seed(time.Now().UnixNano())
  25176. num := rand.Intn(30000)
  25177. Mkdir(miConfig.OrgName)
  25178. file := strconv.FormatInt(int64(num), 10)
  25179. file_name := file + ".txt"
  25180. zip_name := file + ".zip"
  25181. zip_path := miConfig.OrgName + "/" + zip_name
  25182. file_path := miConfig.OrgName + "/" + file_name
  25183. decimal.DivisionPrecision = 2
  25184. var medfee_sumamt float64
  25185. var psn_cash_pay float64
  25186. var fund_pay_sumamt float64
  25187. fixmedins_setl_cnt := int64(len(orders))
  25188. for _, item := range orders {
  25189. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25190. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  25191. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25192. }
  25193. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  25194. defer f.Close()
  25195. if err != nil {
  25196. fmt.Println(err.Error())
  25197. } else {
  25198. for _, item := range orders {
  25199. var refd_setl_flag string
  25200. if item.OrderStatus == 2 {
  25201. refd_setl_flag = "0"
  25202. var str string
  25203. str = item.SetlId + " " +
  25204. item.MdtrtId + " " +
  25205. item.PsnNo + " " +
  25206. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25207. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25208. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  25209. _, err = f.Write([]byte(str))
  25210. }
  25211. if item.OrderStatus == 3 {
  25212. var str string
  25213. str = item.SetlId + " " +
  25214. item.MdtrtId + " " +
  25215. item.PsnNo + " " +
  25216. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25217. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25218. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  25219. _, err = f.Write([]byte(str))
  25220. var str2 string
  25221. str2 = item.SetlId + " " +
  25222. item.MdtrtId + " " +
  25223. item.PsnNo + " " +
  25224. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  25225. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  25226. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  25227. _, err = f.Write([]byte(str2))
  25228. }
  25229. }
  25230. }
  25231. Zip(file_path, zip_path)
  25232. fmt.Println(ReadFile(zip_path))
  25233. fmt.Println(string(ReadFile(zip_path)))
  25234. if config.IsOpen == 1 {
  25235. var user_name string
  25236. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25237. if role.ID == 0 {
  25238. user_name = "管理员"
  25239. } else {
  25240. user_name = role.UserName
  25241. }
  25242. baseParams := models.BaseParams{
  25243. SecretKey: miConfig.SecretKey,
  25244. FixmedinsCode: miConfig.Code,
  25245. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25246. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25247. OrgName: miConfig.OrgName,
  25248. Doctor: user_name,
  25249. }
  25250. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  25251. var dat map[string]interface{}
  25252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25253. fmt.Println(dat)
  25254. } else {
  25255. fmt.Println(err)
  25256. }
  25257. userJSONBytes, _ := json.Marshal(dat)
  25258. var res ResultNine
  25259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25260. utils.ErrorLog("解析失败:%v", err)
  25261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25262. return
  25263. }
  25264. if res.Infcode == 0 {
  25265. fileNo := res.Output.FileQuryNo
  25266. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  25267. "file_qury_no=" + fileNo +
  25268. "&setl_optins=" + "定点医保中心" +
  25269. "&stmt_begndate=" + start_time +
  25270. "&stm_enddate=" + end_time +
  25271. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25272. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25273. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  25274. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25275. "&fixmedins_code=" + miConfig.Code +
  25276. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25277. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25278. "&secret_key=" + miConfig.SecretKey +
  25279. "&org_name=" + miConfig.OrgName +
  25280. "&doctor=" + user_name
  25281. resp, requestErr := http.Get(api)
  25282. if requestErr != nil {
  25283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25284. return
  25285. }
  25286. body, ioErr := ioutil.ReadAll(resp.Body)
  25287. if ioErr != nil {
  25288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25290. return
  25291. }
  25292. var respJSON map[string]interface{}
  25293. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25296. return
  25297. }
  25298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25299. userJSONBytes, _ := json.Marshal(respJSON)
  25300. var res ResultTen
  25301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25302. utils.ErrorLog("解析失败:%v", err)
  25303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25304. return
  25305. }
  25306. if res.Infcode == 0 {
  25307. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  25308. micc := &models.MedicalInsuranceCostCompare{
  25309. StartTime: startime.Unix(),
  25310. EndTime: endtime.Unix(),
  25311. Insutype: "0",
  25312. CheckType: 2,
  25313. Num: fixmedins_setl_cnt,
  25314. Mtime: time.Now().Unix(),
  25315. Status: 1,
  25316. UserOrgId: adminUser.CurrentOrgId,
  25317. CostTotal: medfee_sumamt,
  25318. FuncTotal: fund_pay_sumamt,
  25319. PsnPay: psn_cash_pay,
  25320. Creator: admin_user_id,
  25321. Ctime: time.Now().Unix(),
  25322. }
  25323. service.CreateMedicalInsuranceCostCompareRecord(micc)
  25324. c.ServeSuccessJSON(map[string]interface{}{
  25325. "msg": "明细对账成功",
  25326. })
  25327. }
  25328. } else {
  25329. }
  25330. }
  25331. }
  25332. type CustomOrderInfo struct {
  25333. Name string
  25334. Spec string
  25335. Unit string
  25336. Count float64
  25337. Price float64
  25338. Total float64
  25339. }
  25340. func (c *HisApiController) GetBatchSettleAccounts() {
  25341. admin_user_id, _ := c.GetInt64("admin_user_id")
  25342. order_ids := c.GetString("order_ids")
  25343. order_ids_arr := strings.Split(order_ids, ",")
  25344. data3 := []map[string]interface{}{}
  25345. for _, item := range order_ids_arr {
  25346. id, _ := strconv.ParseInt(item, 10, 64)
  25347. order_id := id
  25348. adminUser := c.GetAdminUserInfo()
  25349. order, _ := service.GetHisOrderByID(order_id)
  25350. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25351. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25352. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25353. orderInfos = append(orderInfos, orderInfos_two...)
  25354. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25355. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25356. var diagnosis_ids []string
  25357. if his.ID > 0 {
  25358. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25359. } else {
  25360. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25361. }
  25362. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25363. var dia_config []*models.HisXtDiagnoseConfig
  25364. var name string
  25365. for _, item := range diagnosis_ids {
  25366. id, _ := strconv.ParseInt(item, 10, 64)
  25367. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25368. dia_config = append(dia_config, &diagnosisConfig)
  25369. if len(name) == 0 {
  25370. name = diagnosisConfig.ClassName
  25371. }
  25372. //} else {
  25373. // name = name + "," + diagnosisConfig.ClassName
  25374. //}
  25375. }
  25376. var bedCostTotal float64 = 0 //床位总费
  25377. var bedCostSelfTotal float64 = 0 //床位自费
  25378. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25379. var bedSelfTotal float64 = 0 //床位部分项目自费
  25380. var bedInscpTotal float64 = 0 //床位部分项目自费
  25381. var operationCostTotal float64 = 0 //手术费
  25382. var operationCostSelfTotal float64 = 0 //手术费
  25383. var operationCostPartSelfTotal float64 = 0 //手术费
  25384. var operationSelfTotal float64 = 0 //床位部分项目自费
  25385. var operationInscpTotal float64 = 0 //床位部分项目自费
  25386. var otherCostTotal float64 = 0 //其他费用
  25387. var otherCostSelfTotal float64 = 0 //其他费用
  25388. var otherCostPartSelfTotal float64 = 0 //其他费用
  25389. var otherSelfTotal float64 = 0 //床位部分项目自费
  25390. var otherInscpTotal float64 = 0 //床位部分项目自费
  25391. var materialCostTotal float64 = 0 //材料费
  25392. var materialCostSelfTotal float64 = 0 //材料费
  25393. var materialCostPartSelfTotal float64 = 0 //材料费
  25394. var materialSelfTotal float64 = 0 //床位部分项目自费
  25395. var materialInscpTotal float64 = 0 //床位部分项目自费
  25396. var westernMedicineCostTotal float64 = 0 //西药费
  25397. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25398. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25399. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25400. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25401. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25402. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25403. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25404. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25405. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25406. var checkCostTotal float64 = 0 //检查费
  25407. var checkCostSelfTotal float64 = 0 //检查费
  25408. var checkCostPartSelfTotal float64 = 0 //检查费
  25409. var checkSelfTotal float64 = 0 //床位部分项目自费
  25410. var checkInscpTotal float64 = 0 //床位部分项目自费
  25411. var laboratoryCostTotal float64 = 0 //化验费
  25412. var laboratoryCostSelfTotal float64 = 0 //化验费
  25413. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25414. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25415. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25416. var treatCostTotal float64 = 0 //治疗费用
  25417. var treatCostSelfTotal float64 = 0 //治疗费用
  25418. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25419. var treatSelfTotal float64 = 0 //床位部分项目自费
  25420. var treatInscpTotal float64 = 0 //床位部分项目自费
  25421. decimal.DivisionPrecision = 2
  25422. for _, item := range orderInfos {
  25423. if item.MedChrgitmType == "01" { //床位费
  25424. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25425. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25426. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25427. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25428. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25429. }
  25430. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25431. if item.MedChrgitmType == "03" { //检查费
  25432. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25433. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25434. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25435. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25436. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25437. }
  25438. } else {
  25439. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25440. fmt.Println("------------")
  25441. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25442. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25443. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25444. }
  25445. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25446. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25447. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25448. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25449. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25450. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25451. }
  25452. }
  25453. if item.MedChrgitmType == "04" { //化验费
  25454. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25455. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25456. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25457. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25458. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25459. }
  25460. if item.MedChrgitmType == "05" { //治疗费
  25461. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25462. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25463. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25464. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25465. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25466. }
  25467. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25468. fmt.Println("------------")
  25469. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25470. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25471. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25472. }
  25473. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25474. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25475. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25476. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25477. }
  25478. //if item.MedChrgitmType == "06" { //手术费
  25479. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25480. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25481. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25482. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25483. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25484. //
  25485. //}
  25486. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25487. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25488. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25489. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25490. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25491. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25492. }
  25493. if item.MedChrgitmType == "09" { //西药费
  25494. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25495. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25496. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25497. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25498. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25499. }
  25500. if item.MedChrgitmType == "11" { //中成费
  25501. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25502. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25503. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25504. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25505. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25506. }
  25507. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25508. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25509. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25510. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25511. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25512. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25513. }
  25514. }
  25515. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25516. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25517. var user_name string
  25518. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25519. if role.ID == 0 {
  25520. user_name = "管理员"
  25521. } else {
  25522. user_name = role.UserName
  25523. }
  25524. baseParams := models.BaseParams{
  25525. SecretKey: miConfig.SecretKey,
  25526. FixmedinsCode: miConfig.Code,
  25527. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25528. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25529. OrgName: miConfig.OrgName,
  25530. Doctor: user_name,
  25531. RequestUrl: miConfig.Url,
  25532. AccessKey: miConfig.AccessKey,
  25533. }
  25534. businessParams := models.BusinessParams{
  25535. PsnNo: order.PsnNo,
  25536. MdtrtId: order.MdtrtId,
  25537. SetlId: order.SetlId,
  25538. }
  25539. var res ResultEleven
  25540. var resEleven10265 ResultEleven10265
  25541. if config.IsOpen == 1 {
  25542. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25543. result := service.Gdyb5203(baseParams, businessParams)
  25544. service.Gdyb5204(baseParams, businessParams)
  25545. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25546. var dat map[string]interface{}
  25547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25548. fmt.Println(dat)
  25549. } else {
  25550. fmt.Println(err)
  25551. }
  25552. userJSONBytes, _ := json.Marshal(dat)
  25553. if miConfig.Code == "H15049901371" {
  25554. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25555. utils.ErrorLog("解析失败:%v", err)
  25556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25557. return
  25558. }
  25559. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25560. res.Output = resEleven10265.Output
  25561. res.ErrMsg = resEleven10265.ErrMsg
  25562. res.Cainfo = resEleven10265.Cainfo
  25563. res.WarnMsg = resEleven10265.WarnMsg
  25564. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25565. res.Infcode = infocode
  25566. } else {
  25567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25568. utils.ErrorLog("解析失败:%v", err)
  25569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25570. return
  25571. }
  25572. }
  25573. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25574. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25575. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25576. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25577. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25578. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25579. var doctor_name string
  25580. if roles.ID == 0 {
  25581. doctor_name = "管理员"
  25582. } else {
  25583. doctor_name = roles.UserName
  25584. }
  25585. yiliao_leibie := ""
  25586. switch order.MedType {
  25587. case "11":
  25588. yiliao_leibie = "普通门诊"
  25589. break
  25590. case "12":
  25591. yiliao_leibie = "门诊挂号"
  25592. break
  25593. case "13":
  25594. yiliao_leibie = "急诊"
  25595. break
  25596. case "14":
  25597. yiliao_leibie = "门诊特殊病"
  25598. break
  25599. case "15":
  25600. yiliao_leibie = "门诊统筹"
  25601. break
  25602. case "16":
  25603. yiliao_leibie = "门诊慢性病"
  25604. break
  25605. case "21":
  25606. yiliao_leibie = "普通住院"
  25607. break
  25608. }
  25609. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25610. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  25611. if res.Infcode == 0 {
  25612. data2 := map[string]interface{}{
  25613. "diagnosis": name,
  25614. "order_infos": orderInfos,
  25615. "number": order.MdtrtId,
  25616. "date": order.SettleAccountsDate,
  25617. "charge_admin": charge_admin,
  25618. "printor_admin": printor_admin,
  25619. "info": res.Output.Setlinfo,
  25620. "order": order,
  25621. "bedCostTotal": bedCostTotal,
  25622. "bedCostSelfTotal": bedCostSelfTotal,
  25623. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25624. "bedSelfTotal": bedSelfTotal,
  25625. "bedInscpTotal": bedInscpTotal,
  25626. "operationCostTotal": operationCostTotal,
  25627. "operationCostSelfTotal": operationCostSelfTotal,
  25628. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25629. "operationSelfTotal": operationSelfTotal,
  25630. "operationInscpTotal": operationInscpTotal,
  25631. "otherCostTotal": otherCostTotal,
  25632. "otherCostSelfTotal": otherCostSelfTotal,
  25633. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25634. "otherSelfTotal": otherSelfTotal,
  25635. "otherInscpTotal": otherInscpTotal,
  25636. "materialCostTotal": materialCostTotal,
  25637. "materialCostSelfTotal": materialCostSelfTotal,
  25638. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25639. "materialSelfTotal": materialSelfTotal,
  25640. "materialInscpTotal": materialInscpTotal,
  25641. "westernMedicineCostTotal": westernMedicineCostTotal,
  25642. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25643. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25644. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25645. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25646. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25647. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25648. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25649. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25650. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25651. "checkCostTotal": checkCostTotal,
  25652. "checkCostSelfTotal": checkCostSelfTotal,
  25653. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25654. "checkSelfTotal": checkSelfTotal,
  25655. "checkInscpTotal": checkInscpTotal,
  25656. "laboratoryCostTotal": laboratoryCostTotal,
  25657. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25658. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25659. "laboratorySelfTotal": laboratorySelfTotal,
  25660. "laboratoryInscpTotal": laboratoryInscpTotal,
  25661. "treatCostTotal": treatCostTotal,
  25662. "treatCostSelfTotal": treatCostSelfTotal,
  25663. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25664. "treatSelfTotal": treatSelfTotal,
  25665. "treatInscpTotal": treatInscpTotal,
  25666. "doctor_info": doctor_info,
  25667. "doctor_code": adminRole_two.DoctorCode,
  25668. "doctor_name": doctor_name,
  25669. "health_card_no": order.PsnNo,
  25670. "department": departments.Name,
  25671. "yiliao_leibie": yiliao_leibie,
  25672. "after_money": order.AccountPrice,
  25673. "patient": patient,
  25674. "org_name": miConfig.OrgName,
  25675. "org_code": miConfig.Code,
  25676. "order_number": order.Number,
  25677. "his_hospital": his_hospital,
  25678. "his": his,
  25679. "dia_config": dia_config,
  25680. "psn_cash_pay": order.PsnCashPay,
  25681. //"check_order_info": cus_slice,
  25682. }
  25683. data3 = append(data3, data2)
  25684. }
  25685. }
  25686. }
  25687. c.ServeSuccessJSON(map[string]interface{}{
  25688. "infos": data3,
  25689. })
  25690. }
  25691. func (c *HisApiController) GetSettleAccounts() {
  25692. //id, _ := c.GetInt64("id")
  25693. //record_time := c.GetString("record_time")
  25694. order_id, _ := c.GetInt64("order_id")
  25695. admin_user_id, _ := c.GetInt64("admin_user_id")
  25696. //timeLayout := "2006-01-02"
  25697. //loc, _ := time.LoadLocation("Local")
  25698. //
  25699. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25700. //if err != nil {
  25701. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25702. // return
  25703. //}Hbyb5203
  25704. //recordDateTime := theTime.Unix()
  25705. adminUser := c.GetAdminUserInfo()
  25706. order, _ := service.GetHisOrderByID(order_id)
  25707. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25708. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25709. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25710. orderInfos = append(orderInfos, orderInfos_two...)
  25711. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25712. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25713. var diagnosis_ids []string
  25714. if his.ID > 0 {
  25715. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25716. } else {
  25717. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25718. }
  25719. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25720. var dia_config []*models.HisXtDiagnoseConfig
  25721. var name string
  25722. for _, item := range diagnosis_ids {
  25723. id, _ := strconv.ParseInt(item, 10, 64)
  25724. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25725. dia_config = append(dia_config, &diagnosisConfig)
  25726. if len(name) == 0 {
  25727. name = diagnosisConfig.ClassName
  25728. } else {
  25729. name = name + "," + diagnosisConfig.ClassName
  25730. }
  25731. }
  25732. if patient.UserOrgId == 10215 {
  25733. name = "慢性肾功能不全(血透治疗)"
  25734. }
  25735. var bedCostTotal float64 = 0 //床位总费
  25736. var bedCostSelfTotal float64 = 0 //床位自费
  25737. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25738. var bedSelfTotal float64 = 0 //床位部分项目自费
  25739. var bedInscpTotal float64 = 0 //床位部分项目自费
  25740. var operationCostTotal float64 = 0 //手术费
  25741. var operationCostSelfTotal float64 = 0 //手术费
  25742. var operationCostPartSelfTotal float64 = 0 //手术费
  25743. var operationSelfTotal float64 = 0 //床位部分项目自费
  25744. var operationInscpTotal float64 = 0 //床位部分项目自费
  25745. var otherCostTotal float64 = 0 //其他费用
  25746. var otherCostSelfTotal float64 = 0 //其他费用
  25747. var otherCostPartSelfTotal float64 = 0 //其他费用
  25748. var otherSelfTotal float64 = 0 //床位部分项目自费
  25749. var otherInscpTotal float64 = 0 //床位部分项目自费
  25750. var materialCostTotal float64 = 0 //材料费
  25751. var materialCostSelfTotal float64 = 0 //材料费
  25752. var materialCostPartSelfTotal float64 = 0 //材料费
  25753. var materialSelfTotal float64 = 0 //床位部分项目自费
  25754. var materialInscpTotal float64 = 0 //床位部分项目自费
  25755. var westernMedicineCostTotal float64 = 0 //西药费
  25756. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25757. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25758. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25759. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25760. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25761. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25762. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25763. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25764. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25765. var checkCostTotal float64 = 0 //检查费
  25766. var checkCostSelfTotal float64 = 0 //检查费
  25767. var checkCostPartSelfTotal float64 = 0 //检查费
  25768. var checkSelfTotal float64 = 0 //床位部分项目自费
  25769. var checkInscpTotal float64 = 0 //床位部分项目自费
  25770. var laboratoryCostTotal float64 = 0 //化验费
  25771. var laboratoryCostSelfTotal float64 = 0 //化验费
  25772. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25773. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25774. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25775. var treatCostTotal float64 = 0 //治疗费用
  25776. var treatCostSelfTotal float64 = 0 //治疗费用
  25777. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25778. var treatSelfTotal float64 = 0 //床位部分项目自费
  25779. var treatInscpTotal float64 = 0 //床位部分项目自费
  25780. decimal.DivisionPrecision = 2
  25781. for _, item := range orderInfos {
  25782. if item.MedChrgitmType == "01" { //床位费
  25783. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25784. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25785. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25786. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25787. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25788. }
  25789. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25790. if item.MedChrgitmType == "03" { //检查费
  25791. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25792. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25793. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25794. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25795. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25796. }
  25797. } else {
  25798. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25799. fmt.Println("------------")
  25800. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25801. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25802. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25803. }
  25804. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25805. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25806. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25807. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25808. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25809. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25810. }
  25811. }
  25812. if item.MedChrgitmType == "04" { //化验费
  25813. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25814. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25815. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25816. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25817. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25818. }
  25819. if item.MedChrgitmType == "05" { //治疗费
  25820. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25821. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25822. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25823. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25824. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25825. }
  25826. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25827. fmt.Println("------------")
  25828. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25829. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25830. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25831. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25832. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25833. }
  25834. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25835. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25836. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25837. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25838. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25839. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25840. }
  25841. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25842. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25843. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25844. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25845. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25846. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25847. }
  25848. if item.MedChrgitmType == "09" { //西药费
  25849. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25850. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25851. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25852. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25853. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25854. }
  25855. if item.MedChrgitmType == "11" { //中成费
  25856. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25857. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25858. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25859. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25860. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25861. }
  25862. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25863. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25864. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25865. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25866. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25867. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25868. }
  25869. }
  25870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25871. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25872. var user_name string
  25873. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25874. if role.ID == 0 {
  25875. user_name = "管理员"
  25876. } else {
  25877. user_name = role.UserName
  25878. }
  25879. baseParams := models.BaseParams{
  25880. SecretKey: miConfig.SecretKey,
  25881. FixmedinsCode: miConfig.Code,
  25882. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25883. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25884. OrgName: miConfig.OrgName,
  25885. Doctor: user_name,
  25886. RequestUrl: miConfig.Url,
  25887. AccessKey: miConfig.AccessKey,
  25888. }
  25889. businessParams := models.BusinessParams{
  25890. PsnNo: order.PsnNo,
  25891. MdtrtId: order.MdtrtId,
  25892. SetlId: order.SetlId,
  25893. }
  25894. var res ResultEleven
  25895. var resah ResultElevenah
  25896. var resEleven10265 ResultEleven10265
  25897. if config.IsOpen == 1 {
  25898. if miConfig.MdtrtareaAdmvs == "421300" {
  25899. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25900. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25901. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25902. resp, requestErr := http.Get(api)
  25903. if requestErr != nil {
  25904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25905. return
  25906. }
  25907. body, ioErr := ioutil.ReadAll(resp.Body)
  25908. if ioErr != nil {
  25909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25911. return
  25912. }
  25913. var respJSON map[string]interface{}
  25914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25917. return
  25918. }
  25919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25920. result, _ := json.Marshal(respJSON)
  25921. fmt.Println("log")
  25922. fmt.Println(string(result))
  25923. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25924. utils.ErrorLog("解析失败:%v", err)
  25925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25926. return
  25927. }
  25928. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25929. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25930. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25931. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25932. resp, requestErr := http.Get(api)
  25933. if requestErr != nil {
  25934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25935. return
  25936. }
  25937. body, ioErr := ioutil.ReadAll(resp.Body)
  25938. if ioErr != nil {
  25939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25941. return
  25942. }
  25943. var respJSON map[string]interface{}
  25944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25947. return
  25948. }
  25949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25950. result, _ := json.Marshal(respJSON)
  25951. fmt.Println("log")
  25952. fmt.Println(string(result))
  25953. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25954. utils.ErrorLog("解析失败:%v", err)
  25955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25956. return
  25957. }
  25958. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25959. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25960. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25961. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  25962. resp, requestErr := http.Get(api)
  25963. if requestErr != nil {
  25964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25965. return
  25966. }
  25967. body, ioErr := ioutil.ReadAll(resp.Body)
  25968. if ioErr != nil {
  25969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25971. return
  25972. }
  25973. var respJSON map[string]interface{}
  25974. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25977. return
  25978. }
  25979. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25980. result, _ := json.Marshal(respJSON)
  25981. fmt.Println("log")
  25982. fmt.Println(string(result))
  25983. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25984. utils.ErrorLog("解析失败:%v", err)
  25985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25986. return
  25987. }
  25988. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25989. var api string
  25990. if miConfig.MdtrtareaAdmvs == "320921" {
  25991. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25992. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25993. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25994. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25995. } else {
  25996. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25997. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25998. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25999. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26000. }
  26001. resp, requestErr := http.Get(api)
  26002. if requestErr != nil {
  26003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26004. return
  26005. }
  26006. body, ioErr := ioutil.ReadAll(resp.Body)
  26007. if ioErr != nil {
  26008. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26010. return
  26011. }
  26012. var respJSON map[string]interface{}
  26013. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26014. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26016. return
  26017. }
  26018. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26019. result, _ := json.Marshal(respJSON)
  26020. fmt.Println("log")
  26021. fmt.Println(string(result))
  26022. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26023. utils.ErrorLog("解析失败:%v", err)
  26024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26025. return
  26026. }
  26027. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26028. res.Output = resEleven10265.Output
  26029. res.ErrMsg = resEleven10265.ErrMsg
  26030. res.Cainfo = resEleven10265.Cainfo
  26031. res.WarnMsg = resEleven10265.WarnMsg
  26032. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26033. res.Infcode = infocode
  26034. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26035. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26036. saveLog(result, requestLog, "5203", "结算单")
  26037. var dat map[string]interface{}
  26038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26039. fmt.Println(dat)
  26040. } else {
  26041. fmt.Println(err)
  26042. }
  26043. userJSONBytes, _ := json.Marshal(dat)
  26044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26045. utils.ErrorLog("解析失败:%v", err)
  26046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26047. return
  26048. }
  26049. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26050. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26051. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26052. fmt.Println(result3)
  26053. fmt.Println(requestLog3)
  26054. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26055. fmt.Println(result2)
  26056. fmt.Println(requestLog2)
  26057. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26058. saveLog(result, requestLog, "5203", "结算单")
  26059. var dat map[string]interface{}
  26060. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26061. fmt.Println(dat)
  26062. } else {
  26063. fmt.Println(err)
  26064. }
  26065. userJSONBytes, _ := json.Marshal(dat)
  26066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26067. utils.ErrorLog("解析失败:%v", err)
  26068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26069. return
  26070. }
  26071. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26072. var api string
  26073. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26074. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26076. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26077. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26078. resp, requestErr := http.Get(api)
  26079. if requestErr != nil {
  26080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26081. return
  26082. }
  26083. body, ioErr := ioutil.ReadAll(resp.Body)
  26084. if ioErr != nil {
  26085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26087. return
  26088. }
  26089. var respJSON map[string]interface{}
  26090. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26093. return
  26094. }
  26095. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26096. if status == "0" {
  26097. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26098. c.ServeSuccessJSON(map[string]interface{}{
  26099. "failed_code": -10,
  26100. "msg": err_msg,
  26101. })
  26102. return
  26103. }
  26104. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26105. result, _ := json.Marshal(respJSON)
  26106. fmt.Println("log")
  26107. fmt.Println(string(result))
  26108. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26109. utils.ErrorLog("解析失败:%v", err)
  26110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26111. return
  26112. }
  26113. res.InfRefmsgid = resah.InfRefmsgid
  26114. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26115. // 创建对应的Time类型
  26116. t := time.UnixMilli(timestamp)
  26117. // 格式化成指定的日期字符串
  26118. str := t.Format("2006-01-02 15:04:05")
  26119. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26120. // 创建对应的Time类型
  26121. t3 := time.UnixMilli(timestamp2)
  26122. // 格式化成指定的日期字符串
  26123. str2 := t3.Format("2006-01-02 15:04:05")
  26124. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  26125. // 创建对应的Time类型
  26126. t4 := time.UnixMilli(timestamp3)
  26127. // 格式化成指定的日期字符串
  26128. str3 := t4.Format("2006-01-02 15:04:05")
  26129. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  26130. // 创建对应的Time类型
  26131. t5 := time.UnixMilli(timestamp4)
  26132. // 格式化成指定的日期字符串
  26133. str5 := t5.Format("2006-01-02 15:04:05")
  26134. res.Output.Setlinfo.Brdy = str2
  26135. res.Output.Setlinfo.SetlTime = str
  26136. res.Output.Setlinfo.Begndate = str3
  26137. res.Output.Setlinfo.Enddate = str5
  26138. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  26139. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  26140. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  26141. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  26142. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26143. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26144. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  26145. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  26146. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26147. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  26148. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  26149. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  26150. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26151. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  26152. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  26153. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  26154. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  26155. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  26156. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26157. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  26158. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  26159. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26160. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  26161. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  26162. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  26163. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26164. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  26165. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  26166. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  26167. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  26168. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26169. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  26170. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26171. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  26172. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  26173. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  26174. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  26175. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  26176. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  26177. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  26178. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  26179. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  26180. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  26181. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  26182. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  26183. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26184. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  26185. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  26186. //res.Output.Setldetail = resah.Output.Setldetail
  26187. res.ErrMsg = resah.ErrMsg
  26188. res.Cainfo = resah.Cainfo
  26189. res.WarnMsg = resah.WarnMsg
  26190. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26191. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  26192. saveLog(result, requestLog, "5203", "结算单")
  26193. var dat map[string]interface{}
  26194. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26195. fmt.Println(dat)
  26196. } else {
  26197. fmt.Println(err)
  26198. }
  26199. userJSONBytes, _ := json.Marshal(dat)
  26200. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26201. utils.ErrorLog("解析失败:%v", err)
  26202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26203. return
  26204. }
  26205. } else if miConfig.MdtrtareaAdmvs == "150499" {
  26206. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26207. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26208. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26209. resp, requestErr := http.Get(api)
  26210. if requestErr != nil {
  26211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26212. return
  26213. }
  26214. body, ioErr := ioutil.ReadAll(resp.Body)
  26215. if ioErr != nil {
  26216. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26218. return
  26219. }
  26220. var respJSON map[string]interface{}
  26221. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26222. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26224. return
  26225. }
  26226. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26227. result, _ := json.Marshal(respJSON)
  26228. fmt.Println("log")
  26229. fmt.Println(string(result))
  26230. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26231. utils.ErrorLog("解析失败:%v", err)
  26232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26233. return
  26234. }
  26235. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26236. res.Output = resEleven10265.Output
  26237. res.ErrMsg = resEleven10265.ErrMsg
  26238. res.Cainfo = resEleven10265.Cainfo
  26239. res.WarnMsg = resEleven10265.WarnMsg
  26240. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26241. res.Infcode = infocode
  26242. } else if miConfig.MdtrtareaAdmvs == "441799" {
  26243. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26244. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26245. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26246. resp, requestErr := http.Get(api)
  26247. if requestErr != nil {
  26248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26249. return
  26250. }
  26251. body, ioErr := ioutil.ReadAll(resp.Body)
  26252. if ioErr != nil {
  26253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26255. return
  26256. }
  26257. var respJSON map[string]interface{}
  26258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26261. return
  26262. }
  26263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26264. result, _ := json.Marshal(respJSON)
  26265. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26266. utils.ErrorLog("解析失败:%v", err)
  26267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26268. return
  26269. }
  26270. } else if miConfig.MdtrtareaAdmvs == "450721" {
  26271. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  26272. //return
  26273. } else {
  26274. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26275. if len(his.InsuplcAdmdvs) == 0 {
  26276. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  26277. } else {
  26278. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26279. }
  26280. result := service.Gdyb5203(baseParams, businessParams)
  26281. //service.Gdyb5204(baseParams, businessParams)
  26282. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26283. var dat map[string]interface{}
  26284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26285. fmt.Println(dat)
  26286. } else {
  26287. fmt.Println(err)
  26288. }
  26289. userJSONBytes, _ := json.Marshal(dat)
  26290. if miConfig.Code == "H15049901371" {
  26291. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26292. utils.ErrorLog("解析失败:%v", err)
  26293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26294. return
  26295. }
  26296. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26297. res.Output = resEleven10265.Output
  26298. res.ErrMsg = resEleven10265.ErrMsg
  26299. res.Cainfo = resEleven10265.Cainfo
  26300. res.WarnMsg = resEleven10265.WarnMsg
  26301. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26302. res.Infcode = infocode
  26303. } else {
  26304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26305. utils.ErrorLog("解析失败:%v", err)
  26306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26307. return
  26308. }
  26309. }
  26310. }
  26311. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26312. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26313. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26314. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26315. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26316. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26317. var doctor_name string
  26318. if roles.ID == 0 {
  26319. doctor_name = "管理员"
  26320. } else {
  26321. doctor_name = roles.UserName
  26322. }
  26323. yiliao_leibie := ""
  26324. switch order.MedType {
  26325. case "11":
  26326. yiliao_leibie = "普通门诊"
  26327. break
  26328. case "12":
  26329. yiliao_leibie = "门诊挂号"
  26330. break
  26331. case "13":
  26332. yiliao_leibie = "急诊"
  26333. break
  26334. case "14":
  26335. yiliao_leibie = "门诊特殊病"
  26336. break
  26337. case "15":
  26338. yiliao_leibie = "门诊统筹"
  26339. break
  26340. case "16":
  26341. yiliao_leibie = "门诊慢性病"
  26342. break
  26343. case "21":
  26344. yiliao_leibie = "普通住院"
  26345. break
  26346. }
  26347. //var rf []CustomFundPay
  26348. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  26349. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26350. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  26351. if res.Infcode == 0 {
  26352. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  26353. c.ServeSuccessJSON(map[string]interface{}{
  26354. "diagnosis": name,
  26355. "order_infos": orderInfos,
  26356. "number": order.MdtrtId,
  26357. "date": order.SettleAccountsDate,
  26358. "charge_admin": charge_admin,
  26359. "printor_admin": printor_admin,
  26360. "info": res.Output.Setlinfo,
  26361. "order": order,
  26362. "bedCostTotal": bedCostTotal,
  26363. "bedCostSelfTotal": bedCostSelfTotal,
  26364. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26365. "bedSelfTotal": bedSelfTotal,
  26366. "bedInscpTotal": bedInscpTotal,
  26367. "operationCostTotal": operationCostTotal,
  26368. "operationCostSelfTotal": operationCostSelfTotal,
  26369. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26370. "operationSelfTotal": operationSelfTotal,
  26371. "operationInscpTotal": operationInscpTotal,
  26372. "otherCostTotal": otherCostTotal,
  26373. "otherCostSelfTotal": otherCostSelfTotal,
  26374. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26375. "otherSelfTotal": otherSelfTotal,
  26376. "otherInscpTotal": otherInscpTotal,
  26377. "materialCostTotal": materialCostTotal,
  26378. "materialCostSelfTotal": materialCostSelfTotal,
  26379. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26380. "materialSelfTotal": materialSelfTotal,
  26381. "materialInscpTotal": materialInscpTotal,
  26382. "westernMedicineCostTotal": westernMedicineCostTotal,
  26383. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26384. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26385. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26386. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26387. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26388. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26389. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26390. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26391. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26392. "checkCostTotal": checkCostTotal,
  26393. "checkCostSelfTotal": checkCostSelfTotal,
  26394. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26395. "checkSelfTotal": checkSelfTotal,
  26396. "checkInscpTotal": checkInscpTotal,
  26397. "laboratoryCostTotal": laboratoryCostTotal,
  26398. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26399. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26400. "laboratorySelfTotal": laboratorySelfTotal,
  26401. "laboratoryInscpTotal": laboratoryInscpTotal,
  26402. "treatCostTotal": treatCostTotal,
  26403. "treatCostSelfTotal": treatCostSelfTotal,
  26404. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26405. "treatSelfTotal": treatSelfTotal,
  26406. "treatInscpTotal": treatInscpTotal,
  26407. "doctor_info": doctor_info,
  26408. "doctor_code": adminRole_two.DoctorCode,
  26409. "doctor_name": doctor_name,
  26410. "health_card_no": order.PsnNo,
  26411. "department": departments.Name,
  26412. "yiliao_leibie": yiliao_leibie,
  26413. "after_money": order.AccountPrice,
  26414. "patient": patient,
  26415. "org_name": miConfig.OrgName,
  26416. "org_code": miConfig.Code,
  26417. "order_number": order.Number,
  26418. "his_hospital": his_hospital,
  26419. "his": his,
  26420. "dia_config": dia_config,
  26421. "psn_cash_pay": order.PsnCashPay,
  26422. //"funds": rf,
  26423. //"check_order_info": cus_slice,
  26424. })
  26425. } else {
  26426. c.ServeSuccessJSON(map[string]interface{}{
  26427. "diagnosis": name,
  26428. "order_infos": orderInfos,
  26429. "number": order.MdtrtId,
  26430. "date": order.SettleAccountsDate,
  26431. "charge_admin": charge_admin,
  26432. "printor_admin": printor_admin,
  26433. "info": order,
  26434. "order": order,
  26435. "bedCostTotal": bedCostTotal,
  26436. "bedCostSelfTotal": bedCostSelfTotal,
  26437. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26438. "bedSelfTotal": bedSelfTotal,
  26439. "bedInscpTotal": bedInscpTotal,
  26440. "operationCostTotal": operationCostTotal,
  26441. "operationCostSelfTotal": operationCostSelfTotal,
  26442. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26443. "operationSelfTotal": operationSelfTotal,
  26444. "operationInscpTotal": operationInscpTotal,
  26445. "otherCostTotal": otherCostTotal,
  26446. "otherCostSelfTotal": otherCostSelfTotal,
  26447. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26448. "otherSelfTotal": otherSelfTotal,
  26449. "otherInscpTotal": otherInscpTotal,
  26450. "materialCostTotal": materialCostTotal,
  26451. "materialCostSelfTotal": materialCostSelfTotal,
  26452. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26453. "materialSelfTotal": materialSelfTotal,
  26454. "materialInscpTotal": materialInscpTotal,
  26455. "westernMedicineCostTotal": westernMedicineCostTotal,
  26456. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26457. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26458. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26459. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26460. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26461. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26462. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26463. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26464. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26465. "checkCostTotal": checkCostTotal,
  26466. "checkCostSelfTotal": checkCostSelfTotal,
  26467. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26468. "checkSelfTotal": checkSelfTotal,
  26469. "checkInscpTotal": checkInscpTotal,
  26470. "laboratoryCostTotal": laboratoryCostTotal,
  26471. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26472. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26473. "laboratorySelfTotal": laboratorySelfTotal,
  26474. "laboratoryInscpTotal": laboratoryInscpTotal,
  26475. "treatCostTotal": treatCostTotal,
  26476. "treatCostSelfTotal": treatCostSelfTotal,
  26477. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26478. "treatSelfTotal": treatSelfTotal,
  26479. "treatInscpTotal": treatInscpTotal,
  26480. "doctor_info": doctor_info,
  26481. "doctor_code": adminRole_two.DoctorCode,
  26482. "doctor_name": doctor_name,
  26483. "health_card_no": order.PsnNo,
  26484. "department": departments.Name,
  26485. "yiliao_leibie": yiliao_leibie,
  26486. "after_money": order.AccountPrice,
  26487. "patient": patient,
  26488. "org_name": miConfig.OrgName,
  26489. "org_code": miConfig.Code,
  26490. "order_number": order.Number,
  26491. "his_hospital": his_hospital,
  26492. "his": his,
  26493. "dia_config": dia_config,
  26494. "psn_cash_pay": order.PsnCashPay,
  26495. //"funds": rf,
  26496. //"check_order_info": cus_slice,
  26497. })
  26498. }
  26499. }
  26500. }
  26501. }
  26502. //func (c *HisApiController) CheckTreatment() {
  26503. // patient_id, _ := c.GetInt64("patient_id")
  26504. // id_card_no := c.GetString("id_card_no")
  26505. // insutype := c.GetString("insutype")
  26506. // med_type := c.GetString("med_type")
  26507. // admin_user_id, _ := c.GetInt64("admin_user_id")
  26508. //
  26509. // adminUser := c.GetAdminUserInfo()
  26510. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26511. //
  26512. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26513. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26514. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26515. //
  26516. // if miConfig.MdtrtareaAdmvs == "421300" {
  26517. // var res ResultTwo
  26518. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  26519. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26520. // "&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)
  26521. // resp, requestErr := http.Get(api)
  26522. // if requestErr != nil {
  26523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26524. // return
  26525. // }
  26526. //
  26527. // body, ioErr := ioutil.ReadAll(resp.Body)
  26528. // if ioErr != nil {
  26529. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26530. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26531. // return
  26532. // }
  26533. // var respJSON map[string]interface{}
  26534. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26535. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26537. // return
  26538. // }
  26539. //
  26540. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26541. // result, _ := json.Marshal(respJSON)
  26542. //
  26543. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26544. // utils.ErrorLog("解析失败:%v", err)
  26545. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26546. // return
  26547. // }
  26548. //
  26549. // if res.Infcode == 0 {
  26550. //
  26551. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  26552. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26553. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  26554. // resp, requestErr := http.Get(api)
  26555. // if requestErr != nil {
  26556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26557. // return
  26558. // }
  26559. //
  26560. // body, ioErr := ioutil.ReadAll(resp.Body)
  26561. // if ioErr != nil {
  26562. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26564. // return
  26565. // }
  26566. // var respJSON map[string]interface{}
  26567. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26568. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26570. // return
  26571. // }
  26572. // var res Result2001
  26573. //
  26574. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26575. // result2, _ := json.Marshal(respJSON)
  26576. //
  26577. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  26578. // utils.ErrorLog("解析失败:%v", err)
  26579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26580. // return
  26581. // }
  26582. //
  26583. // if res.Infcode == 0 {
  26584. // c.ServeSuccessJSON(map[string]interface{}{
  26585. // "msg": res.Output.Trtinfo,
  26586. // })
  26587. // }
  26588. //
  26589. // } else {
  26590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  26591. // return
  26592. // }
  26593. //
  26594. // } else {
  26595. //
  26596. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26597. // var dat map[string]interface{}
  26598. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26599. // fmt.Println(dat)
  26600. // } else {
  26601. // fmt.Println(err)
  26602. // }
  26603. // userJSONBytes, _ := json.Marshal(dat)
  26604. // var res ResultTwo
  26605. // var res10265 ResultTwo10265
  26606. // if miConfig.Code == "H15049901371" {
  26607. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26608. // utils.ErrorLog("解析失败:%v", err)
  26609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26610. // return
  26611. // }
  26612. // res.ErrMsg = res10265.ErrMsg
  26613. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26614. // res.Infcode = infocode
  26615. // res.Output = res10265.Output
  26616. // res.InfRefmsgid = res10265.InfRefmsgid
  26617. // } else {
  26618. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26619. // utils.ErrorLog("解析失败:%v", err)
  26620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26621. // return
  26622. // }
  26623. // }
  26624. //
  26625. // var user_name string
  26626. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  26627. // if role.ID == 0 {
  26628. // user_name = "xxx"
  26629. // } else {
  26630. // user_name = role.UserName
  26631. // }
  26632. //
  26633. // baseParams := models.BaseParams{
  26634. // SecretKey: miConfig.SecretKey,
  26635. // FixmedinsCode: miConfig.Code,
  26636. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26637. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26638. // OrgName: miConfig.OrgName,
  26639. // Doctor: user_name,
  26640. // }
  26641. //
  26642. // if config.IsOpen == 1 {
  26643. // if miConfig.Code == "H15049901371" {
  26644. // if med_type == "14" {
  26645. // if insutype == "390" {
  26646. // med_type = "9933"
  26647. // } else if insutype == "310" {
  26648. // med_type = "990502"
  26649. // }
  26650. // } else if med_type == "11" {
  26651. // med_type = "11"
  26652. // }
  26653. // }
  26654. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  26655. // var dat map[string]interface{}
  26656. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26657. // fmt.Println(dat)
  26658. // } else {
  26659. // fmt.Println(err)
  26660. // }
  26661. // var res Result2001
  26662. // var res10265 Result2001Org10265
  26663. // if miConfig.Code == "H15049901371" {
  26664. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26665. // utils.ErrorLog("解析失败:%v", err)
  26666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26667. // return
  26668. // }
  26669. // res.ErrMsg = res10265.ErrMsg
  26670. // res.Output = res10265.Output
  26671. // res.InfRefmsgid = res10265.InfRefmsgid
  26672. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26673. // res.Infcode = infocode
  26674. // } else {
  26675. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26676. // utils.ErrorLog("解析失败:%v", err)
  26677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26678. // return
  26679. // }
  26680. // }
  26681. // if res.Infcode == 0 {
  26682. // c.ServeSuccessJSON(map[string]interface{}{
  26683. // "msg": res.Output.Trtinfo,
  26684. // })
  26685. // }
  26686. // }
  26687. // }
  26688. //}
  26689. //func (c *HisApiController) PutRecord() {
  26690. // id, _ := c.GetInt64("id")
  26691. // record_time := c.GetString("record_time")
  26692. // timeLayout := "2006-01-02"
  26693. // loc, _ := time.LoadLocation("Local")
  26694. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26695. // if err != nil {
  26696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26697. // return
  26698. // }
  26699. // recordDateTime := theTime.Unix()
  26700. //
  26701. // adminInfo := c.GetAdminUserInfo()
  26702. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26703. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26704. //
  26705. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26706. //
  26707. // fmt.Println(miConfig.SecretKey)
  26708. //
  26709. // if patient == nil {
  26710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26711. // return
  26712. // }
  26713. // if len(patient.IdCardNo) == 0 {
  26714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26715. // return
  26716. // }
  26717. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26718. // if config.IsOpen == 1 {
  26719. // 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
  26720. // resp, requestErr := http.Get(api)
  26721. // if requestErr != nil {
  26722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26723. // return
  26724. // }
  26725. // defer resp.Body.Close()
  26726. // body, ioErr := ioutil.ReadAll(resp.Body)
  26727. // if ioErr != nil {
  26728. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26730. // return
  26731. // }
  26732. // var respJSON map[string]interface{}
  26733. //
  26734. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26735. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26736. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26737. // return
  26738. // }
  26739. //
  26740. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26741. // userJSONBytes, _ := json.Marshal(userJSON)
  26742. // var res ResultTwo
  26743. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26744. // utils.ErrorLog("解析失败:%v", err)
  26745. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26746. // return
  26747. // }
  26748. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26749. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26750. // infoStr := string(Iinfos)
  26751. // idetinfoStr := string(Idetinfos)
  26752. //
  26753. // if res.Infcode == 0 {
  26754. // his := models.VMHisPatient{
  26755. // Status: 1,
  26756. // Ctime: time.Now().Unix(),
  26757. // Mtime: time.Now().Unix(),
  26758. // PsnNo: res.Output.Baseinfo.PsnNo,
  26759. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26760. // Certno: res.Output.Baseinfo.Certno,
  26761. // PsnName: res.Output.Baseinfo.PsnName,
  26762. // Gend: res.Output.Baseinfo.Gend,
  26763. // Naty: res.Output.Baseinfo.Naty,
  26764. // Brdy: res.Output.Baseinfo.Brdy,
  26765. // Age: res.Output.Baseinfo.Age,
  26766. // Iinfo: infoStr,
  26767. // Idetinfo: idetinfoStr,
  26768. // PatientId: patient.ID,
  26769. // RecordDate: theTime.Unix(),
  26770. // UserOrgId: adminInfo.CurrentOrgId,
  26771. // AdminUserId: adminInfo.AdminUser.Id,
  26772. // IsReturn: 1,
  26773. // }
  26774. //
  26775. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26776. // //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")
  26777. // //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")
  26778. //
  26779. // //var dat map[string]interface{}
  26780. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26781. // // fmt.Println(dat)
  26782. // //} else {
  26783. // // fmt.Println(err)
  26784. // //}
  26785. //
  26786. // var dat2 map[string]interface{}
  26787. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26788. // fmt.Println(dat2)
  26789. // } else {
  26790. // fmt.Println(err)
  26791. // }
  26792. //
  26793. // } else {
  26794. // adminUser := c.GetAdminUserInfo()
  26795. // errlog := &models.HisOrderError{
  26796. // UserOrgId: adminUser.CurrentOrgId,
  26797. // Ctime: time.Now().Unix(),
  26798. // Mtime: time.Now().Unix(),
  26799. // ErrMsg: res.ErrMsg,
  26800. // Status: 1,
  26801. // PatientId: id,
  26802. // RecordTime: recordDateTime,
  26803. // Stage: 1,
  26804. // }
  26805. // service.CreateErrMsgLog(errlog)
  26806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26807. // return
  26808. // }
  26809. // }
  26810. //
  26811. //}
  26812. //func (c *HisApiController) GetUploadDiag() {
  26813. // id, _ := c.GetInt64("id")
  26814. // record_time := c.GetString("record_time")
  26815. //
  26816. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26817. // sick_type, _ := c.GetInt64("sick_type")
  26818. // reg_type, _ := c.GetInt64("reg_type")
  26819. //
  26820. // timeLayout := "2006-01-02"
  26821. // loc, _ := time.LoadLocation("Local")
  26822. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26823. // if err != nil {
  26824. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26825. // return
  26826. // }
  26827. //
  26828. // var patientPrescription models.HisPrescriptionInfo
  26829. // recordDateTime := theTime.Unix()
  26830. // adminInfo := c.GetAdminUserInfo()
  26831. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26832. //
  26833. // if patientPrescription.ID == 0 {
  26834. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26835. // }
  26836. //
  26837. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26838. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26839. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26840. // sickConfig, _ := service.FindSickById(sick_type)
  26841. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26842. //
  26843. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26844. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26845. // "&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 +
  26846. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26847. // resp2, requestErr2 := http.Get(api2)
  26848. // if requestErr2 != nil {
  26849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26850. // return
  26851. // }
  26852. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26853. // if ioErr2 != nil {
  26854. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26856. // return
  26857. // }
  26858. // var respJSON2 map[string]interface{}
  26859. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26860. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26861. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26862. // return
  26863. // }
  26864. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26865. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26866. //
  26867. // var res2 ResultSix
  26868. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26869. // utils.ErrorLog("解析失败:%v", err)
  26870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26871. // return
  26872. // }
  26873. // if res2.Infcode != 0 {
  26874. // adminUser := c.GetAdminUserInfo()
  26875. // errlog := &models.HisOrderError{
  26876. // UserOrgId: adminUser.CurrentOrgId,
  26877. // Ctime: time.Now().Unix(),
  26878. // Mtime: time.Now().Unix(),
  26879. // ErrMsg: res2.ErrMsg,
  26880. // Status: 1,
  26881. // PatientId: id,
  26882. // RecordTime: recordDateTime,
  26883. // Stage: 3,
  26884. // }
  26885. // service.CreateErrMsgLog(errlog)
  26886. //
  26887. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26888. // return
  26889. // }
  26890. //
  26891. // c.ServeSuccessJSON(map[string]interface{}{
  26892. // "msg": "上传成功",
  26893. // })
  26894. //
  26895. //}
  26896. type QueryResult struct {
  26897. ID int64
  26898. Name string
  26899. Code string
  26900. List_type_code string
  26901. }
  26902. func (c *HisApiController) GetCheckCode() {
  26903. ids_str := c.GetString("ids")
  26904. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26905. ids_arr := strings.Split(ids_str, ",")
  26906. var queryResult []QueryResult
  26907. ids := make([]int64, 0)
  26908. for _, item := range ids_arr {
  26909. id, _ := strconv.ParseInt(item, 10, 64)
  26910. ids = append(ids, id)
  26911. }
  26912. if record_type == 1 {
  26913. drugs, _ := service.GetBatchDrugList(ids)
  26914. for _, item := range drugs {
  26915. result := QueryResult{
  26916. ID: item.ID,
  26917. Name: item.DrugName,
  26918. Code: item.MedicalInsuranceNumber,
  26919. List_type_code: "101",
  26920. }
  26921. queryResult = append(queryResult, result)
  26922. }
  26923. } else if record_type == 2 {
  26924. goods, _ := service.GetBatchGoodInformationList(ids)
  26925. fmt.Println(goods)
  26926. for _, item := range goods {
  26927. result := QueryResult{
  26928. ID: item.ID,
  26929. Name: item.GoodName,
  26930. Code: item.SocialSecurityDirectoryCode,
  26931. List_type_code: "301",
  26932. }
  26933. queryResult = append(queryResult, result)
  26934. }
  26935. } else if record_type == 3 {
  26936. projects, _ := service.GetBathchMyPorjecgList(ids)
  26937. for _, item := range projects {
  26938. result := QueryResult{
  26939. ID: item.ID,
  26940. Name: item.ProjectName,
  26941. Code: item.MedicalCode,
  26942. List_type_code: "201",
  26943. }
  26944. queryResult = append(queryResult, result)
  26945. }
  26946. }
  26947. admin_user_id, _ := c.GetInt64("admin_user_id")
  26948. adminUser := c.GetAdminUserInfo()
  26949. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26950. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26951. var user_name string
  26952. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26953. if role.ID == 0 {
  26954. user_name = "管理员"
  26955. } else {
  26956. user_name = role.UserName
  26957. }
  26958. baseParams := models.BaseParams{
  26959. SecretKey: miConfig.SecretKey,
  26960. FixmedinsCode: miConfig.Code,
  26961. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26962. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26963. OrgName: miConfig.OrgName,
  26964. Doctor: user_name,
  26965. }
  26966. var result string
  26967. if miConfig.MdtrtareaAdmvs == "430800" {
  26968. for _, item := range queryResult {
  26969. if record_type == 1 {
  26970. 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)
  26971. } else if record_type == 2 {
  26972. fmt.Println(item.Code)
  26973. 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)
  26974. } else if record_type == 3 {
  26975. 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)
  26976. }
  26977. var dat map[string]interface{}
  26978. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26979. fmt.Println(dat)
  26980. } else {
  26981. fmt.Println(err)
  26982. }
  26983. userJSONBytes, _ := json.Marshal(dat)
  26984. var res ResultSix
  26985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26986. utils.ErrorLog("解析失败:%v", err)
  26987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26988. return
  26989. }
  26990. if res.Infcode == 0 {
  26991. if record_type == 1 {
  26992. service.UpdateBaseDrugById(item.ID)
  26993. } else if record_type == 2 {
  26994. service.UpdateGoodInformaitonByDetail(item.ID)
  26995. } else if record_type == 3 {
  26996. service.UpdateProjectById(item.ID)
  26997. }
  26998. c.ServeSuccessJSON(map[string]interface{}{
  26999. "failed_code": 0,
  27000. "msg": "目录对照成功",
  27001. })
  27002. } else {
  27003. c.ServeSuccessJSON(map[string]interface{}{
  27004. "failed_code": -10,
  27005. "msg": res.ErrMsg,
  27006. })
  27007. }
  27008. }
  27009. } else {
  27010. for _, item := range queryResult {
  27011. var result string
  27012. if record_type == 1 {
  27013. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27014. } else if record_type == 2 {
  27015. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27016. } else if record_type == 3 {
  27017. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27018. }
  27019. var dat map[string]interface{}
  27020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27021. fmt.Println(dat)
  27022. } else {
  27023. fmt.Println(err)
  27024. }
  27025. userJSONBytes, _ := json.Marshal(dat)
  27026. var res ResultSix
  27027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27028. utils.ErrorLog("解析失败:%v", err)
  27029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27030. return
  27031. }
  27032. if res.Infcode == 0 {
  27033. if record_type == 1 {
  27034. service.UpdateBaseDrugById(item.ID)
  27035. } else if record_type == 2 {
  27036. service.UpdateGoodInformaitonByDetail(item.ID)
  27037. } else if record_type == 3 {
  27038. service.UpdateProjectById(item.ID)
  27039. }
  27040. c.ServeSuccessJSON(map[string]interface{}{
  27041. "failed_code": 0,
  27042. "msg": "目录对照成功",
  27043. })
  27044. } else {
  27045. c.ServeSuccessJSON(map[string]interface{}{
  27046. "failed_code": -10,
  27047. "msg": res.ErrMsg,
  27048. })
  27049. }
  27050. }
  27051. }
  27052. }
  27053. func (c *HisApiController) UnCheckCode() {
  27054. ids_str := c.GetString("ids")
  27055. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27056. admin_user_id, _ := c.GetInt64("admin_user_id")
  27057. ids_arr := strings.Split(ids_str, ",")
  27058. var queryResult []QueryResult
  27059. ids := make([]int64, 0)
  27060. for _, item := range ids_arr {
  27061. id, _ := strconv.ParseInt(item, 10, 64)
  27062. ids = append(ids, id)
  27063. }
  27064. if record_type == 1 {
  27065. drugs, _ := service.GetBatchDrugList(ids)
  27066. for _, item := range drugs {
  27067. result := QueryResult{
  27068. ID: item.ID,
  27069. Name: item.DrugName,
  27070. Code: item.MedicalInsuranceNumber,
  27071. List_type_code: "101",
  27072. }
  27073. queryResult = append(queryResult, result)
  27074. }
  27075. } else if record_type == 2 {
  27076. goods, _ := service.GetBatchGoodInformationList(ids)
  27077. for _, item := range goods {
  27078. result := QueryResult{
  27079. ID: item.ID,
  27080. Name: item.GoodName,
  27081. Code: item.SocialSecurityDirectoryCode,
  27082. List_type_code: "301",
  27083. }
  27084. queryResult = append(queryResult, result)
  27085. }
  27086. } else if record_type == 3 {
  27087. projects, _ := service.GetBathchMyPorjecgList(ids)
  27088. for _, item := range projects {
  27089. result := QueryResult{
  27090. ID: item.ID,
  27091. Name: item.ProjectName,
  27092. Code: item.MedicalCode,
  27093. List_type_code: "201",
  27094. }
  27095. queryResult = append(queryResult, result)
  27096. }
  27097. }
  27098. adminUser := c.GetAdminUserInfo()
  27099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27100. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27101. var user_name string
  27102. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27103. if role.ID == 0 {
  27104. user_name = "xxx"
  27105. } else {
  27106. user_name = role.UserName
  27107. }
  27108. baseParams := &models.BaseParams{
  27109. SecretKey: miConfig.SecretKey,
  27110. FixmedinsCode: miConfig.Code,
  27111. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27112. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27113. OrgName: miConfig.OrgName,
  27114. Doctor: user_name,
  27115. }
  27116. if config.IsOpen == 1 {
  27117. if miConfig.MdtrtareaAdmvs == "430800" {
  27118. for _, item := range queryResult {
  27119. var result string
  27120. if record_type == 1 {
  27121. 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)
  27122. } else if record_type == 2 {
  27123. fmt.Println(item.Code)
  27124. 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)
  27125. } else if record_type == 3 {
  27126. 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)
  27127. }
  27128. var dat map[string]interface{}
  27129. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27130. fmt.Println(dat)
  27131. } else {
  27132. fmt.Println(err)
  27133. }
  27134. userJSONBytes, _ := json.Marshal(dat)
  27135. var res ResultSix
  27136. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27137. utils.ErrorLog("解析失败:%v", err)
  27138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27139. return
  27140. }
  27141. if res.Infcode == 0 {
  27142. if record_type == 1 {
  27143. service.UpdateBaseDrugById(item.ID)
  27144. } else if record_type == 2 {
  27145. service.UpdateGoodInformaitonByDetail(item.ID)
  27146. } else if record_type == 3 {
  27147. service.UpdateProjectById(item.ID)
  27148. }
  27149. c.ServeSuccessJSON(map[string]interface{}{
  27150. "failed_code": 0,
  27151. "msg": "目录对照成功",
  27152. })
  27153. } else {
  27154. c.ServeSuccessJSON(map[string]interface{}{
  27155. "failed_code": -10,
  27156. "msg": res.ErrMsg,
  27157. })
  27158. }
  27159. }
  27160. } else {
  27161. for _, item := range queryResult {
  27162. var result string
  27163. if record_type == 1 {
  27164. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27165. } else if record_type == 2 {
  27166. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27167. } else if record_type == 3 {
  27168. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27169. }
  27170. var dat2 map[string]interface{}
  27171. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27172. fmt.Println(dat2)
  27173. } else {
  27174. fmt.Println(err)
  27175. }
  27176. userJSONBytes, _ := json.Marshal(dat2)
  27177. var res ResultSix
  27178. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27179. utils.ErrorLog("解析失败:%v", err)
  27180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27181. return
  27182. }
  27183. if res.Infcode == 0 {
  27184. if record_type == 1 {
  27185. service.UpdateDrugByIdDetail(item.ID)
  27186. } else if record_type == 2 {
  27187. service.UpdateGoodInfoById(item.ID)
  27188. } else if record_type == 3 {
  27189. service.UpdateMyProjectById(item.ID)
  27190. }
  27191. c.ServeSuccessJSON(map[string]interface{}{
  27192. "failed_code": 0,
  27193. "msg": "撤销目录对照成功",
  27194. })
  27195. } else {
  27196. c.ServeSuccessJSON(map[string]interface{}{
  27197. "failed_code": -10,
  27198. "msg": res.ErrMsg,
  27199. })
  27200. }
  27201. }
  27202. }
  27203. }
  27204. }
  27205. func (c *HisApiController) GetPatientInfo() {
  27206. id_card_no := c.GetString("id_card_no")
  27207. admin_user_id, _ := c.GetInt64("admin_user_id")
  27208. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  27209. if patient.ID == 0 {
  27210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27211. return
  27212. }
  27213. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  27214. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  27215. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  27216. var res ResultTwo
  27217. var res10265 ResultTwo10265
  27218. if config.IsOpen == 1 {
  27219. if miConfig.MdtrtareaAdmvs == "150499" {
  27220. //请求内网数据
  27221. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  27222. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27223. "&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
  27224. resp, requestErr := http.Get(api)
  27225. if requestErr != nil {
  27226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27227. return
  27228. }
  27229. body, ioErr := ioutil.ReadAll(resp.Body)
  27230. if ioErr != nil {
  27231. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27233. return
  27234. }
  27235. var respJSON map[string]interface{}
  27236. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27239. return
  27240. }
  27241. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27242. result_byte, _ := json.Marshal(respJSON)
  27243. result := string(result_byte)
  27244. var dat map[string]interface{}
  27245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27246. fmt.Println(dat)
  27247. } else {
  27248. fmt.Println(err)
  27249. }
  27250. userJSONBytes, _ := json.Marshal(dat)
  27251. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27252. utils.ErrorLog("解析失败:%v", err)
  27253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27254. return
  27255. }
  27256. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27257. res.Infcode = Infcode
  27258. res.ErrMsg = res10265.ErrMsg
  27259. res.Output = res10265.Output
  27260. res.InfRefmsgid = res10265.InfRefmsgid
  27261. res.RespondTime = res10265.RespondTime
  27262. res.WarnInfo = res10265.WarnInfo
  27263. } else {
  27264. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27265. var dat map[string]interface{}
  27266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27267. fmt.Println(dat)
  27268. } else {
  27269. fmt.Println(err)
  27270. }
  27271. userJSONBytes, _ := json.Marshal(dat)
  27272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27273. utils.ErrorLog("解析失败:%v", err)
  27274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27275. return
  27276. }
  27277. }
  27278. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27279. // utils.ErrorLog("解析失败:%v", err)
  27280. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27281. // return
  27282. //}
  27283. for index, item := range res.Output.Iinfo {
  27284. if item.PsnInsuStas == "2" {
  27285. fmt.Println("--------")
  27286. res.Output.Iinfo[index].Insutype = "300"
  27287. res.Output.Iinfo[index].PsnInsuStas = "1"
  27288. }
  27289. }
  27290. fmt.Println(res.Output.Iinfo)
  27291. if res.Infcode != 0 {
  27292. c.ServeSuccessJSON(map[string]interface{}{
  27293. "failed_code": -10,
  27294. "msg": res.ErrMsg,
  27295. })
  27296. } else {
  27297. c.ServeSuccessJSON(map[string]interface{}{
  27298. "failed_code": 0,
  27299. "info": res,
  27300. })
  27301. }
  27302. }
  27303. }
  27304. func (c *HisApiController) PsnPutOnRecord() {
  27305. record_type, _ := c.GetInt64("type")
  27306. patient_id, _ := c.GetInt64("patient_id")
  27307. admin_user_id, _ := c.GetInt64("admin_user_id")
  27308. start_time := c.GetString("start_time")
  27309. end_time := c.GetString("end_time")
  27310. adminUser := c.GetAdminUserInfo()
  27311. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27312. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27313. var patients []*models.Patients
  27314. if record_type == 1 { //全部备案
  27315. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  27316. patients = append(patients, patient...)
  27317. } else { //单个备案
  27318. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27319. patients = append(patients, patient)
  27320. }
  27321. var user_name string
  27322. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27323. if role.ID == 0 {
  27324. user_name = "xxx"
  27325. } else {
  27326. user_name = role.UserName
  27327. }
  27328. if config.IsOpen == 1 {
  27329. for _, item := range patients {
  27330. 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
  27331. resp, requestErr := http.Get(api)
  27332. if requestErr != nil {
  27333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27334. return
  27335. }
  27336. defer resp.Body.Close()
  27337. body, ioErr := ioutil.ReadAll(resp.Body)
  27338. if ioErr != nil {
  27339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27341. return
  27342. }
  27343. var respJSON map[string]interface{}
  27344. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27345. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27347. return
  27348. }
  27349. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27350. userJSONBytes, _ := json.Marshal(userJSON)
  27351. var res ResultTwo
  27352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27353. utils.ErrorLog("解析失败:%v", err)
  27354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27355. return
  27356. }
  27357. if res.Infcode == 0 {
  27358. 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)
  27359. var dat map[string]interface{}
  27360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27361. fmt.Println(dat)
  27362. } else {
  27363. fmt.Println(err)
  27364. }
  27365. userJSONBytes, _ := json.Marshal(dat)
  27366. var res2 ResultThirteen
  27367. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27368. utils.ErrorLog("解析失败:%v", err)
  27369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27370. return
  27371. }
  27372. if res2.Infcode == 0 {
  27373. psnResult := &models.GdybPsnRecord{
  27374. UserOrgId: adminUser.CurrentOrgId,
  27375. PatientId: item.ID,
  27376. PsnNo: res.Output.Baseinfo.PsnNo,
  27377. Ctime: time.Now().Unix(),
  27378. Mtime: time.Now().Unix(),
  27379. Status: 1,
  27380. IsCancel: 1,
  27381. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27382. }
  27383. service.CreatePsnRecord(psnResult)
  27384. } else {
  27385. c.ServeSuccessJSON(map[string]interface{}{
  27386. "failed_code": -10,
  27387. "msg": res2.ErrMsg,
  27388. })
  27389. return
  27390. }
  27391. }
  27392. }
  27393. }
  27394. }
  27395. func (c *HisApiController) PsnUnPutOnRecord() {
  27396. id, _ := c.GetInt64("id")
  27397. //record_type, _ := c.GetInt64("type")
  27398. admin_user_id, _ := c.GetInt64("admin_user_id")
  27399. adminUser := c.GetAdminUserInfo()
  27400. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27401. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27402. var user_name string
  27403. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27404. if role.ID == 0 {
  27405. user_name = "xxx"
  27406. } else {
  27407. user_name = role.UserName
  27408. }
  27409. psn_record, _ := service.GetPsnRecordById(id)
  27410. if psn_record.ID == 0 {
  27411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27412. return
  27413. }
  27414. if config.IsOpen == 1 {
  27415. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27416. var dat map[string]interface{}
  27417. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27418. fmt.Println(dat)
  27419. } else {
  27420. fmt.Println(err)
  27421. }
  27422. userJSONBytes, _ := json.Marshal(dat)
  27423. var res ResultFourteen
  27424. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27425. utils.ErrorLog("解析失败:%v", err)
  27426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27427. return
  27428. }
  27429. if res.Infcode == 0 {
  27430. psn_record.IsCancel = 2
  27431. service.CreatePsnRecord(&psn_record)
  27432. } else {
  27433. c.ServeSuccessJSON(map[string]interface{}{
  27434. "failed_code": -10,
  27435. "msg": res.ErrMsg,
  27436. })
  27437. return
  27438. }
  27439. }
  27440. }
  27441. func (c *HisApiController) PsnPutNCDSOnRecord() {
  27442. patient_id, _ := c.GetInt64("patient_id")
  27443. insutype_two := c.GetString("insutype")
  27444. psn_no := c.GetString("psn_no")
  27445. doctor_id, _ := c.GetInt64("doctor_id")
  27446. sick_id, _ := c.GetInt64("sick_id")
  27447. department_id, _ := c.GetInt64("department_id")
  27448. start_time := c.GetString("start_time")
  27449. end_time := c.GetString("end_time")
  27450. check_time := c.GetString("check_time")
  27451. hospital_code := c.GetString("hospital_code")
  27452. hospital_name := c.GetString("hospital_name")
  27453. adminUser := c.GetAdminUserInfo()
  27454. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27455. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27456. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27457. sick, _ := service.FindSickById(sick_id)
  27458. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27459. if len(hospital_code) == 0 {
  27460. hospital_code = miConfig.Code
  27461. }
  27462. if len(hospital_name) == 0 {
  27463. hospital_name = miConfig.OrgName
  27464. }
  27465. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27466. var res ResultTwo
  27467. var res10265 ResultTwo10265
  27468. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27469. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  27470. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  27471. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27472. "&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
  27473. resp, requestErr := http.Get(api)
  27474. if requestErr != nil {
  27475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27476. return
  27477. }
  27478. body, ioErr := ioutil.ReadAll(resp.Body)
  27479. if ioErr != nil {
  27480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27482. return
  27483. }
  27484. var respJSON map[string]interface{}
  27485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27488. return
  27489. }
  27490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27491. result, _ := json.Marshal(respJSON)
  27492. fmt.Println("log")
  27493. fmt.Println(string(result))
  27494. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27495. utils.ErrorLog("解析失败:%v", err)
  27496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27497. return
  27498. }
  27499. res.ErrMsg = res10265.ErrMsg
  27500. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27501. res.Infcode = infocode
  27502. res.Output = res10265.Output
  27503. res.InfRefmsgid = res10265.InfRefmsgid
  27504. } else {
  27505. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27506. if miConfig.Code == "H15049901371" {
  27507. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27508. utils.ErrorLog("解析失败:%v", err)
  27509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27510. return
  27511. }
  27512. res.ErrMsg = res10265.ErrMsg
  27513. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27514. res.Infcode = infocode
  27515. res.Output = res10265.Output
  27516. res.InfRefmsgid = res10265.InfRefmsgid
  27517. } else {
  27518. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27519. utils.ErrorLog("解析失败:%v", err)
  27520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27521. return
  27522. }
  27523. }
  27524. }
  27525. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27526. infoStr := string(Iinfos)
  27527. var rf []*ResultFive
  27528. json.Unmarshal([]byte(infoStr), &rf)
  27529. var insuplc_admdvs string
  27530. var insutype string
  27531. var is390 int = 0
  27532. var is310 int = 0
  27533. var insutypes []*ResultFive
  27534. for _, item := range rf {
  27535. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27536. insutypes = append(insutypes, item)
  27537. }
  27538. }
  27539. if len(insutypes) == 1 {
  27540. insutype = insutypes[0].Insutype
  27541. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27542. } else {
  27543. for _, i := range insutypes {
  27544. if i.Insutype == "390" {
  27545. is390 = 1
  27546. }
  27547. if i.Insutype == "310" {
  27548. is310 = 1
  27549. }
  27550. }
  27551. }
  27552. if is390 == 1 {
  27553. insutype = "390"
  27554. }
  27555. if is310 == 1 {
  27556. insutype = "310"
  27557. }
  27558. if len(insutypes) == 2 {
  27559. insutype = insutype_two
  27560. }
  27561. if len(insutypes) == 0 {
  27562. insutype = "310"
  27563. }
  27564. insutype = insutype_two
  27565. fmt.Println(insutype)
  27566. for _, item := range rf {
  27567. fmt.Println(item.Insutype)
  27568. fmt.Println(insutype)
  27569. if item.Insutype == insutype {
  27570. fmt.Println(item.Insutype)
  27571. fmt.Println(insutype)
  27572. insuplc_admdvs = item.InsuplcAdmdvs
  27573. }
  27574. }
  27575. fmt.Println(insuplc_admdvs)
  27576. var res2 ResultThirteen
  27577. var res10265_2 ResultThirteen10265
  27578. if config.IsOpen == 1 {
  27579. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27580. } else {
  27581. if miConfig.MdtrtareaAdmvs == "150499" {
  27582. //
  27583. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  27584. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27585. // "&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
  27586. //resp, requestErr := http.Get(api)
  27587. //if requestErr != nil {
  27588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27589. // return
  27590. //}
  27591. //
  27592. //body, ioErr := ioutil.ReadAll(resp.Body)
  27593. //if ioErr != nil {
  27594. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27595. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27596. // return
  27597. //}
  27598. //var respJSON map[string]interface{}
  27599. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27600. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27602. // return
  27603. //}
  27604. //
  27605. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27606. //result, _ := json.Marshal(respJSON)
  27607. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  27608. // utils.ErrorLog("解析失败:%v", err)
  27609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27610. // return
  27611. //}
  27612. //infocode = resThree.Infcode
  27613. //result, _ := json.Marshal(respJSON)
  27614. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  27615. // utils.ErrorLog("解析失败:%v", err)
  27616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27617. // return
  27618. //}
  27619. //
  27620. //resThree.ErrMsg = resThree10265.ErrMsg
  27621. //
  27622. //resThree.Output = resThree10265.Output
  27623. //
  27624. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  27625. //
  27626. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  27627. //
  27628. } else {
  27629. 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)
  27630. var dat map[string]interface{}
  27631. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27632. fmt.Println(dat)
  27633. } else {
  27634. fmt.Println(err)
  27635. }
  27636. userJSONBytes, _ := json.Marshal(dat)
  27637. if miConfig.Code == "H15049901371" {
  27638. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27639. utils.ErrorLog("解析失败:%v", err)
  27640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27641. return
  27642. }
  27643. res2.ErrMsg = res10265_2.ErrMsg
  27644. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27645. res2.Infcode = infocode
  27646. res2.Output = res10265_2.Output
  27647. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27648. } else {
  27649. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27650. utils.ErrorLog("解析失败:%v", err)
  27651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27652. return
  27653. }
  27654. }
  27655. }
  27656. }
  27657. if res2.Infcode == 0 {
  27658. psnResult := &models.GdybPsnNcdsRecord{
  27659. UserOrgId: adminUser.CurrentOrgId,
  27660. PatientId: patient.ID,
  27661. PsnNo: psn_no,
  27662. DoctorId: doctor.AdminUserId,
  27663. DepartmentId: department_id,
  27664. SickType: sick_id,
  27665. Insutype: insutype,
  27666. Ctime: time.Now().Unix(),
  27667. Mtime: time.Now().Unix(),
  27668. Status: 1,
  27669. IsCancel: 1,
  27670. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27671. }
  27672. service.CreatePsnNCDSRecord(psnResult)
  27673. c.ServeSuccessJSON(map[string]interface{}{
  27674. "failed_code": 0,
  27675. "msg": "备案成功",
  27676. "result": psnResult,
  27677. })
  27678. } else {
  27679. c.ServeSuccessJSON(map[string]interface{}{
  27680. "failed_code": -10,
  27681. "msg": res2.ErrMsg,
  27682. })
  27683. return
  27684. }
  27685. }
  27686. }
  27687. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27688. id, _ := c.GetInt64("id")
  27689. admin_user_id, _ := c.GetInt64("admin_user_id")
  27690. adminUser := c.GetAdminUserInfo()
  27691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27692. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27693. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27694. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27695. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27696. //var user_name string
  27697. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27698. //if role.ID == 0 {
  27699. // user_name = "xxx"
  27700. //} else {
  27701. // user_name = role.UserName
  27702. //}
  27703. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27704. if psn_record.ID == 0 {
  27705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27706. return
  27707. }
  27708. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27709. var res ResultTwo
  27710. var res10265 ResultTwo10265
  27711. if miConfig.Code == "H15049901371" {
  27712. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27713. utils.ErrorLog("解析失败:%v", err)
  27714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27715. return
  27716. }
  27717. res.ErrMsg = res10265.ErrMsg
  27718. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27719. res.Infcode = infocode
  27720. res.Output = res10265.Output
  27721. res.InfRefmsgid = res10265.InfRefmsgid
  27722. } else {
  27723. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27724. utils.ErrorLog("解析失败:%v", err)
  27725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27726. return
  27727. }
  27728. }
  27729. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27730. infoStr := string(Iinfos)
  27731. var rf []*ResultFive
  27732. json.Unmarshal([]byte(infoStr), &rf)
  27733. var insuplc_admdvs string
  27734. var insutype string
  27735. var is390 int = 0
  27736. var is310 int = 0
  27737. var insutypes []*ResultFive
  27738. for _, item := range rf {
  27739. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27740. insutypes = append(insutypes, item)
  27741. }
  27742. }
  27743. if len(insutypes) == 1 {
  27744. insutype = insutypes[0].Insutype
  27745. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27746. } else {
  27747. for _, i := range insutypes {
  27748. if i.Insutype == "390" {
  27749. is390 = 1
  27750. }
  27751. if i.Insutype == "310" {
  27752. is310 = 1
  27753. }
  27754. }
  27755. }
  27756. if is390 == 1 {
  27757. insutype = "390"
  27758. }
  27759. if is310 == 1 {
  27760. insutype = "310"
  27761. }
  27762. if len(insutypes) == 0 {
  27763. insutype = "310"
  27764. }
  27765. insutype = psn_record.Insutype
  27766. for _, item := range rf {
  27767. if item.Insutype == insutype {
  27768. insuplc_admdvs = item.InsuplcAdmdvs
  27769. }
  27770. }
  27771. if config.IsOpen == 1 {
  27772. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27773. var dat map[string]interface{}
  27774. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27775. fmt.Println(dat)
  27776. } else {
  27777. fmt.Println(err)
  27778. }
  27779. userJSONBytes, _ := json.Marshal(dat)
  27780. var res ResultFourteen
  27781. var res10265 ResultFourteen10265
  27782. if miConfig.Code == "H15049901371" {
  27783. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27784. utils.ErrorLog("解析失败:%v", err)
  27785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27786. return
  27787. }
  27788. res.ErrMsg = res10265.ErrMsg
  27789. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27790. res.Infcode = infocode
  27791. res.Output = res10265.Output
  27792. res.InfRefmsgid = res10265.InfRefmsgid
  27793. } else {
  27794. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27795. utils.ErrorLog("解析失败:%v", err)
  27796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27797. return
  27798. }
  27799. }
  27800. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27801. // utils.ErrorLog("解析失败:%v", err)
  27802. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27803. // return
  27804. //}
  27805. if res.Infcode == 0 {
  27806. psn_record.IsCancel = 2
  27807. service.CreatePsnNCDSRecord(&psn_record)
  27808. c.ServeSuccessJSON(map[string]interface{}{
  27809. "failed_code": 0,
  27810. "msg": "撤销备案成功",
  27811. })
  27812. } else {
  27813. c.ServeSuccessJSON(map[string]interface{}{
  27814. "failed_code": -10,
  27815. "msg": res.ErrMsg,
  27816. })
  27817. return
  27818. }
  27819. }
  27820. }
  27821. func (c *HisApiController) TestTest() {
  27822. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27823. fmt.Println(patient.Iinfo)
  27824. }
  27825. type CustomData struct {
  27826. MsgId string
  27827. PsnNo string
  27828. Info string
  27829. }
  27830. func (c *HisApiController) ReversalData() {
  27831. var customData []*CustomData
  27832. custom := &CustomData{
  27833. MsgId: "H44022900158202103301714472004",
  27834. PsnNo: "44020000001101329945",
  27835. Info: "2207",
  27836. }
  27837. customData = append(customData, custom)
  27838. custom1 := &CustomData{
  27839. MsgId: "H4402290015820210330172057803",
  27840. PsnNo: "44020000001101161813",
  27841. Info: "2207",
  27842. }
  27843. customData = append(customData, custom1)
  27844. custom2 := &CustomData{
  27845. MsgId: "H44022900158202103301705198813",
  27846. PsnNo: "44190000133097375417",
  27847. Info: "2207",
  27848. }
  27849. customData = append(customData, custom2)
  27850. custom3 := &CustomData{
  27851. MsgId: "H44022900158202103301715524756",
  27852. PsnNo: "44020000001100187221",
  27853. Info: "2207",
  27854. }
  27855. customData = append(customData, custom3)
  27856. custom4 := &CustomData{
  27857. MsgId: "H44022900158202103301730376224",
  27858. PsnNo: "44020000001101959155",
  27859. Info: "2207",
  27860. }
  27861. customData = append(customData, custom4)
  27862. custom5 := &CustomData{
  27863. MsgId: "H44022900158202103301748008725",
  27864. PsnNo: "44020000001104246641",
  27865. Info: "2207",
  27866. }
  27867. customData = append(customData, custom5)
  27868. custom6 := &CustomData{
  27869. MsgId: "H44022900158202103301718096755",
  27870. PsnNo: "44020000001102211860",
  27871. Info: "2207",
  27872. }
  27873. customData = append(customData, custom6)
  27874. custom7 := &CustomData{
  27875. MsgId: "H44022900158202103301736551640",
  27876. PsnNo: "44020000001102687718",
  27877. Info: "2207",
  27878. }
  27879. customData = append(customData, custom7)
  27880. custom8 := &CustomData{
  27881. MsgId: "H44022900158202103301743097676",
  27882. PsnNo: "44020000001102127785",
  27883. Info: "2207",
  27884. }
  27885. customData = append(customData, custom8)
  27886. custom9 := &CustomData{
  27887. MsgId: "H44022900158202103301712304203",
  27888. PsnNo: "44020000001101518097",
  27889. Info: "2207",
  27890. }
  27891. customData = append(customData, custom9)
  27892. custom10 := &CustomData{
  27893. MsgId: "H44022900158202103301738448785",
  27894. PsnNo: "44020000001100500813",
  27895. Info: "2207",
  27896. }
  27897. customData = append(customData, custom10)
  27898. custom11 := &CustomData{
  27899. MsgId: "H44022900158202103301732455843",
  27900. PsnNo: "44020000001102690557",
  27901. Info: "2207",
  27902. }
  27903. customData = append(customData, custom11)
  27904. custom12 := &CustomData{
  27905. MsgId: "H44022900158202103301745421708",
  27906. PsnNo: "44020000001102211928",
  27907. Info: "2207",
  27908. }
  27909. customData = append(customData, custom12)
  27910. custom1212 := &CustomData{
  27911. MsgId: "H440229001582021033017351627",
  27912. PsnNo: "44020000001102481733",
  27913. Info: "2207",
  27914. }
  27915. customData = append(customData, custom1212)
  27916. custom13 := &CustomData{
  27917. MsgId: "H44022900158202103301740327951",
  27918. PsnNo: "44020000001103174866",
  27919. Info: "2207",
  27920. }
  27921. customData = append(customData, custom13)
  27922. custom14 := &CustomData{
  27923. MsgId: "H4402290015820210330174922668",
  27924. PsnNo: "44020000001102927272",
  27925. Info: "2207",
  27926. }
  27927. customData = append(customData, custom14)
  27928. custom15 := &CustomData{
  27929. MsgId: "H44022900158202103301752362273",
  27930. PsnNo: "44020000001102942890",
  27931. Info: "2207",
  27932. }
  27933. customData = append(customData, custom15)
  27934. custom16 := &CustomData{
  27935. MsgId: "H44022900158202103301751082917",
  27936. PsnNo: "44020000001101662162",
  27937. Info: "2207",
  27938. }
  27939. customData = append(customData, custom16)
  27940. custom17 := &CustomData{
  27941. MsgId: "H44022900158202103301754147728",
  27942. PsnNo: "44020000000229014511",
  27943. Info: "2207",
  27944. }
  27945. customData = append(customData, custom17)
  27946. adminUser := c.GetAdminUserInfo()
  27947. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27948. for _, item := range customData {
  27949. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27950. fmt.Println(result)
  27951. }
  27952. }
  27953. func (c *HisApiController) GetAllopatry() {
  27954. year := c.GetString("year")
  27955. month := c.GetString("month")
  27956. admin_user_id, _ := c.GetInt64("admin_user_id")
  27957. adminUser := c.GetAdminUserInfo()
  27958. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27959. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27960. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27961. var dat map[string]interface{}
  27962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27963. fmt.Println(dat)
  27964. } else {
  27965. fmt.Println(err)
  27966. }
  27967. userJSONBytes, _ := json.Marshal(dat)
  27968. var res models.Result9001
  27969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27970. utils.ErrorLog("解析失败:%v", err)
  27971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27972. return
  27973. }
  27974. fmt.Println(res.Output.Signinoutb)
  27975. fmt.Println(res.Output.Signinoutb.SignNo)
  27976. fmt.Println(string(userJSONBytes))
  27977. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27978. var dat3 map[string]interface{}
  27979. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27980. fmt.Println(dat3)
  27981. } else {
  27982. fmt.Println(err)
  27983. }
  27984. userJSONBytes3, _ := json.Marshal(dat3)
  27985. var res3 models.Result3260
  27986. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27987. utils.ErrorLog("解析失败:%v", err)
  27988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27989. return
  27990. }
  27991. var curpage int
  27992. var pagesize int = 100
  27993. var start int = 1
  27994. //var stop int
  27995. //pagecount := 10
  27996. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27997. var res22 []models.Result3260
  27998. for curpage = 1; curpage <= pagecount; curpage++ {
  27999. if curpage == 1 {
  28000. start = 0
  28001. } else {
  28002. start = (curpage-1)*pagesize + 1
  28003. }
  28004. fmt.Println(start)
  28005. //stop = curpage * pagesize
  28006. //if stop > int(res3.Output.Totalrow) {
  28007. // stop =int(res3.Output.Totalrow)
  28008. //}
  28009. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28010. var dat2 map[string]interface{}
  28011. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28012. fmt.Println(dat)
  28013. } else {
  28014. fmt.Println(err)
  28015. }
  28016. userJSONBytes2, _ := json.Marshal(dat2)
  28017. var res2 models.Result3260
  28018. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28019. utils.ErrorLog("解析失败:%v", err)
  28020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28021. return
  28022. }
  28023. if res2.Infcode == 0 {
  28024. res22 = append(res22, res2)
  28025. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28026. //var dat2 map[string]interface{}
  28027. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28028. // fmt.Println(dat)
  28029. //} else {
  28030. // fmt.Println(err)
  28031. //}
  28032. //c.ServeSuccessJSON(map[string]interface{}{
  28033. // "list": res2.Output.Data,
  28034. //})
  28035. //continue
  28036. }
  28037. }
  28038. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28039. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28040. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28041. //var dat2 map[string]interface{}
  28042. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28043. // fmt.Println(dat)
  28044. //} else {
  28045. // fmt.Println(err)
  28046. //}
  28047. //userJSONBytes2, _ := json.Marshal(dat2)
  28048. //var res2 models.Result3260
  28049. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28050. // utils.ErrorLog("解析失败:%v", err)
  28051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28052. // return
  28053. //}
  28054. //if res2.Infcode == 0 {
  28055. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28056. // var dat2 map[string]interface{}
  28057. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28058. // fmt.Println(dat)
  28059. // } else {
  28060. // fmt.Println(err)
  28061. // }
  28062. // c.ServeSuccessJSON(map[string]interface{}{
  28063. // "list": res2.Output.Data,
  28064. // })
  28065. //}
  28066. }
  28067. func (c *HisApiController) ComfirmAllopatry() {
  28068. year := c.GetString("year")
  28069. month := c.GetString("month")
  28070. admin_user_id, _ := c.GetInt64("admin_user_id")
  28071. adminUser := c.GetAdminUserInfo()
  28072. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28073. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28074. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28075. var dat map[string]interface{}
  28076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28077. fmt.Println(dat)
  28078. } else {
  28079. fmt.Println(err)
  28080. }
  28081. userJSONBytes, _ := json.Marshal(dat)
  28082. var res models.Result9001
  28083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28084. utils.ErrorLog("解析失败:%v", err)
  28085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28086. return
  28087. }
  28088. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28089. var dat2 map[string]interface{}
  28090. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28091. fmt.Println(dat)
  28092. } else {
  28093. fmt.Println(err)
  28094. }
  28095. userJSONBytes2, _ := json.Marshal(dat2)
  28096. var res2 models.Result3260
  28097. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28098. utils.ErrorLog("解析失败:%v", err)
  28099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28100. return
  28101. }
  28102. //if res2.Infcode == 0 {
  28103. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28104. // var dat map[string]interface{}
  28105. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28106. // fmt.Println(dat)
  28107. // } else {
  28108. // fmt.Println(err)
  28109. // }
  28110. // userJSONBytes, _ := json.Marshal(dat)
  28111. // var res3 models.Result3261
  28112. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  28113. // utils.ErrorLog("解析失败:%v", err)
  28114. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28115. // return
  28116. // }
  28117. //
  28118. // if res3.Infcode == 0 {
  28119. // record := &models.HisYidiClearRecord{
  28120. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28121. // Ctime: time.Now().Unix(),
  28122. // Mtime: time.Now().Unix(),
  28123. // Status: 1,
  28124. // MsgId: msgId,
  28125. // }
  28126. // service.SaveClearRecord(record)
  28127. // c.ServeSuccessJSON(map[string]interface{}{
  28128. // "msg": "提取成功",
  28129. // })
  28130. // }
  28131. //}
  28132. }
  28133. func (c *HisApiController) RefundAllopatry() {
  28134. year := c.GetString("year")
  28135. month := c.GetString("month")
  28136. //id, _ := c.GetInt64("id")
  28137. admin_user_id, _ := c.GetInt64("admin_user_id")
  28138. adminUser := c.GetAdminUserInfo()
  28139. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28140. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28141. //record, _ := service.GetClearRecordById(id)
  28142. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28143. var dat map[string]interface{}
  28144. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28145. fmt.Println(dat)
  28146. } else {
  28147. fmt.Println(err)
  28148. }
  28149. userJSONBytes, _ := json.Marshal(dat)
  28150. var res models.Result9001
  28151. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28152. utils.ErrorLog("解析失败:%v", err)
  28153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28154. return
  28155. }
  28156. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  28157. var dat2 map[string]interface{}
  28158. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28159. fmt.Println(dat)
  28160. } else {
  28161. fmt.Println(err)
  28162. }
  28163. userJSONBytes2, _ := json.Marshal(dat2)
  28164. var empty ResultFourteen
  28165. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  28166. utils.ErrorLog("解析失败:%v", err)
  28167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28168. return
  28169. }
  28170. if empty.Infcode == 0 {
  28171. c.ServeSuccessJSON(map[string]interface{}{
  28172. "msg": "撤销成功",
  28173. })
  28174. return
  28175. }
  28176. }
  28177. func (c *HisApiController) ReversalOtherData() {
  28178. var customData []*CustomData
  28179. custom := &CustomData{
  28180. MsgId: "H44022900158202103301714472004",
  28181. PsnNo: "44020000001101329945",
  28182. Info: "2208",
  28183. }
  28184. customData = append(customData, custom)
  28185. custom1 := &CustomData{
  28186. MsgId: "H4402290015820210330172057803",
  28187. PsnNo: "44020000001101161813",
  28188. Info: "2208",
  28189. }
  28190. customData = append(customData, custom1)
  28191. custom2 := &CustomData{
  28192. MsgId: "H44022900158202103301705198813",
  28193. PsnNo: "44190000133097375417",
  28194. Info: "2208",
  28195. }
  28196. customData = append(customData, custom2)
  28197. custom3 := &CustomData{
  28198. MsgId: "H44022900158202103301715524756",
  28199. PsnNo: "44020000001100187221",
  28200. Info: "2208",
  28201. }
  28202. customData = append(customData, custom3)
  28203. custom4 := &CustomData{
  28204. MsgId: "H44022900158202103301730376224",
  28205. PsnNo: "44020000001101959155",
  28206. Info: "2208",
  28207. }
  28208. customData = append(customData, custom4)
  28209. custom5 := &CustomData{
  28210. MsgId: "H44022900158202103301748008725",
  28211. PsnNo: "44020000001104246641",
  28212. Info: "2208",
  28213. }
  28214. customData = append(customData, custom5)
  28215. custom6 := &CustomData{
  28216. MsgId: "H44022900158202103301718096755",
  28217. PsnNo: "44020000001102211860",
  28218. Info: "2208",
  28219. }
  28220. customData = append(customData, custom6)
  28221. custom7 := &CustomData{
  28222. MsgId: "H44022900158202103301736551640",
  28223. PsnNo: "44020000001102687718",
  28224. Info: "2208",
  28225. }
  28226. customData = append(customData, custom7)
  28227. custom8 := &CustomData{
  28228. MsgId: "H44022900158202103301743097676",
  28229. PsnNo: "44020000001102127785",
  28230. Info: "2208",
  28231. }
  28232. customData = append(customData, custom8)
  28233. custom9 := &CustomData{
  28234. MsgId: "H44022900158202103301712304203",
  28235. PsnNo: "44020000001101518097",
  28236. Info: "2208",
  28237. }
  28238. customData = append(customData, custom9)
  28239. custom10 := &CustomData{
  28240. MsgId: "H44022900158202103301738448785",
  28241. PsnNo: "44020000001100500813",
  28242. Info: "2208",
  28243. }
  28244. customData = append(customData, custom10)
  28245. custom11 := &CustomData{
  28246. MsgId: "H44022900158202103301732455843",
  28247. PsnNo: "44020000001102690557",
  28248. Info: "2208",
  28249. }
  28250. customData = append(customData, custom11)
  28251. custom12 := &CustomData{
  28252. MsgId: "H44022900158202103301745421708",
  28253. PsnNo: "44020000001102211928",
  28254. Info: "2208",
  28255. }
  28256. customData = append(customData, custom12)
  28257. custom1212 := &CustomData{
  28258. MsgId: "H440229001582021033017351627",
  28259. PsnNo: "44020000001102481733",
  28260. Info: "2208",
  28261. }
  28262. customData = append(customData, custom1212)
  28263. custom13 := &CustomData{
  28264. MsgId: "H44022900158202103301740327951",
  28265. PsnNo: "44020000001103174866",
  28266. Info: "2208",
  28267. }
  28268. customData = append(customData, custom13)
  28269. custom14 := &CustomData{
  28270. MsgId: "H4402290015820210330174922668",
  28271. PsnNo: "44020000001102927272",
  28272. Info: "2208",
  28273. }
  28274. customData = append(customData, custom14)
  28275. custom15 := &CustomData{
  28276. MsgId: "H44022900158202103301752362273",
  28277. PsnNo: "44020000001102942890",
  28278. Info: "2208",
  28279. }
  28280. customData = append(customData, custom15)
  28281. custom16 := &CustomData{
  28282. MsgId: "H44022900158202103301751082917",
  28283. PsnNo: "44020000001101662162",
  28284. Info: "2208",
  28285. }
  28286. customData = append(customData, custom16)
  28287. custom17 := &CustomData{
  28288. MsgId: "H44022900158202103301754147728",
  28289. PsnNo: "44020000000229014511",
  28290. Info: "2208",
  28291. }
  28292. customData = append(customData, custom17)
  28293. adminUser := c.GetAdminUserInfo()
  28294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28295. for _, item := range customData {
  28296. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28297. fmt.Println(result)
  28298. }
  28299. }
  28300. func PathExists(path string) (bool, error) {
  28301. _, err := os.Stat(path)
  28302. if err == nil {
  28303. return true, nil
  28304. }
  28305. if os.IsNotExist(err) {
  28306. return false, nil
  28307. }
  28308. return false, err
  28309. }
  28310. // 创建文件夹
  28311. func Mkdir(dir string) {
  28312. // 创建文件夹
  28313. exist, err := PathExists(dir)
  28314. if err != nil {
  28315. fmt.Println(err.Error())
  28316. } else {
  28317. if exist {
  28318. fmt.Println(dir + "文件夹已存在!")
  28319. } else {
  28320. // 文件夹名称,权限
  28321. err := os.Mkdir(dir, os.ModePerm)
  28322. if err != nil {
  28323. fmt.Println(dir+"文件夹创建失败:", err.Error())
  28324. } else {
  28325. fmt.Println(dir + "文件夹创建成功!")
  28326. }
  28327. }
  28328. }
  28329. }
  28330. // 压缩文件
  28331. func Zip(srcFile string, destZip string) error {
  28332. zipfile, err := os.Create(destZip)
  28333. if err != nil {
  28334. return err
  28335. }
  28336. defer zipfile.Close()
  28337. archive := zip.NewWriter(zipfile)
  28338. defer archive.Close()
  28339. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  28340. if err != nil {
  28341. return err
  28342. }
  28343. header, err := zip.FileInfoHeader(info)
  28344. if err != nil {
  28345. return err
  28346. }
  28347. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  28348. // header.Name = path
  28349. if info.IsDir() {
  28350. header.Name += "/"
  28351. } else {
  28352. header.Method = zip.Deflate
  28353. }
  28354. writer, err := archive.CreateHeader(header)
  28355. if err != nil {
  28356. return err
  28357. }
  28358. if !info.IsDir() {
  28359. file, err := os.Open(path)
  28360. if err != nil {
  28361. return err
  28362. }
  28363. defer file.Close()
  28364. _, err = io.Copy(writer, file)
  28365. }
  28366. return err
  28367. })
  28368. return err
  28369. }
  28370. func ReadFile(filePath string) []byte {
  28371. f, err := os.Open(filePath)
  28372. if err != nil {
  28373. fmt.Println("read file fail", err)
  28374. return nil
  28375. }
  28376. defer f.Close()
  28377. fd, err := ioutil.ReadAll(f)
  28378. if err != nil {
  28379. fmt.Println("read to fd fail", err)
  28380. return nil
  28381. }
  28382. return fd
  28383. }
  28384. func saveLogq(result string, request string, infno string, desc string) {
  28385. dir := "日志"
  28386. utils.Mkdir(dir)
  28387. month := time.Unix(1557042972, 0).Format("1")
  28388. year := time.Now().Format("2006")
  28389. month = time.Now().Format("01")
  28390. day := time.Now().Format("02")
  28391. hour := time.Now().Format("15")
  28392. min := time.Now().Format("04")
  28393. sec := time.Now().Format("05")
  28394. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28395. file := year + month + day + "_log"
  28396. file_name := file + ".txt"
  28397. file_path := "日志" + "/" + file_name
  28398. exist, _ := utils.PathExists(file_path)
  28399. if exist { //存在
  28400. fmt.Println("存在")
  28401. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28402. if err != nil {
  28403. fmt.Println("read fail")
  28404. }
  28405. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28406. n, _ := f.Seek(0, 2)
  28407. _, err = f.WriteAt([]byte(content), n)
  28408. } else { //不存在
  28409. fmt.Println("文件不存在,创建文件")
  28410. f, err := os.Create("日志" + "/" + file_name)
  28411. defer f.Close()
  28412. if err != nil {
  28413. } else {
  28414. _, err = f.Write([]byte("记录日志"))
  28415. }
  28416. }
  28417. }
  28418. func saveLog(result string, request string, infno string, desc string) {
  28419. org_id, _ := beego.AppConfig.Int64("org_id")
  28420. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28421. dir := miConfig.OrgName + "日志"
  28422. utils.Mkdir(dir)
  28423. month := time.Unix(1557042972, 0).Format("1")
  28424. year := time.Now().Format("2006")
  28425. month = time.Now().Format("01")
  28426. day := time.Now().Format("02")
  28427. hour := time.Now().Format("15")
  28428. min := time.Now().Format("04")
  28429. sec := time.Now().Format("05")
  28430. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28431. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  28432. file_name := file + ".txt"
  28433. file_path := miConfig.OrgName + "日志" + "/" + file_name
  28434. exist, _ := utils.PathExists(file_path)
  28435. if exist { //存在
  28436. fmt.Println("存在")
  28437. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28438. if err != nil {
  28439. fmt.Println("read fail")
  28440. }
  28441. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28442. n, _ := f.Seek(0, 2)
  28443. _, err = f.WriteAt([]byte(content), n)
  28444. } else { //不存在
  28445. fmt.Println("文件不存在,创建文件")
  28446. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  28447. defer f.Close()
  28448. if err != nil {
  28449. } else {
  28450. _, err = f.Write([]byte("记录日志"))
  28451. }
  28452. }
  28453. }
  28454. type Charset string
  28455. const (
  28456. UTF8 = Charset("UTF-8")
  28457. GB18030 = Charset("GB18030")
  28458. )
  28459. func ConvertToString(src string, srcCode string, tagCode string) string {
  28460. srcCoder := mahonia.NewDecoder(srcCode)
  28461. srcResult := srcCoder.ConvertString(src)
  28462. tagCoder := mahonia.NewDecoder(tagCode)
  28463. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  28464. result := string(cdata)
  28465. return result
  28466. }
  28467. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  28468. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28469. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28470. var token string
  28471. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28472. var api string
  28473. if miConfig.MdtrtareaAdmvs == "320921" {
  28474. 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 +
  28475. "&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
  28476. fmt.Println(api)
  28477. } else {
  28478. 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 +
  28479. "&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
  28480. }
  28481. resp, requestErr := http.Get(api)
  28482. if requestErr != nil {
  28483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28484. return ""
  28485. }
  28486. body, ioErr := ioutil.ReadAll(resp.Body)
  28487. if ioErr != nil {
  28488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28490. return ""
  28491. }
  28492. var respJSON map[string]interface{}
  28493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28496. return ""
  28497. }
  28498. var status string
  28499. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28500. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28501. var res ResultTwo //1101结果
  28502. var res10265 ResultTwo10265 //1101结果
  28503. if status == "0" { //读卡成功
  28504. var card_info string //卡信息
  28505. var busi_card_info string
  28506. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28507. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28508. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28509. fmt.Println(card_info)
  28510. fmt.Println(busi_card_info)
  28511. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28512. result, _ := json.Marshal(respJSON)
  28513. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28514. utils.ErrorLog("解析失败:%v", err)
  28515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28516. return ""
  28517. }
  28518. res.ErrMsg = res10265.ErrMsg
  28519. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28520. res.Infcode = infocode
  28521. res.Output = res10265.Output
  28522. res.InfRefmsgid = res10265.InfRefmsgid
  28523. if res.Infcode == 0 {
  28524. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28525. if err == gorm.ErrRecordNotFound {
  28526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28527. return ""
  28528. } else if err != nil {
  28529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28530. return ""
  28531. } else {
  28532. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28533. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28534. infoStr := string(Iinfos)
  28535. idetinfoStr := string(Idetinfos)
  28536. psn := &models.HisPsn{
  28537. PsnNo: res.Output.Baseinfo.PsnNo,
  28538. PatientId: patient.ID,
  28539. Certno: res.Output.Baseinfo.Certno,
  28540. Gend: res.Output.Baseinfo.Gend,
  28541. Naty: res.Output.Baseinfo.Naty,
  28542. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28543. PsnName: res.Output.Baseinfo.PsnName,
  28544. Idetinfo: idetinfoStr,
  28545. Insuinfo: infoStr,
  28546. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28547. CardInfo: card_info,
  28548. VerifyNumber: token,
  28549. }
  28550. service.CreateHisPsn(psn)
  28551. return token
  28552. }
  28553. }
  28554. } else {
  28555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28556. return ""
  28557. }
  28558. } else { //读卡失败
  28559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28560. return ""
  28561. }
  28562. return token
  28563. }
  28564. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  28565. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28566. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28567. var token string
  28568. var api string
  28569. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28570. "&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
  28571. fmt.Println(api)
  28572. resp, requestErr := http.Get(api)
  28573. if requestErr != nil {
  28574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28575. return ""
  28576. }
  28577. body, ioErr := ioutil.ReadAll(resp.Body)
  28578. if ioErr != nil {
  28579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28581. return ""
  28582. }
  28583. var respJSON map[string]interface{}
  28584. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28587. return ""
  28588. }
  28589. var status string
  28590. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28591. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28592. var res ResultTwo //1101结果
  28593. if status == "1" { //读卡成功
  28594. var card_info string //卡信息
  28595. var busi_card_info string
  28596. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28597. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28598. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28599. fmt.Println(card_info)
  28600. fmt.Println(busi_card_info)
  28601. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28602. result, _ := json.Marshal(respJSON)
  28603. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28604. utils.ErrorLog("解析失败:%v", err)
  28605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28606. return ""
  28607. }
  28608. if res.Infcode == 0 {
  28609. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28610. if err == gorm.ErrRecordNotFound {
  28611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28612. return ""
  28613. } else if err != nil {
  28614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28615. return ""
  28616. } else {
  28617. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28618. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28619. infoStr := string(Iinfos)
  28620. idetinfoStr := string(Idetinfos)
  28621. psn := &models.HisPsn{
  28622. PsnNo: res.Output.Baseinfo.PsnNo,
  28623. PatientId: patient.ID,
  28624. Certno: res.Output.Baseinfo.Certno,
  28625. Gend: res.Output.Baseinfo.Gend,
  28626. Naty: res.Output.Baseinfo.Naty,
  28627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28628. PsnName: res.Output.Baseinfo.PsnName,
  28629. Idetinfo: idetinfoStr,
  28630. Insuinfo: infoStr,
  28631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28632. CardInfo: card_info,
  28633. VerifyNumber: token,
  28634. }
  28635. service.CreateHisPsn(psn)
  28636. return token
  28637. }
  28638. }
  28639. } else {
  28640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28641. return ""
  28642. }
  28643. return token
  28644. }
  28645. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28646. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28647. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28648. var token string
  28649. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28650. var api string
  28651. if miConfig.MdtrtareaAdmvs == "320921" {
  28652. 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 +
  28653. "&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
  28654. fmt.Println(api)
  28655. } else {
  28656. 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 +
  28657. "&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
  28658. }
  28659. resp, requestErr := http.Get(api)
  28660. if requestErr != nil {
  28661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28662. return ""
  28663. }
  28664. body, ioErr := ioutil.ReadAll(resp.Body)
  28665. if ioErr != nil {
  28666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28668. return ""
  28669. }
  28670. var respJSON map[string]interface{}
  28671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28674. return ""
  28675. }
  28676. var status string
  28677. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28678. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28679. var res ResultTwo //1101结果
  28680. var res10265 ResultTwo10265 //1101结果
  28681. if status == "0" { //读卡成功
  28682. var card_info string //卡信息
  28683. var busi_card_info string
  28684. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28685. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28686. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28687. fmt.Println(card_info)
  28688. fmt.Println(busi_card_info)
  28689. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28690. result, _ := json.Marshal(respJSON)
  28691. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28692. utils.ErrorLog("解析失败:%v", err)
  28693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28694. return ""
  28695. }
  28696. res.ErrMsg = res10265.ErrMsg
  28697. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28698. res.Infcode = infocode
  28699. res.Output = res10265.Output
  28700. res.InfRefmsgid = res10265.InfRefmsgid
  28701. if res.Infcode == 0 {
  28702. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28703. if err == gorm.ErrRecordNotFound {
  28704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28705. return ""
  28706. } else if err != nil {
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28708. return ""
  28709. } else {
  28710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28712. infoStr := string(Iinfos)
  28713. idetinfoStr := string(Idetinfos)
  28714. psn := &models.HisPsn{
  28715. PsnNo: res.Output.Baseinfo.PsnNo,
  28716. PatientId: patient.ID,
  28717. Certno: res.Output.Baseinfo.Certno,
  28718. Gend: res.Output.Baseinfo.Gend,
  28719. Naty: res.Output.Baseinfo.Naty,
  28720. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28721. PsnName: res.Output.Baseinfo.PsnName,
  28722. Idetinfo: idetinfoStr,
  28723. Insuinfo: infoStr,
  28724. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28725. CardInfo: card_info,
  28726. VerifyNumber: token,
  28727. }
  28728. service.CreateHisPsn(psn)
  28729. return token
  28730. }
  28731. }
  28732. } else {
  28733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28734. return ""
  28735. }
  28736. } else { //读卡失败
  28737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28738. return ""
  28739. }
  28740. return token
  28741. }
  28742. func DeleteExtraSpaceTwo(s string) string {
  28743. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28744. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28745. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28746. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28747. s2 := make([]byte, len(s1)) //定义字符数组切片
  28748. copy(s2, s1) //将字符串复制到切片
  28749. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28750. for len(spc_index) > 0 { //找到适配项
  28751. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28752. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28753. }
  28754. return string(s2)
  28755. }
  28756. func Remove0000(s string) string {
  28757. str := make([]rune, 0, len(s))
  28758. for _, v := range []rune(s) {
  28759. if v == 0 {
  28760. continue
  28761. }
  28762. str = append(str, v)
  28763. }
  28764. return string(str)
  28765. }
  28766. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28767. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28768. readCard := DllDef.MustFindProc("EcQuery")
  28769. pCardInfo := make([]byte, 8192)
  28770. pBusiCardInfo := make([]byte, 8192)
  28771. data := make(map[string]interface{})
  28772. //pData := make(map[string]interface{})
  28773. inputData := make(map[string]interface{})
  28774. inputData["orgId"] = code
  28775. inputData["businessType"] = "01101"
  28776. inputData["operatorId"] = operator_id
  28777. inputData["operatorName"] = operator_name
  28778. inputData["officeId"] = "001"
  28779. inputData["officeName"] = "血透室"
  28780. //
  28781. data["data"] = inputData
  28782. data["transType"] = "ec.query"
  28783. data["orgId"] = code
  28784. bytesData, _ := json.Marshal(data)
  28785. pCardInfo = bytesData
  28786. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28787. fmt.Println(ret2)
  28788. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28789. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28790. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28791. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28792. if ret2 != 0 {
  28793. return "", ""
  28794. }
  28795. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28796. }
  28797. func DeleteExtraSpace(s string) string {
  28798. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28799. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28800. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28801. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28802. s2 := make([]byte, len(s1)) //定义字符数组切片
  28803. copy(s2, s1) //将字符串复制到切片
  28804. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28805. for len(spc_index) > 0 { //找到适配项
  28806. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28807. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28808. }
  28809. return string(s2)
  28810. }
  28811. // 对账
  28812. func (c *HisApiController) Post3202() {
  28813. start_time := c.GetString("start_time")
  28814. end_time := c.GetString("end_time")
  28815. //insutype := c.GetString("insutype")
  28816. clr_type := c.GetString("clr_type")
  28817. clr_org := c.GetString("clr_optins")
  28818. admin_user_id, _ := c.GetInt64("admin_user_id")
  28819. adminUser := c.GetAdminUserInfo()
  28820. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28821. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28822. if len(clr_org) == 0 {
  28823. clr_org = miConfig.MdtrtareaAdmvs
  28824. }
  28825. timeLayout := "2006-01-02"
  28826. loc, _ := time.LoadLocation("Local")
  28827. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28828. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28829. var orders []*models.HisOrder
  28830. if clr_org == "421300" {
  28831. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28832. } else {
  28833. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28834. }
  28835. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28836. //fixmedins_setl_cnt := int64(len(orders))
  28837. var medfee_sumamt float64
  28838. var acct_pay float64
  28839. var fund_pay_sumamt float64
  28840. for _, item := range orders {
  28841. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28842. acct_pay = acct_pay + item.AcctPay
  28843. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28844. }
  28845. //var medfee_sumamt_two float64
  28846. //var acct_pay_two float64
  28847. //var fund_pay_sumamt_two float64
  28848. //for _, item := range orders_two {
  28849. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28850. // acct_pay_two = acct_pay_two + item.AcctPay
  28851. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28852. //}
  28853. //var user_name string
  28854. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28855. //if role.ID == 0 {
  28856. // user_name = "xxx"
  28857. //} else {
  28858. // user_name = role.UserName
  28859. //}
  28860. var res ResultSix
  28861. if config.IsOpen == 1 {
  28862. var bps []*models.BusinessParamsTwo
  28863. var bp models.BusinessParamsTwo
  28864. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28865. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28866. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28867. bp.MedfeeSumamt = medfee_sumamt_str
  28868. bp.AcctPay = acct_pay_str
  28869. bp.FundPaySumamt = fund_pay_sumamt_str
  28870. bp.Insutype = ""
  28871. bp.StmtBegndate = start_time
  28872. bp.ClrType = clr_type
  28873. bp.SetlOptins = clr_org
  28874. bp.StmtEnddate = end_time
  28875. bps = append(bps, &bp)
  28876. data := make(map[string]interface{})
  28877. data["bps"] = bps
  28878. data["org_name"] = miConfig.OrgName
  28879. data["doctor"] = role.UserName
  28880. data["fixmedins_code"] = miConfig.Code
  28881. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28882. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28883. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28884. if miConfig.MdtrtareaAdmvs == "421300" {
  28885. client := &http.Client{}
  28886. bytesData, _ := json.Marshal(data)
  28887. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28888. resp, _ := client.Do(req)
  28889. defer resp.Body.Close()
  28890. body, ioErr := ioutil.ReadAll(resp.Body)
  28891. if ioErr != nil {
  28892. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28894. return
  28895. }
  28896. var respJSON map[string]interface{}
  28897. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28898. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28900. return
  28901. }
  28902. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28903. userJSONBytes, _ := json.Marshal(respJSON)
  28904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28905. utils.ErrorLog("解析失败:%v", err)
  28906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28907. return
  28908. }
  28909. }
  28910. if miConfig.MdtrtareaAdmvs == "420200" {
  28911. client := &http.Client{}
  28912. bytesData, _ := json.Marshal(data)
  28913. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28914. resp, _ := client.Do(req)
  28915. defer resp.Body.Close()
  28916. body, ioErr := ioutil.ReadAll(resp.Body)
  28917. if ioErr != nil {
  28918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28920. return
  28921. }
  28922. var respJSON map[string]interface{}
  28923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28926. return
  28927. }
  28928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28929. userJSONBytes, _ := json.Marshal(respJSON)
  28930. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28931. utils.ErrorLog("解析失败:%v", err)
  28932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28933. return
  28934. }
  28935. }
  28936. if miConfig.MdtrtareaAdmvs == "421182" {
  28937. client := &http.Client{}
  28938. bytesData, _ := json.Marshal(data)
  28939. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28940. resp, _ := client.Do(req)
  28941. defer resp.Body.Close()
  28942. body, ioErr := ioutil.ReadAll(resp.Body)
  28943. if ioErr != nil {
  28944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28946. return
  28947. }
  28948. var respJSON map[string]interface{}
  28949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28952. return
  28953. }
  28954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28955. userJSONBytes, _ := json.Marshal(respJSON)
  28956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28957. utils.ErrorLog("解析失败:%v", err)
  28958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28959. return
  28960. }
  28961. }
  28962. if res.Infcode == 0 {
  28963. c.ServeSuccessJSON(map[string]interface{}{
  28964. "msg": "发起成功",
  28965. })
  28966. } else {
  28967. c.ServeSuccessJSON(map[string]interface{}{
  28968. "failed_code": -10,
  28969. "msg": res.ErrMsg,
  28970. })
  28971. }
  28972. }
  28973. }
  28974. func (c *HisApiController) Post3202b() {
  28975. start_time := c.GetString("start_time")
  28976. end_time := c.GetString("end_time")
  28977. //insutype := c.GetString("insutype")
  28978. clr_type := c.GetString("clr_type")
  28979. clr_org := c.GetString("clr_optins")
  28980. admin_user_id, _ := c.GetInt64("admin_user_id")
  28981. adminUser := c.GetAdminUserInfo()
  28982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28983. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28984. if len(clr_org) == 0 {
  28985. clr_org = miConfig.MdtrtareaAdmvs
  28986. }
  28987. timeLayout := "2006-01-02"
  28988. loc, _ := time.LoadLocation("Local")
  28989. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28990. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28991. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28992. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28993. //fixmedins_setl_cnt := int64(len(orders))
  28994. var medfee_sumamt float64
  28995. var acct_pay float64
  28996. var fund_pay_sumamt float64
  28997. for _, item := range orders {
  28998. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28999. acct_pay = acct_pay + item.AcctPay
  29000. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29001. }
  29002. //var medfee_sumamt_two float64
  29003. //var acct_pay_two float64
  29004. //var fund_pay_sumamt_two float64
  29005. //for _, item := range orders_two {
  29006. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29007. // acct_pay_two = acct_pay_two + item.AcctPay
  29008. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29009. //}
  29010. //var user_name string
  29011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29012. //if role.ID == 0 {
  29013. // user_name = "xxx"
  29014. //} else {
  29015. // user_name = role.UserName
  29016. //}
  29017. var res ResultSix
  29018. if config.IsOpen == 1 {
  29019. var bps []*models.BusinessParamsTwo
  29020. var bp models.BusinessParamsTwo
  29021. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29022. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29023. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29024. bp.MedfeeSumamt = medfee_sumamt_str
  29025. bp.AcctPay = acct_pay_str
  29026. bp.FundPaySumamt = fund_pay_sumamt_str
  29027. bp.Insutype = "390"
  29028. bp.StmtBegndate = start_time
  29029. bp.ClrType = clr_type
  29030. bp.SetlOptins = clr_org
  29031. bp.StmtEnddate = end_time
  29032. bps = append(bps, &bp)
  29033. data := make(map[string]interface{})
  29034. data["bps"] = bps
  29035. data["org_name"] = miConfig.OrgName
  29036. data["doctor"] = role.UserName
  29037. data["fixmedins_code"] = miConfig.Code
  29038. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29039. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29040. if miConfig.MdtrtareaAdmvs == "421300" {
  29041. client := &http.Client{}
  29042. bytesData, _ := json.Marshal(data)
  29043. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29044. resp, _ := client.Do(req)
  29045. defer resp.Body.Close()
  29046. body, ioErr := ioutil.ReadAll(resp.Body)
  29047. if ioErr != nil {
  29048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29050. return
  29051. }
  29052. var respJSON map[string]interface{}
  29053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29056. return
  29057. }
  29058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29059. userJSONBytes, _ := json.Marshal(respJSON)
  29060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29061. utils.ErrorLog("解析失败:%v", err)
  29062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29063. return
  29064. }
  29065. }
  29066. if miConfig.MdtrtareaAdmvs == "420200" {
  29067. client := &http.Client{}
  29068. bytesData, _ := json.Marshal(data)
  29069. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29070. resp, _ := client.Do(req)
  29071. defer resp.Body.Close()
  29072. body, ioErr := ioutil.ReadAll(resp.Body)
  29073. if ioErr != nil {
  29074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29076. return
  29077. }
  29078. var respJSON map[string]interface{}
  29079. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29082. return
  29083. }
  29084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29085. userJSONBytes, _ := json.Marshal(respJSON)
  29086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29087. utils.ErrorLog("解析失败:%v", err)
  29088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29089. return
  29090. }
  29091. }
  29092. if miConfig.MdtrtareaAdmvs == "421182" {
  29093. client := &http.Client{}
  29094. bytesData, _ := json.Marshal(data)
  29095. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29096. resp, _ := client.Do(req)
  29097. defer resp.Body.Close()
  29098. body, ioErr := ioutil.ReadAll(resp.Body)
  29099. if ioErr != nil {
  29100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29102. return
  29103. }
  29104. var respJSON map[string]interface{}
  29105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29108. return
  29109. }
  29110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29111. userJSONBytes, _ := json.Marshal(respJSON)
  29112. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29113. utils.ErrorLog("解析失败:%v", err)
  29114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29115. return
  29116. }
  29117. }
  29118. if res.Infcode == 0 {
  29119. c.ServeSuccessJSON(map[string]interface{}{
  29120. "msg": "发起成功",
  29121. })
  29122. } else {
  29123. c.ServeSuccessJSON(map[string]interface{}{
  29124. "failed_code": -10,
  29125. "msg": res.ErrMsg,
  29126. })
  29127. }
  29128. }
  29129. }
  29130. func (c *HisApiController) Post1608() {
  29131. start_time := c.GetString("start_time")
  29132. end_time := c.GetString("end_time")
  29133. admin_user_id, _ := c.GetInt64("admin_user_id")
  29134. adminUser := c.GetAdminUserInfo()
  29135. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29136. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29137. timeLayout := "2006-01-02"
  29138. loc, _ := time.LoadLocation("Local")
  29139. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29140. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29141. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29142. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29143. fixmedins_setl_cnt := int64(len(orders))
  29144. var medfee_sumamt float64
  29145. var func_smamt float64
  29146. for _, item := range orders {
  29147. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29148. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  29149. }
  29150. times := strings.Split(start_time, "-")
  29151. time_tows := strings.Split(end_time, "-")
  29152. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29153. var res ResultSix
  29154. if config.IsOpen == 1 {
  29155. //var bps []*models.BusinessParamsTwo
  29156. //var bp models.BusinessParamsTwo
  29157. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29158. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  29159. data := make(map[string]interface{})
  29160. data["org_name"] = miConfig.OrgName
  29161. data["doctor"] = role.UserName
  29162. data["func_smamt"] = func_smamt_str
  29163. data["fixmedins_code"] = miConfig.Code
  29164. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29165. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29166. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  29167. data["medfee_sumamt"] = medfee_sumamt_str
  29168. data["start_time"] = times[0] + times[1] + times[2]
  29169. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  29170. if miConfig.MdtrtareaAdmvs == "421300" {
  29171. client := &http.Client{}
  29172. bytesData, _ := json.Marshal(data)
  29173. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29174. resp, _ := client.Do(req)
  29175. defer resp.Body.Close()
  29176. body, ioErr := ioutil.ReadAll(resp.Body)
  29177. if ioErr != nil {
  29178. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29180. return
  29181. }
  29182. var respJSON map[string]interface{}
  29183. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29186. return
  29187. }
  29188. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29189. userJSONBytes, _ := json.Marshal(respJSON)
  29190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29191. utils.ErrorLog("解析失败:%v", err)
  29192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29193. return
  29194. }
  29195. }
  29196. if miConfig.MdtrtareaAdmvs == "420200" {
  29197. client := &http.Client{}
  29198. bytesData, _ := json.Marshal(data)
  29199. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29200. resp, _ := client.Do(req)
  29201. defer resp.Body.Close()
  29202. body, ioErr := ioutil.ReadAll(resp.Body)
  29203. if ioErr != nil {
  29204. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29206. return
  29207. }
  29208. var respJSON map[string]interface{}
  29209. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29212. return
  29213. }
  29214. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29215. userJSONBytes, _ := json.Marshal(respJSON)
  29216. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29217. utils.ErrorLog("解析失败:%v", err)
  29218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29219. return
  29220. }
  29221. }
  29222. if miConfig.MdtrtareaAdmvs == "421182" {
  29223. client := &http.Client{}
  29224. bytesData, _ := json.Marshal(data)
  29225. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  29226. resp, _ := client.Do(req)
  29227. defer resp.Body.Close()
  29228. body, ioErr := ioutil.ReadAll(resp.Body)
  29229. if ioErr != nil {
  29230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29232. return
  29233. }
  29234. var respJSON map[string]interface{}
  29235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29238. return
  29239. }
  29240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29241. userJSONBytes, _ := json.Marshal(respJSON)
  29242. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29243. utils.ErrorLog("解析失败:%v", err)
  29244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29245. return
  29246. }
  29247. }
  29248. if res.Infcode == 0 {
  29249. c.ServeSuccessJSON(map[string]interface{}{
  29250. "msg": "发起成功",
  29251. })
  29252. } else {
  29253. c.ServeSuccessJSON(map[string]interface{}{
  29254. "failed_code": -10,
  29255. "msg": res.ErrMsg,
  29256. })
  29257. }
  29258. }
  29259. }
  29260. // 5.11.1.1【5262】结算信息按时间段查询
  29261. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29262. admin_user_id, _ := c.GetInt64("admin_user_id")
  29263. adminUser := c.GetAdminUserInfo()
  29264. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29265. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29266. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29267. var res Result5262
  29268. if config.IsOpen == 1 {
  29269. if miConfig.MdtrtareaAdmvs == "421300" {
  29270. data := make(map[string]interface{})
  29271. data["bps"] = bp
  29272. data["org_name"] = miConfig.OrgName
  29273. data["doctor"] = role.UserName
  29274. data["fixmedins_code"] = miConfig.Code
  29275. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29276. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29277. data["page"] = strconv.FormatInt(page, 10)
  29278. data["limit"] = strconv.FormatInt(limit, 10)
  29279. fmt.Println(data)
  29280. client := &http.Client{}
  29281. bytesData, _ := json.Marshal(data)
  29282. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29283. resp, _ := client.Do(req)
  29284. defer resp.Body.Close()
  29285. body, ioErr := ioutil.ReadAll(resp.Body)
  29286. if ioErr != nil {
  29287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29289. return
  29290. }
  29291. var respJSON map[string]interface{}
  29292. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29295. return
  29296. }
  29297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29298. userJSONBytes, _ := json.Marshal(respJSON)
  29299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29300. utils.ErrorLog("解析失败:%v", err)
  29301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29302. return
  29303. }
  29304. }
  29305. if miConfig.MdtrtareaAdmvs == "420200" {
  29306. data := make(map[string]interface{})
  29307. data["bps"] = bp
  29308. data["org_name"] = miConfig.OrgName
  29309. data["doctor"] = role.UserName
  29310. data["fixmedins_code"] = miConfig.Code
  29311. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29312. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29313. data["page"] = strconv.FormatInt(page, 10)
  29314. data["limit"] = strconv.FormatInt(limit, 10)
  29315. fmt.Println(data)
  29316. client := &http.Client{}
  29317. bytesData, _ := json.Marshal(data)
  29318. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  29319. resp, _ := client.Do(req)
  29320. defer resp.Body.Close()
  29321. body, ioErr := ioutil.ReadAll(resp.Body)
  29322. if ioErr != nil {
  29323. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29325. return
  29326. }
  29327. var respJSON map[string]interface{}
  29328. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29329. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29331. return
  29332. }
  29333. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29334. userJSONBytes, _ := json.Marshal(respJSON)
  29335. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29336. utils.ErrorLog("解析失败:%v", err)
  29337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29338. return
  29339. }
  29340. }
  29341. if miConfig.MdtrtareaAdmvs == "421182" {
  29342. data := make(map[string]interface{})
  29343. data["bps"] = bp
  29344. data["org_name"] = miConfig.OrgName
  29345. data["doctor"] = role.UserName
  29346. data["fixmedins_code"] = miConfig.Code
  29347. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29348. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29349. data["page"] = strconv.FormatInt(page, 10)
  29350. data["limit"] = strconv.FormatInt(limit, 10)
  29351. fmt.Println(data)
  29352. client := &http.Client{}
  29353. bytesData, _ := json.Marshal(data)
  29354. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  29355. resp, _ := client.Do(req)
  29356. defer resp.Body.Close()
  29357. body, ioErr := ioutil.ReadAll(resp.Body)
  29358. if ioErr != nil {
  29359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29361. return
  29362. }
  29363. var respJSON map[string]interface{}
  29364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29367. return
  29368. }
  29369. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29370. userJSONBytes, _ := json.Marshal(respJSON)
  29371. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29372. utils.ErrorLog("解析失败:%v", err)
  29373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29374. return
  29375. }
  29376. }
  29377. if res.Infcode == 0 {
  29378. c.ServeSuccessJSON(map[string]interface{}{
  29379. "order": res.Output.Result,
  29380. "total": res.Output.PageInfo.RecordCounts,
  29381. })
  29382. } else {
  29383. c.ServeSuccessJSON(map[string]interface{}{
  29384. "failed_code": -10,
  29385. "msg": res.ErrMsg,
  29386. })
  29387. }
  29388. }
  29389. }
  29390. // 5.11.1.2【5267】异地结算信息时间段查询
  29391. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  29392. admin_user_id, _ := c.GetInt64("admin_user_id")
  29393. adminUser := c.GetAdminUserInfo()
  29394. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29395. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29396. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29397. var res Result5267
  29398. if config.IsOpen == 1 {
  29399. if miConfig.MdtrtareaAdmvs == "421300" {
  29400. data := make(map[string]interface{})
  29401. data["bps"] = bp
  29402. data["org_name"] = miConfig.OrgName
  29403. data["doctor"] = role.UserName
  29404. data["fixmedins_code"] = miConfig.Code
  29405. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29406. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29407. data["page"] = page
  29408. data["limit"] = limit
  29409. fmt.Println(data)
  29410. client := &http.Client{}
  29411. bytesData, _ := json.Marshal(data)
  29412. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29413. resp, _ := client.Do(req)
  29414. defer resp.Body.Close()
  29415. body, ioErr := ioutil.ReadAll(resp.Body)
  29416. if ioErr != nil {
  29417. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29419. return
  29420. }
  29421. var respJSON map[string]interface{}
  29422. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29423. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29425. return
  29426. }
  29427. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29428. userJSONBytes, _ := json.Marshal(respJSON)
  29429. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29430. utils.ErrorLog("解析失败:%v", err)
  29431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29432. return
  29433. }
  29434. }
  29435. if miConfig.MdtrtareaAdmvs == "420200" {
  29436. data := make(map[string]interface{})
  29437. data["bps"] = bp
  29438. data["org_name"] = miConfig.OrgName
  29439. data["doctor"] = role.UserName
  29440. data["fixmedins_code"] = miConfig.Code
  29441. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29442. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29443. data["page"] = page
  29444. data["limit"] = limit
  29445. fmt.Println(data)
  29446. client := &http.Client{}
  29447. bytesData, _ := json.Marshal(data)
  29448. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29449. resp, _ := client.Do(req)
  29450. defer resp.Body.Close()
  29451. body, ioErr := ioutil.ReadAll(resp.Body)
  29452. if ioErr != nil {
  29453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29455. return
  29456. }
  29457. var respJSON map[string]interface{}
  29458. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29459. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29461. return
  29462. }
  29463. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29464. userJSONBytes, _ := json.Marshal(respJSON)
  29465. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29466. utils.ErrorLog("解析失败:%v", err)
  29467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29468. return
  29469. }
  29470. }
  29471. if miConfig.MdtrtareaAdmvs == "421182" {
  29472. data := make(map[string]interface{})
  29473. data["bps"] = bp
  29474. data["org_name"] = miConfig.OrgName
  29475. data["doctor"] = role.UserName
  29476. data["fixmedins_code"] = miConfig.Code
  29477. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29479. data["page"] = page
  29480. data["limit"] = limit
  29481. fmt.Println(data)
  29482. client := &http.Client{}
  29483. bytesData, _ := json.Marshal(data)
  29484. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  29485. resp, _ := client.Do(req)
  29486. defer resp.Body.Close()
  29487. body, ioErr := ioutil.ReadAll(resp.Body)
  29488. if ioErr != nil {
  29489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29491. return
  29492. }
  29493. var respJSON map[string]interface{}
  29494. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29497. return
  29498. }
  29499. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29500. userJSONBytes, _ := json.Marshal(respJSON)
  29501. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29502. utils.ErrorLog("解析失败:%v", err)
  29503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29504. return
  29505. }
  29506. }
  29507. if res.Infcode == 0 {
  29508. c.ServeSuccessJSON(map[string]interface{}{
  29509. "order": res.Output.Result,
  29510. "total": res.Output.PageInfo.RecordCounts,
  29511. })
  29512. } else {
  29513. c.ServeSuccessJSON(map[string]interface{}{
  29514. "failed_code": -10,
  29515. "msg": res.ErrMsg,
  29516. })
  29517. }
  29518. }
  29519. }
  29520. func (c *HisApiController) Post3501() {
  29521. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29522. data := make(map[string]interface{})
  29523. var struct3501s []models.Struct3501
  29524. var struct3501 models.Struct3501
  29525. struct3501.OrgName = miConfig.OrgName
  29526. struct3501.AccessKey = miConfig.AccessKey
  29527. struct3501.RequestUrl = miConfig.Url
  29528. struct3501.SecretKey = miConfig.SecretKey
  29529. struct3501.ManuDate = "2022-08-17"
  29530. struct3501.FixmedinsBchno = ""
  29531. struct3501.ManuLotnum = ""
  29532. struct3501.RxFlag = "0"
  29533. struct3501.ExpyEnd = "2022-08-17"
  29534. struct3501.Invdate = "2022-08-17"
  29535. struct3501.InvCnt = "20.25"
  29536. struct3501.Memo = ""
  29537. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29538. struct3501.FixmedinsHilistId = miConfig.Code
  29539. struct3501.FixmedinsHilistName = miConfig.OrgName
  29540. struct3501s = append(struct3501s, struct3501)
  29541. data["struct_3501s"] = struct3501s
  29542. client := &http.Client{}
  29543. bytesData, _ := json.Marshal(data)
  29544. var req *http.Request
  29545. if miConfig.MdtrtareaAdmvs == "320921" {
  29546. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29547. } else {
  29548. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29549. }
  29550. resp, _ := client.Do(req)
  29551. defer resp.Body.Close()
  29552. body, ioErr := ioutil.ReadAll(resp.Body)
  29553. if ioErr != nil {
  29554. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29556. return
  29557. }
  29558. var respJSON map[string]interface{}
  29559. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29560. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29562. return
  29563. }
  29564. var res ResultSix
  29565. var resSix10265 ResultSix10265 //1101结果
  29566. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29567. result, _ := json.Marshal(respJSON)
  29568. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29569. utils.ErrorLog("解析失败:%v", err)
  29570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29571. return
  29572. }
  29573. res.InfRefmsgid = resSix10265.InfRefmsgid
  29574. res.Output = resSix10265.Output
  29575. res.ErrMsg = resSix10265.ErrMsg
  29576. res.Cainfo = resSix10265.Cainfo
  29577. res.WarnMsg = resSix10265.WarnMsg
  29578. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29579. res.Infcode = infocode
  29580. if infocode == 0 {
  29581. c.ServeSuccessJSON(map[string]interface{}{
  29582. "msg": "上传成功",
  29583. })
  29584. return
  29585. } else {
  29586. c.ServeSuccessJSON(map[string]interface{}{
  29587. "failed_code": -10,
  29588. "msg": res.ErrMsg,
  29589. })
  29590. return
  29591. }
  29592. }
  29593. func (c *HisApiController) Post3502() {
  29594. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29595. data := make(map[string]interface{})
  29596. var struct3502s []models.Struct3502
  29597. var struct3502 models.Struct3502
  29598. struct3502.OrgName = miConfig.OrgName
  29599. struct3502.AccessKey = miConfig.AccessKey
  29600. struct3502.RequestUrl = miConfig.Url
  29601. struct3502.SecretKey = miConfig.SecretKey
  29602. struct3502.ManuDate = "2022-08-15"
  29603. struct3502.FixmedinsBchno = ""
  29604. struct3502.ManuLotnum = ""
  29605. struct3502.RxFlag = "0"
  29606. struct3502.ExpyEnd = "2022-08-15"
  29607. struct3502.Invdate = "2022-08-15"
  29608. struct3502.InvCnt = "20.25"
  29609. struct3502.Memo = ""
  29610. struct3502.MedListCodg = "XB01ABD056B002020200517"
  29611. struct3502.FixmedinsHilistId = miConfig.Code
  29612. struct3502.FixmedinsHilistName = miConfig.OrgName
  29613. struct3502s = append(struct3502s, struct3502)
  29614. data["struct_3502s"] = struct3502s
  29615. client := &http.Client{}
  29616. bytesData, _ := json.Marshal(data)
  29617. var req *http.Request
  29618. if miConfig.MdtrtareaAdmvs == "320921" {
  29619. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29620. } else {
  29621. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29622. }
  29623. resp, _ := client.Do(req)
  29624. defer resp.Body.Close()
  29625. body, ioErr := ioutil.ReadAll(resp.Body)
  29626. if ioErr != nil {
  29627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29629. return
  29630. }
  29631. var respJSON map[string]interface{}
  29632. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29635. return
  29636. }
  29637. var res ResultSix
  29638. var resSix10265 ResultSix10265 //1101结果
  29639. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29640. result, _ := json.Marshal(respJSON)
  29641. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29642. utils.ErrorLog("解析失败:%v", err)
  29643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29644. return
  29645. }
  29646. res.InfRefmsgid = resSix10265.InfRefmsgid
  29647. res.Output = resSix10265.Output
  29648. res.ErrMsg = resSix10265.ErrMsg
  29649. res.Cainfo = resSix10265.Cainfo
  29650. res.WarnMsg = resSix10265.WarnMsg
  29651. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29652. res.Infcode = infocode
  29653. if infocode == 0 {
  29654. c.ServeSuccessJSON(map[string]interface{}{
  29655. "msg": "上传成功",
  29656. })
  29657. return
  29658. } else {
  29659. c.ServeSuccessJSON(map[string]interface{}{
  29660. "failed_code": -10,
  29661. "msg": res.ErrMsg,
  29662. })
  29663. return
  29664. }
  29665. }
  29666. func (c *HisApiController) Post3503() {
  29667. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29668. data := make(map[string]interface{})
  29669. var struct3501s []models.Struct3501
  29670. var struct3501 models.Struct3501
  29671. struct3501.OrgName = miConfig.OrgName
  29672. struct3501.AccessKey = miConfig.AccessKey
  29673. struct3501.RequestUrl = miConfig.Url
  29674. struct3501.SecretKey = miConfig.SecretKey
  29675. struct3501.ManuDate = "2022-08-15"
  29676. struct3501.FixmedinsBchno = ""
  29677. struct3501.ManuLotnum = ""
  29678. struct3501.RxFlag = "0"
  29679. struct3501.ExpyEnd = "2022-08-15"
  29680. struct3501.Invdate = "2022-08-15"
  29681. struct3501.InvCnt = "20.25"
  29682. struct3501.Memo = ""
  29683. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29684. struct3501.FixmedinsHilistId = miConfig.Code
  29685. struct3501.FixmedinsHilistName = miConfig.OrgName
  29686. struct3501s = append(struct3501s, struct3501)
  29687. data["struct_3501s"] = struct3501s
  29688. client := &http.Client{}
  29689. bytesData, _ := json.Marshal(data)
  29690. var req *http.Request
  29691. if miConfig.MdtrtareaAdmvs == "320921" {
  29692. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29693. } else {
  29694. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29695. }
  29696. resp, _ := client.Do(req)
  29697. defer resp.Body.Close()
  29698. body, ioErr := ioutil.ReadAll(resp.Body)
  29699. if ioErr != nil {
  29700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29702. return
  29703. }
  29704. var respJSON map[string]interface{}
  29705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29708. return
  29709. }
  29710. var res ResultSix
  29711. var resSix10265 ResultSix10265 //1101结果
  29712. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29713. result, _ := json.Marshal(respJSON)
  29714. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29715. utils.ErrorLog("解析失败:%v", err)
  29716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29717. return
  29718. }
  29719. res.InfRefmsgid = resSix10265.InfRefmsgid
  29720. res.Output = resSix10265.Output
  29721. res.ErrMsg = resSix10265.ErrMsg
  29722. res.Cainfo = resSix10265.Cainfo
  29723. res.WarnMsg = resSix10265.WarnMsg
  29724. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29725. res.Infcode = infocode
  29726. if infocode == 0 {
  29727. c.ServeSuccessJSON(map[string]interface{}{
  29728. "msg": "上传成功",
  29729. })
  29730. return
  29731. } else {
  29732. c.ServeSuccessJSON(map[string]interface{}{
  29733. "failed_code": -10,
  29734. "msg": res.ErrMsg,
  29735. })
  29736. return
  29737. }
  29738. }
  29739. func (c *HisApiController) Post3504() {
  29740. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29741. data := make(map[string]interface{})
  29742. var struct3501s []models.Struct3501
  29743. var struct3501 models.Struct3501
  29744. struct3501.OrgName = miConfig.OrgName
  29745. struct3501.AccessKey = miConfig.AccessKey
  29746. struct3501.RequestUrl = miConfig.Url
  29747. struct3501.SecretKey = miConfig.SecretKey
  29748. struct3501.ManuDate = "2022-08-15"
  29749. struct3501.FixmedinsBchno = ""
  29750. struct3501.ManuLotnum = ""
  29751. struct3501.RxFlag = "0"
  29752. struct3501.ExpyEnd = "2022-08-15"
  29753. struct3501.Invdate = "2022-08-15"
  29754. struct3501.InvCnt = "20.25"
  29755. struct3501.Memo = ""
  29756. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29757. struct3501.FixmedinsHilistId = miConfig.Code
  29758. struct3501.FixmedinsHilistName = miConfig.OrgName
  29759. struct3501s = append(struct3501s, struct3501)
  29760. data["struct_3501s"] = struct3501s
  29761. client := &http.Client{}
  29762. bytesData, _ := json.Marshal(data)
  29763. var req *http.Request
  29764. if miConfig.MdtrtareaAdmvs == "320921" {
  29765. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29766. } else {
  29767. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29768. }
  29769. resp, _ := client.Do(req)
  29770. defer resp.Body.Close()
  29771. body, ioErr := ioutil.ReadAll(resp.Body)
  29772. if ioErr != nil {
  29773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29775. return
  29776. }
  29777. var respJSON map[string]interface{}
  29778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29781. return
  29782. }
  29783. var res ResultSix
  29784. var resSix10265 ResultSix10265 //1101结果
  29785. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29786. result, _ := json.Marshal(respJSON)
  29787. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29788. utils.ErrorLog("解析失败:%v", err)
  29789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29790. return
  29791. }
  29792. res.InfRefmsgid = resSix10265.InfRefmsgid
  29793. res.Output = resSix10265.Output
  29794. res.ErrMsg = resSix10265.ErrMsg
  29795. res.Cainfo = resSix10265.Cainfo
  29796. res.WarnMsg = resSix10265.WarnMsg
  29797. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29798. res.Infcode = infocode
  29799. if infocode == 0 {
  29800. c.ServeSuccessJSON(map[string]interface{}{
  29801. "msg": "上传成功",
  29802. })
  29803. return
  29804. } else {
  29805. c.ServeSuccessJSON(map[string]interface{}{
  29806. "failed_code": -10,
  29807. "msg": res.ErrMsg,
  29808. })
  29809. return
  29810. }
  29811. }
  29812. func (c *HisApiController) Post3505() {
  29813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29814. data := make(map[string]interface{})
  29815. var struct3501s []models.Struct3501
  29816. var struct3501 models.Struct3501
  29817. struct3501.OrgName = miConfig.OrgName
  29818. struct3501.AccessKey = miConfig.AccessKey
  29819. struct3501.RequestUrl = miConfig.Url
  29820. struct3501.SecretKey = miConfig.SecretKey
  29821. struct3501.ManuDate = "2022-08-15"
  29822. struct3501.FixmedinsBchno = ""
  29823. struct3501.ManuLotnum = ""
  29824. struct3501.RxFlag = "0"
  29825. struct3501.ExpyEnd = "2022-08-15"
  29826. struct3501.Invdate = "2022-08-15"
  29827. struct3501.InvCnt = "20.25"
  29828. struct3501.Memo = ""
  29829. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29830. struct3501.FixmedinsHilistId = miConfig.Code
  29831. struct3501.FixmedinsHilistName = miConfig.OrgName
  29832. struct3501s = append(struct3501s, struct3501)
  29833. data["struct_3501s"] = struct3501s
  29834. client := &http.Client{}
  29835. bytesData, _ := json.Marshal(data)
  29836. var req *http.Request
  29837. if miConfig.MdtrtareaAdmvs == "320921" {
  29838. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29839. } else {
  29840. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29841. }
  29842. resp, _ := client.Do(req)
  29843. defer resp.Body.Close()
  29844. body, ioErr := ioutil.ReadAll(resp.Body)
  29845. if ioErr != nil {
  29846. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29848. return
  29849. }
  29850. var respJSON map[string]interface{}
  29851. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29852. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29854. return
  29855. }
  29856. var res ResultSix
  29857. var resSix10265 ResultSix10265 //1101结果
  29858. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29859. result, _ := json.Marshal(respJSON)
  29860. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29861. utils.ErrorLog("解析失败:%v", err)
  29862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29863. return
  29864. }
  29865. res.InfRefmsgid = resSix10265.InfRefmsgid
  29866. res.Output = resSix10265.Output
  29867. res.ErrMsg = resSix10265.ErrMsg
  29868. res.Cainfo = resSix10265.Cainfo
  29869. res.WarnMsg = resSix10265.WarnMsg
  29870. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29871. res.Infcode = infocode
  29872. if infocode == 0 {
  29873. c.ServeSuccessJSON(map[string]interface{}{
  29874. "msg": "上传成功",
  29875. })
  29876. return
  29877. } else {
  29878. c.ServeSuccessJSON(map[string]interface{}{
  29879. "failed_code": -10,
  29880. "msg": res.ErrMsg,
  29881. })
  29882. return
  29883. }
  29884. }
  29885. func (c *HisApiController) Post3506() {
  29886. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29887. data := make(map[string]interface{})
  29888. var struct3501s []models.Struct3501
  29889. var struct3501 models.Struct3501
  29890. struct3501.OrgName = miConfig.OrgName
  29891. struct3501.AccessKey = miConfig.AccessKey
  29892. struct3501.RequestUrl = miConfig.Url
  29893. struct3501.SecretKey = miConfig.SecretKey
  29894. struct3501.ManuDate = "2022-08-15"
  29895. struct3501.FixmedinsBchno = ""
  29896. struct3501.ManuLotnum = ""
  29897. struct3501.RxFlag = "0"
  29898. struct3501.ExpyEnd = "2022-08-15"
  29899. struct3501.Invdate = "2022-08-15"
  29900. struct3501.InvCnt = "20.25"
  29901. struct3501.Memo = ""
  29902. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29903. struct3501.FixmedinsHilistId = miConfig.Code
  29904. struct3501.FixmedinsHilistName = miConfig.OrgName
  29905. struct3501s = append(struct3501s, struct3501)
  29906. data["struct_3501s"] = struct3501s
  29907. client := &http.Client{}
  29908. bytesData, _ := json.Marshal(data)
  29909. var req *http.Request
  29910. if miConfig.MdtrtareaAdmvs == "320921" {
  29911. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29912. } else {
  29913. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29914. }
  29915. resp, _ := client.Do(req)
  29916. defer resp.Body.Close()
  29917. body, ioErr := ioutil.ReadAll(resp.Body)
  29918. if ioErr != nil {
  29919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29921. return
  29922. }
  29923. var respJSON map[string]interface{}
  29924. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29927. return
  29928. }
  29929. var res ResultSix
  29930. var resSix10265 ResultSix10265 //1101结果
  29931. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29932. result, _ := json.Marshal(respJSON)
  29933. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29934. utils.ErrorLog("解析失败:%v", err)
  29935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29936. return
  29937. }
  29938. res.InfRefmsgid = resSix10265.InfRefmsgid
  29939. res.Output = resSix10265.Output
  29940. res.ErrMsg = resSix10265.ErrMsg
  29941. res.Cainfo = resSix10265.Cainfo
  29942. res.WarnMsg = resSix10265.WarnMsg
  29943. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29944. res.Infcode = infocode
  29945. if infocode == 0 {
  29946. c.ServeSuccessJSON(map[string]interface{}{
  29947. "msg": "上传成功",
  29948. })
  29949. return
  29950. } else {
  29951. c.ServeSuccessJSON(map[string]interface{}{
  29952. "failed_code": -10,
  29953. "msg": res.ErrMsg,
  29954. })
  29955. return
  29956. }
  29957. }
  29958. func (c *HisApiController) Post3507() {
  29959. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29960. data := make(map[string]interface{})
  29961. var struct3501s []models.Struct3501
  29962. var struct3501 models.Struct3501
  29963. struct3501.OrgName = miConfig.OrgName
  29964. struct3501.AccessKey = miConfig.AccessKey
  29965. struct3501.RequestUrl = miConfig.Url
  29966. struct3501.SecretKey = miConfig.SecretKey
  29967. struct3501.ManuDate = "2022-08-15"
  29968. struct3501.FixmedinsBchno = ""
  29969. struct3501.ManuLotnum = ""
  29970. struct3501.RxFlag = "0"
  29971. struct3501.ExpyEnd = "2022-08-15"
  29972. struct3501.Invdate = "2022-08-15"
  29973. struct3501.InvCnt = "20.25"
  29974. struct3501.Memo = ""
  29975. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29976. struct3501.FixmedinsHilistId = miConfig.Code
  29977. struct3501.FixmedinsHilistName = miConfig.OrgName
  29978. struct3501s = append(struct3501s, struct3501)
  29979. data["struct_3501s"] = struct3501s
  29980. client := &http.Client{}
  29981. bytesData, _ := json.Marshal(data)
  29982. var req *http.Request
  29983. if miConfig.MdtrtareaAdmvs == "320921" {
  29984. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29985. } else {
  29986. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29987. }
  29988. resp, _ := client.Do(req)
  29989. defer resp.Body.Close()
  29990. body, ioErr := ioutil.ReadAll(resp.Body)
  29991. if ioErr != nil {
  29992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29994. return
  29995. }
  29996. var respJSON map[string]interface{}
  29997. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30000. return
  30001. }
  30002. var res ResultSix
  30003. var resSix10265 ResultSix10265 //1101结果
  30004. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30005. result, _ := json.Marshal(respJSON)
  30006. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30007. utils.ErrorLog("解析失败:%v", err)
  30008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30009. return
  30010. }
  30011. res.InfRefmsgid = resSix10265.InfRefmsgid
  30012. res.Output = resSix10265.Output
  30013. res.ErrMsg = resSix10265.ErrMsg
  30014. res.Cainfo = resSix10265.Cainfo
  30015. res.WarnMsg = resSix10265.WarnMsg
  30016. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30017. res.Infcode = infocode
  30018. if infocode == 0 {
  30019. c.ServeSuccessJSON(map[string]interface{}{
  30020. "msg": "上传成功",
  30021. })
  30022. return
  30023. } else {
  30024. c.ServeSuccessJSON(map[string]interface{}{
  30025. "failed_code": -10,
  30026. "msg": res.ErrMsg,
  30027. })
  30028. return
  30029. }
  30030. }
  30031. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30032. // WebSocket服务器地址
  30033. serverURL := "ws://127.0.0.1:8899"
  30034. // 解析WebSocket服务器地址
  30035. u, err := url.Parse(serverURL)
  30036. if err != nil {
  30037. }
  30038. // 建立WebSocket连接
  30039. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30040. if err != nil {
  30041. }
  30042. defer conn.Close()
  30043. input2 := make(map[string]interface{})
  30044. input := make(map[string]interface{})
  30045. inputData := make(map[string]interface{})
  30046. inputData["orgId"] = code
  30047. inputData["businessType"] = "01101"
  30048. inputData["operatorId"] = operator_id
  30049. inputData["operatorName"] = operator_name
  30050. inputData["officeId"] = "001"
  30051. inputData["officeName"] = "血透室"
  30052. inputData["deviceType"] = ""
  30053. input["data"] = inputData
  30054. input["orgId"] = code
  30055. input["transType"] = "ec.query"
  30056. //if md == ""
  30057. if md[:4] == "4403" {
  30058. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30059. } else if md[:4] == "4401" {
  30060. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30061. } else {
  30062. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30063. }
  30064. input2["indata"] = input
  30065. fmt.Println(input2)
  30066. bytesData, _ := json.Marshal(input2)
  30067. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30068. if err != nil {
  30069. fmt.Println(err)
  30070. }
  30071. // 接收消息
  30072. _, receivedMessage, err := conn.ReadMessage()
  30073. if err != nil {
  30074. fmt.Println(err)
  30075. }
  30076. return "", string(receivedMessage)
  30077. }
  30078. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30079. // WebSocket服务器地址
  30080. serverURL := "ws://127.0.0.1:8899"
  30081. // 解析WebSocket服务器地址
  30082. u, err := url.Parse(serverURL)
  30083. if err != nil {
  30084. }
  30085. // 建立WebSocket连接
  30086. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30087. if err != nil {
  30088. }
  30089. defer conn.Close()
  30090. input2 := make(map[string]interface{})
  30091. input := make(map[string]interface{})
  30092. inputData := make(map[string]interface{})
  30093. inputData["orgId"] = code
  30094. inputData["businessType"] = "01103"
  30095. inputData["operatorId"] = operator_id
  30096. inputData["operatorName"] = operator_name
  30097. inputData["officeId"] = "001"
  30098. inputData["officeName"] = "血透室"
  30099. inputData["deviceType"] = ""
  30100. input["data"] = inputData
  30101. input["orgId"] = code
  30102. input["transType"] = "ec.query"
  30103. //if md ==
  30104. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30105. input2["indata"] = input
  30106. fmt.Println(input2)
  30107. bytesData, _ := json.Marshal(input2)
  30108. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30109. if err != nil {
  30110. fmt.Println(err)
  30111. }
  30112. // 接收消息
  30113. _, receivedMessage, err := conn.ReadMessage()
  30114. if err != nil {
  30115. fmt.Println(err)
  30116. }
  30117. return "", string(receivedMessage)
  30118. }
  30119. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30120. // WebSocket服务器地址
  30121. serverURL := "ws://127.0.0.1:8899"
  30122. // 解析WebSocket服务器地址
  30123. u, err := url.Parse(serverURL)
  30124. if err != nil {
  30125. }
  30126. // 建立WebSocket连接
  30127. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30128. if err != nil {
  30129. }
  30130. defer conn.Close()
  30131. input2 := make(map[string]interface{})
  30132. input := make(map[string]interface{})
  30133. inputData := make(map[string]interface{})
  30134. inputData["orgId"] = code
  30135. inputData["businessType"] = "01101"
  30136. inputData["operatorId"] = operator_id
  30137. inputData["operatorName"] = operator_name
  30138. inputData["officeId"] = "001"
  30139. inputData["officeName"] = "血透室"
  30140. inputData["deviceType"] = ""
  30141. input["data"] = inputData
  30142. input["orgId"] = code
  30143. input["transType"] = "ec.query"
  30144. //if md == ""
  30145. if md[:4] == "4403" {
  30146. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30147. } else if md[:4] == "4401" {
  30148. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30149. } else {
  30150. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30151. }
  30152. input2["indata"] = input
  30153. fmt.Println(input2)
  30154. bytesData, _ := json.Marshal(input2)
  30155. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30156. if err != nil {
  30157. fmt.Println(err)
  30158. }
  30159. // 接收消息
  30160. _, receivedMessage, err := conn.ReadMessage()
  30161. if err != nil {
  30162. fmt.Println(err)
  30163. }
  30164. return "", string(receivedMessage)
  30165. }
  30166. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  30167. // WebSocket服务器地址
  30168. serverURL := "ws://127.0.0.1:8899"
  30169. // 解析WebSocket服务器地址
  30170. u, err := url.Parse(serverURL)
  30171. if err != nil {
  30172. }
  30173. // 建立WebSocket连接
  30174. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30175. if err != nil {
  30176. }
  30177. defer conn.Close()
  30178. input2 := make(map[string]interface{})
  30179. input := make(map[string]interface{})
  30180. inputData := make(map[string]interface{})
  30181. inputData["orgId"] = code
  30182. inputData["businessType"] = "01301"
  30183. inputData["operatorId"] = operator_id
  30184. inputData["operatorName"] = operator_name
  30185. inputData["officeId"] = "001"
  30186. inputData["officeName"] = "血透室"
  30187. inputData["deviceType"] = ""
  30188. input["data"] = inputData
  30189. input["orgId"] = code
  30190. input["transType"] = "ec.query"
  30191. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30192. input2["indata"] = input
  30193. bytesData, _ := json.Marshal(input2)
  30194. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30195. if err != nil {
  30196. fmt.Println(err)
  30197. }
  30198. // 接收消息
  30199. _, receivedMessage, err := conn.ReadMessage()
  30200. if err != nil {
  30201. fmt.Println(err)
  30202. }
  30203. return "", string(receivedMessage)
  30204. }
  30205. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  30206. newArr = make([]string, 0)
  30207. for i := 0; i < len(arr); i++ {
  30208. repeat := false
  30209. for j := i + 1; j < len(arr); j++ {
  30210. if arr[i] == arr[j] {
  30211. repeat = true
  30212. break
  30213. }
  30214. }
  30215. if !repeat {
  30216. newArr = append(newArr, arr[i])
  30217. }
  30218. }
  30219. return
  30220. }
  30221. func getBirthdateAndAge(idNumber string) (string, int, error) {
  30222. if len(idNumber) != 18 {
  30223. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  30224. }
  30225. // 提取出生日期
  30226. year, err := strconv.Atoi(idNumber[6:10])
  30227. if err != nil {
  30228. return "", 0, err
  30229. }
  30230. month, err := strconv.Atoi(idNumber[10:12])
  30231. if err != nil {
  30232. return "", 0, err
  30233. }
  30234. day, err := strconv.Atoi(idNumber[12:14])
  30235. if err != nil {
  30236. return "", 0, err
  30237. }
  30238. // 格式化生日字符串
  30239. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  30240. birthdateFormatted := birthdate.Format("2006-01-02")
  30241. // 计算年龄
  30242. today := time.Now()
  30243. age := today.Year() - birthdate.Year()
  30244. if today.YearDay() < birthdate.YearDay() {
  30245. age--
  30246. }
  30247. return birthdateFormatted, age, nil
  30248. }