his_api_controller.go 1.3MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624
  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"
  37. "github.com/go-ole/go-ole/oleutil"
  38. )
  39. type HisApiController struct {
  40. controllers.BaseAuthAPIController
  41. }
  42. func HisManagerApiRegistRouters() {
  43. //挂号
  44. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  45. //上传就诊信息-上传明细-结算
  46. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  47. //查询
  48. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  49. //对总账
  50. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  51. //对明细
  52. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  53. //退费,退明细
  54. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  55. //退号
  56. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  57. //退明细
  58. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  59. //上传就诊信息-上传明细-预结算
  60. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  61. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  62. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  63. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  64. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  65. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  66. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  67. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  68. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  69. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  70. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  71. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  72. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  73. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  74. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  75. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  76. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  77. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  78. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  79. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  80. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  81. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  82. beego.Router("/api/check", &HisApiController{}, "get:Check")
  83. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  84. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  85. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  86. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  87. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  88. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  89. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  90. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  91. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  92. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  93. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  94. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  95. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  96. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  97. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  98. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  99. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  100. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  101. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  102. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  103. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  104. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  105. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  108. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  109. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  110. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  111. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  112. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  113. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  114. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  115. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  116. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  117. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  118. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  119. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  120. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  121. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  122. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  123. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  124. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  125. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  126. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  127. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  128. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  129. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  130. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  131. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  132. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  133. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  134. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  135. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  136. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  137. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  138. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  139. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  140. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  141. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  142. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  143. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  144. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  145. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  146. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  147. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  148. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  149. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  150. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  151. //库盘和变更
  152. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  153. //删除库盘和变更
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  155. beego.Router("/api/delete_xs_bg", &HisApiController{}, "get:DeleteXSandBG")
  156. //药品变更
  157. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  158. }
  159. func (c *HisApiController) FJ3501AND3502() {
  160. ids := c.GetString("ids")
  161. admin_user_id, _ := c.GetInt64("admin_user_id")
  162. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  163. id_arr := strings.Split(ids, ",")
  164. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  165. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. //库盘
  167. for _, drug := range drugs {
  168. if drug.IsPc == 0 && drug.IsBg == 0 {
  169. number := strconv.FormatInt(time.Now().Unix(), 10) + "-" + strconv.FormatInt(drug.ID, 10) + "-" + "3501"
  170. var struct3501 models.Struct3501
  171. struct3501.OrgName = miConfig.OrgName
  172. struct3501.AccessKey = miConfig.AccessKey
  173. struct3501.Opter = roles.UserName
  174. struct3501.RequestUrl = miConfig.Url
  175. struct3501.Url = miConfig.Url
  176. struct3501.AppId = miConfig.Cainfo
  177. struct3501.AppSecret = miConfig.AppSecret
  178. struct3501.Enckey = miConfig.EncKey
  179. struct3501.SignKey = miConfig.SignKey
  180. struct3501.SecretKey = miConfig.SecretKey
  181. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  182. struct3501.FixmedinsHilistId = miConfig.Code
  183. struct3501.FixmedinsHilistName = miConfig.OrgName
  184. struct3501.RxFlag = "0"
  185. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02")
  186. struct3501.ManuDate = time.Unix(drug.ProductDate, 0).Format("2006-01-02")
  187. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  188. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  189. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  190. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02")
  191. struct3501.FixmedinsBchno = number
  192. memo := make(map[string]interface{})
  193. memo["pric"] = drug.Price
  194. bytesData, _ := json.Marshal(memo)
  195. struct3501.Memo = string(bytesData)
  196. result1, result2, result3 := service.FJyb3501(struct3501)
  197. saveLog(result1, result2, "3501", "3501")
  198. //saveLog(result, requestLog, "2201", "挂号")
  199. fmt.Println(result1)
  200. fmt.Println(result2)
  201. fmt.Println(result3)
  202. var struct3502 models.Struct3502
  203. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  204. struct3502.FixmedinsHilistId = miConfig.Code
  205. struct3502.FixmedinsHilistName = miConfig.OrgName
  206. struct3502.FixmedinsCode = miConfig.Code
  207. struct3502.RxFlag = "0"
  208. struct3502.InvChgTime = time.Now().Format("2006-01-02")
  209. struct3502.OrgName = miConfig.OrgName
  210. struct3501.Opter = roles.UserName
  211. struct3502.AccessKey = miConfig.AccessKey
  212. struct3502.RequestUrl = miConfig.Url
  213. struct3502.SecretKey = miConfig.SecretKey
  214. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  215. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  216. struct3502.Url = miConfig.Url
  217. struct3502.AppId = miConfig.Cainfo
  218. struct3502.AppSecret = miConfig.AppSecret
  219. struct3502.Enckey = miConfig.EncKey
  220. struct3502.SignKey = miConfig.SignKey
  221. struct3502.SecretKey = miConfig.SecretKey
  222. struct3502.Memo = ""
  223. struct3502.InvChgType = "108"
  224. struct3502.FixmedinsBchno = number
  225. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  226. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  227. result11, result22, result33 := service.FJyb3502(struct3502)
  228. fmt.Println(result11)
  229. fmt.Println(result22)
  230. fmt.Println(result33)
  231. saveLog(result11, result22, "3502", "3502")
  232. }
  233. //变更
  234. if drug.IsPc == 1 && drug.IsBg == 0 {
  235. var struct3502 models.Struct3502
  236. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  237. struct3502.FixmedinsHilistId = miConfig.Code
  238. struct3502.FixmedinsHilistName = miConfig.OrgName
  239. struct3502.FixmedinsCode = miConfig.Code
  240. struct3502.Opter = roles.UserName
  241. struct3502.RxFlag = "0"
  242. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  243. struct3502.OrgName = miConfig.OrgName
  244. struct3502.AccessKey = miConfig.AccessKey
  245. struct3502.RequestUrl = miConfig.Url
  246. struct3502.SecretKey = miConfig.SecretKey
  247. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  248. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  249. struct3502.InvChgType = "108"
  250. struct3502.Url = miConfig.Url
  251. struct3502.AppId = miConfig.Cainfo
  252. struct3502.AppSecret = miConfig.AppSecret
  253. struct3502.Enckey = miConfig.EncKey
  254. struct3502.SignKey = miConfig.SignKey
  255. struct3502.SecretKey = miConfig.SecretKey
  256. struct3502.FixmedinsBchno = drug.Bchno
  257. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  258. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  259. result1, result2, result3 := service.FJyb3502(struct3502)
  260. saveLog(result1, result2, "3502", "3502")
  261. fmt.Println(result1)
  262. fmt.Println(result2)
  263. fmt.Println(result3)
  264. }
  265. }
  266. }
  267. func (c *HisApiController) DeletePCandBG() {
  268. ids := c.GetString("ids")
  269. id_arr := strings.Split(ids, ",")
  270. admin_user_id, _ := c.GetInt64("admin_user_id")
  271. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  272. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  273. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  274. for _, item := range drugs {
  275. if item.IsPc == 1 && item.IsBg == 1 {
  276. var struct3507 models.Struct3507
  277. struct3507.FixmedinsBchno = ""
  278. struct3507.InvDataType = "1"
  279. struct3507.Opter = roles.UserName
  280. struct3507.OrgName = miConfig.OrgName
  281. struct3507.AccessKey = miConfig.AccessKey
  282. struct3507.RequestUrl = miConfig.Url
  283. struct3507.SecretKey = miConfig.SecretKey
  284. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  285. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  286. struct3507.Url = miConfig.Url
  287. struct3507.AppId = miConfig.Cainfo
  288. struct3507.AppSecret = miConfig.AppSecret
  289. struct3507.Enckey = miConfig.EncKey
  290. struct3507.SignKey = miConfig.SignKey
  291. struct3507.SecretKey = miConfig.SecretKey
  292. service.FJyb3507(struct3507)
  293. var struct3507_2 models.Struct3507
  294. struct3507_2.OrgName = miConfig.OrgName
  295. struct3507_2.AccessKey = miConfig.AccessKey
  296. struct3507_2.RequestUrl = miConfig.Url
  297. struct3507_2.SecretKey = miConfig.SecretKey
  298. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  299. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  300. struct3507_2.Url = miConfig.Url
  301. struct3507_2.AppId = miConfig.Cainfo
  302. struct3507_2.AppSecret = miConfig.AppSecret
  303. struct3507_2.Enckey = miConfig.EncKey
  304. struct3507_2.SignKey = miConfig.SignKey
  305. struct3507_2.SecretKey = miConfig.SecretKey
  306. struct3507_2.FixmedinsBchno = ""
  307. struct3507_2.InvDataType = "2"
  308. service.FJyb3507(struct3507_2)
  309. }
  310. if item.IsPc == 1 && item.IsBg == 0 {
  311. var struct3507 models.Struct3507
  312. struct3507.OrgName = miConfig.OrgName
  313. struct3507.AccessKey = miConfig.AccessKey
  314. struct3507.RequestUrl = miConfig.Url
  315. struct3507.SecretKey = miConfig.SecretKey
  316. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  317. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  318. struct3507.Url = miConfig.Url
  319. struct3507.AppId = miConfig.Cainfo
  320. struct3507.AppSecret = miConfig.AppSecret
  321. struct3507.Enckey = miConfig.EncKey
  322. struct3507.SignKey = miConfig.SignKey
  323. struct3507.SecretKey = miConfig.SecretKey
  324. struct3507.FixmedinsBchno = ""
  325. struct3507.InvDataType = "1"
  326. service.FJyb3507(struct3507)
  327. }
  328. }
  329. }
  330. func (c *HisApiController) DeleteXSandBG() {
  331. ids := c.GetString("ids")
  332. id_arr := strings.Split(ids, ",")
  333. admin_user_id, _ := c.GetInt64("admin_user_id")
  334. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  335. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  336. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  337. for _, item := range drugs {
  338. if item.IsPc == 1 && item.IsBg == 1 {
  339. var struct3507 models.Struct3507
  340. struct3507.FixmedinsBchno = ""
  341. struct3507.InvDataType = "1"
  342. struct3507.Opter = roles.UserName
  343. struct3507.OrgName = miConfig.OrgName
  344. struct3507.AccessKey = miConfig.AccessKey
  345. struct3507.RequestUrl = miConfig.Url
  346. struct3507.SecretKey = miConfig.SecretKey
  347. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  348. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  349. struct3507.Url = miConfig.Url
  350. struct3507.AppId = miConfig.Cainfo
  351. struct3507.AppSecret = miConfig.AppSecret
  352. struct3507.Enckey = miConfig.EncKey
  353. struct3507.SignKey = miConfig.SignKey
  354. struct3507.SecretKey = miConfig.SecretKey
  355. struct3507.FixmedinsBchno = ""
  356. struct3507.InvDataType = "1"
  357. service.FJyb3507(struct3507)
  358. var struct3507_2 models.Struct3507
  359. struct3507_2.OrgName = miConfig.OrgName
  360. struct3507_2.AccessKey = miConfig.AccessKey
  361. struct3507_2.RequestUrl = miConfig.Url
  362. struct3507_2.SecretKey = miConfig.SecretKey
  363. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  364. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  365. struct3507_2.FixmedinsBchno = ""
  366. struct3507_2.InvDataType = "2"
  367. struct3507_2.Url = miConfig.Url
  368. struct3507_2.AppId = miConfig.Cainfo
  369. struct3507_2.AppSecret = miConfig.AppSecret
  370. struct3507_2.Enckey = miConfig.EncKey
  371. struct3507_2.SignKey = miConfig.SignKey
  372. struct3507_2.SecretKey = miConfig.SecretKey
  373. struct3507_2.FixmedinsBchno = ""
  374. struct3507_2.InvDataType = "1"
  375. service.FJyb3507(struct3507_2)
  376. }
  377. if item.IsPc == 1 && item.IsBg == 0 {
  378. var struct3507 models.Struct3507
  379. struct3507.OrgName = miConfig.OrgName
  380. struct3507.AccessKey = miConfig.AccessKey
  381. struct3507.RequestUrl = miConfig.Url
  382. struct3507.SecretKey = miConfig.SecretKey
  383. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  384. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  385. struct3507.FixmedinsBchno = ""
  386. struct3507.InvDataType = "1"
  387. service.FJyb3507(struct3507)
  388. }
  389. }
  390. }
  391. func (c *HisApiController) ChangeDrug() {
  392. ids := c.GetString("ids")
  393. id_arr := strings.Split(ids, ",")
  394. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  395. admin_user_id, _ := c.GetInt64("admin_user_id")
  396. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  397. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  398. for _, item := range flows {
  399. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  400. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  401. if prescription.OrderStatus == 2 { //已经结算
  402. //判断是否已经销售
  403. if item.IsSale == 1 { //是否已经销售,1是 0否
  404. //是否已经变更 1是 0否
  405. if item.IsChange == 0 { //没变更,进行变更操作
  406. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  407. }
  408. } else { //没销售,
  409. //进行商品销售接口
  410. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "", roles)
  411. if item.IsChange == 0 { //没变更,进行变更操作
  412. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  413. }
  414. }
  415. } else { //还没结算
  416. if item.IsChange == 0 { //没变更,进行变更操作
  417. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  418. }
  419. }
  420. } else if item.ConsumableType == 7 {
  421. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  422. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  423. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  424. //判断是否已经销售
  425. if item.IsSale == 1 { //是否已经销售,1是 0否
  426. //是否已经变更 1是 0否
  427. if item.IsChange == 0 { //没变更,进行变更操作
  428. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  429. }
  430. } else { //没销售,
  431. //进行商品销售退货接口
  432. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  433. if item.IsChange == 0 { //没变更,进行变更操作
  434. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  435. }
  436. }
  437. } else { //还没结算
  438. if item.IsChange == 0 { //没变更,进行变更操作
  439. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  440. }
  441. }
  442. } else { //其他方式
  443. if item.IsChange == 0 { //没变更,进行变更操作
  444. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102", roles)
  445. }
  446. }
  447. }
  448. }
  449. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  450. var struct3502 models.Struct3502
  451. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  452. struct3502.FixmedinsHilistId = miConfig.Code
  453. struct3502.FixmedinsHilistName = miConfig.OrgName
  454. struct3502.FixmedinsCode = miConfig.Code
  455. struct3502.Opter = role.UserName
  456. struct3502.RxFlag = "0"
  457. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  458. struct3502.OrgName = miConfig.OrgName
  459. struct3502.AccessKey = miConfig.AccessKey
  460. struct3502.RequestUrl = miConfig.Url
  461. struct3502.SecretKey = miConfig.SecretKey
  462. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  463. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  464. struct3502.Url = miConfig.Url
  465. struct3502.AppId = miConfig.Cainfo
  466. struct3502.AppSecret = miConfig.AppSecret
  467. struct3502.Enckey = miConfig.EncKey
  468. struct3502.SignKey = miConfig.SignKey
  469. struct3502.SecretKey = miConfig.SecretKey
  470. struct3502.InvChgType = chgType
  471. struct3502.FixmedinsBchno = ""
  472. struct3502.Cnt = strconv.FormatInt(count, 10)
  473. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  474. result1, result2, result3 := service.FJyb3502(struct3502)
  475. fmt.Println(result1)
  476. fmt.Println(result2)
  477. fmt.Println(result3)
  478. }
  479. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string, role models.UserAdminRole) {
  480. var struct3505 models.Struct3505
  481. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  482. struct3505.FixmedinsHilistId = miConfig.Code
  483. struct3505.FixmedinsHilistName = miConfig.OrgName
  484. struct3505.FixmedinsCode = miConfig.Code
  485. struct3505.FixmedinsBchno = ""
  486. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  487. struct3505.PrscDrName = roles.UserName
  488. struct3505.PharName = ""
  489. struct3505.PharPracCertNo = ""
  490. order := service.GetHisOrderByNumber(pre.BatchNumber)
  491. struct3505.SetlId = order.SetlId
  492. struct3505.MdtrtSn = order.MdtrtId
  493. struct3505.ManuLotnum = ""
  494. struct3505.ManuDate = ""
  495. struct3505.ExpyEnd = ""
  496. struct3505.RxFlag = "0"
  497. struct3505.TrdnFlag = "1"
  498. struct3505.Url = miConfig.Url
  499. struct3505.AppId = miConfig.Cainfo
  500. struct3505.AppSecret = miConfig.AppSecret
  501. struct3505.Enckey = miConfig.EncKey
  502. struct3505.SignKey = miConfig.SignKey
  503. struct3505.SecretKey = miConfig.SecretKey
  504. struct3505.RtalDocno = order.Number
  505. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  506. struct3505.SelRetnCnt = strValue
  507. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  508. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  509. struct3505.SelRetnOpterName = roles_two.UserName
  510. if order.IsMedicineInsurance == 1 {
  511. struct3505.MdtrtSetlType = "1"
  512. } else {
  513. struct3505.MdtrtSetlType = "2"
  514. }
  515. struct3505.OrgName = miConfig.OrgName
  516. struct3505.AccessKey = miConfig.AccessKey
  517. struct3505.RequestUrl = miConfig.Url
  518. struct3505.SecretKey = miConfig.SecretKey
  519. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  520. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  521. result1, result2, result3 := service.FJyb3505(struct3505)
  522. fmt.Println(result1)
  523. fmt.Println(result2)
  524. fmt.Println(result3)
  525. }
  526. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  527. var struct3506 models.Struct3506
  528. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  529. struct3506.FixmedinsHilistId = miConfig.Code
  530. struct3506.FixmedinsHilistName = miConfig.OrgName
  531. struct3506.FixmedinsCode = miConfig.Code
  532. struct3506.FixmedinsBchno = ""
  533. order := service.GetHisOrderByNumber(pre.BatchNumber)
  534. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  535. struct3506.ManuLotnum = ""
  536. struct3506.ManuDate = ""
  537. struct3506.MdtrtSn = order.MdtrtId
  538. struct3506.ExpyEnd = ""
  539. struct3506.RxFlag = "0"
  540. struct3506.TrdnFlag = "1"
  541. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  542. struct3506.SelRetnCnt = strValue
  543. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  544. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  545. struct3506.SelRetnOpterName = roles_two.UserName
  546. struct3506.OrgName = miConfig.OrgName
  547. struct3506.AccessKey = miConfig.AccessKey
  548. struct3506.RequestUrl = miConfig.Url
  549. struct3506.SecretKey = miConfig.SecretKey
  550. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  551. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  552. struct3506.Url = miConfig.Url
  553. struct3506.AppId = miConfig.Cainfo
  554. struct3506.AppSecret = miConfig.AppSecret
  555. struct3506.Enckey = miConfig.EncKey
  556. struct3506.SignKey = miConfig.SignKey
  557. struct3506.SecretKey = miConfig.SecretKey
  558. result1, result2, result3 := service.FJyb3506(struct3506)
  559. fmt.Println(result1)
  560. fmt.Println(result2)
  561. fmt.Println(result3)
  562. }
  563. func (c *HisApiController) Get1318() {
  564. adminUser := c.GetAdminUserInfo()
  565. admin_user_id, _ := c.GetInt64("admin_user_id")
  566. code := c.GetString("code")
  567. code = ""
  568. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  569. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  570. api := ""
  571. if miConfig.MdtrtareaAdmvs == "320921" {
  572. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  573. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  574. } else {
  575. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  576. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  577. }
  578. resp, requestErr := http.Get(api)
  579. if requestErr != nil {
  580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  581. return
  582. }
  583. body, ioErr := ioutil.ReadAll(resp.Body)
  584. if ioErr != nil {
  585. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  587. return
  588. }
  589. var respJSON map[string]interface{}
  590. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  591. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. //var res Result2406
  596. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  597. result, _ := json.Marshal(respJSON)
  598. if err := json.Unmarshal([]byte(result), &res); err != nil {
  599. utils.ErrorLog("解析失败:%v", err)
  600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  601. return
  602. }
  603. if res.Infcode == "0" {
  604. c.ServeSuccessJSON(map[string]interface{}{
  605. "result": "",
  606. })
  607. } else {
  608. c.ServeSuccessJSON(map[string]interface{}{
  609. "failed_code": -10,
  610. "msg": res.ErrMsg,
  611. })
  612. */return
  613. //}
  614. }
  615. func (c *HisApiController) Get2503() {
  616. adminUser := c.GetAdminUserInfo()
  617. admin_user_id, _ := c.GetInt64("admin_user_id")
  618. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  619. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  620. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  621. }
  622. func (c *HisApiController) Get2406() {
  623. id, _ := c.GetInt64("id")
  624. record_time := c.GetString("record_time")
  625. his_patient_id, _ := c.GetInt64("his_patient_id")
  626. admin_user_id, _ := c.GetInt64("admin_user_id")
  627. diagnosis_id := c.GetString("diagnosis")
  628. timeLayout := "2006-01-02"
  629. loc, _ := time.LoadLocation("Local")
  630. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  631. if err != nil {
  632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  633. return
  634. }
  635. recordDateTime := theTime.Unix()
  636. adminUser := c.GetAdminUserInfo()
  637. diagnosis_ids := strings.Split(diagnosis_id, ",")
  638. var config []*models.HisXtDiagnoseConfig
  639. for _, item := range diagnosis_ids {
  640. id, _ := strconv.ParseInt(item, 10, 64)
  641. diagnosisConfig, _ := service.FindDiagnoseById(id)
  642. config = append(config, &diagnosisConfig)
  643. }
  644. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  645. fmt.Println(his_patient_id)
  646. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  647. //timestamp := time.Now().Unix()
  648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  649. var patientPrescription models.HisPrescriptionInfo
  650. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  651. if patientPrescription.ID == 0 {
  652. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  653. }
  654. var res2 Result2406
  655. if miConfig.MdtrtareaAdmvs == "341203" {
  656. data := make(map[string]interface{})
  657. client := &http.Client{}
  658. data["psn_no"] = his.PsnNo
  659. data["mdtrt_id"] = his.Number
  660. data["operator"] = roles.UserName
  661. data["cert_no"] = his.IdCardNo
  662. data["org_name"] = miConfig.OrgName
  663. data["psn_name"] = his.Name
  664. data["ipt_otp_no"] = his.IptOtpNo
  665. data["ipt_psn_sp_flag_type"] = "0901"
  666. data["ipt_psn_sp_flag"] = "1"
  667. data["fixmedins_code"] = miConfig.Code
  668. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  669. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  670. data["url"] = miConfig.Url
  671. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  672. bytesData, _ := json.Marshal(data)
  673. var req *http.Request
  674. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  675. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  676. resp, _ := client.Do(req)
  677. defer resp.Body.Close()
  678. body, ioErr := ioutil.ReadAll(resp.Body)
  679. if ioErr != nil {
  680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  682. return
  683. }
  684. var respJSON map[string]interface{}
  685. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  688. return
  689. }
  690. status := respJSON["data"].(map[string]interface{})["status"].(string)
  691. if status == "0" {
  692. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  693. c.ServeSuccessJSON(map[string]interface{}{
  694. "failed_code": -10,
  695. "msg": err_msg,
  696. })
  697. return
  698. }
  699. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  700. userJSONBytes, _ := json.Marshal(respJSON)
  701. fmt.Println("log")
  702. fmt.Println(string(userJSONBytes))
  703. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  704. utils.ErrorLog("解析失败:%v", err)
  705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  706. return
  707. }
  708. }
  709. if res2.Infcode != 0 {
  710. adminUser := c.GetAdminUserInfo()
  711. errlog := &models.HisOrderError{
  712. UserOrgId: adminUser.CurrentOrgId,
  713. Ctime: time.Now().Unix(),
  714. Mtime: time.Now().Unix(),
  715. ErrMsg: res2.ErrMsg,
  716. Status: 1,
  717. PatientId: id,
  718. RecordTime: recordDateTime,
  719. Stage: 3,
  720. }
  721. service.CreateErrMsgLog(errlog)
  722. c.ServeSuccessJSON(map[string]interface{}{
  723. "failed_code": -10,
  724. "msg": res2.ErrMsg,
  725. })
  726. return
  727. } else {
  728. c.ServeSuccessJSON(map[string]interface{}{
  729. "msg": "上传成功",
  730. })
  731. return
  732. }
  733. }
  734. func (c *HisApiController) Get4105() {
  735. }
  736. func (c *HisApiController) Post5302() {
  737. patient_id, _ := c.GetInt64("id")
  738. admin_user_id, _ := c.GetInt64("admin_user_id")
  739. p, _ := service.GetHisPatientById(patient_id)
  740. adminUser := c.GetAdminUserInfo()
  741. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  742. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  743. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  744. }
  745. func (c *HisApiController) Get4104() {
  746. }
  747. type Output struct {
  748. CertNo string `json:"certno"`
  749. PsnName string `json:"psn_name"`
  750. CardNo string `json:"card_no"`
  751. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  752. CardSN string `json:"card_sn"`
  753. PsnCertType string `json:"psn_cert_type"`
  754. MdtrtCertNo string `json:"mdtrt_cert_no"`
  755. MdtrtCertType string `json:"mdtrt_cert_type"`
  756. QRCode string `json:"qrCode"`
  757. EcToken string `json:"ecToken"`
  758. }
  759. type AHResponse struct {
  760. Body AHBody `json:"body"`
  761. Code int `json:"code"`
  762. CSBCode int `json:"csbCode"`
  763. Message string `json:"message"`
  764. RequestID string `json:"requestId"`
  765. State struct{} `json:"state"`
  766. }
  767. type AHBody struct {
  768. ErrMsg string `json:"err_msg"`
  769. InfRefMsgID string `json:"inf_refmsgid"`
  770. InfCode int `json:"infcode"`
  771. Output struct {
  772. Result []struct {
  773. BasMednFlag string `json:"bas_medn_flag"`
  774. ChldMedcFlag string `json:"chld_medc_flag"`
  775. ChrgitmLv string `json:"chrgitm_lv"`
  776. Cnt float64 `json:"cnt"`
  777. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  778. DrtReimFlag string `json:"drt_reim_flag"`
  779. FeedetlSn string `json:"feedetl_sn"`
  780. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  781. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  782. InscpScpAmt float64 `json:"inscp_scp_amt"`
  783. ListSpItemFlag string `json:"list_sp_item_flag"`
  784. LmtUsedFlag string `json:"lmt_used_flag"`
  785. MedChrgitmType string `json:"med_chrgitm_type"`
  786. Memo string `json:"memo"`
  787. OverlmtAmt float64 `json:"overlmt_amt"`
  788. PreselfpayAmt float64 `json:"preselfpay_amt"`
  789. Pric float64 `json:"pric"`
  790. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  791. SelfpayProp float64 `json:"selfpay_prop"`
  792. } `json:"result"`
  793. } `json:"output"`
  794. }
  795. type Response struct {
  796. Output Output `json:"output"`
  797. Infcode int `json:"infcode"`
  798. InfRefMsgID string `json:"inf_refmsgid"`
  799. RefMsgTime string `json:"refmsg_time"`
  800. RespondTime string `json:"respond_time"`
  801. ErrMsg string `json:"err_msg"`
  802. WarnMsg string `json:"warn_msg"`
  803. SignType string `json:"signtype"`
  804. CAInfo string `json:"cainfo"`
  805. }
  806. func (c *HisApiController) Getquerydata() {
  807. query_type, _ := c.GetInt64("type")
  808. refd_setl_flag := c.GetString("refd_setl_flag")
  809. med_type := c.GetString("med_type")
  810. //admin_user_id,_ := c.GetInt64("admin_user_id")
  811. cert_no := c.GetString("cert_no")
  812. psn_no := c.GetString("psn_no")
  813. start_time := c.GetString("start_time")
  814. end_time := c.GetString("end_time")
  815. page, _ := c.GetInt64("page")
  816. limit, _ := c.GetInt64("limit")
  817. var bp models.BusinessParams5262
  818. bp.RefdSetlFlag = refd_setl_flag
  819. bp.MedType = med_type
  820. bp.Certno = cert_no
  821. bp.Psnno = psn_no
  822. bp.QBegntime = start_time
  823. bp.QEndtime = end_time
  824. if query_type == 1 { //本地
  825. Post5262(c, bp, page, limit)
  826. } else { //异地
  827. Post5267(c, bp, page, limit)
  828. }
  829. }
  830. func (c *HisApiController) Drugscheck() {
  831. admin_user_id, _ := c.GetInt64("admin_user_id")
  832. adminUser := c.GetAdminUserInfo()
  833. var queryResult []QueryResult
  834. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  835. for _, item := range drugs {
  836. result := QueryResult{
  837. ID: item.ID,
  838. Name: item.DrugName,
  839. Code: item.MedicalInsuranceNumber,
  840. List_type_code: "101",
  841. }
  842. queryResult = append(queryResult, result)
  843. }
  844. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  845. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  846. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  847. for _, item := range queryResult {
  848. 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)
  849. }
  850. }
  851. func (c *HisApiController) Goodcheck() {
  852. admin_user_id, _ := c.GetInt64("admin_user_id")
  853. adminUser := c.GetAdminUserInfo()
  854. var queryResult []QueryResult
  855. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  856. for _, item := range goods {
  857. result := QueryResult{
  858. ID: item.ID,
  859. Name: item.GoodName,
  860. Code: item.SocialSecurityDirectoryCode,
  861. List_type_code: "301",
  862. }
  863. queryResult = append(queryResult, result)
  864. }
  865. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  866. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  867. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  868. for _, item := range queryResult {
  869. 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)
  870. //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)
  871. }
  872. }
  873. func (c *HisApiController) Projectcheck() {
  874. admin_user_id, _ := c.GetInt64("admin_user_id")
  875. adminUser := c.GetAdminUserInfo()
  876. var queryResult []QueryResult
  877. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  878. for _, item := range projects {
  879. result := QueryResult{
  880. ID: item.ID,
  881. Name: item.ProjectName,
  882. Code: item.MedicalCode,
  883. List_type_code: "201",
  884. }
  885. queryResult = append(queryResult, result)
  886. }
  887. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  888. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  889. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  890. for _, item := range queryResult {
  891. 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)
  892. }
  893. }
  894. //func (c *HisApiController)CancleDia(){
  895. //
  896. // id, _ := c.GetInt64("id")
  897. // record_time := c.GetString("record_time")
  898. // his_patient_id, _ := c.GetInt64("his_patient_id")
  899. //
  900. // admin_user_id, _ := c.GetInt64("admin_user_id")
  901. //
  902. // diagnosis_id := c.GetString("diagnosis")
  903. // sick_type, _ := c.GetInt64("sick_type")
  904. // reg_type, _ := c.GetInt64("p_type")
  905. // begin_time := c.GetString("begin_time")
  906. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  907. //
  908. //
  909. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  910. //
  911. // fmt.Println(acct_used_flag)
  912. //
  913. //
  914. // timeLayout := "2006-01-02"
  915. // loc, _ := time.LoadLocation("Local")
  916. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  917. // if err != nil {
  918. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  919. // return
  920. // }
  921. // recordDateTime := theTime.Unix()
  922. // adminUser := c.GetAdminUserInfo()
  923. //
  924. //
  925. //
  926. //
  927. //
  928. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  929. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  930. // var patientPrescription models.HisPrescriptionInfo
  931. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  932. // if patientPrescription.ID == 0 {
  933. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  934. // }
  935. // //if patientPrescription.Do
  936. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  937. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  938. //
  939. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  940. //
  941. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  942. //
  943. // var config []*models.HisXtDiagnoseConfig
  944. // for _, item := range diagnosis_ids {
  945. // id, _ := strconv.ParseInt(item, 10, 64)
  946. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  947. // config = append(config, &diagnosisConfig)
  948. // }
  949. //
  950. // sickConfig, _ := service.FindSickById(sick_type)
  951. //
  952. //
  953. // data := make(map[string]interface{})
  954. // client := &http.Client{}
  955. // data["psn_no"] = his.PsnNo
  956. // data["mdtrt_id"] = his.Number
  957. // data["doctor"] = roles.UserName
  958. // data["department"] = department.Name
  959. // data["org_name"] = miConfig.OrgName
  960. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  961. // data["doctor_id"] = doctor_info.DoctorNumber
  962. // data["new_doctor_name"] = doctor_info.UserName
  963. // data["fixmedins_code"] = miConfig.Code
  964. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  965. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  966. // data["secret_key"] = miConfig.SecretKey
  967. // data["sick_code"] = sickConfig.CountryCode
  968. // data["sick_name"] = sickConfig.ClassName
  969. // data["url"] = miConfig.Url
  970. // data["ak"] = miConfig.AccessKey
  971. // data["begin_time"] = begin_time
  972. // data["cainfo"] = miConfig.Cainfo
  973. // data["is_vaild"] = "0"
  974. //
  975. // data["dept"] = strconv.FormatInt(department.ID, 10)
  976. // data["config"] = config
  977. // bytesData, _ := json.Marshal(data)
  978. //
  979. // var req *http.Request
  980. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  981. // resp, _ := client.Do(req)
  982. // defer resp.Body.Close()
  983. // body, ioErr := ioutil.ReadAll(resp.Body)
  984. // if ioErr != nil {
  985. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  987. // return
  988. // }
  989. // var respJSON map[string]interface{}
  990. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  991. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. // return
  994. // }
  995. //
  996. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  997. // userJSONBytes, _ := json.Marshal(respJSON)
  998. // fmt.Println("log")
  999. // fmt.Println(string(userJSONBytes))
  1000. //
  1001. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  1002. // utils.ErrorLog("解析失败:%v", err)
  1003. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1004. // return
  1005. // }
  1006. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  1007. // res2.Output = ressix10265.Output
  1008. // res2.ErrMsg = ressix10265.ErrMsg
  1009. // res2.Cainfo = ressix10265.Cainfo
  1010. // res2.WarnMsg = ressix10265.WarnMsg
  1011. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  1012. // res2.Infcode = infocode
  1013. //
  1014. //}
  1015. func (c *HisApiController) Get4102() {
  1016. order_id, _ := c.GetInt64("order_id")
  1017. admin_user_id, _ := c.GetInt64("admin_user_id")
  1018. stas_type := c.GetString("stas_type")
  1019. order, _ := service.GetHisOrderByIDTwo(order_id)
  1020. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1021. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1022. var pp models.PublicParams
  1023. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1024. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1025. pp.FixmedinsName = miConfig.OrgName
  1026. pp.FixmedinsCode = miConfig.Code
  1027. pp.RequestUrl = miConfig.Url
  1028. pp.Cainfo = miConfig.Cainfo
  1029. pp.SecretKey = miConfig.SecretKey
  1030. pp.AccessKey = miConfig.AccessKey
  1031. pp.OpterName = curRoles.UserName
  1032. if miConfig.MdtrtareaAdmvs == "350500" {
  1033. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1034. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  1035. saveLog(result, request, "4102", "清单确认")
  1036. var dat map[string]interface{}
  1037. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1038. fmt.Println(dat)
  1039. } else {
  1040. fmt.Println(err)
  1041. }
  1042. var empty ResultFourteen
  1043. userJSONBytes, _ := json.Marshal(dat)
  1044. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1045. utils.ErrorLog("解析失败:%v", err)
  1046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1047. return
  1048. }
  1049. if empty.Infcode == 0 {
  1050. c.ServeSuccessJSON(map[string]interface{}{
  1051. "msg": "确认成功",
  1052. })
  1053. return
  1054. }
  1055. } else {
  1056. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  1057. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  1058. result3, request3 := service.Jxyb4105(pp)
  1059. saveLog(result, request, "4102", "清单确认")
  1060. saveLog(result2, request2, "4103", "清单确认")
  1061. saveLog(result3, request3, "4105", "清单统计")
  1062. var dat map[string]interface{}
  1063. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1064. fmt.Println(dat)
  1065. } else {
  1066. fmt.Println(err)
  1067. }
  1068. var empty ResultFourteen
  1069. userJSONBytes, _ := json.Marshal(dat)
  1070. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  1071. utils.ErrorLog("解析失败:%v", err)
  1072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1073. return
  1074. }
  1075. if empty.Infcode == 0 {
  1076. c.ServeSuccessJSON(map[string]interface{}{
  1077. "msg": "确认成功",
  1078. })
  1079. return
  1080. }
  1081. }
  1082. }
  1083. // 对账权限查询
  1084. func (c *HisApiController) Get3260() {
  1085. admin_user_id, _ := c.GetInt64("admin_user_id")
  1086. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1087. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1088. var api string
  1089. var res models.JSResult3260
  1090. if miConfig.MdtrtareaAdmvs == "320921" {
  1091. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1092. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1093. } else {
  1094. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1095. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1096. }
  1097. resp, requestErr := http.Get(api)
  1098. if requestErr != nil {
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1100. return
  1101. }
  1102. body, ioErr := ioutil.ReadAll(resp.Body)
  1103. if ioErr != nil {
  1104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1106. return
  1107. }
  1108. var respJSON map[string]interface{}
  1109. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1112. return
  1113. }
  1114. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1115. result, _ := json.Marshal(respJSON)
  1116. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1117. utils.ErrorLog("解析失败:%v", err)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1119. return
  1120. }
  1121. if res.Infcode == "0" {
  1122. c.ServeSuccessJSON(map[string]interface{}{
  1123. "result": res.Output.Data,
  1124. })
  1125. } else {
  1126. c.ServeSuccessJSON(map[string]interface{}{
  1127. "failed_code": -10,
  1128. "msg": res.ErrMsg,
  1129. })
  1130. return
  1131. }
  1132. }
  1133. func (c *HisApiController) Get3261() {
  1134. admin_user_id, _ := c.GetInt64("admin_user_id")
  1135. //month := c.GetString("month")
  1136. startTime := c.GetString("start_time")
  1137. //endTime, _ := c.GetString("end_time")
  1138. times := strings.Split(startTime, "-")
  1139. stmt_mon := times[0] + times[1]
  1140. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1141. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1142. var api string
  1143. var res models.JSResult3261
  1144. //var res10265 Result5301For10265
  1145. if miConfig.MdtrtareaAdmvs == "320921" {
  1146. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1147. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1148. } else {
  1149. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1150. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1151. }
  1152. resp, requestErr := http.Get(api)
  1153. if requestErr != nil {
  1154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1155. return
  1156. }
  1157. body, ioErr := ioutil.ReadAll(resp.Body)
  1158. if ioErr != nil {
  1159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1161. return
  1162. }
  1163. var respJSON map[string]interface{}
  1164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1167. return
  1168. }
  1169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1170. result, _ := json.Marshal(respJSON)
  1171. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1172. utils.ErrorLog("解析失败:%v", err)
  1173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1174. return
  1175. }
  1176. if res.Infcode == "0" {
  1177. c.ServeSuccessJSON(map[string]interface{}{
  1178. "result": res.Output,
  1179. })
  1180. } else {
  1181. c.ServeSuccessJSON(map[string]interface{}{
  1182. "failed_code": -10,
  1183. "msg": res.ErrMsg,
  1184. })
  1185. return
  1186. }
  1187. }
  1188. type TempFun struct {
  1189. FundKey string
  1190. FundCode string
  1191. }
  1192. func (c *HisApiController) Get3262() {
  1193. admin_user_id, _ := c.GetInt64("admin_user_id")
  1194. startTime := c.GetString("start_time")
  1195. endTime := c.GetString("end_time")
  1196. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1197. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1198. //timeLayout := "2006-01-02"
  1199. //loc, _ := time.LoadLocation("Local")
  1200. //var theStartTIme int64
  1201. //if len(startTime) > 0 {
  1202. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1203. // if err != nil {
  1204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1205. // return
  1206. // }
  1207. // theStartTIme = theTime.Unix()
  1208. //}
  1209. //var theEndtTIme int64
  1210. //if len(endTime) > 0 {
  1211. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1212. // if err != nil {
  1213. // utils.ErrorLog(err.Error())
  1214. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1215. // return
  1216. // }
  1217. // theEndtTIme = theTime.Unix()
  1218. //}
  1219. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1220. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1221. for _, team := range datas {
  1222. fmt.Println(team.PsnTime)
  1223. for _, team_two := range datas_two {
  1224. fmt.Println(team_two.PsnTime)
  1225. if team.FundKey == team_two.FundKey {
  1226. fmt.Println(team_two.PsnTime)
  1227. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1228. fmt.Println(team.PsnTime)
  1229. }
  1230. }
  1231. }
  1232. fmt.Println("1111")
  1233. fmt.Println(datas)
  1234. fmt.Println("1111")
  1235. var twos []models.FixMonRecDetailFileInTwo
  1236. for _, team := range datas {
  1237. var two models.FixMonRecDetailFileInTwo
  1238. two.MedType = team.MedType
  1239. two.Insutype = team.Insutype
  1240. two.PsnType = team.PsnType
  1241. two.MedType = team.MedType
  1242. two.FixBlngAdmdvs = "999999"
  1243. two.InsuAdmdvs = "555555"
  1244. two.PsnTime = team.PsnTime
  1245. two.PsnCnt = team.PsnCnt
  1246. two.FundKey = team.FundKey
  1247. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1248. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1249. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1250. two.MedfeeSumAmt = ms
  1251. two.InscpAmt = ia
  1252. two.FundPaySumAmt = fps
  1253. twos = append(twos, two)
  1254. }
  1255. //startTime := c.GetString("start_time")
  1256. //endTime, _ := c.GetString("end_time")
  1257. times := strings.Split(startTime, "-")
  1258. stmt_mon := times[0] + times[1]
  1259. var funs []models.FundDetail
  1260. for _, item := range datas {
  1261. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1262. funs = append(funs, fun...)
  1263. }
  1264. var funInfos []models.Fund
  1265. //for _, item := range funs {
  1266. // var rf []models.FundInfo
  1267. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1268. // for _, subitem := range rf {
  1269. // var fund models.Fund
  1270. // fund.FundCode = subitem.FundPayType
  1271. // fund.FundName = subitem.FundPayTypeName
  1272. // fund.FundAmt = subitem.FundPayAmt
  1273. // fund.FundKey = item.FundKey
  1274. // fund.InsuAdmdvs = "555555"
  1275. // fund.FixBlngAdmdvs = "999999"
  1276. // funInfos = append(funInfos, fund)
  1277. // }
  1278. //}
  1279. var tempFuns []TempFun
  1280. for _, funInfo := range funInfos {
  1281. var tempFun TempFun
  1282. tempFun.FundKey = funInfo.FundKey
  1283. tempFun.FundCode = funInfo.FundCode
  1284. tempFuns = append(tempFuns, tempFun)
  1285. }
  1286. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1287. fmt.Println(tempFuns)
  1288. var funInfosTwo []models.Fund
  1289. decimal.DivisionPrecision = 2
  1290. for _, item := range tempFuns {
  1291. var fund models.Fund
  1292. for _, subItem := range funInfos {
  1293. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1294. fund.FundKey = subItem.FundKey
  1295. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1296. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1297. fund.FundName = subItem.FundName
  1298. fund.FundCode = subItem.FundCode
  1299. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1300. }
  1301. }
  1302. funInfosTwo = append(funInfosTwo, fund)
  1303. }
  1304. fmt.Println("funInfosTwo")
  1305. fmt.Println(funInfosTwo)
  1306. var upld_btch string
  1307. var empty models.JSResultEmpty
  1308. data := make(map[string]interface{})
  1309. data["org_name"] = miConfig.OrgName
  1310. data["doctor"] = curRoles.UserName
  1311. data["doctor_name"] = curRoles.UserName
  1312. data["fixmedins_code"] = miConfig.Code
  1313. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1315. data["secret_key"] = miConfig.SecretKey
  1316. data["url"] = miConfig.Url
  1317. data["ak"] = miConfig.AccessKey
  1318. data["cainfo"] = miConfig.Cainfo
  1319. data["datas"] = twos
  1320. data["fund"] = funInfosTwo
  1321. fmt.Println(twos)
  1322. month := time.Unix(1557042972, 0).Format("1")
  1323. year := time.Now().Format("2006")
  1324. month = time.Now().Format("01")
  1325. day := time.Now().Format("02")
  1326. hour := time.Now().Format("15")
  1327. min := time.Now().Format("04")
  1328. sec := time.Now().Format("05")
  1329. fix_fill_date := year + month + day + hour + min + sec
  1330. data["fix_fill_dept"] = miConfig.OrgName
  1331. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1332. data["fix_fill_psn"] = curRoles.UserName
  1333. data["fix_fill_date"] = fix_fill_date
  1334. data["stmt_loc"] = "2"
  1335. data["setl_mon"] = stmt_mon
  1336. upld_btch = "0"
  1337. data["upld_btch"] = upld_btch
  1338. //fmt.Println(data)
  1339. client := &http.Client{}
  1340. bytesData, _ := json.Marshal(data)
  1341. var req *http.Request
  1342. if miConfig.MdtrtareaAdmvs == "320921" {
  1343. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1344. } else {
  1345. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1346. }
  1347. resp, _ := client.Do(req)
  1348. defer resp.Body.Close()
  1349. body, ioErr := ioutil.ReadAll(resp.Body)
  1350. if ioErr != nil {
  1351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. }
  1354. var respJSON map[string]interface{}
  1355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. }
  1359. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1360. //fmt.Println(respJSON)
  1361. result, _ := json.Marshal(respJSON)
  1362. //fmt.Println(result)
  1363. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1364. utils.ErrorLog("解析失败:%v", err)
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1366. }
  1367. if empty.Infcode != "0" {
  1368. c.ServeSuccessJSON(map[string]interface{}{
  1369. "failed_code": -10,
  1370. "msg": empty.ErrMsg,
  1371. })
  1372. return
  1373. } else {
  1374. c.ServeSuccessJSON(map[string]interface{}{
  1375. "msg": "上传成功",
  1376. })
  1377. return
  1378. }
  1379. }
  1380. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1381. newArr = make([]TempFun, 0)
  1382. for i := 0; i < len(arr); i++ {
  1383. repeat := false
  1384. for j := i + 1; j < len(arr); j++ {
  1385. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1386. repeat = true
  1387. break
  1388. }
  1389. }
  1390. if !repeat {
  1391. newArr = append(newArr, arr[i])
  1392. }
  1393. }
  1394. return
  1395. }
  1396. func (c *HisApiController) Get3263() {
  1397. admin_user_id, _ := c.GetInt64("admin_user_id")
  1398. startTime := c.GetString("start_time")
  1399. //endTime, _ := c.GetString("end_time")
  1400. times := strings.Split(startTime, "-")
  1401. setl_mon := times[0] + times[1]
  1402. upld_btch := "0"
  1403. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1405. var result3263 models.JSResult3263
  1406. data := make(map[string]interface{})
  1407. data["org_name"] = miConfig.OrgName
  1408. data["doctor"] = curRoles.UserName
  1409. data["doctor_name"] = curRoles.UserName
  1410. data["fixmedins_code"] = miConfig.Code
  1411. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1412. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1413. data["secret_key"] = miConfig.SecretKey
  1414. data["url"] = miConfig.Url
  1415. data["ak"] = miConfig.AccessKey
  1416. data["cainfo"] = miConfig.Cainfo
  1417. data["setl_mon"] = setl_mon
  1418. data["stmt_loc"] = "2"
  1419. data["upld_btch"] = upld_btch
  1420. client := &http.Client{}
  1421. bytesData, _ := json.Marshal(data)
  1422. var req *http.Request
  1423. if miConfig.MdtrtareaAdmvs == "320921" {
  1424. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1425. } else {
  1426. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1427. }
  1428. resp, _ := client.Do(req)
  1429. defer resp.Body.Close()
  1430. body, ioErr := ioutil.ReadAll(resp.Body)
  1431. if ioErr != nil {
  1432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1434. }
  1435. var respJSON map[string]interface{}
  1436. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1437. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1439. }
  1440. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1441. fmt.Println(respJSON)
  1442. result, _ := json.Marshal(respJSON)
  1443. fmt.Println(result)
  1444. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1445. utils.ErrorLog("解析失败:%v", err)
  1446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1447. }
  1448. if result3263.Infcode != "0" {
  1449. c.ServeSuccessJSON(map[string]interface{}{
  1450. "failed_code": -10,
  1451. "msg": result3263.ErrMsg,
  1452. })
  1453. return
  1454. } else {
  1455. c.ServeSuccessJSON(map[string]interface{}{
  1456. "list": result3263.Output,
  1457. })
  1458. return
  1459. }
  1460. }
  1461. func (c *HisApiController) Get3264() {
  1462. admin_user_id, _ := c.GetInt64("admin_user_id")
  1463. startTime := c.GetString("start_time")
  1464. //endTime, _ := c.GetString("end_time")
  1465. times := strings.Split(startTime, "-")
  1466. setl_mon := times[0] + times[1]
  1467. upld_btch := "0"
  1468. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1469. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1470. //solidify_id := []
  1471. var result3263 models.JSResult3263
  1472. data := make(map[string]interface{})
  1473. data["org_name"] = miConfig.OrgName
  1474. data["doctor"] = curRoles.UserName
  1475. data["doctor_name"] = curRoles.UserName
  1476. data["fixmedins_code"] = miConfig.Code
  1477. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1479. data["secret_key"] = miConfig.SecretKey
  1480. data["url"] = miConfig.Url
  1481. data["ak"] = miConfig.AccessKey
  1482. data["cainfo"] = miConfig.Cainfo
  1483. data["setl_mon"] = setl_mon
  1484. data["stmt_loc"] = "2"
  1485. data["upld_btch"] = upld_btch
  1486. client := &http.Client{}
  1487. bytesData, _ := json.Marshal(data)
  1488. var req3263 *http.Request
  1489. if miConfig.MdtrtareaAdmvs == "320921" {
  1490. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1491. } else {
  1492. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1493. }
  1494. resp, _ := client.Do(req3263)
  1495. defer resp.Body.Close()
  1496. body, ioErr := ioutil.ReadAll(resp.Body)
  1497. if ioErr != nil {
  1498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1500. }
  1501. var respJSON3263 map[string]interface{}
  1502. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1503. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1505. }
  1506. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1507. fmt.Println(respJSON3263)
  1508. result, _ := json.Marshal(respJSON3263)
  1509. fmt.Println(result)
  1510. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1511. utils.ErrorLog("解析失败:%v", err)
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1513. }
  1514. var ids []string
  1515. for _, item := range result3263.Output {
  1516. ids = append(ids, item.SolidifyID)
  1517. }
  1518. var empty models.JSResultEmpty
  1519. data2 := make(map[string]interface{})
  1520. data2["org_name"] = miConfig.OrgName
  1521. data2["doctor"] = curRoles.UserName
  1522. data2["doctor_name"] = curRoles.UserName
  1523. data2["fixmedins_code"] = miConfig.Code
  1524. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1525. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1526. data2["secret_key"] = miConfig.SecretKey
  1527. data2["url"] = miConfig.Url
  1528. data2["ak"] = miConfig.AccessKey
  1529. data2["cainfo"] = miConfig.Cainfo
  1530. data2["setl_mon"] = setl_mon
  1531. data2["stmt_loc"] = "2"
  1532. data2["upld_btch"] = upld_btch
  1533. data2["solidify_id"] = ids
  1534. client2 := &http.Client{}
  1535. bytesData2, _ := json.Marshal(data2)
  1536. var req *http.Request
  1537. if miConfig.MdtrtareaAdmvs == "320921" {
  1538. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1539. } else {
  1540. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1541. }
  1542. resp2, _ := client2.Do(req)
  1543. defer resp.Body.Close()
  1544. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1545. if ioErr2 != nil {
  1546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1548. }
  1549. var respJSON map[string]interface{}
  1550. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. }
  1554. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1555. fmt.Println(respJSON)
  1556. result2, _ := json.Marshal(respJSON)
  1557. fmt.Println(result2)
  1558. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1559. utils.ErrorLog("解析失败:%v", err)
  1560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1561. }
  1562. if empty.Infcode != "0" {
  1563. c.ServeSuccessJSON(map[string]interface{}{
  1564. "failed_code": -10,
  1565. "msg": empty.ErrMsg,
  1566. })
  1567. return
  1568. } else {
  1569. c.ServeSuccessJSON(map[string]interface{}{
  1570. "msg": "",
  1571. })
  1572. return
  1573. }
  1574. }
  1575. func (c *HisApiController) Get3265() {
  1576. admin_user_id, _ := c.GetInt64("admin_user_id")
  1577. startTime := c.GetString("start_time")
  1578. //endTime, _ := c.GetString("end_time")
  1579. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1580. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1581. times := strings.Split(startTime, "-")
  1582. setl_mon := times[0] + times[1]
  1583. var upld_btch string
  1584. upld_btch = "0"
  1585. //var empty models.JSResultEmpty
  1586. var result3265 models.JSResult3264
  1587. var result3263 models.JSResult3263
  1588. data2 := make(map[string]interface{})
  1589. data2["org_name"] = miConfig.OrgName
  1590. data2["doctor"] = curRoles.UserName
  1591. data2["doctor_name"] = curRoles.UserName
  1592. data2["fixmedins_code"] = miConfig.Code
  1593. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1594. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1595. data2["secret_key"] = miConfig.SecretKey
  1596. data2["url"] = miConfig.Url
  1597. data2["ak"] = miConfig.AccessKey
  1598. data2["cainfo"] = miConfig.Cainfo
  1599. data2["setl_mon"] = setl_mon
  1600. data2["stmt_loc"] = "2"
  1601. data2["upld_btch"] = upld_btch
  1602. client2 := &http.Client{}
  1603. bytesData2, _ := json.Marshal(data2)
  1604. var req3263 *http.Request
  1605. if miConfig.MdtrtareaAdmvs == "320921" {
  1606. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1607. } else {
  1608. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1609. }
  1610. resp2, _ := client2.Do(req3263)
  1611. defer resp2.Body.Close()
  1612. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1613. if ioErr2 != nil {
  1614. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1616. }
  1617. var respJSON3263 map[string]interface{}
  1618. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1619. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1621. }
  1622. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1623. fmt.Println(respJSON3263)
  1624. result2, _ := json.Marshal(respJSON3263)
  1625. fmt.Println(result2)
  1626. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1627. utils.ErrorLog("解析失败:%v", err)
  1628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1629. }
  1630. var ids []string
  1631. for _, item := range result3263.Output {
  1632. ids = append(ids, item.SolidifyID)
  1633. }
  1634. data := make(map[string]interface{})
  1635. data["org_name"] = miConfig.OrgName
  1636. data["doctor"] = curRoles.UserName
  1637. data["doctor_name"] = curRoles.UserName
  1638. data["fixmedins_code"] = miConfig.Code
  1639. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1640. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1641. data["secret_key"] = miConfig.SecretKey
  1642. data["url"] = miConfig.Url
  1643. data["ak"] = miConfig.AccessKey
  1644. data["cainfo"] = miConfig.Cainfo
  1645. data["setl_mon"] = setl_mon
  1646. data["solidify_id"] = ids
  1647. month := time.Unix(1557042972, 0).Format("1")
  1648. year := time.Now().Format("2006")
  1649. month = time.Now().Format("01")
  1650. day := time.Now().Format("02")
  1651. hour := time.Now().Format("15")
  1652. min := time.Now().Format("04")
  1653. sec := time.Now().Format("05")
  1654. fix_fill_date := year + month + day + hour + min + sec
  1655. data["fix_fill_dept"] = miConfig.OrgName
  1656. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1657. data["fix_fill_psn"] = curRoles.UserName
  1658. data["fix_fill_date"] = fix_fill_date
  1659. data["stmt_loc"] = "2"
  1660. data["upld_btch"] = upld_btch
  1661. client := &http.Client{}
  1662. bytesData, _ := json.Marshal(data)
  1663. var req *http.Request
  1664. if miConfig.MdtrtareaAdmvs == "320921" {
  1665. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1666. } else {
  1667. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1668. }
  1669. resp, _ := client.Do(req)
  1670. defer resp.Body.Close()
  1671. body, ioErr := ioutil.ReadAll(resp.Body)
  1672. if ioErr != nil {
  1673. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1675. }
  1676. var respJSON map[string]interface{}
  1677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1680. }
  1681. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1682. fmt.Println(respJSON)
  1683. result, _ := json.Marshal(respJSON)
  1684. fmt.Println(result)
  1685. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1686. utils.ErrorLog("解析失败:%v", err)
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1688. }
  1689. if result3265.Infcode != "0" {
  1690. c.ServeSuccessJSON(map[string]interface{}{
  1691. "failed_code": -10,
  1692. "msg": result3265.ErrMsg,
  1693. })
  1694. return
  1695. } else {
  1696. c.ServeSuccessJSON(map[string]interface{}{
  1697. "info": result3265.Output,
  1698. })
  1699. return
  1700. }
  1701. }
  1702. func (c *HisApiController) Get3266() {
  1703. admin_user_id, _ := c.GetInt64("admin_user_id")
  1704. startTime := c.GetString("start_time")
  1705. //endTime, _ := c.GetString("end_time")
  1706. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1707. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1708. times := strings.Split(startTime, "-")
  1709. stmt_mon := times[0] + times[1]
  1710. var upld_btch string
  1711. //var empty models.JSResultEmpty
  1712. var result3265 models.JSResult3264
  1713. data := make(map[string]interface{})
  1714. data["org_name"] = miConfig.OrgName
  1715. data["doctor"] = curRoles.UserName
  1716. data["doctor_name"] = curRoles.UserName
  1717. data["fixmedins_code"] = miConfig.Code
  1718. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1719. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1720. data["secret_key"] = miConfig.SecretKey
  1721. data["url"] = miConfig.Url
  1722. data["ak"] = miConfig.AccessKey
  1723. data["cainfo"] = miConfig.Cainfo
  1724. data["setl_mon"] = stmt_mon
  1725. month := time.Unix(1557042972, 0).Format("1")
  1726. year := time.Now().Format("2006")
  1727. month = time.Now().Format("01")
  1728. day := time.Now().Format("02")
  1729. hour := time.Now().Format("15")
  1730. min := time.Now().Format("04")
  1731. sec := time.Now().Format("05")
  1732. fix_fill_date := year + month + day + hour + min + sec
  1733. data["fix_fill_dept"] = miConfig.OrgName
  1734. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1735. data["fix_fill_psn"] = curRoles.UserName
  1736. data["fix_fill_date"] = fix_fill_date
  1737. data["stmt_loc"] = "2"
  1738. upld_btch = "0"
  1739. data["upld_btch"] = upld_btch
  1740. client := &http.Client{}
  1741. bytesData, _ := json.Marshal(data)
  1742. var req *http.Request
  1743. if miConfig.MdtrtareaAdmvs == "320921" {
  1744. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1745. } else {
  1746. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1747. }
  1748. resp, _ := client.Do(req)
  1749. defer resp.Body.Close()
  1750. body, ioErr := ioutil.ReadAll(resp.Body)
  1751. if ioErr != nil {
  1752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1754. }
  1755. var respJSON map[string]interface{}
  1756. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. }
  1760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1761. fmt.Println(respJSON)
  1762. result, _ := json.Marshal(respJSON)
  1763. fmt.Println(result)
  1764. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1765. utils.ErrorLog("解析失败:%v", err)
  1766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1767. }
  1768. if result3265.Infcode != "0" {
  1769. c.ServeSuccessJSON(map[string]interface{}{
  1770. "failed_code": -10,
  1771. "msg": result3265.ErrMsg,
  1772. })
  1773. return
  1774. } else {
  1775. c.ServeSuccessJSON(map[string]interface{}{
  1776. "info": result3265.Output,
  1777. })
  1778. return
  1779. }
  1780. }
  1781. func (c *HisApiController) Get3267() {
  1782. admin_user_id, _ := c.GetInt64("admin_user_id")
  1783. startTime := c.GetString("start_time")
  1784. //endTime, _ := c.GetString("end_time")
  1785. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1786. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1787. times := strings.Split(startTime, "-")
  1788. setl_mon := times[0] + times[1]
  1789. var upld_btch string
  1790. //var empty models.JSResultEmpty
  1791. var result3265 models.JSResult3264
  1792. upld_btch = "0"
  1793. data := make(map[string]interface{})
  1794. data["org_name"] = miConfig.OrgName
  1795. data["doctor"] = curRoles.UserName
  1796. data["doctor_name"] = curRoles.UserName
  1797. data["fixmedins_code"] = miConfig.Code
  1798. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1800. data["secret_key"] = miConfig.SecretKey
  1801. data["url"] = miConfig.Url
  1802. data["ak"] = miConfig.AccessKey
  1803. data["cainfo"] = miConfig.Cainfo
  1804. data["setl_mon"] = setl_mon
  1805. data["stmt_loc"] = "2"
  1806. data["upld_btch"] = upld_btch
  1807. client := &http.Client{}
  1808. bytesData, _ := json.Marshal(data)
  1809. var req *http.Request
  1810. if miConfig.MdtrtareaAdmvs == "320921" {
  1811. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1812. } else {
  1813. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1814. }
  1815. resp, _ := client.Do(req)
  1816. defer resp.Body.Close()
  1817. body, ioErr := ioutil.ReadAll(resp.Body)
  1818. if ioErr != nil {
  1819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1821. }
  1822. var respJSON map[string]interface{}
  1823. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1826. }
  1827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1828. fmt.Println(respJSON)
  1829. result, _ := json.Marshal(respJSON)
  1830. fmt.Println(result)
  1831. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1832. utils.ErrorLog("解析失败:%v", err)
  1833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1834. }
  1835. if result3265.Infcode != "0" {
  1836. c.ServeSuccessJSON(map[string]interface{}{
  1837. "failed_code": -10,
  1838. "msg": result3265.ErrMsg,
  1839. })
  1840. return
  1841. } else {
  1842. c.ServeSuccessJSON(map[string]interface{}{
  1843. "info": result3265.Output.Data,
  1844. })
  1845. return
  1846. }
  1847. }
  1848. func (c *HisApiController) Get3268() {
  1849. admin_user_id, _ := c.GetInt64("admin_user_id")
  1850. startTime := c.GetString("start_time")
  1851. endTime := c.GetString("end_time")
  1852. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1853. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1854. times := strings.Split(startTime, "-")
  1855. setl_mon := times[0] + times[1]
  1856. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1857. var twos []models.FixMonRecDetailFileInTwo
  1858. var funs []models.FundDetail
  1859. for _, item := range datas {
  1860. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1861. funs = append(funs, fun...)
  1862. }
  1863. var funInfos []models.Fund
  1864. //for _, item := range funs {
  1865. // var rf []models.FundInfo
  1866. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1867. // for _, subitem := range rf {
  1868. // var fund models.Fund
  1869. // fund.FundCode = subitem.FundPayType
  1870. // fund.FundName = subitem.FundPayTypeName
  1871. // fund.FundAmt = subitem.FundPayAmt
  1872. // fund.FundKey = item.FundKey
  1873. // fund.InsuAdmdvs = "555555"
  1874. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1875. // funInfos = append(funInfos, fund)
  1876. // }
  1877. //}
  1878. for _, team := range datas {
  1879. var two models.FixMonRecDetailFileInTwo
  1880. two.SetlDate = time.Now().Format("2006-01-02")
  1881. two.MedType = team.MedType
  1882. two.Insutype = team.Insutype
  1883. two.PsnType = team.PsnType
  1884. two.MedType = team.MedType
  1885. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1886. two.InsuAdmdvs = team.InsuAdmdvs
  1887. two.PsnTime = team.PsnTime
  1888. two.PsnCnt = team.PsnCnt
  1889. two.FundKey = team.FundKey
  1890. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1891. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1892. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1893. two.MedfeeSumAmt = ms
  1894. two.InscpAmt = ia
  1895. two.FundPaySumAmt = fps
  1896. twos = append(twos, two)
  1897. }
  1898. var upld_btch string
  1899. upld_btch = "0"
  1900. var empty models.JSResultEmpty
  1901. data := make(map[string]interface{})
  1902. data["org_name"] = miConfig.OrgName
  1903. data["doctor"] = curRoles.UserName
  1904. data["doctor_name"] = curRoles.UserName
  1905. data["fixmedins_code"] = miConfig.Code
  1906. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1907. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1908. data["secret_key"] = miConfig.SecretKey
  1909. data["url"] = miConfig.Url
  1910. data["ak"] = miConfig.AccessKey
  1911. data["cainfo"] = miConfig.Cainfo
  1912. data["datas"] = twos
  1913. data["fund"] = funInfos
  1914. data["setl_mon"] = setl_mon
  1915. month := time.Unix(1557042972, 0).Format("1")
  1916. year := time.Now().Format("2006")
  1917. month = time.Now().Format("01")
  1918. day := time.Now().Format("02")
  1919. hour := time.Now().Format("15")
  1920. min := time.Now().Format("04")
  1921. sec := time.Now().Format("05")
  1922. fix_fill_date := year + month + day + hour + min + sec
  1923. data["fix_fill_dept"] = miConfig.OrgName
  1924. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1925. data["fix_fill_psn"] = curRoles.UserName
  1926. data["fix_fill_date"] = fix_fill_date
  1927. data["stmt_loc"] = "2"
  1928. data["upld_btch"] = upld_btch
  1929. client := &http.Client{}
  1930. bytesData, _ := json.Marshal(data)
  1931. var req *http.Request
  1932. if miConfig.MdtrtareaAdmvs == "320921" {
  1933. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1934. } else {
  1935. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1936. }
  1937. resp, _ := client.Do(req)
  1938. defer resp.Body.Close()
  1939. body, ioErr := ioutil.ReadAll(resp.Body)
  1940. if ioErr != nil {
  1941. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1943. }
  1944. var respJSON map[string]interface{}
  1945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1948. }
  1949. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1950. fmt.Println(respJSON)
  1951. result, _ := json.Marshal(respJSON)
  1952. fmt.Println(result)
  1953. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1954. utils.ErrorLog("解析失败:%v", err)
  1955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1956. }
  1957. if empty.Infcode != "0" {
  1958. c.ServeSuccessJSON(map[string]interface{}{
  1959. "failed_code": -10,
  1960. "msg": empty.ErrMsg,
  1961. })
  1962. return
  1963. } else {
  1964. c.ServeSuccessJSON(map[string]interface{}{
  1965. "msg": "上传成功",
  1966. })
  1967. return
  1968. }
  1969. }
  1970. func (c *HisApiController) Get3269() {
  1971. admin_user_id, _ := c.GetInt64("admin_user_id")
  1972. startTime := c.GetString("start_time")
  1973. //endTime, _ := c.GetString("end_time")
  1974. times := strings.Split(startTime, "-")
  1975. setl_mon := times[0] + times[1]
  1976. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1978. var result3263 models.JSResult3263
  1979. data := make(map[string]interface{})
  1980. data["org_name"] = miConfig.OrgName
  1981. data["doctor"] = curRoles.UserName
  1982. data["doctor_name"] = curRoles.UserName
  1983. data["fixmedins_code"] = miConfig.Code
  1984. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1985. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1986. data["secret_key"] = miConfig.SecretKey
  1987. data["url"] = miConfig.Url
  1988. data["ak"] = miConfig.AccessKey
  1989. data["cainfo"] = miConfig.Cainfo
  1990. data["setl_mon"] = setl_mon
  1991. data["stmt_loc"] = "2"
  1992. client := &http.Client{}
  1993. bytesData, _ := json.Marshal(data)
  1994. var req *http.Request
  1995. if miConfig.MdtrtareaAdmvs == "320921" {
  1996. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1997. } else {
  1998. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1999. }
  2000. resp, _ := client.Do(req)
  2001. defer resp.Body.Close()
  2002. body, ioErr := ioutil.ReadAll(resp.Body)
  2003. if ioErr != nil {
  2004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2006. }
  2007. var respJSON map[string]interface{}
  2008. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2011. }
  2012. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2013. fmt.Println(respJSON)
  2014. result, _ := json.Marshal(respJSON)
  2015. fmt.Println(result)
  2016. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  2017. utils.ErrorLog("解析失败:%v", err)
  2018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2019. }
  2020. if result3263.Infcode != "0" {
  2021. c.ServeSuccessJSON(map[string]interface{}{
  2022. "failed_code": -10,
  2023. "msg": result3263.ErrMsg,
  2024. })
  2025. return
  2026. } else {
  2027. c.ServeSuccessJSON(map[string]interface{}{
  2028. "msg": "上传成功",
  2029. })
  2030. return
  2031. }
  2032. }
  2033. func (c *HisApiController) Get3270() {
  2034. admin_user_id, _ := c.GetInt64("admin_user_id")
  2035. startTime := c.GetString("start_time")
  2036. //endTime, _ := c.GetString("end_time")
  2037. times := strings.Split(startTime, "-")
  2038. setl_mon := times[0] + times[1]
  2039. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2040. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2041. var result3263 models.JSResult3263
  2042. data2 := make(map[string]interface{})
  2043. data2["org_name"] = miConfig.OrgName
  2044. data2["doctor"] = curRoles.UserName
  2045. data2["doctor_name"] = curRoles.UserName
  2046. data2["fixmedins_code"] = miConfig.Code
  2047. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2048. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2049. data2["secret_key"] = miConfig.SecretKey
  2050. data2["url"] = miConfig.Url
  2051. data2["ak"] = miConfig.AccessKey
  2052. data2["cainfo"] = miConfig.Cainfo
  2053. data2["setl_mon"] = setl_mon
  2054. data2["stmt_loc"] = "2"
  2055. client2 := &http.Client{}
  2056. bytesData2, _ := json.Marshal(data2)
  2057. var req3263 *http.Request
  2058. if miConfig.MdtrtareaAdmvs == "320921" {
  2059. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2060. } else {
  2061. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2062. }
  2063. resp2, _ := client2.Do(req3263)
  2064. defer resp2.Body.Close()
  2065. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2066. if ioErr2 != nil {
  2067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2069. }
  2070. var respJSON3263 map[string]interface{}
  2071. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2074. }
  2075. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2076. fmt.Println(respJSON3263)
  2077. result2, _ := json.Marshal(respJSON3263)
  2078. fmt.Println(result2)
  2079. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2080. utils.ErrorLog("解析失败:%v", err)
  2081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2082. }
  2083. var ids []string
  2084. for _, item := range result3263.Output {
  2085. ids = append(ids, item.SolidifyID)
  2086. }
  2087. var result3264 models.JSResult3264
  2088. data := make(map[string]interface{})
  2089. data["org_name"] = miConfig.OrgName
  2090. data["doctor"] = curRoles.UserName
  2091. data["doctor_name"] = curRoles.UserName
  2092. data["fixmedins_code"] = miConfig.Code
  2093. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2094. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2095. data["secret_key"] = miConfig.SecretKey
  2096. data["url"] = miConfig.Url
  2097. data["ak"] = miConfig.AccessKey
  2098. data["cainfo"] = miConfig.Cainfo
  2099. data["setl_mon"] = setl_mon
  2100. data["stmt_loc"] = "2"
  2101. data["solidify_id"] = ids
  2102. client := &http.Client{}
  2103. bytesData, _ := json.Marshal(data)
  2104. var req *http.Request
  2105. if miConfig.MdtrtareaAdmvs == "320921" {
  2106. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2107. } else {
  2108. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2109. }
  2110. resp, _ := client.Do(req)
  2111. defer resp.Body.Close()
  2112. body, ioErr := ioutil.ReadAll(resp.Body)
  2113. if ioErr != nil {
  2114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2116. }
  2117. var respJSON map[string]interface{}
  2118. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2119. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2121. }
  2122. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2123. fmt.Println(respJSON)
  2124. result, _ := json.Marshal(respJSON)
  2125. fmt.Println(result)
  2126. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2127. utils.ErrorLog("解析失败:%v", err)
  2128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2129. }
  2130. if result3264.Infcode != "0" {
  2131. c.ServeSuccessJSON(map[string]interface{}{
  2132. "failed_code": -10,
  2133. "msg": result3264.ErrMsg,
  2134. })
  2135. return
  2136. } else {
  2137. c.ServeSuccessJSON(map[string]interface{}{
  2138. "info": result3264.Output,
  2139. })
  2140. return
  2141. }
  2142. }
  2143. func (c *HisApiController) Get3271() {
  2144. admin_user_id, _ := c.GetInt64("admin_user_id")
  2145. startTime := c.GetString("start_time")
  2146. //endTime, _ := c.GetString("end_time")
  2147. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2148. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2149. times := strings.Split(startTime, "-")
  2150. setl_mon := times[0] + times[1]
  2151. //var empty models.JSResultEmpty
  2152. var result3265 models.JSResult3264
  2153. var result3263 models.JSResult3263
  2154. data2 := make(map[string]interface{})
  2155. data2["org_name"] = miConfig.OrgName
  2156. data2["doctor"] = curRoles.UserName
  2157. data2["doctor_name"] = curRoles.UserName
  2158. data2["fixmedins_code"] = miConfig.Code
  2159. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2160. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2161. data2["secret_key"] = miConfig.SecretKey
  2162. data2["url"] = miConfig.Url
  2163. data2["ak"] = miConfig.AccessKey
  2164. data2["cainfo"] = miConfig.Cainfo
  2165. data2["setl_mon"] = setl_mon
  2166. data2["stmt_loc"] = "2"
  2167. client2 := &http.Client{}
  2168. bytesData2, _ := json.Marshal(data2)
  2169. var req3263 *http.Request
  2170. if miConfig.MdtrtareaAdmvs == "320921" {
  2171. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2172. } else {
  2173. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2174. }
  2175. resp2, _ := client2.Do(req3263)
  2176. defer resp2.Body.Close()
  2177. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2178. if ioErr2 != nil {
  2179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2181. }
  2182. var respJSON3263 map[string]interface{}
  2183. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2184. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2186. }
  2187. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2188. fmt.Println(respJSON3263)
  2189. result2, _ := json.Marshal(respJSON3263)
  2190. fmt.Println(result2)
  2191. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2192. utils.ErrorLog("解析失败:%v", err)
  2193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. }
  2195. var ids []string
  2196. for _, item := range result3263.Output {
  2197. ids = append(ids, item.SolidifyID)
  2198. }
  2199. data := make(map[string]interface{})
  2200. data["org_name"] = miConfig.OrgName
  2201. data["doctor"] = curRoles.UserName
  2202. data["doctor_name"] = curRoles.UserName
  2203. data["fixmedins_code"] = miConfig.Code
  2204. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2205. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2206. data["secret_key"] = miConfig.SecretKey
  2207. data["url"] = miConfig.Url
  2208. data["ak"] = miConfig.AccessKey
  2209. data["cainfo"] = miConfig.Cainfo
  2210. data["setl_mon"] = setl_mon
  2211. data["solidify_id"] = ids
  2212. month := time.Unix(1557042972, 0).Format("1")
  2213. year := time.Now().Format("2006")
  2214. month = time.Now().Format("01")
  2215. day := time.Now().Format("02")
  2216. hour := time.Now().Format("15")
  2217. min := time.Now().Format("04")
  2218. sec := time.Now().Format("05")
  2219. fix_fill_date := year + month + day + hour + min + sec
  2220. data["fix_fill_dept"] = miConfig.OrgName
  2221. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2222. data["fix_fill_psn"] = curRoles.UserName
  2223. data["fix_fill_date"] = fix_fill_date
  2224. data["stmt_loc"] = "2"
  2225. client := &http.Client{}
  2226. bytesData, _ := json.Marshal(data)
  2227. var req *http.Request
  2228. if miConfig.MdtrtareaAdmvs == "320921" {
  2229. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2230. } else {
  2231. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2232. }
  2233. resp, _ := client.Do(req)
  2234. defer resp.Body.Close()
  2235. body, ioErr := ioutil.ReadAll(resp.Body)
  2236. if ioErr != nil {
  2237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2239. }
  2240. var respJSON map[string]interface{}
  2241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2244. }
  2245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2246. fmt.Println(respJSON)
  2247. result, _ := json.Marshal(respJSON)
  2248. fmt.Println(result)
  2249. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2250. utils.ErrorLog("解析失败:%v", err)
  2251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2252. }
  2253. if result3265.Infcode != "0" {
  2254. c.ServeSuccessJSON(map[string]interface{}{
  2255. "failed_code": -10,
  2256. "msg": result3265.ErrMsg,
  2257. })
  2258. return
  2259. } else {
  2260. c.ServeSuccessJSON(map[string]interface{}{
  2261. "info": result3265.Output.Data,
  2262. })
  2263. return
  2264. }
  2265. }
  2266. func (c *HisApiController) Get3272() {
  2267. admin_user_id, _ := c.GetInt64("admin_user_id")
  2268. startTime := c.GetString("start_time")
  2269. //endTime, _ := c.GetString("end_time")
  2270. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2272. times := strings.Split(startTime, "-")
  2273. setl_mon := times[0] + times[1]
  2274. var upld_btch string
  2275. //var empty models.JSResultEmpty
  2276. var result3265 models.JSResult3264
  2277. data := make(map[string]interface{})
  2278. data["org_name"] = miConfig.OrgName
  2279. data["doctor"] = curRoles.UserName
  2280. data["doctor_name"] = curRoles.UserName
  2281. data["fixmedins_code"] = miConfig.Code
  2282. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2283. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2284. data["secret_key"] = miConfig.SecretKey
  2285. data["url"] = miConfig.Url
  2286. data["ak"] = miConfig.AccessKey
  2287. data["cainfo"] = miConfig.Cainfo
  2288. data["setl_mon"] = setl_mon
  2289. month := time.Unix(1557042972, 0).Format("1")
  2290. year := time.Now().Format("2006")
  2291. month = time.Now().Format("01")
  2292. day := time.Now().Format("02")
  2293. hour := time.Now().Format("15")
  2294. min := time.Now().Format("04")
  2295. sec := time.Now().Format("05")
  2296. fix_fill_date := year + month + day + hour + min + sec
  2297. data["fix_fill_dept"] = miConfig.OrgName
  2298. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2299. data["fix_fill_psn"] = curRoles.UserName
  2300. data["fix_fill_date"] = fix_fill_date
  2301. data["stmt_loc"] = "2"
  2302. data["upld_btch"] = upld_btch
  2303. client := &http.Client{}
  2304. bytesData, _ := json.Marshal(data)
  2305. var req *http.Request
  2306. if miConfig.MdtrtareaAdmvs == "320921" {
  2307. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2308. } else {
  2309. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2310. }
  2311. resp, _ := client.Do(req)
  2312. defer resp.Body.Close()
  2313. body, ioErr := ioutil.ReadAll(resp.Body)
  2314. if ioErr != nil {
  2315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. }
  2318. var respJSON map[string]interface{}
  2319. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2322. }
  2323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2324. fmt.Println(respJSON)
  2325. result, _ := json.Marshal(respJSON)
  2326. fmt.Println(result)
  2327. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2328. utils.ErrorLog("解析失败:%v", err)
  2329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2330. }
  2331. if result3265.Infcode != "0" {
  2332. c.ServeSuccessJSON(map[string]interface{}{
  2333. "failed_code": -10,
  2334. "msg": result3265.ErrMsg,
  2335. })
  2336. return
  2337. } else {
  2338. c.ServeSuccessJSON(map[string]interface{}{
  2339. "info": result3265.Output,
  2340. })
  2341. return
  2342. }
  2343. }
  2344. func (c *HisApiController) Get3273() {
  2345. admin_user_id, _ := c.GetInt64("admin_user_id")
  2346. startTime := c.GetString("start_time")
  2347. //endTime, _ := c.GetString("end_time")
  2348. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2349. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2350. times := strings.Split(startTime, "-")
  2351. setl_mon := times[0] + times[1]
  2352. var result3265 models.JSResult3264
  2353. data := make(map[string]interface{})
  2354. data["org_name"] = miConfig.OrgName
  2355. data["doctor"] = curRoles.UserName
  2356. data["doctor_name"] = curRoles.UserName
  2357. data["fixmedins_code"] = miConfig.Code
  2358. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2359. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2360. data["secret_key"] = miConfig.SecretKey
  2361. data["url"] = miConfig.Url
  2362. data["ak"] = miConfig.AccessKey
  2363. data["cainfo"] = miConfig.Cainfo
  2364. data["setl_mon"] = setl_mon
  2365. data["stmt_loc"] = "2"
  2366. client := &http.Client{}
  2367. bytesData, _ := json.Marshal(data)
  2368. var req *http.Request
  2369. if miConfig.MdtrtareaAdmvs == "320921" {
  2370. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2371. } else {
  2372. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2373. }
  2374. resp, _ := client.Do(req)
  2375. defer resp.Body.Close()
  2376. body, ioErr := ioutil.ReadAll(resp.Body)
  2377. if ioErr != nil {
  2378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2380. }
  2381. var respJSON map[string]interface{}
  2382. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2385. }
  2386. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2387. fmt.Println(respJSON)
  2388. result, _ := json.Marshal(respJSON)
  2389. fmt.Println(result)
  2390. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2391. utils.ErrorLog("解析失败:%v", err)
  2392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2393. }
  2394. if result3265.Infcode != "0" {
  2395. c.ServeSuccessJSON(map[string]interface{}{
  2396. "failed_code": -10,
  2397. "msg": result3265.ErrMsg,
  2398. })
  2399. return
  2400. } else {
  2401. c.ServeSuccessJSON(map[string]interface{}{
  2402. "info": result3265.Output.Data,
  2403. })
  2404. return
  2405. }
  2406. }
  2407. func (c *HisApiController) Get3274() {
  2408. //if miConfig.MdtrtareaAdmvs == "320921" {
  2409. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2410. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2411. // "&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
  2412. //
  2413. //} else {
  2414. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2415. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2416. // "&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
  2417. //
  2418. //}
  2419. }
  2420. func (c *HisApiController) Get3275() {
  2421. //if miConfig.MdtrtareaAdmvs == "320921" {
  2422. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2423. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2424. // "&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
  2425. //
  2426. //} else {
  2427. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2428. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2429. // "&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
  2430. //
  2431. //}
  2432. }
  2433. func (c *HisApiController) Get3276() {
  2434. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2435. //month := c.GetString("month")
  2436. //
  2437. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2438. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2439. //var api string
  2440. //var res Result5301
  2441. //
  2442. //if miConfig.MdtrtareaAdmvs == "320921" {
  2443. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2444. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2445. //} else {
  2446. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2447. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2448. //}
  2449. //
  2450. //resp, requestErr := http.Get(api)
  2451. //if requestErr != nil {
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. //}
  2455. //
  2456. //body, ioErr := ioutil.ReadAll(resp.Body)
  2457. //if ioErr != nil {
  2458. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2460. // return
  2461. //}
  2462. //var respJSON map[string]interface{}
  2463. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2464. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2465. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2466. // return
  2467. //}
  2468. //
  2469. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2470. //result, _ := json.Marshal(respJSON)
  2471. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2472. // utils.ErrorLog("解析失败:%v", err)
  2473. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2474. // return
  2475. //}
  2476. }
  2477. func (c *HisApiController) Get3277() {
  2478. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2479. //month := c.GetString("month")
  2480. //
  2481. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2482. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2483. //var api string
  2484. //var res Result5301
  2485. //
  2486. //if miConfig.MdtrtareaAdmvs == "320921" {
  2487. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2488. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2489. //} else {
  2490. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2491. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2492. //}
  2493. //
  2494. //resp, requestErr := http.Get(api)
  2495. //if requestErr != nil {
  2496. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2497. // return
  2498. //}
  2499. //
  2500. //body, ioErr := ioutil.ReadAll(resp.Body)
  2501. //if ioErr != nil {
  2502. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2503. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2504. // return
  2505. //}
  2506. //var respJSON map[string]interface{}
  2507. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2508. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2510. // return
  2511. //}
  2512. //
  2513. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2514. //result, _ := json.Marshal(respJSON)
  2515. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2516. // utils.ErrorLog("解析失败:%v", err)
  2517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2518. // return
  2519. //}
  2520. }
  2521. func (c *HisApiController) GetCFYLJG001() {
  2522. admin_user_id, _ := c.GetInt64("admin_user_id")
  2523. patient_id, _ := c.GetInt64("patient_id")
  2524. his_patient_id, _ := c.GetInt64("his_patient_id")
  2525. record_time := c.GetString("record_time")
  2526. admin_user_id = 3626
  2527. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2528. psn, _ := service.GetPsnByPatientId(patient_id)
  2529. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2530. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2531. var cFYLJG001 models.CFYLJG001
  2532. timeLayout := "2006-01-02"
  2533. loc, _ := time.LoadLocation("Local")
  2534. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2535. if err != nil {
  2536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2537. return
  2538. }
  2539. recordDateTime := theTime.Unix()
  2540. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2541. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2542. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2543. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2544. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2545. for _, item := range prescriptions {
  2546. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2547. if his.IdCardType == 1 {
  2548. bas := strings.Split(psn.CardInfo, "|")
  2549. basNumber := bas[1]
  2550. fmt.Println(basNumber)
  2551. card_sn := bas[3]
  2552. card_no := bas[2]
  2553. cFYLJG001.MdtrtCertType = "03"
  2554. cFYLJG001.CardSn = card_sn
  2555. cFYLJG001.MdtrtCertNo = card_no
  2556. cFYLJG001.EcToken = ""
  2557. cFYLJG001.AuthNo = ""
  2558. } else if his.IdCardType == 2 {
  2559. cFYLJG001.MdtrtCertType = "02"
  2560. cFYLJG001.CardSn = ""
  2561. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2562. cFYLJG001.EcToken = ""
  2563. cFYLJG001.AuthNo = ""
  2564. } else if his.IdCardType == 4 {
  2565. cFYLJG001.MdtrtCertType = "01"
  2566. cFYLJG001.CardSn = ""
  2567. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2568. cFYLJG001.EcToken = psn.VerifyNumber
  2569. cFYLJG001.AuthNo = ""
  2570. }
  2571. cFYLJG001.BizTypeCode = "01"
  2572. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2573. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2574. cFYLJG001.RxTypeCode = "1"
  2575. tempTime := time.Unix(item.PreTime, 0)
  2576. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2577. cFYLJG001.PrscTime = timeFormatOne
  2578. var count float64
  2579. if item.Type == 1 {
  2580. for _, sumItem := range item.HisDoctorAdviceInfo {
  2581. count = count + sumItem.PrescribingNumber
  2582. }
  2583. }
  2584. cFYLJG001.RxDrugCnt = count
  2585. cFYLJG001.ValiDays = "5"
  2586. ts := time.Unix(item.PreTime, 0)
  2587. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2588. tempTime3 := time.Unix(record_time2, 0)
  2589. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2590. cFYLJG001.ValiEndTime = timeFormat3
  2591. cFYLJG001.RxCotnFlag = "0"
  2592. for _, subItem := range item.HisDoctorAdviceInfo {
  2593. var drug models.RxDrug
  2594. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2595. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2596. drug.RxItemTypeCode = "11"
  2597. drug.DrugDosform = "乳膏剂" //TODO
  2598. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2599. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2600. }
  2601. drug.MedcWayDscr = subItem.DeliveryWay
  2602. tempTime2 := time.Unix(subItem.StartTime, 0)
  2603. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2604. drug.MedcBegntime = timeFormatTwo
  2605. if subItem.Day > 0 {
  2606. ts := time.Unix(subItem.StartTime, 0)
  2607. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2608. tempTime4 := time.Unix(record_time, 0)
  2609. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2610. drug.MedcEndtime = timeFormat5
  2611. } else {
  2612. tempTime2 := time.Unix(subItem.StartTime, 0)
  2613. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2614. drug.MedcEndtime = timeFormatTwo
  2615. }
  2616. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2617. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2618. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2619. drug.DrugCnt = subItem.PrescribingNumber
  2620. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2621. drug.DrugGenname = subItem.AdviceName
  2622. drug.MedcWayCodg = subItem.DeliveryWay
  2623. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2624. drug.SinDoscnt = subItem.SingleDose
  2625. drug.SinDosunt = subItem.SingleDoseUnit
  2626. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2627. drug.UsedFrquName = subItem.ExecutionFrequency
  2628. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2629. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2630. drug.HospApprFlag = "1"
  2631. cFYLJG001.List = append(cFYLJG001.List, drug)
  2632. }
  2633. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2634. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2635. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2636. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2637. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2638. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2639. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2640. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2641. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2642. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2643. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2644. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2645. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2646. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2647. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2648. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2649. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2650. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2651. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2652. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2653. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2654. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2655. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2656. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2657. tempTime2 := time.Now().Unix()
  2658. tempTime6 := time.Unix(tempTime2, 0)
  2659. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2660. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2661. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2662. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2663. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2664. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2665. //memo := make(map[string]interface{})
  2666. //inputData := make(map[string]interface{}, 0)
  2667. //type MyData struct {
  2668. // Insutype string `json:"insutype"`
  2669. //}
  2670. //
  2671. // data := MyData{
  2672. // Insutype: his.Insutype,
  2673. //}
  2674. //
  2675. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2676. var config []*models.HisXtDiagnoseConfig
  2677. for _, item := range diagnosis_ids {
  2678. id, _ := strconv.ParseInt(item, 10, 64)
  2679. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2680. config = append(config, &diagnosisConfig)
  2681. }
  2682. for index, subitem := range config {
  2683. if index == 0 {
  2684. var dia models.DiseInfo
  2685. dia.DiagType = "1"
  2686. dia.MaindiagFlag = "1"
  2687. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2688. dia.DiagCode = subitem.CountryCode
  2689. dia.DiagName = subitem.ClassName
  2690. dia.DiagDept = "肾内科"
  2691. dia.DiagDrNo = doctor.DoctorNumber
  2692. dia.DiagDrName = doctor.UserName
  2693. tempTime3 := time.Unix(item.PreTime, 0)
  2694. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2695. dia.DiagTime = timeFormatTwo
  2696. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2697. } else {
  2698. var dia models.DiseInfo
  2699. dia.DiagType = "1"
  2700. dia.MaindiagFlag = "0"
  2701. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2702. dia.DiagCode = subitem.CountryCode
  2703. dia.DiagName = subitem.ClassName
  2704. dia.DiagDept = "肾内科"
  2705. dia.DiagDrNo = doctor.DoctorNumber
  2706. dia.DiagDrName = doctor.UserName
  2707. tempTime3 := time.Unix(item.PreTime, 0)
  2708. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2709. dia.DiagTime = timeFormatTwo
  2710. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2711. }
  2712. }
  2713. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2714. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2715. var res ResultCFYLJG001
  2716. var respJSON2 map[string]interface{}
  2717. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. userJSONBytes2, _ := json.Marshal(respJSON2)
  2723. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2724. utils.ErrorLog("解析失败:%v", err)
  2725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2726. return
  2727. }
  2728. if res.Infcode == -1 {
  2729. c.ServeSuccessJSON(map[string]interface{}{
  2730. "failed_code": -10,
  2731. "msg": res.ErrMsg,
  2732. })
  2733. return
  2734. } else {
  2735. var flow models.HisPrescriptionFlow
  2736. flow.Ctime = time.Now().Unix()
  2737. flow.SignDigest = ""
  2738. flow.RxTraceCode = res.Output.RxTraceCode
  2739. flow.HiRxno = res.Output.HiRxno
  2740. flow.MID = his.Number
  2741. flow.Status = 1
  2742. flow.DCode = doctor_info.DoctorNumber
  2743. flow.OriginalRxFile = ""
  2744. flow.OriginalValue = ""
  2745. flow.SignCertDn = ""
  2746. flow.UserOrgId = 10454
  2747. flow.SignCertSn = ""
  2748. flow.Mtime = time.Now().Unix()
  2749. service.Createflow(&flow)
  2750. c.ServeSuccessJSON(map[string]interface{}{
  2751. "msg": "上传成功",
  2752. })
  2753. }
  2754. }
  2755. }
  2756. func (c *HisApiController) GetCFYLJG002() {
  2757. admin_user_id, _ := c.GetInt64("admin_user_id")
  2758. his_patient_id, _ := c.GetInt64("his_patient_id")
  2759. record_time := c.GetString("record_time")
  2760. admin_user_id = 3626
  2761. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2762. //id, _ := c.GetInt64("id")
  2763. admin_user_id = 3626
  2764. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2765. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2766. flow, _ := service.Getflowtwo(his.Number)
  2767. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2768. //record_time := c.GetString("record_time")
  2769. patient_id, _ := c.GetInt64("patient_id")
  2770. //patient_id = 23834
  2771. //record_time = "2023-09-18"
  2772. timeLayout := "2006-01-02"
  2773. loc, _ := time.LoadLocation("Local")
  2774. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2775. if err != nil {
  2776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2777. return
  2778. }
  2779. recordDateTime := theTime.Unix()
  2780. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2781. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2782. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2783. dept, _ := service.GetDepartMentDetail(info.Departments)
  2784. inputData := make(map[string]interface{})
  2785. inputData["rxTraceCode"] = flow.RxTraceCode
  2786. inputData["hiRxno"] = flow.HiRxno
  2787. inputData["mdtrtId"] = flow.MID
  2788. inputData["patnName"] = his.PsnName
  2789. inputData["psnCertType"] = his.PsnCertType
  2790. inputData["certno"] = his.Certno
  2791. inputData["fixmedinsName"] = miConfig.OrgName
  2792. inputData["fixmedinsCode"] = miConfig.Code
  2793. inputData["drCode"] = doctor_info.DoctorNumber
  2794. inputData["prscDrName"] = doctor_info.UserName
  2795. inputData["pharDeptName"] = dept.Name
  2796. inputData["pharDeptCode"] = dept.Number
  2797. inputData["pharProfttlCodg"] = dept.Name
  2798. inputData["pharProfttlName"] = ""
  2799. inputData["pharCode"] = "HY440309002107"
  2800. inputData["pharCertType"] = "01"
  2801. inputData["pharCertno"] = "430482199408260023"
  2802. inputData["pharName"] = "彭斯遥"
  2803. inputData["pharPracCertNo"] = ""
  2804. tempTime2 := time.Unix(info.Ctime, 0)
  2805. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2806. inputData["pharChkTime"] = timeFormatTwo
  2807. bytesData, _ := json.Marshal(inputData)
  2808. fmt.Println(string(bytesData))
  2809. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2810. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2811. if err != nil {
  2812. fmt.Println("Error reading PDF file:", err)
  2813. return
  2814. }
  2815. // 将 PDF 文件内容进行 Base64 编码
  2816. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2817. fmt.Println(err)
  2818. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2819. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2820. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2821. var res2 Result002
  2822. var respJSON2 map[string]interface{}
  2823. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2826. return
  2827. }
  2828. userJSONBytes2, _ := json.Marshal(respJSON2)
  2829. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2830. utils.ErrorLog("解析失败:%v", err)
  2831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2832. return
  2833. }
  2834. if res2.Infcode == 0 {
  2835. flow.Ctime = time.Now().Unix()
  2836. flow.SignDigest = res2.Output.SignDigest
  2837. flow.RxFile = res2.Output.RxFile
  2838. flow.MID = his.Number
  2839. flow.Status = 1
  2840. flow.DCode = doctor_info.DoctorNumber
  2841. flow.OriginalRxFile = rx_encoded
  2842. flow.OriginalValue = encoded
  2843. flow.SignCertDn = res2.Output.SignCertDn
  2844. flow.SignCertSn = res2.Output.SignCertSn
  2845. flow.Mtime = time.Now().Unix()
  2846. service.Saveflow(flow)
  2847. c.ServeSuccessJSON(map[string]interface{}{
  2848. "msg": "预签名成功",
  2849. })
  2850. } else {
  2851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2852. return
  2853. }
  2854. }
  2855. func (c *HisApiController) GetCFYLJG003() {
  2856. admin_user_id, _ := c.GetInt64("admin_user_id")
  2857. his_patient_id, _ := c.GetInt64("his_patient_id")
  2858. record_time := c.GetString("record_time")
  2859. admin_user_id = 3626
  2860. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2861. //id, _ := c.GetInt64("id")
  2862. admin_user_id = 3626
  2863. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2864. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2865. flow, _ := service.Getflowtwo(his.Number)
  2866. //id = 3
  2867. patient_id, _ := c.GetInt64("patient_id")
  2868. //patient_id = 23834
  2869. //record_time = "2023-09-18"
  2870. timeLayout := "2006-01-02"
  2871. loc, _ := time.LoadLocation("Local")
  2872. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2873. if err != nil {
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2875. return
  2876. }
  2877. recordDateTime := theTime.Unix()
  2878. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2879. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2880. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2881. dept, _ := service.GetDepartMentDetail(info.Departments)
  2882. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2883. var cFYLJG003 models.CFYLJG003
  2884. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2885. cFYLJG003.HiRxno = flow.HiRxno
  2886. cFYLJG003.MdtrtID = flow.MID
  2887. cFYLJG003.PatnName = his.Name
  2888. cFYLJG003.Certno = his.Certno
  2889. cFYLJG003.FixmedinsName = miConfig.OrgName
  2890. cFYLJG003.FixmedinsCode = miConfig.Code
  2891. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2892. cFYLJG003.PrscDrName = doctor_info.UserName
  2893. cFYLJG003.PharDeptName = dept.Name
  2894. cFYLJG003.PharDeptCode = dept.Number
  2895. cFYLJG003.PharCode = "HY440309002107"
  2896. cFYLJG003.PharCertType = "01"
  2897. cFYLJG003.PharCertno = "430482199408260023"
  2898. cFYLJG003.PharName = "彭斯遥"
  2899. cFYLJG003.PsnCertType = "01"
  2900. cFYLJG003.RxFile = flow.RxFile
  2901. cFYLJG003.SignDigest = flow.SignDigest
  2902. cFYLJG003.FixmedinsCode = miConfig.Code
  2903. cFYLJG003.PsnCertType = "01"
  2904. cFYLJG003.PharProfttlCodg = dept.Name
  2905. //inputData["pharProfttlCodg"] =dept.Name
  2906. tempTime2 := time.Unix(info.Ctime, 0)
  2907. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2908. cFYLJG003.PharChkTime = timeFormatTwo
  2909. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2910. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2911. var res ResultCFYLJG003
  2912. var respJSON2 map[string]interface{}
  2913. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2916. return
  2917. }
  2918. userJSONBytes2, _ := json.Marshal(respJSON2)
  2919. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2920. utils.ErrorLog("解析失败:%v", err)
  2921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2922. return
  2923. }
  2924. if res.Infcode == -1 {
  2925. c.ServeSuccessJSON(map[string]interface{}{
  2926. "failed_code": -10,
  2927. "msg": res.ErrMsg,
  2928. })
  2929. return
  2930. } else {
  2931. c.ServeSuccessJSON(map[string]interface{}{
  2932. "info": res.Output,
  2933. })
  2934. }
  2935. }
  2936. func (c *HisApiController) GetCFYLJG004() {
  2937. admin_user_id, _ := c.GetInt64("admin_user_id")
  2938. his_patient_id, _ := c.GetInt64("his_patient_id")
  2939. record_time := c.GetString("record_time")
  2940. admin_user_id = 3626
  2941. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2942. //id, _ := c.GetInt64("id")
  2943. admin_user_id = 3626
  2944. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2945. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2946. flow, _ := service.Getflowtwo(his.Number)
  2947. //id = 3
  2948. patient_id, _ := c.GetInt64("patient_id")
  2949. //patient_id = 23834
  2950. //record_time = "2023-09-18"
  2951. timeLayout := "2006-01-02"
  2952. loc, _ := time.LoadLocation("Local")
  2953. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2954. if err != nil {
  2955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2956. return
  2957. }
  2958. recordDateTime := theTime.Unix()
  2959. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2960. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2961. var cFYLJG004 models.CFYLJG004
  2962. cFYLJG004.HiRxno = flow.HiRxno
  2963. cFYLJG004.FixmedinsCode = miConfig.Code
  2964. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2965. cFYLJG004.UndoDrCertType = "01"
  2966. cFYLJG004.UndoRea = "撤销处方"
  2967. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2968. cFYLJG004.UndoDrName = doctor_info.UserName
  2969. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2970. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2971. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2972. var res ResultCFYLJG004
  2973. var respJSON2 map[string]interface{}
  2974. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2975. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2977. return
  2978. }
  2979. userJSONBytes2, _ := json.Marshal(respJSON2)
  2980. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2981. utils.ErrorLog("解析失败:%v", err)
  2982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2983. return
  2984. }
  2985. if res.Infcode == -1 {
  2986. c.ServeSuccessJSON(map[string]interface{}{
  2987. "failed_code": -10,
  2988. "msg": res.ErrMsg,
  2989. })
  2990. return
  2991. } else {
  2992. flow.Status = 0
  2993. service.Saveflow(flow)
  2994. c.ServeSuccessJSON(map[string]interface{}{
  2995. "msg": "撤销成功",
  2996. })
  2997. return
  2998. }
  2999. }
  3000. func (c *HisApiController) GetCFYLJG005() {
  3001. admin_user_id, _ := c.GetInt64("admin_user_id")
  3002. his_patient_id, _ := c.GetInt64("his_patient_id")
  3003. //record_time := c.GetString("record_time")
  3004. admin_user_id = 3626
  3005. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3006. //id, _ := c.GetInt64("id")
  3007. admin_user_id = 3626
  3008. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3009. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3010. flow, _ := service.Getflowtwo(his.Number)
  3011. //id = 3
  3012. var cFYLJG005 models.CFYLJG005
  3013. //patient_id, _ := c.GetInt64("patient_id")
  3014. cFYLJG005.HiRxno = flow.HiRxno
  3015. cFYLJG005.MdtrtID = flow.MID
  3016. cFYLJG005.EcToken = ""
  3017. cFYLJG005.PsnName = his.Name
  3018. cFYLJG005.PsnCertType = "01"
  3019. cFYLJG005.Certno = his.IdCardNo
  3020. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  3021. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  3022. var res ResultCFYLJG005
  3023. var respJSON2 map[string]interface{}
  3024. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3025. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3027. return
  3028. }
  3029. userJSONBytes2, _ := json.Marshal(respJSON2)
  3030. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3031. utils.ErrorLog("解析失败:%v", err)
  3032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3033. return
  3034. }
  3035. if res.Infcode == -1 {
  3036. c.ServeSuccessJSON(map[string]interface{}{
  3037. "failed_code": -10,
  3038. "msg": res.ErrMsg,
  3039. })
  3040. return
  3041. } else {
  3042. c.ServeSuccessJSON(map[string]interface{}{
  3043. "info": res.Output,
  3044. })
  3045. return
  3046. }
  3047. }
  3048. func (c *HisApiController) GetCFYLJG006() {
  3049. admin_user_id, _ := c.GetInt64("admin_user_id")
  3050. his_patient_id, _ := c.GetInt64("his_patient_id")
  3051. admin_user_id = 3626
  3052. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3053. //id, _ := c.GetInt64("id")
  3054. admin_user_id = 3626
  3055. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3056. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3057. flow, _ := service.Getflowtwo(his.Number)
  3058. //id = 3
  3059. patient_id, _ := c.GetInt64("patient_id")
  3060. var cFYLJG006 models.CFYLJG006
  3061. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3062. cFYLJG006.HiRxno = flow.HiRxno
  3063. cFYLJG006.MdtrtID = flow.MID
  3064. cFYLJG006.PsnName = patient.Name
  3065. cFYLJG006.PsnCertType = "01"
  3066. cFYLJG006.Certno = patient.IdCardNo
  3067. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  3068. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  3069. var res ResultCFYLJG006
  3070. var respJSON2 map[string]interface{}
  3071. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3074. return
  3075. }
  3076. userJSONBytes2, _ := json.Marshal(respJSON2)
  3077. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3078. utils.ErrorLog("解析失败:%v", err)
  3079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3080. return
  3081. }
  3082. if res.Infcode == -1 {
  3083. c.ServeSuccessJSON(map[string]interface{}{
  3084. "failed_code": -10,
  3085. "msg": res.ErrMsg,
  3086. })
  3087. return
  3088. } else {
  3089. c.ServeSuccessJSON(map[string]interface{}{
  3090. "info": res.Output,
  3091. })
  3092. return
  3093. }
  3094. }
  3095. func (c *HisApiController) GetCFYLJG007() {
  3096. admin_user_id, _ := c.GetInt64("admin_user_id")
  3097. his_patient_id, _ := c.GetInt64("his_patient_id")
  3098. admin_user_id = 3626
  3099. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3100. //id, _ := c.GetInt64("id")
  3101. admin_user_id = 3626
  3102. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3103. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3104. flow, _ := service.Getflowtwo(his.Number)
  3105. //id = 3
  3106. patient_id, _ := c.GetInt64("patient_id")
  3107. var cFYLJG007 models.CFYLJG007
  3108. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3109. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3110. cFYLJG007.HiRxno = flow.HiRxno
  3111. cFYLJG007.MdtrtID = flow.MID
  3112. cFYLJG007.PsnNo = his.PsnNo
  3113. cFYLJG007.PsnCertType = "01"
  3114. cFYLJG007.Certno = patient.IdCardNo
  3115. cFYLJG007.PsnName = patient.Name
  3116. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3117. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3118. var res ResultCFYLJG007
  3119. var respJSON2 map[string]interface{}
  3120. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3123. return
  3124. }
  3125. userJSONBytes2, _ := json.Marshal(respJSON2)
  3126. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3127. utils.ErrorLog("解析失败:%v", err)
  3128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3129. return
  3130. }
  3131. if res.Infcode == -1 {
  3132. c.ServeSuccessJSON(map[string]interface{}{
  3133. "failed_code": -10,
  3134. "msg": res.ErrMsg,
  3135. })
  3136. return
  3137. } else {
  3138. c.ServeSuccessJSON(map[string]interface{}{
  3139. "info": res,
  3140. })
  3141. return
  3142. }
  3143. }
  3144. func (c *HisApiController) GetCFYLJG008() {
  3145. admin_user_id, _ := c.GetInt64("admin_user_id")
  3146. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3147. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3148. var cFYLJG008 models.CFYLJG008
  3149. //id, _ := c.GetInt64("id")
  3150. patient_id, _ := c.GetInt64("patient_id")
  3151. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3152. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3153. //id = 3
  3154. //flow, _ := service.Getflow(id)
  3155. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3156. //
  3157. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3158. //patient_id, _ := c.GetInt64("patient_id")
  3159. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3160. record_time := c.GetString("record_time")
  3161. admin_user_id = 3626
  3162. patient_id = 19424
  3163. //his_patient_id = 263947
  3164. record_time = "2023-08-29"
  3165. timeLayout := "2006-01-02"
  3166. loc, _ := time.LoadLocation("Local")
  3167. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3168. if err != nil {
  3169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3170. return
  3171. }
  3172. recordDateTime := theTime.Unix()
  3173. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3174. cFYLJG008.FixmedinsName = ""
  3175. cFYLJG008.Lat = ""
  3176. cFYLJG008.Lng = ""
  3177. cFYLJG008.OrderType = "1"
  3178. cFYLJG008.PoolareaNo = ""
  3179. cFYLJG008.Lng = ""
  3180. cFYLJG008.PageNum = 1
  3181. cFYLJG008.PageSize = 10
  3182. var MPI models.MedinsProdInvChgDDTO
  3183. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3184. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3185. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3186. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3187. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3188. var res ResultCFYLJG008
  3189. var respJSON2 map[string]interface{}
  3190. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3193. return
  3194. }
  3195. userJSONBytes2, _ := json.Marshal(respJSON2)
  3196. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3197. utils.ErrorLog("解析失败:%v", err)
  3198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3199. return
  3200. }
  3201. if res.Infcode == -1 {
  3202. c.ServeSuccessJSON(map[string]interface{}{
  3203. "failed_code": -10,
  3204. "msg": res.ErrMsg,
  3205. })
  3206. return
  3207. } else {
  3208. c.ServeSuccessJSON(map[string]interface{}{
  3209. "info": res.Output,
  3210. })
  3211. return
  3212. }
  3213. }
  3214. func (c *HisApiController) GetBL4201A() {
  3215. order_id, _ := c.GetInt64("order_id")
  3216. admin_user_id, _ := c.GetInt64("admin_user_id")
  3217. order, _ := service.GetHisOrderByIDTwo(order_id)
  3218. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3219. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3220. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3221. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3222. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3223. department, _ := service.GetDepartMentDetail(his.Departments)
  3224. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3225. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3226. if order.ID == 0 {
  3227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3228. return
  3229. }
  3230. var struct4201A models.Struct4201A
  3231. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3232. for _, items := range order_info {
  3233. memo := make(map[string]interface{})
  3234. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3235. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3236. fsiOPFLD.MedType = "14"
  3237. fsiOPFLD.BkkpSn = items.FeedetlSn
  3238. fsiOPFLD.FixmedinsCode = miConfig.Code
  3239. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3240. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3241. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3242. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3243. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3244. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3245. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3246. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3247. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3248. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3249. fsiOPFLD.BilgDeptName = department.Name
  3250. fsiOPFLD.BilgDeptCodg = department.Number
  3251. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3252. fsiOPFLD.BilgDrName = doctor.UserName
  3253. fsiOPFLD.MedChrgitmType = "09"
  3254. memo["hosp_appr_flag"] = "1"
  3255. memo["invoice_no"] = order.MdtrtId
  3256. memo["memo"] = "自费"
  3257. bytesData, _ := json.Marshal(memo)
  3258. fsiOPFLD.Memo = string(bytesData)
  3259. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3260. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3261. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3262. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3263. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3264. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3265. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3266. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3267. fsiOPFLD.BilgDeptName = department.Name
  3268. fsiOPFLD.BilgDeptCodg = department.Number
  3269. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3270. fsiOPFLD.BilgDrName = doctor.UserName
  3271. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3272. case 0:
  3273. break
  3274. case 1:
  3275. fsiOPFLD.MedChrgitmType = "14"
  3276. break
  3277. case 2:
  3278. fsiOPFLD.MedChrgitmType = "05"
  3279. break
  3280. case 3:
  3281. fsiOPFLD.MedChrgitmType = "03"
  3282. break
  3283. case 4:
  3284. fsiOPFLD.MedChrgitmType = "03"
  3285. break
  3286. case 5:
  3287. fsiOPFLD.MedChrgitmType = "08"
  3288. break
  3289. case 6:
  3290. fsiOPFLD.MedChrgitmType = "14"
  3291. break
  3292. case 7:
  3293. fsiOPFLD.MedChrgitmType = "14"
  3294. break
  3295. case 8:
  3296. fsiOPFLD.MedChrgitmType = "03"
  3297. break
  3298. case 9:
  3299. fsiOPFLD.MedChrgitmType = "14"
  3300. break
  3301. case 10:
  3302. fsiOPFLD.MedChrgitmType = "14"
  3303. break
  3304. case 11:
  3305. fsiOPFLD.MedChrgitmType = "06"
  3306. break
  3307. case 12:
  3308. fsiOPFLD.MedChrgitmType = "12"
  3309. break
  3310. case 13:
  3311. fsiOPFLD.MedChrgitmType = "01"
  3312. break
  3313. case 14:
  3314. fsiOPFLD.MedChrgitmType = "04"
  3315. break
  3316. case 15:
  3317. fsiOPFLD.MedChrgitmType = "14"
  3318. break
  3319. }
  3320. memo["hosp_appr_flag"] = "1"
  3321. memo["invoice_no"] = order.MdtrtId
  3322. memo["memo"] = "自费"
  3323. bytesData, _ := json.Marshal(memo)
  3324. fsiOPFLD.Memo = string(bytesData)
  3325. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3326. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3327. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3328. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3329. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3330. fsiOPFLD.BilgDeptName = department.Name
  3331. fsiOPFLD.BilgDeptCodg = department.Number
  3332. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3333. fsiOPFLD.BilgDrName = doctor.UserName
  3334. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3335. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3336. fsiOPFLD.MedChrgitmType = "08"
  3337. memo["hosp_appr_flag"] = "1"
  3338. memo["invoice_no"] = order.MdtrtId
  3339. memo["memo"] = "自费"
  3340. bytesData, _ := json.Marshal(memo)
  3341. fsiOPFLD.Memo = string(bytesData)
  3342. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3343. }
  3344. }
  3345. }
  3346. for _, items := range order_info_two {
  3347. memo := make(map[string]interface{})
  3348. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3349. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3350. fsiOPFLD.MedType = "14"
  3351. fsiOPFLD.BkkpSn = items.FeedetlSn
  3352. fsiOPFLD.FixmedinsCode = miConfig.Code
  3353. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3354. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3355. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3356. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3357. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3358. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3359. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3360. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3361. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3362. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3363. fsiOPFLD.BilgDeptName = department.Name
  3364. fsiOPFLD.BilgDeptCodg = department.Number
  3365. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3366. fsiOPFLD.BilgDrName = doctor.UserName
  3367. fsiOPFLD.MedChrgitmType = "09"
  3368. memo["hosp_appr_flag"] = "1"
  3369. memo["invoice_no"] = order.MdtrtId
  3370. memo["memo"] = "自费"
  3371. bytesData, _ := json.Marshal(memo)
  3372. fsiOPFLD.Memo = string(bytesData)
  3373. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3374. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3375. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3376. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3377. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3378. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3379. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3380. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3381. fsiOPFLD.BilgDeptName = department.Name
  3382. fsiOPFLD.BilgDeptCodg = department.Number
  3383. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3384. fsiOPFLD.BilgDrName = doctor.UserName
  3385. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3386. case 0:
  3387. break
  3388. case 1:
  3389. fsiOPFLD.MedChrgitmType = "14"
  3390. break
  3391. case 2:
  3392. fsiOPFLD.MedChrgitmType = "05"
  3393. break
  3394. case 3:
  3395. fsiOPFLD.MedChrgitmType = "03"
  3396. break
  3397. case 4:
  3398. fsiOPFLD.MedChrgitmType = "03"
  3399. break
  3400. case 5:
  3401. fsiOPFLD.MedChrgitmType = "08"
  3402. break
  3403. case 6:
  3404. fsiOPFLD.MedChrgitmType = "14"
  3405. break
  3406. case 7:
  3407. fsiOPFLD.MedChrgitmType = "14"
  3408. break
  3409. case 8:
  3410. fsiOPFLD.MedChrgitmType = "03"
  3411. break
  3412. case 9:
  3413. fsiOPFLD.MedChrgitmType = "14"
  3414. break
  3415. case 10:
  3416. fsiOPFLD.MedChrgitmType = "14"
  3417. break
  3418. case 11:
  3419. fsiOPFLD.MedChrgitmType = "06"
  3420. break
  3421. case 12:
  3422. fsiOPFLD.MedChrgitmType = "12"
  3423. break
  3424. case 13:
  3425. fsiOPFLD.MedChrgitmType = "01"
  3426. break
  3427. case 14:
  3428. fsiOPFLD.MedChrgitmType = "04"
  3429. break
  3430. case 15:
  3431. fsiOPFLD.MedChrgitmType = "14"
  3432. break
  3433. }
  3434. memo["hosp_appr_flag"] = "1"
  3435. memo["invoice_no"] = order.MdtrtId
  3436. memo["memo"] = "自费"
  3437. bytesData, _ := json.Marshal(memo)
  3438. fsiOPFLD.Memo = string(bytesData)
  3439. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3440. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3441. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3442. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3443. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3444. fsiOPFLD.BilgDeptName = department.Name
  3445. fsiOPFLD.BilgDeptCodg = department.Number
  3446. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3447. fsiOPFLD.BilgDrName = doctor.UserName
  3448. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3449. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3450. fsiOPFLD.MedChrgitmType = "08"
  3451. memo["hosp_appr_flag"] = "1"
  3452. memo["invoice_no"] = order.MdtrtId
  3453. memo["memo"] = "自费"
  3454. bytesData, _ := json.Marshal(memo)
  3455. fsiOPFLD.Memo = string(bytesData)
  3456. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3457. }
  3458. }
  3459. }
  3460. fmt.Println(fsiOPFLDs)
  3461. struct4201A.Fopfd = fsiOPFLDs
  3462. fmt.Println(struct4201A.Fopfd)
  3463. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3464. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3465. var res2 ResultSix
  3466. var respJSON2 map[string]interface{}
  3467. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3470. return
  3471. }
  3472. userJSONBytes2, _ := json.Marshal(respJSON2)
  3473. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3474. utils.ErrorLog("解析失败:%v", err)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3476. return
  3477. }
  3478. if res2.Infcode != 0 {
  3479. c.ServeSuccessJSON(map[string]interface{}{
  3480. "failed_code": -10,
  3481. "msg": res2.ErrMsg,
  3482. })
  3483. return
  3484. } else {
  3485. order.IsUploadOrderInfo = 1
  3486. service.UpdateOrder(order)
  3487. c.ServeSuccessJSON(map[string]interface{}{
  3488. "msg": "上传成功",
  3489. })
  3490. }
  3491. }
  3492. func (c *HisApiController) Get2505() {
  3493. admin_user_id, _ := c.GetInt64("admin_user_id")
  3494. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3495. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3496. 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)
  3497. }
  3498. func (c *HisApiController) Get4201A() {
  3499. order_id, _ := c.GetInt64("order_id")
  3500. admin_user_id, _ := c.GetInt64("admin_user_id")
  3501. order, _ := service.GetHisOrderByIDTwo(order_id)
  3502. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3503. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3504. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3505. //order_info = append(order_info, order_info_two...)
  3506. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3507. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3508. department, _ := service.GetDepartMentDetail(his.Departments)
  3509. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3510. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3511. if order.ID == 0 {
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3513. return
  3514. }
  3515. var struct4201A models.Struct4201A
  3516. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3517. for _, items := range order_info {
  3518. memo := make(map[string]interface{})
  3519. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3520. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3521. fsiOPFLD.MedType = "14"
  3522. fsiOPFLD.BkkpSn = items.FeedetlSn
  3523. fsiOPFLD.FixmedinsCode = miConfig.Code
  3524. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3525. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3526. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3527. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3528. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3529. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3530. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3531. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3532. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3533. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3534. fsiOPFLD.BilgDeptName = department.Name
  3535. fsiOPFLD.BilgDeptCodg = department.Number
  3536. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3537. fsiOPFLD.BilgDrName = doctor.UserName
  3538. fsiOPFLD.MedChrgitmType = "09"
  3539. memo["hosp_appr_flag"] = "1"
  3540. memo["invoice_no"] = order.MdtrtId
  3541. memo["memo"] = "自费"
  3542. bytesData, _ := json.Marshal(memo)
  3543. fsiOPFLD.Memo = string(bytesData)
  3544. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3545. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3546. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3547. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3548. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3549. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3550. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3551. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3552. fsiOPFLD.BilgDeptName = department.Name
  3553. fsiOPFLD.BilgDeptCodg = department.Number
  3554. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3555. fsiOPFLD.BilgDrName = doctor.UserName
  3556. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3557. case 0:
  3558. break
  3559. case 1:
  3560. fsiOPFLD.MedChrgitmType = "14"
  3561. break
  3562. case 2:
  3563. fsiOPFLD.MedChrgitmType = "05"
  3564. break
  3565. case 3:
  3566. fsiOPFLD.MedChrgitmType = "03"
  3567. break
  3568. case 4:
  3569. fsiOPFLD.MedChrgitmType = "03"
  3570. break
  3571. case 5:
  3572. fsiOPFLD.MedChrgitmType = "08"
  3573. break
  3574. case 6:
  3575. fsiOPFLD.MedChrgitmType = "14"
  3576. break
  3577. case 7:
  3578. fsiOPFLD.MedChrgitmType = "14"
  3579. break
  3580. case 8:
  3581. fsiOPFLD.MedChrgitmType = "03"
  3582. break
  3583. case 9:
  3584. fsiOPFLD.MedChrgitmType = "14"
  3585. break
  3586. case 10:
  3587. fsiOPFLD.MedChrgitmType = "14"
  3588. break
  3589. case 11:
  3590. fsiOPFLD.MedChrgitmType = "06"
  3591. break
  3592. case 12:
  3593. fsiOPFLD.MedChrgitmType = "12"
  3594. break
  3595. case 13:
  3596. fsiOPFLD.MedChrgitmType = "01"
  3597. break
  3598. case 14:
  3599. fsiOPFLD.MedChrgitmType = "04"
  3600. break
  3601. case 15:
  3602. fsiOPFLD.MedChrgitmType = "14"
  3603. break
  3604. }
  3605. memo["hosp_appr_flag"] = "1"
  3606. memo["invoice_no"] = order.MdtrtId
  3607. memo["memo"] = "自费"
  3608. bytesData, _ := json.Marshal(memo)
  3609. fsiOPFLD.Memo = string(bytesData)
  3610. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3611. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3612. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3613. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3614. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3615. fsiOPFLD.BilgDeptName = department.Name
  3616. fsiOPFLD.BilgDeptCodg = department.Number
  3617. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3618. fsiOPFLD.BilgDrName = doctor.UserName
  3619. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3620. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3621. fsiOPFLD.MedChrgitmType = "08"
  3622. memo["hosp_appr_flag"] = "1"
  3623. memo["invoice_no"] = order.MdtrtId
  3624. memo["memo"] = "自费"
  3625. bytesData, _ := json.Marshal(memo)
  3626. fsiOPFLD.Memo = string(bytesData)
  3627. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3628. }
  3629. }
  3630. }
  3631. for _, items := range order_info_two {
  3632. memo := make(map[string]interface{})
  3633. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3634. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3635. fsiOPFLD.MedType = "14"
  3636. fsiOPFLD.BkkpSn = items.FeedetlSn
  3637. fsiOPFLD.FixmedinsCode = miConfig.Code
  3638. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3639. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3640. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3641. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3642. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3643. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3644. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3645. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3646. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3647. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3648. fsiOPFLD.BilgDeptName = department.Name
  3649. fsiOPFLD.BilgDeptCodg = department.Number
  3650. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3651. fsiOPFLD.BilgDrName = doctor.UserName
  3652. fsiOPFLD.MedChrgitmType = "09"
  3653. memo["hosp_appr_flag"] = "1"
  3654. memo["invoice_no"] = order.MdtrtId
  3655. memo["memo"] = "自费"
  3656. bytesData, _ := json.Marshal(memo)
  3657. fsiOPFLD.Memo = string(bytesData)
  3658. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3659. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3660. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3661. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3662. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3663. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3664. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3665. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3666. fsiOPFLD.BilgDeptName = department.Name
  3667. fsiOPFLD.BilgDeptCodg = department.Number
  3668. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3669. fsiOPFLD.BilgDrName = doctor.UserName
  3670. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3671. case 0:
  3672. break
  3673. case 1:
  3674. fsiOPFLD.MedChrgitmType = "14"
  3675. break
  3676. case 2:
  3677. fsiOPFLD.MedChrgitmType = "05"
  3678. break
  3679. case 3:
  3680. fsiOPFLD.MedChrgitmType = "03"
  3681. break
  3682. case 4:
  3683. fsiOPFLD.MedChrgitmType = "03"
  3684. break
  3685. case 5:
  3686. fsiOPFLD.MedChrgitmType = "08"
  3687. break
  3688. case 6:
  3689. fsiOPFLD.MedChrgitmType = "14"
  3690. break
  3691. case 7:
  3692. fsiOPFLD.MedChrgitmType = "14"
  3693. break
  3694. case 8:
  3695. fsiOPFLD.MedChrgitmType = "03"
  3696. break
  3697. case 9:
  3698. fsiOPFLD.MedChrgitmType = "14"
  3699. break
  3700. case 10:
  3701. fsiOPFLD.MedChrgitmType = "14"
  3702. break
  3703. case 11:
  3704. fsiOPFLD.MedChrgitmType = "06"
  3705. break
  3706. case 12:
  3707. fsiOPFLD.MedChrgitmType = "12"
  3708. break
  3709. case 13:
  3710. fsiOPFLD.MedChrgitmType = "01"
  3711. break
  3712. case 14:
  3713. fsiOPFLD.MedChrgitmType = "04"
  3714. break
  3715. case 15:
  3716. fsiOPFLD.MedChrgitmType = "14"
  3717. break
  3718. }
  3719. memo["hosp_appr_flag"] = "1"
  3720. memo["invoice_no"] = order.MdtrtId
  3721. memo["memo"] = "自费"
  3722. bytesData, _ := json.Marshal(memo)
  3723. fsiOPFLD.Memo = string(bytesData)
  3724. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3725. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3726. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3727. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3728. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3729. fsiOPFLD.BilgDeptName = department.Name
  3730. fsiOPFLD.BilgDeptCodg = department.Number
  3731. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3732. fsiOPFLD.BilgDrName = doctor.UserName
  3733. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3734. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3735. fsiOPFLD.MedChrgitmType = "08"
  3736. memo["hosp_appr_flag"] = "1"
  3737. memo["invoice_no"] = order.MdtrtId
  3738. memo["memo"] = "自费"
  3739. bytesData, _ := json.Marshal(memo)
  3740. fsiOPFLD.Memo = string(bytesData)
  3741. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3742. }
  3743. }
  3744. }
  3745. fmt.Println(fsiOPFLDs)
  3746. struct4201A.Fopfd = fsiOPFLDs
  3747. fmt.Println(struct4201A.Fopfd)
  3748. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3749. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3750. var res2 ResultSix
  3751. var respJSON2 map[string]interface{}
  3752. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3753. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3755. return
  3756. }
  3757. userJSONBytes2, _ := json.Marshal(respJSON2)
  3758. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3759. utils.ErrorLog("解析失败:%v", err)
  3760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3761. return
  3762. }
  3763. if res2.Infcode != 0 {
  3764. c.ServeSuccessJSON(map[string]interface{}{
  3765. "failed_code": -10,
  3766. "msg": res2.ErrMsg,
  3767. })
  3768. return
  3769. } else {
  3770. order.IsUploadOrderInfo = 1
  3771. service.UpdateOrder(order)
  3772. c.ServeSuccessJSON(map[string]interface{}{
  3773. "msg": "上传成功",
  3774. })
  3775. }
  3776. }
  3777. func (c *HisApiController) Get4202() {
  3778. order_id, _ := c.GetInt64("order_id")
  3779. admin_user_id, _ := c.GetInt64("admin_user_id")
  3780. order, _ := service.GetHisOrderByIDTwo(order_id)
  3781. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3782. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3783. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3784. if order.ID == 0 {
  3785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3786. return
  3787. }
  3788. var struct4202 models.Struct4202
  3789. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3790. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3791. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3792. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3793. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3794. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3795. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3796. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3797. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3798. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3799. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3800. var config []*models.HisXtDiagnoseConfig
  3801. for _, item := range diagnosis_ids {
  3802. id, _ := strconv.ParseInt(item, 10, 64)
  3803. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3804. config = append(config, &diagnosisConfig)
  3805. }
  3806. var tempDiaginfos []models.OwnPayPatnDiagListD
  3807. for index, item := range config {
  3808. if index == 0 {
  3809. var tempDiaginfo models.OwnPayPatnDiagListD
  3810. tempDiaginfo.InoutDiagType = "1"
  3811. tempDiaginfo.DiagCode = item.CountryCode
  3812. tempDiaginfo.DiagName = item.CountryContentName
  3813. tempDiaginfo.DiagType = "1"
  3814. tempDiaginfo.DiagSrtNo = "1"
  3815. tempDiaginfo.MaindiagFlag = "1"
  3816. tempDiaginfo.ValiFlag = "1"
  3817. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3818. } else {
  3819. var tempDiaginfo models.OwnPayPatnDiagListD
  3820. tempDiaginfo.DiagCode = item.CountryCode
  3821. tempDiaginfo.DiagName = item.CountryContentName
  3822. tempDiaginfo.DiagType = "2"
  3823. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3824. tempDiaginfo.MaindiagFlag = "0"
  3825. tempDiaginfo.ValiFlag = "1"
  3826. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3827. }
  3828. }
  3829. struct4202.ODiagListD = tempDiaginfos
  3830. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3831. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3832. var res2 ResultSix
  3833. var respJSON2 map[string]interface{}
  3834. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3835. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3837. return
  3838. }
  3839. userJSONBytes2, _ := json.Marshal(respJSON2)
  3840. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3841. utils.ErrorLog("解析失败:%v", err)
  3842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3843. return
  3844. }
  3845. if res2.Infcode != 0 {
  3846. c.ServeSuccessJSON(map[string]interface{}{
  3847. "failed_code": -10,
  3848. "msg": res2.ErrMsg,
  3849. })
  3850. return
  3851. } else {
  3852. order.IsUploadDiagnose = 1
  3853. service.UpdateOrder(order)
  3854. c.ServeSuccessJSON(map[string]interface{}{
  3855. "msg": "上传成功",
  3856. })
  3857. }
  3858. }
  3859. func (c *HisApiController) Get4203() {
  3860. admin_user_id, _ := c.GetInt64("admin_user_id")
  3861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3863. order_id, _ := c.GetInt64("order_id")
  3864. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3865. number := ""
  3866. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3867. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3868. if his.ID == 0 {
  3869. number = hospital.Number
  3870. } else {
  3871. number = his.Number
  3872. }
  3873. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3874. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3875. var res2 ResultSix
  3876. var respJSON2 map[string]interface{}
  3877. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3878. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3880. return
  3881. }
  3882. userJSONBytes2, _ := json.Marshal(respJSON2)
  3883. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3884. utils.ErrorLog("解析失败:%v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. if res2.Infcode != 0 {
  3889. c.ServeSuccessJSON(map[string]interface{}{
  3890. "failed_code": -10,
  3891. "msg": res2.ErrMsg,
  3892. })
  3893. return
  3894. } else {
  3895. order.IsUploadSuccess = 1
  3896. service.UpdateOrderTwo(order)
  3897. c.ServeSuccessJSON(map[string]interface{}{
  3898. "msg": "上传成功",
  3899. })
  3900. }
  3901. }
  3902. func (c *HisApiController) Get4205() {
  3903. order_id, _ := c.GetInt64("order_id")
  3904. admin_user_id, _ := c.GetInt64("admin_user_id")
  3905. fapiao_code := c.GetString("fapiao_code")
  3906. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3907. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3908. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3910. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3911. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3912. //order_info = append(order_info, order_info_two...)
  3913. department, _ := service.GetDepartMentDetail(his.Departments)
  3914. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3915. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3916. if order.ID == 0 {
  3917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3918. return
  3919. }
  3920. var struct4201A models.Struct4201A
  3921. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3922. for _, items := range order_info {
  3923. memo := make(map[string]interface{})
  3924. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3925. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3926. fsiOPFLD.MedType = pre.MedType
  3927. fsiOPFLD.FixmedinsCode = miConfig.Code
  3928. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3929. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3930. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3931. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3932. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3933. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3934. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3935. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3936. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3937. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3938. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3939. fsiOPFLD.BilgDeptName = department.Name
  3940. fsiOPFLD.BilgDeptCodg = department.Number
  3941. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3942. fsiOPFLD.BilgDrName = doctor.UserName
  3943. fsiOPFLD.MedChrgitmType = "09"
  3944. memo["hosp_appr_flag"] = "1"
  3945. memo["invoice_no"] = fapiao_code
  3946. memo["memo"] = "自费"
  3947. bytesData, _ := json.Marshal(memo)
  3948. fsiOPFLD.Memo = string(bytesData)
  3949. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3950. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3951. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3952. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3953. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3954. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3955. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3956. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3957. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3958. fsiOPFLD.BilgDeptName = department.Name
  3959. fsiOPFLD.BilgDeptCodg = department.Number
  3960. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3961. fsiOPFLD.BilgDrName = doctor.UserName
  3962. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3963. case 0:
  3964. break
  3965. case 1:
  3966. fsiOPFLD.MedChrgitmType = "14"
  3967. break
  3968. case 2:
  3969. fsiOPFLD.MedChrgitmType = "05"
  3970. break
  3971. case 3:
  3972. fsiOPFLD.MedChrgitmType = "03"
  3973. break
  3974. case 4:
  3975. fsiOPFLD.MedChrgitmType = "03"
  3976. break
  3977. case 5:
  3978. fsiOPFLD.MedChrgitmType = "08"
  3979. break
  3980. case 6:
  3981. fsiOPFLD.MedChrgitmType = "14"
  3982. break
  3983. case 7:
  3984. fsiOPFLD.MedChrgitmType = "14"
  3985. break
  3986. case 8:
  3987. fsiOPFLD.MedChrgitmType = "03"
  3988. break
  3989. case 9:
  3990. fsiOPFLD.MedChrgitmType = "14"
  3991. break
  3992. case 10:
  3993. fsiOPFLD.MedChrgitmType = "14"
  3994. break
  3995. case 11:
  3996. fsiOPFLD.MedChrgitmType = "06"
  3997. break
  3998. case 12:
  3999. fsiOPFLD.MedChrgitmType = "12"
  4000. break
  4001. case 13:
  4002. fsiOPFLD.MedChrgitmType = "01"
  4003. break
  4004. case 14:
  4005. fsiOPFLD.MedChrgitmType = "04"
  4006. break
  4007. case 15:
  4008. fsiOPFLD.MedChrgitmType = "14"
  4009. break
  4010. }
  4011. memo["hosp_appr_flag"] = "1"
  4012. memo["invoice_no"] = fapiao_code
  4013. memo["memo"] = "自费"
  4014. bytesData, _ := json.Marshal(memo)
  4015. fsiOPFLD.Memo = string(bytesData)
  4016. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4017. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  4018. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4019. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4020. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4021. fsiOPFLD.BilgDeptName = department.Name
  4022. fsiOPFLD.BilgDeptCodg = department.Number
  4023. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4024. fsiOPFLD.BilgDrName = doctor.UserName
  4025. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4026. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4027. fsiOPFLD.MedChrgitmType = "08"
  4028. memo["hosp_appr_flag"] = "1"
  4029. memo["invoice_no"] = fapiao_code
  4030. memo["memo"] = "自费"
  4031. bytesData, _ := json.Marshal(memo)
  4032. fsiOPFLD.Memo = string(bytesData)
  4033. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4034. }
  4035. }
  4036. }
  4037. for _, items := range order_info_two {
  4038. memo := make(map[string]interface{})
  4039. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  4040. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  4041. fsiOPFLD.MedType = pre.MedType
  4042. fsiOPFLD.BkkpSn = items.FeedetlSn
  4043. fsiOPFLD.FixmedinsCode = miConfig.Code
  4044. fsiOPFLD.FixmedinsName = miConfig.OrgName
  4045. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  4046. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  4047. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  4048. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4049. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  4050. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4051. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  4052. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4053. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  4054. fsiOPFLD.BilgDeptName = department.Name
  4055. fsiOPFLD.BilgDeptCodg = department.Number
  4056. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4057. fsiOPFLD.BilgDrName = doctor.UserName
  4058. fsiOPFLD.MedChrgitmType = "09"
  4059. memo["hosp_appr_flag"] = "1"
  4060. memo["invoice_no"] = fapiao_code
  4061. memo["memo"] = "自费"
  4062. bytesData, _ := json.Marshal(memo)
  4063. fsiOPFLD.Memo = string(bytesData)
  4064. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4065. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  4066. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  4067. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  4068. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4069. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4070. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  4071. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  4072. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  4073. fsiOPFLD.BilgDeptName = department.Name
  4074. fsiOPFLD.BilgDeptCodg = department.Number
  4075. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4076. fsiOPFLD.BilgDrName = doctor.UserName
  4077. switch items.HisPrescriptionProject.HisProject.CostClassify {
  4078. case 0:
  4079. break
  4080. case 1:
  4081. fsiOPFLD.MedChrgitmType = "14"
  4082. break
  4083. case 2:
  4084. fsiOPFLD.MedChrgitmType = "05"
  4085. break
  4086. case 3:
  4087. fsiOPFLD.MedChrgitmType = "03"
  4088. break
  4089. case 4:
  4090. fsiOPFLD.MedChrgitmType = "03"
  4091. break
  4092. case 5:
  4093. fsiOPFLD.MedChrgitmType = "08"
  4094. break
  4095. case 6:
  4096. fsiOPFLD.MedChrgitmType = "14"
  4097. break
  4098. case 7:
  4099. fsiOPFLD.MedChrgitmType = "14"
  4100. break
  4101. case 8:
  4102. fsiOPFLD.MedChrgitmType = "03"
  4103. break
  4104. case 9:
  4105. fsiOPFLD.MedChrgitmType = "14"
  4106. break
  4107. case 10:
  4108. fsiOPFLD.MedChrgitmType = "14"
  4109. break
  4110. case 11:
  4111. fsiOPFLD.MedChrgitmType = "06"
  4112. break
  4113. case 12:
  4114. fsiOPFLD.MedChrgitmType = "12"
  4115. break
  4116. case 13:
  4117. fsiOPFLD.MedChrgitmType = "01"
  4118. break
  4119. case 14:
  4120. fsiOPFLD.MedChrgitmType = "04"
  4121. break
  4122. case 15:
  4123. fsiOPFLD.MedChrgitmType = "14"
  4124. break
  4125. }
  4126. memo["hosp_appr_flag"] = "1"
  4127. memo["invoice_no"] = fapiao_code
  4128. memo["memo"] = "自费"
  4129. bytesData, _ := json.Marshal(memo)
  4130. fsiOPFLD.Memo = string(bytesData)
  4131. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4132. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4133. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4134. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4135. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4136. fsiOPFLD.BilgDeptName = department.Name
  4137. fsiOPFLD.BilgDeptCodg = department.Number
  4138. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4139. fsiOPFLD.BilgDrName = doctor.UserName
  4140. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4141. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4142. fsiOPFLD.MedChrgitmType = "08"
  4143. memo["hosp_appr_flag"] = "1"
  4144. memo["invoice_no"] = fapiao_code
  4145. memo["memo"] = "自费"
  4146. bytesData, _ := json.Marshal(memo)
  4147. fsiOPFLD.Memo = string(bytesData)
  4148. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4149. }
  4150. }
  4151. }
  4152. fmt.Println(fsiOPFLDs)
  4153. struct4201A.Fopfd = fsiOPFLDs
  4154. fmt.Println(struct4201A.Fopfd)
  4155. var struct4202 models.Struct4202
  4156. timeLayout := "2006-01-02 15:04:05"
  4157. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4158. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4159. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4160. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4161. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4162. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4163. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4164. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4165. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4166. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4167. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4168. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4169. var config []*models.HisXtDiagnoseConfig
  4170. for _, item := range diagnosis_ids {
  4171. id, _ := strconv.ParseInt(item, 10, 64)
  4172. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4173. config = append(config, &diagnosisConfig)
  4174. }
  4175. var tempDiaginfos []models.OwnPayPatnDiagListD
  4176. for index, item := range config {
  4177. if index == 0 {
  4178. var tempDiaginfo models.OwnPayPatnDiagListD
  4179. tempDiaginfo.InoutDiagType = "1"
  4180. tempDiaginfo.DiagCode = item.CountryCode
  4181. tempDiaginfo.DiagName = item.CountryContentName
  4182. tempDiaginfo.DiagType = "1"
  4183. tempDiaginfo.DiagSrtNo = "1"
  4184. tempDiaginfo.MaindiagFlag = "1"
  4185. tempDiaginfo.ValiFlag = "1"
  4186. tempDiaginfo.DiagDrName = doctor.UserName
  4187. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4188. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4189. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4190. } else {
  4191. var tempDiaginfo models.OwnPayPatnDiagListD
  4192. tempDiaginfo.DiagCode = item.CountryCode
  4193. tempDiaginfo.DiagName = item.CountryContentName
  4194. tempDiaginfo.DiagType = "2"
  4195. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4196. tempDiaginfo.MaindiagFlag = "0"
  4197. tempDiaginfo.ValiFlag = "1"
  4198. tempDiaginfo.DiagDrName = doctor.UserName
  4199. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4200. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4201. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4202. }
  4203. }
  4204. struct4202.ODiagListD = tempDiaginfos
  4205. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4206. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4207. var res2 ResultSix
  4208. var respJSON2 map[string]interface{}
  4209. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4212. return
  4213. }
  4214. userJSONBytes2, _ := json.Marshal(respJSON2)
  4215. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4216. utils.ErrorLog("解析失败:%v", err)
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4218. return
  4219. }
  4220. if res2.Infcode != 0 {
  4221. c.ServeSuccessJSON(map[string]interface{}{
  4222. "failed_code": -10,
  4223. "msg": res2.ErrMsg,
  4224. })
  4225. return
  4226. } else {
  4227. order.IsUploadDiagnose = 1
  4228. order.IsUploadOrderInfo = 1
  4229. service.UpdateOrderTwo(order)
  4230. c.ServeSuccessJSON(map[string]interface{}{
  4231. "msg": "上传成功",
  4232. })
  4233. }
  4234. }
  4235. func (c *HisApiController) Get4207() {
  4236. admin_user_id, _ := c.GetInt64("admin_user_id")
  4237. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4238. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4239. order_id, _ := c.GetInt64("order_id")
  4240. order, _ := service.GetHisOrderByIDTwo(order_id)
  4241. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4242. var struct4207 models.Struct4207
  4243. struct4207.PageNum = "1"
  4244. struct4207.PageSize = "1000"
  4245. struct4207.FixmedinsCode = miConfig.Code
  4246. struct4207.FixmedinsMdtrtID = order.Number
  4247. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4248. saveLog(result, requestLog, "4207", "查询")
  4249. var res2 ResultSix
  4250. var respJSON2 map[string]interface{}
  4251. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4254. return
  4255. }
  4256. userJSONBytes2, _ := json.Marshal(respJSON2)
  4257. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4258. utils.ErrorLog("解析失败:%v", err)
  4259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4260. return
  4261. }
  4262. if res2.Infcode != 0 {
  4263. c.ServeSuccessJSON(map[string]interface{}{
  4264. "failed_code": -10,
  4265. "msg": res2.ErrMsg,
  4266. })
  4267. return
  4268. } else {
  4269. c.ServeSuccessJSON(map[string]interface{}{
  4270. "msg": "查询成功",
  4271. })
  4272. }
  4273. }
  4274. func (c *HisApiController) Get4208() {
  4275. admin_user_id, _ := c.GetInt64("admin_user_id")
  4276. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4277. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4278. order_id, _ := c.GetInt64("order_id")
  4279. order, _ := service.GetHisOrderByIDTwo(order_id)
  4280. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4281. var struct4208 models.Struct4208
  4282. struct4208.PageNum = "1"
  4283. struct4208.PageSize = "1000"
  4284. struct4208.PsnCertType = "01"
  4285. struct4208.Certno = his.Certno
  4286. struct4208.MedType = order.MedType
  4287. struct4208.PsnName = his.Name
  4288. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4289. saveLog(result, requestLog, "4208", "查询")
  4290. var res2 ResultSix
  4291. var respJSON2 map[string]interface{}
  4292. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4295. return
  4296. }
  4297. userJSONBytes2, _ := json.Marshal(respJSON2)
  4298. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4299. utils.ErrorLog("解析失败:%v", err)
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. if res2.Infcode != 0 {
  4304. c.ServeSuccessJSON(map[string]interface{}{
  4305. "failed_code": -10,
  4306. "msg": res2.ErrMsg,
  4307. })
  4308. return
  4309. } else {
  4310. c.ServeSuccessJSON(map[string]interface{}{
  4311. "msg": "查询成功",
  4312. })
  4313. }
  4314. }
  4315. func (c *HisApiController) Get4209() {
  4316. admin_user_id, _ := c.GetInt64("admin_user_id")
  4317. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4319. order_id, _ := c.GetInt64("order_id")
  4320. order, _ := service.GetHisOrderByIDTwo(order_id)
  4321. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4322. var struct4209 models.Struct4209
  4323. struct4209.FixmedinsMdtrtID = order.Number
  4324. struct4209.FixmedinsCode = miConfig.Code
  4325. struct4209.PageSize = "1000"
  4326. struct4209.PageNum = "1"
  4327. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4328. saveLog(result, requestLog, "4209", "查询")
  4329. var res2 ResultSix
  4330. var respJSON2 map[string]interface{}
  4331. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4334. return
  4335. }
  4336. userJSONBytes2, _ := json.Marshal(respJSON2)
  4337. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4338. utils.ErrorLog("解析失败:%v", err)
  4339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4340. return
  4341. }
  4342. if res2.Infcode != 0 {
  4343. c.ServeSuccessJSON(map[string]interface{}{
  4344. "failed_code": -10,
  4345. "msg": res2.ErrMsg,
  4346. })
  4347. return
  4348. } else {
  4349. c.ServeSuccessJSON(map[string]interface{}{
  4350. "msg": "查询成功",
  4351. })
  4352. }
  4353. }
  4354. type Result3101 struct {
  4355. Infcode string `json:"infcode"`
  4356. InfRefmsgid string `json:"inf_refmsgid"`
  4357. RefmsgTime string `json:"refmsg_time"`
  4358. RespondTime string `json:"respond_time"`
  4359. Enctype string `json:"enctype"`
  4360. Signtype string `json:"signtype"`
  4361. ErrMsg string `json:"err_msg"`
  4362. Output struct {
  4363. Result []struct {
  4364. JudgeResultDetailDtos []struct {
  4365. VolaItemType string `json:"vola_item_type"`
  4366. MdtrtID string `json:"mdtrt_id"`
  4367. JrdID string `json:"jrd_id"`
  4368. PatnID string `json:"patn_id"`
  4369. RxID string `json:"rx_id"`
  4370. VolaAmt interface{} `json:"vola_amt"`
  4371. } `json:"judge_result_detail_dtos"`
  4372. RuleID string `json:"rule_id"`
  4373. VolaEvid string `json:"vola_evid"`
  4374. MdtrtID string `json:"mdtrt_id"`
  4375. RuleName string `json:"rule_name"`
  4376. VolaAmtStas string `json:"vola_amt_stas"`
  4377. JrID string `json:"jr_id"`
  4378. PatnID string `json:"patn_id"`
  4379. SevDeg string `json:"sev_deg"`
  4380. VolaAmt float64 `json:"vola_amt"`
  4381. VolaBhvrType string `json:"vola_bhvr_type"`
  4382. VolaCont string `json:"vola_cont"`
  4383. } `json:"result"`
  4384. } `json:"output"`
  4385. }
  4386. type Resultgd3101 struct {
  4387. Infcode int64 `json:"infcode"`
  4388. InfRefmsgid string `json:"inf_refmsgid"`
  4389. RefmsgTime string `json:"refmsg_time"`
  4390. RespondTime string `json:"respond_time"`
  4391. Enctype string `json:"enctype"`
  4392. Signtype string `json:"signtype"`
  4393. ErrMsg string `json:"err_msg"`
  4394. Output struct {
  4395. Result []struct {
  4396. JudgeResultDetailDtos []struct {
  4397. VolaItemType string `json:"vola_item_type"`
  4398. MdtrtID string `json:"mdtrt_id"`
  4399. JrdID string `json:"jrd_id"`
  4400. PatnID string `json:"patn_id"`
  4401. RxID string `json:"rx_id"`
  4402. VolaAmt interface{} `json:"vola_amt"`
  4403. } `json:"judge_result_detail_dtos"`
  4404. RuleID string `json:"rule_id"`
  4405. VolaEvid string `json:"vola_evid"`
  4406. MdtrtID string `json:"mdtrt_id"`
  4407. RuleName string `json:"rule_name"`
  4408. VolaAmtStas string `json:"vola_amt_stas"`
  4409. JrID string `json:"jr_id"`
  4410. PatnID string `json:"patn_id"`
  4411. SevDeg string `json:"sev_deg"`
  4412. VolaAmt float64 `json:"vola_amt"`
  4413. VolaBhvrType string `json:"vola_bhvr_type"`
  4414. VolaCont string `json:"vola_cont"`
  4415. } `json:"result"`
  4416. } `json:"output"`
  4417. }
  4418. func (c *HisApiController) ReadEleToken() {
  4419. admin_user_id, _ := c.GetInt64("admin_user_id")
  4420. his_patient_id, _ := c.GetInt64("his_patient_id")
  4421. adminUser := c.GetAdminUserInfo()
  4422. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4423. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4424. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4425. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4426. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4427. if len(tokens) > 0 {
  4428. c.ServeSuccessJSON(map[string]interface{}{
  4429. "msg": "读取成功",
  4430. })
  4431. } else {
  4432. c.ServeSuccessJSON(map[string]interface{}{
  4433. "failed_code": -10,
  4434. "msg": "读取失败",
  4435. })
  4436. }
  4437. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4438. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4439. if len(tokens) > 0 {
  4440. c.ServeSuccessJSON(map[string]interface{}{
  4441. "msg": "读取成功",
  4442. })
  4443. } else {
  4444. c.ServeSuccessJSON(map[string]interface{}{
  4445. "failed_code": -10,
  4446. "msg": "读取失败",
  4447. })
  4448. }
  4449. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4450. var api string
  4451. 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 +
  4452. "&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"
  4453. resp, requestErr := http.Get(api)
  4454. if requestErr != nil {
  4455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4456. }
  4457. body, ioErr := ioutil.ReadAll(resp.Body)
  4458. if ioErr != nil {
  4459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4461. }
  4462. var respJSON map[string]interface{}
  4463. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4464. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4466. return
  4467. }
  4468. var status string
  4469. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4470. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4471. var token string
  4472. var res ResultTwo //1101结果
  4473. var res10265 ResultTwo10265 //1101结果
  4474. if status == "0" { //读卡成功
  4475. var card_info string //卡信息
  4476. var busi_card_info string
  4477. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4478. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4479. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4480. fmt.Println(card_info)
  4481. fmt.Println(busi_card_info)
  4482. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4483. result, _ := json.Marshal(respJSON)
  4484. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4485. utils.ErrorLog("解析失败:%v", err)
  4486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4487. return
  4488. }
  4489. res.ErrMsg = res10265.ErrMsg
  4490. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4491. res.Infcode = infocode
  4492. res.Output = res10265.Output
  4493. res.InfRefmsgid = res10265.InfRefmsgid
  4494. if res.Infcode == 0 {
  4495. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4496. if err == gorm.ErrRecordNotFound {
  4497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4498. return
  4499. } else if err != nil {
  4500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4501. return
  4502. } else {
  4503. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4504. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4505. infoStr := string(Iinfos)
  4506. idetinfoStr := string(Idetinfos)
  4507. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4508. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4509. psn := &models.HisPsn{
  4510. PsnNo: res.Output.Baseinfo.PsnNo,
  4511. PatientId: patient.ID,
  4512. Certno: res.Output.Baseinfo.Certno,
  4513. Gend: res.Output.Baseinfo.Gend,
  4514. Naty: res.Output.Baseinfo.Naty,
  4515. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4516. PsnName: res.Output.Baseinfo.PsnName,
  4517. Age: float64(age),
  4518. Brdy: b,
  4519. Idetinfo: idetinfoStr,
  4520. Insuinfo: infoStr,
  4521. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4522. CardInfo: card_info,
  4523. VerifyNumber: token,
  4524. IdCardType: 4,
  4525. }
  4526. var rf []*ResultFive
  4527. json.Unmarshal([]byte(infoStr), &rf)
  4528. var insutypes []*ResultFive
  4529. var insutype string
  4530. var is390 int = 0
  4531. var is310 int = 0
  4532. for _, item := range rf {
  4533. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4534. insutypes = append(insutypes, item)
  4535. }
  4536. }
  4537. if len(insutypes) == 1 {
  4538. insutype = insutypes[0].Insutype
  4539. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4540. } else {
  4541. for _, i := range insutypes {
  4542. if i.Insutype == "390" {
  4543. is390 = 1
  4544. }
  4545. if i.Insutype == "310" {
  4546. is310 = 1
  4547. }
  4548. }
  4549. }
  4550. if is390 == 1 {
  4551. insutype = "390"
  4552. }
  4553. if is310 == 1 {
  4554. insutype = "310"
  4555. }
  4556. if len(insutypes) == 0 {
  4557. insutype = "310"
  4558. }
  4559. service.CreateHisPsn(psn)
  4560. c.ServeSuccessJSON(map[string]interface{}{
  4561. "patient": patient,
  4562. "number": token,
  4563. "insutype": insutype,
  4564. })
  4565. }
  4566. } else {
  4567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4568. return
  4569. }
  4570. } else { //读卡失败
  4571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4572. return
  4573. }
  4574. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4575. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4576. if len(errMsg) == 0 {
  4577. type ELeData struct {
  4578. Data struct {
  4579. IdNo string `json:"idNo"`
  4580. IdType string `json:"idType"`
  4581. UserName string `json:"userName"`
  4582. EcToken string `json:"ecToken"`
  4583. InsuOrg string `json:"insuOrg"`
  4584. Gender string `json:"gender"`
  4585. Birthday string `json:"birthday"`
  4586. Nationality string `json:"nationality"`
  4587. Email string `json:"email"`
  4588. Extra string `json:"extra"`
  4589. } `json:"data"`
  4590. Code int `json:"code"`
  4591. Message string `json:"message"`
  4592. }
  4593. var ele ELeData
  4594. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4595. if err != nil {
  4596. utils.ErrorLog("解析失败:%v", err)
  4597. }
  4598. token := ele.Data.EcToken
  4599. if len(token) > 0 {
  4600. psn := &models.HisPsn{
  4601. PsnNo: his.PsnNo,
  4602. Age: 0,
  4603. PatientId: his.PatientId,
  4604. Certno: his.Certno,
  4605. Brdy: his.Brdy,
  4606. Gend: his.Gend,
  4607. Naty: his.Naty,
  4608. PsnCertType: his.PsnCertType,
  4609. PsnName: his.PsnName,
  4610. Idetinfo: his.Idetinfo,
  4611. Insuinfo: his.Iinfo,
  4612. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4613. CardInfo: outPutInfo,
  4614. VerifyNumber: token,
  4615. }
  4616. service.CreateHisPsn(psn)
  4617. }
  4618. if len(token) > 0 {
  4619. c.ServeSuccessJSON(map[string]interface{}{
  4620. "msg": "读取成功",
  4621. })
  4622. } else {
  4623. c.ServeSuccessJSON(map[string]interface{}{
  4624. "failed_code": -10,
  4625. "msg": "读取失败",
  4626. })
  4627. }
  4628. }
  4629. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4630. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4631. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4632. type ELeData struct {
  4633. Data struct {
  4634. IdNo string `json:"idNo"`
  4635. IdType string `json:"idType"`
  4636. UserName string `json:"userName"`
  4637. EcToken string `json:"ecToken"`
  4638. InsuOrg string `json:"insuOrg"`
  4639. Gender string `json:"gender"`
  4640. Birthday string `json:"birthday"`
  4641. Nationality string `json:"nationality"`
  4642. Email string `json:"email"`
  4643. Extra string `json:"extra"`
  4644. } `json:"data"`
  4645. Code int `json:"code"`
  4646. Message string `json:"message"`
  4647. }
  4648. var ele ELeData
  4649. err := json.Unmarshal([]byte(result), &ele)
  4650. if err != nil {
  4651. utils.ErrorLog("解析失败:%v", err)
  4652. }
  4653. token := ele.Data.EcToken
  4654. token = Remove0000(token)
  4655. fmt.Println(ele.Data.UserName)
  4656. 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)
  4657. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4658. var res ResultTwo
  4659. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4660. utils.ErrorLog("解析失败:%v", err)
  4661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4662. return
  4663. }
  4664. if res.Infcode == 0 {
  4665. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4666. if err == gorm.ErrRecordNotFound {
  4667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4668. return
  4669. } else if err != nil {
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4671. return
  4672. } else {
  4673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4675. infoStr := string(Iinfos)
  4676. idetinfoStr := string(Idetinfos)
  4677. psn := &models.HisPsn{
  4678. PsnNo: res.Output.Baseinfo.PsnNo,
  4679. PatientId: patient.ID,
  4680. Certno: res.Output.Baseinfo.Certno,
  4681. Gend: res.Output.Baseinfo.Gend,
  4682. Naty: res.Output.Baseinfo.Naty,
  4683. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4684. PsnName: res.Output.Baseinfo.PsnName,
  4685. Idetinfo: idetinfoStr,
  4686. Insuinfo: infoStr,
  4687. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4688. CardInfo: "",
  4689. VerifyNumber: token,
  4690. }
  4691. service.CreateHisPsn(psn)
  4692. c.ServeSuccessJSON(map[string]interface{}{
  4693. "patient": patient,
  4694. "number": token,
  4695. })
  4696. }
  4697. } else {
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4699. return
  4700. }
  4701. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4702. idNo := c.GetString("idNo")
  4703. userName := c.GetString("userName")
  4704. ecToken := c.GetString("ecToken")
  4705. insuOrg := c.GetString("insuOrg")
  4706. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4707. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4708. var res ResultTwo
  4709. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4710. utils.ErrorLog("解析失败:%v", err)
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. if res.Infcode == 0 {
  4715. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4716. if err == gorm.ErrRecordNotFound {
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4718. return
  4719. } else if err != nil {
  4720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4721. return
  4722. } else {
  4723. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4724. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4725. infoStr := string(Iinfos)
  4726. idetinfoStr := string(Idetinfos)
  4727. psn := &models.HisPsn{
  4728. PsnNo: res.Output.Baseinfo.PsnNo,
  4729. PatientId: patient.ID,
  4730. Certno: res.Output.Baseinfo.Certno,
  4731. Gend: res.Output.Baseinfo.Gend,
  4732. Naty: res.Output.Baseinfo.Naty,
  4733. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4734. PsnName: res.Output.Baseinfo.PsnName,
  4735. Idetinfo: idetinfoStr,
  4736. Insuinfo: infoStr,
  4737. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4738. CardInfo: "",
  4739. VerifyNumber: ecToken,
  4740. InsuplcAdmdvs: insuOrg,
  4741. }
  4742. service.CreateHisPsn(psn)
  4743. c.ServeSuccessJSON(map[string]interface{}{
  4744. "patient": patient,
  4745. "number": ecToken,
  4746. })
  4747. }
  4748. } else {
  4749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4750. return
  4751. }
  4752. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4753. res := c.GetoleInfo()
  4754. if res.Infcode == 0 {
  4755. var result string
  4756. if res.Output.MdtrtCertType == "01" {
  4757. 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)
  4758. } else if res.Output.MdtrtCertType == "02" {
  4759. 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)
  4760. } else if res.Output.MdtrtCertType == "03" {
  4761. 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)
  4762. }
  4763. var dat map[string]interface{}
  4764. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4765. fmt.Println(dat)
  4766. } else {
  4767. fmt.Println(err)
  4768. }
  4769. userJSONBytes, _ := json.Marshal(dat)
  4770. var res2 ResultTwo
  4771. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4772. utils.ErrorLog("解析失败:%v", err)
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. return
  4775. }
  4776. if res2.Infcode == 0 {
  4777. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4778. if err == gorm.ErrRecordNotFound {
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4780. return
  4781. } else if err != nil {
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4783. return
  4784. } else {
  4785. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4786. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4787. infoStr := string(Iinfos)
  4788. idetinfoStr := string(Idetinfos)
  4789. var rf []*ResultFive
  4790. json.Unmarshal([]byte(infoStr), &rf)
  4791. var insutypes []*ResultFive
  4792. var insutype string
  4793. var is390 int = 0
  4794. var is310 int = 0
  4795. //var insuplc_admdvs string
  4796. for _, item := range rf {
  4797. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4798. insutypes = append(insutypes, item)
  4799. }
  4800. }
  4801. if len(insutypes) == 1 {
  4802. insutype = insutypes[0].Insutype
  4803. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4804. } else {
  4805. for _, i := range insutypes {
  4806. if i.Insutype == "390" {
  4807. is390 = 1
  4808. }
  4809. if i.Insutype == "310" {
  4810. is310 = 1
  4811. }
  4812. }
  4813. }
  4814. if is390 == 1 {
  4815. insutype = "390"
  4816. }
  4817. if is310 == 1 {
  4818. insutype = "310"
  4819. }
  4820. if len(insutypes) == 0 {
  4821. insutype = "310"
  4822. }
  4823. psn := &models.HisPsn{
  4824. PsnNo: res2.Output.Baseinfo.PsnNo,
  4825. PatientId: patient.ID,
  4826. Certno: res2.Output.Baseinfo.Certno,
  4827. Gend: res2.Output.Baseinfo.Gend,
  4828. Naty: res2.Output.Baseinfo.Naty,
  4829. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4830. PsnName: res2.Output.Baseinfo.PsnName,
  4831. Idetinfo: idetinfoStr,
  4832. Insuinfo: infoStr,
  4833. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4834. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4835. VerifyNumber: res.Output.EcToken,
  4836. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4837. }
  4838. service.CreateHisPsn(psn)
  4839. c.ServeSuccessJSON(map[string]interface{}{
  4840. "patient": patient,
  4841. "number": res.Output.CardNo,
  4842. "insutype": insutype,
  4843. })
  4844. }
  4845. } else {
  4846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4847. return
  4848. }
  4849. } else {
  4850. c.ServeSuccessJSON(map[string]interface{}{
  4851. "failed_code": -10,
  4852. "msg": res.ErrMsg,
  4853. })
  4854. }
  4855. } else {
  4856. //if initFlag == 0 {
  4857. // c.TestGetBasBaseInit()
  4858. //}
  4859. //token := c.GetEleBaseInfo()
  4860. //token = Remove0000(token)
  4861. type ELeData struct {
  4862. Code string `json:"code"`
  4863. Data struct {
  4864. Aac002 string `json:"aac002"`
  4865. Aaz500 string `json:"aaz500"`
  4866. ActCardNo string `json:"actCardNo"`
  4867. Bab520 string `json:"bab520"`
  4868. Bkz543 string `json:"bkz543"`
  4869. BusinessType string `json:"businessType"`
  4870. CertfCodg string `json:"certfCodg"`
  4871. EcIndexNo string `json:"ecIndexNo"`
  4872. EcToken string `json:"ecToken"`
  4873. ID0000 string `json:"id0000"`
  4874. IDNo string `json:"idNo"`
  4875. IDType string `json:"idType"`
  4876. Idcode string `json:"idcode"`
  4877. IdentityToken string `json:"identity_token"`
  4878. InsuOrg string `json:"insuOrg"`
  4879. OfficeID string `json:"officeId"`
  4880. OfficeName string `json:"officeName"`
  4881. OperatorID string `json:"operatorId"`
  4882. OperatorName string `json:"operatorName"`
  4883. OrgID string `json:"orgId"`
  4884. UserName string `json:"userName"`
  4885. } `json:"data"`
  4886. Infno interface{} `json:"infno"`
  4887. Message string `json:"message"`
  4888. OrgID string `json:"orgId"`
  4889. TransType string `json:"transType"`
  4890. }
  4891. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4892. fmt.Println(result)
  4893. outPutInfo := Remove0000(result)
  4894. fmt.Println(outPutInfo)
  4895. var ele ELeData
  4896. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4897. if err != nil {
  4898. utils.ErrorLog("解析失败:%v", err)
  4899. }
  4900. token := ele.Data.EcToken
  4901. var result2 string
  4902. var requestLog2 string
  4903. if len(token) > 0 {
  4904. if strings.Contains(ele.Data.IDNo, "HKG") {
  4905. 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)
  4906. } else {
  4907. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4908. }
  4909. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4910. var res ResultTwo
  4911. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4912. utils.ErrorLog("解析失败:%v", err)
  4913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4914. return
  4915. }
  4916. if res.Infcode == 0 {
  4917. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4918. if err == gorm.ErrRecordNotFound {
  4919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4920. return
  4921. } else if err != nil {
  4922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4923. return
  4924. } else {
  4925. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4926. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4927. infoStr := string(Iinfos)
  4928. idetinfoStr := string(Idetinfos)
  4929. psn := &models.HisPsn{
  4930. PsnNo: res.Output.Baseinfo.PsnNo,
  4931. PatientId: patient.ID,
  4932. Certno: res.Output.Baseinfo.Certno,
  4933. Gend: res.Output.Baseinfo.Gend,
  4934. Naty: res.Output.Baseinfo.Naty,
  4935. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4936. PsnName: res.Output.Baseinfo.PsnName,
  4937. Idetinfo: idetinfoStr,
  4938. Insuinfo: infoStr,
  4939. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4940. CardInfo: "",
  4941. VerifyNumber: token,
  4942. }
  4943. service.CreateHisPsn(psn)
  4944. c.ServeSuccessJSON(map[string]interface{}{
  4945. "msg": "读取成功",
  4946. })
  4947. }
  4948. } else {
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4950. return
  4951. }
  4952. } else {
  4953. c.ServeSuccessJSON(map[string]interface{}{
  4954. "failed_code": -10,
  4955. "msg": "读取失败",
  4956. })
  4957. }
  4958. }
  4959. }
  4960. func (c *HisApiController) ReadEleFace() {
  4961. admin_user_id, _ := c.GetInt64("admin_user_id")
  4962. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4963. adminUser := c.GetAdminUserInfo()
  4964. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4965. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4966. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4967. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4968. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4969. if len(tokens) > 0 {
  4970. c.ServeSuccessJSON(map[string]interface{}{
  4971. "msg": "读取成功",
  4972. })
  4973. } else {
  4974. c.ServeSuccessJSON(map[string]interface{}{
  4975. "failed_code": -10,
  4976. "msg": "读取失败",
  4977. })
  4978. }
  4979. }
  4980. }
  4981. func (c *HisApiController) Get9001() {
  4982. adminUser := c.GetAdminUserInfo()
  4983. admin_user_id, _ := c.GetInt64("admin_user_id")
  4984. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4985. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4986. if miConfig.MdtrtareaAdmvs == "350500" {
  4987. service.GetFjAuthorizationInfo(miConfig.Code)
  4988. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4989. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4990. var dat map[string]interface{}
  4991. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4992. fmt.Println(dat)
  4993. } else {
  4994. fmt.Println(err)
  4995. }
  4996. userJSONBytes, _ := json.Marshal(dat)
  4997. var res models.Result9001
  4998. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4999. utils.ErrorLog("解析失败:%v", err)
  5000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5001. return
  5002. }
  5003. } else if miConfig.MdtrtareaAdmvs == "341203" {
  5004. fmt.Println(miConfig.SecretKey)
  5005. var res models.Result9001Two
  5006. 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 +
  5007. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  5008. resp, requestErr := http.Get(api)
  5009. if requestErr != nil {
  5010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5011. return
  5012. }
  5013. body, ioErr := ioutil.ReadAll(resp.Body)
  5014. if ioErr != nil {
  5015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5017. return
  5018. }
  5019. var respJSON map[string]interface{}
  5020. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. status := respJSON["data"].(map[string]interface{})["status"].(string)
  5026. if status == "0" {
  5027. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  5028. c.ServeSuccessJSON(map[string]interface{}{
  5029. "failed_code": -10,
  5030. "msg": err_msg,
  5031. })
  5032. return
  5033. }
  5034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5035. result, _ := json.Marshal(respJSON)
  5036. fmt.Println("log")
  5037. fmt.Println(string(result))
  5038. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5039. utils.ErrorLog("解析失败:%v", err)
  5040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5041. return
  5042. }
  5043. if res.Infcode == 0 {
  5044. sign := models.HisSignIn{
  5045. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5046. SignNo: res.Output.Signinoutb.SignNo,
  5047. SignTime: "",
  5048. Ctime: time.Now().Unix(),
  5049. Mtime: time.Now().Unix(),
  5050. Status: 1,
  5051. InputLog: "",
  5052. OutputLog: "",
  5053. FixmedinsCode: miConfig.Code,
  5054. }
  5055. err := service.CreateSignIn(&sign)
  5056. if err == nil {
  5057. c.ServeSuccessJSON(map[string]interface{}{
  5058. "msg": "签到成功",
  5059. })
  5060. }
  5061. } else {
  5062. c.ServeSuccessJSON(map[string]interface{}{
  5063. "failed_code": -10,
  5064. "msg": res.ErrMsg,
  5065. })
  5066. return
  5067. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5068. //return
  5069. }
  5070. } else {
  5071. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  5072. var dat map[string]interface{}
  5073. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5074. fmt.Println(dat)
  5075. } else {
  5076. fmt.Println(err)
  5077. }
  5078. userJSONBytes, _ := json.Marshal(dat)
  5079. var res models.Result9001
  5080. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5081. utils.ErrorLog("解析失败:%v", err)
  5082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5083. return
  5084. }
  5085. if res.Infcode == 0 {
  5086. sign := models.HisSignIn{
  5087. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5088. SignNo: res.Output.Signinoutb.SignNo,
  5089. SignTime: res.Output.Signinoutb.SignTime,
  5090. Ctime: time.Now().Unix(),
  5091. Mtime: time.Now().Unix(),
  5092. Status: 1,
  5093. InputLog: "",
  5094. OutputLog: "",
  5095. FixmedinsCode: miConfig.Code,
  5096. }
  5097. err := service.CreateSignIn(&sign)
  5098. if err == nil {
  5099. c.ServeSuccessJSON(map[string]interface{}{
  5100. "msg": "签到成功",
  5101. })
  5102. }
  5103. }
  5104. }
  5105. }
  5106. 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) {
  5107. var res Result3101
  5108. adminUser := c.GetAdminUserInfo()
  5109. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5110. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5111. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5112. //record_time := c.GetString("record_time")
  5113. //trig_scen := c.GetString("trig_scen")
  5114. timeLayout := "2006-01-02"
  5115. loc, _ := time.LoadLocation("Local")
  5116. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5117. if err != nil {
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5119. return res
  5120. }
  5121. recordDateTime := theTime.Unix()
  5122. var patientPrescription models.HisPrescriptionInfo
  5123. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5124. //if patientPrescription.ID == 0 {
  5125. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5126. //}
  5127. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5128. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5129. //
  5130. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5131. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5132. var pp models.PublicParams
  5133. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5134. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5135. pp.FixmedinsName = miConfig.OrgName
  5136. pp.FixmedinsCode = miConfig.Code
  5137. pp.RequestUrl = miConfig.Url
  5138. pp.Cainfo = miConfig.Cainfo
  5139. pp.SecretKey = miConfig.SecretKey
  5140. pp.AccessKey = miConfig.AccessKey
  5141. pp.OpterName = roles.UserName
  5142. var config []*models.HisXtDiagnoseConfig
  5143. for _, item := range diagnosis_ids {
  5144. id, _ := strconv.ParseInt(item, 10, 64)
  5145. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5146. config = append(config, &diagnosisConfig)
  5147. }
  5148. var pd models.PatientDtos
  5149. pd.PatnID = his.PsnNo
  5150. pd.PatnName = his.Name
  5151. pd.Gend = his.Gend
  5152. pd.Brdy = his.Brdy
  5153. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5154. pd.CurrMdtrtID = his.Number
  5155. var fed models.FsiEncounterDtos
  5156. fed.MdtrtID = his.Number
  5157. fed.MedinsID = miConfig.Code
  5158. fed.MedinsName = miConfig.OrgName
  5159. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5160. fed.MedMdtrtType = "1"
  5161. fed.MedinsType = "1"
  5162. fed.MedinsLv = "11"
  5163. tm := time.Unix(his.RecordDate, 0)
  5164. s_tm := tm.Format("2006-01-02 15:04:05")
  5165. fed.AdmDate = s_tm
  5166. fed.DscgDate = s_tm
  5167. fed.DscgMainDiseCodg = config[0].CountryCode
  5168. fed.DscgMainDiseName = config[0].CountryContentName
  5169. //诊断信息
  5170. var fdds []*models.FsiDiagnoseDtos
  5171. for index, item := range config {
  5172. if index == 0 {
  5173. var fdd models.FsiDiagnoseDtos
  5174. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5175. fdd.InoutDiseType = "1"
  5176. fdd.MaindiseFlag = "1"
  5177. fdd.DiseDate = s_tm
  5178. fdd.DiasSrtNo = "1"
  5179. fdd.DiseName = item.CountryContentName
  5180. fdd.DiseCodg = item.CountryCode
  5181. fdds = append(fdds, &fdd)
  5182. } else {
  5183. var fdd models.FsiDiagnoseDtos
  5184. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5185. fdd.InoutDiseType = "1"
  5186. fdd.MaindiseFlag = "1"
  5187. fdd.DiseDate = s_tm
  5188. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5189. fdd.DiseName = item.CountryContentName
  5190. fdd.DiseCodg = item.CountryCode
  5191. fdds = append(fdds, &fdd)
  5192. }
  5193. }
  5194. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5195. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5196. fed.AdmDeptName = department.Name
  5197. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5198. fed.DscgDeptName = department.Name
  5199. fed.MedMdtrtType = "1"
  5200. fed.MedType = "11"
  5201. //if his.Insutype == "390" {
  5202. // fed.MedType = "1402"
  5203. //} else {
  5204. // fed.MedType = "9933"
  5205. //}
  5206. var orders []*models.FsiOrderDtos
  5207. if trig_scen == "2" {
  5208. //处方医嘱信息
  5209. for _, item := range prescriptions {
  5210. for _, subItem := range item.HisDoctorAdviceInfo {
  5211. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5212. var order models.FsiOrderDtos
  5213. order.RxID = strconv.FormatInt(item.ID, 10)
  5214. order.Rxno = strconv.FormatInt(item.ID, 10)
  5215. order.LongDrordFlag = "0"
  5216. order.HilistType = "1"
  5217. order.ChrgType = "1"
  5218. order.DrordBhvr = "-"
  5219. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5220. order.HosplistName = subItem.BaseDrugLib.DrugName
  5221. order.HilistLv = "1"
  5222. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5223. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5224. order.HosplistName = subItem.BaseDrugLib.DrugName
  5225. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5226. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5227. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5228. order.OwnpayAmt = ""
  5229. order.SelfpayAmt = ""
  5230. order.Spec = ""
  5231. order.SpecUnt = ""
  5232. order.DrordBegnDate = s_tm
  5233. order.DrordStopDate = ""
  5234. order.DrordDrCodg = doctor_info.DoctorNumber
  5235. order.DrordDeptName = department.Name
  5236. order.DrordDeptCodg = department.Number
  5237. order.DrordDrName = doctor_info.UserName
  5238. order.DrordDrProfttl = "234"
  5239. order.CurrDrordFlag = "1"
  5240. orders = append(orders, &order)
  5241. }
  5242. }
  5243. for _, subItem := range item.HisPrescriptionProject {
  5244. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5245. var order models.FsiOrderDtos
  5246. order.RxID = strconv.FormatInt(item.ID, 10)
  5247. order.Rxno = strconv.FormatInt(item.ID, 10)
  5248. order.LongDrordFlag = "0"
  5249. order.HilistType = "1"
  5250. order.ChrgType = "1"
  5251. order.DrordBhvr = "-"
  5252. order.HilistCode = subItem.HisProject.MedicalCode
  5253. order.HosplistName = subItem.HisProject.ProjectName
  5254. order.HilistLv = "1"
  5255. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5256. order.HosplistCode = subItem.HisProject.MedicalCode
  5257. order.HosplistName = subItem.HisProject.ProjectName
  5258. order.Cnt = subItem.Count
  5259. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5260. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5261. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5262. order.OwnpayAmt = ""
  5263. order.SelfpayAmt = ""
  5264. order.Spec = ""
  5265. order.SpecUnt = ""
  5266. order.DrordBegnDate = s_tm
  5267. order.DrordStopDate = ""
  5268. order.DrordDrCodg = doctor_info.DoctorNumber
  5269. order.DrordDeptName = department.Name
  5270. order.DrordDeptCodg = department.Number
  5271. order.DrordDrName = doctor_info.UserName
  5272. order.DrordDrProfttl = "234"
  5273. order.CurrDrordFlag = "1"
  5274. orders = append(orders, &order)
  5275. }
  5276. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5277. var order models.FsiOrderDtos
  5278. order.RxID = strconv.FormatInt(item.ID, 10)
  5279. order.Rxno = strconv.FormatInt(item.ID, 10)
  5280. order.LongDrordFlag = "0"
  5281. order.HilistType = "1"
  5282. order.ChrgType = "1"
  5283. order.DrordBhvr = "-"
  5284. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5285. order.HosplistName = subItem.GoodInfo.GoodName
  5286. order.HilistLv = "1"
  5287. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5288. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5289. order.HosplistName = subItem.GoodInfo.GoodName
  5290. order.Cnt = subItem.Count
  5291. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5292. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5293. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5294. order.OwnpayAmt = ""
  5295. order.SelfpayAmt = ""
  5296. order.Spec = ""
  5297. order.SpecUnt = ""
  5298. order.DrordBegnDate = s_tm
  5299. order.DrordStopDate = ""
  5300. order.DrordDrCodg = doctor_info.DoctorNumber
  5301. order.DrordDeptName = department.Name
  5302. order.DrordDeptCodg = department.Number
  5303. order.DrordDrName = doctor_info.UserName
  5304. order.DrordDrProfttl = "234"
  5305. order.CurrDrordFlag = "1"
  5306. orders = append(orders, &order)
  5307. }
  5308. }
  5309. }
  5310. //处方医嘱信息
  5311. }
  5312. fed.MatnStas = "0"
  5313. fed.MedfeeSumamt = "0"
  5314. fed.OwnpayAmt = "0"
  5315. fed.SelfpayAmt = "0"
  5316. fed.AcctPayamt = "0"
  5317. fed.MaAmt = "0"
  5318. fed.HifpPayamt = "0"
  5319. fed.SetlTotlnum = "1"
  5320. fed.Insutype = his.Insutype
  5321. fed.ReimFlag = "0"
  5322. fed.OutSetlFlag = "0"
  5323. var fopd []*models.FsiOperationDtosData
  5324. data := make(map[string]interface{})
  5325. data["fed"] = fed
  5326. data["fdd"] = fdds
  5327. data["fod"] = orders
  5328. data["pd"] = pd
  5329. data["pp"] = pp
  5330. data["fopd"] = fopd
  5331. data["trig_scen"] = trig_scen
  5332. fmt.Println(data)
  5333. fmt.Println(fed)
  5334. fmt.Println(fdds)
  5335. fmt.Println(orders)
  5336. fmt.Println(pd)
  5337. fmt.Println(pp)
  5338. fmt.Println(fopd)
  5339. client := &http.Client{}
  5340. bytesData, _ := json.Marshal(data)
  5341. var req *http.Request
  5342. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5343. if miConfig.MdtrtareaAdmvs == "320921" {
  5344. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5345. } else {
  5346. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5347. }
  5348. resp, _ := client.Do(req)
  5349. defer resp.Body.Close()
  5350. body, ioErr := ioutil.ReadAll(resp.Body)
  5351. if ioErr != nil {
  5352. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5354. return res
  5355. }
  5356. var respJSON map[string]interface{}
  5357. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5360. return res
  5361. }
  5362. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5363. fmt.Println(respJSON)
  5364. result, _ := json.Marshal(respJSON)
  5365. fmt.Println(result)
  5366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5367. utils.ErrorLog("解析失败:%v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return res
  5370. }
  5371. return res
  5372. } else {
  5373. //if miConfig.MdtrtareaAdmvs == "441202" {
  5374. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5375. saveLog(output, input, "3101", "事前")
  5376. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5377. utils.ErrorLog("解析失败:%v", err)
  5378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5379. return
  5380. }
  5381. return res
  5382. //}
  5383. }
  5384. }
  5385. 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) {
  5386. adminUser := c.GetAdminUserInfo()
  5387. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5388. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5389. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5390. //record_time := c.GetString("record_time")
  5391. //trig_scen := c.GetString("trig_scen")
  5392. timeLayout := "2006-01-02"
  5393. loc, _ := time.LoadLocation("Local")
  5394. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5395. if err != nil {
  5396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5397. return res
  5398. }
  5399. recordDateTime := theTime.Unix()
  5400. var patientPrescription models.HisPrescriptionInfo
  5401. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5402. if patientPrescription.ID == 0 {
  5403. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5404. }
  5405. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5406. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5407. //
  5408. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5409. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5410. var pp models.PublicParams
  5411. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5412. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5413. pp.FixmedinsName = miConfig.OrgName
  5414. pp.FixmedinsCode = miConfig.Code
  5415. pp.RequestUrl = miConfig.Url
  5416. pp.Cainfo = miConfig.Cainfo
  5417. pp.SecretKey = miConfig.SecretKey
  5418. pp.AccessKey = miConfig.AccessKey
  5419. pp.OpterName = roles.UserName
  5420. var config []*models.HisXtDiagnoseConfig
  5421. for _, item := range diagnosis_ids {
  5422. id, _ := strconv.ParseInt(item, 10, 64)
  5423. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5424. config = append(config, &diagnosisConfig)
  5425. }
  5426. var pd models.PatientDtos
  5427. pd.PatnID = his.PsnNo
  5428. pd.PatnName = his.Name
  5429. pd.Gend = his.Gend
  5430. pd.Brdy = his.Brdy
  5431. pd.Poolarea = his.InsuplcAdmdvs
  5432. pd.CurrMdtrtID = his.Number
  5433. var fed models.FsiEncounterDtos
  5434. fed.MdtrtID = his.Number
  5435. fed.MedinsID = miConfig.Code
  5436. fed.MedinsName = miConfig.OrgName
  5437. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5438. fed.MedMdtrtType = "1"
  5439. fed.MedinsType = "1"
  5440. fed.MedinsLv = "11"
  5441. tm := time.Unix(his.RecordDate, 0)
  5442. s_tm := tm.Format("2006-01-02 15:04:05")
  5443. fed.AdmDate = s_tm
  5444. fed.DscgDate = s_tm
  5445. fed.DscgMainDiseCodg = config[0].CountryCode
  5446. fed.DscgMainDiseName = config[0].CountryContentName
  5447. //诊断信息
  5448. var fdds []*models.FsiDiagnoseDtos
  5449. for index, item := range config {
  5450. if index == 0 {
  5451. var fdd models.FsiDiagnoseDtos
  5452. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5453. fdd.InoutDiseType = "1"
  5454. fdd.MaindiseFlag = "1"
  5455. fdd.DiseDate = s_tm
  5456. fdd.DiasSrtNo = "1"
  5457. fdd.DiseName = item.CountryContentName
  5458. fdd.DiseCodg = item.CountryCode
  5459. fdds = append(fdds, &fdd)
  5460. } else {
  5461. var fdd models.FsiDiagnoseDtos
  5462. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5463. fdd.InoutDiseType = "1"
  5464. fdd.MaindiseFlag = "1"
  5465. fdd.DiseDate = s_tm
  5466. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5467. fdd.DiseName = item.CountryContentName
  5468. fdd.DiseCodg = item.CountryCode
  5469. fdds = append(fdds, &fdd)
  5470. }
  5471. }
  5472. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5473. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5474. fed.AdmDeptName = department.Name
  5475. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5476. fed.DscgDeptName = department.Name
  5477. fed.MedMdtrtType = "1"
  5478. fed.MedType = "11"
  5479. //if his.Insutype == "390" {
  5480. // fed.MedType = "1402"
  5481. //} else {
  5482. // fed.MedType = "9933"
  5483. //}
  5484. var orders []*models.FsiOrderDtos
  5485. if trig_scen == "2" {
  5486. //处方医嘱信息
  5487. for _, item := range prescriptions {
  5488. for _, subItem := range item.HisDoctorAdviceInfo {
  5489. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5490. var order models.FsiOrderDtos
  5491. order.RxID = strconv.FormatInt(item.ID, 10)
  5492. order.Rxno = strconv.FormatInt(item.ID, 10)
  5493. order.LongDrordFlag = "0"
  5494. order.HilistType = "1"
  5495. order.ChrgType = "1"
  5496. order.DrordBhvr = "-"
  5497. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5498. order.HosplistName = subItem.BaseDrugLib.DrugName
  5499. order.HilistLv = "1"
  5500. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5501. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5502. order.HosplistName = subItem.BaseDrugLib.DrugName
  5503. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5504. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5505. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5506. order.OwnpayAmt = ""
  5507. order.SelfpayAmt = ""
  5508. order.Spec = ""
  5509. order.SpecUnt = ""
  5510. order.DrordBegnDate = s_tm
  5511. order.DrordStopDate = ""
  5512. order.DrordDrCodg = doctor_info.DoctorNumber
  5513. order.DrordDeptName = department.Name
  5514. order.DrordDeptCodg = department.Number
  5515. order.DrordDrName = doctor_info.UserName
  5516. order.DrordDrProfttl = "234"
  5517. order.CurrDrordFlag = "1"
  5518. orders = append(orders, &order)
  5519. }
  5520. }
  5521. for _, subItem := range item.HisPrescriptionProject {
  5522. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5523. var order models.FsiOrderDtos
  5524. order.RxID = strconv.FormatInt(item.ID, 10)
  5525. order.Rxno = strconv.FormatInt(item.ID, 10)
  5526. order.LongDrordFlag = "0"
  5527. order.HilistType = "1"
  5528. order.ChrgType = "1"
  5529. order.DrordBhvr = "-"
  5530. order.HilistCode = subItem.HisProject.MedicalCode
  5531. order.HosplistName = subItem.HisProject.ProjectName
  5532. order.HilistLv = "1"
  5533. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5534. order.HosplistCode = subItem.HisProject.MedicalCode
  5535. order.HosplistName = subItem.HisProject.ProjectName
  5536. order.Cnt = subItem.Count
  5537. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5538. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5539. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5540. order.OwnpayAmt = ""
  5541. order.SelfpayAmt = ""
  5542. order.Spec = ""
  5543. order.SpecUnt = ""
  5544. order.DrordBegnDate = s_tm
  5545. order.DrordStopDate = ""
  5546. order.DrordDrCodg = doctor_info.DoctorNumber
  5547. order.DrordDeptName = department.Name
  5548. order.DrordDeptCodg = department.Number
  5549. order.DrordDrName = doctor_info.UserName
  5550. order.DrordDrProfttl = "234"
  5551. order.CurrDrordFlag = "1"
  5552. orders = append(orders, &order)
  5553. }
  5554. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5555. var order models.FsiOrderDtos
  5556. order.RxID = strconv.FormatInt(item.ID, 10)
  5557. order.Rxno = strconv.FormatInt(item.ID, 10)
  5558. order.LongDrordFlag = "0"
  5559. order.HilistType = "1"
  5560. order.ChrgType = "1"
  5561. order.DrordBhvr = "-"
  5562. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5563. order.HosplistName = subItem.GoodInfo.GoodName
  5564. order.HilistLv = "1"
  5565. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5566. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5567. order.HosplistName = subItem.GoodInfo.GoodName
  5568. order.Cnt = subItem.Count
  5569. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5570. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5571. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5572. order.OwnpayAmt = ""
  5573. order.SelfpayAmt = ""
  5574. order.Spec = ""
  5575. order.SpecUnt = ""
  5576. order.DrordBegnDate = s_tm
  5577. order.DrordStopDate = ""
  5578. order.DrordDrCodg = doctor_info.DoctorNumber
  5579. order.DrordDeptName = department.Name
  5580. order.DrordDeptCodg = department.Number
  5581. order.DrordDrName = doctor_info.UserName
  5582. order.DrordDrProfttl = "234"
  5583. order.CurrDrordFlag = "1"
  5584. orders = append(orders, &order)
  5585. }
  5586. }
  5587. }
  5588. //处方医嘱信息
  5589. }
  5590. fed.MatnStas = "0"
  5591. fed.MedfeeSumamt = "0"
  5592. fed.OwnpayAmt = "0"
  5593. fed.SelfpayAmt = "0"
  5594. fed.AcctPayamt = "0"
  5595. fed.MaAmt = "0"
  5596. fed.HifpPayamt = "0"
  5597. fed.SetlTotlnum = "1"
  5598. fed.Insutype = his.Insutype
  5599. fed.ReimFlag = "0"
  5600. fed.OutSetlFlag = "0"
  5601. var fopd []*models.FsiOperationDtosData
  5602. data := make(map[string]interface{})
  5603. data["fed"] = fed
  5604. data["fdd"] = fdds
  5605. data["fod"] = orders
  5606. data["pd"] = pd
  5607. data["pp"] = pp
  5608. data["fopd"] = fopd
  5609. data["trig_scen"] = trig_scen
  5610. fmt.Println(data)
  5611. fmt.Println(fed)
  5612. fmt.Println(fdds)
  5613. fmt.Println(orders)
  5614. fmt.Println(pd)
  5615. fmt.Println(pp)
  5616. fmt.Println(fopd)
  5617. client := &http.Client{}
  5618. bytesData, _ := json.Marshal(data)
  5619. var req *http.Request
  5620. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5621. if miConfig.MdtrtareaAdmvs == "320921" {
  5622. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5623. } else {
  5624. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5625. }
  5626. resp, _ := client.Do(req)
  5627. defer resp.Body.Close()
  5628. body, ioErr := ioutil.ReadAll(resp.Body)
  5629. if ioErr != nil {
  5630. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5632. return res
  5633. }
  5634. var respJSON map[string]interface{}
  5635. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5636. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5638. return res
  5639. }
  5640. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5641. fmt.Println(respJSON)
  5642. result, _ := json.Marshal(respJSON)
  5643. fmt.Println(result)
  5644. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5645. utils.ErrorLog("解析失败:%v", err)
  5646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5647. return res
  5648. }
  5649. return res
  5650. } else {
  5651. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5652. saveLog(output, input, "3101", "事前")
  5653. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5654. utils.ErrorLog("解析失败:%v", err)
  5655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5656. return
  5657. }
  5658. return res
  5659. }
  5660. return res
  5661. }
  5662. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5663. ////patient_id, _ := c.GetInt64("patient_id")
  5664. //order_id, _ := c.GetInt64("order_id")
  5665. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5666. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5667. //trig_scen := c.GetString("trig_scen")
  5668. adminUser := c.GetAdminUserInfo()
  5669. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5670. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5671. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5672. record_time := c.GetString("record_time")
  5673. order, _ := service.GetHisOrderByID(order_id)
  5674. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5675. timeLayout := "2006-01-02"
  5676. loc, _ := time.LoadLocation("Local")
  5677. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5678. if err != nil {
  5679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5680. return
  5681. }
  5682. recordDateTime := theTime.Unix()
  5683. var patientPrescription models.HisPrescriptionInfo
  5684. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5685. if patientPrescription.ID == 0 {
  5686. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5687. }
  5688. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5689. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5690. //
  5691. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5692. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5693. var pp models.PublicParams
  5694. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5695. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5696. pp.FixmedinsName = miConfig.OrgName
  5697. pp.FixmedinsCode = miConfig.Code
  5698. pp.RequestUrl = miConfig.Url
  5699. pp.Cainfo = miConfig.Cainfo
  5700. pp.SecretKey = miConfig.SecretKey
  5701. pp.AccessKey = miConfig.AccessKey
  5702. pp.OpterName = roles.UserName
  5703. var config []*models.HisXtDiagnoseConfig
  5704. for _, item := range diagnosis_ids {
  5705. id, _ := strconv.ParseInt(item, 10, 64)
  5706. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5707. config = append(config, &diagnosisConfig)
  5708. }
  5709. var pd models.PatientDtos
  5710. pd.PatnID = his.PsnNo
  5711. pd.PatnName = his.Name
  5712. pd.Gend = his.Gend
  5713. pd.Brdy = psn_info.Brdy
  5714. pd.Poolarea = his.InsuplcAdmdvs
  5715. pd.CurrMdtrtID = his.Number
  5716. var fed models.FsiEncounterDtos
  5717. fed.MdtrtID = his.Number
  5718. fed.MedinsID = miConfig.Code
  5719. fed.MedinsName = miConfig.OrgName
  5720. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5721. fed.MedMdtrtType = "1"
  5722. fed.MedinsType = "1"
  5723. fed.MedinsLv = "11"
  5724. tm := time.Unix(his.RecordDate, 0)
  5725. s_tm := tm.Format("2006-01-02 15:04:05")
  5726. fed.AdmDate = s_tm
  5727. fed.DscgDate = s_tm
  5728. fed.DscgMainDiseCodg = config[0].CountryCode
  5729. fed.DscgMainDiseName = config[0].CountryContentName
  5730. //诊断信息
  5731. var fdds []*models.FsiDiagnoseDtos
  5732. for index, item := range config {
  5733. if index == 0 {
  5734. var fdd models.FsiDiagnoseDtos
  5735. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5736. fdd.InoutDiseType = "1"
  5737. fdd.MaindiseFlag = "1"
  5738. fdd.DiseDate = s_tm
  5739. fdd.DiasSrtNo = "1"
  5740. fdd.DiseName = item.CountryContentName
  5741. fdd.DiseCodg = item.CountryCode
  5742. fdds = append(fdds, &fdd)
  5743. } else {
  5744. var fdd models.FsiDiagnoseDtos
  5745. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5746. fdd.InoutDiseType = "1"
  5747. fdd.MaindiseFlag = "1"
  5748. fdd.DiseDate = s_tm
  5749. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5750. fdd.DiseName = item.CountryContentName
  5751. fdd.DiseCodg = item.CountryCode
  5752. fdds = append(fdds, &fdd)
  5753. }
  5754. }
  5755. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5756. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5757. fed.AdmDeptName = department.Name
  5758. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5759. fed.DscgDeptName = department.Name
  5760. fed.MedType = order.MedType
  5761. //处方医嘱信息
  5762. var orders []*models.FsiOrderDtos
  5763. //for _, item := range prescriptions {
  5764. // for _, subItem := range item.HisDoctorAdviceInfo {
  5765. // var order models.FsiOrderDtos
  5766. // order.RxID = strconv.FormatInt(item.ID, 10)
  5767. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5768. // order.LongDrordFlag = "0"
  5769. // order.HilistType = "1"
  5770. // order.ChrgType = "1"
  5771. // order.DrordBhvr = "-"
  5772. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5773. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5774. // order.HilistLv = "1"
  5775. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5776. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5777. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5778. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5779. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5780. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5781. // order.OwnpayAmt = ""
  5782. // order.SelfpayAmt = ""
  5783. // order.Spec = ""
  5784. // order.SpecUnt = ""
  5785. // order.DrordBegnDate = s_tm
  5786. // order.DrordStopDate = ""
  5787. // order.DrordDrCodg = "1"
  5788. // order.DrordDeptName = department.Name
  5789. // order.DrordDrCodg = "1"
  5790. // order.DrordDrName = doctor_info.UserName
  5791. // order.DrordDrProfttl = ""
  5792. // order.CurrDrordFlag = "1"
  5793. // orders = append(orders, &order)
  5794. // }
  5795. // for _, subItem := range item.HisPrescriptionProject {
  5796. // if subItem.Type == 2 {
  5797. // var order models.FsiOrderDtos
  5798. // order.RxID = strconv.FormatInt(item.ID, 10)
  5799. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5800. // order.LongDrordFlag = "0"
  5801. // order.HilistType = "1"
  5802. // order.ChrgType = "1"
  5803. // order.DrordBhvr = "-"
  5804. // order.HilistCode = subItem.HisProject.MedicalCode
  5805. // order.HosplistName = subItem.HisProject.ProjectName
  5806. // order.HilistLv = "1"
  5807. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5808. // order.HosplistCode = subItem.HisProject.MedicalCode
  5809. // order.HosplistName = subItem.HisProject.ProjectName
  5810. // order.Cnt = subItem.Count
  5811. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5812. //
  5813. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5814. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5815. // order.OwnpayAmt = ""
  5816. // order.SelfpayAmt = ""
  5817. // order.Spec = ""
  5818. // order.SpecUnt = ""
  5819. // order.DrordBegnDate = s_tm
  5820. // order.DrordStopDate = ""
  5821. // order.DrordDrCodg = "1"
  5822. // order.DrordDeptName = department.Name
  5823. // order.DrordDrCodg = "1"
  5824. // order.DrordDrName = doctor_info.UserName
  5825. // order.DrordDrProfttl = ""
  5826. // order.CurrDrordFlag = "1"
  5827. // orders = append(orders, &order)
  5828. //
  5829. // }
  5830. // if subItem.Type == 3 {
  5831. //
  5832. // var order models.FsiOrderDtos
  5833. // order.RxID = strconv.FormatInt(item.ID, 10)
  5834. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5835. // order.LongDrordFlag = "0"
  5836. // order.HilistType = "1"
  5837. // order.ChrgType = "1"
  5838. // order.DrordBhvr = "-"
  5839. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5840. // order.HosplistName = subItem.GoodInfo.GoodName
  5841. // order.HilistLv = "1"
  5842. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5843. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5844. // order.HosplistName = subItem.GoodInfo.GoodName
  5845. // order.Cnt = subItem.Count
  5846. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5847. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5848. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5849. // order.OwnpayAmt = ""
  5850. // order.SelfpayAmt = ""
  5851. // order.Spec = ""
  5852. // order.SpecUnt = ""
  5853. // order.DrordBegnDate = s_tm
  5854. // order.DrordStopDate = ""
  5855. // order.DrordDrCodg = "1"
  5856. // order.DrordDeptName = department.Name
  5857. // order.DrordDrCodg = "1"
  5858. // order.DrordDrName = doctor_info.UserName
  5859. // order.DrordDrProfttl = ""
  5860. // order.CurrDrordFlag = "1"
  5861. // orders = append(orders, &order)
  5862. //
  5863. // }
  5864. // }
  5865. //}
  5866. for _, item := range prescriptions {
  5867. for _, subItem := range item.HisDoctorAdviceInfo {
  5868. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5869. var order models.FsiOrderDtos
  5870. order.RxID = strconv.FormatInt(item.ID, 10)
  5871. order.Rxno = strconv.FormatInt(item.ID, 10)
  5872. order.LongDrordFlag = "0"
  5873. order.HilistType = "1"
  5874. order.ChrgType = "1"
  5875. order.DrordBhvr = "-"
  5876. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5877. order.HosplistName = subItem.BaseDrugLib.DrugName
  5878. order.HilistLv = "1"
  5879. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5880. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5881. order.HosplistName = subItem.BaseDrugLib.DrugName
  5882. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5883. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5884. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5885. order.OwnpayAmt = ""
  5886. order.SelfpayAmt = ""
  5887. order.Spec = ""
  5888. order.SpecUnt = ""
  5889. order.DrordBegnDate = s_tm
  5890. order.DrordStopDate = ""
  5891. order.DrordDrCodg = doctor_info.DoctorNumber
  5892. order.DrordDeptName = department.Name
  5893. order.DrordDeptCodg = department.Number
  5894. order.DrordDrName = doctor_info.UserName
  5895. order.DrordDrProfttl = "234"
  5896. order.CurrDrordFlag = "1"
  5897. orders = append(orders, &order)
  5898. }
  5899. }
  5900. for _, subItem := range item.HisPrescriptionProject {
  5901. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5902. var order models.FsiOrderDtos
  5903. order.RxID = strconv.FormatInt(item.ID, 10)
  5904. order.Rxno = strconv.FormatInt(item.ID, 10)
  5905. order.LongDrordFlag = "0"
  5906. order.HilistType = "1"
  5907. order.ChrgType = "1"
  5908. order.DrordBhvr = "-"
  5909. order.HilistCode = subItem.HisProject.MedicalCode
  5910. order.HosplistName = subItem.HisProject.ProjectName
  5911. order.HilistLv = "1"
  5912. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5913. order.HosplistCode = subItem.HisProject.MedicalCode
  5914. order.HosplistName = subItem.HisProject.ProjectName
  5915. order.Cnt = subItem.Count
  5916. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5917. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5918. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5919. order.OwnpayAmt = ""
  5920. order.SelfpayAmt = ""
  5921. order.Spec = ""
  5922. order.SpecUnt = ""
  5923. order.DrordBegnDate = s_tm
  5924. order.DrordStopDate = ""
  5925. order.DrordDrCodg = doctor_info.DoctorNumber
  5926. order.DrordDeptName = department.Name
  5927. order.DrordDeptCodg = department.Number
  5928. order.DrordDrName = doctor_info.UserName
  5929. order.DrordDrProfttl = "234"
  5930. order.CurrDrordFlag = "1"
  5931. orders = append(orders, &order)
  5932. }
  5933. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5934. var order models.FsiOrderDtos
  5935. order.RxID = strconv.FormatInt(item.ID, 10)
  5936. order.Rxno = strconv.FormatInt(item.ID, 10)
  5937. order.LongDrordFlag = "0"
  5938. order.HilistType = "1"
  5939. order.ChrgType = "1"
  5940. order.DrordBhvr = "0"
  5941. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5942. order.HosplistName = subItem.GoodInfo.GoodName
  5943. order.HilistLv = "1"
  5944. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5945. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5946. order.HosplistName = subItem.GoodInfo.GoodName
  5947. order.Cnt = subItem.Count
  5948. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5949. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5950. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5951. order.OwnpayAmt = ""
  5952. order.SelfpayAmt = ""
  5953. order.Spec = ""
  5954. order.SpecUnt = ""
  5955. order.DrordBegnDate = s_tm
  5956. order.DrordStopDate = ""
  5957. order.DrordDrCodg = doctor_info.DoctorNumber
  5958. order.DrordDeptName = department.Name
  5959. order.DrordDeptCodg = department.Number
  5960. order.DrordDrName = doctor_info.UserName
  5961. order.DrordDrProfttl = "234"
  5962. order.CurrDrordFlag = "1"
  5963. orders = append(orders, &order)
  5964. }
  5965. }
  5966. }
  5967. //处方医嘱信息
  5968. fed.MatnStas = "0"
  5969. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5970. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5971. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5972. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5973. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5974. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5975. fed.SetlTotlnum = "1"
  5976. fed.Insutype = his.Insutype
  5977. fed.ReimFlag = "0"
  5978. fed.OutSetlFlag = "0"
  5979. var fopd []*models.FsiOperationDtosData
  5980. data := make(map[string]interface{})
  5981. data["fed"] = fed
  5982. data["fdd"] = fdds
  5983. data["fod"] = orders
  5984. data["pd"] = pd
  5985. data["pp"] = pp
  5986. data["fopd"] = fopd
  5987. data["trig_scen"] = trig_scen
  5988. client := &http.Client{}
  5989. bytesData, _ := json.Marshal(data)
  5990. var req *http.Request
  5991. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5992. if miConfig.MdtrtareaAdmvs == "320921" {
  5993. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5994. } else {
  5995. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5996. }
  5997. resp, _ := client.Do(req)
  5998. defer resp.Body.Close()
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return res
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return res
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6012. result, _ := json.Marshal(respJSON)
  6013. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6014. utils.ErrorLog("解析失败:%v", err)
  6015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6016. return res
  6017. }
  6018. return res
  6019. } else {
  6020. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6021. saveLog(output, input, "3102", "事中")
  6022. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6023. utils.ErrorLog("解析失败:%v", err)
  6024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6025. return
  6026. }
  6027. return res
  6028. }
  6029. return res
  6030. }
  6031. 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) {
  6032. var res Resultgd3101
  6033. adminUser := c.GetAdminUserInfo()
  6034. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6035. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6036. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6037. //record_time := c.GetString("record_time")
  6038. //trig_scen := c.GetString("trig_scen")
  6039. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6040. timeLayout := "2006-01-02"
  6041. loc, _ := time.LoadLocation("Local")
  6042. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6043. if err != nil {
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6045. return res
  6046. }
  6047. recordDateTime := theTime.Unix()
  6048. var patientPrescription models.HisPrescriptionInfo
  6049. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6050. //if patientPrescription.ID == 0 {
  6051. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6052. //}
  6053. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6054. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6055. //
  6056. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6057. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6058. var pp models.PublicParams
  6059. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6060. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6061. pp.FixmedinsName = miConfig.OrgName
  6062. pp.FixmedinsCode = miConfig.Code
  6063. pp.RequestUrl = miConfig.Url
  6064. pp.Cainfo = miConfig.Cainfo
  6065. pp.SecretKey = miConfig.SecretKey
  6066. pp.AccessKey = miConfig.AccessKey
  6067. pp.OpterName = roles.UserName
  6068. var config []*models.HisXtDiagnoseConfig
  6069. for _, item := range diagnosis_ids {
  6070. id, _ := strconv.ParseInt(item, 10, 64)
  6071. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6072. config = append(config, &diagnosisConfig)
  6073. }
  6074. var pd models.PatientDtos
  6075. pd.PatnID = his.PsnNo
  6076. pd.PatnName = his.Name
  6077. pd.Gend = his.Gend
  6078. pd.Brdy = psn_info.Brdy
  6079. pd.Poolarea = miConfig.MdtrtareaAdmvs
  6080. pd.CurrMdtrtID = his.Number
  6081. var fed models.FsiEncounterDtos
  6082. fed.MdtrtID = his.Number
  6083. fed.MedinsID = miConfig.Code
  6084. fed.MedinsName = miConfig.OrgName
  6085. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6086. fed.MedMdtrtType = "1"
  6087. fed.MedinsType = "1"
  6088. fed.MedinsLv = "11"
  6089. tm := time.Unix(his.RecordDate, 0)
  6090. s_tm := tm.Format("2006-01-02 15:04:05")
  6091. fed.AdmDate = s_tm
  6092. fed.DscgDate = s_tm
  6093. fed.DscgMainDiseCodg = config[0].CountryCode
  6094. fed.DscgMainDiseName = config[0].CountryContentName
  6095. //诊断信息
  6096. var fdds []*models.FsiDiagnoseDtos
  6097. for index, item := range config {
  6098. if index == 0 {
  6099. var fdd models.FsiDiagnoseDtos
  6100. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6101. fdd.InoutDiseType = "1"
  6102. fdd.MaindiseFlag = "1"
  6103. fdd.DiseDate = s_tm
  6104. fdd.DiasSrtNo = "1"
  6105. fdd.DiseName = item.CountryContentName
  6106. fdd.DiseCodg = item.CountryCode
  6107. fdds = append(fdds, &fdd)
  6108. } else {
  6109. var fdd models.FsiDiagnoseDtos
  6110. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6111. fdd.InoutDiseType = "1"
  6112. fdd.MaindiseFlag = "1"
  6113. fdd.DiseDate = s_tm
  6114. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6115. fdd.DiseName = item.CountryContentName
  6116. fdd.DiseCodg = item.CountryCode
  6117. fdds = append(fdds, &fdd)
  6118. }
  6119. }
  6120. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6121. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6122. fed.AdmDeptName = department.Name
  6123. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6124. fed.DscgDeptName = department.Name
  6125. fed.MedMdtrtType = "1"
  6126. fed.MedType = "11"
  6127. //if his.Insutype == "390" {
  6128. // fed.MedType = "1402"
  6129. //} else {
  6130. // fed.MedType = "9933"
  6131. //}
  6132. var orders []*models.FsiOrderDtos
  6133. if trig_scen == "2" {
  6134. //处方医嘱信息
  6135. for _, item := range prescriptions {
  6136. for _, subItem := range item.HisDoctorAdviceInfo {
  6137. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6138. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6139. var order models.FsiOrderDtos
  6140. order.RxID = strconv.FormatInt(item.ID, 10)
  6141. order.Rxno = strconv.FormatInt(item.ID, 10)
  6142. order.LongDrordFlag = "0"
  6143. order.HilistType = "1"
  6144. order.ChrgType = "1"
  6145. order.DrordBhvr = "0"
  6146. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6147. order.HosplistName = subItem.BaseDrugLib.DrugName
  6148. order.HilistLv = "1"
  6149. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6150. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6151. order.HosplistName = subItem.BaseDrugLib.DrugName
  6152. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6153. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6154. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6155. order.OwnpayAmt = ""
  6156. order.SelfpayAmt = ""
  6157. order.Spec = spec
  6158. order.SpecUnt = subItem.PrescribingNumberUnit
  6159. order.DrordBegnDate = s_tm
  6160. order.DrordStopDate = ""
  6161. order.DrordDrCodg = doctor_info.DoctorNumber
  6162. order.DrordDeptName = department.Name
  6163. order.DrordDeptCodg = department.Number
  6164. order.DrordDrName = doctor_info.UserName
  6165. order.DrordDrProfttl = "234"
  6166. order.CurrDrordFlag = "1"
  6167. orders = append(orders, &order)
  6168. }
  6169. }
  6170. for _, subItem := range item.HisPrescriptionProject {
  6171. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6172. var order models.FsiOrderDtos
  6173. order.RxID = strconv.FormatInt(item.ID, 10)
  6174. order.Rxno = strconv.FormatInt(item.ID, 10)
  6175. order.LongDrordFlag = "0"
  6176. order.HilistType = "1"
  6177. order.ChrgType = "1"
  6178. order.DrordBhvr = "0"
  6179. order.HilistCode = subItem.HisProject.MedicalCode
  6180. order.HosplistName = subItem.HisProject.ProjectName
  6181. order.HilistLv = "1"
  6182. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6183. order.HosplistCode = subItem.HisProject.MedicalCode
  6184. order.HosplistName = subItem.HisProject.ProjectName
  6185. order.Cnt = subItem.Count
  6186. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6187. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6188. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6189. order.OwnpayAmt = ""
  6190. order.SelfpayAmt = ""
  6191. order.Spec = subItem.Unit
  6192. order.SpecUnt = subItem.Unit
  6193. order.DrordBegnDate = s_tm
  6194. order.DrordStopDate = ""
  6195. order.DrordDrCodg = doctor_info.DoctorNumber
  6196. order.DrordDeptName = department.Name
  6197. order.DrordDeptCodg = department.Number
  6198. order.DrordDrName = doctor_info.UserName
  6199. order.DrordDrProfttl = "234"
  6200. order.CurrDrordFlag = "1"
  6201. orders = append(orders, &order)
  6202. }
  6203. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6204. var order models.FsiOrderDtos
  6205. order.RxID = strconv.FormatInt(item.ID, 10)
  6206. order.Rxno = strconv.FormatInt(item.ID, 10)
  6207. order.LongDrordFlag = "0"
  6208. order.HilistType = "1"
  6209. order.ChrgType = "1"
  6210. order.DrordBhvr = "0"
  6211. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6212. order.HosplistName = subItem.GoodInfo.GoodName
  6213. order.HilistLv = "1"
  6214. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6215. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6216. order.HosplistName = subItem.GoodInfo.GoodName
  6217. order.Cnt = subItem.Count
  6218. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6219. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6220. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6221. order.OwnpayAmt = ""
  6222. order.SelfpayAmt = ""
  6223. order.Spec = subItem.GoodInfo.SpecificationName
  6224. order.SpecUnt = subItem.Unit
  6225. order.DrordBegnDate = s_tm
  6226. order.DrordStopDate = ""
  6227. order.DrordDrCodg = doctor_info.DoctorNumber
  6228. order.DrordDeptName = department.Name
  6229. order.DrordDeptCodg = department.Number
  6230. order.DrordDrName = doctor_info.UserName
  6231. order.DrordDrProfttl = "234"
  6232. order.CurrDrordFlag = "1"
  6233. orders = append(orders, &order)
  6234. }
  6235. }
  6236. }
  6237. //处方医嘱信息
  6238. }
  6239. fed.MatnStas = "0"
  6240. fed.MedfeeSumamt = "0"
  6241. fed.OwnpayAmt = "0"
  6242. fed.SelfpayAmt = "0"
  6243. fed.AcctPayamt = "0"
  6244. fed.MaAmt = "0"
  6245. fed.HifpPayamt = "0"
  6246. fed.SetlTotlnum = "1"
  6247. fed.Insutype = his.Insutype
  6248. fed.ReimFlag = "0"
  6249. fed.OutSetlFlag = "0"
  6250. var fopd []*models.FsiOperationDtosData
  6251. data := make(map[string]interface{})
  6252. data["fed"] = fed
  6253. data["fdd"] = fdds
  6254. data["fod"] = orders
  6255. data["pd"] = pd
  6256. data["pp"] = pp
  6257. data["fopd"] = fopd
  6258. data["trig_scen"] = trig_scen
  6259. fmt.Println(data)
  6260. fmt.Println(fed)
  6261. fmt.Println(fdds)
  6262. fmt.Println(orders)
  6263. fmt.Println(pd)
  6264. fmt.Println(pp)
  6265. fmt.Println(fopd)
  6266. client := &http.Client{}
  6267. bytesData, _ := json.Marshal(data)
  6268. var req *http.Request
  6269. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6270. if miConfig.MdtrtareaAdmvs == "320921" {
  6271. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6272. } else {
  6273. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6274. }
  6275. resp, _ := client.Do(req)
  6276. defer resp.Body.Close()
  6277. body, ioErr := ioutil.ReadAll(resp.Body)
  6278. if ioErr != nil {
  6279. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6281. return res
  6282. }
  6283. var respJSON map[string]interface{}
  6284. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6285. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6287. return res
  6288. }
  6289. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6290. fmt.Println(respJSON)
  6291. result, _ := json.Marshal(respJSON)
  6292. fmt.Println(result)
  6293. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6294. utils.ErrorLog("解析失败:%v", err)
  6295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6296. return res
  6297. }
  6298. return res
  6299. } else {
  6300. //if miConfig.MdtrtareaAdmvs == "441202" {
  6301. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6302. saveLog(output, input, "3101", "事前")
  6303. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6304. utils.ErrorLog("解析失败:%v", err)
  6305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6306. return
  6307. }
  6308. return res
  6309. //}
  6310. }
  6311. }
  6312. 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) {
  6313. adminUser := c.GetAdminUserInfo()
  6314. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6315. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6316. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6317. //record_time := c.GetString("record_time")
  6318. //trig_scen := c.GetString("trig_scen")
  6319. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6320. timeLayout := "2006-01-02"
  6321. loc, _ := time.LoadLocation("Local")
  6322. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6323. if err != nil {
  6324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6325. return res
  6326. }
  6327. recordDateTime := theTime.Unix()
  6328. var patientPrescription models.HisPrescriptionInfo
  6329. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6330. if patientPrescription.ID == 0 {
  6331. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6332. }
  6333. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6334. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6335. //
  6336. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6337. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6338. var pp models.PublicParams
  6339. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6340. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6341. pp.FixmedinsName = miConfig.OrgName
  6342. pp.FixmedinsCode = miConfig.Code
  6343. pp.RequestUrl = miConfig.Url
  6344. pp.Cainfo = miConfig.Cainfo
  6345. pp.SecretKey = miConfig.SecretKey
  6346. pp.AccessKey = miConfig.AccessKey
  6347. pp.OpterName = roles.UserName
  6348. var config []*models.HisXtDiagnoseConfig
  6349. for _, item := range diagnosis_ids {
  6350. id, _ := strconv.ParseInt(item, 10, 64)
  6351. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6352. config = append(config, &diagnosisConfig)
  6353. }
  6354. var pd models.PatientDtos
  6355. pd.PatnID = his.PsnNo
  6356. pd.PatnName = his.Name
  6357. pd.Gend = his.Gend
  6358. pd.Brdy = psn_info.Brdy
  6359. pd.Poolarea = his.InsuplcAdmdvs
  6360. pd.CurrMdtrtID = his.Number
  6361. var fed models.FsiEncounterDtos
  6362. fed.MdtrtID = his.Number
  6363. fed.MedinsID = miConfig.Code
  6364. fed.MedinsName = miConfig.OrgName
  6365. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6366. fed.MedMdtrtType = "1"
  6367. fed.MedinsType = "1"
  6368. fed.MedinsLv = "11"
  6369. tm := time.Unix(his.RecordDate, 0)
  6370. s_tm := tm.Format("2006-01-02 15:04:05")
  6371. fed.AdmDate = s_tm
  6372. fed.DscgDate = s_tm
  6373. fed.DscgMainDiseCodg = config[0].CountryCode
  6374. fed.DscgMainDiseName = config[0].CountryContentName
  6375. //诊断信息
  6376. var fdds []*models.FsiDiagnoseDtos
  6377. for index, item := range config {
  6378. if index == 0 {
  6379. var fdd models.FsiDiagnoseDtos
  6380. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6381. fdd.InoutDiseType = "1"
  6382. fdd.MaindiseFlag = "1"
  6383. fdd.DiseDate = s_tm
  6384. fdd.DiasSrtNo = "1"
  6385. fdd.DiseName = item.CountryContentName
  6386. fdd.DiseCodg = item.CountryCode
  6387. fdds = append(fdds, &fdd)
  6388. } else {
  6389. var fdd models.FsiDiagnoseDtos
  6390. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6391. fdd.InoutDiseType = "1"
  6392. fdd.MaindiseFlag = "1"
  6393. fdd.DiseDate = s_tm
  6394. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6395. fdd.DiseName = item.CountryContentName
  6396. fdd.DiseCodg = item.CountryCode
  6397. fdds = append(fdds, &fdd)
  6398. }
  6399. }
  6400. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6401. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6402. fed.AdmDeptName = department.Name
  6403. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6404. fed.DscgDeptName = department.Name
  6405. fed.MedMdtrtType = "1"
  6406. fed.MedType = "11"
  6407. //if his.Insutype == "390" {
  6408. // fed.MedType = "1402"
  6409. //} else {
  6410. // fed.MedType = "9933"
  6411. //}
  6412. var orders []*models.FsiOrderDtos
  6413. if trig_scen == "2" {
  6414. //处方医嘱信息
  6415. for _, item := range prescriptions {
  6416. for _, subItem := range item.HisDoctorAdviceInfo {
  6417. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6418. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6419. var order models.FsiOrderDtos
  6420. order.RxID = strconv.FormatInt(item.ID, 10)
  6421. order.Rxno = strconv.FormatInt(item.ID, 10)
  6422. order.LongDrordFlag = "0"
  6423. order.HilistType = "1"
  6424. order.ChrgType = "1"
  6425. order.DrordBhvr = "0"
  6426. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6427. order.HosplistName = subItem.BaseDrugLib.DrugName
  6428. order.HilistLv = "1"
  6429. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6430. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6431. order.HosplistName = subItem.BaseDrugLib.DrugName
  6432. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6433. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6434. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6435. order.OwnpayAmt = ""
  6436. order.SelfpayAmt = ""
  6437. order.Spec = spec
  6438. order.SpecUnt = subItem.PrescribingNumberUnit
  6439. order.DrordBegnDate = s_tm
  6440. order.DrordStopDate = ""
  6441. order.DrordDrCodg = doctor_info.DoctorNumber
  6442. order.DrordDeptName = department.Name
  6443. order.DrordDeptCodg = department.Number
  6444. order.DrordDrName = doctor_info.UserName
  6445. order.DrordDrProfttl = "234"
  6446. order.CurrDrordFlag = "1"
  6447. orders = append(orders, &order)
  6448. }
  6449. }
  6450. for _, subItem := range item.HisPrescriptionProject {
  6451. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6452. var order models.FsiOrderDtos
  6453. order.RxID = strconv.FormatInt(item.ID, 10)
  6454. order.Rxno = strconv.FormatInt(item.ID, 10)
  6455. order.LongDrordFlag = "0"
  6456. order.HilistType = "1"
  6457. order.ChrgType = "1"
  6458. order.DrordBhvr = "0"
  6459. order.HilistCode = subItem.HisProject.MedicalCode
  6460. order.HosplistName = subItem.HisProject.ProjectName
  6461. order.HilistLv = "1"
  6462. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6463. order.HosplistCode = subItem.HisProject.MedicalCode
  6464. order.HosplistName = subItem.HisProject.ProjectName
  6465. order.Cnt = subItem.Count
  6466. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6467. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6468. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6469. order.OwnpayAmt = ""
  6470. order.SelfpayAmt = ""
  6471. order.Spec = subItem.Unit
  6472. order.SpecUnt = subItem.Unit
  6473. order.DrordBegnDate = s_tm
  6474. order.DrordStopDate = ""
  6475. order.DrordDrCodg = doctor_info.DoctorNumber
  6476. order.DrordDeptName = department.Name
  6477. order.DrordDeptCodg = department.Number
  6478. order.DrordDrName = doctor_info.UserName
  6479. order.DrordDrProfttl = "234"
  6480. order.CurrDrordFlag = "1"
  6481. orders = append(orders, &order)
  6482. }
  6483. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6484. var order models.FsiOrderDtos
  6485. order.RxID = strconv.FormatInt(item.ID, 10)
  6486. order.Rxno = strconv.FormatInt(item.ID, 10)
  6487. order.LongDrordFlag = "0"
  6488. order.HilistType = "1"
  6489. order.ChrgType = "1"
  6490. order.DrordBhvr = "0"
  6491. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6492. order.HosplistName = subItem.GoodInfo.GoodName
  6493. order.HilistLv = "1"
  6494. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6495. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6496. order.HosplistName = subItem.GoodInfo.GoodName
  6497. order.Cnt = subItem.Count
  6498. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6499. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6500. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6501. order.OwnpayAmt = ""
  6502. order.SelfpayAmt = ""
  6503. order.Spec = subItem.GoodInfo.SpecificationName
  6504. order.SpecUnt = subItem.Unit
  6505. order.DrordBegnDate = s_tm
  6506. order.DrordStopDate = ""
  6507. order.DrordDrCodg = doctor_info.DoctorNumber
  6508. order.DrordDeptName = department.Name
  6509. order.DrordDeptCodg = department.Number
  6510. order.DrordDrName = doctor_info.UserName
  6511. order.DrordDrProfttl = "234"
  6512. order.CurrDrordFlag = "1"
  6513. orders = append(orders, &order)
  6514. }
  6515. }
  6516. }
  6517. //处方医嘱信息
  6518. }
  6519. fed.MatnStas = "0"
  6520. fed.MedfeeSumamt = "0"
  6521. fed.OwnpayAmt = "0"
  6522. fed.SelfpayAmt = "0"
  6523. fed.AcctPayamt = "0"
  6524. fed.MaAmt = "0"
  6525. fed.HifpPayamt = "0"
  6526. fed.SetlTotlnum = "1"
  6527. fed.Insutype = his.Insutype
  6528. fed.ReimFlag = "0"
  6529. fed.OutSetlFlag = "0"
  6530. var fopd []*models.FsiOperationDtosData
  6531. data := make(map[string]interface{})
  6532. data["fed"] = fed
  6533. data["fdd"] = fdds
  6534. data["fod"] = orders
  6535. data["pd"] = pd
  6536. data["pp"] = pp
  6537. data["fopd"] = fopd
  6538. data["trig_scen"] = trig_scen
  6539. fmt.Println(data)
  6540. fmt.Println(fed)
  6541. fmt.Println(fdds)
  6542. fmt.Println(orders)
  6543. fmt.Println(pd)
  6544. fmt.Println(pp)
  6545. fmt.Println(fopd)
  6546. client := &http.Client{}
  6547. bytesData, _ := json.Marshal(data)
  6548. var req *http.Request
  6549. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6550. if miConfig.MdtrtareaAdmvs == "320921" {
  6551. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6552. } else {
  6553. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6554. }
  6555. resp, _ := client.Do(req)
  6556. defer resp.Body.Close()
  6557. body, ioErr := ioutil.ReadAll(resp.Body)
  6558. if ioErr != nil {
  6559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6561. return res
  6562. }
  6563. var respJSON map[string]interface{}
  6564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6567. return res
  6568. }
  6569. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6570. fmt.Println(respJSON)
  6571. result, _ := json.Marshal(respJSON)
  6572. fmt.Println(result)
  6573. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6574. utils.ErrorLog("解析失败:%v", err)
  6575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6576. return res
  6577. }
  6578. return res
  6579. } else {
  6580. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6581. saveLog(output, input, "3101", "事前")
  6582. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6583. utils.ErrorLog("解析失败:%v", err)
  6584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6585. return
  6586. }
  6587. return res
  6588. }
  6589. return res
  6590. }
  6591. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6592. ////patient_id, _ := c.GetInt64("patient_id")
  6593. //order_id, _ := c.GetInt64("order_id")
  6594. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6595. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6596. //trig_scen := c.GetString("trig_scen")
  6597. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6598. utils.ErrorLog("解析失败:%v", psn_info)
  6599. adminUser := c.GetAdminUserInfo()
  6600. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6601. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6602. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6603. record_time := c.GetString("record_time")
  6604. order, _ := service.GetHisOrderByID(order_id)
  6605. timeLayout := "2006-01-02"
  6606. loc, _ := time.LoadLocation("Local")
  6607. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6608. if err != nil {
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6610. return
  6611. }
  6612. recordDateTime := theTime.Unix()
  6613. var patientPrescription models.HisPrescriptionInfo
  6614. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6615. if patientPrescription.ID == 0 {
  6616. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6617. }
  6618. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6619. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6620. //
  6621. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6622. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6623. var pp models.PublicParams
  6624. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6625. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6626. pp.FixmedinsName = miConfig.OrgName
  6627. pp.FixmedinsCode = miConfig.Code
  6628. pp.RequestUrl = miConfig.Url
  6629. pp.Cainfo = miConfig.Cainfo
  6630. pp.SecretKey = miConfig.SecretKey
  6631. pp.AccessKey = miConfig.AccessKey
  6632. pp.OpterName = roles.UserName
  6633. var config []*models.HisXtDiagnoseConfig
  6634. for _, item := range diagnosis_ids {
  6635. id, _ := strconv.ParseInt(item, 10, 64)
  6636. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6637. config = append(config, &diagnosisConfig)
  6638. }
  6639. var pd models.PatientDtos
  6640. pd.PatnID = his.PsnNo
  6641. pd.PatnName = his.Name
  6642. pd.Gend = his.Gend
  6643. pd.Brdy = psn_info.Brdy
  6644. pd.Poolarea = his.InsuplcAdmdvs
  6645. pd.CurrMdtrtID = his.Number
  6646. var fed models.FsiEncounterDtos
  6647. fed.MdtrtID = his.Number
  6648. fed.MedinsID = miConfig.Code
  6649. fed.MedinsName = miConfig.OrgName
  6650. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6651. fed.MedMdtrtType = "1"
  6652. fed.MedinsType = "1"
  6653. fed.MedinsLv = "11"
  6654. tm := time.Unix(his.RecordDate, 0)
  6655. s_tm := tm.Format("2006-01-02 15:04:05")
  6656. fed.AdmDate = s_tm
  6657. fed.DscgDate = s_tm
  6658. fed.DscgMainDiseCodg = config[0].CountryCode
  6659. fed.DscgMainDiseName = config[0].CountryContentName
  6660. //诊断信息
  6661. var fdds []*models.FsiDiagnoseDtos
  6662. for index, item := range config {
  6663. if index == 0 {
  6664. var fdd models.FsiDiagnoseDtos
  6665. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6666. fdd.InoutDiseType = "1"
  6667. fdd.MaindiseFlag = "1"
  6668. fdd.DiseDate = s_tm
  6669. fdd.DiasSrtNo = "1"
  6670. fdd.DiseName = item.CountryContentName
  6671. fdd.DiseCodg = item.CountryCode
  6672. fdds = append(fdds, &fdd)
  6673. } else {
  6674. var fdd models.FsiDiagnoseDtos
  6675. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6676. fdd.InoutDiseType = "1"
  6677. fdd.MaindiseFlag = "1"
  6678. fdd.DiseDate = s_tm
  6679. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6680. fdd.DiseName = item.CountryContentName
  6681. fdd.DiseCodg = item.CountryCode
  6682. fdds = append(fdds, &fdd)
  6683. }
  6684. }
  6685. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6686. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6687. fed.AdmDeptName = department.Name
  6688. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6689. fed.DscgDeptName = department.Name
  6690. fed.MedType = order.MedType
  6691. //处方医嘱信息
  6692. var orders []*models.FsiOrderDtos
  6693. //for _, item := range prescriptions {
  6694. // for _, subItem := range item.HisDoctorAdviceInfo {
  6695. // var order models.FsiOrderDtos
  6696. // order.RxID = strconv.FormatInt(item.ID, 10)
  6697. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6698. // order.LongDrordFlag = "0"
  6699. // order.HilistType = "1"
  6700. // order.ChrgType = "1"
  6701. // order.DrordBhvr = "-"
  6702. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6703. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6704. // order.HilistLv = "1"
  6705. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6706. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6707. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6708. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6709. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6710. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6711. // order.OwnpayAmt = ""
  6712. // order.SelfpayAmt = ""
  6713. // order.Spec = ""
  6714. // order.SpecUnt = ""
  6715. // order.DrordBegnDate = s_tm
  6716. // order.DrordStopDate = ""
  6717. // order.DrordDrCodg = "1"
  6718. // order.DrordDeptName = department.Name
  6719. // order.DrordDrCodg = "1"
  6720. // order.DrordDrName = doctor_info.UserName
  6721. // order.DrordDrProfttl = ""
  6722. // order.CurrDrordFlag = "1"
  6723. // orders = append(orders, &order)
  6724. // }
  6725. // for _, subItem := range item.HisPrescriptionProject {
  6726. // if subItem.Type == 2 {
  6727. // var order models.FsiOrderDtos
  6728. // order.RxID = strconv.FormatInt(item.ID, 10)
  6729. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6730. // order.LongDrordFlag = "0"
  6731. // order.HilistType = "1"
  6732. // order.ChrgType = "1"
  6733. // order.DrordBhvr = "-"
  6734. // order.HilistCode = subItem.HisProject.MedicalCode
  6735. // order.HosplistName = subItem.HisProject.ProjectName
  6736. // order.HilistLv = "1"
  6737. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6738. // order.HosplistCode = subItem.HisProject.MedicalCode
  6739. // order.HosplistName = subItem.HisProject.ProjectName
  6740. // order.Cnt = subItem.Count
  6741. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6742. //
  6743. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6744. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6745. // order.OwnpayAmt = ""
  6746. // order.SelfpayAmt = ""
  6747. // order.Spec = ""
  6748. // order.SpecUnt = ""
  6749. // order.DrordBegnDate = s_tm
  6750. // order.DrordStopDate = ""
  6751. // order.DrordDrCodg = "1"
  6752. // order.DrordDeptName = department.Name
  6753. // order.DrordDrCodg = "1"
  6754. // order.DrordDrName = doctor_info.UserName
  6755. // order.DrordDrProfttl = ""
  6756. // order.CurrDrordFlag = "1"
  6757. // orders = append(orders, &order)
  6758. //
  6759. // }
  6760. // if subItem.Type == 3 {
  6761. //
  6762. // var order models.FsiOrderDtos
  6763. // order.RxID = strconv.FormatInt(item.ID, 10)
  6764. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6765. // order.LongDrordFlag = "0"
  6766. // order.HilistType = "1"
  6767. // order.ChrgType = "1"
  6768. // order.DrordBhvr = "-"
  6769. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6770. // order.HosplistName = subItem.GoodInfo.GoodName
  6771. // order.HilistLv = "1"
  6772. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6773. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6774. // order.HosplistName = subItem.GoodInfo.GoodName
  6775. // order.Cnt = subItem.Count
  6776. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6777. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6778. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6779. // order.OwnpayAmt = ""
  6780. // order.SelfpayAmt = ""
  6781. // order.Spec = ""
  6782. // order.SpecUnt = ""
  6783. // order.DrordBegnDate = s_tm
  6784. // order.DrordStopDate = ""
  6785. // order.DrordDrCodg = "1"
  6786. // order.DrordDeptName = department.Name
  6787. // order.DrordDrCodg = "1"
  6788. // order.DrordDrName = doctor_info.UserName
  6789. // order.DrordDrProfttl = ""
  6790. // order.CurrDrordFlag = "1"
  6791. // orders = append(orders, &order)
  6792. //
  6793. // }
  6794. // }
  6795. //}
  6796. for _, item := range prescriptions {
  6797. for _, subItem := range item.HisDoctorAdviceInfo {
  6798. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6799. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6800. var order models.FsiOrderDtos
  6801. order.RxID = strconv.FormatInt(item.ID, 10)
  6802. order.Rxno = strconv.FormatInt(item.ID, 10)
  6803. order.LongDrordFlag = "0"
  6804. order.HilistType = "1"
  6805. order.ChrgType = "1"
  6806. order.DrordBhvr = "0"
  6807. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6808. order.HosplistName = subItem.BaseDrugLib.DrugName
  6809. order.HilistLv = "1"
  6810. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6811. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6812. order.HosplistName = subItem.BaseDrugLib.DrugName
  6813. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6814. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6815. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6816. order.OwnpayAmt = ""
  6817. order.SelfpayAmt = ""
  6818. order.Spec = spec
  6819. order.SpecUnt = subItem.PrescribingNumberUnit
  6820. order.DrordBegnDate = s_tm
  6821. order.DrordStopDate = ""
  6822. order.DrordDrCodg = doctor_info.DoctorNumber
  6823. order.DrordDeptName = department.Name
  6824. order.DrordDeptCodg = department.Number
  6825. order.DrordDrName = doctor_info.UserName
  6826. order.DrordDrProfttl = "234"
  6827. order.CurrDrordFlag = "1"
  6828. orders = append(orders, &order)
  6829. }
  6830. }
  6831. for _, subItem := range item.HisPrescriptionProject {
  6832. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6833. var order models.FsiOrderDtos
  6834. order.RxID = strconv.FormatInt(item.ID, 10)
  6835. order.Rxno = strconv.FormatInt(item.ID, 10)
  6836. order.LongDrordFlag = "0"
  6837. order.HilistType = "1"
  6838. order.ChrgType = "1"
  6839. order.DrordBhvr = "0"
  6840. order.HilistCode = subItem.HisProject.MedicalCode
  6841. order.HosplistName = subItem.HisProject.ProjectName
  6842. order.HilistLv = "1"
  6843. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6844. order.HosplistCode = subItem.HisProject.MedicalCode
  6845. order.HosplistName = subItem.HisProject.ProjectName
  6846. order.Cnt = subItem.Count
  6847. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6848. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6849. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6850. order.OwnpayAmt = ""
  6851. order.SelfpayAmt = ""
  6852. order.Spec = subItem.Unit
  6853. order.SpecUnt = subItem.Unit
  6854. order.DrordBegnDate = s_tm
  6855. order.DrordStopDate = ""
  6856. order.DrordDrCodg = doctor_info.DoctorNumber
  6857. order.DrordDeptName = department.Name
  6858. order.DrordDeptCodg = department.Number
  6859. order.DrordDrName = doctor_info.UserName
  6860. order.DrordDrProfttl = "234"
  6861. order.CurrDrordFlag = "1"
  6862. orders = append(orders, &order)
  6863. }
  6864. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6865. var order models.FsiOrderDtos
  6866. order.RxID = strconv.FormatInt(item.ID, 10)
  6867. order.Rxno = strconv.FormatInt(item.ID, 10)
  6868. order.LongDrordFlag = "0"
  6869. order.HilistType = "1"
  6870. order.ChrgType = "1"
  6871. order.DrordBhvr = "0"
  6872. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6873. order.HosplistName = subItem.GoodInfo.GoodName
  6874. order.HilistLv = "1"
  6875. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6876. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6877. order.HosplistName = subItem.GoodInfo.GoodName
  6878. order.Cnt = subItem.Count
  6879. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6880. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6881. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6882. order.OwnpayAmt = ""
  6883. order.SelfpayAmt = ""
  6884. order.Spec = subItem.GoodInfo.SpecificationName
  6885. order.SpecUnt = subItem.Unit
  6886. order.DrordBegnDate = s_tm
  6887. order.DrordStopDate = ""
  6888. order.DrordDrCodg = doctor_info.DoctorNumber
  6889. order.DrordDeptName = department.Name
  6890. order.DrordDeptCodg = department.Number
  6891. order.DrordDrName = doctor_info.UserName
  6892. order.DrordDrProfttl = "234"
  6893. order.CurrDrordFlag = "1"
  6894. orders = append(orders, &order)
  6895. }
  6896. }
  6897. }
  6898. //处方医嘱信息
  6899. fed.MatnStas = "0"
  6900. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6901. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6902. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6903. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6904. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6905. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6906. fed.SetlTotlnum = "1"
  6907. fed.Insutype = his.Insutype
  6908. fed.ReimFlag = "0"
  6909. fed.OutSetlFlag = "0"
  6910. var fopd []*models.FsiOperationDtosData
  6911. data := make(map[string]interface{})
  6912. data["fed"] = fed
  6913. data["fdd"] = fdds
  6914. data["fod"] = orders
  6915. data["pd"] = pd
  6916. data["pp"] = pp
  6917. data["fopd"] = fopd
  6918. data["trig_scen"] = trig_scen
  6919. client := &http.Client{}
  6920. bytesData, _ := json.Marshal(data)
  6921. var req *http.Request
  6922. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6923. if miConfig.MdtrtareaAdmvs == "320921" {
  6924. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6925. } else {
  6926. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6927. }
  6928. resp, _ := client.Do(req)
  6929. defer resp.Body.Close()
  6930. body, ioErr := ioutil.ReadAll(resp.Body)
  6931. if ioErr != nil {
  6932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return res
  6935. }
  6936. var respJSON map[string]interface{}
  6937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6940. return res
  6941. }
  6942. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6943. result, _ := json.Marshal(respJSON)
  6944. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6945. utils.ErrorLog("解析失败:%v", err)
  6946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6947. return res
  6948. }
  6949. return res
  6950. } else {
  6951. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6952. saveLog(output, input, "3102", "事中")
  6953. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6954. utils.ErrorLog("解析失败:%v", err)
  6955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6956. return
  6957. }
  6958. return res
  6959. }
  6960. return res
  6961. }
  6962. func (c *HisApiController) Check() {
  6963. psn_no := c.GetString("psn_no")
  6964. in := c.GetString("in")
  6965. mt := c.GetString("mt")
  6966. baseParams := models.BaseParams{
  6967. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6968. FixmedinsCode: "H15049901371",
  6969. InsuplcAdmdvs: "150499",
  6970. MdtrtareaAdmvs: "150499",
  6971. OrgName: "赤峰费森血液透析中心",
  6972. Doctor: "1111",
  6973. }
  6974. service.Gdyb2001(baseParams, psn_no, in, mt)
  6975. }
  6976. func (c *HisApiController) GetPsnNcdsInfo() {
  6977. admin_user_id, _ := c.GetInt64("admin_user_id")
  6978. patient_id, _ := c.GetInt64("patient_id")
  6979. //id, _ := c.GetInt64("id")
  6980. adminUser := c.GetAdminUserInfo()
  6981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6982. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6983. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6984. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6985. //psn_record, _ := service.GetP(id)
  6986. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6987. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  6988. //
  6989. //if psn_record.ID == 0 {
  6990. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6991. // return
  6992. //}
  6993. var res Result5301
  6994. var res10265 Result5301For10265
  6995. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6996. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6997. var api string
  6998. if miConfig.MdtrtareaAdmvs == "320921" {
  6999. 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 +
  7000. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7001. } else {
  7002. 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 +
  7003. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7004. }
  7005. resp, requestErr := http.Get(api)
  7006. if requestErr != nil {
  7007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7008. return
  7009. }
  7010. body, ioErr := ioutil.ReadAll(resp.Body)
  7011. if ioErr != nil {
  7012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7014. return
  7015. }
  7016. var respJSON map[string]interface{}
  7017. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7020. return
  7021. }
  7022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7023. result, _ := json.Marshal(respJSON)
  7024. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7025. utils.ErrorLog("解析失败:%v", err)
  7026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7027. return
  7028. }
  7029. res.ErrMsg = res10265.ErrMsg
  7030. res.Output = res10265.Output
  7031. res.InfRefmsgid = res10265.InfRefmsgid
  7032. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7033. res.Infcode = infocode
  7034. } else if miConfig.MdtrtareaAdmvs == "341203" {
  7035. psn_info, _ := service.GetPsnByPatientId(patient_id)
  7036. var api string
  7037. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  7038. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  7039. resp, requestErr := http.Get(api)
  7040. if requestErr != nil {
  7041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7042. return
  7043. }
  7044. body, ioErr := ioutil.ReadAll(resp.Body)
  7045. if ioErr != nil {
  7046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. var respJSON map[string]interface{}
  7051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7054. return
  7055. }
  7056. status := respJSON["data"].(map[string]interface{})["status"].(string)
  7057. if status == "0" {
  7058. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  7059. c.ServeSuccessJSON(map[string]interface{}{
  7060. "failed_code": -10,
  7061. "msg": err_msg,
  7062. })
  7063. return
  7064. }
  7065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7066. result, _ := json.Marshal(respJSON)
  7067. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7068. utils.ErrorLog("解析失败:%v", err)
  7069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7070. return
  7071. }
  7072. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7073. p, _ := service.GetHisPatientById(patient_id)
  7074. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7075. var dat map[string]interface{}
  7076. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7077. fmt.Println(dat)
  7078. } else {
  7079. fmt.Println(err)
  7080. }
  7081. userJSONBytes, _ := json.Marshal(dat)
  7082. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7083. utils.ErrorLog("解析失败:%v", err)
  7084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7085. return
  7086. }
  7087. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7088. p, _ := service.GetHisPatientById(patient_id)
  7089. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  7090. var dat map[string]interface{}
  7091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7092. fmt.Println(dat)
  7093. } else {
  7094. fmt.Println(err)
  7095. }
  7096. userJSONBytes, _ := json.Marshal(dat)
  7097. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7098. utils.ErrorLog("解析失败:%v", err)
  7099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7100. return
  7101. }
  7102. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7103. p, _ := service.GetHisPatientById(patient_id)
  7104. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7105. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7107. resp, requestErr := http.Get(api)
  7108. if requestErr != nil {
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. return
  7111. }
  7112. body, ioErr := ioutil.ReadAll(resp.Body)
  7113. if ioErr != nil {
  7114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. return
  7117. }
  7118. var respJSON map[string]interface{}
  7119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7122. return
  7123. }
  7124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7125. result, _ := json.Marshal(respJSON)
  7126. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7127. utils.ErrorLog("解析失败:%v", err)
  7128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7129. return
  7130. }
  7131. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7132. p, _ := service.GetHisPatientById(patient_id)
  7133. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7134. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7135. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7136. resp, requestErr := http.Get(api)
  7137. if requestErr != nil {
  7138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. return
  7140. }
  7141. body, ioErr := ioutil.ReadAll(resp.Body)
  7142. if ioErr != nil {
  7143. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. return
  7146. }
  7147. var respJSON map[string]interface{}
  7148. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7151. return
  7152. }
  7153. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7154. result, _ := json.Marshal(respJSON)
  7155. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7156. utils.ErrorLog("解析失败:%v", err)
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7161. p, _ := service.GetHisPatientById(patient_id)
  7162. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7163. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7164. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7165. resp, requestErr := http.Get(api)
  7166. if requestErr != nil {
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. body, ioErr := ioutil.ReadAll(resp.Body)
  7171. if ioErr != nil {
  7172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. var respJSON map[string]interface{}
  7177. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7180. return
  7181. }
  7182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7183. result, _ := json.Marshal(respJSON)
  7184. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7185. utils.ErrorLog("解析失败:%v", err)
  7186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7187. return
  7188. }
  7189. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7190. p, _ := service.GetHisPatientById(patient_id)
  7191. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7192. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7193. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7194. resp, requestErr := http.Get(api)
  7195. if requestErr != nil {
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. body, ioErr := ioutil.ReadAll(resp.Body)
  7200. if ioErr != nil {
  7201. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7203. return
  7204. }
  7205. var respJSON map[string]interface{}
  7206. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7207. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7209. return
  7210. }
  7211. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7212. result, _ := json.Marshal(respJSON)
  7213. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7214. utils.ErrorLog("解析失败:%v", err)
  7215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7216. return
  7217. }
  7218. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7219. p, _ := service.GetHisPatientById(patient_id)
  7220. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7221. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7222. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7223. resp, requestErr := http.Get(api)
  7224. if requestErr != nil {
  7225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7226. return
  7227. }
  7228. body, ioErr := ioutil.ReadAll(resp.Body)
  7229. if ioErr != nil {
  7230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7232. return
  7233. }
  7234. var respJSON map[string]interface{}
  7235. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7238. return
  7239. }
  7240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7241. result, _ := json.Marshal(respJSON)
  7242. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7243. utils.ErrorLog("解析失败:%v", err)
  7244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7245. return
  7246. }
  7247. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7248. p, _ := service.GetHisPatientById(patient_id)
  7249. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7250. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7251. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7252. resp, requestErr := http.Get(api)
  7253. if requestErr != nil {
  7254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7255. return
  7256. }
  7257. body, ioErr := ioutil.ReadAll(resp.Body)
  7258. if ioErr != nil {
  7259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7261. return
  7262. }
  7263. var respJSON map[string]interface{}
  7264. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7267. return
  7268. }
  7269. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7270. result, _ := json.Marshal(respJSON)
  7271. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7272. utils.ErrorLog("解析失败:%v", err)
  7273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7274. return
  7275. }
  7276. } else {
  7277. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7278. var dat map[string]interface{}
  7279. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7280. fmt.Println(dat)
  7281. } else {
  7282. fmt.Println(err)
  7283. }
  7284. userJSONBytes, _ := json.Marshal(dat)
  7285. if miConfig.Code == "H15049901371" {
  7286. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7287. utils.ErrorLog("解析失败:%v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. return
  7290. }
  7291. res.InfRefmsgid = res10265.InfRefmsgid
  7292. res.Output = res10265.Output
  7293. res.ErrMsg = res10265.ErrMsg
  7294. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7295. res.Infcode = infocode
  7296. } else {
  7297. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7298. utils.ErrorLog("解析失败:%v", err)
  7299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7300. return
  7301. }
  7302. }
  7303. }
  7304. if res.Infcode == 0 {
  7305. c.ServeSuccessJSON(map[string]interface{}{
  7306. "result": res.Output.Result,
  7307. })
  7308. }
  7309. }
  7310. func (c *HisApiController) CheckInsutype() {
  7311. his_patient_id, _ := c.GetInt64("his_patient_id")
  7312. admin_user_id, _ := c.GetInt64("admin_user_id")
  7313. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7314. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7315. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7316. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7317. var dat map[string]interface{}
  7318. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7319. fmt.Println(dat)
  7320. } else {
  7321. fmt.Println(err)
  7322. }
  7323. userJSONBytes, _ := json.Marshal(dat)
  7324. var res Result90100
  7325. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7326. utils.ErrorLog("解析失败:%v", err)
  7327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7328. return
  7329. }
  7330. if res.Infcode != 0 {
  7331. c.ServeSuccessJSON(map[string]interface{}{
  7332. "failed_code": -10,
  7333. "msg": res.ErrMsg,
  7334. })
  7335. return
  7336. } else {
  7337. fmt.Println(res)
  7338. }
  7339. }
  7340. func (c *HisApiController) CheckCardPWD() {
  7341. card_pwd := c.GetString("card_pwd")
  7342. his_patient_id, _ := c.GetInt64("his_patient_id")
  7343. admin_user_id, _ := c.GetInt64("admin_user_id")
  7344. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7345. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7346. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7347. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7348. bas := strings.Split(psn.CardInfo, "|")
  7349. basNumber := bas[2]
  7350. if psn.InsuplcAdmdvs[:4] == "4403" {
  7351. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7352. var dat map[string]interface{}
  7353. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7354. fmt.Println(dat)
  7355. } else {
  7356. fmt.Println(err)
  7357. }
  7358. userJSONBytes, _ := json.Marshal(dat)
  7359. var res Result90991
  7360. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7361. utils.ErrorLog("解析失败:%v", err)
  7362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7363. return
  7364. }
  7365. if res.Infcode != 0 {
  7366. c.ServeSuccessJSON(map[string]interface{}{
  7367. "failed_code": -10,
  7368. "msg": res.ErrMsg,
  7369. })
  7370. return
  7371. } else {
  7372. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7373. var msg string
  7374. switch res.Output.Result.CardStat {
  7375. case "00":
  7376. msg = "未激活"
  7377. break
  7378. case "10":
  7379. msg = "激活"
  7380. break
  7381. case "20":
  7382. msg = "窗口挂失"
  7383. break
  7384. case "21":
  7385. msg = "电话挂失"
  7386. break
  7387. case "22":
  7388. msg = "单位网上申报挂失"
  7389. break
  7390. case "23":
  7391. msg = "保健办挂失"
  7392. break
  7393. case "24":
  7394. msg = "个人网上挂失"
  7395. break
  7396. case "25":
  7397. msg = "网上服务大厅挂失"
  7398. break
  7399. case "30":
  7400. msg = "注销"
  7401. break
  7402. case "40":
  7403. msg = "回收"
  7404. break
  7405. case "99":
  7406. msg = "制卡中(无效卡)"
  7407. break
  7408. }
  7409. c.ServeSuccessJSON(map[string]interface{}{
  7410. "failed_code": -10,
  7411. "msg": msg,
  7412. })
  7413. return
  7414. } else {
  7415. c.ServeSuccessJSON(map[string]interface{}{
  7416. "msg": "校验成功",
  7417. })
  7418. return
  7419. }
  7420. }
  7421. } else {
  7422. c.ServeSuccessJSON(map[string]interface{}{
  7423. "msg": "校验成功",
  7424. })
  7425. return
  7426. }
  7427. }
  7428. func (c *HisApiController) CheckCardPWDTwo() {
  7429. //card_pwd := c.GetString("card_pwd")
  7430. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7431. admin_user_id, _ := c.GetInt64("admin_user_id")
  7432. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7433. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7434. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7435. var dat map[string]interface{}
  7436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7437. fmt.Println(dat)
  7438. } else {
  7439. fmt.Println(err)
  7440. }
  7441. userJSONBytes, _ := json.Marshal(dat)
  7442. var res Result90991
  7443. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7444. utils.ErrorLog("解析失败:%v", err)
  7445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7446. return
  7447. }
  7448. if res.Infcode != 0 {
  7449. c.ServeSuccessJSON(map[string]interface{}{
  7450. "failed_code": -10,
  7451. "msg": res.ErrMsg,
  7452. })
  7453. return
  7454. } else {
  7455. if res.Output.Result.SscnoCheckStat == "0" {
  7456. var msg string
  7457. switch res.Output.Result.CardStat {
  7458. case "00":
  7459. msg = "未激活"
  7460. break
  7461. case "10":
  7462. msg = "激活"
  7463. break
  7464. case "20":
  7465. msg = "窗口挂失"
  7466. break
  7467. case "21":
  7468. msg = "电话挂失"
  7469. break
  7470. case "22":
  7471. msg = "单位网上申报挂失"
  7472. break
  7473. case "23":
  7474. msg = "保健办挂失"
  7475. break
  7476. case "24":
  7477. msg = "个人网上挂失"
  7478. break
  7479. case "25":
  7480. msg = "网上服务大厅挂失"
  7481. break
  7482. case "30":
  7483. msg = "注销"
  7484. break
  7485. case "40":
  7486. msg = "回收"
  7487. break
  7488. case "99":
  7489. msg = "制卡中(无效卡)"
  7490. break
  7491. }
  7492. c.ServeSuccessJSON(map[string]interface{}{
  7493. "failed_code": -10,
  7494. "msg": msg,
  7495. })
  7496. return
  7497. } else {
  7498. c.ServeSuccessJSON(map[string]interface{}{
  7499. "msg": "校验成功",
  7500. })
  7501. return
  7502. }
  7503. }
  7504. }
  7505. type ELeCertData struct {
  7506. Data struct {
  7507. Extra string `json:"extra"`
  7508. IDNo string `json:"idNo"`
  7509. IDType string `json:"idType"`
  7510. EcToken string `json:"ecToken"`
  7511. InsuOrg string `json:"insuOrg"`
  7512. UserName string `json:"userName"`
  7513. EcIndexNo string `json:"ecIndexNo"`
  7514. Gender string `json:"gender"`
  7515. Birthday string `json:"birthday"`
  7516. Nationality string `json:"nationality"`
  7517. Email string `json:"email"`
  7518. } `json:"OutData"`
  7519. }
  7520. func (c *HisApiController) ReadCard() {
  7521. id_card_type, _ := c.GetInt64("id_card_type")
  7522. admin_user_id, _ := c.GetInt64("admin_user_id")
  7523. certificates, _ := c.GetInt64("certificates")
  7524. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7525. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7526. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7527. switch id_card_type {
  7528. case 1:
  7529. if miConfig.MdtrtareaAdmvs == "421300" {
  7530. var res ResultTwo
  7531. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7532. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7533. "&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)
  7534. resp, requestErr := http.Get(api)
  7535. if requestErr != nil {
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. return
  7538. }
  7539. body, ioErr := ioutil.ReadAll(resp.Body)
  7540. if ioErr != nil {
  7541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7543. return
  7544. }
  7545. var respJSON map[string]interface{}
  7546. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7549. return
  7550. }
  7551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7552. result, _ := json.Marshal(respJSON)
  7553. fmt.Println("log")
  7554. fmt.Println(string(result))
  7555. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7556. utils.ErrorLog("解析失败:%v", err)
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. return
  7559. }
  7560. if res.Infcode == 0 {
  7561. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7562. if err == gorm.ErrRecordNotFound {
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7564. return
  7565. } else if err != nil {
  7566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7567. return
  7568. } else {
  7569. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7570. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7571. infoStr := string(Iinfos)
  7572. idetinfoStr := string(Idetinfos)
  7573. var rf []*ResultFive
  7574. json.Unmarshal([]byte(infoStr), &rf)
  7575. var insutypes []*ResultFive
  7576. var insutype string
  7577. var is390 int = 0
  7578. var is310 int = 0
  7579. for _, item := range rf {
  7580. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7581. insutypes = append(insutypes, item)
  7582. }
  7583. }
  7584. if len(insutypes) == 1 {
  7585. insutype = insutypes[0].Insutype
  7586. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7587. } else {
  7588. for _, i := range insutypes {
  7589. if i.Insutype == "390" {
  7590. is390 = 1
  7591. }
  7592. if i.Insutype == "310" {
  7593. is310 = 1
  7594. }
  7595. }
  7596. }
  7597. if is390 == 1 {
  7598. insutype = "390"
  7599. }
  7600. if is310 == 1 {
  7601. insutype = "310"
  7602. }
  7603. if len(insutypes) == 0 {
  7604. insutype = "390"
  7605. }
  7606. var insuplc_admdvs string
  7607. for _, item := range rf {
  7608. if item.Insutype == insutype {
  7609. insuplc_admdvs = item.InsuplcAdmdvs
  7610. }
  7611. }
  7612. if strings.Contains(insuplc_admdvs, "4213") {
  7613. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7614. }
  7615. psn := &models.HisPsn{
  7616. PsnNo: res.Output.Baseinfo.PsnNo,
  7617. PatientId: patient.ID,
  7618. Certno: res.Output.Baseinfo.Certno,
  7619. Gend: res.Output.Baseinfo.Gend,
  7620. Naty: res.Output.Baseinfo.Naty,
  7621. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7622. PsnName: res.Output.Baseinfo.PsnName,
  7623. Idetinfo: idetinfoStr,
  7624. Insuinfo: infoStr,
  7625. InsuplcAdmdvs: insuplc_admdvs,
  7626. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7627. }
  7628. service.CreateHisPsn(psn)
  7629. c.ServeSuccessJSON(map[string]interface{}{
  7630. "patient": patient,
  7631. "number": res.Output.Baseinfo.Certno,
  7632. })
  7633. }
  7634. } else {
  7635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7636. return
  7637. }
  7638. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7639. var res ResultTwo
  7640. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7641. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7642. "&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)
  7643. resp, requestErr := http.Get(api)
  7644. if requestErr != nil {
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. body, ioErr := ioutil.ReadAll(resp.Body)
  7649. if ioErr != nil {
  7650. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7652. return
  7653. }
  7654. var respJSON map[string]interface{}
  7655. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7656. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7658. return
  7659. }
  7660. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7661. result, _ := json.Marshal(respJSON)
  7662. fmt.Println("log")
  7663. fmt.Println(string(result))
  7664. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7665. utils.ErrorLog("解析失败:%v", err)
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7667. return
  7668. }
  7669. if res.Infcode == 0 {
  7670. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7671. if err == gorm.ErrRecordNotFound {
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7673. return
  7674. } else if err != nil {
  7675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7676. return
  7677. } else {
  7678. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7679. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7680. infoStr := string(Iinfos)
  7681. idetinfoStr := string(Idetinfos)
  7682. psn := &models.HisPsn{
  7683. PsnNo: res.Output.Baseinfo.PsnNo,
  7684. PatientId: patient.ID,
  7685. Certno: res.Output.Baseinfo.Certno,
  7686. Gend: res.Output.Baseinfo.Gend,
  7687. Naty: res.Output.Baseinfo.Naty,
  7688. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7689. PsnName: res.Output.Baseinfo.PsnName,
  7690. Idetinfo: idetinfoStr,
  7691. Insuinfo: infoStr,
  7692. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7693. }
  7694. service.CreateHisPsn(psn)
  7695. var rf []*ResultFive
  7696. json.Unmarshal([]byte(infoStr), &rf)
  7697. var insutypes []*ResultFive
  7698. var insutype string
  7699. var is390 int = 0
  7700. var is310 int = 0
  7701. for _, item := range rf {
  7702. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7703. insutypes = append(insutypes, item)
  7704. }
  7705. }
  7706. if len(insutypes) == 1 {
  7707. insutype = insutypes[0].Insutype
  7708. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7709. } else {
  7710. for _, i := range insutypes {
  7711. if i.Insutype == "390" {
  7712. is390 = 1
  7713. }
  7714. if i.Insutype == "310" {
  7715. is310 = 1
  7716. }
  7717. }
  7718. }
  7719. if is390 == 1 {
  7720. insutype = "390"
  7721. }
  7722. if is310 == 1 {
  7723. insutype = "310"
  7724. }
  7725. if len(insutypes) == 0 {
  7726. insutype = "310"
  7727. }
  7728. c.ServeSuccessJSON(map[string]interface{}{
  7729. "patient": patient,
  7730. "number": res.Output.Baseinfo.Certno,
  7731. "insutype": insutype,
  7732. })
  7733. }
  7734. } else {
  7735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7736. return
  7737. }
  7738. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7739. var res ResultTwo
  7740. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7741. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7742. "&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)
  7743. resp, requestErr := http.Get(api)
  7744. if requestErr != nil {
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. body, ioErr := ioutil.ReadAll(resp.Body)
  7749. if ioErr != nil {
  7750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. var respJSON map[string]interface{}
  7755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7758. return
  7759. }
  7760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7761. result, _ := json.Marshal(respJSON)
  7762. fmt.Println("log")
  7763. fmt.Println(string(result))
  7764. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7765. utils.ErrorLog("解析失败:%v", err)
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. if res.Infcode == 0 {
  7770. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7771. if err == gorm.ErrRecordNotFound {
  7772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7773. return
  7774. } else if err != nil {
  7775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7776. return
  7777. } else {
  7778. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7779. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7780. infoStr := string(Iinfos)
  7781. idetinfoStr := string(Idetinfos)
  7782. var rf []*ResultFive
  7783. json.Unmarshal([]byte(infoStr), &rf)
  7784. var insutypes []*ResultFive
  7785. var insutype string
  7786. var is390 int = 0
  7787. var is310 int = 0
  7788. for _, item := range rf {
  7789. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7790. insutypes = append(insutypes, item)
  7791. }
  7792. }
  7793. if len(insutypes) == 1 {
  7794. insutype = insutypes[0].Insutype
  7795. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7796. } else {
  7797. for _, i := range insutypes {
  7798. if i.Insutype == "390" {
  7799. is390 = 1
  7800. }
  7801. if i.Insutype == "310" {
  7802. is310 = 1
  7803. }
  7804. }
  7805. }
  7806. if is390 == 1 {
  7807. insutype = "390"
  7808. }
  7809. if is310 == 1 {
  7810. insutype = "310"
  7811. }
  7812. if len(insutypes) == 0 {
  7813. insutype = "390"
  7814. }
  7815. var insuplc_admdvs string
  7816. for _, item := range rf {
  7817. if item.Insutype == insutype {
  7818. insuplc_admdvs = item.InsuplcAdmdvs
  7819. }
  7820. }
  7821. psn := &models.HisPsn{
  7822. PsnNo: res.Output.Baseinfo.PsnNo,
  7823. PatientId: patient.ID,
  7824. Certno: res.Output.Baseinfo.Certno,
  7825. Gend: res.Output.Baseinfo.Gend,
  7826. Naty: res.Output.Baseinfo.Naty,
  7827. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7828. PsnName: res.Output.Baseinfo.PsnName,
  7829. Idetinfo: idetinfoStr,
  7830. Insuinfo: infoStr,
  7831. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7832. InsuplcAdmdvs: insuplc_admdvs,
  7833. }
  7834. service.CreateHisPsn(psn)
  7835. for _, item := range rf {
  7836. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7837. insutypes = append(insutypes, item)
  7838. }
  7839. }
  7840. if len(insutypes) == 1 {
  7841. insutype = insutypes[0].Insutype
  7842. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7843. } else {
  7844. for _, i := range insutypes {
  7845. if i.Insutype == "390" {
  7846. is390 = 1
  7847. }
  7848. if i.Insutype == "310" {
  7849. is310 = 1
  7850. }
  7851. }
  7852. }
  7853. if is390 == 1 {
  7854. insutype = "390"
  7855. }
  7856. if is310 == 1 {
  7857. insutype = "310"
  7858. }
  7859. if len(insutypes) == 0 {
  7860. insutype = "310"
  7861. }
  7862. c.ServeSuccessJSON(map[string]interface{}{
  7863. "patient": patient,
  7864. "number": res.Output.Baseinfo.Certno,
  7865. "insutype": insutype,
  7866. })
  7867. }
  7868. } else {
  7869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7870. return
  7871. }
  7872. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7873. var res ResultTwo
  7874. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7875. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7876. "&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)
  7877. resp, requestErr := http.Get(api)
  7878. if requestErr != nil {
  7879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7880. return
  7881. }
  7882. body, ioErr := ioutil.ReadAll(resp.Body)
  7883. if ioErr != nil {
  7884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. var respJSON map[string]interface{}
  7889. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7895. result, _ := json.Marshal(respJSON)
  7896. fmt.Println("log")
  7897. fmt.Println(string(result))
  7898. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7899. utils.ErrorLog("解析失败:%v", err)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. if res.Infcode == 0 {
  7904. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7905. if err == gorm.ErrRecordNotFound {
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7907. return
  7908. } else if err != nil {
  7909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7910. return
  7911. } else {
  7912. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7913. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7914. infoStr := string(Iinfos)
  7915. idetinfoStr := string(Idetinfos)
  7916. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7917. psn := &models.HisPsn{
  7918. PsnNo: res.Output.Baseinfo.PsnNo,
  7919. PatientId: patient.ID,
  7920. Certno: res.Output.Baseinfo.Certno,
  7921. Brdy: b,
  7922. Age: float64(age),
  7923. Gend: res.Output.Baseinfo.Gend,
  7924. Naty: res.Output.Baseinfo.Naty,
  7925. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7926. PsnName: res.Output.Baseinfo.PsnName,
  7927. Idetinfo: idetinfoStr,
  7928. Insuinfo: infoStr,
  7929. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7930. }
  7931. service.CreateHisPsn(psn)
  7932. var rf []*ResultFive
  7933. json.Unmarshal([]byte(infoStr), &rf)
  7934. var insutypes []*ResultFive
  7935. var insutype string
  7936. var is390 int = 0
  7937. var is310 int = 0
  7938. for _, item := range rf {
  7939. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7940. insutypes = append(insutypes, item)
  7941. }
  7942. }
  7943. if len(insutypes) == 1 {
  7944. insutype = insutypes[0].Insutype
  7945. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7946. } else {
  7947. for _, i := range insutypes {
  7948. if i.Insutype == "390" {
  7949. is390 = 1
  7950. }
  7951. if i.Insutype == "310" {
  7952. is310 = 1
  7953. }
  7954. }
  7955. }
  7956. if is390 == 1 {
  7957. insutype = "390"
  7958. }
  7959. if is310 == 1 {
  7960. insutype = "310"
  7961. }
  7962. if len(insutypes) == 0 {
  7963. insutype = "310"
  7964. }
  7965. c.ServeSuccessJSON(map[string]interface{}{
  7966. "patient": patient,
  7967. "number": res.Output.Baseinfo.Certno,
  7968. "insutype": insutype,
  7969. })
  7970. }
  7971. } else {
  7972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7973. return
  7974. }
  7975. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7976. var api string
  7977. if miConfig.MdtrtareaAdmvs == "320921" {
  7978. 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 +
  7979. "&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
  7980. fmt.Println(api)
  7981. } else {
  7982. 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 +
  7983. "&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)
  7984. }
  7985. resp, requestErr := http.Get(api)
  7986. if requestErr != nil {
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. body, ioErr := ioutil.ReadAll(resp.Body)
  7991. if ioErr != nil {
  7992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7994. return
  7995. }
  7996. var respJSON map[string]interface{}
  7997. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. var status string
  8003. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8004. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8005. //console.log()
  8006. fmt.Println("type===")
  8007. fmt.Println(card_type)
  8008. var token string
  8009. var res ResultTwo //1101结果
  8010. var res10265 ResultTwo10265 //1101结果
  8011. var card_info string //卡信息
  8012. var busi_card_info string
  8013. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8014. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8015. if status == "0" { //读卡成功
  8016. if card_type == "1" {
  8017. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8018. result, _ := json.Marshal(respJSON)
  8019. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8020. utils.ErrorLog("解析失败:%v", err)
  8021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8022. return
  8023. }
  8024. res.ErrMsg = res10265.ErrMsg
  8025. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8026. res.Infcode = infocode
  8027. res.Output = res10265.Output
  8028. res.InfRefmsgid = res10265.InfRefmsgid
  8029. } else {
  8030. //var card_info string //卡信息
  8031. //var busi_card_info string
  8032. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8033. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8034. //fmt.Println(card_info)
  8035. //fmt.Println(busi_card_info)
  8036. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8037. result, _ := json.Marshal(respJSON)
  8038. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8039. utils.ErrorLog("解析失败:%v", err)
  8040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8041. return
  8042. }
  8043. res.ErrMsg = res10265.ErrMsg
  8044. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8045. res.Infcode = infocode
  8046. res.Output = res10265.Output
  8047. res.InfRefmsgid = res10265.InfRefmsgid
  8048. }
  8049. if res.Infcode == 0 {
  8050. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8051. if err == gorm.ErrRecordNotFound {
  8052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8053. return
  8054. } else if err != nil {
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8056. return
  8057. } else {
  8058. if card_type == "1" {
  8059. bas := strings.Split(card_info, "|")
  8060. basNumber := bas[2]
  8061. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8062. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8063. infoStr := string(Iinfos)
  8064. idetinfoStr := string(Idetinfos)
  8065. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  8066. psn := &models.HisPsn{
  8067. PsnNo: res.Output.Baseinfo.PsnNo,
  8068. PatientId: patient.ID,
  8069. Certno: res.Output.Baseinfo.Certno,
  8070. Brdy: b,
  8071. Age: float64(age),
  8072. Gend: res.Output.Baseinfo.Gend,
  8073. Naty: res.Output.Baseinfo.Naty,
  8074. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8075. PsnName: res.Output.Baseinfo.PsnName,
  8076. Idetinfo: idetinfoStr,
  8077. Insuinfo: infoStr,
  8078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8079. CardInfo: card_info,
  8080. VerifyNumber: busi_card_info,
  8081. }
  8082. service.CreateHisPsn(psn)
  8083. var rf []*ResultFive
  8084. json.Unmarshal([]byte(infoStr), &rf)
  8085. var insutypes []*ResultFive
  8086. var insutype string
  8087. var is390 int = 0
  8088. var is310 int = 0
  8089. for _, item := range rf {
  8090. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8091. insutypes = append(insutypes, item)
  8092. }
  8093. }
  8094. if len(insutypes) == 1 {
  8095. insutype = insutypes[0].Insutype
  8096. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8097. } else {
  8098. for _, i := range insutypes {
  8099. if i.Insutype == "390" {
  8100. is390 = 1
  8101. }
  8102. if i.Insutype == "310" {
  8103. is310 = 1
  8104. }
  8105. }
  8106. }
  8107. if is390 == 1 {
  8108. insutype = "390"
  8109. }
  8110. if is310 == 1 {
  8111. insutype = "310"
  8112. }
  8113. if len(insutypes) == 0 {
  8114. insutype = "310"
  8115. }
  8116. c.ServeSuccessJSON(map[string]interface{}{
  8117. "patient": patient,
  8118. "number": basNumber,
  8119. "insutype": insutype,
  8120. })
  8121. } else {
  8122. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8123. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8124. infoStr := string(Iinfos)
  8125. idetinfoStr := string(Idetinfos)
  8126. psn := &models.HisPsn{
  8127. PsnNo: res.Output.Baseinfo.PsnNo,
  8128. PatientId: patient.ID,
  8129. Certno: res.Output.Baseinfo.Certno,
  8130. Gend: res.Output.Baseinfo.Gend,
  8131. Naty: res.Output.Baseinfo.Naty,
  8132. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8133. PsnName: res.Output.Baseinfo.PsnName,
  8134. Idetinfo: idetinfoStr,
  8135. Insuinfo: infoStr,
  8136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8137. CardInfo: card_info,
  8138. VerifyNumber: token,
  8139. }
  8140. service.CreateHisPsn(psn)
  8141. c.ServeSuccessJSON(map[string]interface{}{
  8142. "patient": patient,
  8143. "number": token,
  8144. })
  8145. }
  8146. }
  8147. } else {
  8148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8149. return
  8150. }
  8151. } else { //读卡失败
  8152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8153. return
  8154. }
  8155. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8156. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8157. cardnum = DeleteExtraSpaceTwo(cardnum)
  8158. cardCode = DeleteExtraSpaceTwo(cardCode)
  8159. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8160. name = DeleteExtraSpaceTwo(name)
  8161. errmsg = DeleteExtraSpaceTwo(errmsg)
  8162. cardnum = Remove0000(cardnum)
  8163. cardCode = Remove0000(cardCode)
  8164. id_card_no = Remove0000(id_card_no)
  8165. name = Remove0000(name)
  8166. errmsg = Remove0000(errmsg)
  8167. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8168. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8169. //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)
  8170. //fmt.Println(result2)
  8171. //fmt.Println(requestLog2)
  8172. //fmt.Println(errMsgLog2)
  8173. 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)
  8174. saveLog(result, requestLog, "1101", "获取人员信息")
  8175. fmt.Println(errMsgLog)
  8176. if len(errMsgLog) > 0 {
  8177. } else {
  8178. var dat map[string]interface{}
  8179. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8180. fmt.Println(dat)
  8181. } else {
  8182. fmt.Println(err)
  8183. }
  8184. userJSONBytes, _ := json.Marshal(dat)
  8185. var res ResultTwo
  8186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8187. utils.ErrorLog("解析失败:%v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. res.ErrMsg = errMsgLog
  8192. if res.Infcode == 0 {
  8193. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8194. if err == gorm.ErrRecordNotFound {
  8195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8196. return
  8197. } else if err != nil {
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8199. return
  8200. } else {
  8201. fmt.Println(res)
  8202. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8203. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8204. infoStr := string(Iinfos)
  8205. idetinfoStr := string(Idetinfos)
  8206. var rf []*ResultFive
  8207. json.Unmarshal([]byte(infoStr), &rf)
  8208. var insutypes []*ResultFive
  8209. var insutype string
  8210. var is390 int = 0
  8211. var is310 int = 0
  8212. for _, item := range rf {
  8213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8214. insutypes = append(insutypes, item)
  8215. }
  8216. }
  8217. if len(insutypes) == 1 {
  8218. insutype = insutypes[0].Insutype
  8219. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8220. } else {
  8221. for _, i := range insutypes {
  8222. if i.Insutype == "390" {
  8223. is390 = 1
  8224. }
  8225. if i.Insutype == "310" {
  8226. is310 = 1
  8227. }
  8228. }
  8229. }
  8230. if is390 == 1 {
  8231. insutype = "390"
  8232. }
  8233. if is310 == 1 {
  8234. insutype = "310"
  8235. }
  8236. if len(insutypes) == 0 {
  8237. insutype = "390"
  8238. }
  8239. var insuplc_admdvs string
  8240. for _, item := range rf {
  8241. if item.Insutype == insutype {
  8242. insuplc_admdvs = item.InsuplcAdmdvs
  8243. }
  8244. }
  8245. psn := &models.HisPsn{
  8246. PsnNo: res.Output.Baseinfo.PsnNo,
  8247. PatientId: patient.ID,
  8248. Certno: res.Output.Baseinfo.Certno,
  8249. Gend: res.Output.Baseinfo.Gend,
  8250. Naty: res.Output.Baseinfo.Naty,
  8251. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8252. PsnName: res.Output.Baseinfo.PsnName,
  8253. Idetinfo: idetinfoStr,
  8254. Insuinfo: infoStr,
  8255. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8256. CardInfo: basStr,
  8257. VerifyNumber: "",
  8258. InsuplcAdmdvs: insuplc_admdvs,
  8259. }
  8260. service.CreateHisPsn(psn)
  8261. c.ServeSuccessJSON(map[string]interface{}{
  8262. "patient": patient,
  8263. "number": cardnum,
  8264. "insutype": insutype,
  8265. })
  8266. }
  8267. } else {
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8269. return
  8270. }
  8271. }
  8272. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8273. fmt.Println(initFlag)
  8274. fmt.Println("initFlag")
  8275. if initFlag == 0 {
  8276. c.TestGetJiangXiBasBaseInit()
  8277. }
  8278. basStr := c.GetBasBaseInfo()
  8279. if len(basStr) == 0 {
  8280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8281. return
  8282. }
  8283. fmt.Println(basStr)
  8284. bas := strings.Split(basStr, "|")
  8285. basNumber := bas[1]
  8286. fmt.Println(basNumber)
  8287. card_sn := bas[3]
  8288. fmt.Println(card_sn)
  8289. 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, "")
  8290. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8291. var dat map[string]interface{}
  8292. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8293. fmt.Println(dat)
  8294. } else {
  8295. fmt.Println(err)
  8296. }
  8297. userJSONBytes, _ := json.Marshal(dat)
  8298. var res ResultTwo
  8299. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8300. utils.ErrorLog("解析失败:%v", err)
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8302. return
  8303. }
  8304. if res.Infcode == 0 {
  8305. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8306. if err == gorm.ErrRecordNotFound {
  8307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8308. return
  8309. } else if err != nil {
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8311. return
  8312. } else {
  8313. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8314. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8315. infoStr := string(Iinfos)
  8316. idetinfoStr := string(Idetinfos)
  8317. var rf []*ResultFive
  8318. json.Unmarshal([]byte(infoStr), &rf)
  8319. var insutypes []*ResultFive
  8320. var insutype string
  8321. var is390 int = 0
  8322. var is310 int = 0
  8323. var insuplc_admdvs string
  8324. for _, item := range rf {
  8325. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8326. insutypes = append(insutypes, item)
  8327. }
  8328. }
  8329. if len(insutypes) == 1 {
  8330. insutype = insutypes[0].Insutype
  8331. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8332. } else {
  8333. for _, i := range insutypes {
  8334. if i.Insutype == "390" {
  8335. is390 = 1
  8336. }
  8337. if i.Insutype == "310" {
  8338. is310 = 1
  8339. }
  8340. }
  8341. }
  8342. if is390 == 1 {
  8343. insutype = "390"
  8344. }
  8345. if is310 == 1 {
  8346. insutype = "310"
  8347. }
  8348. if len(insutypes) == 0 {
  8349. insutype = "310"
  8350. }
  8351. for _, item := range rf {
  8352. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8353. insuplc_admdvs = item.InsuplcAdmdvs
  8354. }
  8355. }
  8356. psn := &models.HisPsn{
  8357. PsnNo: res.Output.Baseinfo.PsnNo,
  8358. PatientId: patient.ID,
  8359. Certno: res.Output.Baseinfo.Certno,
  8360. Gend: res.Output.Baseinfo.Gend,
  8361. Naty: res.Output.Baseinfo.Naty,
  8362. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8363. PsnName: res.Output.Baseinfo.PsnName,
  8364. Idetinfo: idetinfoStr,
  8365. Insuinfo: infoStr,
  8366. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8367. CardInfo: basStr,
  8368. InsuplcAdmdvs: insuplc_admdvs,
  8369. VerifyNumber: "",
  8370. }
  8371. service.CreateHisPsn(psn)
  8372. c.ServeSuccessJSON(map[string]interface{}{
  8373. "patient": patient,
  8374. "number": basNumber,
  8375. "insutype": insutype,
  8376. })
  8377. }
  8378. } else {
  8379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8380. return
  8381. }
  8382. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8383. fmt.Println(initFlag)
  8384. fmt.Println("initFlag")
  8385. if initFlag == 0 {
  8386. c.TestGetHnBasBaseInit()
  8387. }
  8388. basStr := c.GetBasBaseInfo()
  8389. if len(basStr) == 0 {
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8391. return
  8392. }
  8393. fmt.Println(basStr)
  8394. bas := strings.Split(basStr, "|")
  8395. basNumber := bas[1]
  8396. fmt.Println(basNumber)
  8397. card_sn := bas[3]
  8398. card_no := bas[2]
  8399. fmt.Println(card_sn)
  8400. name := bas[4]
  8401. name = ConvertToString(name, "gbk", "utf-8")
  8402. 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)
  8403. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8404. var dat map[string]interface{}
  8405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8406. fmt.Println(dat)
  8407. } else {
  8408. fmt.Println(err)
  8409. }
  8410. userJSONBytes, _ := json.Marshal(dat)
  8411. var res ResultTwo
  8412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8413. utils.ErrorLog("解析失败:%v", err)
  8414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8415. return
  8416. }
  8417. if res.Infcode == 0 {
  8418. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8419. if err == gorm.ErrRecordNotFound {
  8420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8421. return
  8422. } else if err != nil {
  8423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8424. return
  8425. } else {
  8426. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8427. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8428. infoStr := string(Iinfos)
  8429. idetinfoStr := string(Idetinfos)
  8430. psn := &models.HisPsn{
  8431. PsnNo: res.Output.Baseinfo.PsnNo,
  8432. PatientId: patient.ID,
  8433. Certno: res.Output.Baseinfo.Certno,
  8434. Gend: res.Output.Baseinfo.Gend,
  8435. Naty: res.Output.Baseinfo.Naty,
  8436. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8437. PsnName: res.Output.Baseinfo.PsnName,
  8438. Idetinfo: idetinfoStr,
  8439. Insuinfo: infoStr,
  8440. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8441. CardInfo: basStr,
  8442. VerifyNumber: "",
  8443. }
  8444. service.CreateHisPsn(psn)
  8445. var rf []*ResultFive
  8446. json.Unmarshal([]byte(infoStr), &rf)
  8447. var insutypes []*ResultFive
  8448. var insutype string
  8449. var is390 int = 0
  8450. var is310 int = 0
  8451. for _, item := range rf {
  8452. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8453. insutypes = append(insutypes, item)
  8454. }
  8455. }
  8456. if len(insutypes) == 1 {
  8457. insutype = insutypes[0].Insutype
  8458. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8459. } else {
  8460. for _, i := range insutypes {
  8461. if i.Insutype == "390" {
  8462. is390 = 1
  8463. }
  8464. if i.Insutype == "310" {
  8465. is310 = 1
  8466. }
  8467. }
  8468. }
  8469. if is390 == 1 {
  8470. insutype = "390"
  8471. }
  8472. if is310 == 1 {
  8473. insutype = "310"
  8474. }
  8475. if len(insutypes) == 0 {
  8476. insutype = "310"
  8477. }
  8478. c.ServeSuccessJSON(map[string]interface{}{
  8479. "patient": patient,
  8480. "number": basNumber,
  8481. "insutype": insutype,
  8482. })
  8483. }
  8484. } else {
  8485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8486. return
  8487. }
  8488. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8489. var api string
  8490. 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 +
  8491. "&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
  8492. fmt.Println(api)
  8493. resp, requestErr := http.Get(api)
  8494. if requestErr != nil {
  8495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8496. return
  8497. }
  8498. body, ioErr := ioutil.ReadAll(resp.Body)
  8499. if ioErr != nil {
  8500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. return
  8503. }
  8504. var respJSON map[string]interface{}
  8505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8508. return
  8509. }
  8510. var res ResultTwo //1101结果
  8511. var res10265 ResultTwo10265 //1101结果
  8512. var card_info string //卡信息
  8513. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8514. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8515. result, _ := json.Marshal(respJSON)
  8516. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8517. utils.ErrorLog("解析失败:%v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. res.ErrMsg = res10265.ErrMsg
  8522. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8523. res.Infcode = infocode
  8524. res.Output = res10265.Output
  8525. res.InfRefmsgid = res10265.InfRefmsgid
  8526. if res.Infcode == 0 {
  8527. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8528. if err == gorm.ErrRecordNotFound {
  8529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8530. return
  8531. } else if err != nil {
  8532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8533. return
  8534. } else {
  8535. bas := strings.Split(card_info, "|")
  8536. basNumber := bas[2]
  8537. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8538. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8539. infoStr := string(Iinfos)
  8540. idetinfoStr := string(Idetinfos)
  8541. psn := &models.HisPsn{
  8542. PsnNo: res.Output.Baseinfo.PsnNo,
  8543. PatientId: patient.ID,
  8544. Certno: res.Output.Baseinfo.Certno,
  8545. Gend: res.Output.Baseinfo.Gend,
  8546. Naty: res.Output.Baseinfo.Naty,
  8547. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8548. PsnName: res.Output.Baseinfo.PsnName,
  8549. Idetinfo: idetinfoStr,
  8550. Insuinfo: infoStr,
  8551. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8552. CardInfo: card_info,
  8553. VerifyNumber: token,
  8554. }
  8555. service.CreateHisPsn(psn)
  8556. var rf []*ResultFive
  8557. json.Unmarshal([]byte(infoStr), &rf)
  8558. var insutypes []*ResultFive
  8559. var insutype string
  8560. var is390 int = 0
  8561. var is310 int = 0
  8562. for _, item := range rf {
  8563. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8564. insutypes = append(insutypes, item)
  8565. }
  8566. }
  8567. if len(insutypes) == 1 {
  8568. insutype = insutypes[0].Insutype
  8569. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8570. } else {
  8571. for _, i := range insutypes {
  8572. if i.Insutype == "390" {
  8573. is390 = 1
  8574. }
  8575. if i.Insutype == "310" {
  8576. is310 = 1
  8577. }
  8578. }
  8579. }
  8580. if is390 == 1 {
  8581. insutype = "390"
  8582. }
  8583. if is310 == 1 {
  8584. insutype = "310"
  8585. }
  8586. if len(insutypes) == 0 {
  8587. insutype = "310"
  8588. }
  8589. c.ServeSuccessJSON(map[string]interface{}{
  8590. "patient": patient,
  8591. "number": basNumber,
  8592. "insutype": insutype,
  8593. })
  8594. }
  8595. } else {
  8596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8597. return
  8598. }
  8599. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8600. res := c.GetoleInfo()
  8601. if res.Infcode == 0 {
  8602. var result string
  8603. if res.Output.MdtrtCertType == "01" {
  8604. 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)
  8605. } else if res.Output.MdtrtCertType == "02" {
  8606. 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)
  8607. } else if res.Output.MdtrtCertType == "03" {
  8608. 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)
  8609. }
  8610. var dat map[string]interface{}
  8611. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8612. fmt.Println(dat)
  8613. } else {
  8614. fmt.Println(err)
  8615. }
  8616. userJSONBytes, _ := json.Marshal(dat)
  8617. var res2 ResultTwo
  8618. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8619. utils.ErrorLog("解析失败:%v", err)
  8620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8621. return
  8622. }
  8623. if res2.Infcode == 0 {
  8624. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8625. if err == gorm.ErrRecordNotFound {
  8626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8627. return
  8628. } else if err != nil {
  8629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8630. return
  8631. } else {
  8632. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8633. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8634. infoStr := string(Iinfos)
  8635. idetinfoStr := string(Idetinfos)
  8636. var rf []*ResultFive
  8637. json.Unmarshal([]byte(infoStr), &rf)
  8638. var insutypes []*ResultFive
  8639. var insutype string
  8640. var is390 int = 0
  8641. var is310 int = 0
  8642. //var insuplc_admdvs string
  8643. for _, item := range rf {
  8644. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8645. insutypes = append(insutypes, item)
  8646. }
  8647. }
  8648. if len(insutypes) == 1 {
  8649. insutype = insutypes[0].Insutype
  8650. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8651. } else {
  8652. for _, i := range insutypes {
  8653. if i.Insutype == "390" {
  8654. is390 = 1
  8655. }
  8656. if i.Insutype == "310" {
  8657. is310 = 1
  8658. }
  8659. }
  8660. }
  8661. if is390 == 1 {
  8662. insutype = "390"
  8663. }
  8664. if is310 == 1 {
  8665. insutype = "310"
  8666. }
  8667. if len(insutypes) == 0 {
  8668. insutype = "310"
  8669. }
  8670. psn := &models.HisPsn{
  8671. PsnNo: res2.Output.Baseinfo.PsnNo,
  8672. PatientId: patient.ID,
  8673. Certno: res2.Output.Baseinfo.Certno,
  8674. Gend: res2.Output.Baseinfo.Gend,
  8675. Naty: res2.Output.Baseinfo.Naty,
  8676. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8677. PsnName: res2.Output.Baseinfo.PsnName,
  8678. Idetinfo: idetinfoStr,
  8679. Insuinfo: infoStr,
  8680. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8681. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8682. VerifyNumber: res.Output.EcToken,
  8683. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8684. }
  8685. if res.Output.MdtrtCertType == "01" {
  8686. psn.VerifyNumber = res.Output.EcToken
  8687. //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)
  8688. } else if res.Output.MdtrtCertType == "02" {
  8689. psn.VerifyNumber = res.Output.MdtrtCertNo
  8690. //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)
  8691. } else if res.Output.MdtrtCertType == "03" {
  8692. psn.VerifyNumber = res.Output.MdtrtCertNo
  8693. //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)
  8694. }
  8695. var balc float64
  8696. for _, item := range rf {
  8697. if item.Insutype == insutype {
  8698. balc = item.Balc
  8699. }
  8700. }
  8701. service.CreateHisPsn(psn)
  8702. c.ServeSuccessJSON(map[string]interface{}{
  8703. "patient": patient,
  8704. "number": res.Output.CardNo,
  8705. "insutype": insutype,
  8706. "blac": balc,
  8707. "desc": idetinfoStr,
  8708. })
  8709. }
  8710. } else {
  8711. c.ServeSuccessJSON(map[string]interface{}{
  8712. "failed_code": -10,
  8713. "msg": res2.ErrMsg,
  8714. })
  8715. }
  8716. } else {
  8717. c.ServeSuccessJSON(map[string]interface{}{
  8718. "failed_code": -10,
  8719. "msg": res.ErrMsg,
  8720. })
  8721. }
  8722. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8723. var api string
  8724. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8725. "&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
  8726. fmt.Println(api)
  8727. resp, requestErr := http.Get(api)
  8728. if requestErr != nil {
  8729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8730. return
  8731. }
  8732. body, ioErr := ioutil.ReadAll(resp.Body)
  8733. if ioErr != nil {
  8734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8736. return
  8737. }
  8738. var respJSON map[string]interface{}
  8739. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. var status string
  8745. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8746. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8747. //console.log()
  8748. fmt.Println("type===")
  8749. fmt.Println(card_type)
  8750. var token string
  8751. var res ResultTwo //1101结果
  8752. //var res10265 ResultTwoesultTwo10265 //1101结果
  8753. var card_info string //卡信息
  8754. var busi_card_info string
  8755. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8756. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8757. if status == "0" { //读卡成功
  8758. if card_type == "1" {
  8759. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8760. result, _ := json.Marshal(respJSON)
  8761. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8762. utils.ErrorLog("解析失败:%v", err)
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8764. return
  8765. }
  8766. } else {
  8767. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8768. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8769. result, _ := json.Marshal(respJSON)
  8770. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8771. utils.ErrorLog("解析失败:%v", err)
  8772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8773. return
  8774. }
  8775. }
  8776. if res.Infcode == 0 {
  8777. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8778. if err == gorm.ErrRecordNotFound {
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8780. return
  8781. } else if err != nil {
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8783. return
  8784. } else {
  8785. if card_type == "1" {
  8786. bas := strings.Split(card_info, "|")
  8787. basNumber := bas[2]
  8788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8789. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8790. infoStr := string(Iinfos)
  8791. idetinfoStr := string(Idetinfos)
  8792. psn := &models.HisPsn{
  8793. PsnNo: res.Output.Baseinfo.PsnNo,
  8794. PatientId: patient.ID,
  8795. Certno: res.Output.Baseinfo.Certno,
  8796. Gend: res.Output.Baseinfo.Gend,
  8797. Naty: res.Output.Baseinfo.Naty,
  8798. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8799. PsnName: res.Output.Baseinfo.PsnName,
  8800. Idetinfo: idetinfoStr,
  8801. Insuinfo: infoStr,
  8802. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8803. CardInfo: card_info,
  8804. VerifyNumber: busi_card_info,
  8805. }
  8806. service.CreateHisPsn(psn)
  8807. var rf []*ResultFive
  8808. json.Unmarshal([]byte(infoStr), &rf)
  8809. var insutypes []*ResultFive
  8810. var insutype string
  8811. var is390 int = 0
  8812. var is310 int = 0
  8813. for _, item := range rf {
  8814. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8815. insutypes = append(insutypes, item)
  8816. }
  8817. }
  8818. if len(insutypes) == 1 {
  8819. insutype = insutypes[0].Insutype
  8820. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8821. } else {
  8822. for _, i := range insutypes {
  8823. if i.Insutype == "390" {
  8824. is390 = 1
  8825. }
  8826. if i.Insutype == "310" {
  8827. is310 = 1
  8828. }
  8829. }
  8830. }
  8831. if is390 == 1 {
  8832. insutype = "390"
  8833. }
  8834. if is310 == 1 {
  8835. insutype = "310"
  8836. }
  8837. if len(insutypes) == 0 {
  8838. insutype = "310"
  8839. }
  8840. c.ServeSuccessJSON(map[string]interface{}{
  8841. "patient": patient,
  8842. "number": basNumber,
  8843. "insutype": insutype,
  8844. })
  8845. } else {
  8846. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8847. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8848. infoStr := string(Iinfos)
  8849. idetinfoStr := string(Idetinfos)
  8850. psn := &models.HisPsn{
  8851. PsnNo: res.Output.Baseinfo.PsnNo,
  8852. PatientId: patient.ID,
  8853. Certno: res.Output.Baseinfo.Certno,
  8854. Gend: res.Output.Baseinfo.Gend,
  8855. Naty: res.Output.Baseinfo.Naty,
  8856. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8857. PsnName: res.Output.Baseinfo.PsnName,
  8858. Idetinfo: idetinfoStr,
  8859. Insuinfo: infoStr,
  8860. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8861. CardInfo: card_info,
  8862. VerifyNumber: token,
  8863. }
  8864. service.CreateHisPsn(psn)
  8865. c.ServeSuccessJSON(map[string]interface{}{
  8866. "patient": patient,
  8867. "number": token,
  8868. })
  8869. }
  8870. }
  8871. } else {
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8873. return
  8874. }
  8875. } else { //读卡失败
  8876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8877. return
  8878. }
  8879. } else {
  8880. if initFlag == 0 {
  8881. c.TestGetBasBaseInit()
  8882. }
  8883. basStr := c.GetBasBaseInfo()
  8884. if len(basStr) == 0 {
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8886. return
  8887. }
  8888. fmt.Println(basStr)
  8889. bas := strings.Split(basStr, "|")
  8890. basNumber := bas[1]
  8891. fmt.Println(basNumber)
  8892. card_sn := bas[3]
  8893. fmt.Println(card_sn)
  8894. cardNumber := bas[2]
  8895. fmt.Println(cardNumber)
  8896. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8897. var result string
  8898. if bas[0][:2] == "44" {
  8899. 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)
  8900. } else {
  8901. 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)
  8902. }
  8903. var dat map[string]interface{}
  8904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8905. fmt.Println(dat)
  8906. } else {
  8907. fmt.Println(err)
  8908. }
  8909. userJSONBytes, _ := json.Marshal(dat)
  8910. var res ResultTwo
  8911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8912. utils.ErrorLog("解析失败:%v", err)
  8913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8914. return
  8915. }
  8916. if res.Infcode == 0 {
  8917. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8918. if err == gorm.ErrRecordNotFound {
  8919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8920. return
  8921. } else if err != nil {
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8923. return
  8924. } else {
  8925. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8926. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8927. infoStr := string(Iinfos)
  8928. idetinfoStr := string(Idetinfos)
  8929. var rf []*ResultFive
  8930. json.Unmarshal([]byte(infoStr), &rf)
  8931. var insutypes []*ResultFive
  8932. var insutype string
  8933. var is390 int = 0
  8934. var is310 int = 0
  8935. var insuplc_admdvs string
  8936. for _, item := range rf {
  8937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8938. insutypes = append(insutypes, item)
  8939. }
  8940. }
  8941. if len(insutypes) == 1 {
  8942. insutype = insutypes[0].Insutype
  8943. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8944. } else {
  8945. for _, i := range insutypes {
  8946. if i.Insutype == "390" {
  8947. is390 = 1
  8948. }
  8949. if i.Insutype == "310" {
  8950. is310 = 1
  8951. }
  8952. }
  8953. }
  8954. if is390 == 1 {
  8955. insutype = "390"
  8956. }
  8957. if is310 == 1 {
  8958. insutype = "310"
  8959. }
  8960. if len(insutypes) == 0 {
  8961. insutype = "310"
  8962. }
  8963. for _, item := range rf {
  8964. if item.Insutype == insutype {
  8965. insuplc_admdvs = item.InsuplcAdmdvs
  8966. }
  8967. }
  8968. psn := &models.HisPsn{
  8969. PsnNo: res.Output.Baseinfo.PsnNo,
  8970. PatientId: patient.ID,
  8971. Certno: res.Output.Baseinfo.Certno,
  8972. Gend: res.Output.Baseinfo.Gend,
  8973. Naty: res.Output.Baseinfo.Naty,
  8974. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8975. PsnName: res.Output.Baseinfo.PsnName,
  8976. Idetinfo: idetinfoStr,
  8977. Insuinfo: infoStr,
  8978. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8979. CardInfo: basStr,
  8980. VerifyNumber: "",
  8981. InsuplcAdmdvs: insuplc_admdvs,
  8982. }
  8983. service.CreateHisPsn(psn)
  8984. c.ServeSuccessJSON(map[string]interface{}{
  8985. "patient": patient,
  8986. "number": basNumber,
  8987. })
  8988. }
  8989. } else {
  8990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8991. return
  8992. }
  8993. break
  8994. }
  8995. case 2:
  8996. if miConfig.MdtrtareaAdmvs == "430800" {
  8997. if initFlag == 0 {
  8998. c.TestGetHnBasBaseInit()
  8999. }
  9000. SFZStr := c.GetSFZBaseInfo()
  9001. if len(SFZStr) == 0 {
  9002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  9003. return
  9004. }
  9005. fmt.Println(SFZStr)
  9006. id_card_str := strings.Split(SFZStr, "^")
  9007. card_no := id_card_str[0]
  9008. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9009. //name := id_card_str[1]
  9010. //name = ConvertToString(name, "gbk", "utf-8")
  9011. 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)
  9012. var dat map[string]interface{}
  9013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9014. fmt.Println(dat)
  9015. } else {
  9016. fmt.Println(err)
  9017. }
  9018. userJSONBytes, _ := json.Marshal(dat)
  9019. var res ResultTwo
  9020. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9021. utils.ErrorLog("解析失败:%v", err)
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9023. return
  9024. }
  9025. if res.Infcode == 0 {
  9026. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  9027. if err == gorm.ErrRecordNotFound {
  9028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9029. return
  9030. } else if err != nil {
  9031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9032. return
  9033. } else {
  9034. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9035. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9036. infoStr := string(Iinfos)
  9037. idetinfoStr := string(Idetinfos)
  9038. var rf []*ResultFive
  9039. json.Unmarshal([]byte(infoStr), &rf)
  9040. var insutypes []*ResultFive
  9041. var insutype string
  9042. var is390 int = 0
  9043. var is310 int = 0
  9044. for _, item := range rf {
  9045. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9046. insutypes = append(insutypes, item)
  9047. }
  9048. }
  9049. if len(insutypes) == 1 {
  9050. insutype = insutypes[0].Insutype
  9051. } else {
  9052. for _, i := range insutypes {
  9053. if i.Insutype == "390" {
  9054. is390 = 1
  9055. }
  9056. if i.Insutype == "310" {
  9057. is310 = 1
  9058. }
  9059. }
  9060. }
  9061. if is390 == 1 {
  9062. insutype = "390"
  9063. }
  9064. if is310 == 1 {
  9065. insutype = "310"
  9066. }
  9067. if len(insutypes) == 0 {
  9068. insutype = "310"
  9069. }
  9070. var InsuplcAdmdvs string
  9071. for _, item := range rf {
  9072. if item.Insutype == insutype {
  9073. InsuplcAdmdvs = item.InsuplcAdmdvs
  9074. }
  9075. }
  9076. psn := &models.HisPsn{
  9077. PsnNo: res.Output.Baseinfo.PsnNo,
  9078. PatientId: patient.ID,
  9079. Certno: res.Output.Baseinfo.Certno,
  9080. Gend: res.Output.Baseinfo.Gend,
  9081. Naty: res.Output.Baseinfo.Naty,
  9082. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9083. PsnName: res.Output.Baseinfo.PsnName,
  9084. Idetinfo: idetinfoStr,
  9085. Insuinfo: infoStr,
  9086. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9087. CardInfo: SFZStr,
  9088. VerifyNumber: "",
  9089. InsuplcAdmdvs: InsuplcAdmdvs,
  9090. }
  9091. service.CreateHisPsn(psn)
  9092. c.ServeSuccessJSON(map[string]interface{}{
  9093. "patient": patient,
  9094. "number": card_no,
  9095. "insutype": insutype,
  9096. })
  9097. }
  9098. } else {
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9100. return
  9101. }
  9102. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9103. var res ResultTwo
  9104. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9105. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9106. "&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)
  9107. resp, requestErr := http.Get(api)
  9108. if requestErr != nil {
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9110. return
  9111. }
  9112. body, ioErr := ioutil.ReadAll(resp.Body)
  9113. if ioErr != nil {
  9114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9116. return
  9117. }
  9118. var respJSON map[string]interface{}
  9119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9122. return
  9123. }
  9124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9125. result, _ := json.Marshal(respJSON)
  9126. fmt.Println("log")
  9127. fmt.Println(string(result))
  9128. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9129. utils.ErrorLog("解析失败:%v", err)
  9130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9131. return
  9132. }
  9133. if res.Infcode == 0 {
  9134. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9135. if err == gorm.ErrRecordNotFound {
  9136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9137. return
  9138. } else if err != nil {
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9140. return
  9141. } else {
  9142. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9143. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9144. infoStr := string(Iinfos)
  9145. idetinfoStr := string(Idetinfos)
  9146. psn := &models.HisPsn{
  9147. PsnNo: res.Output.Baseinfo.PsnNo,
  9148. PatientId: patient.ID,
  9149. Certno: res.Output.Baseinfo.Certno,
  9150. Gend: res.Output.Baseinfo.Gend,
  9151. Naty: res.Output.Baseinfo.Naty,
  9152. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9153. PsnName: res.Output.Baseinfo.PsnName,
  9154. Idetinfo: idetinfoStr,
  9155. Insuinfo: infoStr,
  9156. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9157. }
  9158. service.CreateHisPsn(psn)
  9159. c.ServeSuccessJSON(map[string]interface{}{
  9160. "patient": patient,
  9161. "number": res.Output.Baseinfo.Certno,
  9162. })
  9163. }
  9164. } else {
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9166. return
  9167. }
  9168. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9169. var res ResultTwo
  9170. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9171. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9172. "&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)
  9173. resp, requestErr := http.Get(api)
  9174. if requestErr != nil {
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. body, ioErr := ioutil.ReadAll(resp.Body)
  9179. if ioErr != nil {
  9180. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. return
  9183. }
  9184. var respJSON map[string]interface{}
  9185. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9186. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9188. return
  9189. }
  9190. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9191. result, _ := json.Marshal(respJSON)
  9192. fmt.Println("log")
  9193. fmt.Println(string(result))
  9194. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9195. utils.ErrorLog("解析失败:%v", err)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. if res.Infcode == 0 {
  9200. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9201. if err == gorm.ErrRecordNotFound {
  9202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9203. return
  9204. } else if err != nil {
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9206. return
  9207. } else {
  9208. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9209. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9210. infoStr := string(Iinfos)
  9211. idetinfoStr := string(Idetinfos)
  9212. psn := &models.HisPsn{
  9213. PsnNo: res.Output.Baseinfo.PsnNo,
  9214. PatientId: patient.ID,
  9215. Certno: res.Output.Baseinfo.Certno,
  9216. Gend: res.Output.Baseinfo.Gend,
  9217. Naty: res.Output.Baseinfo.Naty,
  9218. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9219. PsnName: res.Output.Baseinfo.PsnName,
  9220. Idetinfo: idetinfoStr,
  9221. Insuinfo: infoStr,
  9222. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9223. }
  9224. service.CreateHisPsn(psn)
  9225. c.ServeSuccessJSON(map[string]interface{}{
  9226. "patient": patient,
  9227. "number": res.Output.Baseinfo.Certno,
  9228. })
  9229. }
  9230. } else {
  9231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9232. return
  9233. }
  9234. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9235. var res ResultTwo
  9236. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9237. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9238. "&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)
  9239. resp, requestErr := http.Get(api)
  9240. if requestErr != nil {
  9241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9242. return
  9243. }
  9244. body, ioErr := ioutil.ReadAll(resp.Body)
  9245. if ioErr != nil {
  9246. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9248. return
  9249. }
  9250. var respJSON map[string]interface{}
  9251. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9252. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9254. return
  9255. }
  9256. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9257. result, _ := json.Marshal(respJSON)
  9258. fmt.Println("log")
  9259. fmt.Println(string(result))
  9260. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9261. utils.ErrorLog("解析失败:%v", err)
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9263. return
  9264. }
  9265. if res.Infcode == 0 {
  9266. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9267. if err == gorm.ErrRecordNotFound {
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9269. return
  9270. } else if err != nil {
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9272. return
  9273. } else {
  9274. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9275. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9276. infoStr := string(Iinfos)
  9277. idetinfoStr := string(Idetinfos)
  9278. var rf []*ResultFive
  9279. json.Unmarshal([]byte(infoStr), &rf)
  9280. var insutypes []*ResultFive
  9281. var insutype string
  9282. var is390 int = 0
  9283. var is310 int = 0
  9284. for _, item := range rf {
  9285. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9286. insutypes = append(insutypes, item)
  9287. }
  9288. }
  9289. if len(insutypes) == 1 {
  9290. insutype = insutypes[0].Insutype
  9291. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9292. } else {
  9293. for _, i := range insutypes {
  9294. if i.Insutype == "390" {
  9295. is390 = 1
  9296. }
  9297. if i.Insutype == "310" {
  9298. is310 = 1
  9299. }
  9300. }
  9301. }
  9302. if is390 == 1 {
  9303. insutype = "390"
  9304. }
  9305. if is310 == 1 {
  9306. insutype = "310"
  9307. }
  9308. if len(insutypes) == 0 {
  9309. insutype = "390"
  9310. }
  9311. var insuplc_admdvs string
  9312. for _, item := range rf {
  9313. if item.Insutype == insutype {
  9314. insuplc_admdvs = item.InsuplcAdmdvs
  9315. }
  9316. }
  9317. psn := &models.HisPsn{
  9318. PsnNo: res.Output.Baseinfo.PsnNo,
  9319. PatientId: patient.ID,
  9320. Certno: res.Output.Baseinfo.Certno,
  9321. Gend: res.Output.Baseinfo.Gend,
  9322. Naty: res.Output.Baseinfo.Naty,
  9323. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9324. PsnName: res.Output.Baseinfo.PsnName,
  9325. Idetinfo: idetinfoStr,
  9326. Insuinfo: infoStr,
  9327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9328. InsuplcAdmdvs: insuplc_admdvs,
  9329. }
  9330. service.CreateHisPsn(psn)
  9331. c.ServeSuccessJSON(map[string]interface{}{
  9332. "patient": patient,
  9333. "number": res.Output.Baseinfo.Certno,
  9334. })
  9335. }
  9336. } else {
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9338. return
  9339. }
  9340. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9341. res := c.GetoleInfo()
  9342. if res.Infcode == 0 {
  9343. var result string
  9344. if res.Output.MdtrtCertType == "01" {
  9345. 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)
  9346. } else if res.Output.MdtrtCertType == "02" {
  9347. 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)
  9348. } else if res.Output.MdtrtCertType == "03" {
  9349. 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)
  9350. }
  9351. var dat map[string]interface{}
  9352. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9353. fmt.Println(dat)
  9354. } else {
  9355. fmt.Println(err)
  9356. }
  9357. userJSONBytes, _ := json.Marshal(dat)
  9358. var res2 ResultTwo
  9359. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9360. utils.ErrorLog("解析失败:%v", err)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. if res2.Infcode == 0 {
  9365. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9366. if err == gorm.ErrRecordNotFound {
  9367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9368. return
  9369. } else if err != nil {
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9371. return
  9372. } else {
  9373. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9374. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9375. infoStr := string(Iinfos)
  9376. idetinfoStr := string(Idetinfos)
  9377. var rf []*ResultFive
  9378. json.Unmarshal([]byte(infoStr), &rf)
  9379. var insutypes []*ResultFive
  9380. var insutype string
  9381. var is390 int = 0
  9382. var is310 int = 0
  9383. //var insuplc_admdvs string
  9384. for _, item := range rf {
  9385. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9386. insutypes = append(insutypes, item)
  9387. }
  9388. }
  9389. if len(insutypes) == 1 {
  9390. insutype = insutypes[0].Insutype
  9391. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9392. } else {
  9393. for _, i := range insutypes {
  9394. if i.Insutype == "390" {
  9395. is390 = 1
  9396. }
  9397. if i.Insutype == "310" {
  9398. is310 = 1
  9399. }
  9400. }
  9401. }
  9402. if is390 == 1 {
  9403. insutype = "390"
  9404. }
  9405. if is310 == 1 {
  9406. insutype = "310"
  9407. }
  9408. if len(insutypes) == 0 {
  9409. insutype = "310"
  9410. }
  9411. psn := &models.HisPsn{
  9412. PsnNo: res2.Output.Baseinfo.PsnNo,
  9413. PatientId: patient.ID,
  9414. //Brdy: res2.Output.Baseinfo.Brdy,
  9415. Certno: res2.Output.Baseinfo.Certno,
  9416. Gend: res2.Output.Baseinfo.Gend,
  9417. Naty: res2.Output.Baseinfo.Naty,
  9418. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9419. PsnName: res2.Output.Baseinfo.PsnName,
  9420. Idetinfo: idetinfoStr,
  9421. Insuinfo: infoStr,
  9422. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9423. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9424. VerifyNumber: res.Output.EcToken,
  9425. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9426. }
  9427. service.CreateHisPsn(psn)
  9428. var balc float64
  9429. for _, item := range rf {
  9430. if item.Insutype == insutype {
  9431. balc = item.Balc
  9432. }
  9433. }
  9434. c.ServeSuccessJSON(map[string]interface{}{
  9435. "patient": patient,
  9436. "number": res.Output.CardNo,
  9437. "insutype": insutype,
  9438. "blac": balc,
  9439. "desc": idetinfoStr,
  9440. })
  9441. }
  9442. } else {
  9443. c.ServeSuccessJSON(map[string]interface{}{
  9444. "failed_code": -10,
  9445. "msg": res2.ErrMsg,
  9446. })
  9447. }
  9448. } else {
  9449. c.ServeSuccessJSON(map[string]interface{}{
  9450. "failed_code": -10,
  9451. "msg": res.ErrMsg,
  9452. })
  9453. }
  9454. } else {
  9455. SFZStr := c.GetSFZBaseInfo()
  9456. id_card_str := strings.Split(SFZStr, "^")
  9457. id_card_number := id_card_str[0]
  9458. card_sn := ""
  9459. 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)
  9460. var dat map[string]interface{}
  9461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9462. fmt.Println(dat)
  9463. } else {
  9464. fmt.Println(err)
  9465. }
  9466. userJSONBytes, _ := json.Marshal(dat)
  9467. var res ResultTwo
  9468. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9469. utils.ErrorLog("解析失败:%v", err)
  9470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9471. return
  9472. }
  9473. if res.Infcode == 0 {
  9474. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9475. if err == gorm.ErrRecordNotFound {
  9476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9477. return
  9478. } else if err != nil {
  9479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9480. return
  9481. } else {
  9482. c.ServeSuccessJSON(map[string]interface{}{
  9483. "patient": patient,
  9484. "number": id_card_number,
  9485. })
  9486. }
  9487. } else {
  9488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9489. return
  9490. }
  9491. }
  9492. break
  9493. case 3:
  9494. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9495. var api string
  9496. if miConfig.MdtrtareaAdmvs == "320921" {
  9497. 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 +
  9498. "&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
  9499. fmt.Println(api)
  9500. } else {
  9501. 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 +
  9502. "&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)
  9503. }
  9504. resp, requestErr := http.Get(api)
  9505. if requestErr != nil {
  9506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. return
  9508. }
  9509. body, ioErr := ioutil.ReadAll(resp.Body)
  9510. if ioErr != nil {
  9511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. return
  9514. }
  9515. var respJSON map[string]interface{}
  9516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. return
  9520. }
  9521. var status string
  9522. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9523. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9524. var token string
  9525. var res ResultTwo //1101结果
  9526. var res10265 ResultTwo10265 //1101结果
  9527. var card_info string //卡信息
  9528. var busi_card_info string
  9529. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9530. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9531. if status == "0" { //读卡成功
  9532. if card_type == "1" {
  9533. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9534. result, _ := json.Marshal(respJSON)
  9535. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9536. utils.ErrorLog("解析失败:%v", err)
  9537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9538. return
  9539. }
  9540. res.ErrMsg = res10265.ErrMsg
  9541. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9542. res.Infcode = infocode
  9543. res.Output = res10265.Output
  9544. res.InfRefmsgid = res10265.InfRefmsgid
  9545. } else {
  9546. //var card_info string //卡信息
  9547. //var busi_card_info string
  9548. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9549. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9550. //fmt.Println(card_info)
  9551. //fmt.Println(busi_card_info)
  9552. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9553. result, _ := json.Marshal(respJSON)
  9554. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. res.ErrMsg = res10265.ErrMsg
  9560. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9561. res.Infcode = infocode
  9562. res.Output = res10265.Output
  9563. res.InfRefmsgid = res10265.InfRefmsgid
  9564. }
  9565. if res.Infcode == 0 {
  9566. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9567. if err == gorm.ErrRecordNotFound {
  9568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9569. return
  9570. } else if err != nil {
  9571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9572. return
  9573. } else {
  9574. if card_type == "1" {
  9575. bas := strings.Split(card_info, "|")
  9576. basNumber := bas[2]
  9577. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9578. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9579. infoStr := string(Iinfos)
  9580. idetinfoStr := string(Idetinfos)
  9581. psn := &models.HisPsn{
  9582. PsnNo: res.Output.Baseinfo.PsnNo,
  9583. PatientId: patient.ID,
  9584. Certno: res.Output.Baseinfo.Certno,
  9585. //Brdy: res.Output.Baseinfo.Brdy,
  9586. Gend: res.Output.Baseinfo.Gend,
  9587. Naty: res.Output.Baseinfo.Naty,
  9588. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9589. PsnName: res.Output.Baseinfo.PsnName,
  9590. Idetinfo: idetinfoStr,
  9591. Insuinfo: infoStr,
  9592. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9593. CardInfo: card_info,
  9594. VerifyNumber: busi_card_info,
  9595. }
  9596. service.CreateHisPsn(psn)
  9597. c.ServeSuccessJSON(map[string]interface{}{
  9598. "patient": patient,
  9599. "number": basNumber,
  9600. })
  9601. } else {
  9602. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9603. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9604. infoStr := string(Iinfos)
  9605. idetinfoStr := string(Idetinfos)
  9606. psn := &models.HisPsn{
  9607. PsnNo: res.Output.Baseinfo.PsnNo,
  9608. PatientId: patient.ID,
  9609. Certno: res.Output.Baseinfo.Certno,
  9610. Gend: res.Output.Baseinfo.Gend,
  9611. Naty: res.Output.Baseinfo.Naty,
  9612. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9613. PsnName: res.Output.Baseinfo.PsnName,
  9614. Idetinfo: idetinfoStr,
  9615. Insuinfo: infoStr,
  9616. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9617. CardInfo: card_info,
  9618. VerifyNumber: token,
  9619. }
  9620. service.CreateHisPsn(psn)
  9621. var rf []*ResultFive
  9622. json.Unmarshal([]byte(infoStr), &rf)
  9623. var insutypes []*ResultFive
  9624. var insutype string
  9625. var is390 int = 0
  9626. var is310 int = 0
  9627. for _, item := range rf {
  9628. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9629. insutypes = append(insutypes, item)
  9630. }
  9631. }
  9632. if len(insutypes) == 1 {
  9633. insutype = insutypes[0].Insutype
  9634. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9635. } else {
  9636. for _, i := range insutypes {
  9637. if i.Insutype == "390" {
  9638. is390 = 1
  9639. }
  9640. if i.Insutype == "310" {
  9641. is310 = 1
  9642. }
  9643. }
  9644. }
  9645. if is390 == 1 {
  9646. insutype = "390"
  9647. }
  9648. if is310 == 1 {
  9649. insutype = "310"
  9650. }
  9651. if len(insutypes) == 0 {
  9652. insutype = "310"
  9653. }
  9654. c.ServeSuccessJSON(map[string]interface{}{
  9655. "patient": patient,
  9656. "number": token,
  9657. "insutype": insutype,
  9658. })
  9659. }
  9660. }
  9661. } else {
  9662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9663. return
  9664. }
  9665. } else { //读卡失败
  9666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9667. return
  9668. }
  9669. }
  9670. break
  9671. case 4:
  9672. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9673. var api string
  9674. if miConfig.MdtrtareaAdmvs == "320921" {
  9675. 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 +
  9676. "&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
  9677. fmt.Println(api)
  9678. } else {
  9679. 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 +
  9680. "&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)
  9681. }
  9682. resp, requestErr := http.Get(api)
  9683. if requestErr != nil {
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. return
  9686. }
  9687. body, ioErr := ioutil.ReadAll(resp.Body)
  9688. if ioErr != nil {
  9689. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9691. return
  9692. }
  9693. var respJSON map[string]interface{}
  9694. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9697. return
  9698. }
  9699. var status string
  9700. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9701. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9702. var token string
  9703. var res ResultTwo //1101结果
  9704. var res10265 ResultTwo10265 //1101结果
  9705. if status == "0" { //读卡成功
  9706. var card_info string //卡信息
  9707. var busi_card_info string
  9708. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9709. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9710. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9711. fmt.Println(card_info)
  9712. fmt.Println(busi_card_info)
  9713. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9714. result, _ := json.Marshal(respJSON)
  9715. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9716. utils.ErrorLog("解析失败:%v", err)
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9718. return
  9719. }
  9720. res.ErrMsg = res10265.ErrMsg
  9721. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9722. res.Infcode = infocode
  9723. res.Output = res10265.Output
  9724. res.InfRefmsgid = res10265.InfRefmsgid
  9725. if res.Infcode == 0 {
  9726. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9727. if err == gorm.ErrRecordNotFound {
  9728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9729. return
  9730. } else if err != nil {
  9731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9732. return
  9733. } else {
  9734. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9735. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9736. infoStr := string(Iinfos)
  9737. idetinfoStr := string(Idetinfos)
  9738. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9739. psn := &models.HisPsn{
  9740. PsnNo: res.Output.Baseinfo.PsnNo,
  9741. PatientId: patient.ID,
  9742. Certno: res.Output.Baseinfo.Certno,
  9743. Brdy: b,
  9744. Age: float64(age),
  9745. //Brdy: res.Output.Baseinfo.Brdy,
  9746. Gend: res.Output.Baseinfo.Gend,
  9747. Naty: res.Output.Baseinfo.Naty,
  9748. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9749. PsnName: res.Output.Baseinfo.PsnName,
  9750. Idetinfo: idetinfoStr,
  9751. Insuinfo: infoStr,
  9752. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9753. CardInfo: card_info,
  9754. VerifyNumber: token,
  9755. }
  9756. var rf []*ResultFive
  9757. json.Unmarshal([]byte(infoStr), &rf)
  9758. var insutypes []*ResultFive
  9759. var insutype string
  9760. var is390 int = 0
  9761. var is310 int = 0
  9762. for _, item := range rf {
  9763. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9764. insutypes = append(insutypes, item)
  9765. }
  9766. }
  9767. if len(insutypes) == 1 {
  9768. insutype = insutypes[0].Insutype
  9769. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9770. } else {
  9771. for _, i := range insutypes {
  9772. if i.Insutype == "390" {
  9773. is390 = 1
  9774. }
  9775. if i.Insutype == "310" {
  9776. is310 = 1
  9777. }
  9778. }
  9779. }
  9780. if is390 == 1 {
  9781. insutype = "390"
  9782. }
  9783. if is310 == 1 {
  9784. insutype = "310"
  9785. }
  9786. if len(insutypes) == 0 {
  9787. insutype = "310"
  9788. }
  9789. service.CreateHisPsn(psn)
  9790. c.ServeSuccessJSON(map[string]interface{}{
  9791. "patient": patient,
  9792. "number": token,
  9793. "insutype": insutype,
  9794. })
  9795. }
  9796. } else {
  9797. c.ServeSuccessJSON(map[string]interface{}{
  9798. "failed_code": -10,
  9799. "msg": res.ErrMsg,
  9800. })
  9801. }
  9802. } else { //读卡失败
  9803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9804. return
  9805. }
  9806. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9807. var api string
  9808. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9809. "&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
  9810. resp, requestErr := http.Get(api)
  9811. if requestErr != nil {
  9812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9813. return
  9814. }
  9815. body, ioErr := ioutil.ReadAll(resp.Body)
  9816. if ioErr != nil {
  9817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9819. return
  9820. }
  9821. var respJSON map[string]interface{}
  9822. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9825. return
  9826. }
  9827. var status string
  9828. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9829. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9830. var token string
  9831. var res ResultTwo //1101结果
  9832. if status == "1" { //读卡成功
  9833. var card_info string //卡信息
  9834. var busi_card_info string
  9835. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9836. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9837. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9838. fmt.Println(card_info)
  9839. fmt.Println(busi_card_info)
  9840. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9841. result, _ := json.Marshal(respJSON)
  9842. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9843. utils.ErrorLog("解析失败:%v", err)
  9844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9845. return
  9846. }
  9847. if res.Infcode == 0 {
  9848. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9849. if err == gorm.ErrRecordNotFound {
  9850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9851. return
  9852. } else if err != nil {
  9853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9854. return
  9855. } else {
  9856. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9857. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9858. infoStr := string(Iinfos)
  9859. idetinfoStr := string(Idetinfos)
  9860. psn := &models.HisPsn{
  9861. PsnNo: res.Output.Baseinfo.PsnNo,
  9862. PatientId: patient.ID,
  9863. Certno: res.Output.Baseinfo.Certno,
  9864. Gend: res.Output.Baseinfo.Gend,
  9865. Naty: res.Output.Baseinfo.Naty,
  9866. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9867. PsnName: res.Output.Baseinfo.PsnName,
  9868. Idetinfo: idetinfoStr,
  9869. Insuinfo: infoStr,
  9870. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9871. CardInfo: card_info,
  9872. VerifyNumber: token,
  9873. }
  9874. var rf []*ResultFive
  9875. json.Unmarshal([]byte(infoStr), &rf)
  9876. var insutypes []*ResultFive
  9877. var insutype string
  9878. var is390 int = 0
  9879. var is310 int = 0
  9880. for _, item := range rf {
  9881. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9882. insutypes = append(insutypes, item)
  9883. }
  9884. }
  9885. if len(insutypes) == 1 {
  9886. insutype = insutypes[0].Insutype
  9887. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9888. } else {
  9889. for _, i := range insutypes {
  9890. if i.Insutype == "390" {
  9891. is390 = 1
  9892. }
  9893. if i.Insutype == "310" {
  9894. is310 = 1
  9895. }
  9896. }
  9897. }
  9898. if is390 == 1 {
  9899. insutype = "390"
  9900. }
  9901. if is310 == 1 {
  9902. insutype = "310"
  9903. }
  9904. if len(insutypes) == 0 {
  9905. insutype = "310"
  9906. }
  9907. service.CreateHisPsn(psn)
  9908. c.ServeSuccessJSON(map[string]interface{}{
  9909. "patient": patient,
  9910. "number": token,
  9911. "insutype": insutype,
  9912. })
  9913. }
  9914. } else {
  9915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9916. return
  9917. }
  9918. } else { //读卡失败
  9919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9920. return
  9921. }
  9922. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9923. idNo := c.GetString("idNo")
  9924. userName := c.GetString("userName")
  9925. ecToken := c.GetString("ecToken")
  9926. insuOrg := c.GetString("insuOrg")
  9927. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9928. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9929. var res ResultTwo
  9930. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9931. utils.ErrorLog("解析失败:%v", err)
  9932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9933. return
  9934. }
  9935. if res.Infcode == 0 {
  9936. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9937. if err == gorm.ErrRecordNotFound {
  9938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9939. return
  9940. } else if err != nil {
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9942. return
  9943. } else {
  9944. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9945. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9946. infoStr := string(Iinfos)
  9947. idetinfoStr := string(Idetinfos)
  9948. psn := &models.HisPsn{
  9949. PsnNo: res.Output.Baseinfo.PsnNo,
  9950. PatientId: patient.ID,
  9951. Certno: res.Output.Baseinfo.Certno,
  9952. Gend: res.Output.Baseinfo.Gend,
  9953. Naty: res.Output.Baseinfo.Naty,
  9954. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9955. PsnName: res.Output.Baseinfo.PsnName,
  9956. Idetinfo: idetinfoStr,
  9957. Insuinfo: infoStr,
  9958. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9959. CardInfo: "",
  9960. Stage: "1",
  9961. VerifyNumber: ecToken,
  9962. InsuplcAdmdvs: insuOrg,
  9963. }
  9964. service.CreateHisPsn(psn)
  9965. var rf []*ResultFive
  9966. json.Unmarshal([]byte(infoStr), &rf)
  9967. var insutypes []*ResultFive
  9968. var insutype string
  9969. var is390 int = 0
  9970. var is310 int = 0
  9971. for _, item := range rf {
  9972. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9973. insutypes = append(insutypes, item)
  9974. }
  9975. }
  9976. if len(insutypes) == 1 {
  9977. insutype = insutypes[0].Insutype
  9978. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9979. } else {
  9980. for _, i := range insutypes {
  9981. if i.Insutype == "390" {
  9982. is390 = 1
  9983. }
  9984. if i.Insutype == "310" {
  9985. is310 = 1
  9986. }
  9987. }
  9988. }
  9989. if is390 == 1 {
  9990. insutype = "390"
  9991. }
  9992. if is310 == 1 {
  9993. insutype = "310"
  9994. }
  9995. if len(insutypes) == 0 {
  9996. insutype = "310"
  9997. }
  9998. c.ServeSuccessJSON(map[string]interface{}{
  9999. "patient": patient,
  10000. "number": ecToken,
  10001. "insutype": insutype,
  10002. })
  10003. }
  10004. } else {
  10005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10006. return
  10007. }
  10008. } else if miConfig.MdtrtareaAdmvs == "360302" {
  10009. //if initFlag == 0 {
  10010. //c.TestGetJiangXiBasBaseInit()
  10011. //}
  10012. //if initEleFlag == 0 {
  10013. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10014. //}
  10015. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  10016. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  10017. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10018. type ELeData struct {
  10019. Data struct {
  10020. IdNo string `json:"idNo"`
  10021. IdType string `json:"idType"`
  10022. UserName string `json:"userName"`
  10023. EcToken string `json:"ecToken"`
  10024. InsuOrg string `json:"insuOrg"`
  10025. Gender string `json:"gender"`
  10026. Birthday string `json:"birthday"`
  10027. Nationality string `json:"nationality"`
  10028. Email string `json:"email"`
  10029. Extra string `json:"extra"`
  10030. } `json:"data"`
  10031. Code int `json:"code"`
  10032. Message string `json:"message"`
  10033. }
  10034. var ele ELeData
  10035. err := json.Unmarshal([]byte(result), &ele)
  10036. if err != nil {
  10037. utils.ErrorLog("解析失败:%v", err)
  10038. }
  10039. token := ele.Data.EcToken
  10040. token = Remove0000(token)
  10041. 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)
  10042. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10043. var res ResultTwo
  10044. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10045. utils.ErrorLog("解析失败:%v", err)
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10047. return
  10048. }
  10049. if res.Infcode == 0 {
  10050. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10051. if err == gorm.ErrRecordNotFound {
  10052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10053. return
  10054. } else if err != nil {
  10055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10056. return
  10057. } else {
  10058. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10059. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10060. infoStr := string(Iinfos)
  10061. idetinfoStr := string(Idetinfos)
  10062. psn := &models.HisPsn{
  10063. PsnNo: res.Output.Baseinfo.PsnNo,
  10064. PatientId: patient.ID,
  10065. Certno: res.Output.Baseinfo.Certno,
  10066. Gend: res.Output.Baseinfo.Gend,
  10067. Naty: res.Output.Baseinfo.Naty,
  10068. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10069. PsnName: res.Output.Baseinfo.PsnName,
  10070. Idetinfo: idetinfoStr,
  10071. Insuinfo: infoStr,
  10072. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10073. CardInfo: "",
  10074. VerifyNumber: token,
  10075. }
  10076. service.CreateHisPsn(psn)
  10077. var rf []*ResultFive
  10078. json.Unmarshal([]byte(infoStr), &rf)
  10079. var insutypes []*ResultFive
  10080. var insutype string
  10081. var is390 int = 0
  10082. var is310 int = 0
  10083. for _, item := range rf {
  10084. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10085. insutypes = append(insutypes, item)
  10086. }
  10087. }
  10088. if len(insutypes) == 1 {
  10089. insutype = insutypes[0].Insutype
  10090. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10091. } else {
  10092. for _, i := range insutypes {
  10093. if i.Insutype == "390" {
  10094. is390 = 1
  10095. }
  10096. if i.Insutype == "310" {
  10097. is310 = 1
  10098. }
  10099. }
  10100. }
  10101. if is390 == 1 {
  10102. insutype = "390"
  10103. }
  10104. if is310 == 1 {
  10105. insutype = "310"
  10106. }
  10107. if len(insutypes) == 0 {
  10108. insutype = "310"
  10109. }
  10110. c.ServeSuccessJSON(map[string]interface{}{
  10111. "patient": patient,
  10112. "number": token,
  10113. "insutype": insutype,
  10114. })
  10115. }
  10116. } else {
  10117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10118. return
  10119. }
  10120. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10121. //if initFlag == 0 {
  10122. c.TestGetJiangXiBasBaseInit()
  10123. //}
  10124. //if initEleFlag == 0 {
  10125. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10126. //}
  10127. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10128. type ELeData struct {
  10129. Data struct {
  10130. IdNo string `json:"idNo"`
  10131. IdType string `json:"idType"`
  10132. UserName string `json:"userName"`
  10133. EcToken string `json:"ecToken"`
  10134. InsuOrg string `json:"insuOrg"`
  10135. Gender string `json:"gender"`
  10136. Birthday string `json:"birthday"`
  10137. Nationality string `json:"nationality"`
  10138. Email string `json:"email"`
  10139. Extra string `json:"extra"`
  10140. } `json:"data"`
  10141. Code int `json:"code"`
  10142. Message string `json:"message"`
  10143. }
  10144. var ele ELeData
  10145. err := json.Unmarshal([]byte(json_result), &ele)
  10146. if err != nil {
  10147. utils.ErrorLog("解析失败:%v", err)
  10148. }
  10149. token := ele.Data.EcToken
  10150. token = Remove0000(token)
  10151. 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)
  10152. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10153. var res ResultTwo
  10154. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10155. utils.ErrorLog("解析失败:%v", err)
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. if res.Infcode == 0 {
  10160. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10161. if err == gorm.ErrRecordNotFound {
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10163. return
  10164. } else if err != nil {
  10165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10166. return
  10167. } else {
  10168. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10169. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10170. infoStr := string(Iinfos)
  10171. idetinfoStr := string(Idetinfos)
  10172. psn := &models.HisPsn{
  10173. PsnNo: res.Output.Baseinfo.PsnNo,
  10174. PatientId: patient.ID,
  10175. Certno: res.Output.Baseinfo.Certno,
  10176. Gend: res.Output.Baseinfo.Gend,
  10177. Naty: res.Output.Baseinfo.Naty,
  10178. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10179. PsnName: res.Output.Baseinfo.PsnName,
  10180. Idetinfo: idetinfoStr,
  10181. Insuinfo: infoStr,
  10182. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10183. CardInfo: "",
  10184. VerifyNumber: token,
  10185. }
  10186. service.CreateHisPsn(psn)
  10187. var rf []*ResultFive
  10188. json.Unmarshal([]byte(infoStr), &rf)
  10189. var insutypes []*ResultFive
  10190. var insutype string
  10191. var is390 int = 0
  10192. var is310 int = 0
  10193. for _, item := range rf {
  10194. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10195. insutypes = append(insutypes, item)
  10196. }
  10197. }
  10198. if len(insutypes) == 1 {
  10199. insutype = insutypes[0].Insutype
  10200. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10201. } else {
  10202. for _, i := range insutypes {
  10203. if i.Insutype == "390" {
  10204. is390 = 1
  10205. }
  10206. if i.Insutype == "310" {
  10207. is310 = 1
  10208. }
  10209. }
  10210. }
  10211. if is390 == 1 {
  10212. insutype = "390"
  10213. }
  10214. if is310 == 1 {
  10215. insutype = "310"
  10216. }
  10217. if len(insutypes) == 0 {
  10218. insutype = "310"
  10219. }
  10220. c.ServeSuccessJSON(map[string]interface{}{
  10221. "patient": patient,
  10222. "number": token,
  10223. "insutype": insutype,
  10224. })
  10225. }
  10226. } else {
  10227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10228. return
  10229. }
  10230. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10231. type ELeData struct {
  10232. Code string `json:"code"`
  10233. Data struct {
  10234. Aac002 string `json:"aac002"`
  10235. Aaz500 string `json:"aaz500"`
  10236. ActCardNo string `json:"actCardNo"`
  10237. Bab520 string `json:"bab520"`
  10238. Bkz543 string `json:"bkz543"`
  10239. BusinessType string `json:"businessType"`
  10240. CertfCodg string `json:"certfCodg"`
  10241. EcIndexNo string `json:"ecIndexNo"`
  10242. EcToken string `json:"ecToken"`
  10243. ID0000 string `json:"id0000"`
  10244. IDNo string `json:"idNo"`
  10245. IDType string `json:"idType"`
  10246. Idcode string `json:"idcode"`
  10247. IdentityToken string `json:"identity_token"`
  10248. InsuOrg string `json:"insuOrg"`
  10249. OfficeID string `json:"officeId"`
  10250. OfficeName string `json:"officeName"`
  10251. OperatorID string `json:"operatorId"`
  10252. OperatorName string `json:"operatorName"`
  10253. OrgID string `json:"orgId"`
  10254. UserName string `json:"userName"`
  10255. } `json:"data"`
  10256. Infno interface{} `json:"infno"`
  10257. Message string `json:"message"`
  10258. OrgID string `json:"orgId"`
  10259. TransType string `json:"transType"`
  10260. }
  10261. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10262. outPutInfo = Remove0000(outPutInfo)
  10263. if len(outPutInfo) > 0 {
  10264. var ele ELeData
  10265. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10266. if err != nil {
  10267. utils.ErrorLog("解析失败:%v", err)
  10268. }
  10269. token := ele.Data.EcToken
  10270. fmt.Println(inputInfo)
  10271. fmt.Println(outPutInfo)
  10272. 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)
  10273. saveLog(result, requestLog, "1101", "获取人员信息")
  10274. var dat map[string]interface{}
  10275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10276. fmt.Println(dat)
  10277. } else {
  10278. fmt.Println(err)
  10279. }
  10280. userJSONBytes, _ := json.Marshal(dat)
  10281. var res ResultTwo
  10282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10283. utils.ErrorLog("解析失败:%v", err)
  10284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10285. return
  10286. }
  10287. res.ErrMsg = errMsgLog
  10288. if res.Infcode == 0 {
  10289. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10290. if err == gorm.ErrRecordNotFound {
  10291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10292. return
  10293. } else if err != nil {
  10294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10295. return
  10296. } else {
  10297. fmt.Println(res)
  10298. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10299. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10300. infoStr := string(Iinfos)
  10301. idetinfoStr := string(Idetinfos)
  10302. psn := &models.HisPsn{
  10303. PsnNo: res.Output.Baseinfo.PsnNo,
  10304. PatientId: patient.ID,
  10305. Certno: res.Output.Baseinfo.Certno,
  10306. Gend: res.Output.Baseinfo.Gend,
  10307. Naty: res.Output.Baseinfo.Naty,
  10308. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10309. PsnName: res.Output.Baseinfo.PsnName,
  10310. Idetinfo: idetinfoStr,
  10311. Insuinfo: infoStr,
  10312. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10313. CardInfo: outPutInfo,
  10314. VerifyNumber: token,
  10315. InsuplcAdmdvs: ele.Data.InsuOrg,
  10316. }
  10317. service.CreateHisPsn(psn)
  10318. var rf []*ResultFive
  10319. json.Unmarshal([]byte(infoStr), &rf)
  10320. var insutypes []*ResultFive
  10321. var insutype string
  10322. var is390 int = 0
  10323. var is310 int = 0
  10324. for _, item := range rf {
  10325. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10326. insutypes = append(insutypes, item)
  10327. }
  10328. }
  10329. if len(insutypes) == 1 {
  10330. insutype = insutypes[0].Insutype
  10331. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10332. } else {
  10333. for _, i := range insutypes {
  10334. if i.Insutype == "390" {
  10335. is390 = 1
  10336. }
  10337. if i.Insutype == "310" {
  10338. is310 = 1
  10339. }
  10340. }
  10341. }
  10342. if is390 == 1 {
  10343. insutype = "390"
  10344. }
  10345. if is310 == 1 {
  10346. insutype = "310"
  10347. }
  10348. if len(insutypes) == 0 {
  10349. insutype = "310"
  10350. }
  10351. c.ServeSuccessJSON(map[string]interface{}{
  10352. "patient": patient,
  10353. "number": token,
  10354. "insutype": insutype,
  10355. })
  10356. }
  10357. } else {
  10358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10359. return
  10360. }
  10361. }
  10362. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10363. var api string
  10364. 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 +
  10365. "&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
  10366. resp, requestErr := http.Get(api)
  10367. if requestErr != nil {
  10368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10369. return
  10370. }
  10371. body, ioErr := ioutil.ReadAll(resp.Body)
  10372. if ioErr != nil {
  10373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10375. return
  10376. }
  10377. var respJSON map[string]interface{}
  10378. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10381. return
  10382. }
  10383. var status string
  10384. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10385. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10386. var token string
  10387. var res ResultTwo //1101结果
  10388. var res10265 ResultTwo10265 //1101结果
  10389. if status == "0" { //读卡成功
  10390. var card_info string //卡信息
  10391. var busi_card_info string
  10392. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10393. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10394. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10395. fmt.Println(card_info)
  10396. fmt.Println(busi_card_info)
  10397. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10398. result, _ := json.Marshal(respJSON)
  10399. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10400. utils.ErrorLog("解析失败:%v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. res.ErrMsg = res10265.ErrMsg
  10405. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10406. res.Infcode = infocode
  10407. res.Output = res10265.Output
  10408. res.InfRefmsgid = res10265.InfRefmsgid
  10409. if res.Infcode == 0 {
  10410. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10411. if err == gorm.ErrRecordNotFound {
  10412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10413. return
  10414. } else if err != nil {
  10415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10416. return
  10417. } else {
  10418. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10419. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10420. infoStr := string(Iinfos)
  10421. idetinfoStr := string(Idetinfos)
  10422. psn := &models.HisPsn{
  10423. PsnNo: res.Output.Baseinfo.PsnNo,
  10424. PatientId: patient.ID,
  10425. Certno: res.Output.Baseinfo.Certno,
  10426. Gend: res.Output.Baseinfo.Gend,
  10427. Naty: res.Output.Baseinfo.Naty,
  10428. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10429. PsnName: res.Output.Baseinfo.PsnName,
  10430. Idetinfo: idetinfoStr,
  10431. Insuinfo: infoStr,
  10432. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10433. CardInfo: card_info,
  10434. VerifyNumber: token,
  10435. }
  10436. var rf []*ResultFive
  10437. json.Unmarshal([]byte(infoStr), &rf)
  10438. var insutypes []*ResultFive
  10439. var insutype string
  10440. var is390 int = 0
  10441. var is310 int = 0
  10442. for _, item := range rf {
  10443. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10444. insutypes = append(insutypes, item)
  10445. }
  10446. }
  10447. if len(insutypes) == 1 {
  10448. insutype = insutypes[0].Insutype
  10449. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10450. } else {
  10451. for _, i := range insutypes {
  10452. if i.Insutype == "390" {
  10453. is390 = 1
  10454. }
  10455. if i.Insutype == "310" {
  10456. is310 = 1
  10457. }
  10458. }
  10459. }
  10460. if is390 == 1 {
  10461. insutype = "390"
  10462. }
  10463. if is310 == 1 {
  10464. insutype = "310"
  10465. }
  10466. if len(insutypes) == 0 {
  10467. insutype = "310"
  10468. }
  10469. service.CreateHisPsn(psn)
  10470. c.ServeSuccessJSON(map[string]interface{}{
  10471. "patient": patient,
  10472. "number": token,
  10473. "insutype": insutype,
  10474. })
  10475. }
  10476. } else {
  10477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10478. return
  10479. }
  10480. } else { //读卡失败
  10481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10482. return
  10483. }
  10484. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10485. res := c.GetoleInfo()
  10486. if res.Infcode == 0 {
  10487. var result string
  10488. if res.Output.MdtrtCertType == "01" {
  10489. 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)
  10490. } else if res.Output.MdtrtCertType == "02" {
  10491. 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)
  10492. } else if res.Output.MdtrtCertType == "03" {
  10493. 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)
  10494. }
  10495. var dat map[string]interface{}
  10496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10497. fmt.Println(dat)
  10498. } else {
  10499. fmt.Println(err)
  10500. }
  10501. userJSONBytes, _ := json.Marshal(dat)
  10502. var res2 ResultTwo
  10503. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10504. utils.ErrorLog("解析失败:%v", err)
  10505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10506. return
  10507. }
  10508. if res2.Infcode == 0 {
  10509. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10510. if err == gorm.ErrRecordNotFound {
  10511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10512. return
  10513. } else if err != nil {
  10514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10515. return
  10516. } else {
  10517. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10518. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10519. infoStr := string(Iinfos)
  10520. idetinfoStr := string(Idetinfos)
  10521. var rf []*ResultFive
  10522. json.Unmarshal([]byte(infoStr), &rf)
  10523. var insutypes []*ResultFive
  10524. var insutype string
  10525. var is390 int = 0
  10526. var is310 int = 0
  10527. //var insuplc_admdvs string
  10528. for _, item := range rf {
  10529. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10530. insutypes = append(insutypes, item)
  10531. }
  10532. }
  10533. if len(insutypes) == 1 {
  10534. insutype = insutypes[0].Insutype
  10535. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10536. } else {
  10537. for _, i := range insutypes {
  10538. if i.Insutype == "390" {
  10539. is390 = 1
  10540. }
  10541. if i.Insutype == "310" {
  10542. is310 = 1
  10543. }
  10544. }
  10545. }
  10546. if is390 == 1 {
  10547. insutype = "390"
  10548. }
  10549. if is310 == 1 {
  10550. insutype = "310"
  10551. }
  10552. if len(insutypes) == 0 {
  10553. insutype = "310"
  10554. }
  10555. psn := &models.HisPsn{
  10556. PsnNo: res2.Output.Baseinfo.PsnNo,
  10557. PatientId: patient.ID,
  10558. Certno: res2.Output.Baseinfo.Certno,
  10559. Gend: res2.Output.Baseinfo.Gend,
  10560. Naty: res2.Output.Baseinfo.Naty,
  10561. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10562. PsnName: res2.Output.Baseinfo.PsnName,
  10563. Idetinfo: idetinfoStr,
  10564. Insuinfo: infoStr,
  10565. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10566. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10567. VerifyNumber: res.Output.EcToken,
  10568. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10569. }
  10570. if res.Output.MdtrtCertType == "01" {
  10571. psn.VerifyNumber = res.Output.EcToken
  10572. //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)
  10573. } else if res.Output.MdtrtCertType == "02" {
  10574. psn.VerifyNumber = res.Output.CardNo
  10575. //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)
  10576. } else if res.Output.MdtrtCertType == "03" {
  10577. psn.VerifyNumber = res.Output.MdtrtCertNo
  10578. //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)
  10579. }
  10580. service.CreateHisPsn(psn)
  10581. var balc float64
  10582. for _, item := range rf {
  10583. if item.Insutype == insutype {
  10584. balc = item.Balc
  10585. }
  10586. }
  10587. c.ServeSuccessJSON(map[string]interface{}{
  10588. "patient": patient,
  10589. "number": res.Output.CardNo,
  10590. "insutype": insutype,
  10591. "blac": balc,
  10592. "desc": idetinfoStr,
  10593. })
  10594. }
  10595. } else {
  10596. c.ServeSuccessJSON(map[string]interface{}{
  10597. "failed_code": -10,
  10598. "msg": res2.ErrMsg,
  10599. })
  10600. }
  10601. } else {
  10602. c.ServeSuccessJSON(map[string]interface{}{
  10603. "failed_code": -10,
  10604. "msg": res.ErrMsg,
  10605. })
  10606. }
  10607. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10608. var res ResultTwo
  10609. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10610. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10611. "&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)
  10612. resp, requestErr := http.Get(api)
  10613. if requestErr != nil {
  10614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10615. return
  10616. }
  10617. body, ioErr := ioutil.ReadAll(resp.Body)
  10618. if ioErr != nil {
  10619. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10621. return
  10622. }
  10623. var respJSON map[string]interface{}
  10624. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10627. return
  10628. }
  10629. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10630. result, _ := json.Marshal(respJSON)
  10631. fmt.Println("log")
  10632. fmt.Println(string(result))
  10633. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10634. utils.ErrorLog("解析失败:%v", err)
  10635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10636. return
  10637. }
  10638. if res.Infcode == 0 {
  10639. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10640. if err == gorm.ErrRecordNotFound {
  10641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10642. return
  10643. } else if err != nil {
  10644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10645. return
  10646. } else {
  10647. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10648. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10649. infoStr := string(Iinfos)
  10650. idetinfoStr := string(Idetinfos)
  10651. var rf []*ResultFive
  10652. json.Unmarshal([]byte(infoStr), &rf)
  10653. var insutypes []*ResultFive
  10654. var insutype string
  10655. var is390 int = 0
  10656. var is310 int = 0
  10657. for _, item := range rf {
  10658. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10659. insutypes = append(insutypes, item)
  10660. }
  10661. }
  10662. if len(insutypes) == 1 {
  10663. insutype = insutypes[0].Insutype
  10664. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10665. } else {
  10666. for _, i := range insutypes {
  10667. if i.Insutype == "390" {
  10668. is390 = 1
  10669. }
  10670. if i.Insutype == "310" {
  10671. is310 = 1
  10672. }
  10673. }
  10674. }
  10675. if is390 == 1 {
  10676. insutype = "390"
  10677. }
  10678. if is310 == 1 {
  10679. insutype = "310"
  10680. }
  10681. if len(insutypes) == 0 {
  10682. insutype = "390"
  10683. }
  10684. var insuplc_admdvs string
  10685. for _, item := range rf {
  10686. if item.Insutype == insutype {
  10687. insuplc_admdvs = item.InsuplcAdmdvs
  10688. }
  10689. }
  10690. psn := &models.HisPsn{
  10691. PsnNo: res.Output.Baseinfo.PsnNo,
  10692. PatientId: patient.ID,
  10693. Certno: res.Output.Baseinfo.Certno,
  10694. Gend: res.Output.Baseinfo.Gend,
  10695. Naty: res.Output.Baseinfo.Naty,
  10696. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10697. PsnName: res.Output.Baseinfo.PsnName,
  10698. Idetinfo: idetinfoStr,
  10699. Insuinfo: infoStr,
  10700. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10701. InsuplcAdmdvs: insuplc_admdvs,
  10702. }
  10703. service.CreateHisPsn(psn)
  10704. c.ServeSuccessJSON(map[string]interface{}{
  10705. "patient": patient,
  10706. "number": res.Output.Baseinfo.Certno,
  10707. })
  10708. }
  10709. } else {
  10710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10711. return
  10712. }
  10713. } else {
  10714. type ELeData struct {
  10715. Code string `json:"code"`
  10716. Data struct {
  10717. Aac002 string `json:"aac002"`
  10718. Aaz500 string `json:"aaz500"`
  10719. ActCardNo string `json:"actCardNo"`
  10720. Bab520 string `json:"bab520"`
  10721. Bkz543 string `json:"bkz543"`
  10722. BusinessType string `json:"businessType"`
  10723. CertfCodg string `json:"certfCodg"`
  10724. EcIndexNo string `json:"ecIndexNo"`
  10725. EcToken string `json:"ecToken"`
  10726. ID0000 string `json:"id0000"`
  10727. IDNo string `json:"idNo"`
  10728. IDType string `json:"idType"`
  10729. Idcode string `json:"idcode"`
  10730. IdentityToken string `json:"identity_token"`
  10731. InsuOrg string `json:"insuOrg"`
  10732. OfficeID string `json:"officeId"`
  10733. OfficeName string `json:"officeName"`
  10734. OperatorID string `json:"operatorId"`
  10735. OperatorName string `json:"operatorName"`
  10736. OrgID string `json:"orgId"`
  10737. UserName string `json:"userName"`
  10738. } `json:"data"`
  10739. Infno interface{} `json:"infno"`
  10740. Message string `json:"message"`
  10741. OrgID string `json:"orgId"`
  10742. TransType string `json:"transType"`
  10743. }
  10744. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10745. fmt.Println(result)
  10746. outPutInfo := Remove0000(result)
  10747. fmt.Println(outPutInfo)
  10748. if len(outPutInfo) > 0 {
  10749. var ele ELeData
  10750. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10751. if err != nil {
  10752. utils.ErrorLog("解析失败:%v", err)
  10753. }
  10754. token := ele.Data.EcToken
  10755. fmt.Println(outPutInfo)
  10756. 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)
  10757. saveLog(result, requestLog, "1101", "获取人员信息")
  10758. var dat map[string]interface{}
  10759. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10760. fmt.Println(dat)
  10761. } else {
  10762. fmt.Println(err)
  10763. }
  10764. userJSONBytes, _ := json.Marshal(dat)
  10765. var res ResultTwo
  10766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10767. utils.ErrorLog("解析失败:%v", err)
  10768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10769. return
  10770. }
  10771. if res.Infcode == 0 {
  10772. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10773. if err == gorm.ErrRecordNotFound {
  10774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10775. return
  10776. } else if err != nil {
  10777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10778. return
  10779. } else {
  10780. fmt.Println(res)
  10781. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10782. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10783. infoStr := string(Iinfos)
  10784. idetinfoStr := string(Idetinfos)
  10785. psn := &models.HisPsn{
  10786. PsnNo: res.Output.Baseinfo.PsnNo,
  10787. PatientId: patient.ID,
  10788. Certno: res.Output.Baseinfo.Certno,
  10789. Gend: res.Output.Baseinfo.Gend,
  10790. Naty: res.Output.Baseinfo.Naty,
  10791. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10792. PsnName: res.Output.Baseinfo.PsnName,
  10793. Idetinfo: idetinfoStr,
  10794. Insuinfo: infoStr,
  10795. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10796. CardInfo: outPutInfo,
  10797. VerifyNumber: token,
  10798. InsuplcAdmdvs: ele.Data.InsuOrg,
  10799. }
  10800. service.CreateHisPsn(psn)
  10801. var rf []*ResultFive
  10802. json.Unmarshal([]byte(infoStr), &rf)
  10803. var insutypes []*ResultFive
  10804. var insutype string
  10805. var is390 int = 0
  10806. var is310 int = 0
  10807. for _, item := range rf {
  10808. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10809. insutypes = append(insutypes, item)
  10810. }
  10811. }
  10812. if len(insutypes) == 1 {
  10813. insutype = insutypes[0].Insutype
  10814. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10815. } else {
  10816. for _, i := range insutypes {
  10817. if i.Insutype == "390" {
  10818. is390 = 1
  10819. }
  10820. if i.Insutype == "310" {
  10821. is310 = 1
  10822. }
  10823. }
  10824. }
  10825. if is390 == 1 {
  10826. insutype = "390"
  10827. }
  10828. if is310 == 1 {
  10829. insutype = "310"
  10830. }
  10831. if len(insutypes) == 0 {
  10832. insutype = "310"
  10833. }
  10834. c.ServeSuccessJSON(map[string]interface{}{
  10835. "patient": patient,
  10836. "number": token,
  10837. "insutype": insutype,
  10838. })
  10839. }
  10840. } else {
  10841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10842. return
  10843. }
  10844. }
  10845. //fmt.Println(result)
  10846. //
  10847. //if initFlag == 0 {
  10848. // c.TestGetBasBaseInit()
  10849. //}
  10850. //token := c.GetEleBaseInfo()
  10851. //
  10852. //token = Remove0000(token)
  10853. //
  10854. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10855. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10856. ////
  10857. //var res ResultTwo
  10858. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10859. // utils.ErrorLog("解析失败:%v", err)
  10860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10861. // return
  10862. //}
  10863. //
  10864. //if res.Infcode == 0 {
  10865. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10866. // if err == gorm.ErrRecordNotFound {
  10867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10868. // return
  10869. // } else if err != nil {
  10870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10871. // return
  10872. //
  10873. // } else {
  10874. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10875. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10876. // infoStr := string(Iinfos)
  10877. // idetinfoStr := string(Idetinfos)
  10878. //
  10879. //
  10880. //
  10881. //
  10882. // var rf []*ResultFive
  10883. // json.Unmarshal([]byte(infoStr), &rf)
  10884. //
  10885. // var insutypes []*ResultFive
  10886. // var insutype string
  10887. // var is390 int = 0
  10888. // var is310 int = 0
  10889. // var insuplc_admdvs string
  10890. //
  10891. // for _, item := range rf {
  10892. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10893. // insutypes = append(insutypes, item)
  10894. // }
  10895. // }
  10896. //
  10897. // if len(insutypes) == 1 {
  10898. // insutype = insutypes[0].Insutype
  10899. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10900. // } else {
  10901. // for _, i := range insutypes {
  10902. // if i.Insutype == "390" {
  10903. // is390 = 1
  10904. // }
  10905. //
  10906. // if i.Insutype == "310" {
  10907. // is310 = 1
  10908. // }
  10909. // }
  10910. // }
  10911. // if is390 == 1 {
  10912. // insutype = "390"
  10913. // }
  10914. //
  10915. // if is310 == 1 {
  10916. // insutype = "310"
  10917. // }
  10918. // if len(insutypes) == 0 {
  10919. // insutype = "310"
  10920. // }
  10921. // for _, item := range rf {
  10922. // if item.Insutype == insutype {
  10923. // insuplc_admdvs = item.InsuplcAdmdvs
  10924. // }
  10925. // }
  10926. // psn := &models.HisPsn{
  10927. // PsnNo: res.Output.Baseinfo.PsnNo,
  10928. // Age: res.Output.Baseinfo.Age,
  10929. // PatientId: patient.ID,
  10930. // Certno: res.Output.Baseinfo.Certno,
  10931. // Brdy: res.Output.Baseinfo.Brdy,
  10932. // Gend: res.Output.Baseinfo.Gend,
  10933. // Naty: res.Output.Baseinfo.Naty,
  10934. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10935. // PsnName: res.Output.Baseinfo.PsnName,
  10936. // Idetinfo: idetinfoStr,
  10937. // Insuinfo: infoStr,
  10938. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10939. // CardInfo: "",
  10940. // VerifyNumber: token,
  10941. // InsuplcAdmdvs: insuplc_admdvs,
  10942. // }
  10943. // service.CreateHisPsn(psn)
  10944. //
  10945. // c.ServeSuccessJSON(map[string]interface{}{
  10946. // "patient": patient,
  10947. // "number": token,
  10948. // })
  10949. // }
  10950. //} else {
  10951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10952. // return
  10953. //}
  10954. }
  10955. break
  10956. case 5:
  10957. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10958. var api string
  10959. if miConfig.MdtrtareaAdmvs == "320921" {
  10960. 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 +
  10961. "&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
  10962. fmt.Println(api)
  10963. } else {
  10964. 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 +
  10965. "&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)
  10966. }
  10967. resp, requestErr := http.Get(api)
  10968. if requestErr != nil {
  10969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10970. return
  10971. }
  10972. body, ioErr := ioutil.ReadAll(resp.Body)
  10973. if ioErr != nil {
  10974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10976. return
  10977. }
  10978. var respJSON map[string]interface{}
  10979. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10980. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10982. return
  10983. }
  10984. var status string
  10985. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10986. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10987. var token string
  10988. var res ResultTwo //1101结果
  10989. var res10265 ResultTwo10265 //1101结果
  10990. if status == "0" { //读卡成功
  10991. var card_info string //卡信息
  10992. //var busi_card_info string
  10993. var auth_info string
  10994. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10995. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10996. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10997. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10998. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10999. result, _ := json.Marshal(respJSON)
  11000. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11001. utils.ErrorLog("解析失败:%v", err)
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11003. return
  11004. }
  11005. res.ErrMsg = res10265.ErrMsg
  11006. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11007. res.Infcode = infocode
  11008. res.Output = res10265.Output
  11009. res.InfRefmsgid = res10265.InfRefmsgid
  11010. if res.Infcode == 0 {
  11011. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  11012. if err == gorm.ErrRecordNotFound {
  11013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11014. return
  11015. } else if err != nil {
  11016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11017. return
  11018. } else {
  11019. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11020. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11021. infoStr := string(Iinfos)
  11022. idetinfoStr := string(Idetinfos)
  11023. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  11024. psn := &models.HisPsn{
  11025. PsnNo: res.Output.Baseinfo.PsnNo,
  11026. PatientId: patient.ID,
  11027. Certno: res.Output.Baseinfo.Certno,
  11028. Gend: res.Output.Baseinfo.Gend,
  11029. Brdy: b,
  11030. Age: float64(age),
  11031. Naty: res.Output.Baseinfo.Naty,
  11032. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11033. PsnName: res.Output.Baseinfo.PsnName,
  11034. Idetinfo: idetinfoStr,
  11035. Insuinfo: infoStr,
  11036. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11037. CardInfo: card_info,
  11038. VerifyNumber: token,
  11039. AuthInfo: auth_info,
  11040. }
  11041. var rf []*ResultFive
  11042. json.Unmarshal([]byte(infoStr), &rf)
  11043. var insutypes []*ResultFive
  11044. var insutype string
  11045. var is390 int = 0
  11046. var is310 int = 0
  11047. for _, item := range rf {
  11048. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11049. insutypes = append(insutypes, item)
  11050. }
  11051. }
  11052. if len(insutypes) == 1 {
  11053. insutype = insutypes[0].Insutype
  11054. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  11055. } else {
  11056. for _, i := range insutypes {
  11057. if i.Insutype == "390" {
  11058. is390 = 1
  11059. }
  11060. if i.Insutype == "310" {
  11061. is310 = 1
  11062. }
  11063. }
  11064. }
  11065. if is390 == 1 {
  11066. insutype = "390"
  11067. }
  11068. if is310 == 1 {
  11069. insutype = "310"
  11070. }
  11071. if len(insutypes) == 0 {
  11072. insutype = "310"
  11073. }
  11074. service.CreateHisPsn(psn)
  11075. c.ServeSuccessJSON(map[string]interface{}{
  11076. "patient": patient,
  11077. "number": token,
  11078. "insutype": insutype,
  11079. })
  11080. }
  11081. } else {
  11082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11083. return
  11084. }
  11085. } else { //读卡失败
  11086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11087. return
  11088. }
  11089. }
  11090. break
  11091. }
  11092. }
  11093. var initFlag int64 = 0
  11094. var initEleFlag int64 = 0
  11095. func (c *HisApiController) TestGetBasBaseInit() {
  11096. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11097. Iinit := DllDef.MustFindProc("Init")
  11098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11099. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11100. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11101. if ret != 0 {
  11102. fmt.Println("SSCard的报错原因:", err)
  11103. fmt.Println("SSCard的运算结果为:", ret)
  11104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11105. return
  11106. }
  11107. result := int(ret)
  11108. fmt.Println("SSCard的运算结果为1:", result)
  11109. initFlag = 1
  11110. return
  11111. }
  11112. func (c *HisApiController) HandleJiangXiReadCard() {
  11113. fmt.Println("~~~~~~")
  11114. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11115. admin_user_id, _ := c.GetInt64("admin_user_id")
  11116. id_card_type, _ := c.GetInt64("id_card_type")
  11117. //certificates, _ := c.GetInt64("certificates")
  11118. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11119. if initFlag == 0 {
  11120. c.TestGetJiangXiBasBaseInit()
  11121. }
  11122. basStr := c.GetBasBaseInfo()
  11123. if len(basStr) == 0 {
  11124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11125. return
  11126. }
  11127. fmt.Println(basStr)
  11128. bas := strings.Split(basStr, "|")
  11129. basNumber := bas[1]
  11130. fmt.Println(basNumber)
  11131. card_sn := bas[3]
  11132. fmt.Println(card_sn)
  11133. 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, "")
  11134. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11135. var dat map[string]interface{}
  11136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11137. fmt.Println(dat)
  11138. } else {
  11139. fmt.Println(err)
  11140. }
  11141. userJSONBytes, _ := json.Marshal(dat)
  11142. var res ResultTwo
  11143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11144. utils.ErrorLog("解析失败:%v", err)
  11145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11146. return
  11147. }
  11148. if res.Infcode == 0 {
  11149. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11150. if err == gorm.ErrRecordNotFound {
  11151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11152. return
  11153. } else if err != nil {
  11154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11155. return
  11156. } else {
  11157. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11158. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11159. infoStr := string(Iinfos)
  11160. idetinfoStr := string(Idetinfos)
  11161. psn := &models.HisPsn{
  11162. PsnNo: res.Output.Baseinfo.PsnNo,
  11163. PatientId: patient.ID,
  11164. Certno: res.Output.Baseinfo.Certno,
  11165. Gend: res.Output.Baseinfo.Gend,
  11166. Naty: res.Output.Baseinfo.Naty,
  11167. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11168. PsnName: res.Output.Baseinfo.PsnName,
  11169. Idetinfo: idetinfoStr,
  11170. Insuinfo: infoStr,
  11171. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11172. CardInfo: basStr,
  11173. VerifyNumber: "",
  11174. }
  11175. service.CreateHisPsn(psn)
  11176. c.ServeSuccessJSON(map[string]interface{}{
  11177. "patient": patient,
  11178. "number": basNumber,
  11179. })
  11180. }
  11181. } else {
  11182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11183. return
  11184. }
  11185. }
  11186. func (c *HisApiController) TestGetHnBasBaseInit() {
  11187. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11188. Iinit := DllDef.MustFindProc("Init")
  11189. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11190. //http://10.77.211.236/CSB/hsa-fsi-1303
  11191. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11192. if ret != 0 {
  11193. fmt.Println("SSCard的报错原因:", err)
  11194. fmt.Println("SSCard的运算结果为:", ret)
  11195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11196. return
  11197. }
  11198. result := int(ret)
  11199. fmt.Println("SSCard的运算结果为1:", result)
  11200. initFlag = 1
  11201. return
  11202. }
  11203. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11204. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11205. Iinit := DllDef.MustFindProc("Init")
  11206. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11207. //http://10.77.211.236/CSB/hsa-fsi-1303
  11208. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11209. if ret != 0 {
  11210. fmt.Println("SSCard的报错原因:", err)
  11211. fmt.Println("SSCard的运算结果为:", ret)
  11212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11213. return
  11214. }
  11215. result := int(ret)
  11216. fmt.Println("SSCard的运算结果为1:", result)
  11217. initFlag = 1
  11218. return
  11219. }
  11220. func (c *HisApiController) GetSFZBaseInfo() string {
  11221. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11222. readCard := DllDef.MustFindProc("ReadSFZ")
  11223. if readCard == nil {
  11224. fmt.Println("readcard is nil")
  11225. readCard = DllDef.MustFindProc("ReadSFZ")
  11226. }
  11227. str := make([]byte, 8096)
  11228. str1 := make([]byte, 8096)
  11229. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11230. fmt.Println(r)
  11231. return Remove0000(string(str))
  11232. }
  11233. func (c *HisApiController) GetEleBaseInfo() string {
  11234. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11235. readCard := DllDef.MustFindProc("GetQRBase")
  11236. fmt.Println(readCard)
  11237. if readCard == nil {
  11238. fmt.Println("readcard is nil")
  11239. readCard = DllDef.MustFindProc("GetQRBase")
  11240. }
  11241. str := make([]byte, 1024)
  11242. str1 := make([]byte, 1024)
  11243. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11244. fmt.Println(ret2)
  11245. fmt.Println(string(str1))
  11246. fmt.Println(string(str))
  11247. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11248. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11249. if ret2 != 0 {
  11250. return ""
  11251. }
  11252. return string(str)
  11253. }
  11254. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11255. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11256. readCard := DllDef.MustFindProc("NationEcTrans")
  11257. fmt.Println(readCard)
  11258. fmt.Println("!!!!!")
  11259. pBusiCardInfo := make([]byte, 2048)
  11260. input := make(map[string]interface{})
  11261. inputData := make(map[string]interface{})
  11262. inputData["orgId"] = code
  11263. inputData["businessType"] = "01101"
  11264. inputData["operatorId"] = "1"
  11265. inputData["operatorName"] = "admin"
  11266. inputData["officeId"] = "001"
  11267. inputData["officeName"] = "血透室"
  11268. inputData["deviceType"] = ""
  11269. input["data"] = inputData
  11270. input["orgId"] = code
  11271. input["transType"] = "ec.query"
  11272. bytesData, _ := json.Marshal(input)
  11273. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11274. fmt.Println(ret2)
  11275. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11276. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11277. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11278. }
  11279. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11280. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11281. readCard := DllDef.MustFindProc("NationEcTrans")
  11282. fmt.Println(readCard)
  11283. fmt.Println("!!!!!")
  11284. pBusiCardInfo := make([]byte, 2048)
  11285. input := make(map[string]interface{})
  11286. inputData := make(map[string]interface{})
  11287. inputData["orgId"] = code
  11288. inputData["businessType"] = "01101"
  11289. inputData["operatorId"] = "9"
  11290. inputData["operatorName"] = "admin"
  11291. inputData["officeId"] = "001"
  11292. inputData["officeName"] = "血透室"
  11293. inputData["deviceType"] = ""
  11294. input["data"] = inputData
  11295. input["orgId"] = code
  11296. input["transType"] = "ec.query"
  11297. bytesData, _ := json.Marshal(input)
  11298. 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])))
  11299. fmt.Println(ret2)
  11300. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11301. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11302. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11303. }
  11304. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11305. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11306. readCard := DllDef.MustFindProc("NationEcTrans")
  11307. fmt.Println(readCard)
  11308. fmt.Println("!!!!!")
  11309. pBusiCardInfo := make([]byte, 2048)
  11310. input := make(map[string]interface{})
  11311. inputData := make(map[string]interface{})
  11312. inputData["orgId"] = code
  11313. inputData["businessType"] = "01301"
  11314. inputData["operatorId"] = "9"
  11315. inputData["operatorName"] = "admin"
  11316. inputData["officeId"] = "001"
  11317. inputData["officeName"] = "血透室"
  11318. inputData["deviceType"] = ""
  11319. input["data"] = inputData
  11320. input["orgId"] = code
  11321. input["transType"] = "ec.query"
  11322. bytesData, _ := json.Marshal(input)
  11323. 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])))
  11324. fmt.Println(ret2)
  11325. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11326. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11327. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11328. }
  11329. func GetJxEleBaseInfo(org_id int64) string {
  11330. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11331. readCard := DllDef.MustFindProc("NationEcTrans")
  11332. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11333. if readCard == nil {
  11334. fmt.Println("readcard is nil")
  11335. readCard = DllDef.MustFindProc("NationEcTrans")
  11336. }
  11337. str1 := make([]byte, 1024)
  11338. data := make(map[string]interface{})
  11339. inputData := make(map[string]interface{})
  11340. inputData["orgId"] = miConfig.Code
  11341. inputData["businessType"] = "01101"
  11342. inputData["operatorId"] = "test001"
  11343. inputData["operatorName"] = "cn"
  11344. inputData["officeId"] = "32760"
  11345. inputData["officeName"] = "waike"
  11346. inputData["deviceType"] = ""
  11347. data["data"] = inputData
  11348. data["transType"] = "ec.query"
  11349. data["extra "] = ""
  11350. data["orgId"] = miConfig.Code
  11351. bytesData, _ := json.Marshal(data)
  11352. //bytesData, _ := json.Marshal(data)
  11353. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11354. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11355. fmt.Println(ret2)
  11356. fmt.Println(string(str1))
  11357. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11358. if ret2 != 0 {
  11359. return ""
  11360. }
  11361. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11362. }
  11363. func GetJxEleBaseInitInfo(org_id int64) string {
  11364. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11365. readCard := DllDef.MustFindProc("NationEcTrans")
  11366. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11367. if readCard == nil {
  11368. fmt.Println("readcard is nil")
  11369. readCard = DllDef.MustFindProc("NationEcTrans")
  11370. }
  11371. str1 := make([]byte, 2048)
  11372. data := make(map[string]interface{})
  11373. inputData := make(map[string]interface{})
  11374. inputData["orgId"] = miConfig.Code
  11375. inputData["businessType"] = "01101"
  11376. inputData["operatorId"] = "1"
  11377. inputData["operatorName"] = "huangchuang"
  11378. inputData["officeId"] = "101"
  11379. inputData["officeName"] = "xuetou"
  11380. inputData["deviceType"] = ""
  11381. data["data"] = inputData
  11382. data["transType"] = "ec.query"
  11383. data["orgId"] = miConfig.Code
  11384. bytesData, _ := json.Marshal(data)
  11385. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11386. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11387. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11388. fmt.Println(ret2)
  11389. fmt.Println(string(str1))
  11390. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11391. if ret2 != 0 {
  11392. return ""
  11393. }
  11394. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11395. initEleFlag = 1
  11396. }
  11397. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11398. }
  11399. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11400. // // 构建命令
  11401. // cmd := exec.Command("python", "b.py")
  11402. //
  11403. // // 执行命令并等待完成
  11404. // output, err := cmd.CombinedOutput()
  11405. // if err != nil {
  11406. // fmt.Println("Error executing Python script:", err)
  11407. // return
  11408. // }
  11409. //
  11410. // // 打印Python脚本的输出
  11411. // fmt.Println(string(output))
  11412. //}
  11413. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11414. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11415. readCard := DllDef.MustFindProc("gxyb_call")
  11416. if readCard == nil {
  11417. fmt.Println("readcard is nil")
  11418. readCard = DllDef.MustFindProc("gxyb_call")
  11419. }
  11420. str := make([]byte, 1024)
  11421. str1 := make([]byte, 1024)
  11422. //data := make(map[string]interface{})
  11423. currentTime := time.Now()
  11424. // 格式化时间为 "YYYYMMDDHH24MISS"
  11425. formattedTime := currentTime.Format("20060102150405")
  11426. inputData := make(map[string]interface{})
  11427. inputData2 := make(map[string]interface{})
  11428. inputData["transNo"] = "1401"
  11429. inputData["transType"] = "passwordCheck"
  11430. inputData["timestamp"] = formattedTime
  11431. inputData2["fixmedinsCode"] = code
  11432. inputData2["psnNo"] = ""
  11433. inputData["data"] = inputData2
  11434. jsonBytes, err := json.Marshal(inputData)
  11435. if err != nil {
  11436. fmt.Println("Error encoding map to JSON:", err)
  11437. }
  11438. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11439. fmt.Println(string(str1))
  11440. fmt.Println(string(str))
  11441. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11442. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11443. if ret2 != 0 {
  11444. return ""
  11445. }
  11446. return string(str)
  11447. }
  11448. func (c *HisApiController) GetoleInfo() Response {
  11449. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11450. defer ole.CoUninitialize()
  11451. // Replace with the ProgID or CLSID of your COM object
  11452. progID := "YinHai.XJ.Actual.Interface.New"
  11453. // Create COM object
  11454. unknown, err := oleutil.CreateObject(progID)
  11455. if err != nil {
  11456. fmt.Println("Unable to create COM object:", err)
  11457. }
  11458. defer unknown.Release()
  11459. // Query for the IDispatch interface
  11460. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11461. if err != nil {
  11462. fmt.Println("Unable to get IDispatch interface:", err)
  11463. }
  11464. defer dispatch.Release()
  11465. // Prepare parameters
  11466. transNo := "1401"
  11467. transType := "passwordCheck"
  11468. timestamp := time.Now().Unix()
  11469. fixmedinsCode := "H45072101171"
  11470. psnNo := ""
  11471. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11472. result2 := ""
  11473. // Call COM object's method using the IDispatch interface
  11474. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11475. fmt.Println(resulr)
  11476. fmt.Println(result2)
  11477. if err != nil {
  11478. fmt.Println("调用COM对象方法失败:", err)
  11479. }
  11480. var response Response
  11481. err2 := json.Unmarshal([]byte(result2), &response)
  11482. if err2 != nil {
  11483. fmt.Println("解析JSON失败:", err)
  11484. }
  11485. return response
  11486. }
  11487. func (c *HisApiController) GetBasBaseInfo() string {
  11488. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11489. readCard := DllDef.MustFindProc("ReadCardBas")
  11490. if readCard == nil {
  11491. fmt.Println("readcard is nil")
  11492. readCard = DllDef.MustFindProc("ReadCardBas")
  11493. }
  11494. str := make([]byte, 1024)
  11495. str1 := make([]byte, 1024)
  11496. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11497. fmt.Println(string(str1))
  11498. fmt.Println(string(str))
  11499. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11500. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11501. if ret2 != 0 {
  11502. return ""
  11503. }
  11504. return string(str)
  11505. }
  11506. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11507. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11508. readCard := DllDef.MustFindProc("read_cardinfo")
  11509. if readCard == nil {
  11510. fmt.Println("readcard is nil")
  11511. readCard = DllDef.MustFindProc("read_cardinfo")
  11512. }
  11513. str := make([]byte, 1024) //卡号
  11514. str1 := make([]byte, 1024) //卡识别码
  11515. str2 := make([]byte, 1024) //身份证号
  11516. str3 := make([]byte, 1024) //姓名
  11517. str4 := make([]byte, 1024) //错误信息
  11518. 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])))
  11519. fmt.Println(string(str1))
  11520. fmt.Println(string(str))
  11521. fmt.Println(string(str2))
  11522. fmt.Println(string(str3))
  11523. fmt.Println(string(str4))
  11524. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11525. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11526. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11527. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11528. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11529. if ret2 != 0 {
  11530. return "", "", "", "", ""
  11531. }
  11532. return string(str), string(str1), string(str2), string(str3), string(str4)
  11533. }
  11534. type CustomFundPay struct {
  11535. FundPayType string `json:"fund_pay_type"`
  11536. FundPayamt float64 `json:"fund_payamt"`
  11537. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11538. }
  11539. //func (c *HisApiController) GetBatchSettleList() {
  11540. // start_time_str := c.GetString("start_time")
  11541. // //end_time_str := c.GetString("end_time")
  11542. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11543. //
  11544. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11545. //
  11546. // for _, item := range orders {
  11547. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11548. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11549. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11550. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11551. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11552. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11553. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11554. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11555. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11556. //
  11557. // if order.ID == 0 {
  11558. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11559. // return
  11560. // }
  11561. //
  11562. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11563. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11564. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11565. // //fmt.Println(count)
  11566. // //var zero string
  11567. // //number := count + 1
  11568. // //if number >= 1000 {
  11569. // // zero = "0000" + strconv.FormatInt(number, 10)
  11570. // //} else if number >= 10000 {
  11571. // // zero = "000" + strconv.FormatInt(number, 10)
  11572. // //} else if number >= 100000 {
  11573. // // zero = "00" + strconv.FormatInt(number, 10)
  11574. // //} else if number >= 1000000 {
  11575. // // zero = "0" + strconv.FormatInt(number, 10)
  11576. // //} else {
  11577. // // zero = strconv.FormatInt(number, 10)
  11578. // //}
  11579. // //fmt.Println(zero)
  11580. //
  11581. // struct4101 := service.Struct4101{
  11582. // PsnNo: order.PsnNo,
  11583. // MdtrtId: order.MdtrtId,
  11584. // SetlId: order.SetlId,
  11585. // PsnName: order.PsnName,
  11586. // Gend: order.Gend,
  11587. // Brdy: his.Brdy,
  11588. // Age: his.Age,
  11589. // Naty: order.Naty,
  11590. // PatnCertType: "01",
  11591. // Certno: order.Certno,
  11592. // Prfs: "90",
  11593. // ConerName: roles[0].UserName,
  11594. // PatnRlts: "99",
  11595. // ConerAddr: miConfig.OrgName,
  11596. // ConerTel: admin.Mobile,
  11597. // HiType: order.Insutype,
  11598. // Insuplc: miConfig.InsuplcAdmdvs,
  11599. // MaindiagFlag: "1",
  11600. // BillCode: order.SetlId,
  11601. // BillNo: order.SetlId,
  11602. // BizSn: order.Number,
  11603. // PsnSelfPay: order.PsnPartAmt,
  11604. // PsnOwnPay: order.PsnPartAmt,
  11605. // AcctPay: order.AcctPay,
  11606. // PsnCashpay: order.PsnCashPay,
  11607. // HiPaymtd: "1",
  11608. // Hsorg: miConfig.InsuplcAdmdvs,
  11609. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11610. // MedinsFillPsn: curRoles.UserName,
  11611. // MedinsFillDept: miConfig.OrgName,
  11612. // IptMedType: "2",
  11613. // }
  11614. // struct4101.SetlBegnDate = order.SetlTime
  11615. // struct4101.SetlEndDate = order.SetlTime
  11616. // time_arr := strings.Split(order.SetlTime, " ")
  11617. // struct4101.AdmTime = time_arr[0]
  11618. // struct4101.AdmEndTime = time_arr[0]
  11619. //
  11620. // var rf []CustomFundPay
  11621. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11622. //
  11623. // var tempFunPays []service.CustomStruct
  11624. // for _, item := range rf {
  11625. // var tempFunPay service.CustomStruct
  11626. // tempFunPay.FundPayamt = item.FundPayamt
  11627. // tempFunPay.FundPayType = item.FundPayType
  11628. // tempFunPays = append(tempFunPays, tempFunPay)
  11629. // }
  11630. // struct4101.CustomStruct = tempFunPays
  11631. //
  11632. // var tempDiaginfos []service.DiaginfoStructTwo
  11633. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11634. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11635. //
  11636. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11637. // var config []*models.HisXtDiagnoseConfig
  11638. // for _, item := range diagnosis_ids {
  11639. // id, _ := strconv.ParseInt(item, 10, 64)
  11640. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11641. // config = append(config, &diagnosisConfig)
  11642. // }
  11643. //
  11644. // for index, item := range config {
  11645. // if index == 0 {
  11646. // var tempDiaginfo service.DiaginfoStructTwo
  11647. // tempDiaginfo.DiagCode = item.CountryCode
  11648. // tempDiaginfo.DiagName = item.CountryContentName
  11649. // tempDiaginfo.DiagType = "1"
  11650. // tempDiaginfo.MaindiagFlag = "1"
  11651. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11652. // } else {
  11653. // var tempDiaginfo service.DiaginfoStructTwo
  11654. // tempDiaginfo.DiagCode = item.CountryCode
  11655. // tempDiaginfo.DiagName = item.CountryContentName
  11656. // tempDiaginfo.DiagType = "1"
  11657. // tempDiaginfo.MaindiagFlag = "0"
  11658. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11659. // }
  11660. // }
  11661. // struct4101.Diseinfo = tempDiaginfos
  11662. //
  11663. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11664. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11665. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11666. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11667. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11668. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11669. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11670. //
  11671. // var iteminfo service.IteminfoStruct
  11672. //
  11673. // var bedCostTotal float64 = 0 //床位总费
  11674. // var bedCostSelfTotal float64 = 0 //床位自费
  11675. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11676. //
  11677. // var operationCostTotal float64 = 0 //手术费
  11678. // var operationCostSelfTotal float64 = 0 //手术费
  11679. // var operationCostPartSelfTotal float64 = 0 //手术费
  11680. //
  11681. // var otherCostTotal float64 = 0 //其他费用
  11682. // var otherCostSelfTotal float64 = 0 //其他费用
  11683. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11684. //
  11685. // var materialCostTotal float64 = 0 //材料费
  11686. // var materialCostSelfTotal float64 = 0 //材料费
  11687. // var materialCostPartSelfTotal float64 = 0 //材料费
  11688. //
  11689. // var westernMedicineCostTotal float64 = 0 //西药费
  11690. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11691. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11692. //
  11693. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11694. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11695. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11696. //
  11697. // var checkCostTotal float64 = 0 //检查费
  11698. // var checkCostSelfTotal float64 = 0 //检查费
  11699. // var checkCostPartSelfTotal float64 = 0 //检查费
  11700. //
  11701. // var laboratoryCostTotal float64 = 0 //化验费
  11702. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11703. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11704. //
  11705. // var treatCostTotal float64 = 0 //治疗费用
  11706. // var treatCostSelfTotal float64 = 0 //治疗费用
  11707. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11708. //
  11709. // decimal.DivisionPrecision = 2
  11710. //
  11711. // var bed_fulamt_ownpay_amt float64 = 0
  11712. // var operation_fulamt_ownpay_amt float64 = 0
  11713. // var other_fulamt_ownpay_amt float64 = 0
  11714. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11715. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11716. // var check_fulamt_ownpay_amt float64 = 0
  11717. // var material_fulamt_ownpay_amt float64 = 0
  11718. // var laboratory_fulamt_ownpay_amt float64 = 0
  11719. // var treat_fulamt_ownpay_amt float64 = 0
  11720. //
  11721. // var bed_claa_sunmfee float64 = 0
  11722. // var bed_clab_amt float64 = 0
  11723. // var bed_other_amt float64 = 0
  11724. //
  11725. // var operation_claa_sunmfee float64 = 0
  11726. // var operation_clab_amt float64 = 0
  11727. // var operation_other_amt float64 = 0
  11728. //
  11729. // var other_claa_sunmfee float64 = 0
  11730. // var other_clab_amt float64 = 0
  11731. // var other_other_amt float64 = 0
  11732. //
  11733. // var westernMedicine_claa_sunmfee float64 = 0
  11734. // var westernMedicine_clab_amt float64 = 0
  11735. // var westernMedicine_other_amt float64 = 0
  11736. //
  11737. // var chineseTraditional_claa_sunmfee float64 = 0
  11738. // var chineseTraditional_clab_amt float64 = 0
  11739. // var chineseTraditional_other_amt float64 = 0
  11740. //
  11741. // var check_claa_sunmfee float64 = 0
  11742. // var check_clab_amt float64 = 0
  11743. // var check_other_amt float64 = 0
  11744. //
  11745. // var material_claa_sunmfee float64 = 0
  11746. // var material_clab_amt float64 = 0
  11747. // var material_other_amt float64 = 0
  11748. //
  11749. // var laboratory_claa_sunmfee float64 = 0
  11750. // var laboratory_clab_amt float64 = 0
  11751. // var laboratory_other_amt float64 = 0
  11752. //
  11753. // var treat_claa_sunmfee float64 = 0
  11754. // var treat_clab_amt float64 = 0
  11755. // var treat_other_amt float64 = 0
  11756. //
  11757. // for _, item := range order.HisOrderInfo {
  11758. // if item.MedChrgitmType == "01" { //床位费
  11759. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11760. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11761. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11762. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11763. // if item.ChrgitmLv == "1" {
  11764. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11765. // }
  11766. // if item.ChrgitmLv == "2" {
  11767. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11768. //
  11769. // }
  11770. // if item.ChrgitmLv == "3" {
  11771. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11772. // }
  11773. //
  11774. // }
  11775. //
  11776. // if item.MedChrgitmType == "03" { //检查费
  11777. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11778. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11779. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11780. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11781. // if item.ChrgitmLv == "1" {
  11782. //
  11783. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11784. //
  11785. // }
  11786. // if item.ChrgitmLv == "2" {
  11787. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11788. //
  11789. // }
  11790. // if item.ChrgitmLv == "3" {
  11791. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11792. // }
  11793. // }
  11794. //
  11795. // if item.MedChrgitmType == "04" { //化验费
  11796. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11797. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11798. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11799. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11800. // if item.ChrgitmLv == "1" {
  11801. //
  11802. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11803. //
  11804. // }
  11805. // if item.ChrgitmLv == "2" {
  11806. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11807. //
  11808. // }
  11809. // if item.ChrgitmLv == "3" {
  11810. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11811. // }
  11812. // }
  11813. //
  11814. // if item.MedChrgitmType == "05" { //治疗费
  11815. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11816. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11817. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11818. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11819. // if item.ChrgitmLv == "1" {
  11820. //
  11821. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11822. //
  11823. // }
  11824. // if item.ChrgitmLv == "2" {
  11825. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11826. //
  11827. // }
  11828. // if item.ChrgitmLv == "3" {
  11829. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11830. // }
  11831. // }
  11832. //
  11833. // if item.MedChrgitmType == "06" { //手术费
  11834. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11835. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11836. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11837. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11838. //
  11839. // if item.ChrgitmLv == "1" {
  11840. //
  11841. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11842. //
  11843. // }
  11844. // if item.ChrgitmLv == "2" {
  11845. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11846. //
  11847. // }
  11848. // if item.ChrgitmLv == "3" {
  11849. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11850. // }
  11851. // }
  11852. //
  11853. // if item.MedChrgitmType == "08" { //材料费
  11854. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11855. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11856. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11857. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11858. // if item.ChrgitmLv == "1" {
  11859. //
  11860. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11861. //
  11862. // }
  11863. // if item.ChrgitmLv == "2" {
  11864. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11865. //
  11866. // }
  11867. // if item.ChrgitmLv == "3" {
  11868. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11869. // }
  11870. // }
  11871. //
  11872. // if item.MedChrgitmType == "09" { //西药费
  11873. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11874. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11875. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11876. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11877. // if item.ChrgitmLv == "1" {
  11878. //
  11879. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11880. //
  11881. // }
  11882. // if item.ChrgitmLv == "2" {
  11883. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11884. //
  11885. // }
  11886. // if item.ChrgitmLv == "3" {
  11887. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11888. // }
  11889. // }
  11890. //
  11891. // if item.MedChrgitmType == "11" { //中成费
  11892. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11893. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11894. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11895. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11896. // if item.ChrgitmLv == "1" {
  11897. //
  11898. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11899. //
  11900. // }
  11901. // if item.ChrgitmLv == "2" {
  11902. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11903. //
  11904. // }
  11905. // if item.ChrgitmLv == "3" {
  11906. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11907. // }
  11908. // }
  11909. //
  11910. // if item.MedChrgitmType == "14" { //其他费
  11911. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11912. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11913. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11914. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11915. // if item.ChrgitmLv == "1" {
  11916. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11917. //
  11918. // }
  11919. // if item.ChrgitmLv == "2" {
  11920. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11921. //
  11922. // }
  11923. // if item.ChrgitmLv == "3" {
  11924. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11925. // }
  11926. // }
  11927. //
  11928. // }
  11929. //
  11930. // var iteminfoStructs []service.IteminfoStruct
  11931. //
  11932. // if bedCostTotal != 0 {
  11933. // iteminfo.MedChrgitm = "01"
  11934. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11935. // iteminfo.Amt = bedCostTotal
  11936. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11937. // iteminfo.ClabAmt = bed_clab_amt
  11938. // iteminfo.OthAmt = bed_other_amt
  11939. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11940. // }
  11941. //
  11942. // if checkCostTotal != 0 {
  11943. // iteminfo.MedChrgitm = "03"
  11944. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11945. // iteminfo.Amt = checkCostTotal
  11946. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11947. // iteminfo.ClabAmt = check_clab_amt
  11948. // iteminfo.OthAmt = check_other_amt
  11949. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11950. //
  11951. // }
  11952. //
  11953. // if laboratoryCostTotal != 0 {
  11954. // iteminfo.MedChrgitm = "04"
  11955. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11956. // iteminfo.Amt = laboratoryCostTotal
  11957. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11958. // iteminfo.ClabAmt = laboratory_clab_amt
  11959. // iteminfo.OthAmt = laboratory_other_amt
  11960. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11961. //
  11962. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11963. //
  11964. // }
  11965. //
  11966. // if treatCostTotal != 0 {
  11967. // iteminfo.MedChrgitm = "05"
  11968. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11969. // iteminfo.Amt = treatCostTotal
  11970. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11971. // iteminfo.ClabAmt = treat_clab_amt
  11972. // iteminfo.OthAmt = treat_other_amt
  11973. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11974. // //(struct4101.IteminfoStruct, iteminfo)
  11975. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11976. // }
  11977. //
  11978. // if operationCostTotal != 0 {
  11979. // iteminfo.MedChrgitm = "06"
  11980. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11981. // iteminfo.Amt = operationCostTotal
  11982. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11983. // iteminfo.ClabAmt = operation_clab_amt
  11984. // iteminfo.OthAmt = operation_other_amt
  11985. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11986. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11987. // }
  11988. //
  11989. // if materialCostTotal != 0 {
  11990. // iteminfo.MedChrgitm = "08"
  11991. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11992. // iteminfo.Amt = materialCostTotal
  11993. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11994. // iteminfo.ClabAmt = material_clab_amt
  11995. // iteminfo.OthAmt = material_other_amt
  11996. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11997. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11998. // }
  11999. //
  12000. // if westernMedicineCostTotal != 0 {
  12001. // iteminfo.MedChrgitm = "09"
  12002. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12003. // iteminfo.Amt = westernMedicineCostTotal
  12004. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12005. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12006. // iteminfo.OthAmt = westernMedicine_other_amt
  12007. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12008. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12009. //
  12010. // }
  12011. // if chineseTraditionalMedicineCostTotal != 0 {
  12012. // iteminfo.MedChrgitm = "11"
  12013. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12014. // iteminfo.Amt = westernMedicineCostTotal
  12015. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12016. // iteminfo.ClabAmt = westernMedicine_clab_amt
  12017. // iteminfo.OthAmt = westernMedicine_other_amt
  12018. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12019. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12020. //
  12021. // }
  12022. // if otherCostTotal != 0 {
  12023. // iteminfo.MedChrgitm = "14"
  12024. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12025. // iteminfo.Amt = otherCostTotal
  12026. // iteminfo.ClaaSumfee = other_claa_sunmfee
  12027. // iteminfo.ClabAmt = other_clab_amt
  12028. // iteminfo.OthAmt = other_other_amt
  12029. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12030. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  12031. //
  12032. // }
  12033. // struct4101.IteminfoStruct = iteminfoStructs
  12034. // struct4101.Ntly = "中国"
  12035. // struct4101.AdmCaty = "A03.06"
  12036. //
  12037. // struct4101.DoctorName = doctor.UserName
  12038. // struct4101.DoctorCode = doctor.DoctorNumber
  12039. //
  12040. // var res ResultSeventeen
  12041. //
  12042. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12043. // struct4101.BillCode = order.Number
  12044. // struct4101.BillNo = order.SetlId
  12045. // var resOther ResultSeventeenOther
  12046. // var pp models.PublicParams
  12047. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12048. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12049. // pp.FixmedinsName = miConfig.OrgName
  12050. // pp.FixmedinsCode = miConfig.Code
  12051. // pp.RequestUrl = miConfig.Url
  12052. // pp.Cainfo = miConfig.Cainfo
  12053. // pp.SecretKey = miConfig.SecretKey
  12054. // pp.AccessKey = miConfig.AccessKey
  12055. // pp.OpterName = curRoles.UserName
  12056. //
  12057. // client := &http.Client{}
  12058. // var req *http.Request
  12059. // data := make(map[string]interface{})
  12060. // data["struct4101"] = struct4101
  12061. // data["pp"] = pp
  12062. // bytesData, _ := json.Marshal(data)
  12063. // if miConfig.MdtrtareaAdmvs == "320921" {
  12064. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12065. // } else {
  12066. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12067. // }
  12068. // resp, _ := client.Do(req)
  12069. // defer resp.Body.Close()
  12070. // body, ioErr := ioutil.ReadAll(resp.Body)
  12071. // if ioErr != nil {
  12072. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12073. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12074. // return
  12075. // }
  12076. // var respJSON map[string]interface{}
  12077. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12078. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12080. // return
  12081. // }
  12082. //
  12083. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12084. // userJSONBytes, _ := json.Marshal(respJSON)
  12085. // fmt.Println("log")
  12086. // fmt.Println(string(userJSONBytes))
  12087. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12088. // utils.ErrorLog("解析失败:%v", err)
  12089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12090. // return
  12091. // }
  12092. // res.InfRefmsgid = resOther.InfRefmsgid
  12093. // res.Output = resOther.Output
  12094. // res.ErrMsg = resOther.ErrMsg
  12095. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12096. // res.Infcode = infocode
  12097. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12098. //
  12099. // var pp models.PublicParams
  12100. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12101. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12102. // pp.FixmedinsName = miConfig.OrgName
  12103. // pp.FixmedinsCode = miConfig.Code
  12104. // pp.RequestUrl = miConfig.Url
  12105. // pp.Cainfo = miConfig.Cainfo
  12106. // pp.SecretKey = miConfig.SecretKey
  12107. // pp.AccessKey = miConfig.AccessKey
  12108. // pp.OpterName = curRoles.UserName
  12109. // result, _ := service.Jxyb4101(struct4101, pp)
  12110. // var dat map[string]interface{}
  12111. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12112. // fmt.Println(dat)
  12113. // } else {
  12114. // fmt.Println(err)
  12115. // }
  12116. // userJSONBytes, _ := json.Marshal(dat)
  12117. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12118. // utils.ErrorLog("解析失败:%v", err)
  12119. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12120. // return
  12121. // }
  12122. //
  12123. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12124. // var pp models.PublicParams
  12125. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12126. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12127. // pp.FixmedinsName = miConfig.OrgName
  12128. // pp.FixmedinsCode = miConfig.Code
  12129. // pp.RequestUrl = miConfig.Url
  12130. // pp.Cainfo = miConfig.Cainfo
  12131. // pp.SecretKey = miConfig.SecretKey
  12132. // pp.AccessKey = miConfig.AccessKey
  12133. // pp.OpterName = curRoles.UserName
  12134. // result, _ := service.Hnyb4101(struct4101, pp)
  12135. // var dat map[string]interface{}
  12136. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12137. // fmt.Println(dat)
  12138. // } else {
  12139. // fmt.Println(err)
  12140. // }
  12141. // userJSONBytes, _ := json.Marshal(dat)
  12142. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12143. // utils.ErrorLog("解析失败:%v", err)
  12144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12145. // return
  12146. // }
  12147. //
  12148. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12149. // var resOther ResultSeventeenOther
  12150. //
  12151. // var pp models.PublicParams
  12152. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12153. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12154. // pp.FixmedinsName = miConfig.OrgName
  12155. // pp.FixmedinsCode = miConfig.Code
  12156. // pp.RequestUrl = miConfig.Url
  12157. // pp.Cainfo = miConfig.Cainfo
  12158. // pp.SecretKey = miConfig.SecretKey
  12159. // pp.AccessKey = miConfig.AccessKey
  12160. // pp.OpterName = curRoles.UserName
  12161. // client := &http.Client{}
  12162. // var req *http.Request
  12163. // data := make(map[string]interface{})
  12164. // data["struct4101"] = struct4101
  12165. // data["pp"] = pp
  12166. // bytesData, _ := json.Marshal(data)
  12167. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12168. // resp, _ := client.Do(req)
  12169. // defer resp.Body.Close()
  12170. // body, ioErr := ioutil.ReadAll(resp.Body)
  12171. // if ioErr != nil {
  12172. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12173. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12174. // return
  12175. // }
  12176. // var respJSON map[string]interface{}
  12177. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12178. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12180. // return
  12181. // }
  12182. //
  12183. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12184. // userJSONBytes, _ := json.Marshal(respJSON)
  12185. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12186. // utils.ErrorLog("解析失败:%v", err)
  12187. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12188. // return
  12189. // }
  12190. // res.InfRefmsgid = resOther.InfRefmsgid
  12191. // res.Output = resOther.Output
  12192. // res.ErrMsg = resOther.ErrMsg
  12193. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12194. // res.Infcode = infocode
  12195. //
  12196. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12197. // var pp models.PublicParams
  12198. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12199. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12200. // pp.FixmedinsName = miConfig.OrgName
  12201. // pp.FixmedinsCode = miConfig.Code
  12202. // pp.RequestUrl = miConfig.Url
  12203. // pp.Cainfo = miConfig.Cainfo
  12204. // pp.SecretKey = miConfig.SecretKey
  12205. // pp.AccessKey = miConfig.AccessKey
  12206. // pp.OpterName = curRoles.UserName
  12207. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12208. // fmt.Println(requestLog)
  12209. // fmt.Println(errMsgLog)
  12210. //
  12211. // saveLog(result, requestLog, "4101a", "上传清单")
  12212. //
  12213. // var dat map[string]interface{}
  12214. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12215. // fmt.Println(dat)
  12216. // } else {
  12217. // fmt.Println(err)
  12218. // }
  12219. // userJSONBytes, _ := json.Marshal(dat)
  12220. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12221. // utils.ErrorLog("解析失败:%v", err)
  12222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12223. // return
  12224. // }
  12225. //
  12226. // } else {
  12227. //
  12228. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12229. // var dat map[string]interface{}
  12230. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12231. // fmt.Println(dat)
  12232. // } else {
  12233. // fmt.Println(err)
  12234. // }
  12235. // userJSONBytes, _ := json.Marshal(dat)
  12236. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12237. // utils.ErrorLog("解析失败:%v", err)
  12238. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12239. // return
  12240. // }
  12241. // }
  12242. //
  12243. // if res.Infcode != 0 {
  12244. // adminUser := c.GetAdminUserInfo()
  12245. // errlog := &models.HisOrderError{
  12246. // UserOrgId: adminUser.CurrentOrgId,
  12247. // Ctime: time.Now().Unix(),
  12248. // Mtime: time.Now().Unix(),
  12249. // ErrMsg: res.ErrMsg,
  12250. // Status: 1,
  12251. // PatientId: order.ID,
  12252. // Stage: 10265,
  12253. // }
  12254. // service.CreateErrMsgLog(errlog)
  12255. // continue
  12256. // } else {
  12257. // //order.FaPiaoNumber = zero
  12258. // //order.FaPiaoCode = last_order.FaPiaoCode
  12259. // //service.UpdateOrder(order)
  12260. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12261. // Number: res.Output.SetlListId,
  12262. // Status: 1,
  12263. // Ctime: time.Now().Unix(),
  12264. // Mtime: time.Now().Unix(),
  12265. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12266. // IsUpload: 1,
  12267. // OrderId: order.ID,
  12268. // }
  12269. // service.CreateUploadRecord(hisFundSettleListResult)
  12270. // c.ServeSuccessJSON(map[string]interface{}{
  12271. // "msg": "上传成功",
  12272. // "result": hisFundSettleListResult,
  12273. // })
  12274. // continue
  12275. // }
  12276. // }
  12277. //}
  12278. func (c *HisApiController) GetbatchSettleList() {
  12279. //order_id, _ := c.GetInt64("order_id")
  12280. admin_user_id, _ := c.GetInt64("admin_user_id")
  12281. orders, _ := service.GetAllHisOrderTwo10485()
  12282. for _, item := range orders {
  12283. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12284. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12285. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12286. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12287. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12288. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12289. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12290. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12291. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12292. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12293. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12294. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12295. //fmt.Println(count)
  12296. //var zero string
  12297. //number := count + 1
  12298. //if number >= 1000 {
  12299. // zero = "0000" + strconv.FormatInt(number, 10)
  12300. //} else if number >= 10000 {
  12301. // zero = "000" + strconv.FormatInt(number, 10)
  12302. //} else if number >= 100000 {
  12303. // zero = "00" + strconv.FormatInt(number, 10)
  12304. //} else if number >= 1000000 {
  12305. // zero = "0" + strconv.FormatInt(number, 10)
  12306. //} else {
  12307. // zero = strconv.FormatInt(number, 10)
  12308. //}
  12309. //fmt.Println(zero)
  12310. struct4101 := service.Struct4101{
  12311. PsnNo: order.PsnNo,
  12312. MdtrtId: order.MdtrtId,
  12313. SetlId: order.SetlId,
  12314. PsnName: order.PsnName,
  12315. Gend: order.Gend,
  12316. Brdy: his.Brdy,
  12317. Age: his.Age,
  12318. Naty: order.Naty,
  12319. PatnCertType: "01",
  12320. Certno: order.Certno,
  12321. Prfs: "90",
  12322. ConerName: roles[0].UserName,
  12323. PatnRlts: "99",
  12324. ConerAddr: miConfig.OrgName,
  12325. ConerTel: admin.Mobile,
  12326. HiType: order.Insutype,
  12327. Insuplc: miConfig.InsuplcAdmdvs,
  12328. MaindiagFlag: "1",
  12329. BillCode: order.SetlId,
  12330. BillNo: order.SetlId,
  12331. BizSn: order.Number,
  12332. PsnSelfPay: order.PsnPartAmt,
  12333. PsnOwnPay: order.PsnPartAmt,
  12334. AcctPay: order.AcctPay,
  12335. PsnCashpay: order.PsnCashPay,
  12336. HiPaymtd: "1",
  12337. Hsorg: miConfig.InsuplcAdmdvs,
  12338. HsorgOpter: miConfig.InsuplcAdmdvs,
  12339. MedinsFillPsn: curRoles.UserName,
  12340. MedinsFillDept: miConfig.OrgName,
  12341. IptMedType: "2",
  12342. }
  12343. struct4101.SetlBegnDate = order.SetlTime
  12344. struct4101.SetlEndDate = order.SetlTime
  12345. time_arr := strings.Split(order.SetlTime, " ")
  12346. struct4101.AdmTime = time_arr[0]
  12347. struct4101.AdmEndTime = time_arr[0]
  12348. //var rf []CustomFundPay
  12349. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12350. //
  12351. //var tempFunPays []service.CustomStruct
  12352. //for _, item := range rf {
  12353. // var tempFunPay service.CustomStruct
  12354. // tempFunPay.FundPayamt = item.FundPayamt
  12355. // tempFunPay.FundPayType = item.FundPayType
  12356. // tempFunPays = append(tempFunPays, tempFunPay)
  12357. //}
  12358. //struct4101.CustomStruct = tempFunPays
  12359. var tempDiaginfos []service.DiaginfoStructTwo
  12360. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12361. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12362. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12363. var config []*models.HisXtDiagnoseConfig
  12364. for _, item := range diagnosis_ids {
  12365. id, _ := strconv.ParseInt(item, 10, 64)
  12366. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12367. config = append(config, &diagnosisConfig)
  12368. }
  12369. for index, item := range config {
  12370. if index == 0 {
  12371. var tempDiaginfo service.DiaginfoStructTwo
  12372. tempDiaginfo.DiagCode = item.CountryCode
  12373. tempDiaginfo.DiagName = item.CountryContentName
  12374. tempDiaginfo.DiagType = "1"
  12375. tempDiaginfo.MaindiagFlag = "1"
  12376. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12377. } else {
  12378. var tempDiaginfo service.DiaginfoStructTwo
  12379. tempDiaginfo.DiagCode = item.CountryCode
  12380. tempDiaginfo.DiagName = item.CountryContentName
  12381. tempDiaginfo.DiagType = "1"
  12382. tempDiaginfo.MaindiagFlag = "0"
  12383. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12384. }
  12385. }
  12386. struct4101.Diseinfo = tempDiaginfos
  12387. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12388. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12389. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12390. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12391. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12392. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12393. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12394. var iteminfo service.IteminfoStruct
  12395. var bedCostTotal float64 = 0 //床位总费
  12396. var bedCostSelfTotal float64 = 0 //床位自费
  12397. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12398. var operationCostTotal float64 = 0 //手术费
  12399. var operationCostSelfTotal float64 = 0 //手术费
  12400. var operationCostPartSelfTotal float64 = 0 //手术费
  12401. var otherCostTotal float64 = 0 //其他费用
  12402. var otherCostSelfTotal float64 = 0 //其他费用
  12403. var otherCostPartSelfTotal float64 = 0 //其他费用
  12404. var materialCostTotal float64 = 0 //材料费
  12405. var materialCostSelfTotal float64 = 0 //材料费
  12406. var materialCostPartSelfTotal float64 = 0 //材料费
  12407. var westernMedicineCostTotal float64 = 0 //西药费
  12408. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12409. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12410. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12411. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12412. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12413. var checkCostTotal float64 = 0 //检查费
  12414. var checkCostSelfTotal float64 = 0 //检查费
  12415. var checkCostPartSelfTotal float64 = 0 //检查费
  12416. var laboratoryCostTotal float64 = 0 //化验费
  12417. var laboratoryCostSelfTotal float64 = 0 //化验费
  12418. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12419. var treatCostTotal float64 = 0 //治疗费用
  12420. var treatCostSelfTotal float64 = 0 //治疗费用
  12421. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12422. decimal.DivisionPrecision = 2
  12423. var bed_fulamt_ownpay_amt float64 = 0
  12424. var operation_fulamt_ownpay_amt float64 = 0
  12425. var other_fulamt_ownpay_amt float64 = 0
  12426. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12427. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12428. var check_fulamt_ownpay_amt float64 = 0
  12429. var material_fulamt_ownpay_amt float64 = 0
  12430. var laboratory_fulamt_ownpay_amt float64 = 0
  12431. var treat_fulamt_ownpay_amt float64 = 0
  12432. var bed_claa_sunmfee float64 = 0
  12433. var bed_clab_amt float64 = 0
  12434. var bed_other_amt float64 = 0
  12435. var operation_claa_sunmfee float64 = 0
  12436. var operation_clab_amt float64 = 0
  12437. var operation_other_amt float64 = 0
  12438. var other_claa_sunmfee float64 = 0
  12439. var other_clab_amt float64 = 0
  12440. var other_other_amt float64 = 0
  12441. var westernMedicine_claa_sunmfee float64 = 0
  12442. var westernMedicine_clab_amt float64 = 0
  12443. var westernMedicine_other_amt float64 = 0
  12444. var chineseTraditional_claa_sunmfee float64 = 0
  12445. var chineseTraditional_clab_amt float64 = 0
  12446. var chineseTraditional_other_amt float64 = 0
  12447. var check_claa_sunmfee float64 = 0
  12448. var check_clab_amt float64 = 0
  12449. var check_other_amt float64 = 0
  12450. var material_claa_sunmfee float64 = 0
  12451. var material_clab_amt float64 = 0
  12452. var material_other_amt float64 = 0
  12453. var laboratory_claa_sunmfee float64 = 0
  12454. var laboratory_clab_amt float64 = 0
  12455. var laboratory_other_amt float64 = 0
  12456. var treat_claa_sunmfee float64 = 0
  12457. var treat_clab_amt float64 = 0
  12458. var treat_other_amt float64 = 0
  12459. for _, item := range order.HisOrderInfo {
  12460. if item.MedChrgitmType == "01" { //床位费
  12461. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12462. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12463. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12464. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12465. if item.ChrgitmLv == "1" {
  12466. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12467. }
  12468. if item.ChrgitmLv == "2" {
  12469. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12470. }
  12471. if item.ChrgitmLv == "3" {
  12472. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12473. }
  12474. }
  12475. if item.MedChrgitmType == "03" { //检查费
  12476. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12477. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12478. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12479. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12480. if item.ChrgitmLv == "1" {
  12481. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12482. }
  12483. if item.ChrgitmLv == "2" {
  12484. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12485. }
  12486. if item.ChrgitmLv == "3" {
  12487. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12488. }
  12489. }
  12490. if item.MedChrgitmType == "04" { //化验费
  12491. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12492. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12493. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12494. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12495. if item.ChrgitmLv == "1" {
  12496. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12497. }
  12498. if item.ChrgitmLv == "2" {
  12499. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12500. }
  12501. if item.ChrgitmLv == "3" {
  12502. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12503. }
  12504. }
  12505. if item.MedChrgitmType == "05" { //治疗费
  12506. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12507. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12508. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12509. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12510. if item.ChrgitmLv == "1" {
  12511. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12512. }
  12513. if item.ChrgitmLv == "2" {
  12514. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12515. }
  12516. if item.ChrgitmLv == "3" {
  12517. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12518. }
  12519. }
  12520. if item.MedChrgitmType == "06" { //手术费
  12521. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12522. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12523. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12524. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12525. if item.ChrgitmLv == "1" {
  12526. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12527. }
  12528. if item.ChrgitmLv == "2" {
  12529. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12530. }
  12531. if item.ChrgitmLv == "3" {
  12532. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12533. }
  12534. }
  12535. if item.MedChrgitmType == "08" { //材料费
  12536. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12537. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12538. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12539. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12540. if item.ChrgitmLv == "1" {
  12541. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12542. }
  12543. if item.ChrgitmLv == "2" {
  12544. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12545. }
  12546. if item.ChrgitmLv == "3" {
  12547. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12548. }
  12549. }
  12550. if item.MedChrgitmType == "09" { //西药费
  12551. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12552. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12553. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12554. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12555. if item.ChrgitmLv == "1" {
  12556. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12557. }
  12558. if item.ChrgitmLv == "2" {
  12559. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12560. }
  12561. if item.ChrgitmLv == "3" {
  12562. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12563. }
  12564. }
  12565. if item.MedChrgitmType == "11" { //中成费
  12566. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12567. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12568. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12569. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12570. if item.ChrgitmLv == "1" {
  12571. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12572. }
  12573. if item.ChrgitmLv == "2" {
  12574. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12575. }
  12576. if item.ChrgitmLv == "3" {
  12577. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12578. }
  12579. }
  12580. if item.MedChrgitmType == "14" { //其他费
  12581. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12582. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12583. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12584. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12585. if item.ChrgitmLv == "1" {
  12586. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12587. }
  12588. if item.ChrgitmLv == "2" {
  12589. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12590. }
  12591. if item.ChrgitmLv == "3" {
  12592. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12593. }
  12594. }
  12595. }
  12596. var iteminfoStructs []service.IteminfoStruct
  12597. if bedCostTotal != 0 {
  12598. iteminfo.MedChrgitm = "01"
  12599. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12600. iteminfo.Amt = bedCostTotal
  12601. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12602. iteminfo.ClabAmt = bed_clab_amt
  12603. iteminfo.OthAmt = bed_other_amt
  12604. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12605. }
  12606. if checkCostTotal != 0 {
  12607. iteminfo.MedChrgitm = "03"
  12608. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12609. iteminfo.Amt = checkCostTotal
  12610. iteminfo.ClaaSumfee = check_claa_sunmfee
  12611. iteminfo.ClabAmt = check_clab_amt
  12612. iteminfo.OthAmt = check_other_amt
  12613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12614. }
  12615. if laboratoryCostTotal != 0 {
  12616. iteminfo.MedChrgitm = "04"
  12617. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12618. iteminfo.Amt = laboratoryCostTotal
  12619. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12620. iteminfo.ClabAmt = laboratory_clab_amt
  12621. iteminfo.OthAmt = laboratory_other_amt
  12622. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12623. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12624. }
  12625. if treatCostTotal != 0 {
  12626. iteminfo.MedChrgitm = "05"
  12627. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12628. iteminfo.Amt = treatCostTotal
  12629. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12630. iteminfo.ClabAmt = treat_clab_amt
  12631. iteminfo.OthAmt = treat_other_amt
  12632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12633. //(struct4101.IteminfoStruct, iteminfo)
  12634. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12635. }
  12636. if operationCostTotal != 0 {
  12637. iteminfo.MedChrgitm = "06"
  12638. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12639. iteminfo.Amt = operationCostTotal
  12640. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12641. iteminfo.ClabAmt = operation_clab_amt
  12642. iteminfo.OthAmt = operation_other_amt
  12643. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12644. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12645. }
  12646. if materialCostTotal != 0 {
  12647. iteminfo.MedChrgitm = "08"
  12648. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12649. iteminfo.Amt = materialCostTotal
  12650. iteminfo.ClaaSumfee = material_claa_sunmfee
  12651. iteminfo.ClabAmt = material_clab_amt
  12652. iteminfo.OthAmt = material_other_amt
  12653. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12654. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12655. }
  12656. if westernMedicineCostTotal != 0 {
  12657. iteminfo.MedChrgitm = "09"
  12658. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12659. iteminfo.Amt = westernMedicineCostTotal
  12660. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12661. iteminfo.ClabAmt = westernMedicine_clab_amt
  12662. iteminfo.OthAmt = westernMedicine_other_amt
  12663. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12664. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12665. }
  12666. if chineseTraditionalMedicineCostTotal != 0 {
  12667. iteminfo.MedChrgitm = "11"
  12668. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12669. iteminfo.Amt = westernMedicineCostTotal
  12670. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12671. iteminfo.ClabAmt = westernMedicine_clab_amt
  12672. iteminfo.OthAmt = westernMedicine_other_amt
  12673. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12674. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12675. }
  12676. if otherCostTotal != 0 {
  12677. iteminfo.MedChrgitm = "14"
  12678. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12679. iteminfo.Amt = otherCostTotal
  12680. iteminfo.ClaaSumfee = other_claa_sunmfee
  12681. iteminfo.ClabAmt = other_clab_amt
  12682. iteminfo.OthAmt = other_other_amt
  12683. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12684. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12685. }
  12686. struct4101.IteminfoStruct = iteminfoStructs
  12687. struct4101.Ntly = "中国"
  12688. struct4101.AdmCaty = "A03.06"
  12689. struct4101.DoctorName = doctor.UserName
  12690. struct4101.DoctorCode = doctor.DoctorNumber
  12691. var res ResultSeventeen
  12692. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12693. struct4101.BillCode = order.Number
  12694. struct4101.BillNo = order.SetlId
  12695. var resOther ResultSeventeenOther
  12696. var pp models.PublicParams
  12697. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12698. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12699. pp.FixmedinsName = miConfig.OrgName
  12700. pp.FixmedinsCode = miConfig.Code
  12701. pp.RequestUrl = miConfig.Url
  12702. pp.Cainfo = miConfig.Cainfo
  12703. pp.SecretKey = miConfig.SecretKey
  12704. pp.AccessKey = miConfig.AccessKey
  12705. pp.OpterName = curRoles.UserName
  12706. client := &http.Client{}
  12707. var req *http.Request
  12708. data := make(map[string]interface{})
  12709. data["struct4101"] = struct4101
  12710. data["pp"] = pp
  12711. bytesData, _ := json.Marshal(data)
  12712. if miConfig.MdtrtareaAdmvs == "320921" {
  12713. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12714. } else {
  12715. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12716. }
  12717. resp, _ := client.Do(req)
  12718. defer resp.Body.Close()
  12719. body, ioErr := ioutil.ReadAll(resp.Body)
  12720. if ioErr != nil {
  12721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12723. return
  12724. }
  12725. var respJSON map[string]interface{}
  12726. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12729. return
  12730. }
  12731. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12732. userJSONBytes, _ := json.Marshal(respJSON)
  12733. fmt.Println("log")
  12734. fmt.Println(string(userJSONBytes))
  12735. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12736. utils.ErrorLog("解析失败:%v", err)
  12737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12738. return
  12739. }
  12740. res.InfRefmsgid = resOther.InfRefmsgid
  12741. res.Output = resOther.Output
  12742. res.ErrMsg = resOther.ErrMsg
  12743. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12744. res.Infcode = infocode
  12745. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12746. var pp models.PublicParams
  12747. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12748. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12749. pp.FixmedinsName = miConfig.OrgName
  12750. pp.FixmedinsCode = miConfig.Code
  12751. pp.RequestUrl = miConfig.Url
  12752. pp.Cainfo = miConfig.Cainfo
  12753. pp.SecretKey = miConfig.SecretKey
  12754. pp.AccessKey = miConfig.AccessKey
  12755. pp.OpterName = curRoles.UserName
  12756. result, _ := service.Jxyb4101(struct4101, pp)
  12757. var dat map[string]interface{}
  12758. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12759. fmt.Println(dat)
  12760. } else {
  12761. fmt.Println(err)
  12762. }
  12763. userJSONBytes, _ := json.Marshal(dat)
  12764. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12765. utils.ErrorLog("解析失败:%v", err)
  12766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12767. return
  12768. }
  12769. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12770. var pp models.PublicParams
  12771. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12772. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12773. pp.FixmedinsName = miConfig.OrgName
  12774. pp.FixmedinsCode = miConfig.Code
  12775. pp.RequestUrl = miConfig.Url
  12776. pp.Cainfo = miConfig.Cainfo
  12777. pp.SecretKey = miConfig.SecretKey
  12778. pp.AccessKey = miConfig.AccessKey
  12779. pp.OpterName = curRoles.UserName
  12780. result, _ := service.Hnyb4101(struct4101, pp)
  12781. var dat map[string]interface{}
  12782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12783. fmt.Println(dat)
  12784. } else {
  12785. fmt.Println(err)
  12786. }
  12787. userJSONBytes, _ := json.Marshal(dat)
  12788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12789. utils.ErrorLog("解析失败:%v", err)
  12790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12791. return
  12792. }
  12793. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12794. var resOther ResultSeventeenOther
  12795. var pp models.PublicParams
  12796. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12797. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12798. pp.FixmedinsName = miConfig.OrgName
  12799. pp.FixmedinsCode = miConfig.Code
  12800. pp.RequestUrl = miConfig.Url
  12801. pp.Cainfo = miConfig.Cainfo
  12802. pp.SecretKey = miConfig.SecretKey
  12803. pp.AccessKey = miConfig.AccessKey
  12804. pp.OpterName = curRoles.UserName
  12805. client := &http.Client{}
  12806. var req *http.Request
  12807. data := make(map[string]interface{})
  12808. data["struct4101"] = struct4101
  12809. data["pp"] = pp
  12810. bytesData, _ := json.Marshal(data)
  12811. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12812. resp, _ := client.Do(req)
  12813. defer resp.Body.Close()
  12814. body, ioErr := ioutil.ReadAll(resp.Body)
  12815. if ioErr != nil {
  12816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. var respJSON map[string]interface{}
  12821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12824. return
  12825. }
  12826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12827. userJSONBytes, _ := json.Marshal(respJSON)
  12828. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12829. utils.ErrorLog("解析失败:%v", err)
  12830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12831. return
  12832. }
  12833. res.InfRefmsgid = resOther.InfRefmsgid
  12834. res.Output = resOther.Output
  12835. res.ErrMsg = resOther.ErrMsg
  12836. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12837. res.Infcode = infocode
  12838. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12839. var pp models.PublicParams
  12840. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12841. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12842. pp.FixmedinsName = miConfig.OrgName
  12843. pp.FixmedinsCode = miConfig.Code
  12844. pp.RequestUrl = miConfig.Url
  12845. pp.Cainfo = miConfig.Cainfo
  12846. pp.SecretKey = miConfig.SecretKey
  12847. pp.AccessKey = miConfig.AccessKey
  12848. pp.OpterName = curRoles.UserName
  12849. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12850. fmt.Println(requestLog)
  12851. fmt.Println(errMsgLog)
  12852. saveLog(result, requestLog, "4101a", "上传清单")
  12853. var dat map[string]interface{}
  12854. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12855. fmt.Println(dat)
  12856. } else {
  12857. fmt.Println(err)
  12858. }
  12859. userJSONBytes, _ := json.Marshal(dat)
  12860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12861. utils.ErrorLog("解析失败:%v", err)
  12862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12863. return
  12864. }
  12865. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12866. var pp models.PublicParams
  12867. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12868. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12869. pp.FixmedinsName = miConfig.OrgName
  12870. pp.FixmedinsCode = miConfig.Code
  12871. pp.RequestUrl = miConfig.Url
  12872. pp.Cainfo = miConfig.Cainfo
  12873. pp.SecretKey = miConfig.SecretKey
  12874. pp.AccessKey = miConfig.AccessKey
  12875. pp.OpterName = curRoles.UserName
  12876. client := &http.Client{}
  12877. var req *http.Request
  12878. data := make(map[string]interface{})
  12879. data["struct4101"] = struct4101
  12880. data["pp"] = pp
  12881. bytesData, _ := json.Marshal(data)
  12882. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12883. resp, _ := client.Do(req)
  12884. defer resp.Body.Close()
  12885. body, ioErr := ioutil.ReadAll(resp.Body)
  12886. if ioErr != nil {
  12887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12889. return
  12890. }
  12891. var respJSON map[string]interface{}
  12892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12895. return
  12896. }
  12897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12898. userJSONBytes, _ := json.Marshal(respJSON)
  12899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12900. utils.ErrorLog("解析失败:%v", err)
  12901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12902. return
  12903. }
  12904. } else {
  12905. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12906. var dat map[string]interface{}
  12907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12908. fmt.Println(dat)
  12909. } else {
  12910. fmt.Println(err)
  12911. }
  12912. userJSONBytes, _ := json.Marshal(dat)
  12913. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12914. utils.ErrorLog("解析失败:%v", err)
  12915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12916. return
  12917. }
  12918. }
  12919. if res.Infcode != 0 {
  12920. errlog := &models.HisOrderError{
  12921. UserOrgId: order.UserOrgId,
  12922. Ctime: time.Now().Unix(),
  12923. Mtime: time.Now().Unix(),
  12924. ErrMsg: res.ErrMsg + "解析失败",
  12925. Status: 1,
  12926. PatientId: order.ID,
  12927. Stage: 10485,
  12928. }
  12929. service.CreateErrMsgLog(errlog)
  12930. continue
  12931. //c.ServeSuccessJSON(map[string]interface{}{
  12932. // "failed_code": -10,
  12933. // "msg": res.ErrMsg,
  12934. //})
  12935. } else {
  12936. //order.FaPiaoNumber = zero
  12937. //order.FaPiaoCode = last_order.FaPiaoCode
  12938. //service.UpdateOrder(order)
  12939. hisFundSettleListResult := &models.HisFundSettleListResult{
  12940. Number: res.Output.SetlListId,
  12941. Status: 1,
  12942. Ctime: time.Now().Unix(),
  12943. Mtime: time.Now().Unix(),
  12944. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12945. IsUpload: 1,
  12946. OrderId: order.ID,
  12947. }
  12948. service.CreateUploadRecord(hisFundSettleListResult)
  12949. continue
  12950. }
  12951. }
  12952. }
  12953. func (c *HisApiController) GetSettleList() {
  12954. order_id, _ := c.GetInt64("order_id")
  12955. admin_user_id, _ := c.GetInt64("admin_user_id")
  12956. order, _ := service.GetHisOrderByIDTwo(order_id)
  12957. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12958. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12959. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12960. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12961. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12962. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12963. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12964. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12965. if order.ID == 0 {
  12966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12967. return
  12968. }
  12969. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12970. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12971. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12972. //fmt.Println(count)
  12973. //var zero string
  12974. //number := count + 1
  12975. //if number >= 1000 {
  12976. // zero = "0000" + strconv.FormatInt(number, 10)
  12977. //} else if number >= 10000 {
  12978. // zero = "000" + strconv.FormatInt(number, 10)
  12979. //} else if number >= 100000 {
  12980. // zero = "00" + strconv.FormatInt(number, 10)
  12981. //} else if number >= 1000000 {
  12982. // zero = "0" + strconv.FormatInt(number, 10)
  12983. //} else {
  12984. // zero = strconv.FormatInt(number, 10)
  12985. //}
  12986. //fmt.Println(zero)
  12987. struct4101 := service.Struct4101{
  12988. PsnNo: order.PsnNo,
  12989. MdtrtId: order.MdtrtId,
  12990. SetlId: order.SetlId,
  12991. PsnName: order.PsnName,
  12992. Gend: order.Gend,
  12993. Brdy: his.Brdy,
  12994. Age: his.Age,
  12995. Naty: order.Naty,
  12996. PatnCertType: "01",
  12997. Certno: order.Certno,
  12998. Prfs: "90",
  12999. ConerName: roles[0].UserName,
  13000. PatnRlts: "99",
  13001. ConerAddr: miConfig.OrgName,
  13002. ConerTel: admin.Mobile,
  13003. HiType: order.Insutype,
  13004. Insuplc: miConfig.InsuplcAdmdvs,
  13005. MaindiagFlag: "1",
  13006. BillCode: order.SetlId,
  13007. BillNo: order.SetlId,
  13008. BizSn: order.Number,
  13009. PsnSelfPay: order.PsnPartAmt,
  13010. PsnOwnPay: order.PsnPartAmt,
  13011. AcctPay: order.AcctPay,
  13012. PsnCashpay: order.PsnCashPay,
  13013. HiPaymtd: "1",
  13014. Hsorg: miConfig.InsuplcAdmdvs,
  13015. HsorgOpter: miConfig.InsuplcAdmdvs,
  13016. MedinsFillPsn: curRoles.UserName,
  13017. MedinsFillDept: miConfig.OrgName,
  13018. IptMedType: "2",
  13019. }
  13020. struct4101.SetlBegnDate = order.SetlTime
  13021. struct4101.SetlEndDate = order.SetlTime
  13022. time_arr := strings.Split(order.SetlTime, " ")
  13023. struct4101.AdmTime = time_arr[0]
  13024. struct4101.AdmEndTime = time_arr[0]
  13025. //
  13026. //var rf []CustomFundPay
  13027. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13028. //
  13029. //var tempFunPays []service.CustomStruct
  13030. //for _, item := range rf {
  13031. // var tempFunPay service.CustomStruct
  13032. // tempFunPay.FundPayamt = item.FundPayamt
  13033. // tempFunPay.FundPayType = item.FundPayType
  13034. // tempFunPays = append(tempFunPays, tempFunPay)
  13035. //}
  13036. //struct4101.CustomStruct = tempFunPays
  13037. var tempDiaginfos []service.DiaginfoStructTwo
  13038. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13039. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13040. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  13041. var config []*models.HisXtDiagnoseConfig
  13042. for _, item := range diagnosis_ids {
  13043. id, _ := strconv.ParseInt(item, 10, 64)
  13044. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13045. config = append(config, &diagnosisConfig)
  13046. }
  13047. if miConfig.Code == "H15049901371" {
  13048. //for _, item := range config {
  13049. // if item.ID == 138 {
  13050. diagnosisConfig, _ := service.FindDiagnoseById(138)
  13051. var tempDiaginfo service.DiaginfoStructTwo
  13052. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  13053. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  13054. tempDiaginfo.DiagType = "1"
  13055. tempDiaginfo.MaindiagFlag = "1"
  13056. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13057. //}
  13058. //}
  13059. for _, item := range config {
  13060. if item.ID != 138 {
  13061. var tempDiaginfo service.DiaginfoStructTwo
  13062. tempDiaginfo.DiagCode = item.CountryCode
  13063. tempDiaginfo.DiagName = item.CountryContentName
  13064. tempDiaginfo.DiagType = "1"
  13065. tempDiaginfo.MaindiagFlag = "0"
  13066. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13067. }
  13068. }
  13069. } else {
  13070. for index, item := range config {
  13071. if index == 0 {
  13072. var tempDiaginfo service.DiaginfoStructTwo
  13073. tempDiaginfo.DiagCode = item.CountryCode
  13074. tempDiaginfo.DiagName = item.CountryContentName
  13075. tempDiaginfo.DiagType = "1"
  13076. tempDiaginfo.MaindiagFlag = "1"
  13077. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13078. } else {
  13079. var tempDiaginfo service.DiaginfoStructTwo
  13080. tempDiaginfo.DiagCode = item.CountryCode
  13081. tempDiaginfo.DiagName = item.CountryContentName
  13082. tempDiaginfo.DiagType = "1"
  13083. tempDiaginfo.MaindiagFlag = "0"
  13084. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13085. }
  13086. }
  13087. }
  13088. struct4101.Diseinfo = tempDiaginfos
  13089. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13090. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13091. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13092. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13093. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13094. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13095. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13096. var iteminfo service.IteminfoStruct
  13097. var bedCostTotal float64 = 0 //床位总费
  13098. var bedCostSelfTotal float64 = 0 //床位自费
  13099. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13100. var operationCostTotal float64 = 0 //手术费
  13101. var operationCostSelfTotal float64 = 0 //手术费
  13102. var operationCostPartSelfTotal float64 = 0 //手术费
  13103. var otherCostTotal float64 = 0 //其他费用
  13104. var otherCostSelfTotal float64 = 0 //其他费用
  13105. var otherCostPartSelfTotal float64 = 0 //其他费用
  13106. var materialCostTotal float64 = 0 //材料费
  13107. var materialCostSelfTotal float64 = 0 //材料费
  13108. var materialCostPartSelfTotal float64 = 0 //材料费
  13109. var westernMedicineCostTotal float64 = 0 //西药费
  13110. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13111. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13112. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13113. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13114. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13115. var checkCostTotal float64 = 0 //检查费
  13116. var checkCostSelfTotal float64 = 0 //检查费
  13117. var checkCostPartSelfTotal float64 = 0 //检查费
  13118. var laboratoryCostTotal float64 = 0 //化验费
  13119. var laboratoryCostSelfTotal float64 = 0 //化验费
  13120. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13121. var treatCostTotal float64 = 0 //治疗费用
  13122. var treatCostSelfTotal float64 = 0 //治疗费用
  13123. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13124. decimal.DivisionPrecision = 2
  13125. var bed_fulamt_ownpay_amt float64 = 0
  13126. var operation_fulamt_ownpay_amt float64 = 0
  13127. var other_fulamt_ownpay_amt float64 = 0
  13128. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13129. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13130. var check_fulamt_ownpay_amt float64 = 0
  13131. var material_fulamt_ownpay_amt float64 = 0
  13132. var laboratory_fulamt_ownpay_amt float64 = 0
  13133. var treat_fulamt_ownpay_amt float64 = 0
  13134. var bed_claa_sunmfee float64 = 0
  13135. var bed_clab_amt float64 = 0
  13136. var bed_other_amt float64 = 0
  13137. var operation_claa_sunmfee float64 = 0
  13138. var operation_clab_amt float64 = 0
  13139. var operation_other_amt float64 = 0
  13140. var other_claa_sunmfee float64 = 0
  13141. var other_clab_amt float64 = 0
  13142. var other_other_amt float64 = 0
  13143. var westernMedicine_claa_sunmfee float64 = 0
  13144. var westernMedicine_clab_amt float64 = 0
  13145. var westernMedicine_other_amt float64 = 0
  13146. var chineseTraditional_claa_sunmfee float64 = 0
  13147. var chineseTraditional_clab_amt float64 = 0
  13148. var chineseTraditional_other_amt float64 = 0
  13149. var check_claa_sunmfee float64 = 0
  13150. var check_clab_amt float64 = 0
  13151. var check_other_amt float64 = 0
  13152. var material_claa_sunmfee float64 = 0
  13153. var material_clab_amt float64 = 0
  13154. var material_other_amt float64 = 0
  13155. var laboratory_claa_sunmfee float64 = 0
  13156. var laboratory_clab_amt float64 = 0
  13157. var laboratory_other_amt float64 = 0
  13158. var treat_claa_sunmfee float64 = 0
  13159. var treat_clab_amt float64 = 0
  13160. var treat_other_amt float64 = 0
  13161. for _, item := range order.HisOrderInfo {
  13162. if item.MedChrgitmType == "01" { //床位费
  13163. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13164. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13165. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13166. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13167. if item.ChrgitmLv == "1" {
  13168. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13169. }
  13170. if item.ChrgitmLv == "2" {
  13171. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13172. }
  13173. if item.ChrgitmLv == "3" {
  13174. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13175. }
  13176. }
  13177. if item.MedChrgitmType == "03" { //检查费
  13178. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13179. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13180. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13181. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13182. if item.ChrgitmLv == "1" {
  13183. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13184. }
  13185. if item.ChrgitmLv == "2" {
  13186. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13187. }
  13188. if item.ChrgitmLv == "3" {
  13189. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13190. }
  13191. }
  13192. if item.MedChrgitmType == "04" { //化验费
  13193. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13194. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13195. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13196. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13197. if item.ChrgitmLv == "1" {
  13198. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13199. }
  13200. if item.ChrgitmLv == "2" {
  13201. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13202. }
  13203. if item.ChrgitmLv == "3" {
  13204. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13205. }
  13206. }
  13207. if item.MedChrgitmType == "05" { //治疗费
  13208. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13209. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13210. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13211. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13212. if item.ChrgitmLv == "1" {
  13213. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13214. }
  13215. if item.ChrgitmLv == "2" {
  13216. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13217. }
  13218. if item.ChrgitmLv == "3" {
  13219. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13220. }
  13221. }
  13222. if item.MedChrgitmType == "06" { //手术费
  13223. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13224. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13225. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13226. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13227. if item.ChrgitmLv == "1" {
  13228. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13229. }
  13230. if item.ChrgitmLv == "2" {
  13231. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13232. }
  13233. if item.ChrgitmLv == "3" {
  13234. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13235. }
  13236. }
  13237. if item.MedChrgitmType == "08" { //材料费
  13238. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13239. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13240. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13241. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13242. if item.ChrgitmLv == "1" {
  13243. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13244. }
  13245. if item.ChrgitmLv == "2" {
  13246. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13247. }
  13248. if item.ChrgitmLv == "3" {
  13249. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13250. }
  13251. }
  13252. if item.MedChrgitmType == "09" { //西药费
  13253. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13254. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13255. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13256. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13257. if item.ChrgitmLv == "1" {
  13258. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13259. }
  13260. if item.ChrgitmLv == "2" {
  13261. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13262. }
  13263. if item.ChrgitmLv == "3" {
  13264. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13265. }
  13266. }
  13267. if item.MedChrgitmType == "11" { //中成费
  13268. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13269. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13270. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13271. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13272. if item.ChrgitmLv == "1" {
  13273. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13274. }
  13275. if item.ChrgitmLv == "2" {
  13276. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13277. }
  13278. if item.ChrgitmLv == "3" {
  13279. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13280. }
  13281. }
  13282. if item.MedChrgitmType == "14" { //其他费
  13283. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13284. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13285. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13286. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13287. if item.ChrgitmLv == "1" {
  13288. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13289. }
  13290. if item.ChrgitmLv == "2" {
  13291. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13292. }
  13293. if item.ChrgitmLv == "3" {
  13294. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13295. }
  13296. }
  13297. }
  13298. var iteminfoStructs []service.IteminfoStruct
  13299. if bedCostTotal != 0 {
  13300. iteminfo.MedChrgitm = "01"
  13301. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13302. iteminfo.Amt = bedCostTotal
  13303. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13304. iteminfo.ClabAmt = bed_clab_amt
  13305. iteminfo.OthAmt = bed_other_amt
  13306. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13307. }
  13308. if checkCostTotal != 0 {
  13309. iteminfo.MedChrgitm = "03"
  13310. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13311. iteminfo.Amt = checkCostTotal
  13312. iteminfo.ClaaSumfee = check_claa_sunmfee
  13313. iteminfo.ClabAmt = check_clab_amt
  13314. iteminfo.OthAmt = check_other_amt
  13315. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13316. }
  13317. if laboratoryCostTotal != 0 {
  13318. iteminfo.MedChrgitm = "04"
  13319. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13320. iteminfo.Amt = laboratoryCostTotal
  13321. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13322. iteminfo.ClabAmt = laboratory_clab_amt
  13323. iteminfo.OthAmt = laboratory_other_amt
  13324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13325. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13326. }
  13327. if treatCostTotal != 0 {
  13328. iteminfo.MedChrgitm = "05"
  13329. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13330. iteminfo.Amt = treatCostTotal
  13331. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13332. iteminfo.ClabAmt = treat_clab_amt
  13333. iteminfo.OthAmt = treat_other_amt
  13334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13335. //(struct4101.IteminfoStruct, iteminfo)
  13336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13337. }
  13338. if operationCostTotal != 0 {
  13339. iteminfo.MedChrgitm = "06"
  13340. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13341. iteminfo.Amt = operationCostTotal
  13342. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13343. iteminfo.ClabAmt = operation_clab_amt
  13344. iteminfo.OthAmt = operation_other_amt
  13345. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13346. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13347. }
  13348. if materialCostTotal != 0 {
  13349. iteminfo.MedChrgitm = "08"
  13350. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13351. iteminfo.Amt = materialCostTotal
  13352. iteminfo.ClaaSumfee = material_claa_sunmfee
  13353. iteminfo.ClabAmt = material_clab_amt
  13354. iteminfo.OthAmt = material_other_amt
  13355. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13356. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13357. }
  13358. if westernMedicineCostTotal != 0 {
  13359. iteminfo.MedChrgitm = "09"
  13360. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13361. iteminfo.Amt = westernMedicineCostTotal
  13362. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13363. iteminfo.ClabAmt = westernMedicine_clab_amt
  13364. iteminfo.OthAmt = westernMedicine_other_amt
  13365. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13366. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13367. }
  13368. if chineseTraditionalMedicineCostTotal != 0 {
  13369. iteminfo.MedChrgitm = "11"
  13370. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13371. iteminfo.Amt = westernMedicineCostTotal
  13372. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13373. iteminfo.ClabAmt = westernMedicine_clab_amt
  13374. iteminfo.OthAmt = westernMedicine_other_amt
  13375. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13376. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13377. }
  13378. if otherCostTotal != 0 {
  13379. iteminfo.MedChrgitm = "14"
  13380. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13381. iteminfo.Amt = otherCostTotal
  13382. iteminfo.ClaaSumfee = other_claa_sunmfee
  13383. iteminfo.ClabAmt = other_clab_amt
  13384. iteminfo.OthAmt = other_other_amt
  13385. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13386. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13387. }
  13388. struct4101.IteminfoStruct = iteminfoStructs
  13389. struct4101.Ntly = "中国"
  13390. struct4101.AdmCaty = "A03.06"
  13391. struct4101.DoctorName = doctor.UserName
  13392. struct4101.DoctorCode = doctor.DoctorNumber
  13393. var res ResultSeventeen
  13394. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13395. struct4101.BillCode = order.Number
  13396. struct4101.BillNo = order.SetlId
  13397. var resOther ResultSeventeenOther
  13398. var pp models.PublicParams
  13399. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13400. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13401. pp.FixmedinsName = miConfig.OrgName
  13402. pp.FixmedinsCode = miConfig.Code
  13403. pp.RequestUrl = miConfig.Url
  13404. pp.Cainfo = miConfig.Cainfo
  13405. pp.SecretKey = miConfig.SecretKey
  13406. pp.AccessKey = miConfig.AccessKey
  13407. pp.OpterName = curRoles.UserName
  13408. client := &http.Client{}
  13409. var req *http.Request
  13410. data := make(map[string]interface{})
  13411. data["struct4101"] = struct4101
  13412. data["pp"] = pp
  13413. bytesData, _ := json.Marshal(data)
  13414. if miConfig.MdtrtareaAdmvs == "320921" {
  13415. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13416. } else {
  13417. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13418. }
  13419. resp, _ := client.Do(req)
  13420. defer resp.Body.Close()
  13421. body, ioErr := ioutil.ReadAll(resp.Body)
  13422. if ioErr != nil {
  13423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13425. return
  13426. }
  13427. var respJSON map[string]interface{}
  13428. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13431. return
  13432. }
  13433. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13434. userJSONBytes, _ := json.Marshal(respJSON)
  13435. fmt.Println("log")
  13436. fmt.Println(string(userJSONBytes))
  13437. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13438. utils.ErrorLog("解析失败:%v", err)
  13439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13440. return
  13441. }
  13442. res.InfRefmsgid = resOther.InfRefmsgid
  13443. res.Output = resOther.Output
  13444. res.ErrMsg = resOther.ErrMsg
  13445. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13446. res.Infcode = infocode
  13447. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13448. var pp models.PublicParams
  13449. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13450. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13451. pp.FixmedinsName = miConfig.OrgName
  13452. pp.FixmedinsCode = miConfig.Code
  13453. pp.RequestUrl = miConfig.Url
  13454. pp.Cainfo = miConfig.Cainfo
  13455. pp.SecretKey = miConfig.SecretKey
  13456. pp.AccessKey = miConfig.AccessKey
  13457. pp.OpterName = curRoles.UserName
  13458. result, _ := service.Jxyb4101(struct4101, pp)
  13459. var dat map[string]interface{}
  13460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13461. fmt.Println(dat)
  13462. } else {
  13463. fmt.Println(err)
  13464. }
  13465. userJSONBytes, _ := json.Marshal(dat)
  13466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13467. utils.ErrorLog("解析失败:%v", err)
  13468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13469. return
  13470. }
  13471. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13472. var pp models.PublicParams
  13473. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13474. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13475. pp.FixmedinsName = miConfig.OrgName
  13476. pp.FixmedinsCode = miConfig.Code
  13477. pp.RequestUrl = miConfig.Url
  13478. pp.Cainfo = miConfig.Cainfo
  13479. pp.SecretKey = miConfig.SecretKey
  13480. pp.AccessKey = miConfig.AccessKey
  13481. pp.OpterName = curRoles.UserName
  13482. result, _ := service.Hnyb4101(struct4101, pp)
  13483. var dat map[string]interface{}
  13484. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13485. fmt.Println(dat)
  13486. } else {
  13487. fmt.Println(err)
  13488. }
  13489. userJSONBytes, _ := json.Marshal(dat)
  13490. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13491. utils.ErrorLog("解析失败:%v", err)
  13492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13493. return
  13494. }
  13495. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13496. var resOther ResultSeventeenOther
  13497. var pp models.PublicParams
  13498. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13499. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13500. pp.FixmedinsName = miConfig.OrgName
  13501. pp.FixmedinsCode = miConfig.Code
  13502. pp.RequestUrl = miConfig.Url
  13503. pp.Cainfo = miConfig.Cainfo
  13504. pp.SecretKey = miConfig.SecretKey
  13505. pp.AccessKey = miConfig.AccessKey
  13506. pp.OpterName = curRoles.UserName
  13507. client := &http.Client{}
  13508. var req *http.Request
  13509. data := make(map[string]interface{})
  13510. data["struct4101"] = struct4101
  13511. data["pp"] = pp
  13512. bytesData, _ := json.Marshal(data)
  13513. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13514. resp, _ := client.Do(req)
  13515. defer resp.Body.Close()
  13516. body, ioErr := ioutil.ReadAll(resp.Body)
  13517. if ioErr != nil {
  13518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13520. return
  13521. }
  13522. var respJSON map[string]interface{}
  13523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13526. return
  13527. }
  13528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13529. userJSONBytes, _ := json.Marshal(respJSON)
  13530. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13531. utils.ErrorLog("解析失败:%v", err)
  13532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13533. return
  13534. }
  13535. res.InfRefmsgid = resOther.InfRefmsgid
  13536. res.Output = resOther.Output
  13537. res.ErrMsg = resOther.ErrMsg
  13538. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13539. res.Infcode = infocode
  13540. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13541. var pp models.PublicParams
  13542. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13543. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13544. pp.FixmedinsName = miConfig.OrgName
  13545. pp.FixmedinsCode = miConfig.Code
  13546. pp.RequestUrl = miConfig.Url
  13547. pp.Cainfo = miConfig.Cainfo
  13548. pp.SecretKey = miConfig.SecretKey
  13549. pp.AccessKey = miConfig.AccessKey
  13550. pp.OpterName = curRoles.UserName
  13551. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13552. fmt.Println(requestLog)
  13553. fmt.Println(errMsgLog)
  13554. saveLog(result, requestLog, "4101a", "上传清单")
  13555. var dat map[string]interface{}
  13556. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13557. fmt.Println(dat)
  13558. } else {
  13559. fmt.Println(err)
  13560. }
  13561. userJSONBytes, _ := json.Marshal(dat)
  13562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13563. utils.ErrorLog("解析失败:%v", err)
  13564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13565. return
  13566. }
  13567. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13568. var pp models.PublicParams
  13569. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13570. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13571. pp.FixmedinsName = miConfig.OrgName
  13572. pp.FixmedinsCode = miConfig.Code
  13573. pp.RequestUrl = miConfig.Url
  13574. pp.Cainfo = miConfig.Cainfo
  13575. pp.SecretKey = miConfig.SecretKey
  13576. pp.AccessKey = miConfig.AccessKey
  13577. pp.OpterName = curRoles.UserName
  13578. client := &http.Client{}
  13579. var req *http.Request
  13580. data := make(map[string]interface{})
  13581. data["struct4101"] = struct4101
  13582. data["pp"] = pp
  13583. bytesData, _ := json.Marshal(data)
  13584. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13585. resp, _ := client.Do(req)
  13586. defer resp.Body.Close()
  13587. body, ioErr := ioutil.ReadAll(resp.Body)
  13588. if ioErr != nil {
  13589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13591. return
  13592. }
  13593. var respJSON map[string]interface{}
  13594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13597. return
  13598. }
  13599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13600. userJSONBytes, _ := json.Marshal(respJSON)
  13601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13602. utils.ErrorLog("解析失败:%v", err)
  13603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13604. return
  13605. }
  13606. } else {
  13607. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13608. var dat map[string]interface{}
  13609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13610. fmt.Println(dat)
  13611. } else {
  13612. fmt.Println(err)
  13613. }
  13614. userJSONBytes, _ := json.Marshal(dat)
  13615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13616. utils.ErrorLog("解析失败:%v", err)
  13617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13618. return
  13619. }
  13620. }
  13621. if res.Infcode != 0 {
  13622. c.ServeSuccessJSON(map[string]interface{}{
  13623. "failed_code": -10,
  13624. "msg": res.ErrMsg,
  13625. })
  13626. return
  13627. } else {
  13628. //order.FaPiaoNumber = zero
  13629. //order.FaPiaoCode = last_order.FaPiaoCode
  13630. //service.UpdateOrder(order)
  13631. hisFundSettleListResult := &models.HisFundSettleListResult{
  13632. Number: res.Output.SetlListId,
  13633. Status: 1,
  13634. Ctime: time.Now().Unix(),
  13635. Mtime: time.Now().Unix(),
  13636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13637. IsUpload: 1,
  13638. OrderId: order_id,
  13639. }
  13640. service.CreateUploadRecord(hisFundSettleListResult)
  13641. c.ServeSuccessJSON(map[string]interface{}{
  13642. "msg": "上传成功",
  13643. "result": hisFundSettleListResult,
  13644. })
  13645. return
  13646. }
  13647. }
  13648. func (c *HisApiController) GetSettleListHospital() {
  13649. order_id, _ := c.GetInt64("order_id")
  13650. admin_user_id, _ := c.GetInt64("admin_user_id")
  13651. order, _ := service.GetHisOrderByIDTwo(order_id)
  13652. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13653. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13654. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13655. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13656. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13657. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13658. if order.ID == 0 {
  13659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13660. return
  13661. }
  13662. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13663. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13664. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13665. fmt.Println(count)
  13666. var zero string
  13667. number := count + 1
  13668. if number >= 1000 {
  13669. zero = "0000" + strconv.FormatInt(number, 10)
  13670. } else if number >= 10000 {
  13671. zero = "000" + strconv.FormatInt(number, 10)
  13672. } else if number >= 100000 {
  13673. zero = "00" + strconv.FormatInt(number, 10)
  13674. } else if number >= 1000000 {
  13675. zero = "0" + strconv.FormatInt(number, 10)
  13676. } else {
  13677. zero = strconv.FormatInt(number, 10)
  13678. }
  13679. fmt.Println(zero)
  13680. struct4101 := service.Struct4101{
  13681. PsnNo: order.PsnNo,
  13682. MdtrtId: order.MdtrtId,
  13683. SetlId: order.SetlId,
  13684. PsnName: order.PsnName,
  13685. Gend: order.Gend,
  13686. Brdy: his.Brdy,
  13687. Age: int64(order.Age),
  13688. Naty: order.Naty,
  13689. PatnCertType: "01",
  13690. Certno: order.Certno,
  13691. Prfs: "90",
  13692. ConerName: roles[0].UserName,
  13693. PatnRlts: "99",
  13694. ConerAddr: miConfig.OrgName,
  13695. ConerTel: admin.Mobile,
  13696. HiType: order.Insutype,
  13697. Insuplc: miConfig.InsuplcAdmdvs,
  13698. MaindiagFlag: "1",
  13699. BillCode: order.SetlId,
  13700. BillNo: order.SetlId,
  13701. BizSn: order.Number,
  13702. PsnSelfPay: order.PsnPartAmt,
  13703. PsnOwnPay: order.PsnPartAmt,
  13704. AcctPay: order.AcctPay,
  13705. PsnCashpay: order.PsnCashPay,
  13706. HiPaymtd: "1",
  13707. Hsorg: miConfig.InsuplcAdmdvs,
  13708. HsorgOpter: miConfig.InsuplcAdmdvs,
  13709. MedinsFillPsn: curRoles.UserName,
  13710. MedinsFillDept: depart.Name,
  13711. IptMedType: "2",
  13712. AdmTime: his.InHosptialTime,
  13713. AdmEndTime: his.OutHosptialTime,
  13714. }
  13715. struct4101.SetlBegnDate = order.SetlTime
  13716. struct4101.SetlEndDate = order.SetlTime
  13717. //var rf []CustomFundPay
  13718. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13719. //
  13720. //var tempFunPays []service.CustomStruct
  13721. //for _, item := range rf {
  13722. // var tempFunPay service.CustomStruct
  13723. // tempFunPay.FundPayamt = item.FundPayamt
  13724. // tempFunPay.FundPayType = item.FundPayType
  13725. // tempFunPays = append(tempFunPays, tempFunPay)
  13726. //}
  13727. //struct4101.CustomStruct = tempFunPays
  13728. var tempDiaginfos []service.DiaginfoStructTwo
  13729. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13730. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13731. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13732. //for _, item := range infos {
  13733. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13734. //}
  13735. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13736. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13737. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13738. fmt.Println(diagnosis_ids_arr)
  13739. if order.UserOrgId == 10210 {
  13740. var diagnosis_ids_arr_two []int64
  13741. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13742. var config []*models.HisXtDiagnoseConfig
  13743. for _, id := range diagnosis_ids_arr_two {
  13744. //id, _ := strconv.ParseInt(item, 10, 64)
  13745. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13746. if diagnosisConfig.ID > 0 {
  13747. config = append(config, &diagnosisConfig)
  13748. }
  13749. }
  13750. for index, item := range config {
  13751. if item.ID > 0 {
  13752. if index == 0 {
  13753. var tempDiaginfo service.DiaginfoStructTwo
  13754. tempDiaginfo.DiagCode = item.CountryCode
  13755. tempDiaginfo.DiagName = item.CountryContentName
  13756. tempDiaginfo.DiagType = "1"
  13757. tempDiaginfo.MaindiagFlag = "1"
  13758. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13759. } else {
  13760. var tempDiaginfo service.DiaginfoStructTwo
  13761. tempDiaginfo.DiagCode = item.CountryCode
  13762. tempDiaginfo.DiagName = item.CountryContentName
  13763. tempDiaginfo.DiagType = "1"
  13764. tempDiaginfo.MaindiagFlag = "0"
  13765. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13766. }
  13767. }
  13768. }
  13769. struct4101.Diseinfo = tempDiaginfos
  13770. } else {
  13771. var config []*models.HisXtDiagnoseConfig
  13772. for _, item := range diagnosis_ids_arr {
  13773. id, _ := strconv.ParseInt(item, 10, 64)
  13774. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13775. if diagnosisConfig.ID > 0 {
  13776. config = append(config, &diagnosisConfig)
  13777. }
  13778. }
  13779. for index, item := range config {
  13780. if item.ID > 0 {
  13781. if index == 0 {
  13782. var tempDiaginfo service.DiaginfoStructTwo
  13783. tempDiaginfo.DiagCode = item.CountryCode
  13784. tempDiaginfo.DiagName = item.CountryContentName
  13785. tempDiaginfo.DiagType = "1"
  13786. tempDiaginfo.MaindiagFlag = "1"
  13787. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13788. } else {
  13789. var tempDiaginfo service.DiaginfoStructTwo
  13790. tempDiaginfo.DiagCode = item.CountryCode
  13791. tempDiaginfo.DiagName = item.CountryContentName
  13792. tempDiaginfo.DiagType = "1"
  13793. tempDiaginfo.MaindiagFlag = "0"
  13794. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13795. }
  13796. }
  13797. }
  13798. struct4101.Diseinfo = tempDiaginfos
  13799. }
  13800. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13801. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13802. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13803. tempOpspdiseinfo2.OprnOprtCode = ""
  13804. tempOpspdiseinfo2.OprnOprtName = ""
  13805. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13806. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13807. var iteminfo service.IteminfoStruct
  13808. var bedCostTotal float64 = 0 //床位总费
  13809. var bedCostSelfTotal float64 = 0 //床位自费
  13810. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13811. var operationCostTotal float64 = 0 //手术费
  13812. var operationCostSelfTotal float64 = 0 //手术费
  13813. var operationCostPartSelfTotal float64 = 0 //手术费
  13814. var otherCostTotal float64 = 0 //其他费用
  13815. var otherCostSelfTotal float64 = 0 //其他费用
  13816. var otherCostPartSelfTotal float64 = 0 //其他费用
  13817. var materialCostTotal float64 = 0 //材料费
  13818. var materialCostSelfTotal float64 = 0 //材料费
  13819. var materialCostPartSelfTotal float64 = 0 //材料费
  13820. var westernMedicineCostTotal float64 = 0 //西药费
  13821. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13822. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13823. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13824. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13825. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13826. var checkCostTotal float64 = 0 //检查费
  13827. var checkCostSelfTotal float64 = 0 //检查费
  13828. var checkCostPartSelfTotal float64 = 0 //检查费
  13829. var laboratoryCostTotal float64 = 0 //化验费
  13830. var laboratoryCostSelfTotal float64 = 0 //化验费
  13831. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13832. var treatCostTotal float64 = 0 //治疗费用
  13833. var treatCostSelfTotal float64 = 0 //治疗费用
  13834. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13835. decimal.DivisionPrecision = 2
  13836. var bed_fulamt_ownpay_amt float64 = 0
  13837. var operation_fulamt_ownpay_amt float64 = 0
  13838. var other_fulamt_ownpay_amt float64 = 0
  13839. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13840. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13841. var check_fulamt_ownpay_amt float64 = 0
  13842. var material_fulamt_ownpay_amt float64 = 0
  13843. var laboratory_fulamt_ownpay_amt float64 = 0
  13844. var treat_fulamt_ownpay_amt float64 = 0
  13845. var bed_claa_sunmfee float64 = 0
  13846. var bed_clab_amt float64 = 0
  13847. var bed_other_amt float64 = 0
  13848. var operation_claa_sunmfee float64 = 0
  13849. var operation_clab_amt float64 = 0
  13850. var operation_other_amt float64 = 0
  13851. var other_claa_sunmfee float64 = 0
  13852. var other_clab_amt float64 = 0
  13853. var other_other_amt float64 = 0
  13854. var westernMedicine_claa_sunmfee float64 = 0
  13855. var westernMedicine_clab_amt float64 = 0
  13856. var westernMedicine_other_amt float64 = 0
  13857. var chineseTraditional_claa_sunmfee float64 = 0
  13858. var chineseTraditional_clab_amt float64 = 0
  13859. var chineseTraditional_other_amt float64 = 0
  13860. var check_claa_sunmfee float64 = 0
  13861. var check_clab_amt float64 = 0
  13862. var check_other_amt float64 = 0
  13863. var material_claa_sunmfee float64 = 0
  13864. var material_clab_amt float64 = 0
  13865. var material_other_amt float64 = 0
  13866. var laboratory_claa_sunmfee float64 = 0
  13867. var laboratory_clab_amt float64 = 0
  13868. var laboratory_other_amt float64 = 0
  13869. var treat_claa_sunmfee float64 = 0
  13870. var treat_clab_amt float64 = 0
  13871. var treat_other_amt float64 = 0
  13872. for _, item := range order.HisOrderInfo {
  13873. if item.MedChrgitmType == "01" { //床位费
  13874. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13875. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13876. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13877. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13878. if item.ChrgitmLv == "1" {
  13879. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13880. }
  13881. if item.ChrgitmLv == "2" {
  13882. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13883. }
  13884. if item.ChrgitmLv == "3" {
  13885. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13886. }
  13887. }
  13888. if item.MedChrgitmType == "03" { //检查费
  13889. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13890. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13891. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13892. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13893. if item.ChrgitmLv == "1" {
  13894. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13895. }
  13896. if item.ChrgitmLv == "2" {
  13897. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13898. }
  13899. if item.ChrgitmLv == "3" {
  13900. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13901. }
  13902. }
  13903. if item.MedChrgitmType == "04" { //化验费
  13904. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13905. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13906. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13907. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13908. if item.ChrgitmLv == "1" {
  13909. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13910. }
  13911. if item.ChrgitmLv == "2" {
  13912. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13913. }
  13914. if item.ChrgitmLv == "3" {
  13915. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13916. }
  13917. }
  13918. if item.MedChrgitmType == "05" { //治疗费
  13919. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13920. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13921. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13922. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13923. if item.ChrgitmLv == "1" {
  13924. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13925. }
  13926. if item.ChrgitmLv == "2" {
  13927. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13928. }
  13929. if item.ChrgitmLv == "3" {
  13930. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13931. }
  13932. }
  13933. if item.MedChrgitmType == "06" { //手术费
  13934. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13935. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13936. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13937. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13938. if item.ChrgitmLv == "1" {
  13939. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13940. }
  13941. if item.ChrgitmLv == "2" {
  13942. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13943. }
  13944. if item.ChrgitmLv == "3" {
  13945. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13946. }
  13947. }
  13948. if item.MedChrgitmType == "08" { //材料费
  13949. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13950. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13951. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13952. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13953. if item.ChrgitmLv == "1" {
  13954. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13955. }
  13956. if item.ChrgitmLv == "2" {
  13957. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13958. }
  13959. if item.ChrgitmLv == "3" {
  13960. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13961. }
  13962. }
  13963. if item.MedChrgitmType == "09" { //西药费
  13964. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13965. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13966. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13967. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13968. if item.ChrgitmLv == "1" {
  13969. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13970. }
  13971. if item.ChrgitmLv == "2" {
  13972. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13973. }
  13974. if item.ChrgitmLv == "3" {
  13975. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13976. }
  13977. }
  13978. if item.MedChrgitmType == "11" { //中成费
  13979. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13980. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13981. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13982. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13983. if item.ChrgitmLv == "1" {
  13984. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13985. }
  13986. if item.ChrgitmLv == "2" {
  13987. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13988. }
  13989. if item.ChrgitmLv == "3" {
  13990. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13991. }
  13992. }
  13993. if item.MedChrgitmType == "14" { //其他费
  13994. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13995. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13996. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13997. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13998. if item.ChrgitmLv == "1" {
  13999. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14000. }
  14001. if item.ChrgitmLv == "2" {
  14002. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14003. }
  14004. if item.ChrgitmLv == "3" {
  14005. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14006. }
  14007. }
  14008. }
  14009. var iteminfoStructs []service.IteminfoStruct
  14010. if bedCostTotal != 0 {
  14011. iteminfo.MedChrgitm = "01"
  14012. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14013. iteminfo.Amt = bedCostTotal
  14014. iteminfo.ClaaSumfee = bed_claa_sunmfee
  14015. iteminfo.ClabAmt = bed_clab_amt
  14016. iteminfo.OthAmt = bed_other_amt
  14017. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14018. }
  14019. if checkCostTotal != 0 {
  14020. iteminfo.MedChrgitm = "03"
  14021. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14022. iteminfo.Amt = checkCostTotal
  14023. iteminfo.ClaaSumfee = check_claa_sunmfee
  14024. iteminfo.ClabAmt = check_clab_amt
  14025. iteminfo.OthAmt = check_other_amt
  14026. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14027. }
  14028. if laboratoryCostTotal != 0 {
  14029. iteminfo.MedChrgitm = "04"
  14030. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14031. iteminfo.Amt = laboratoryCostTotal
  14032. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14033. iteminfo.ClabAmt = laboratory_clab_amt
  14034. iteminfo.OthAmt = laboratory_other_amt
  14035. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14036. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14037. }
  14038. if treatCostTotal != 0 {
  14039. iteminfo.MedChrgitm = "05"
  14040. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14041. iteminfo.Amt = treatCostTotal
  14042. iteminfo.ClaaSumfee = treat_claa_sunmfee
  14043. iteminfo.ClabAmt = treat_clab_amt
  14044. iteminfo.OthAmt = treat_other_amt
  14045. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14046. //(struct4101.IteminfoStruct, iteminfo)
  14047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14048. }
  14049. if operationCostTotal != 0 {
  14050. iteminfo.MedChrgitm = "06"
  14051. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14052. iteminfo.Amt = operationCostTotal
  14053. iteminfo.ClaaSumfee = operation_claa_sunmfee
  14054. iteminfo.ClabAmt = operation_clab_amt
  14055. iteminfo.OthAmt = operation_other_amt
  14056. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14057. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14058. }
  14059. if materialCostTotal != 0 {
  14060. iteminfo.MedChrgitm = "08"
  14061. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14062. iteminfo.Amt = materialCostTotal
  14063. iteminfo.ClaaSumfee = material_claa_sunmfee
  14064. iteminfo.ClabAmt = material_clab_amt
  14065. iteminfo.OthAmt = material_other_amt
  14066. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14067. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14068. }
  14069. if westernMedicineCostTotal != 0 {
  14070. iteminfo.MedChrgitm = "09"
  14071. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14072. iteminfo.Amt = westernMedicineCostTotal
  14073. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14074. iteminfo.ClabAmt = westernMedicine_clab_amt
  14075. iteminfo.OthAmt = westernMedicine_other_amt
  14076. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14077. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14078. }
  14079. if chineseTraditionalMedicineCostTotal != 0 {
  14080. iteminfo.MedChrgitm = "11"
  14081. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14082. iteminfo.Amt = westernMedicineCostTotal
  14083. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14084. iteminfo.ClabAmt = westernMedicine_clab_amt
  14085. iteminfo.OthAmt = westernMedicine_other_amt
  14086. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14087. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14088. }
  14089. if otherCostTotal != 0 {
  14090. iteminfo.MedChrgitm = "14"
  14091. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14092. iteminfo.Amt = otherCostTotal
  14093. iteminfo.ClaaSumfee = other_claa_sunmfee
  14094. iteminfo.ClabAmt = other_clab_amt
  14095. iteminfo.OthAmt = other_other_amt
  14096. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14097. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14098. }
  14099. struct4101.IteminfoStruct = iteminfoStructs
  14100. struct4101.Ntly = "中国"
  14101. struct4101.AdmCaty = "A03.06"
  14102. var resOther ResultSeventeenOther
  14103. var res ResultSeventeen
  14104. if miConfig.MdtrtareaAdmvs == "150499" {
  14105. var pp models.PublicParams
  14106. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14107. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14108. pp.FixmedinsName = miConfig.OrgName
  14109. pp.FixmedinsCode = miConfig.Code
  14110. pp.RequestUrl = miConfig.Url
  14111. pp.Cainfo = miConfig.Cainfo
  14112. pp.SecretKey = miConfig.SecretKey
  14113. pp.AccessKey = miConfig.AccessKey
  14114. pp.OpterName = curRoles.UserName
  14115. client := &http.Client{}
  14116. var req *http.Request
  14117. data := make(map[string]interface{})
  14118. data["struct4101"] = struct4101
  14119. data["pp"] = pp
  14120. bytesData, _ := json.Marshal(data)
  14121. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14122. resp, _ := client.Do(req)
  14123. defer resp.Body.Close()
  14124. body, ioErr := ioutil.ReadAll(resp.Body)
  14125. if ioErr != nil {
  14126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14128. return
  14129. }
  14130. var respJSON map[string]interface{}
  14131. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14134. return
  14135. }
  14136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14137. userJSONBytes, _ := json.Marshal(respJSON)
  14138. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14139. utils.ErrorLog("解析失败:%v", err)
  14140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14141. return
  14142. }
  14143. res.InfRefmsgid = resOther.InfRefmsgid
  14144. res.Output = resOther.Output
  14145. res.ErrMsg = resOther.ErrMsg
  14146. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14147. res.Infcode = infocode
  14148. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14149. var pp models.PublicParams
  14150. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14151. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14152. pp.FixmedinsName = miConfig.OrgName
  14153. pp.FixmedinsCode = miConfig.Code
  14154. pp.RequestUrl = miConfig.Url
  14155. pp.Cainfo = miConfig.Cainfo
  14156. pp.SecretKey = miConfig.SecretKey
  14157. pp.AccessKey = miConfig.AccessKey
  14158. pp.OpterName = curRoles.UserName
  14159. result, _ := service.Jxyb4101(struct4101, pp)
  14160. var dat map[string]interface{}
  14161. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14162. fmt.Println(dat)
  14163. } else {
  14164. fmt.Println(err)
  14165. }
  14166. userJSONBytes, _ := json.Marshal(dat)
  14167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14168. utils.ErrorLog("解析失败:%v", err)
  14169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14170. return
  14171. }
  14172. } else {
  14173. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14174. var dat map[string]interface{}
  14175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14176. fmt.Println(dat)
  14177. } else {
  14178. fmt.Println(err)
  14179. }
  14180. userJSONBytes, _ := json.Marshal(dat)
  14181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14182. utils.ErrorLog("解析失败:%v", err)
  14183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14184. return
  14185. }
  14186. }
  14187. if res.Infcode != 0 {
  14188. c.ServeSuccessJSON(map[string]interface{}{
  14189. "failed_code": -10,
  14190. "msg": res.ErrMsg,
  14191. })
  14192. return
  14193. } else {
  14194. if miConfig.MdtrtareaAdmvs != "150499" {
  14195. order.FaPiaoNumber = zero
  14196. order.FaPiaoCode = last_order.FaPiaoCode
  14197. service.UpdateOrder(order)
  14198. }
  14199. hisFundSettleListResult := &models.HisFundSettleListResult{
  14200. Number: res.Output.SetlListId,
  14201. Status: 1,
  14202. Ctime: time.Now().Unix(),
  14203. Mtime: time.Now().Unix(),
  14204. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14205. IsUpload: 1,
  14206. OrderId: order_id,
  14207. }
  14208. service.CreateUploadRecord(hisFundSettleListResult)
  14209. c.ServeSuccessJSON(map[string]interface{}{
  14210. "msg": "上传成功",
  14211. "result": hisFundSettleListResult,
  14212. })
  14213. return
  14214. }
  14215. }
  14216. //func (c *HisApiController) GetBatchSettleList() {
  14217. // orders, _ := service.GetAllHisOrder(10106)
  14218. // for _, item := range orders {
  14219. // order_id := item.ID
  14220. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14221. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14222. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14223. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14224. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14225. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14226. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14227. //
  14228. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14229. //
  14230. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14231. //
  14232. // if order.ID == 0 {
  14233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14234. // return
  14235. // }
  14236. // if his.BalanceAccountsType == 2 {
  14237. // continue
  14238. // }
  14239. // struct4101 := service.Struct4101{
  14240. // PsnNo: order.PsnNo,
  14241. // MdtrtId: order.MdtrtId,
  14242. // SetlId: order.SetlId,
  14243. // PsnName: order.PsnName,
  14244. // Gend: order.Gend,
  14245. // Brdy: his.Brdy,
  14246. // Age: his.Age,
  14247. // Naty: order.Naty,
  14248. // PatnCertType: "01",
  14249. // Certno: order.Certno,
  14250. // Prfs: "90",
  14251. // ConerName: roles[0].UserName,
  14252. // PatnRlts: "99",
  14253. // ConerAddr: miConfig.OrgName,
  14254. // ConerTel: admin.Mobile,
  14255. // HiType: order.Insutype,
  14256. // Insuplc: his.InsuplcAdmdvs,
  14257. // MaindiagFlag: "1",
  14258. // BillCode: order.SetlId,
  14259. // BillNo: order.SetlId,
  14260. // BizSn: order.Number,
  14261. // PsnSelfPay: order.PsnPartAmt,
  14262. // PsnOwnPay: order.PsnPartAmt,
  14263. // AcctPay: order.AcctPay,
  14264. // PsnCashpay: order.PsnCashPay,
  14265. // HiPaymtd: "1",
  14266. // Hsorg: his.InsuplcAdmdvs,
  14267. // HsorgOpter: his.InsuplcAdmdvs,
  14268. // MedinsFillPsn: curRoles.UserName,
  14269. // MedinsFillDept: depart.Name,
  14270. // IptMedType: "2",
  14271. // }
  14272. // struct4101.SetlBegnDate = order.SetlTime
  14273. // struct4101.SetlEndDate = order.SetlTime
  14274. // //if order.SettleType == 1 {
  14275. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14276. // // dateStr := t.Format("2006-01-02")
  14277. // // struct4101.SetlBegnDate = dateStr
  14278. // // struct4101.SetlEndDate = dateStr
  14279. // //} else {
  14280. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14281. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14282. // // dateStartStr := t.Format("2006-01-02")
  14283. // // dateEndStr := t2.Format("2006-01-02")
  14284. // // struct4101.SetlBegnDate = dateStartStr
  14285. // // struct4101.SetlEndDate = dateEndStr
  14286. // //}
  14287. //
  14288. // var rf []CustomFundPay
  14289. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14290. //
  14291. // var tempFunPays []service.CustomStruct
  14292. // var tempFunPay610100 service.CustomStruct
  14293. //
  14294. // for _, item := range rf {
  14295. // if item.FundPayType == "610100" {
  14296. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14297. // tempFunPay610100.FundPayType = item.FundPayType
  14298. // } else {
  14299. // var tempFunPay service.CustomStruct
  14300. // tempFunPay.FundPayamt = item.FundPayamt
  14301. // tempFunPay.FundPayType = item.FundPayType
  14302. // tempFunPays = append(tempFunPays, tempFunPay)
  14303. // }
  14304. // }
  14305. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14306. // struct4101.CustomStruct = tempFunPays
  14307. //
  14308. // var tempDiaginfos []service.DiaginfoStructTwo
  14309. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14310. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14311. //
  14312. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14313. // var config []*models.HisXtDiagnoseConfig
  14314. // for _, item := range diagnosis_ids {
  14315. // id, _ := strconv.ParseInt(item, 10, 64)
  14316. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14317. // config = append(config, &diagnosisConfig)
  14318. // }
  14319. //
  14320. // for index, item := range config {
  14321. // if index == 0 {
  14322. // var tempDiaginfo service.DiaginfoStructTwo
  14323. // tempDiaginfo.DiagCode = item.CountryCode
  14324. // tempDiaginfo.DiagName = item.CountryContentName
  14325. // tempDiaginfo.DiagType = "1"
  14326. // tempDiaginfo.MaindiagFlag = "1"
  14327. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14328. // } else {
  14329. //
  14330. // var tempDiaginfo service.DiaginfoStructTwo
  14331. // tempDiaginfo.DiagCode = item.CountryCode
  14332. // tempDiaginfo.DiagName = item.CountryContentName
  14333. // tempDiaginfo.DiagType = "2"
  14334. // tempDiaginfo.MaindiagFlag = "0"
  14335. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14336. // }
  14337. // }
  14338. // struct4101.Diseinfo = tempDiaginfos
  14339. //
  14340. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14341. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14342. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14343. // tempOpspdiseinfo2.OprnOprtCode = ""
  14344. // tempOpspdiseinfo2.OprnOprtName = ""
  14345. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14346. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14347. //
  14348. // var iteminfo service.IteminfoStruct
  14349. //
  14350. // var bedCostTotal float64 = 0 //床位总费
  14351. // var bedCostSelfTotal float64 = 0 //床位自费
  14352. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14353. //
  14354. // var examineCostTotal float64 = 0 //诊查总费
  14355. // var examineCostSelfTotal float64 = 0 //诊查自费
  14356. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14357. //
  14358. // var nursingCostTotal float64 = 0 //护理总费
  14359. // var nursingCostSelfTotal float64 = 0 //护理自费
  14360. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14361. //
  14362. // var chineseMedicineCostTotal float64 = 0 //中成药
  14363. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14364. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14365. //
  14366. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14367. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14368. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14369. //
  14370. // var registerCostTotal float64 = 0 //一般诊疗费
  14371. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14372. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14373. //
  14374. // var operationCostTotal float64 = 0 //手术费
  14375. // var operationCostSelfTotal float64 = 0 //手术费
  14376. // var operationCostPartSelfTotal float64 = 0 //手术费
  14377. //
  14378. // var otherCostTotal float64 = 0 //其他费用
  14379. // var otherCostSelfTotal float64 = 0 //其他费用
  14380. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14381. //
  14382. // var materialCostTotal float64 = 0 //材料费
  14383. // var materialCostSelfTotal float64 = 0 //材料费
  14384. // var materialCostPartSelfTotal float64 = 0 //材料费
  14385. //
  14386. // var westernMedicineCostTotal float64 = 0 //西药费
  14387. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14388. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14389. //
  14390. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14391. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14392. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14393. //
  14394. // var checkCostTotal float64 = 0 //检查费
  14395. // var checkCostSelfTotal float64 = 0 //检查费
  14396. // var checkCostPartSelfTotal float64 = 0 //检查费
  14397. //
  14398. // var laboratoryCostTotal float64 = 0 //化验费
  14399. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14400. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14401. //
  14402. // var treatCostTotal float64 = 0 //治疗费用
  14403. // var treatCostSelfTotal float64 = 0 //治疗费用
  14404. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14405. //
  14406. // decimal.DivisionPrecision = 2
  14407. //
  14408. // var bed_fulamt_ownpay_amt float64 = 0
  14409. //
  14410. // var examine_fulamt_ownpay_amt float64 = 0
  14411. //
  14412. // var nursing_fulamt_ownpay_amt float64 = 0
  14413. //
  14414. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14415. //
  14416. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14417. //
  14418. // var register_fulamt_ownpay_amt float64 = 0
  14419. //
  14420. // var operation_fulamt_ownpay_amt float64 = 0
  14421. // var other_fulamt_ownpay_amt float64 = 0
  14422. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14423. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14424. // var check_fulamt_ownpay_amt float64 = 0
  14425. // var material_fulamt_ownpay_amt float64 = 0
  14426. // var laboratory_fulamt_ownpay_amt float64 = 0
  14427. // var treat_fulamt_ownpay_amt float64 = 0
  14428. //
  14429. // var bed_claa_sunmfee float64 = 0
  14430. // var bed_clab_amt float64 = 0
  14431. // var bed_other_amt float64 = 0
  14432. //
  14433. // var examine_claa_sunmfee float64 = 0
  14434. // var examine_clab_amt float64 = 0
  14435. // var examine_other_amt float64 = 0
  14436. //
  14437. // var nursing_claa_sunmfee float64 = 0
  14438. // var nursing_clab_amt float64 = 0
  14439. // var nursing_other_amt float64 = 0
  14440. //
  14441. // var chinese_medicine_claa_sunmfee float64 = 0
  14442. // var chinese_medicine_clab_amt float64 = 0
  14443. // var chinese_medicine_other_amt float64 = 0
  14444. //
  14445. // var commonly_treatment_claa_sunmfee float64 = 0
  14446. // var commonly_treatment_clab_amt float64 = 0
  14447. // var commonly_treatment_other_amt float64 = 0
  14448. //
  14449. // var operation_claa_sunmfee float64 = 0
  14450. // var operation_clab_amt float64 = 0
  14451. // var operation_other_amt float64 = 0
  14452. //
  14453. // var other_claa_sunmfee float64 = 0
  14454. // var other_clab_amt float64 = 0
  14455. // var other_other_amt float64 = 0
  14456. //
  14457. // var westernMedicine_claa_sunmfee float64 = 0
  14458. // var westernMedicine_clab_amt float64 = 0
  14459. // var westernMedicine_other_amt float64 = 0
  14460. //
  14461. // var chineseTraditional_claa_sunmfee float64 = 0
  14462. // var chineseTraditional_clab_amt float64 = 0
  14463. // var chineseTraditional_other_amt float64 = 0
  14464. //
  14465. // var check_claa_sunmfee float64 = 0
  14466. // var check_clab_amt float64 = 0
  14467. // var check_other_amt float64 = 0
  14468. //
  14469. // var material_claa_sunmfee float64 = 0
  14470. // var material_clab_amt float64 = 0
  14471. // var material_other_amt float64 = 0
  14472. //
  14473. // var laboratory_claa_sunmfee float64 = 0
  14474. // var laboratory_clab_amt float64 = 0
  14475. // var laboratory_other_amt float64 = 0
  14476. //
  14477. // var treat_claa_sunmfee float64 = 0
  14478. // var treat_clab_amt float64 = 0
  14479. // var treat_other_amt float64 = 0
  14480. //
  14481. // var register_claa_sunmfee float64 = 0
  14482. // var register_clab_amt float64 = 0
  14483. // var register_other_amt float64 = 0
  14484. //
  14485. // for _, item := range order.HisOrderInfo {
  14486. // if item.MedChrgitmType == "01" { //床位费
  14487. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14488. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14489. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14490. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14491. // if item.ChrgitmLv == "1" {
  14492. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14493. // }
  14494. // if item.ChrgitmLv == "2" {
  14495. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14496. //
  14497. // }
  14498. // if item.ChrgitmLv == "3" {
  14499. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14500. // }
  14501. //
  14502. // }
  14503. //
  14504. // if item.MedChrgitmType == "02" { //诊查
  14505. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14506. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14507. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14508. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14509. // if item.ChrgitmLv == "1" {
  14510. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14511. // }
  14512. // if item.ChrgitmLv == "2" {
  14513. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14514. //
  14515. // }
  14516. // if item.ChrgitmLv == "3" {
  14517. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14518. // }
  14519. //
  14520. // }
  14521. //
  14522. // if item.MedChrgitmType == "03" { //检查费
  14523. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14524. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14525. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14526. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14527. // if item.ChrgitmLv == "1" {
  14528. //
  14529. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14530. //
  14531. // }
  14532. // if item.ChrgitmLv == "2" {
  14533. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14534. //
  14535. // }
  14536. // if item.ChrgitmLv == "3" {
  14537. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14538. // }
  14539. // }
  14540. //
  14541. // if item.MedChrgitmType == "04" { //化验费
  14542. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14543. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14544. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14545. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14546. // if item.ChrgitmLv == "1" {
  14547. //
  14548. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14549. //
  14550. // }
  14551. // if item.ChrgitmLv == "2" {
  14552. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14553. //
  14554. // }
  14555. // if item.ChrgitmLv == "3" {
  14556. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14557. // }
  14558. // }
  14559. //
  14560. // if item.MedChrgitmType == "05" { //治疗费
  14561. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14562. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14563. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14564. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14565. // if item.ChrgitmLv == "1" {
  14566. //
  14567. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14568. //
  14569. // }
  14570. // if item.ChrgitmLv == "2" {
  14571. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14572. //
  14573. // }
  14574. // if item.ChrgitmLv == "3" {
  14575. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14576. // }
  14577. // }
  14578. //
  14579. // if item.MedChrgitmType == "06" { //手术费
  14580. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14581. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14582. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14583. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14584. //
  14585. // if item.ChrgitmLv == "1" {
  14586. //
  14587. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14588. //
  14589. // }
  14590. // if item.ChrgitmLv == "2" {
  14591. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14592. //
  14593. // }
  14594. // if item.ChrgitmLv == "3" {
  14595. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14596. // }
  14597. // }
  14598. //
  14599. // if item.MedChrgitmType == "07" { //手术费
  14600. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14601. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14602. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14603. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14604. //
  14605. // if item.ChrgitmLv == "1" {
  14606. //
  14607. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14608. //
  14609. // }
  14610. // if item.ChrgitmLv == "2" {
  14611. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14612. //
  14613. // }
  14614. // if item.ChrgitmLv == "3" {
  14615. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14616. // }
  14617. // }
  14618. //
  14619. // if item.MedChrgitmType == "08" { //材料费
  14620. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14621. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14622. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14623. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14624. // if item.ChrgitmLv == "1" {
  14625. //
  14626. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14627. //
  14628. // }
  14629. // if item.ChrgitmLv == "2" {
  14630. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14631. //
  14632. // }
  14633. // if item.ChrgitmLv == "3" {
  14634. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14635. // }
  14636. // }
  14637. // if item.MedChrgitmType == "09" { //西药费
  14638. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14639. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14640. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14641. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14642. // if item.ChrgitmLv == "1" {
  14643. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14644. // }
  14645. // if item.ChrgitmLv == "2" {
  14646. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14647. // }
  14648. // if item.ChrgitmLv == "3" {
  14649. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14650. // }
  14651. // }
  14652. // if item.MedChrgitmType == "10" { //中药饮片
  14653. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14654. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14655. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14656. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14657. // if item.ChrgitmLv == "1" {
  14658. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14659. // }
  14660. // if item.ChrgitmLv == "2" {
  14661. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14662. // }
  14663. // if item.ChrgitmLv == "3" {
  14664. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14665. // }
  14666. // }
  14667. //
  14668. // if item.MedChrgitmType == "11" { //中成费
  14669. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14670. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14671. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14672. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14673. // if item.ChrgitmLv == "1" {
  14674. //
  14675. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14676. //
  14677. // }
  14678. // if item.ChrgitmLv == "2" {
  14679. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14680. //
  14681. // }
  14682. // if item.ChrgitmLv == "3" {
  14683. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14684. // }
  14685. // }
  14686. //
  14687. // if item.MedChrgitmType == "12" { //中成费
  14688. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14689. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14690. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14691. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14692. // if item.ChrgitmLv == "1" {
  14693. //
  14694. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14695. //
  14696. // }
  14697. // if item.ChrgitmLv == "2" {
  14698. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14699. //
  14700. // }
  14701. // if item.ChrgitmLv == "3" {
  14702. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14703. // }
  14704. // }
  14705. //
  14706. // if item.MedChrgitmType == "13" { //中成费
  14707. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14708. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14709. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14710. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14711. // if item.ChrgitmLv == "1" {
  14712. //
  14713. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14714. //
  14715. // }
  14716. // if item.ChrgitmLv == "2" {
  14717. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14718. //
  14719. // }
  14720. // if item.ChrgitmLv == "3" {
  14721. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14722. // }
  14723. // }
  14724. //
  14725. // if item.MedChrgitmType == "14" { //其他费
  14726. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14727. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14728. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14729. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14730. // if item.ChrgitmLv == "1" {
  14731. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14732. //
  14733. // }
  14734. // if item.ChrgitmLv == "2" {
  14735. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14736. //
  14737. // }
  14738. // if item.ChrgitmLv == "3" {
  14739. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14740. // }
  14741. // }
  14742. //
  14743. // }
  14744. //
  14745. // var iteminfoStructs []service.IteminfoStruct
  14746. //
  14747. // if bedCostTotal != 0 {
  14748. // iteminfo.MedChrgitm = "01"
  14749. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14750. // iteminfo.Amt = bedCostTotal
  14751. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14752. // iteminfo.ClabAmt = bed_clab_amt
  14753. // iteminfo.OthAmt = bed_other_amt
  14754. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14755. // }
  14756. //
  14757. // if examineCostTotal != 0 {
  14758. // iteminfo.MedChrgitm = "02"
  14759. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14760. // iteminfo.Amt = examineCostTotal
  14761. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14762. // iteminfo.ClabAmt = examine_clab_amt
  14763. // iteminfo.OthAmt = examine_other_amt
  14764. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14765. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14766. // }
  14767. //
  14768. // if checkCostTotal != 0 {
  14769. // iteminfo.MedChrgitm = "03"
  14770. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14771. // iteminfo.Amt = checkCostTotal
  14772. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14773. // iteminfo.ClabAmt = check_clab_amt
  14774. // iteminfo.OthAmt = check_other_amt
  14775. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14776. //
  14777. // }
  14778. //
  14779. // if laboratoryCostTotal != 0 {
  14780. // iteminfo.MedChrgitm = "04"
  14781. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14782. // iteminfo.Amt = laboratoryCostTotal
  14783. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14784. // iteminfo.ClabAmt = laboratory_clab_amt
  14785. // iteminfo.OthAmt = laboratory_other_amt
  14786. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14787. //
  14788. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14789. //
  14790. // }
  14791. //
  14792. // if treatCostTotal != 0 {
  14793. // iteminfo.MedChrgitm = "05"
  14794. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14795. // iteminfo.Amt = treatCostTotal
  14796. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14797. // iteminfo.ClabAmt = treat_clab_amt
  14798. // iteminfo.OthAmt = treat_other_amt
  14799. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14800. // //(struct4101.IteminfoStruct, iteminfo)
  14801. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14802. // }
  14803. //
  14804. // if operationCostTotal != 0 {
  14805. // iteminfo.MedChrgitm = "06"
  14806. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14807. // iteminfo.Amt = operationCostTotal
  14808. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14809. // iteminfo.ClabAmt = operation_clab_amt
  14810. // iteminfo.OthAmt = operation_other_amt
  14811. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14812. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14813. // }
  14814. //
  14815. // if nursingCostTotal != 0 {
  14816. // iteminfo.MedChrgitm = "07"
  14817. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14818. // iteminfo.Amt = nursingCostTotal
  14819. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14820. // iteminfo.ClabAmt = nursing_clab_amt
  14821. // iteminfo.OthAmt = nursing_other_amt
  14822. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14823. // }
  14824. //
  14825. // if materialCostTotal != 0 {
  14826. // iteminfo.MedChrgitm = "08"
  14827. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14828. // iteminfo.Amt = materialCostTotal
  14829. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14830. // iteminfo.ClabAmt = material_clab_amt
  14831. // iteminfo.OthAmt = material_other_amt
  14832. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14833. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14834. // }
  14835. //
  14836. // if westernMedicineCostTotal != 0 {
  14837. // iteminfo.MedChrgitm = "09"
  14838. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14839. // iteminfo.Amt = westernMedicineCostTotal
  14840. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14841. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14842. // iteminfo.OthAmt = westernMedicine_other_amt
  14843. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14844. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14845. //
  14846. // }
  14847. //
  14848. // if chineseMedicineCostTotal != 0 {
  14849. // iteminfo.MedChrgitm = "10"
  14850. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14851. // iteminfo.Amt = chineseMedicineCostTotal
  14852. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14853. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14854. // iteminfo.OthAmt = chinese_medicine_other_amt
  14855. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14856. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14857. //
  14858. // }
  14859. //
  14860. // if chineseTraditionalMedicineCostTotal != 0 {
  14861. // iteminfo.MedChrgitm = "11"
  14862. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14863. // iteminfo.Amt = westernMedicineCostTotal
  14864. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14865. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14866. // iteminfo.OthAmt = westernMedicine_other_amt
  14867. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14868. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14869. //
  14870. // }
  14871. //
  14872. // if commonlyTreatmentCostTotal != 0 {
  14873. // iteminfo.MedChrgitm = "12"
  14874. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14875. // iteminfo.Amt = commonlyTreatmentCostTotal
  14876. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14877. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14878. // iteminfo.OthAmt = commonly_treatment_other_amt
  14879. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14880. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14881. //
  14882. // }
  14883. //
  14884. // if registerCostTotal != 0 {
  14885. // iteminfo.MedChrgitm = "13"
  14886. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14887. // iteminfo.Amt = registerCostTotal
  14888. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14889. // iteminfo.ClabAmt = register_clab_amt
  14890. // iteminfo.OthAmt = register_other_amt
  14891. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14892. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14893. //
  14894. // }
  14895. //
  14896. // if otherCostTotal != 0 {
  14897. // iteminfo.MedChrgitm = "14"
  14898. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14899. // iteminfo.Amt = otherCostTotal
  14900. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14901. // iteminfo.ClabAmt = other_clab_amt
  14902. // iteminfo.OthAmt = other_other_amt
  14903. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14904. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14905. //
  14906. // }
  14907. // struct4101.IteminfoStruct = iteminfoStructs
  14908. // time_arr := strings.Split(order.SetlTime, " ")
  14909. // struct4101.AdmTime = time_arr[0]
  14910. // struct4101.AdmEndTime = time_arr[0]
  14911. //
  14912. // struct4101.DoctorName = doctor.UserName
  14913. // struct4101.DoctorCode = doctor.DoctorNumber
  14914. //
  14915. // struct4101.Ntly = "中国"
  14916. // struct4101.AdmCaty = "A03.06"
  14917. // var res ResultSeventeen
  14918. // if miConfig.MdtrtareaAdmvs == "421300" {
  14919. // data := make(map[string]interface{})
  14920. // data["struct4101"] = struct4101
  14921. // data["secret_key"] = miConfig.SecretKey
  14922. // data["org_name"] = miConfig.OrgName
  14923. // data["opera"] = curRoles.UserName
  14924. // data["code"] = miConfig.Code
  14925. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14926. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14927. //
  14928. // client := &http.Client{}
  14929. // bytesData, _ := json.Marshal(data)
  14930. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14931. // resp, _ := client.Do(req)
  14932. // defer resp.Body.Close()
  14933. // body, ioErr := ioutil.ReadAll(resp.Body)
  14934. // if ioErr != nil {
  14935. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14936. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14937. // return
  14938. // }
  14939. // var respJSON map[string]interface{}
  14940. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14941. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14943. // return
  14944. // }
  14945. //
  14946. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14947. // userJSONBytes, _ := json.Marshal(respJSON)
  14948. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14949. // utils.ErrorLog("解析失败:%v", err)
  14950. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14951. // adminUser := c.GetAdminUserInfo()
  14952. // errlog := &models.HisOrderError{
  14953. // UserOrgId: adminUser.CurrentOrgId,
  14954. // Ctime: time.Now().Unix(),
  14955. // Mtime: time.Now().Unix(),
  14956. // ErrMsg: res.ErrMsg + "解析失败",
  14957. // Status: 1,
  14958. // PatientId: order_id,
  14959. // Stage: 10088,
  14960. // }
  14961. // service.CreateErrMsgLog(errlog)
  14962. // continue
  14963. // }
  14964. //
  14965. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14966. // data := make(map[string]interface{})
  14967. // data["struct4101"] = struct4101
  14968. // data["secret_key"] = miConfig.SecretKey
  14969. // data["org_name"] = miConfig.OrgName
  14970. // data["opera"] = curRoles.UserName
  14971. // data["code"] = miConfig.Code
  14972. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14973. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14974. //
  14975. // client := &http.Client{}
  14976. // bytesData, _ := json.Marshal(data)
  14977. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14978. // resp, _ := client.Do(req)
  14979. // defer resp.Body.Close()
  14980. // body, ioErr := ioutil.ReadAll(resp.Body)
  14981. // if ioErr != nil {
  14982. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14984. // return
  14985. // }
  14986. // var respJSON map[string]interface{}
  14987. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14988. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14990. // return
  14991. // }
  14992. //
  14993. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14994. // userJSONBytes, _ := json.Marshal(respJSON)
  14995. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14996. // utils.ErrorLog("解析失败:%v", err)
  14997. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14998. // adminUser := c.GetAdminUserInfo()
  14999. // errlog := &models.HisOrderError{
  15000. // UserOrgId: adminUser.CurrentOrgId,
  15001. // Ctime: time.Now().Unix(),
  15002. // Mtime: time.Now().Unix(),
  15003. // ErrMsg: res.ErrMsg + "解析失败",
  15004. // Status: 1,
  15005. // PatientId: order_id,
  15006. // Stage: 10088,
  15007. // }
  15008. // service.CreateErrMsgLog(errlog)
  15009. // continue
  15010. // }
  15011. //
  15012. // } else {
  15013. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  15014. // fmt.Println(result)
  15015. //
  15016. // var dat map[string]interface{}
  15017. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15018. // fmt.Println(dat)
  15019. // } else {
  15020. // fmt.Println(err)
  15021. // }
  15022. // userJSONBytes, _ := json.Marshal(dat)
  15023. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15024. // utils.ErrorLog("解析失败:%v", err)
  15025. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15026. // adminUser := c.GetAdminUserInfo()
  15027. // errlog := &models.HisOrderError{
  15028. // UserOrgId: adminUser.CurrentOrgId,
  15029. // Ctime: time.Now().Unix(),
  15030. // Mtime: time.Now().Unix(),
  15031. // ErrMsg: res.ErrMsg + "解析失败",
  15032. // Status: 1,
  15033. // PatientId: order_id,
  15034. // Stage: 10106,
  15035. // }
  15036. // service.CreateErrMsgLog(errlog)
  15037. // continue
  15038. // }
  15039. // }
  15040. //
  15041. // if res.Infcode != 0 {
  15042. // adminUser := c.GetAdminUserInfo()
  15043. // errlog := &models.HisOrderError{
  15044. // UserOrgId: adminUser.CurrentOrgId,
  15045. // Ctime: time.Now().Unix(),
  15046. // Mtime: time.Now().Unix(),
  15047. // ErrMsg: res.ErrMsg,
  15048. // Status: 1,
  15049. // PatientId: order_id,
  15050. // Stage: 10106,
  15051. // }
  15052. // service.CreateErrMsgLog(errlog)
  15053. // continue
  15054. // } else {
  15055. // hisFundSettleListResult := &models.HisFundSettleListResult{
  15056. // Number: res.Output.SetlListId,
  15057. // Status: 1,
  15058. // Ctime: time.Now().Unix(),
  15059. // Mtime: time.Now().Unix(),
  15060. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15061. // IsUpload: 1,
  15062. // OrderId: order_id,
  15063. // }
  15064. // service.CreateUploadRecord(hisFundSettleListResult)
  15065. // continue
  15066. // }
  15067. // }
  15068. //}
  15069. func (c *HisApiController) GetOrgInfo() {
  15070. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  15071. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  15072. }
  15073. func (c *HisApiController) GetHisPatientInfo() {
  15074. medical_insurance_card := c.GetString("medical_insurance_card")
  15075. id_card_type, _ := c.GetInt64("id_card_type")
  15076. id_card := c.GetString("id_card")
  15077. adminInfo := c.GetAdminUserInfo()
  15078. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15079. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15080. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  15081. IdCardNo := ""
  15082. if id_card_type == 1 {
  15083. IdCardNo = medical_insurance_card
  15084. } else if id_card_type == 2 {
  15085. IdCardNo = id_card
  15086. }
  15087. if config.IsOpen == 1 {
  15088. 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
  15089. resp, requestErr := http.Get(api)
  15090. if requestErr != nil {
  15091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15092. return
  15093. }
  15094. defer resp.Body.Close()
  15095. body, ioErr := ioutil.ReadAll(resp.Body)
  15096. if ioErr != nil {
  15097. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15099. return
  15100. }
  15101. var respJSON map[string]interface{}
  15102. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15103. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15105. return
  15106. }
  15107. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15108. userJSONBytes, _ := json.Marshal(userJSON)
  15109. var res ResultTwo
  15110. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15111. utils.ErrorLog("解析失败:%v", err)
  15112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15113. return
  15114. }
  15115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15116. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15117. infoStr := string(Iinfos)
  15118. idetinfoStr := string(Idetinfos)
  15119. if res.Infcode == 0 {
  15120. his := models.VMHisPatient{
  15121. Status: 1,
  15122. Ctime: time.Now().Unix(),
  15123. Mtime: time.Now().Unix(),
  15124. PsnNo: res.Output.Baseinfo.PsnNo,
  15125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15126. Certno: res.Output.Baseinfo.Certno,
  15127. PsnName: res.Output.Baseinfo.PsnName,
  15128. Gend: res.Output.Baseinfo.Gend,
  15129. Naty: res.Output.Baseinfo.Naty,
  15130. Iinfo: infoStr,
  15131. Idetinfo: idetinfoStr,
  15132. UserOrgId: adminInfo.CurrentOrgId,
  15133. IsReturn: 1,
  15134. IdCardType: id_card_type,
  15135. }
  15136. c.ServeSuccessJSON(map[string]interface{}{
  15137. "info": his,
  15138. })
  15139. } else {
  15140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15141. return
  15142. }
  15143. }
  15144. }
  15145. //func GetBasBaseInfo() (jsonStr string, err error) {
  15146. //
  15147. // handle := syscall.NewLazyDLL("SSCard.dll")
  15148. // add := handle.NewProc("ReadCardBas")
  15149. // str := make([]byte, 1024)
  15150. // str1 := make([]byte, 1024)
  15151. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15152. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15153. //
  15154. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15155. //
  15156. // fmt.Println("> Add(4,5)的结果为:", ret)
  15157. // handle.Release()
  15158. //
  15159. // return "", nil
  15160. //
  15161. //}
  15162. //func GetQRBaseInfo() (jsonStr string, err error) {
  15163. // handle := syscall.LoadDLL("SSCard.dll")
  15164. // ReadCardBas := handle.FindProc("GetQRBase")
  15165. //
  15166. // str := make([]byte, 256)
  15167. // str1 := make([]byte, 256)
  15168. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15169. //
  15170. // fmt.Println(string(str))
  15171. // fmt.Println(r)
  15172. // return string(str), nil
  15173. //}
  15174. //func CardInit() int {
  15175. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15176. // add := DllTestDef.MustFindProc("Init")
  15177. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15178. // if err != nil {
  15179. // fmt.Println("SSCard的运算结果为:", ret)
  15180. // }
  15181. // result := int(ret)
  15182. // return result
  15183. //}
  15184. //func CardInit() int {
  15185. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15186. // if err != nil {
  15187. // fmt.Println("SSCard的运算结果为:", ret)
  15188. // }
  15189. // fmt.Println(err)
  15190. // result := int(ret)
  15191. // return result
  15192. //}
  15193. func IntPtr(n int) uintptr {
  15194. return uintptr(n)
  15195. }
  15196. func StrPtr(s string) uintptr {
  15197. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15198. }
  15199. type Result2001 struct {
  15200. Cainfo interface{} `json:"cainfo"`
  15201. ErrMsg string `json:"err_msg"`
  15202. InfRefmsgid string `json:"inf_refmsgid"`
  15203. Infcode int64 `json:"infcode"`
  15204. Output struct {
  15205. Trtinfo struct {
  15206. PsnNo string `json:"psn_no"`
  15207. TrtChkType string `json:"trt_chk_type"`
  15208. FundPayType string `json:"fund_pay_type"`
  15209. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15210. Begndate string `json:"begndate"`
  15211. Enddate string `json:"enddate"`
  15212. TrtChkRslt string `json:"trt_chk_rslt"`
  15213. } `json:"trtinfo"`
  15214. } `json:"output"`
  15215. RefmsgTime string `json:"refmsg_time"`
  15216. RespondTime string `json:"respond_time"`
  15217. Signtype interface{} `json:"signtype"`
  15218. WarnMsg interface{} `json:"warn_msg"`
  15219. }
  15220. type Result2001Org10265 struct {
  15221. Cainfo interface{} `json:"cainfo"`
  15222. ErrMsg string `json:"err_msg"`
  15223. InfRefmsgid string `json:"inf_refmsgid"`
  15224. Infcode string `json:"infcode"`
  15225. Output struct {
  15226. Trtinfo struct {
  15227. PsnNo string `json:"psn_no"`
  15228. TrtChkType string `json:"trt_chk_type"`
  15229. FundPayType string `json:"fund_pay_type"`
  15230. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15231. Begndate string `json:"begndate"`
  15232. Enddate string `json:"enddate"`
  15233. TrtChkRslt string `json:"trt_chk_rslt"`
  15234. } `json:"trtinfo"`
  15235. } `json:"output"`
  15236. RefmsgTime string `json:"refmsg_time"`
  15237. RespondTime string `json:"respond_time"`
  15238. Signtype interface{} `json:"signtype"`
  15239. WarnMsg interface{} `json:"warn_msg"`
  15240. }
  15241. type ResultTwo struct {
  15242. ErrMsg string `json:"err_msg"`
  15243. InfRefmsgid string `json:"inf_refmsgid"`
  15244. Infcode int64 `json:"infcode"`
  15245. Output struct {
  15246. Baseinfo struct {
  15247. //Brdy string `json:"brdy"`
  15248. Certno string `json:"certno"`
  15249. Gend string `json:"gend"`
  15250. Naty string `json:"naty"`
  15251. PsnCertType string `json:"psn_cert_type"`
  15252. PsnName string `json:"psn_name"`
  15253. PsnNo string `json:"psn_no"`
  15254. } `json:"baseinfo"`
  15255. Idetinfo []interface{} `json:"idetinfo"`
  15256. Iinfo []struct {
  15257. Balc float64 `json:"balc"`
  15258. CvlservFlag string `json:"cvlserv_flag"`
  15259. EmpName string `json:"emp_name"`
  15260. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15261. Insutype string `json:"insutype"`
  15262. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15263. //PausInsuDate string `json:"paus_insu_date"`
  15264. //PsnInsuDate string `json:"psn_insu_date"`
  15265. PsnInsuStas string `json:"psn_insu_stas"`
  15266. PsnType string `json:"psn_type"`
  15267. } `json:"insuinfo"`
  15268. } `json:"output"`
  15269. RefmsgTime string `json:"refmsg_time"`
  15270. RespondTime string `json:"respond_time"`
  15271. Signtype interface{} `json:"signtype"`
  15272. WarnInfo interface{} `json:"warn_info"`
  15273. }
  15274. type ResultTwo10265 struct {
  15275. ErrMsg string `json:"err_msg"`
  15276. InfRefmsgid string `json:"inf_refmsgid"`
  15277. Infcode string `json:"infcode"`
  15278. Output struct {
  15279. Baseinfo struct {
  15280. //Brdy string `json:"brdy"`
  15281. Certno string `json:"certno"`
  15282. Gend string `json:"gend"`
  15283. Naty string `json:"naty"`
  15284. PsnCertType string `json:"psn_cert_type"`
  15285. PsnName string `json:"psn_name"`
  15286. PsnNo string `json:"psn_no"`
  15287. } `json:"baseinfo"`
  15288. Idetinfo []interface{} `json:"idetinfo"`
  15289. Iinfo []struct {
  15290. Balc float64 `json:"balc"`
  15291. CvlservFlag string `json:"cvlserv_flag"`
  15292. EmpName string `json:"emp_name"`
  15293. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15294. Insutype string `json:"insutype"`
  15295. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15296. PsnInsuStas string `json:"psn_insu_stas"`
  15297. PsnType string `json:"psn_type"`
  15298. } `json:"insuinfo"`
  15299. } `json:"output"`
  15300. RefmsgTime string `json:"refmsg_time"`
  15301. RespondTime string `json:"respond_time"`
  15302. Signtype interface{} `json:"signtype"`
  15303. WarnInfo interface{} `json:"warn_info"`
  15304. }
  15305. type ResultThree struct {
  15306. Cainfo interface{} `json:"cainfo"`
  15307. ErrMsg string `json:"err_msg"`
  15308. InfRefmsgid string `json:"inf_refmsgid"`
  15309. Infcode int64 `json:"infcode"`
  15310. Output struct {
  15311. Data struct {
  15312. IptOtpNo string `json:"ipt_otp_no"`
  15313. MdtrtID string `json:"mdtrt_id"`
  15314. PsnNo string `json:"psn_no"`
  15315. } `json:"data"`
  15316. } `json:"output"`
  15317. RefmsgTime string `json:"refmsg_time"`
  15318. RespondTime string `json:"respond_time"`
  15319. Signtype interface{} `json:"signtype"`
  15320. WarnMsg interface{} `json:"warn_msg"`
  15321. }
  15322. type ResultThree10265 struct {
  15323. Cainfo interface{} `json:"cainfo"`
  15324. ErrMsg string `json:"err_msg"`
  15325. InfRefmsgid string `json:"inf_refmsgid"`
  15326. Infcode string `json:"infcode"`
  15327. Output struct {
  15328. Data struct {
  15329. IptOtpNo string `json:"ipt_otp_no"`
  15330. MdtrtID string `json:"mdtrt_id"`
  15331. PsnNo string `json:"psn_no"`
  15332. } `json:"data"`
  15333. } `json:"output"`
  15334. RefmsgTime string `json:"refmsg_time"`
  15335. RespondTime string `json:"respond_time"`
  15336. Signtype interface{} `json:"signtype"`
  15337. WarnMsg interface{} `json:"warn_msg"`
  15338. }
  15339. type ResultFour struct {
  15340. Cainfo string `json:"cainfo"`
  15341. ErrMsg string `json:"err_msg"`
  15342. InfRefmsgid string `json:"inf_refmsgid"`
  15343. Infcode int64 `json:"infcode"`
  15344. Output struct {
  15345. Result []struct {
  15346. BasMednFlag string `json:"bas_medn_flag"`
  15347. ChldMedcFlag string `json:"chld_medc_flag"`
  15348. ChrgitmLv string `json:"chrgitm_lv"`
  15349. Cnt float64 `json:"cnt"`
  15350. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15351. DrtReimFlag string `json:"drt_reim_flag"`
  15352. FeedetlSn string `json:"feedetl_sn"`
  15353. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15354. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15355. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15356. ListSpItemFlag string `json:"list_sp_item_flag"`
  15357. LmtUsedFlag string `json:"lmt_used_flag"`
  15358. MedChrgitmType string `json:"med_chrgitm_type"`
  15359. Memo string `json:"memo"`
  15360. OverlmtAmt float64 `json:"overlmt_amt"`
  15361. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15362. Pric float64 `json:"pric"`
  15363. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15364. SelfpayProp float64 `json:"selfpay_prop"`
  15365. } `json:"result"`
  15366. } `json:"output"`
  15367. RefmsgTime string `json:"refmsg_time"`
  15368. RespondTime string `json:"respond_time"`
  15369. Signtype string `json:"signtype"`
  15370. WarnMsg string `json:"warn_msg"`
  15371. }
  15372. type ResultFour10265 struct {
  15373. Cainfo string `json:"cainfo"`
  15374. ErrMsg string `json:"err_msg"`
  15375. InfRefmsgid string `json:"inf_refmsgid"`
  15376. Infcode string `json:"infcode"`
  15377. Output struct {
  15378. Result []struct {
  15379. BasMednFlag string `json:"bas_medn_flag"`
  15380. ChldMedcFlag string `json:"chld_medc_flag"`
  15381. ChrgitmLv string `json:"chrgitm_lv"`
  15382. Cnt float64 `json:"cnt"`
  15383. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15384. DrtReimFlag string `json:"drt_reim_flag"`
  15385. FeedetlSn string `json:"feedetl_sn"`
  15386. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15387. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15388. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15389. ListSpItemFlag string `json:"list_sp_item_flag"`
  15390. LmtUsedFlag string `json:"lmt_used_flag"`
  15391. MedChrgitmType string `json:"med_chrgitm_type"`
  15392. Memo string `json:"memo"`
  15393. OverlmtAmt float64 `json:"overlmt_amt"`
  15394. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15395. Pric float64 `json:"pric"`
  15396. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15397. SelfpayProp float64 `json:"selfpay_prop"`
  15398. } `json:"result"`
  15399. } `json:"output"`
  15400. RefmsgTime string `json:"refmsg_time"`
  15401. RespondTime string `json:"respond_time"`
  15402. Signtype string `json:"signtype"`
  15403. WarnMsg string `json:"warn_msg"`
  15404. }
  15405. type ResultMemo struct {
  15406. InsuAdmdvs string `json:"insuAdmdvs"`
  15407. }
  15408. // [{"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}]
  15409. type ResultIDInfo struct {
  15410. Begntime string `json:"begntime"`
  15411. Endtime string `json:"endtime"`
  15412. Memo string `json:"memo"`
  15413. }
  15414. type ResultFive struct {
  15415. Balc float64 `json:"balc"`
  15416. CvlservFlag string `json:"cvlserv_flag"`
  15417. EmpName string `json:"emp_name"`
  15418. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15419. Insutype string `json:"insutype"`
  15420. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15421. PausInsuDate string `json:"paus_insu_date"`
  15422. PsnInsuDate string `json:"psn_insu_date"`
  15423. PsnInsuStas string `json:"psn_insu_stas"`
  15424. PsnType string `json:"psn_type"`
  15425. }
  15426. type ResultSix struct {
  15427. Cainfo interface{} `json:"cainfo"`
  15428. ErrMsg string `json:"err_msg"`
  15429. InfRefmsgid string `json:"inf_refmsgid"`
  15430. Infcode int64 `json:"infcode"`
  15431. Output struct {
  15432. } `json:"output"`
  15433. RefmsgTime string `json:"refmsg_time"`
  15434. RespondTime string `json:"respond_time"`
  15435. Signtype interface{} `json:"signtype"`
  15436. WarnMsg interface{} `json:"warn_msg"`
  15437. }
  15438. type Result2406 struct {
  15439. Cainfo interface{} `json:"cainfo"`
  15440. ErrMsg string `json:"err_msg"`
  15441. InfRefmsgid string `json:"inf_refmsgid"`
  15442. Infcode int64 `json:"infcode"`
  15443. Output struct {
  15444. Result struct {
  15445. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15446. } `json:"result"`
  15447. } `json:"output"`
  15448. RefmsgTime string `json:"refmsg_time"`
  15449. RespondTime string `json:"respond_time"`
  15450. Signtype interface{} `json:"signtype"`
  15451. WarnMsg interface{} `json:"warn_msg"`
  15452. }
  15453. type GZResultSix struct {
  15454. Cainfo interface{} `json:"cainfo"`
  15455. ErrMsg string `json:"err_msg"`
  15456. InfRefmsgid string `json:"inf_refmsgid"`
  15457. Infcode int64 `json:"infcode"`
  15458. Output string `json:"output"`
  15459. RefmsgTime string `json:"refmsg_time"`
  15460. RespondTime string `json:"respond_time"`
  15461. Signtype interface{} `json:"signtype"`
  15462. WarnMsg interface{} `json:"warn_msg"`
  15463. }
  15464. type ResultSix10265 struct {
  15465. Cainfo interface{} `json:"cainfo"`
  15466. ErrMsg string `json:"err_msg"`
  15467. InfRefmsgid string `json:"inf_refmsgid"`
  15468. Infcode string `json:"infcode"`
  15469. Output struct {
  15470. } `json:"output"`
  15471. RefmsgTime string `json:"refmsg_time"`
  15472. RespondTime string `json:"respond_time"`
  15473. Signtype interface{} `json:"signtype"`
  15474. WarnMsg interface{} `json:"warn_msg"`
  15475. }
  15476. type ResultSeven struct {
  15477. Cainfo string `json:"cainfo"`
  15478. ErrMsg string `json:"err_msg"`
  15479. InfRefmsgid string `json:"inf_refmsgid"`
  15480. Infcode int64 `json:"infcode"`
  15481. Output struct {
  15482. Setlinfo struct {
  15483. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15484. AcctPay float64 `json:"acct_pay"`
  15485. ActPayDedc float64 `json:"act_pay_dedc"`
  15486. Age float64 `json:"age"`
  15487. Balc float64 `json:"balc"`
  15488. Certno string `json:"certno"`
  15489. ClrOptins string `json:"clr_optins"`
  15490. ClrType string `json:"clr_type"`
  15491. ClrWay string `json:"clr_way"`
  15492. CvlservFlag string `json:"cvlserv_flag"`
  15493. CvlservPay float64 `json:"cvlserv_pay"`
  15494. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15495. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15496. Gend string `json:"gend"`
  15497. HifesPay float64 `json:"hifes_pay"`
  15498. HifmiPay float64 `json:"hifmi_pay"`
  15499. HifpPay float64 `json:"hifp_pay"`
  15500. HospPartAmt float64 `json:"hosp_part_amt"`
  15501. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15502. Insutype string `json:"insutype"`
  15503. MafPay float64 `json:"maf_pay"`
  15504. MdtrtCertType string `json:"mdtrt_cert_type"`
  15505. HifobPay float64 `json:"hifob_pay"`
  15506. MdtrtID string `json:"mdtrt_id"`
  15507. MedType string `json:"med_type"`
  15508. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15509. MedinsSetlID string `json:"medins_setl_id"`
  15510. Naty string `json:"naty"`
  15511. OthPay float64 `json:"oth_pay"`
  15512. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15513. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15514. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15515. PsnCashPay float64 `json:"psn_cash_pay"`
  15516. PsnCertType string `json:"psn_cert_type"`
  15517. PsnName string `json:"psn_name"`
  15518. PsnNo string `json:"psn_no"`
  15519. PsnPartAmt float64 `json:"psn_part_amt"`
  15520. PsnType string `json:"psn_type"`
  15521. SetlID string `json:"setl_id"`
  15522. SetlTime string `json:"setl_time"`
  15523. } `json:"setlinfo"`
  15524. Setldetail interface{} `json:"setldetail"`
  15525. } `json:"output"`
  15526. RefmsgTime string `json:"refmsg_time"`
  15527. RespondTime string `json:"respond_time"`
  15528. Signtype interface{} `json:"signtype"`
  15529. WarnMsg interface{} `json:"warn_msg"`
  15530. }
  15531. type ResultSevenAH struct {
  15532. Cainfo string `json:"cainfo"`
  15533. ErrMsg string `json:"err_msg"`
  15534. InfRefmsgid string `json:"inf_refmsgid"`
  15535. Infcode int64 `json:"infcode"`
  15536. Output struct {
  15537. Setlinfo struct {
  15538. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15539. AcctPay float64 `json:"acct_pay"`
  15540. ActPayDedc float64 `json:"act_pay_dedc"`
  15541. Age float64 `json:"age"`
  15542. Balc float64 `json:"balc"`
  15543. Certno string `json:"certno"`
  15544. ClrOptins string `json:"clr_optins"`
  15545. ClrType string `json:"clr_type"`
  15546. ClrWay string `json:"clr_way"`
  15547. CvlservFlag string `json:"cvlserv_flag"`
  15548. CvlservPay float64 `json:"cvlserv_pay"`
  15549. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15550. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15551. Gend string `json:"gend"`
  15552. HifesPay float64 `json:"hifes_pay"`
  15553. HifmiPay float64 `json:"hifmi_pay"`
  15554. HifpPay float64 `json:"hifp_pay"`
  15555. HospPartAmt float64 `json:"hosp_part_amt"`
  15556. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15557. Insutype string `json:"insutype"`
  15558. MafPay float64 `json:"maf_pay"`
  15559. MdtrtCertType string `json:"mdtrt_cert_type"`
  15560. HifobPay float64 `json:"hifob_pay"`
  15561. MdtrtID string `json:"mdtrt_id"`
  15562. MedType string `json:"med_type"`
  15563. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15564. MedinsSetlID string `json:"medins_setl_id"`
  15565. Naty string `json:"naty"`
  15566. OthPay float64 `json:"oth_pay"`
  15567. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15568. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15569. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15570. PsnCashPay float64 `json:"psn_cash_pay"`
  15571. PsnCertType string `json:"psn_cert_type"`
  15572. PsnName string `json:"psn_name"`
  15573. PsnNo string `json:"psn_no"`
  15574. PsnPartAmt float64 `json:"psn_part_amt"`
  15575. PsnType string `json:"psn_type"`
  15576. SetlID string `json:"setl_id"`
  15577. SetlTime int64 `json:"setl_time"`
  15578. } `json:"setlinfo"`
  15579. Setldetail interface{} `json:"setldetail"`
  15580. } `json:"output"`
  15581. RefmsgTime string `json:"refmsg_time"`
  15582. RespondTime string `json:"respond_time"`
  15583. Signtype interface{} `json:"signtype"`
  15584. WarnMsg interface{} `json:"warn_msg"`
  15585. }
  15586. type ResultSeven10265 struct {
  15587. Cainfo string `json:"cainfo"`
  15588. ErrMsg string `json:"err_msg"`
  15589. InfRefmsgid string `json:"inf_refmsgid"`
  15590. Infcode string `json:"infcode"`
  15591. Output struct {
  15592. Setlinfo struct {
  15593. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15594. AcctPay float64 `json:"acct_pay"`
  15595. ActPayDedc float64 `json:"act_pay_dedc"`
  15596. Age float64 `json:"age"`
  15597. Balc float64 `json:"balc"`
  15598. Certno string `json:"certno"`
  15599. ClrOptins string `json:"clr_optins"`
  15600. ClrType string `json:"clr_type"`
  15601. ClrWay string `json:"clr_way"`
  15602. CvlservFlag string `json:"cvlserv_flag"`
  15603. CvlservPay float64 `json:"cvlserv_pay"`
  15604. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15605. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15606. Gend string `json:"gend"`
  15607. HifesPay float64 `json:"hifes_pay"`
  15608. HifmiPay float64 `json:"hifmi_pay"`
  15609. HifpPay float64 `json:"hifp_pay"`
  15610. HospPartAmt float64 `json:"hosp_part_amt"`
  15611. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15612. Insutype string `json:"insutype"`
  15613. MafPay float64 `json:"maf_pay"`
  15614. MdtrtCertType string `json:"mdtrt_cert_type"`
  15615. HifobPay float64 `json:"hifob_pay"`
  15616. MdtrtID string `json:"mdtrt_id"`
  15617. MedType string `json:"med_type"`
  15618. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15619. MedinsSetlID string `json:"medins_setl_id"`
  15620. Naty string `json:"naty"`
  15621. OthPay float64 `json:"oth_pay"`
  15622. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15623. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15624. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15625. PsnCashPay float64 `json:"psn_cash_pay"`
  15626. PsnCertType string `json:"psn_cert_type"`
  15627. PsnName string `json:"psn_name"`
  15628. PsnNo string `json:"psn_no"`
  15629. PsnPartAmt float64 `json:"psn_part_amt"`
  15630. PsnType string `json:"psn_type"`
  15631. SetlID string `json:"setl_id"`
  15632. SetlTime string `json:"setl_time"`
  15633. } `json:"setlinfo"`
  15634. Setldetail interface{} `json:"setldetail"`
  15635. } `json:"output"`
  15636. RefmsgTime string `json:"refmsg_time"`
  15637. RespondTime string `json:"respond_time"`
  15638. Signtype interface{} `json:"signtype"`
  15639. WarnMsg interface{} `json:"warn_msg"`
  15640. }
  15641. type ResultSeven10265Two struct {
  15642. Cainfo string `json:"cainfo"`
  15643. ErrMsg string `json:"err_msg"`
  15644. InfRefmsgid string `json:"inf_refmsgid"`
  15645. Infcode string `json:"infcode"`
  15646. Output struct {
  15647. Setlinfo struct {
  15648. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15649. AcctPay float64 `json:"acct_pay"`
  15650. ActPayDedc float64 `json:"act_pay_dedc"`
  15651. Age float64 `json:"age"`
  15652. Balc float64 `json:"balc"`
  15653. Certno string `json:"certno"`
  15654. ClrOptins string `json:"clr_optins"`
  15655. ClrType string `json:"clr_type"`
  15656. ClrWay string `json:"clr_way"`
  15657. CvlservFlag string `json:"cvlserv_flag"`
  15658. CvlservPay float64 `json:"cvlserv_pay"`
  15659. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15660. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15661. Gend string `json:"gend"`
  15662. HifesPay float64 `json:"hifes_pay"`
  15663. HifmiPay float64 `json:"hifmi_pay"`
  15664. HifpPay float64 `json:"hifp_pay"`
  15665. HospPartAmt string `json:"hosp_part_amt"`
  15666. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15667. Insutype string `json:"insutype"`
  15668. MafPay float64 `json:"maf_pay"`
  15669. MdtrtCertType string `json:"mdtrt_cert_type"`
  15670. HifobPay float64 `json:"hifob_pay"`
  15671. MdtrtID string `json:"mdtrt_id"`
  15672. MedType string `json:"med_type"`
  15673. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15674. MedinsSetlID string `json:"medins_setl_id"`
  15675. Naty string `json:"naty"`
  15676. OthPay float64 `json:"oth_pay"`
  15677. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15678. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15679. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15680. PsnCashPay float64 `json:"psn_cash_pay"`
  15681. PsnCertType string `json:"psn_cert_type"`
  15682. PsnName string `json:"psn_name"`
  15683. PsnNo string `json:"psn_no"`
  15684. PsnPartAmt float64 `json:"psn_part_amt"`
  15685. PsnType string `json:"psn_type"`
  15686. SetlID string `json:"setl_id"`
  15687. SetlTime string `json:"setl_time"`
  15688. } `json:"setlinfo"`
  15689. Setldetail interface{} `json:"setldetail"`
  15690. } `json:"output"`
  15691. RefmsgTime string `json:"refmsg_time"`
  15692. RespondTime string `json:"respond_time"`
  15693. Signtype interface{} `json:"signtype"`
  15694. WarnMsg interface{} `json:"warn_msg"`
  15695. }
  15696. type GZResultSeven10265Two struct {
  15697. Cainfo string `json:"cainfo"`
  15698. ErrMsg string `json:"err_msg"`
  15699. InfRefmsgid string `json:"inf_refmsgid"`
  15700. Infcode int64 `json:"infcode"`
  15701. Output struct {
  15702. Setlinfo struct {
  15703. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15704. AcctPay float64 `json:"acct_pay"`
  15705. ActPayDedc float64 `json:"act_pay_dedc"`
  15706. Age float64 `json:"age"`
  15707. Balc float64 `json:"balc"`
  15708. Certno string `json:"certno"`
  15709. ClrOptins string `json:"clr_optins"`
  15710. ClrType string `json:"clr_type"`
  15711. ClrWay string `json:"clr_way"`
  15712. CvlservFlag string `json:"cvlserv_flag"`
  15713. CvlservPay float64 `json:"cvlserv_pay"`
  15714. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15715. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15716. Gend string `json:"gend"`
  15717. HifesPay float64 `json:"hifes_pay"`
  15718. HifmiPay float64 `json:"hifmi_pay"`
  15719. HifpPay float64 `json:"hifp_pay"`
  15720. HospPartAmt float64 `json:"hosp_part_amt"`
  15721. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15722. Insutype string `json:"insutype"`
  15723. MafPay float64 `json:"maf_pay"`
  15724. MdtrtCertType string `json:"mdtrt_cert_type"`
  15725. HifobPay float64 `json:"hifob_pay"`
  15726. MdtrtID string `json:"mdtrt_id"`
  15727. MedType string `json:"med_type"`
  15728. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15729. MedinsSetlID string `json:"medins_setl_id"`
  15730. Naty string `json:"naty"`
  15731. OthPay float64 `json:"oth_pay"`
  15732. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15733. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15734. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15735. PsnCashPay float64 `json:"psn_cash_pay"`
  15736. PsnCertType string `json:"psn_cert_type"`
  15737. PsnName string `json:"psn_name"`
  15738. PsnNo string `json:"psn_no"`
  15739. PsnPartAmt float64 `json:"psn_part_amt"`
  15740. PsnType string `json:"psn_type"`
  15741. SetlID string `json:"setl_id"`
  15742. SetlTime string `json:"setl_time"`
  15743. } `json:"setlinfo"`
  15744. Setldetail interface{} `json:"setldetail"`
  15745. } `json:"output"`
  15746. RefmsgTime string `json:"refmsg_time"`
  15747. RespondTime string `json:"respond_time"`
  15748. Signtype interface{} `json:"signtype"`
  15749. WarnMsg interface{} `json:"warn_msg"`
  15750. }
  15751. type ResultEight struct {
  15752. Cainfo string `json:"cainfo"`
  15753. ErrMsg string `json:"err_msg"`
  15754. InfRefmsgid string `json:"inf_refmsgid"`
  15755. Infcode int64 `json:"infcode"`
  15756. Output struct {
  15757. Stmtinfo struct {
  15758. SetlOptins string `json:"setl_optins"`
  15759. StmtRslt string `json:"stmt_rslt"`
  15760. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15761. } `json:"stmtinfo"`
  15762. } `json:"output"`
  15763. RefmsgTime string `json:"refmsg_time"`
  15764. RespondTime string `json:"respond_time"`
  15765. Signtype interface{} `json:"signtype"`
  15766. WarnMsg interface{} `json:"warn_msg"`
  15767. }
  15768. type ResultEightFor10188 struct {
  15769. Cainfo string `json:"cainfo"`
  15770. ErrMsg string `json:"err_msg"`
  15771. InfRefmsgid string `json:"inf_refmsgid"`
  15772. Infcode string `json:"infcode"`
  15773. Output struct {
  15774. Stmtinfo struct {
  15775. SetlOptins string `json:"setl_optins"`
  15776. StmtRslt string `json:"stmt_rslt"`
  15777. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15778. } `json:"stmtinfo"`
  15779. } `json:"output"`
  15780. RefmsgTime string `json:"refmsg_time"`
  15781. RespondTime string `json:"respond_time"`
  15782. Signtype interface{} `json:"signtype"`
  15783. WarnMsg interface{} `json:"warn_msg"`
  15784. }
  15785. type ResultNine struct {
  15786. Cainfo string `json:"cainfo"`
  15787. ErrMsg string `json:"err_msg"`
  15788. InfRefmsgid string `json:"inf_refmsgid"`
  15789. Infcode int64 `json:"infcode"`
  15790. Output struct {
  15791. FileQuryNo string `json:"file_qury_no"`
  15792. } `json:"output"`
  15793. RefmsgTime string `json:"refmsg_time"`
  15794. RespondTime string `json:"respond_time"`
  15795. Signtype interface{} `json:"signtype"`
  15796. WarnMsg interface{} `json:"warn_msg"`
  15797. }
  15798. type ResultTen struct {
  15799. Cainfo string `json:"cainfo"`
  15800. ErrMsg string `json:"err_msg"`
  15801. InfRefmsgid string `json:"inf_refmsgid"`
  15802. Infcode int64 `json:"infcode"`
  15803. Output struct {
  15804. Fileinfo struct {
  15805. DldEndtime string `json:"dld_endtime"`
  15806. FileQuryNo string `json:"file_qury_no"`
  15807. Filename string `json:"filename"`
  15808. } `json:"fileinfo"`
  15809. } `json:"output"`
  15810. RefmsgTime string `json:"refmsg_time"`
  15811. RespondTime string `json:"respond_time"`
  15812. Signtype interface{} `json:"signtype"`
  15813. WarnMsg interface{} `json:"warn_msg"`
  15814. }
  15815. type Result5262 struct {
  15816. ErrMsg string `json:"err_msg"`
  15817. InfRefmsgid string `json:"inf_refmsgid"`
  15818. Infcode int64 `json:"infcode"`
  15819. Output struct {
  15820. PageInfo struct {
  15821. Size int `json:"size"`
  15822. RecordCounts int `json:"record_counts"`
  15823. } `json:"page_info"`
  15824. Idetinfo []interface{} `json:"idetinfo"`
  15825. Result []struct {
  15826. SetlID string `json:"setl_id"`
  15827. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15828. MdtrtID string `json:"mdtrt_id"`
  15829. InitSetlID string `json:"init_setl_id,omitempty"`
  15830. PsnNo string `json:"psn_no"`
  15831. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15832. PsnName string `json:"psn_name"`
  15833. PsnCertType string `json:"psn_cert_type"`
  15834. Certno string `json:"certno"`
  15835. Gend string `json:"gend,omitempty"`
  15836. Naty string `json:"naty,omitempty"`
  15837. Brdy string `json:"brdy,omitempty"`
  15838. Age float64 `json:"age,omitempty"`
  15839. Insutype string `json:"insutype,omitempty"`
  15840. PsnType string `json:"psn_type"`
  15841. CvlservFlag string `json:"cvlserv_flag"`
  15842. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15843. SpPsnType string `json:"sp_psn_type,omitempty"`
  15844. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15845. ClctGrde string `json:"clct_grde,omitempty"`
  15846. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15847. NwbFlag string `json:"nwb_flag,omitempty"`
  15848. InsuAdmdvs string `json:"insu_admdvs"`
  15849. EmpNo string `json:"emp_no,omitempty"`
  15850. EmpName string `json:"emp_name,omitempty"`
  15851. EmpType string `json:"emp_type,omitempty"`
  15852. EconType string `json:"econ_type,omitempty"`
  15853. AfilIndu string `json:"afil_indu,omitempty"`
  15854. AfilRlts string `json:"afil_rlts,omitempty"`
  15855. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15856. PayLoc string `json:"pay_loc,omitempty"`
  15857. FixmedinsCode string `json:"fixmedins_code"`
  15858. FixmedinsName string `json:"fixmedins_name"`
  15859. HospLv string `json:"hosp_lv,omitempty"`
  15860. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15861. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15862. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15863. Begndate string `json:"begndate"`
  15864. Enddate string `json:"enddate"`
  15865. SetlTime string `json:"setl_time"`
  15866. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15867. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15868. MedType string `json:"med_type"`
  15869. SetlType string `json:"setl_type,omitempty"`
  15870. ClrType string `json:"clr_type,omitempty"`
  15871. ClrWay string `json:"clr_way,omitempty"`
  15872. PsnSetlway string `json:"psn_setlway,omitempty"`
  15873. ClrOptins string `json:"clr_optins,omitempty"`
  15874. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15875. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15876. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15877. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15878. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15879. DedcStd float64 `json:"dedc_std,omitempty"`
  15880. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15881. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15882. HifpPay float64 `json:"hifp_pay,omitempty"`
  15883. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15884. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15885. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15886. HifesPay float64 `json:"hifes_pay,omitempty"`
  15887. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15888. HifobPay float64 `json:"hifob_pay,omitempty"`
  15889. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15890. MafPay float64 `json:"maf_pay,omitempty"`
  15891. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15892. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15893. PsnPay float64 `json:"psn_pay,omitempty"`
  15894. AcctPay float64 `json:"acct_pay,omitempty"`
  15895. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15896. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15897. Balc float64 `json:"balc,omitempty"`
  15898. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15899. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15900. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15901. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15902. Year string `json:"year,omitempty"`
  15903. DiseNo string `json:"dise_no,omitempty"`
  15904. DiseName string `json:"dise_name,omitempty"`
  15905. Invono string `json:"invono,omitempty"`
  15906. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15907. ValiFlag string `json:"vali_flag,omitempty"`
  15908. Memo string `json:"memo,omitempty"`
  15909. Rid string `json:"rid"`
  15910. UpdtTime string `json:"updt_time,omitempty"`
  15911. CrterID string `json:"crter_id,omitempty"`
  15912. CrterName string `json:"crter_name,omitempty"`
  15913. CrteTime string `json:"crte_time,omitempty"`
  15914. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15915. OpterID string `json:"opter_id,omitempty"`
  15916. OpterName string `json:"opter_name,omitempty"`
  15917. OptTime string `json:"opt_time,omitempty"`
  15918. OptinsNo string `json:"optins_no,omitempty"`
  15919. PoolareaNo string `json:"poolarea_no,omitempty"`
  15920. } `json:"result"`
  15921. } `json:"output"`
  15922. RefmsgTime string `json:"refmsg_time"`
  15923. RespondTime string `json:"respond_time"`
  15924. Signtype interface{} `json:"signtype"`
  15925. WarnInfo interface{} `json:"warn_info"`
  15926. }
  15927. type Result5267 struct {
  15928. ErrMsg string `json:"err_msg"`
  15929. InfRefmsgid string `json:"inf_refmsgid"`
  15930. Infcode int64 `json:"infcode"`
  15931. Output struct {
  15932. PageInfo struct {
  15933. Size int `json:"size"`
  15934. RecordCounts int `json:"record_counts"`
  15935. } `json:"pageinfo"`
  15936. Result []struct {
  15937. SetlID string `json:"setl_id"`
  15938. ClrOptins string `json:"clr_optins"`
  15939. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15940. MdtrtID string `json:"mdtrt_id"`
  15941. InitSetlID string `json:"init_setl_id,omitempty"`
  15942. PsnNo string `json:"psn_no"`
  15943. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15944. PsnName string `json:"psn_name"`
  15945. PsnCertType string `json:"psn_cert_type"`
  15946. Certno string `json:"certno"`
  15947. Gend string `json:"gend,omitempty"`
  15948. Naty string `json:"naty,omitempty"`
  15949. Brdy string `json:"brdy,omitempty"`
  15950. Age float64 `json:"age,omitempty"`
  15951. Insutype string `json:"insutype,omitempty"`
  15952. PsnType string `json:"psn_type"`
  15953. CvlservFlag string `json:"cvlserv_flag"`
  15954. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15955. SpPsnType string `json:"sp_psn_type,omitempty"`
  15956. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15957. ClctGrde string `json:"clct_grde,omitempty"`
  15958. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15959. NwbFlag string `json:"nwb_flag,omitempty"`
  15960. InsuAdmdvs string `json:"insu_admdvs"`
  15961. EmpNo string `json:"emp_no,omitempty"`
  15962. EmpName string `json:"emp_name,omitempty"`
  15963. EmpType string `json:"emp_type,omitempty"`
  15964. EconType string `json:"econ_type,omitempty"`
  15965. AfilIndu string `json:"afil_indu,omitempty"`
  15966. AfilRlts string `json:"afil_rlts,omitempty"`
  15967. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15968. PayLoc string `json:"pay_loc,omitempty"`
  15969. FixmedinsCode string `json:"fixmedins_code"`
  15970. FixmedinsName string `json:"fixmedins_name"`
  15971. HospLv string `json:"hosp_lv,omitempty"`
  15972. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15973. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15974. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15975. Begndate string `json:"begndate,omitempty"`
  15976. Enddate string `json:"enddate,omitempty"`
  15977. SetlTime string `json:"setl_time,omitempty"`
  15978. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15979. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15980. MedType string `json:"med_type"`
  15981. SetlType string `json:"setl_type,omitempty"`
  15982. ClrType string `json:"clr_type,omitempty"`
  15983. ClrWay string `json:"clr_way,omitempty"`
  15984. PsnSetlway string `json:"psn_setlway,omitempty"`
  15985. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15986. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15987. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15988. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15989. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15990. DedcStd float64 `json:"dedc_std,omitempty"`
  15991. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15992. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15993. HifpPay float64 `json:"hifp_pay,omitempty"`
  15994. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15995. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15996. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15997. HifesPay float64 `json:"hifes_pay,omitempty"`
  15998. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15999. HifobPay float64 `json:"hifob_pay,omitempty"`
  16000. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  16001. MafPay float64 `json:"maf_pay,omitempty"`
  16002. OthfundPay float64 `json:"othfund_pay,omitempty"`
  16003. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  16004. PsnPay float64 `json:"psn_pay,omitempty"`
  16005. AcctPay float64 `json:"acct_pay,omitempty"`
  16006. CashPayamt float64 `json:"cash_payamt,omitempty"`
  16007. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  16008. Balc float64 `json:"balc,omitempty"`
  16009. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  16010. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  16011. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  16012. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  16013. Year string `json:"year,omitempty"`
  16014. DiseNo string `json:"dise_no,omitempty"`
  16015. DiseName string `json:"dise_name,omitempty"`
  16016. Invono string `json:"invono,omitempty"`
  16017. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  16018. Memo string `json:"memo,omitempty"`
  16019. UpdtTime string `json:"updt_time,omitempty"`
  16020. OpterID string `json:"opter_id,omitempty"`
  16021. OpterName string `json:"opter_name,omitempty"`
  16022. OptTime string `json:"opt_time,omitempty"`
  16023. OptinsNo string `json:"optins_no,omitempty"`
  16024. PoolareaNo string `json:"poolarea_no,omitempty"`
  16025. } `json:"result"`
  16026. } `json:"output"`
  16027. RefmsgTime string `json:"refmsg_time"`
  16028. RespondTime string `json:"respond_time"`
  16029. Signtype interface{} `json:"signtype"`
  16030. WarnInfo interface{} `json:"warn_info"`
  16031. }
  16032. // type Autogenerated struct {
  16033. // Output struct {
  16034. // Setlinfo struct {
  16035. // SetlTime string `json:"setl_time"`
  16036. // CvlservPay float64 `json:"cvlserv_pay"`
  16037. // Year string `json:"year"`
  16038. // MedType string `json:"med_type"`
  16039. // PsnPay float64 `json:"psn_pay"`
  16040. // OpterID string `json:"opter_id"`
  16041. // Begndate string `json:"begndate"`
  16042. // FlxempeFlag string `json:"flxempe_flag"`
  16043. // HifmiPay float64 `json:"hifmi_pay"`
  16044. // PsnNo string `json:"psn_no"`
  16045. // ActPayDedc float64 `json:"act_pay_dedc"`
  16046. // MedinsSetlID interface{} `json:"medins_setl_id"`
  16047. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16048. // ClrWay string `json:"clr_way"`
  16049. // OthPay float64 `json:"oth_pay"`
  16050. // Gend string `json:"gend"`
  16051. // MdtrtID string `json:"mdtrt_id"`
  16052. // AcctPay float64 `json:"acct_pay"`
  16053. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  16054. // Insutype string `json:"insutype"`
  16055. // Invono interface{} `json:"invono"`
  16056. // Enddate string `json:"enddate"`
  16057. // CashPayamt float64 `json:"cash_payamt"`
  16058. // PsnType string `json:"psn_type"`
  16059. // FixmedinsName string `json:"fixmedins_name"`
  16060. // HifpPay float64 `json:"hifp_pay"`
  16061. // NewFlag interface{} `json:"new_flag"`
  16062. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16063. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  16064. // PayLoc string `json:"pay_loc"`
  16065. // ClrType string `json:"clr_type"`
  16066. // RefdSetlFlag string `json:"refd_setl_flag"`
  16067. // CvlservFlag string `json:"cvlserv_flag"`
  16068. // EmpName string `json:"emp_name"`
  16069. // Brdy string `json:"brdy"`
  16070. // Naty string `json:"naty"`
  16071. // Certno string `json:"certno"`
  16072. // DiseCode string `json:"dise_code"`
  16073. // FixmedinsCode string `json:"fixmedins_code"`
  16074. // DedcHospLv string `json:"dedc_hosp_lv"`
  16075. // OpterName string `json:"opter_name"`
  16076. // Balc float64 `json:"balc"`
  16077. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16078. // PsnCertType string `json:"psn_cert_type"`
  16079. // HifobPay float64 `json:"hifob_pay"`
  16080. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  16081. // HifesPay float64 `json:"hifes_pay"`
  16082. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16083. // OptTime string `json:"opt_time"`
  16084. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16085. // SetlID string `json:"setl_id"`
  16086. // MafPay float64 `json:"maf_pay"`
  16087. // PsnName string `json:"psn_name"`
  16088. // InsuOptins interface{} `json:"insu_optins"`
  16089. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16090. // ClrOptins string `json:"clr_optins"`
  16091. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16092. // DiseName string `json:"dise_name"`
  16093. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16094. // Age float64 `json:"age"`
  16095. // DtrtCertType string `json:"dtrt_cert_type"`
  16096. // HospLv string `json:"hosp_lv"`
  16097. // } `json:"setlinfo"`
  16098. // Setldetail []struct {
  16099. // FundPayType string `json:"fund_pay_type"`
  16100. // FundPayamt float64 `json:"fund_payamt"`
  16101. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16102. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16103. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16104. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16105. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16106. // } `json:"setldetail"`
  16107. // } `json:"output"`
  16108. // Infcode int `json:"infcode"`
  16109. // WarnMsg interface{} `json:"warn_msg"`
  16110. // Cainfo interface{} `json:"cainfo"`
  16111. // ErrMsg interface{} `json:"err_msg"`
  16112. // RefmsgTime string `json:"refmsg_time"`
  16113. // Signtype interface{} `json:"signtype"`
  16114. // RespondTime string `json:"respond_time"`
  16115. // InfRefmsgid string `json:"inf_refmsgid"`
  16116. // }
  16117. type Result002 struct {
  16118. Cainfo interface{} `json:"cainfo"`
  16119. ErrMsg string `json:"err_msg"`
  16120. InfRefmsgid string `json:"inf_refmsgid"`
  16121. Infcode int64 `json:"infcode"`
  16122. Output struct {
  16123. RxFile string `json:"rx_file"`
  16124. SignDigest string `json:"sign_digest"`
  16125. SignCertSn string `json:"sign_cert_sn"`
  16126. SignCertDn string `json:"sign_cert_dn"`
  16127. } `json:"output"`
  16128. RefmsgTime string `json:"refmsg_time"`
  16129. RespondTime string `json:"respond_time"`
  16130. Signtype interface{} `json:"signtype"`
  16131. WarnMsg interface{} `json:"warn_msg"`
  16132. }
  16133. type Result003 struct {
  16134. Cainfo interface{} `json:"cainfo"`
  16135. ErrMsg string `json:"err_msg"`
  16136. InfRefmsgid string `json:"inf_refmsgid"`
  16137. Infcode int64 `json:"infcode"`
  16138. Output struct {
  16139. HiRxno string `json:"hi_rxno"`
  16140. RxStasCodg string `json:"rx_stas_codg"`
  16141. RxStasName string `json:"rx_stas_name"`
  16142. } `json:"output"`
  16143. RefmsgTime string `json:"refmsg_time"`
  16144. RespondTime string `json:"respond_time"`
  16145. Signtype interface{} `json:"signtype"`
  16146. WarnMsg interface{} `json:"warn_msg"`
  16147. }
  16148. type ResultEleven struct {
  16149. Cainfo string `json:"cainfo"`
  16150. ErrMsg string `json:"err_msg"`
  16151. InfRefmsgid string `json:"inf_refmsgid"`
  16152. Infcode int64 `json:"infcode"`
  16153. Output struct {
  16154. Setlinfo struct {
  16155. SetlTime string `json:"setl_time"`
  16156. CvlservPay float64 `json:"cvlserv_pay"`
  16157. Year string `json:"year"`
  16158. MedType string `json:"med_type"`
  16159. PsnPay float64 `json:"psn_pay"`
  16160. OpterID string `json:"opter_id"`
  16161. Begndate string `json:"begndate"`
  16162. FlxempeFlag string `json:"flxempe_flag"`
  16163. HifmiPay float64 `json:"hifmi_pay"`
  16164. PsnNo string `json:"psn_no"`
  16165. ActPayDedc float64 `json:"act_pay_dedc"`
  16166. MedinsSetlID interface{} `json:"medins_setl_id"`
  16167. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16168. ClrWay string `json:"clr_way"`
  16169. OthPay float64 `json:"oth_pay"`
  16170. Gend string `json:"gend"`
  16171. MdtrtID string `json:"mdtrt_id"`
  16172. AcctPay float64 `json:"acct_pay"`
  16173. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16174. Insutype string `json:"insutype"`
  16175. Invono interface{} `json:"invono"`
  16176. Enddate string `json:"enddate"`
  16177. CashPayamt float64 `json:"cash_payamt"`
  16178. PsnType string `json:"psn_type"`
  16179. FixmedinsName string `json:"fixmedins_name"`
  16180. HifpPay float64 `json:"hifp_pay"`
  16181. NewFlag interface{} `json:"new_flag"`
  16182. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16183. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16184. PayLoc string `json:"pay_loc"`
  16185. ClrType string `json:"clr_type"`
  16186. RefdSetlFlag string `json:"refd_setl_flag"`
  16187. CvlservFlag string `json:"cvlserv_flag"`
  16188. EmpName string `json:"emp_name"`
  16189. Brdy string `json:"brdy"`
  16190. Naty string `json:"naty"`
  16191. Certno string `json:"certno"`
  16192. DiseCode string `json:"dise_code"`
  16193. FixmedinsCode string `json:"fixmedins_code"`
  16194. DedcHospLv string `json:"dedc_hosp_lv"`
  16195. OpterName string `json:"opter_name"`
  16196. Balc float64 `json:"balc"`
  16197. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16198. PsnCertType string `json:"psn_cert_type"`
  16199. HifobPay float64 `json:"hifob_pay"`
  16200. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16201. HifesPay float64 `json:"hifes_pay"`
  16202. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16203. OptTime string `json:"opt_time"`
  16204. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16205. SetlID string `json:"setl_id"`
  16206. MafPay float64 `json:"maf_pay"`
  16207. PsnName string `json:"psn_name"`
  16208. InsuOptins interface{} `json:"insu_optins"`
  16209. PrefFundPay interface{} `json:"pref_fund_pay"`
  16210. ClrOptins string `json:"clr_optins"`
  16211. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16212. DiseName string `json:"dise_name"`
  16213. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16214. Age float64 `json:"age"`
  16215. DtrtCertType string `json:"dtrt_cert_type"`
  16216. HospLv string `json:"hosp_lv"`
  16217. PsnCashPay float64 `json:"psn_cash_pay"`
  16218. } `json:"setlinfo"`
  16219. } `json:"output"`
  16220. RefmsgTime string `json:"refmsg_time"`
  16221. RespondTime string `json:"respond_time"`
  16222. Signtype interface{} `json:"signtype"`
  16223. WarnMsg interface{} `json:"warn_msg"`
  16224. }
  16225. type ResultElevenah struct {
  16226. Cainfo string `json:"cainfo"`
  16227. ErrMsg string `json:"err_msg"`
  16228. InfRefmsgid string `json:"inf_refmsgid"`
  16229. Infcode int64 `json:"infcode"`
  16230. Output struct {
  16231. Setlinfo struct {
  16232. SetlTime int64 `json:"setl_time"`
  16233. CvlservPay float64 `json:"cvlserv_pay"`
  16234. Year string `json:"year"`
  16235. MedType string `json:"med_type"`
  16236. PsnPay float64 `json:"psn_pay"`
  16237. OpterID string `json:"opter_id"`
  16238. Begndate int64 `json:"begndate"`
  16239. FlxempeFlag string `json:"flxempe_flag"`
  16240. HifmiPay float64 `json:"hifmi_pay"`
  16241. PsnNo string `json:"psn_no"`
  16242. ActPayDedc float64 `json:"act_pay_dedc"`
  16243. MedinsSetlID interface{} `json:"medins_setl_id"`
  16244. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16245. ClrWay string `json:"clr_way"`
  16246. OthPay float64 `json:"oth_pay"`
  16247. Gend string `json:"gend"`
  16248. MdtrtID string `json:"mdtrt_id"`
  16249. AcctPay float64 `json:"acct_pay"`
  16250. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16251. Insutype string `json:"insutype"`
  16252. Invono interface{} `json:"invono"`
  16253. Enddate int64 `json:"enddate"`
  16254. CashPayamt float64 `json:"cash_payamt"`
  16255. PsnType string `json:"psn_type"`
  16256. FixmedinsName string `json:"fixmedins_name"`
  16257. HifpPay float64 `json:"hifp_pay"`
  16258. NewFlag interface{} `json:"new_flag"`
  16259. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16260. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16261. PayLoc string `json:"pay_loc"`
  16262. ClrType string `json:"clr_type"`
  16263. RefdSetlFlag string `json:"refd_setl_flag"`
  16264. CvlservFlag string `json:"cvlserv_flag"`
  16265. EmpName string `json:"emp_name"`
  16266. Brdy int64 `json:"brdy"`
  16267. Naty string `json:"naty"`
  16268. Certno string `json:"certno"`
  16269. DiseCode string `json:"dise_code"`
  16270. FixmedinsCode string `json:"fixmedins_code"`
  16271. DedcHospLv string `json:"dedc_hosp_lv"`
  16272. OpterName string `json:"opter_name"`
  16273. Balc float64 `json:"balc"`
  16274. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16275. PsnCertType string `json:"psn_cert_type"`
  16276. HifobPay float64 `json:"hifob_pay"`
  16277. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16278. HifesPay float64 `json:"hifes_pay"`
  16279. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16280. OptTime int64 `json:"opt_time"`
  16281. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16282. SetlID string `json:"setl_id"`
  16283. MafPay float64 `json:"maf_pay"`
  16284. PsnName string `json:"psn_name"`
  16285. InsuOptins interface{} `json:"insu_optins"`
  16286. PrefFundPay interface{} `json:"pref_fund_pay"`
  16287. ClrOptins string `json:"clr_optins"`
  16288. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16289. DiseName string `json:"dise_name"`
  16290. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16291. Age float64 `json:"age"`
  16292. DtrtCertType string `json:"dtrt_cert_type"`
  16293. HospLv string `json:"hosp_lv"`
  16294. PsnCashPay float64 `json:"psn_cash_pay"`
  16295. } `json:"setlinfo"`
  16296. } `json:"output"`
  16297. RefmsgTime string `json:"refmsg_time"`
  16298. RespondTime string `json:"respond_time"`
  16299. Signtype interface{} `json:"signtype"`
  16300. WarnMsg interface{} `json:"warn_msg"`
  16301. }
  16302. type ResultEleven10265 struct {
  16303. Cainfo string `json:"cainfo"`
  16304. ErrMsg string `json:"err_msg"`
  16305. InfRefmsgid string `json:"inf_refmsgid"`
  16306. Infcode string `json:"infcode"`
  16307. Output struct {
  16308. Setlinfo struct {
  16309. SetlTime string `json:"setl_time"`
  16310. CvlservPay float64 `json:"cvlserv_pay"`
  16311. Year string `json:"year"`
  16312. MedType string `json:"med_type"`
  16313. PsnPay float64 `json:"psn_pay"`
  16314. OpterID string `json:"opter_id"`
  16315. Begndate string `json:"begndate"`
  16316. FlxempeFlag string `json:"flxempe_flag"`
  16317. HifmiPay float64 `json:"hifmi_pay"`
  16318. PsnNo string `json:"psn_no"`
  16319. ActPayDedc float64 `json:"act_pay_dedc"`
  16320. MedinsSetlID interface{} `json:"medins_setl_id"`
  16321. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16322. ClrWay string `json:"clr_way"`
  16323. OthPay float64 `json:"oth_pay"`
  16324. Gend string `json:"gend"`
  16325. MdtrtID string `json:"mdtrt_id"`
  16326. AcctPay float64 `json:"acct_pay"`
  16327. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16328. Insutype string `json:"insutype"`
  16329. Invono interface{} `json:"invono"`
  16330. Enddate string `json:"enddate"`
  16331. CashPayamt float64 `json:"cash_payamt"`
  16332. PsnType string `json:"psn_type"`
  16333. FixmedinsName string `json:"fixmedins_name"`
  16334. HifpPay float64 `json:"hifp_pay"`
  16335. NewFlag interface{} `json:"new_flag"`
  16336. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16337. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16338. PayLoc string `json:"pay_loc"`
  16339. ClrType string `json:"clr_type"`
  16340. RefdSetlFlag string `json:"refd_setl_flag"`
  16341. CvlservFlag string `json:"cvlserv_flag"`
  16342. EmpName string `json:"emp_name"`
  16343. Brdy string `json:"brdy"`
  16344. Naty string `json:"naty"`
  16345. Certno string `json:"certno"`
  16346. DiseCode string `json:"dise_code"`
  16347. FixmedinsCode string `json:"fixmedins_code"`
  16348. DedcHospLv string `json:"dedc_hosp_lv"`
  16349. OpterName string `json:"opter_name"`
  16350. Balc float64 `json:"balc"`
  16351. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16352. PsnCertType string `json:"psn_cert_type"`
  16353. HifobPay float64 `json:"hifob_pay"`
  16354. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16355. HifesPay float64 `json:"hifes_pay"`
  16356. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16357. OptTime string `json:"opt_time"`
  16358. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16359. SetlID string `json:"setl_id"`
  16360. MafPay float64 `json:"maf_pay"`
  16361. PsnName string `json:"psn_name"`
  16362. InsuOptins interface{} `json:"insu_optins"`
  16363. PrefFundPay interface{} `json:"pref_fund_pay"`
  16364. ClrOptins string `json:"clr_optins"`
  16365. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16366. DiseName string `json:"dise_name"`
  16367. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16368. Age float64 `json:"age"`
  16369. DtrtCertType string `json:"dtrt_cert_type"`
  16370. HospLv string `json:"hosp_lv"`
  16371. PsnCashPay float64 `json:"psn_cash_pay"`
  16372. } `json:"setlinfo"`
  16373. } `json:"output"`
  16374. RefmsgTime string `json:"refmsg_time"`
  16375. RespondTime string `json:"respond_time"`
  16376. Signtype interface{} `json:"signtype"`
  16377. WarnMsg interface{} `json:"warn_msg"`
  16378. }
  16379. type ResultTwelve struct {
  16380. Cainfo string `json:"cainfo"`
  16381. ErrMsg string `json:"err_msg"`
  16382. InfRefmsgid string `json:"inf_refmsgid"`
  16383. Infcode int64 `json:"infcode"`
  16384. Output struct {
  16385. MdtrtId string `json:"mdtrt_id"`
  16386. ChrgBchno string `json:"chrg_bchno"`
  16387. PsnNo string `json:"psn_no"`
  16388. } `json:"output"`
  16389. RefmsgTime string `json:"refmsg_time"`
  16390. RespondTime string `json:"respond_time"`
  16391. Signtype interface{} `json:"signtype"`
  16392. WarnMsg interface{} `json:"warn_msg"`
  16393. }
  16394. type ResultThirteen struct {
  16395. ErrMsg string `json:"err_msg"`
  16396. InfRefmsgid string `json:"inf_refmsgid"`
  16397. Infcode int64 `json:"infcode"`
  16398. Output struct {
  16399. Result struct {
  16400. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16401. } `json:"result"`
  16402. } `json:"output"`
  16403. RefmsgTime string `json:"refmsg_time"`
  16404. RespondTime string `json:"respond_time"`
  16405. Signtype interface{} `json:"signtype"`
  16406. WarnInfo interface{} `json:"warn_info"`
  16407. }
  16408. type ResultThirteen10265 struct {
  16409. ErrMsg string `json:"err_msg"`
  16410. InfRefmsgid string `json:"inf_refmsgid"`
  16411. Infcode string `json:"infcode"`
  16412. Output struct {
  16413. Result struct {
  16414. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16415. } `json:"result"`
  16416. } `json:"output"`
  16417. RefmsgTime string `json:"refmsg_time"`
  16418. RespondTime string `json:"respond_time"`
  16419. Signtype interface{} `json:"signtype"`
  16420. WarnInfo interface{} `json:"warn_info"`
  16421. }
  16422. type ResultFourteen struct {
  16423. ErrMsg string `json:"err_msg"`
  16424. InfRefmsgid string `json:"inf_refmsgid"`
  16425. Infcode int64 `json:"infcode"`
  16426. Output struct {
  16427. } `json:"output"`
  16428. RefmsgTime string `json:"refmsg_time"`
  16429. RespondTime string `json:"respond_time"`
  16430. Signtype interface{} `json:"signtype"`
  16431. WarnInfo interface{} `json:"warn_info"`
  16432. }
  16433. type ResultCFYLJG001 struct {
  16434. ErrMsg string `json:"err_msg"`
  16435. InfRefmsgid string `json:"inf_refmsgid"`
  16436. Infcode int64 `json:"infcode"`
  16437. Output struct {
  16438. RxTraceCode string `json:"rx_trace_code"`
  16439. HiRxno string `json:"hi_rxno"`
  16440. } `json:"output"`
  16441. RefmsgTime string `json:"refmsg_time"`
  16442. RespondTime string `json:"respond_time"`
  16443. Signtype interface{} `json:"signtype"`
  16444. WarnInfo interface{} `json:"warn_info"`
  16445. }
  16446. type ResultCFYLJG007 struct {
  16447. ErrMsg string `json:"err_msg"`
  16448. InfRefmsgid string `json:"inf_refmsgid"`
  16449. Infcode int64 `json:"infcode"`
  16450. Output struct {
  16451. HiRxno string `json:"hi_rxno"`
  16452. RxStasName string `json:"rx_stas_name"`
  16453. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16454. Seltdelts []interface{} `json:"seltdelts"`
  16455. RxUsedStasName string `json:"rx_used_stas_name"`
  16456. RxStasCodg string `json:"rx_stas_codg"`
  16457. } `json:"output"`
  16458. RefmsgTime string `json:"refmsg_time"`
  16459. RespondTime string `json:"respond_time"`
  16460. Signtype interface{} `json:"signtype"`
  16461. WarnInfo interface{} `json:"warn_info"`
  16462. }
  16463. type ResultCFYLJG002 struct {
  16464. ErrMsg string `json:"err_msg"`
  16465. InfRefmsgid string `json:"inf_refmsgid"`
  16466. Infcode int64 `json:"infcode"`
  16467. Output struct {
  16468. RxFile string `json:"rx_file"`
  16469. SignDigest string `json:"sign_digest"`
  16470. SignCertSn string `json:"sign_cert_sn"`
  16471. SignCertDn string `json:"sign_cert_dn"`
  16472. } `json:"output"`
  16473. RefmsgTime string `json:"refmsg_time"`
  16474. RespondTime string `json:"respond_time"`
  16475. Signtype interface{} `json:"signtype"`
  16476. WarnInfo interface{} `json:"warn_info"`
  16477. }
  16478. type ResultCFYLJG003 struct {
  16479. ErrMsg string `json:"err_msg"`
  16480. InfRefmsgid string `json:"inf_refmsgid"`
  16481. Infcode int64 `json:"infcode"`
  16482. Output struct {
  16483. HiRxno string `json:"hi_rxno"`
  16484. RxStasCodg string `json:"rx_stas_codg"`
  16485. RxStasName string `json:"rx_stas_name"`
  16486. } `json:"output"`
  16487. RefmsgTime string `json:"refmsg_time"`
  16488. RespondTime string `json:"respond_time"`
  16489. Signtype interface{} `json:"signtype"`
  16490. WarnInfo interface{} `json:"warn_info"`
  16491. }
  16492. type ResultCFYLJG004 struct {
  16493. ErrMsg string `json:"err_msg"`
  16494. InfRefmsgid string `json:"inf_refmsgid"`
  16495. Infcode int64 `json:"infcode"`
  16496. Output struct {
  16497. HiRxno string `json:"hi_rxno"`
  16498. RxStasCodg string `json:"rx_stas_codg"`
  16499. RxStasName string `json:"rx_stas_name"`
  16500. } `json:"output"`
  16501. RefmsgTime string `json:"refmsg_time"`
  16502. RespondTime string `json:"respond_time"`
  16503. Signtype interface{} `json:"signtype"`
  16504. WarnInfo interface{} `json:"warn_info"`
  16505. }
  16506. type ResultCFYLJG008 struct {
  16507. ErrMsg string `json:"err_msg"`
  16508. InfRefmsgid string `json:"inf_refmsgid"`
  16509. Infcode int64 `json:"infcode"`
  16510. Output struct {
  16511. PoolareaNo string `json:"poolareaNo"`
  16512. AdmdvsName string `json:"admdvsName"`
  16513. Count string `json:"count"`
  16514. } `json:"output"`
  16515. RefmsgTime string `json:"refmsg_time"`
  16516. RespondTime string `json:"respond_time"`
  16517. Signtype interface{} `json:"signtype"`
  16518. WarnInfo interface{} `json:"warn_info"`
  16519. }
  16520. type ResultCFYLJG005 struct {
  16521. ErrMsg string `json:"err_msg"`
  16522. InfRefmsgid string `json:"inf_refmsgid"`
  16523. Infcode int64 `json:"infcode"`
  16524. Output struct {
  16525. HiRxNo string `json:"hi_rxno"`
  16526. FixMedinsCode string `json:"fixmedins_code"`
  16527. FixMedinsName string `json:"fixmedins_name"`
  16528. RxStasCodg string `json:"rx_stas_codg"`
  16529. RxStasName string `json:"rx_stas_name"`
  16530. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16531. RxUserdStasName string `json:"rx_userd_stas_name"`
  16532. PrscTime string `json:"prsc_time"`
  16533. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16534. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16535. RxUsedWayName string `json:"rx_used_way_name"`
  16536. RxFrquCodg string `json:"rx_frqu_codg"`
  16537. RxFrquName string `json:"rx_frqu_name"`
  16538. RxDosunt string `json:"rx_dosunt"`
  16539. RxDoscnt float64 `json:"rx_doscnt"`
  16540. RxDrordDscr string `json:"rx_drord_dscr"`
  16541. ValiDays int64 `json:"vali_days"`
  16542. ValiEndTime string `json:"vali_end_time"`
  16543. ReptFlag string `json:"rept_flag"`
  16544. MaxReptCnt int64 `json:"max_rept_cnt"`
  16545. ReptdCnt int64 `json:"reptd_cnt"`
  16546. MinInrvDays int64 `json:"min_inrv_days"`
  16547. RxTypeCode string `json:"rx_type_code"`
  16548. RxTypeName string `json:"rx_type_name"`
  16549. LongRxFlag string `json:"long_rx_flag"`
  16550. RxDetlList []struct {
  16551. MedListCodg string `json:"med_list_codg"`
  16552. MedinsListCodg string `json:"medins_list_codg"`
  16553. HospPrepFlag string `json:"hosp_prep_flag"`
  16554. RxItemTypeCode string `json:"rx_item_type_code"`
  16555. RxItemTypeName string `json:"rx_item_type_name"`
  16556. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16557. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16558. TcmHerbFoote string `json:"tcmherb_foote"`
  16559. MednTypeCode string `json:"medn_type_code"`
  16560. MednTypeName string `json:"medn_type_name"`
  16561. MainMedcFlag string `json:"main_medc_flag"`
  16562. UrgtFlag string `json:"urgt_flag"`
  16563. BasMednFlag string `json:"bas_medn_flag"`
  16564. ImpDrugFlag string `json:"imp_drug_flag"`
  16565. ProdBarc string `json:"prod_barc"`
  16566. DrugProdname string `json:"drug_prodname"`
  16567. GennameCodg string `json:"genname_codg"`
  16568. DrugGenname string `json:"drug_genname"`
  16569. DrugDosform string `json:"drug_dosform"`
  16570. DrugSpec string `json:"drug_spec"`
  16571. PrdrName string `json:"prdr_name"`
  16572. MedcWayCodg string `json:"medc_way_codg"`
  16573. MedcWayDscr string `json:"medc_way_dscr"`
  16574. MedcBegntime string `json:"medc_begntime"`
  16575. MedcEndtime string `json:"medc_endtime"`
  16576. MedcDays float64 `json:"medc_days"`
  16577. DrugPric float64 `json:"drug_pric"`
  16578. DrugSumamt float64 `json:"drug_sumamt"`
  16579. DrugCnt float64 `json:"drug_cnt"`
  16580. DrugDosunt string `json:"drug_dosunt"`
  16581. SinDoscnt float64 `json:"sin_doscnt"`
  16582. SinDosunt string `json:"sin_dosunt"`
  16583. UsedFrquCodg string `json:"used_frqu_codg"`
  16584. UsedFrquName string `json:"used_frqu_name"`
  16585. DrugTotlcnt string `json:"drug_totlcnt"`
  16586. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16587. DiseCodg string `json:"dise_codg"`
  16588. HospApprFlag string `json:"hosp_appr_flag"`
  16589. } `json:"rx_detl_list"`
  16590. RxOtpinfo struct {
  16591. MedType string `json:"med_type"`
  16592. IptOtpNo string `json:"ipt_otp_no"`
  16593. OtpIptFlag string `json:"otp_ipt_flag"`
  16594. PatnName string `json:"patn_name"`
  16595. PatnAge float64 `json:"patn_age"`
  16596. PatnHgt float64 `json:"patn_hgt"`
  16597. PatnWt float64 `json:"patn_wt"`
  16598. Gend string `json:"gend"`
  16599. GesoVal float64 `json:"geso_val"`
  16600. NwbFlag string `json:"nwb_flag"`
  16601. NwbAge string `json:"nwb_age"`
  16602. SuckPrdFlag string `json:"suck_prd_flag"`
  16603. AlgsHis string `json:"algs_his"`
  16604. Insutype string `json:"insutype"`
  16605. PrscDeptName string `json:"prsc_dept_name"`
  16606. PrscDrName string `json:"prsc_dr_name"`
  16607. PharName string `json:"phar_name"`
  16608. PharChkTime string `json:"phar_chk_time"`
  16609. MdtrtTime string `json:"mdtrt_time"`
  16610. DiseCodg string `json:"dise_codg"`
  16611. DiseName string `json:"dise_name"`
  16612. SpDiseFlag string `json:"sp_dise_flag"`
  16613. MaindiagCode string `json:"maindiag_code"`
  16614. MaindiagName string `json:"maindiag_name"`
  16615. DiseCondDscr string `json:"dise_cond_dscr"`
  16616. FstdiagFlag string `json:"fstdiag_flag"`
  16617. } `json:"rx_otpinfo"`
  16618. RxDiseList []struct {
  16619. DiagType string `json:"diag_type"`
  16620. MaindiagFlag string `json:"maindiag_flag"`
  16621. DiagSrtNo string `json:"diag_srt_no"`
  16622. DiagCode string `json:"diag_code"`
  16623. DiagName string `json:"diag_name"`
  16624. DiagDept string `json:"diag_dept"`
  16625. DiagDrNo string `json:"diag_dr_no"`
  16626. DiagDrName string `json:"diag_dr_name"`
  16627. DiagTime string `json:"diag_time"`
  16628. TcmDiseCode string `json:"tcm_dise_code"`
  16629. TcmDiseName string `json:"tcm_dise_name"`
  16630. TcmSympCode string `json:"tcmsymp_code"`
  16631. TcmSymp string `json:"tcmsymp"`
  16632. } `json:"rx_dise_list"`
  16633. } `json:"output"`
  16634. RefmsgTime string `json:"refmsg_time"`
  16635. RespondTime string `json:"respond_time"`
  16636. Signtype interface{} `json:"signtype"`
  16637. WarnInfo interface{} `json:"warn_info"`
  16638. }
  16639. type ResultCFYLJG006 struct {
  16640. ErrMsg string `json:"err_msg"`
  16641. InfRefmsgid string `json:"inf_refmsgid"`
  16642. Infcode int64 `json:"infcode"`
  16643. Output struct {
  16644. HiRxNo string `json:"hi_rxno"`
  16645. PharCode string `json:"phar_code"`
  16646. PharName string `json:"phar_name"`
  16647. RxChkOpnn string `json:"rx_chk_opnn"`
  16648. RxChkTime string `json:"rx_chk_time"`
  16649. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16650. RxChkStasName string `json:"rx_chk_stas_name"`
  16651. RxStasCodg string `json:"rx_stas_codg"`
  16652. RxStasName string `json:"rx_stas_name"`
  16653. } `json:"output"`
  16654. RefmsgTime string `json:"refmsg_time"`
  16655. RespondTime string `json:"respond_time"`
  16656. Signtype interface{} `json:"signtype"`
  16657. WarnInfo interface{} `json:"warn_info"`
  16658. }
  16659. type ResultFourteen10265 struct {
  16660. ErrMsg string `json:"err_msg"`
  16661. InfRefmsgid string `json:"inf_refmsgid"`
  16662. Infcode string `json:"infcode"`
  16663. Output struct {
  16664. } `json:"output"`
  16665. RefmsgTime string `json:"refmsg_time"`
  16666. RespondTime string `json:"respond_time"`
  16667. Signtype interface{} `json:"signtype"`
  16668. WarnInfo interface{} `json:"warn_info"`
  16669. }
  16670. type ResultSixteen struct {
  16671. Cainfo string `json:"cainfo"`
  16672. ErrMsg string `json:"err_msg"`
  16673. InfRefmsgid string `json:"inf_refmsgid"`
  16674. Infcode int64 `json:"infcode"`
  16675. Output struct {
  16676. Setlinfo struct {
  16677. MdtrtID string `json:"mdtrt_id"`
  16678. SetlID string `json:"setl_id"`
  16679. ClrOptins string `json:"clr_optins"`
  16680. SetlTime string `json:"setl_time"`
  16681. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16682. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16683. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16684. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16685. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16686. ActPayDedc float64 `json:"act_pay_dedc"`
  16687. HifpPay float64 `json:"hifp_pay"`
  16688. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16689. Lfpay float64 `json:"selfpay"`
  16690. CvlservPay float64 `json:"cvlserv_pay"`
  16691. HifesPay float64 `json:"hifes_pay"`
  16692. HifmiPay float64 `json:"hifmi_pay"`
  16693. HifobPay float64 `json:"hifob_pay"`
  16694. MafPay float64 `json:"maf_pay"`
  16695. OthPay float64 `json:"oth_pay"`
  16696. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16697. PsnPartAmt float64 `json:"psn_part_amt"`
  16698. AcctPay float64 `json:"acct_pay"`
  16699. Balc float64 `json:"balc"`
  16700. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16701. HospPartAmt float64 `json:"hosp_part_amt"`
  16702. MedinsSetlID string `json:"medins_setl_id"`
  16703. PdnCashPay string `json:"pdn_cash_pay"`
  16704. } `json:"setlinfo"`
  16705. } `json:"output"`
  16706. RefmsgTime string `json:"refmsg_time"`
  16707. RespondTime string `json:"respond_time"`
  16708. Signtype interface{} `json:"signtype"`
  16709. WarnMsg interface{} `json:"warn_msg"`
  16710. }
  16711. type ResultSixteen10265 struct {
  16712. Cainfo string `json:"cainfo"`
  16713. ErrMsg string `json:"err_msg"`
  16714. InfRefmsgid string `json:"inf_refmsgid"`
  16715. Infcode string `json:"infcode"`
  16716. Output struct {
  16717. Setlinfo struct {
  16718. MdtrtID string `json:"mdtrt_id"`
  16719. SetlID string `json:"setl_id"`
  16720. ClrOptins string `json:"clr_optins"`
  16721. SetlTime string `json:"setl_time"`
  16722. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16723. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16724. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16725. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16726. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16727. ActPayDedc float64 `json:"act_pay_dedc"`
  16728. HifpPay float64 `json:"hifp_pay"`
  16729. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16730. Lfpay float64 `json:"selfpay"`
  16731. CvlservPay float64 `json:"cvlserv_pay"`
  16732. HifesPay float64 `json:"hifes_pay"`
  16733. HifmiPay float64 `json:"hifmi_pay"`
  16734. HifobPay float64 `json:"hifob_pay"`
  16735. MafPay float64 `json:"maf_pay"`
  16736. OthPay float64 `json:"oth_pay"`
  16737. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16738. PsnPartAmt float64 `json:"psn_part_amt"`
  16739. AcctPay float64 `json:"acct_pay"`
  16740. Balc float64 `json:"balc"`
  16741. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16742. HospPartAmt float64 `json:"hosp_part_amt"`
  16743. MedinsSetlID string `json:"medins_setl_id"`
  16744. PdnCashPay string `json:"pdn_cash_pay"`
  16745. } `json:"setlinfo"`
  16746. } `json:"output"`
  16747. RefmsgTime string `json:"refmsg_time"`
  16748. RespondTime string `json:"respond_time"`
  16749. Signtype interface{} `json:"signtype"`
  16750. WarnMsg interface{} `json:"warn_msg"`
  16751. }
  16752. type ResultSixteen10265Two struct {
  16753. Cainfo string `json:"cainfo"`
  16754. ErrMsg string `json:"err_msg"`
  16755. InfRefmsgid string `json:"inf_refmsgid"`
  16756. Infcode string `json:"infcode"`
  16757. Output struct {
  16758. Setlinfo interface{} `json:"setlinfo"`
  16759. } `json:"output"`
  16760. RefmsgTime string `json:"refmsg_time"`
  16761. RespondTime string `json:"respond_time"`
  16762. Signtype interface{} `json:"signtype"`
  16763. WarnMsg interface{} `json:"warn_msg"`
  16764. }
  16765. type ResultgzSixteen10265Two struct {
  16766. Cainfo string `json:"cainfo"`
  16767. ErrMsg string `json:"err_msg"`
  16768. InfRefmsgid string `json:"inf_refmsgid"`
  16769. Infcode int64 `json:"infcode"`
  16770. Output struct {
  16771. Setlinfo interface{} `json:"setlinfo"`
  16772. } `json:"output"`
  16773. RefmsgTime string `json:"refmsg_time"`
  16774. RespondTime string `json:"respond_time"`
  16775. Signtype interface{} `json:"signtype"`
  16776. WarnMsg interface{} `json:"warn_msg"`
  16777. }
  16778. type ResultSeventeen struct {
  16779. ErrMsg string `json:"err_msg"`
  16780. InfRefmsgid string `json:"inf_refmsgid"`
  16781. Infcode int64 `json:"infcode"`
  16782. Output struct {
  16783. SetlListId string `json:"setl_list_id"`
  16784. } `json:"output"`
  16785. RefmsgTime string `json:"refmsg_time"`
  16786. RespondTime string `json:"respond_time"`
  16787. Signtype string `json:"signtype"`
  16788. WarnInfo string `json:"warn_info"`
  16789. }
  16790. type ResultSeventeenOther struct {
  16791. ErrMsg string `json:"err_msg"`
  16792. InfRefmsgid string `json:"inf_refmsgid"`
  16793. Infcode string `json:"infcode"`
  16794. Output struct {
  16795. SetlListId string `json:"setl_list_id"`
  16796. } `json:"output"`
  16797. RefmsgTime string `json:"refmsg_time"`
  16798. RespondTime string `json:"respond_time"`
  16799. Signtype string `json:"signtype"`
  16800. WarnInfo string `json:"warn_info"`
  16801. }
  16802. type Result90991 struct {
  16803. ErrMsg string `json:"err_msg"`
  16804. InfRefmsgid string `json:"inf_refmsgid"`
  16805. Infcode int64 `json:"infcode"`
  16806. Output struct {
  16807. Result struct {
  16808. PsnNo string `json:"psn_no"`
  16809. CardStat string `json:"card_stat"`
  16810. Certno string `json:"certno"`
  16811. PsnName string `json:"psn_name"`
  16812. CheckStat string `json:"check_stat"`
  16813. SscnoCheckStat string `json:"sscno_check_stat"`
  16814. } `json:"result"`
  16815. } `json:"output"`
  16816. RefmsgTime string `json:"refmsg_time"`
  16817. RespondTime string `json:"respond_time"`
  16818. Signtype interface{} `json:"signtype"`
  16819. WarnInfo interface{} `json:"warn_info"`
  16820. }
  16821. type Result90100 struct {
  16822. ErrMsg string `json:"err_msg"`
  16823. InfRefmsgid string `json:"inf_refmsgid"`
  16824. Infcode int64 `json:"infcode"`
  16825. Output struct {
  16826. PoolareaNo string `json:"poolarea_no"`
  16827. PoolareaNoName string `json:"poolarea_no_name"`
  16828. Insutype string `json:"insutype"`
  16829. InsutypeName string `json:"insutype_name"`
  16830. ClctType string `json:"clct_type"`
  16831. ClctTypeName string `json:"clct_type_name"`
  16832. ClctFlag string `json:"clct_flag"`
  16833. ClctFlagName string `json:"clct_flag_name"`
  16834. AccrymBegn string `json:"accrym_begn"`
  16835. AccrymEnd string `json:"accrym_end"`
  16836. ClctTime string `json:"clct_time"`
  16837. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16838. } `json:"output"`
  16839. RefmsgTime string `json:"refmsg_time"`
  16840. RespondTime string `json:"respond_time"`
  16841. Signtype interface{} `json:"signtype"`
  16842. WarnInfo interface{} `json:"warn_info"`
  16843. }
  16844. type Custom struct {
  16845. DetItemFeeSumamt string
  16846. Cut string
  16847. FeedetlSn string
  16848. Price string
  16849. MedListCodg string
  16850. Type int64
  16851. AdviceId int64
  16852. ProjectId int64
  16853. ItemId int64
  16854. }
  16855. type Result5301 struct {
  16856. ErrMsg string `json:"err_msg"`
  16857. InfRefmsgid string `json:"inf_refmsgid"`
  16858. Infcode int64 `json:"infcode"`
  16859. Output struct {
  16860. Result []struct {
  16861. OpspDiseCode string `json:"opsp_dise_code"`
  16862. OpspDiseName string `json:"opsp_dise_name"`
  16863. Begndate string `json:"begndate"`
  16864. Enddate string `json:"enddate"`
  16865. } `json:"feedetail"`
  16866. } `json:"output"`
  16867. RefmsgTime string `json:"refmsg_time"`
  16868. RespondTime string `json:"respond_time"`
  16869. Signtype interface{} `json:"signtype"`
  16870. WarnInfo interface{} `json:"warn_info"`
  16871. }
  16872. type Result5301For10265 struct {
  16873. ErrMsg string `json:"err_msg"`
  16874. InfRefmsgid string `json:"inf_refmsgid"`
  16875. Infcode string `json:"infcode"`
  16876. Output struct {
  16877. Result []struct {
  16878. OpspDiseCode string `json:"opsp_dise_code"`
  16879. OpspDiseName string `json:"opsp_dise_name"`
  16880. Begndate string `json:"begndate"`
  16881. Enddate string `json:"enddate"`
  16882. } `json:"feedetail"`
  16883. } `json:"output"`
  16884. RefmsgTime string `json:"refmsg_time"`
  16885. RespondTime string `json:"respond_time"`
  16886. Signtype interface{} `json:"signtype"`
  16887. WarnInfo interface{} `json:"warn_info"`
  16888. }
  16889. //获取个人信息----挂号-----上传就诊信息
  16890. func (c *HisApiController) GetRegisterInfo() {
  16891. id, _ := c.GetInt64("id")
  16892. record_time := c.GetString("record_time")
  16893. settlementValue, _ := c.GetInt64("settlement_value")
  16894. medical_insurance_card := c.GetString("medical_insurance_card")
  16895. name := c.GetString("name")
  16896. id_card_type, _ := c.GetInt64("id_card_type")
  16897. certificates, _ := c.GetInt64("certificates")
  16898. medical_care, _ := c.GetInt64("medical_care")
  16899. birthday := c.GetString("birthday")
  16900. id_card := c.GetString("id_card")
  16901. register_type, _ := c.GetInt64("register")
  16902. doctor, _ := c.GetInt64("doctor")
  16903. department, _ := c.GetInt64("department")
  16904. gender, _ := c.GetInt64("sex")
  16905. registration_fee, _ := c.GetFloat("registration_fee")
  16906. medical_expenses, _ := c.GetFloat("medical_expenses")
  16907. social_type, _ := c.GetInt64("social_type")
  16908. admin_user_id, _ := c.GetInt64("admin_user_id")
  16909. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16910. mdtrt_type := c.GetString("mdtrt_type")
  16911. if id_card_type == 5 {
  16912. id_card_type = 4
  16913. }
  16914. timeLayout := "2006-01-02"
  16915. loc, _ := time.LoadLocation("Local")
  16916. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16917. birthUnix := birthdays.Unix()
  16918. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16919. if err != nil {
  16920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16921. return
  16922. }
  16923. recordDateTime := theTime.Unix()
  16924. adminInfo := c.GetAdminUserInfo()
  16925. var patient service.Patients
  16926. if id == 0 {
  16927. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16928. } else {
  16929. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16930. }
  16931. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16932. if patientPrescription.ID == 0 {
  16933. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16934. }
  16935. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16936. if patient.ID == 0 {
  16937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16938. return
  16939. }
  16940. if len(patient.IdCardNo) == 0 {
  16941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16942. return
  16943. }
  16944. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16945. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16946. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16947. //就诊结算未完成,不能进行二次挂号
  16948. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16949. //if len(his) >= 1 {
  16950. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16951. // if len(his) >= 1 && order.ID == 0 {
  16952. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16953. // return
  16954. // }
  16955. //}
  16956. //var register_log string
  16957. if config.IsOpen == 1 {
  16958. var res ResultTwo
  16959. var res10265 ResultTwo10265
  16960. var PsnNo string
  16961. var PsnCertType string
  16962. var Certno string
  16963. var PsnName string
  16964. var Gend string
  16965. var Naty string
  16966. var Brdy string
  16967. var Age float64
  16968. var infoStr string
  16969. var idetinfoStr string
  16970. var infocode int64
  16971. var verify_number string
  16972. fmt.Println(verify_number)
  16973. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  16974. psn_info, _ := service.GetPsnByPatientId(id)
  16975. PsnNo = psn_info.PsnNo
  16976. PsnCertType = psn_info.PsnCertType
  16977. Certno = psn_info.Certno
  16978. PsnName = psn_info.PsnName
  16979. Gend = psn_info.Gend
  16980. Naty = psn_info.Naty
  16981. Brdy = psn_info.Brdy
  16982. Age = psn_info.Age
  16983. infoStr = psn_info.Insuinfo
  16984. idetinfoStr = psn_info.Idetinfo
  16985. infocode = 0
  16986. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16987. psn_info, _ := service.GetPsnByPatientId(id)
  16988. PsnNo = psn_info.PsnNo
  16989. PsnCertType = psn_info.PsnCertType
  16990. Certno = psn_info.Certno
  16991. PsnName = psn_info.PsnName
  16992. Gend = psn_info.Gend
  16993. Naty = psn_info.Naty
  16994. Brdy = psn_info.Brdy
  16995. Age = psn_info.Age
  16996. infoStr = psn_info.Insuinfo
  16997. idetinfoStr = psn_info.Idetinfo
  16998. infocode = 0
  16999. verify_number = psn_info.VerifyNumber
  17000. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17001. if id_card_type == 2 {
  17002. //请求内网数据
  17003. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  17004. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  17005. "&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
  17006. resp, requestErr := http.Get(api)
  17007. if requestErr != nil {
  17008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17009. return
  17010. }
  17011. body, ioErr := ioutil.ReadAll(resp.Body)
  17012. if ioErr != nil {
  17013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17015. return
  17016. }
  17017. var respJSON map[string]interface{}
  17018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17021. return
  17022. }
  17023. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17024. result_byte, _ := json.Marshal(respJSON)
  17025. result := string(result_byte)
  17026. var dat map[string]interface{}
  17027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  17028. fmt.Println(dat)
  17029. } else {
  17030. fmt.Println(err)
  17031. }
  17032. userJSONBytes, _ := json.Marshal(dat)
  17033. var res ResultTwo
  17034. var resTwo10265 ResultTwo10265
  17035. if miConfig.Code == "H15049901371" {
  17036. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  17037. utils.ErrorLog("解析失败:%v", err)
  17038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17039. return
  17040. }
  17041. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  17042. res.Infcode = Infcode
  17043. res.ErrMsg = resTwo10265.ErrMsg
  17044. res.Output = resTwo10265.Output
  17045. res.InfRefmsgid = resTwo10265.InfRefmsgid
  17046. res.RespondTime = resTwo10265.RespondTime
  17047. res.WarnInfo = resTwo10265.WarnInfo
  17048. } else {
  17049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  17050. utils.ErrorLog("解析失败:%v", err)
  17051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17052. return
  17053. }
  17054. }
  17055. //var insutypes []string
  17056. //var insutype string
  17057. //var is390 int = 0
  17058. //var is310 int = 0
  17059. //for _, item := range res.Output.Iinfo {
  17060. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17061. // insutypes = append(insutypes, item.Insutype)
  17062. // }
  17063. //}
  17064. //if len(insutypes) == 1 {
  17065. // insutype = insutypes[0]
  17066. //} else {
  17067. // for _, i := range insutypes {
  17068. // if i == "390" {
  17069. // is390 = 1
  17070. // }
  17071. //
  17072. // if i == "310" {
  17073. // is310 = 1
  17074. // }
  17075. // }
  17076. //}
  17077. //if is390 == 1 {
  17078. // insutype = "390"
  17079. //}
  17080. //if is310 == 1 {
  17081. // insutype = "310"
  17082. //}
  17083. //if len(insutypes) == 0 {
  17084. // insutype = "310"
  17085. //}
  17086. PsnNo = res.Output.Baseinfo.PsnNo
  17087. PsnCertType = res.Output.Baseinfo.PsnCertType
  17088. Certno = res.Output.Baseinfo.Certno
  17089. PsnName = res.Output.Baseinfo.PsnName
  17090. Gend = res.Output.Baseinfo.Gend
  17091. Naty = res.Output.Baseinfo.Naty
  17092. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17093. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17094. infoStr = string(Iinfos)
  17095. idetinfoStr = string(Idetinfos)
  17096. infocode = res.Infcode
  17097. //infocode = 0
  17098. //verify_number = psn_info.VerifyNumber
  17099. } else {
  17100. psn_info, _ := service.GetPsnByPatientId(id)
  17101. PsnNo = psn_info.PsnNo
  17102. PsnCertType = psn_info.PsnCertType
  17103. Certno = psn_info.Certno
  17104. PsnName = psn_info.PsnName
  17105. Gend = psn_info.Gend
  17106. Naty = psn_info.Naty
  17107. Brdy = psn_info.Brdy
  17108. Age = psn_info.Age
  17109. infoStr = psn_info.Insuinfo
  17110. idetinfoStr = psn_info.Idetinfo
  17111. infocode = 0
  17112. verify_number = psn_info.VerifyNumber
  17113. }
  17114. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17115. if id_card_type == 1 {
  17116. psn_info, _ := service.GetPsnByPatientId(id)
  17117. PsnNo = psn_info.PsnNo
  17118. PsnCertType = psn_info.PsnCertType
  17119. Certno = psn_info.Certno
  17120. PsnName = psn_info.PsnName
  17121. Gend = psn_info.Gend
  17122. Naty = psn_info.Naty
  17123. Brdy = psn_info.Brdy
  17124. Age = psn_info.Age
  17125. infoStr = psn_info.Insuinfo
  17126. idetinfoStr = psn_info.Idetinfo
  17127. infocode = 0
  17128. verify_number = psn_info.VerifyNumber
  17129. } else if id_card_type == 2 {
  17130. 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)
  17131. fmt.Println(errMsgLog)
  17132. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17134. utils.ErrorLog("解析失败:%v", err)
  17135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17136. return
  17137. }
  17138. PsnNo = res.Output.Baseinfo.PsnNo
  17139. PsnCertType = res.Output.Baseinfo.PsnCertType
  17140. Certno = res.Output.Baseinfo.Certno
  17141. PsnName = res.Output.Baseinfo.PsnName
  17142. Gend = res.Output.Baseinfo.Gend
  17143. Naty = res.Output.Baseinfo.Naty
  17144. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17145. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17146. infoStr = string(Iinfos)
  17147. idetinfoStr = string(Idetinfos)
  17148. infocode = res.Infcode
  17149. }
  17150. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17151. if id_card_type == 1 {
  17152. psn_info, _ := service.GetPsnByPatientId(id)
  17153. PsnNo = psn_info.PsnNo
  17154. PsnCertType = psn_info.PsnCertType
  17155. Certno = psn_info.Certno
  17156. PsnName = psn_info.PsnName
  17157. Gend = psn_info.Gend
  17158. Naty = psn_info.Naty
  17159. Brdy = psn_info.Brdy
  17160. Age = psn_info.Age
  17161. infoStr = psn_info.Insuinfo
  17162. idetinfoStr = psn_info.Idetinfo
  17163. infocode = 0
  17164. verify_number = psn_info.VerifyNumber
  17165. } else if id_card_type == 2 {
  17166. 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, "")
  17167. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17169. utils.ErrorLog("解析失败:%v", err)
  17170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17171. return
  17172. }
  17173. PsnNo = res.Output.Baseinfo.PsnNo
  17174. PsnCertType = res.Output.Baseinfo.PsnCertType
  17175. Certno = res.Output.Baseinfo.Certno
  17176. PsnName = res.Output.Baseinfo.PsnName
  17177. Gend = res.Output.Baseinfo.Gend
  17178. Naty = res.Output.Baseinfo.Naty
  17179. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17180. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17181. infoStr = string(Iinfos)
  17182. idetinfoStr = string(Idetinfos)
  17183. infocode = res.Infcode
  17184. } else {
  17185. psn_info, _ := service.GetPsnByPatientId(id)
  17186. PsnNo = psn_info.PsnNo
  17187. PsnCertType = psn_info.PsnCertType
  17188. Certno = psn_info.Certno
  17189. PsnName = psn_info.PsnName
  17190. Gend = psn_info.Gend
  17191. Naty = psn_info.Naty
  17192. Brdy = psn_info.Brdy
  17193. Age = psn_info.Age
  17194. infoStr = psn_info.Insuinfo
  17195. idetinfoStr = psn_info.Idetinfo
  17196. infocode = 0
  17197. verify_number = psn_info.VerifyNumber
  17198. }
  17199. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17200. psn_info, _ := service.GetPsnByPatientId(id)
  17201. PsnNo = psn_info.PsnNo
  17202. PsnCertType = psn_info.PsnCertType
  17203. Certno = psn_info.Certno
  17204. PsnName = psn_info.PsnName
  17205. Gend = psn_info.Gend
  17206. Naty = psn_info.Naty
  17207. Brdy = psn_info.Brdy
  17208. Age = psn_info.Age
  17209. infoStr = psn_info.Insuinfo
  17210. idetinfoStr = psn_info.Idetinfo
  17211. infocode = 0
  17212. verify_number = psn_info.VerifyNumber
  17213. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17214. if id_card_type == 1 {
  17215. psn_info, _ := service.GetPsnByPatientId(id)
  17216. PsnNo = psn_info.PsnNo
  17217. PsnCertType = psn_info.PsnCertType
  17218. Certno = psn_info.Certno
  17219. PsnName = psn_info.PsnName
  17220. Gend = psn_info.Gend
  17221. Naty = psn_info.Naty
  17222. Brdy = psn_info.Brdy
  17223. Age = psn_info.Age
  17224. infoStr = psn_info.Insuinfo
  17225. idetinfoStr = psn_info.Idetinfo
  17226. infocode = 0
  17227. verify_number = psn_info.VerifyNumber
  17228. } else if id_card_type == 2 {
  17229. 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)
  17230. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17231. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17232. utils.ErrorLog("解析失败:%v", err)
  17233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17234. return
  17235. }
  17236. PsnNo = res.Output.Baseinfo.PsnNo
  17237. PsnCertType = res.Output.Baseinfo.PsnCertType
  17238. Certno = res.Output.Baseinfo.Certno
  17239. PsnName = res.Output.Baseinfo.PsnName
  17240. Gend = res.Output.Baseinfo.Gend
  17241. Naty = res.Output.Baseinfo.Naty
  17242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17244. infoStr = string(Iinfos)
  17245. idetinfoStr = string(Idetinfos)
  17246. infocode = res.Infcode
  17247. } else if id_card_type == 4 {
  17248. psn_info, _ := service.GetPsnByPatientId(id)
  17249. PsnNo = psn_info.PsnNo
  17250. PsnCertType = psn_info.PsnCertType
  17251. Certno = psn_info.Certno
  17252. PsnName = psn_info.PsnName
  17253. Gend = psn_info.Gend
  17254. Naty = psn_info.Naty
  17255. Brdy = psn_info.Brdy
  17256. Age = psn_info.Age
  17257. infoStr = psn_info.Insuinfo
  17258. idetinfoStr = psn_info.Idetinfo
  17259. infocode = 0
  17260. verify_number = psn_info.VerifyNumber
  17261. }
  17262. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17263. var result string
  17264. var requestLog string
  17265. 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), "")
  17266. if id_card_type == 4 {
  17267. psn_info, _ := service.GetPsnByPatientId(id)
  17268. PsnNo = psn_info.PsnNo
  17269. PsnCertType = psn_info.PsnCertType
  17270. Certno = psn_info.Certno
  17271. PsnName = psn_info.PsnName
  17272. Gend = psn_info.Gend
  17273. Naty = psn_info.Naty
  17274. Brdy = psn_info.Brdy
  17275. Age = psn_info.Age
  17276. infoStr = psn_info.Insuinfo
  17277. idetinfoStr = psn_info.Idetinfo
  17278. infocode = 0
  17279. verify_number = psn_info.VerifyNumber
  17280. } else {
  17281. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17282. if miConfig.Code == "H15049901371" {
  17283. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17284. utils.ErrorLog("解析失败:%v", err)
  17285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17286. return
  17287. }
  17288. res.ErrMsg = res10265.ErrMsg
  17289. res.Output = res10265.Output
  17290. res.InfRefmsgid = res10265.InfRefmsgid
  17291. } else {
  17292. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17293. utils.ErrorLog("解析失败:%v", err)
  17294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17295. return
  17296. }
  17297. }
  17298. PsnNo = res.Output.Baseinfo.PsnNo
  17299. PsnCertType = res.Output.Baseinfo.PsnCertType
  17300. Certno = res.Output.Baseinfo.Certno
  17301. PsnName = res.Output.Baseinfo.PsnName
  17302. Gend = res.Output.Baseinfo.Gend
  17303. Naty = res.Output.Baseinfo.Naty
  17304. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17305. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17306. infoStr = string(Iinfos)
  17307. idetinfoStr = string(Idetinfos)
  17308. if miConfig.Code == "H15049901371" {
  17309. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17310. } else {
  17311. infocode = res.Infcode
  17312. }
  17313. }
  17314. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17315. psn_info, _ := service.GetPsnByPatientId(id)
  17316. PsnNo = psn_info.PsnNo
  17317. PsnCertType = psn_info.PsnCertType
  17318. Certno = psn_info.Certno
  17319. PsnName = psn_info.PsnName
  17320. Gend = psn_info.Gend
  17321. Naty = psn_info.Naty
  17322. Brdy = psn_info.Brdy
  17323. Age = psn_info.Age
  17324. infoStr = psn_info.Insuinfo
  17325. idetinfoStr = psn_info.Idetinfo
  17326. infocode = 0
  17327. verify_number = psn_info.VerifyNumber
  17328. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17329. psn_info, _ := service.GetPsnByPatientId(id)
  17330. PsnNo = psn_info.PsnNo
  17331. PsnCertType = psn_info.PsnCertType
  17332. Certno = psn_info.Certno
  17333. PsnName = psn_info.PsnName
  17334. Gend = psn_info.Gend
  17335. Naty = psn_info.Naty
  17336. Brdy = psn_info.Brdy
  17337. Age = psn_info.Age
  17338. infoStr = psn_info.Insuinfo
  17339. idetinfoStr = psn_info.Idetinfo
  17340. infocode = 0
  17341. verify_number = psn_info.VerifyNumber
  17342. } else {
  17343. var result string
  17344. var requestLog string
  17345. //if miConfig.UserOrgId == 10138 {
  17346. if id_card_type != 4 || id_card_type != 1 {
  17347. var insa string
  17348. if len(patient.InsuplcAdmdvs) > 0 {
  17349. insa = patient.InsuplcAdmdvs
  17350. } else {
  17351. insa = miConfig.InsuplcAdmdvs
  17352. }
  17353. //psn_info, _ := service.GetPsnByPatientId(id)
  17354. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17355. 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)
  17356. }
  17357. //}
  17358. //else {
  17359. // var insa string
  17360. // if len(patient.InsuplcAdmdvs) > 0 {
  17361. // insa = patient.InsuplcAdmdvs
  17362. // } else {
  17363. // insa = miConfig.InsuplcAdmdvs
  17364. // }
  17365. // 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)
  17366. //}
  17367. if id_card_type == 4 || id_card_type == 1 {
  17368. psn_info, _ := service.GetPsnByPatientId(id)
  17369. PsnNo = psn_info.PsnNo
  17370. PsnCertType = psn_info.PsnCertType
  17371. Certno = psn_info.Certno
  17372. PsnName = psn_info.PsnName
  17373. Gend = psn_info.Gend
  17374. Naty = psn_info.Naty
  17375. Brdy = psn_info.Brdy
  17376. Age = psn_info.Age
  17377. infoStr = psn_info.Insuinfo
  17378. idetinfoStr = psn_info.Idetinfo
  17379. infocode = 0
  17380. verify_number = psn_info.VerifyNumber
  17381. } else {
  17382. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17383. if miConfig.Code == "H15049901371" {
  17384. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17385. utils.ErrorLog("解析失败:%v", err)
  17386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17387. return
  17388. }
  17389. res.ErrMsg = res10265.ErrMsg
  17390. res.Output = res10265.Output
  17391. res.InfRefmsgid = res10265.InfRefmsgid
  17392. } else {
  17393. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17394. utils.ErrorLog("解析失败:%v", err)
  17395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17396. return
  17397. }
  17398. }
  17399. PsnNo = res.Output.Baseinfo.PsnNo
  17400. PsnCertType = res.Output.Baseinfo.PsnCertType
  17401. Certno = res.Output.Baseinfo.Certno
  17402. PsnName = res.Output.Baseinfo.PsnName
  17403. Gend = res.Output.Baseinfo.Gend
  17404. Naty = res.Output.Baseinfo.Naty
  17405. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17406. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17407. infoStr = string(Iinfos)
  17408. idetinfoStr = string(Idetinfos)
  17409. if miConfig.Code == "H15049901371" {
  17410. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17411. } else {
  17412. infocode = res.Infcode
  17413. }
  17414. }
  17415. }
  17416. if infocode == 0 {
  17417. his := models.VMHisPatient{
  17418. Name: name,
  17419. Gender: gender,
  17420. Birthday: birthUnix,
  17421. MedicalTreatmentType: medical_care,
  17422. IdType: certificates,
  17423. IdCardNo: id_card,
  17424. BalanceAccountsType: settlementValue,
  17425. SocialType: social_type,
  17426. MedicalInsuranceNumber: medical_insurance_card,
  17427. RegisterType: register_type,
  17428. RegisterCost: registration_fee,
  17429. TreatmentCost: medical_expenses,
  17430. Status: 1,
  17431. Ctime: time.Now().Unix(),
  17432. Mtime: time.Now().Unix(),
  17433. PsnNo: PsnNo,
  17434. PsnCertType: PsnCertType,
  17435. Certno: Certno,
  17436. PsnName: PsnName,
  17437. Gend: Gend,
  17438. Naty: Naty,
  17439. Brdy: Brdy,
  17440. Age: Age,
  17441. Iinfo: infoStr,
  17442. Idetinfo: idetinfoStr,
  17443. PatientId: patient.ID,
  17444. RecordDate: theTime.Unix(),
  17445. UserOrgId: adminInfo.CurrentOrgId,
  17446. AdminUserId: admin_user_id,
  17447. IsReturn: 1,
  17448. IdCardType: id_card_type,
  17449. Doctor: doctor,
  17450. Departments: department,
  17451. MdtrtGrpType: mdtrt_type,
  17452. }
  17453. timestamp := time.Now().Unix()
  17454. tempTime := time.Unix(timestamp, 0)
  17455. timeFormat := tempTime.Format("20060102150405")
  17456. chrgBchno := rand.Intn(100000) + 10000
  17457. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17458. his.Number = ipt_otp_no
  17459. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17460. department, _ := service.GetDepartMentDetail(department)
  17461. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17462. IdCardNo := ""
  17463. if id_card_type == 1 {
  17464. // IdCardNo = medical_insurance_card
  17465. IdCardNo = patient.IdCardNo
  17466. } else {
  17467. IdCardNo = patient.IdCardNo
  17468. }
  17469. var rf []*ResultFive
  17470. json.Unmarshal([]byte(his.Iinfo), &rf)
  17471. var insutypes []*ResultFive
  17472. var insutype string
  17473. var insuplc_admdvs_temp string
  17474. var is390 int = 0
  17475. var is310 int = 0
  17476. for _, item := range rf {
  17477. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17478. insutypes = append(insutypes, item)
  17479. }
  17480. }
  17481. if len(insutypes) == 1 {
  17482. insutype = insutypes[0].Insutype
  17483. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17484. if insutype == "390" {
  17485. is390 = 1
  17486. }
  17487. if insutype == "310" {
  17488. is310 = 1
  17489. }
  17490. } else {
  17491. for _, i := range insutypes {
  17492. if i.Insutype == "390" {
  17493. is390 = 1
  17494. }
  17495. if i.Insutype == "310" {
  17496. is310 = 1
  17497. }
  17498. }
  17499. }
  17500. if is390 == 1 {
  17501. insutype = "390"
  17502. }
  17503. if is310 == 1 {
  17504. insutype = "310"
  17505. }
  17506. fmt.Println(social_type)
  17507. if social_type > 0 {
  17508. insutype = strconv.FormatInt(social_type, 10)
  17509. }
  17510. var infocode int64
  17511. var resThree ResultThree
  17512. var resThree10265 ResultThree10265
  17513. if len(insuplc_admdvs) == 0 {
  17514. psn_info, _ := service.GetPsnByPatientId(id)
  17515. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17516. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17517. //}
  17518. } else {
  17519. insuplc_admdvs_temp = insuplc_admdvs
  17520. }
  17521. if miConfig.MdtrtareaAdmvs == "421300" {
  17522. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17523. psn_info, _ := service.GetPsnByPatientId(id)
  17524. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17525. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17526. "&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
  17527. resp, requestErr := http.Get(api)
  17528. if requestErr != nil {
  17529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17530. return
  17531. }
  17532. body, ioErr := ioutil.ReadAll(resp.Body)
  17533. if ioErr != nil {
  17534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17536. return
  17537. }
  17538. var respJSON map[string]interface{}
  17539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17542. return
  17543. }
  17544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17545. result, _ := json.Marshal(respJSON)
  17546. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17547. utils.ErrorLog("解析失败:%v", err)
  17548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17549. return
  17550. }
  17551. infocode = resThree.Infcode
  17552. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17553. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17554. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17555. // insuplc_admdvs_temp =
  17556. //}
  17557. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17558. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17559. //}
  17560. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17561. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17562. "&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
  17563. resp, requestErr := http.Get(api)
  17564. if requestErr != nil {
  17565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17566. return
  17567. }
  17568. body, ioErr := ioutil.ReadAll(resp.Body)
  17569. if ioErr != nil {
  17570. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17572. return
  17573. }
  17574. var respJSON map[string]interface{}
  17575. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17578. return
  17579. }
  17580. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17581. result, _ := json.Marshal(respJSON)
  17582. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17583. utils.ErrorLog("解析失败:%v", err)
  17584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17585. return
  17586. }
  17587. infocode = resThree.Infcode
  17588. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17589. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17590. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17591. // insuplc_admdvs_temp =
  17592. //}
  17593. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17594. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17595. //}
  17596. utils.ErrorLog("解析失败:%v", insutype)
  17597. utils.ErrorLog("解析失败:%v", PsnNo)
  17598. utils.ErrorLog("解析失败:%v", Certno)
  17599. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17600. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17601. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17602. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17603. utils.ErrorLog("解析失败:%v", PsnNo)
  17604. utils.ErrorLog("解析失败:%v", department.Number )
  17605. utils.ErrorLog("解析失败:%v", department.Name )
  17606. utils.ErrorLog("解析失败:%v", roles.UserName)
  17607. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17608. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17609. "&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
  17610. resp, requestErr := http.Get(api)
  17611. if requestErr != nil {
  17612. utils.ErrorLog("解析失败:%v", requestErr)
  17613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17614. return
  17615. }
  17616. body, ioErr := ioutil.ReadAll(resp.Body)
  17617. if ioErr != nil {
  17618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17620. return
  17621. }
  17622. var respJSON map[string]interface{}
  17623. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17626. return
  17627. }
  17628. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17629. result, _ := json.Marshal(respJSON)
  17630. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17631. utils.ErrorLog("解析失败:%v", err)
  17632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17633. return
  17634. }
  17635. infocode = resThree.Infcode
  17636. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17637. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17638. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17639. // insuplc_admdvs_temp =
  17640. //}
  17641. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17642. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17643. //}
  17644. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17645. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17646. "&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
  17647. resp, requestErr := http.Get(api)
  17648. if requestErr != nil {
  17649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17650. return
  17651. }
  17652. body, ioErr := ioutil.ReadAll(resp.Body)
  17653. if ioErr != nil {
  17654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17656. return
  17657. }
  17658. var respJSON map[string]interface{}
  17659. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17662. return
  17663. }
  17664. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17665. result, _ := json.Marshal(respJSON)
  17666. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17667. utils.ErrorLog("解析失败:%v", err)
  17668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17669. return
  17670. }
  17671. infocode = resThree.Infcode
  17672. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17673. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17674. psn_info, _ := service.GetPsnByPatientId(id)
  17675. var verify_number string
  17676. if id_card_type == 4 {
  17677. verify_number = psn_info.VerifyNumber
  17678. } else if id_card_type == 1 {
  17679. bas := strings.Split(psn_info.CardInfo, "|")
  17680. cardNumber := bas[2]
  17681. verify_number = cardNumber
  17682. }
  17683. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17684. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17685. "&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
  17686. resp, requestErr := http.Get(api)
  17687. if requestErr != nil {
  17688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17689. return
  17690. }
  17691. body, ioErr := ioutil.ReadAll(resp.Body)
  17692. if ioErr != nil {
  17693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17695. return
  17696. }
  17697. var respJSON map[string]interface{}
  17698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17701. return
  17702. }
  17703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17704. result, _ := json.Marshal(respJSON)
  17705. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17706. // utils.ErrorLog("解析失败:%v", err)
  17707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17708. // return
  17709. //}
  17710. //infocode = resThree.Infcode
  17711. //result, _ := json.Marshal(respJSON)
  17712. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17713. utils.ErrorLog("解析失败:%v", err)
  17714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17715. return
  17716. }
  17717. resThree.ErrMsg = resThree10265.ErrMsg
  17718. resThree.Output = resThree10265.Output
  17719. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17720. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17721. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17722. psn_info, _ := service.GetPsnByPatientId(id)
  17723. his.PsnNo = psn_info.PsnNo
  17724. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17725. var cert_no string
  17726. if id_card_type == 3 {
  17727. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17728. cert_no = IdCardNo
  17729. } else if id_card_type == 4 {
  17730. cert_no = IdCardNo
  17731. psn_info.VerifyNumber = psn_info.VerifyNumber
  17732. } else {
  17733. bas := strings.Split(psn_info.CardInfo, "|")
  17734. cert_no = bas[2]
  17735. }
  17736. var hisPrescription []*models.HisPrescription
  17737. for _, item := range rf {
  17738. if item.Insutype == insutype {
  17739. //insuplc_admdvs = item.InsuplcAdmdvs
  17740. his.InsuplcAdmdvs = insuplc_admdvs
  17741. }
  17742. }
  17743. his.Insutype = insutype
  17744. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17745. fmt.Println(res3101)
  17746. fmt.Println(res3101.Infcode)
  17747. if res3101.Infcode == "0" {
  17748. fmt.Println("33333333")
  17749. if len(res3101.Output.Result) > 0 {
  17750. fmt.Println("222222")
  17751. for _, item := range res3101.Output.Result {
  17752. if len(res3101.ErrMsg) == 0 {
  17753. res3101.ErrMsg = item.VolaCont
  17754. } else {
  17755. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17756. }
  17757. }
  17758. c.ServeSuccessJSON(map[string]interface{}{
  17759. "failed_code": -10,
  17760. "msg": res3101.ErrMsg,
  17761. })
  17762. return
  17763. } else {
  17764. fmt.Println("11111")
  17765. var api string
  17766. if miConfig.MdtrtareaAdmvs == "320921" {
  17767. ipt_otp_no = timeFormat
  17768. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17769. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17770. "&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
  17771. } else {
  17772. ipt_otp_no = timeFormat
  17773. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17774. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17775. "&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
  17776. }
  17777. resp, requestErr := http.Get(api)
  17778. if requestErr != nil {
  17779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17780. return
  17781. }
  17782. body, ioErr := ioutil.ReadAll(resp.Body)
  17783. if ioErr != nil {
  17784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17786. return
  17787. }
  17788. var respJSON map[string]interface{}
  17789. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17792. return
  17793. }
  17794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17795. result, _ := json.Marshal(respJSON)
  17796. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17797. utils.ErrorLog("解析失败:%v", err)
  17798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17799. return
  17800. }
  17801. resThree.ErrMsg = resThree10265.ErrMsg
  17802. resThree.Output = resThree10265.Output
  17803. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17804. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17805. }
  17806. } else if res3101.Infcode != "0" {
  17807. c.ServeSuccessJSON(map[string]interface{}{
  17808. "failed_code": -10,
  17809. "msg": res3101.ErrMsg,
  17810. })
  17811. return
  17812. }
  17813. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17814. psn_info, _ := service.GetPsnByPatientId(id)
  17815. var cert_no string
  17816. if id_card_type == 1 {
  17817. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17818. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17819. } else if id_card_type == 4 {
  17820. cert_no = psn_info.VerifyNumber
  17821. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17822. } else {
  17823. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17824. cert_no = psn_info.VerifyNumber
  17825. }
  17826. 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)
  17827. saveLog(result, requestLog, "2201", "挂号")
  17828. if miConfig.Code == "H15049901371" {
  17829. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17830. utils.ErrorLog("解析失败:%v", err)
  17831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17832. return
  17833. }
  17834. resThree.ErrMsg = resThree10265.ErrMsg
  17835. resThree.Output = resThree10265.Output
  17836. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17837. } else {
  17838. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17839. utils.ErrorLog("解析失败:%v", err)
  17840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17841. return
  17842. }
  17843. }
  17844. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17845. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17846. psn_info, _ := service.GetPsnByPatientId(id)
  17847. var result string
  17848. var requestLog string
  17849. if id_card_type == 1 {
  17850. bas := strings.Split(psn_info.CardInfo, "|")
  17851. basNumber := bas[2]
  17852. card_sn := bas[3]
  17853. 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)
  17854. saveLog(result, requestLog, "2201A", "挂号")
  17855. } else if id_card_type == 2 {
  17856. 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, "", "", "", "", "", "")
  17857. saveLog(result, requestLog, "2201A", "挂号")
  17858. } else {
  17859. 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)
  17860. saveLog(result, requestLog, "2201A", "挂号")
  17861. }
  17862. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17863. utils.ErrorLog("解析失败:%v", err)
  17864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17865. return
  17866. }
  17867. infocode = resThree.Infcode
  17868. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17869. psn_info, _ := service.GetPsnByPatientId(id)
  17870. his.PsnNo = psn_info.PsnNo
  17871. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17872. var cert_no string
  17873. if id_card_type == 1 {
  17874. bas := strings.Split(psn_info.CardInfo, "|")
  17875. cert_no = bas[2]
  17876. } else if id_card_type == 4 {
  17877. cert_no = IdCardNo
  17878. psn_info.VerifyNumber = psn_info.VerifyNumber
  17879. } else {
  17880. cert_no = IdCardNo
  17881. psn_info.VerifyNumber = cert_no
  17882. }
  17883. for _, item := range rf {
  17884. if item.Insutype == insutype {
  17885. his.InsuplcAdmdvs = insuplc_admdvs
  17886. }
  17887. }
  17888. his.Insutype = insutype
  17889. var api string
  17890. ipt_otp_no = timeFormat
  17891. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17892. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17893. "&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
  17894. resp, requestErr := http.Get(api)
  17895. if requestErr != nil {
  17896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17897. return
  17898. }
  17899. body, ioErr := ioutil.ReadAll(resp.Body)
  17900. if ioErr != nil {
  17901. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17903. return
  17904. }
  17905. var respJSON map[string]interface{}
  17906. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17907. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17909. return
  17910. }
  17911. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17912. if status == "0" {
  17913. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17914. c.ServeSuccessJSON(map[string]interface{}{
  17915. "failed_code": -10,
  17916. "msg": err_msg,
  17917. })
  17918. return
  17919. }
  17920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17921. result, _ := json.Marshal(respJSON)
  17922. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17923. utils.ErrorLog("解析失败:%v", err)
  17924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17925. return
  17926. }
  17927. infocode = resThree.Infcode
  17928. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17929. psn_info, _ := service.GetPsnByPatientId(id)
  17930. var result string
  17931. var requestLog string
  17932. if id_card_type == 1 {
  17933. bas := strings.Split(psn_info.CardInfo, "|")
  17934. basNumber := bas[2]
  17935. card_sn := bas[3]
  17936. 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)
  17937. saveLog(result, requestLog, "2201A", "挂号")
  17938. } else if id_card_type == 2 {
  17939. 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, "", "")
  17940. saveLog(result, requestLog, "2201A", "挂号")
  17941. } else {
  17942. 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, "", "")
  17943. saveLog(result, requestLog, "2201A", "挂号")
  17944. }
  17945. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17946. utils.ErrorLog("解析失败:%v", err)
  17947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17948. return
  17949. }
  17950. infocode = resThree.Infcode
  17951. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17952. psn_info, _ := service.GetPsnByPatientId(id)
  17953. 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)
  17954. saveLog(result, requestLog, "2201A", "挂号")
  17955. if miConfig.Code == "H15049901371" {
  17956. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17957. utils.ErrorLog("解析失败:%v", err)
  17958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17959. return
  17960. }
  17961. resThree.ErrMsg = resThree10265.ErrMsg
  17962. resThree.Output = resThree10265.Output
  17963. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17964. } else {
  17965. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17966. utils.ErrorLog("解析失败:%v", err)
  17967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17968. return
  17969. }
  17970. }
  17971. if miConfig.Code == "H15049901371" {
  17972. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17973. } else {
  17974. infocode = resThree.Infcode
  17975. }
  17976. } else {
  17977. psn_info, _ := service.GetPsnByPatientId(id)
  17978. if id_card_type == 4 || id_card_type == 1 {
  17979. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17980. }
  17981. var rf []*ResultFive
  17982. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17983. var insutypes []*ResultFive
  17984. var insutype string
  17985. var is390 int = 0
  17986. var is310 int = 0
  17987. for _, item := range rf {
  17988. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17989. insutypes = append(insutypes, item)
  17990. }
  17991. }
  17992. if len(insutypes) == 1 {
  17993. insutype = insutypes[0].Insutype
  17994. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17995. } else {
  17996. for _, i := range insutypes {
  17997. if i.Insutype == "390" {
  17998. is390 = 1
  17999. }
  18000. if i.Insutype == "310" {
  18001. is310 = 1
  18002. }
  18003. }
  18004. }
  18005. if is390 == 1 {
  18006. insutype = "390"
  18007. }
  18008. if is310 == 1 {
  18009. insutype = "310"
  18010. }
  18011. fmt.Println(len(insutypes))
  18012. if len(insutypes) == 0 {
  18013. for index, item := range rf {
  18014. if index == 0 {
  18015. insutype = item.Insutype
  18016. insuplc_admdvs = item.InsuplcAdmdvs
  18017. }
  18018. }
  18019. fmt.Println(insutype)
  18020. fmt.Println(insuplc_admdvs)
  18021. }
  18022. if social_type > 0 {
  18023. insutype = strconv.FormatInt(social_type, 10)
  18024. }
  18025. fmt.Println("--------")
  18026. fmt.Println(psn_info)
  18027. fmt.Println(psn_info.PsnNo)
  18028. if miConfig.MdtrtareaAdmvs == "441202" {
  18029. var hisPrescription []*models.HisPrescription
  18030. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  18031. if res3101.Infcode == 0 {
  18032. fmt.Println("33333333")
  18033. if len(res3101.Output.Result) > 0 {
  18034. fmt.Println("222222")
  18035. for _, item := range res3101.Output.Result {
  18036. if len(res3101.ErrMsg) == 0 {
  18037. res3101.ErrMsg = item.VolaCont
  18038. } else {
  18039. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  18040. }
  18041. }
  18042. c.ServeSuccessJSON(map[string]interface{}{
  18043. "failed_code": -10,
  18044. "msg": res3101.ErrMsg,
  18045. })
  18046. return
  18047. } else {
  18048. hour := time.Now().Format("15")
  18049. min := time.Now().Format("04")
  18050. sec := time.Now().Format("05")
  18051. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18052. fmt.Println(record_time_two)
  18053. 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)
  18054. saveLog(result, requestLog, "2201A", "挂号")
  18055. if miConfig.Code == "H15049901371" {
  18056. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18057. utils.ErrorLog("解析失败:%v", err)
  18058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18059. return
  18060. }
  18061. resThree.ErrMsg = resThree10265.ErrMsg
  18062. resThree.Output = resThree10265.Output
  18063. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18064. } else {
  18065. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18066. utils.ErrorLog("解析失败:%v", err)
  18067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18068. return
  18069. }
  18070. }
  18071. if miConfig.Code == "H15049901371" {
  18072. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18073. } else {
  18074. infocode = resThree.Infcode
  18075. }
  18076. }
  18077. } else if res3101.Infcode != 0 {
  18078. c.ServeSuccessJSON(map[string]interface{}{
  18079. "failed_code": -10,
  18080. "msg": res3101.ErrMsg,
  18081. })
  18082. return
  18083. }
  18084. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18085. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  18086. psn_info, _ := service.GetPsnByPatientId(id)
  18087. var verify_number string
  18088. if id_card_type == 4 {
  18089. verify_number = psn_info.VerifyNumber
  18090. } else if id_card_type == 1 {
  18091. bas := strings.Split(psn_info.CardInfo, "|")
  18092. cardNumber := bas[2]
  18093. verify_number = cardNumber
  18094. } else {
  18095. verify_number = psn_info.Certno
  18096. }
  18097. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18098. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18099. "&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
  18100. resp, requestErr := http.Get(api)
  18101. if requestErr != nil {
  18102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18103. return
  18104. }
  18105. body, ioErr := ioutil.ReadAll(resp.Body)
  18106. if ioErr != nil {
  18107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18109. return
  18110. }
  18111. var respJSON map[string]interface{}
  18112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18115. return
  18116. }
  18117. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18118. result, _ := json.Marshal(respJSON)
  18119. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18120. utils.ErrorLog("解析失败:%v", err)
  18121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18122. return
  18123. }
  18124. infocode = resThree.Infcode
  18125. } else {
  18126. hour := time.Now().Format("15")
  18127. min := time.Now().Format("04")
  18128. sec := time.Now().Format("05")
  18129. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18130. if id_card_type == 1 {
  18131. for _, item := range rf {
  18132. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18133. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18134. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18135. } else if strconv.FormatInt(social_type, 10) == "390" {
  18136. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18137. } else {
  18138. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18139. }
  18140. }
  18141. }
  18142. }
  18143. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18144. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18145. }
  18146. if id_card_type == 1 {
  18147. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18148. bas := strings.Split(psn_info.CardInfo, "|")
  18149. basNumber := bas[1]
  18150. IdCardNo = basNumber
  18151. }
  18152. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18153. IdCardNo = psn_info.VerifyNumber
  18154. }
  18155. 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)
  18156. saveLog(result, requestLog, "2201A", "挂号")
  18157. if miConfig.Code == "H15049901371" {
  18158. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18159. utils.ErrorLog("解析失败:%v", err)
  18160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18161. return
  18162. }
  18163. resThree.ErrMsg = resThree10265.ErrMsg
  18164. resThree.Output = resThree10265.Output
  18165. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18166. } else {
  18167. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18168. utils.ErrorLog("解析失败:%v", err)
  18169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18170. return
  18171. }
  18172. }
  18173. if miConfig.Code == "H15049901371" {
  18174. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18175. } else {
  18176. infocode = resThree.Infcode
  18177. }
  18178. }
  18179. }
  18180. if infocode != 0 {
  18181. adminUser := c.GetAdminUserInfo()
  18182. errlog := &models.HisOrderError{
  18183. UserOrgId: adminUser.CurrentOrgId,
  18184. Ctime: time.Now().Unix(),
  18185. Mtime: time.Now().Unix(),
  18186. ErrMsg: resThree.ErrMsg,
  18187. Status: 1,
  18188. PatientId: id,
  18189. RecordTime: recordDateTime,
  18190. Stage: 2,
  18191. }
  18192. service.CreateErrMsgLog(errlog)
  18193. c.ServeSuccessJSON(map[string]interface{}{
  18194. "failed_code": -10,
  18195. "msg": resThree.ErrMsg,
  18196. })
  18197. return
  18198. }
  18199. his.Number = resThree.Output.Data.MdtrtID
  18200. his.PsnNo = resThree.Output.Data.PsnNo
  18201. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18202. his.IdCardNo = patient.IdCardNo
  18203. his.PhoneNumber = patient.Phone
  18204. his.UserOrgId = adminInfo.CurrentOrgId
  18205. his.Insutype = insutype
  18206. his.Ctime = time.Now().Unix()
  18207. his.Mtime = time.Now().Unix()
  18208. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18209. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18210. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18211. }
  18212. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18213. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18214. }
  18215. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18216. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18217. }
  18218. his.Status = 1
  18219. his.MdtrtGrpType = mdtrt_type
  18220. service.UpdateHisPatientStatus(&his)
  18221. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18222. c.ServeSuccessJSON(map[string]interface{}{
  18223. "his_info": his,
  18224. })
  18225. } else {
  18226. adminUser := c.GetAdminUserInfo()
  18227. errlog := &models.HisOrderError{
  18228. UserOrgId: adminUser.CurrentOrgId,
  18229. Ctime: time.Now().Unix(),
  18230. Mtime: time.Now().Unix(),
  18231. ErrMsg: res.ErrMsg,
  18232. Status: 1,
  18233. PatientId: id,
  18234. RecordTime: recordDateTime,
  18235. Stage: 1,
  18236. }
  18237. service.CreateErrMsgLog(errlog)
  18238. c.ServeSuccessJSON(map[string]interface{}{
  18239. "failed_code": -10,
  18240. "msg": res.ErrMsg,
  18241. })
  18242. return
  18243. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18244. }
  18245. }
  18246. }
  18247. func (c *HisApiController) GetUploadInfo() {
  18248. id, _ := c.GetInt64("id")
  18249. record_time := c.GetString("record_time")
  18250. his_patient_id, _ := c.GetInt64("his_patient_id")
  18251. order_id, _ := c.GetInt64("order_id")
  18252. pay_way, _ := c.GetInt64("pay_way")
  18253. pay_ways := c.GetString("pay_ways")
  18254. oth_desc := c.GetString("oth_desc")
  18255. pay_price, _ := c.GetFloat("pay_price")
  18256. pay_card_no := c.GetString("pay_card_no")
  18257. discount_price, _ := c.GetFloat("discount_price")
  18258. preferential_price, _ := c.GetFloat("preferential_price")
  18259. reality_price, _ := c.GetFloat("reality_price")
  18260. found_price, _ := c.GetFloat("found_price")
  18261. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18262. private_price, _ := c.GetFloat("private_price")
  18263. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18264. admin_user_id, _ := c.GetInt64("admin_user_id")
  18265. fapiao_code := c.GetString("fapiao_code")
  18266. fapiao_number := c.GetString("fapiao_number")
  18267. diagnosis_id := c.GetString("diagnosis")
  18268. sick_type, _ := c.GetInt64("sick_type")
  18269. reg_type, _ := c.GetInt64("p_type")
  18270. begin_time := c.GetString("begin_time")
  18271. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18272. cash_pay := c.GetString("cash_pay")
  18273. band_card_pay := c.GetString("band_card_pay")
  18274. wechat_pay := c.GetString("wechat_pay")
  18275. ali_pay := c.GetString("ali_pay")
  18276. jifen_pay := c.GetString("jifen_pay")
  18277. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18278. fmt.Println(acct_used_flag)
  18279. id_str := c.GetString("ids")
  18280. ids_arr := strings.Split(id_str, ",")
  18281. timeLayout := "2006-01-02"
  18282. loc, _ := time.LoadLocation("Local")
  18283. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18284. if err != nil {
  18285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18286. return
  18287. }
  18288. recordDateTime := theTime.Unix()
  18289. adminUser := c.GetAdminUserInfo()
  18290. var tempOrder models.HisOrder
  18291. tempOrder, _ = service.GetHisOrderByID(order_id)
  18292. var prescriptions []*models.HisPrescription
  18293. var start_time int64
  18294. var end_time int64
  18295. //押金模块
  18296. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18297. tmp_decimal := c.GetString("tmp_decimal")
  18298. var decimal float64 //本次使用的押金
  18299. var errmsg error
  18300. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18301. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18302. return
  18303. }
  18304. if len(tmp_decimal) > 0 {
  18305. if tmp_decimal[0] == 45 {
  18306. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18307. return
  18308. }
  18309. }
  18310. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18311. fmt.Println(errs)
  18312. decimal = tt
  18313. //if adminUser.CurrentOrgId == 10106{
  18314. // if len(fapiao_code) == 0{
  18315. // fapiao_code = "144072080589"
  18316. // }
  18317. // if len(fapiao_number) == 0{
  18318. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18319. // if order.ID == 0{
  18320. // fapiao_number = "00001520"
  18321. // }else{
  18322. // //fapiao_code = "00001520"
  18323. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18324. // var zero string
  18325. // if fpNumber >= 1000{
  18326. // zero = "0000" + strconv.Itoa(fpNumber)
  18327. // }else if fpNumber >= 10000{
  18328. // zero = "000" + strconv.Itoa(fpNumber)
  18329. // } else if fpNumber >= 100000{
  18330. // zero = "00" + strconv.Itoa(fpNumber)
  18331. // } else if fpNumber >= 1000000{
  18332. // zero = "0" + strconv.Itoa(fpNumber)
  18333. // }else {
  18334. // zero = strconv.Itoa(fpNumber)
  18335. // }
  18336. // fapiao_number = zero
  18337. // }
  18338. // }
  18339. //}
  18340. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18341. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18342. var patientPrescription models.HisPrescriptionInfo
  18343. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18344. if patientPrescription.ID == 0 {
  18345. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18346. }
  18347. //if patientPrescription.Do
  18348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18349. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18350. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18351. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18352. var config []*models.HisXtDiagnoseConfig
  18353. for _, item := range diagnosis_ids {
  18354. id, _ := strconv.ParseInt(item, 10, 64)
  18355. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18356. config = append(config, &diagnosisConfig)
  18357. }
  18358. sickConfig, _ := service.FindSickById(sick_type)
  18359. //if tempOrder.ID == 0 {
  18360. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18361. //}
  18362. if tempOrder.ID == 0 {
  18363. var result string
  18364. var requestLog string
  18365. var res2 ResultSix
  18366. var res3 GZResultSix
  18367. var ressix10265 ResultSix10265
  18368. if miConfig.MdtrtareaAdmvs == "421300" {
  18369. data := make(map[string]interface{})
  18370. client := &http.Client{}
  18371. data["psn_no"] = his.PsnNo
  18372. data["mdtrt_id"] = his.Number
  18373. data["opter"] = roles.UserName
  18374. data["org_name"] = miConfig.OrgName
  18375. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18376. data["doctor_id"] = doctor_info.DoctorNumber
  18377. data["doctor_name"] = doctor_info.UserName
  18378. data["department"] = department.Name
  18379. data["fixmedins_code"] = miConfig.Code
  18380. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18381. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18382. data["secret_key"] = miConfig.SecretKey
  18383. data["sick_code"] = sickConfig.CountryCode
  18384. data["sick_name"] = sickConfig.ClassName
  18385. data["dept"] = strconv.FormatInt(department.ID, 10)
  18386. data["config"] = config
  18387. data["begin_time"] = begin_time
  18388. bytesData, _ := json.Marshal(data)
  18389. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18390. resp, _ := client.Do(req)
  18391. defer resp.Body.Close()
  18392. body, ioErr := ioutil.ReadAll(resp.Body)
  18393. if ioErr != nil {
  18394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18396. return
  18397. }
  18398. var respJSON map[string]interface{}
  18399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18402. return
  18403. }
  18404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18405. userJSONBytes, _ := json.Marshal(respJSON)
  18406. fmt.Println("log")
  18407. fmt.Println(string(userJSONBytes))
  18408. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18409. utils.ErrorLog("解析失败:%v", err)
  18410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18411. return
  18412. }
  18413. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18414. data := make(map[string]interface{})
  18415. client := &http.Client{}
  18416. data["psn_no"] = his.PsnNo
  18417. data["mdtrt_id"] = his.Number
  18418. data["opter"] = roles.UserName
  18419. data["org_name"] = miConfig.OrgName
  18420. if reg_type == 11 && his.Insutype == "390" {
  18421. data["med_type"] = "110104"
  18422. } else {
  18423. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18424. }
  18425. data["doctor_id"] = doctor_info.DoctorNumber
  18426. data["doctor_name"] = doctor_info.UserName
  18427. data["department"] = department.Name
  18428. data["fixmedins_code"] = miConfig.Code
  18429. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18430. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18431. data["secret_key"] = miConfig.SecretKey
  18432. data["sick_code"] = sickConfig.CountryCode
  18433. data["sick_name"] = sickConfig.ClassName
  18434. data["dept"] = strconv.FormatInt(department.ID, 10)
  18435. data["config"] = config
  18436. data["begin_time"] = begin_time
  18437. bytesData, _ := json.Marshal(data)
  18438. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18439. resp, _ := client.Do(req)
  18440. defer resp.Body.Close()
  18441. body, ioErr := ioutil.ReadAll(resp.Body)
  18442. if ioErr != nil {
  18443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18445. return
  18446. }
  18447. var respJSON map[string]interface{}
  18448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18451. return
  18452. }
  18453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18454. userJSONBytes, _ := json.Marshal(respJSON)
  18455. fmt.Println("log")
  18456. fmt.Println(string(userJSONBytes))
  18457. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18458. utils.ErrorLog("解析失败:%v", err)
  18459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18460. return
  18461. }
  18462. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18463. data := make(map[string]interface{})
  18464. client := &http.Client{}
  18465. data["psn_no"] = his.PsnNo
  18466. data["mdtrt_id"] = his.Number
  18467. data["opter"] = roles.UserName
  18468. data["org_name"] = miConfig.OrgName
  18469. if reg_type == 11 && his.Insutype == "390" {
  18470. data["med_type"] = "110104"
  18471. } else {
  18472. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18473. }
  18474. data["doctor_id"] = doctor_info.DoctorNumber
  18475. data["doctor_name"] = doctor_info.UserName
  18476. data["department"] = department.Name
  18477. data["fixmedins_code"] = miConfig.Code
  18478. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18479. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18480. data["secret_key"] = miConfig.SecretKey
  18481. data["sick_code"] = sickConfig.CountryCode
  18482. data["sick_name"] = sickConfig.ClassName
  18483. data["dept"] = strconv.FormatInt(department.ID, 10)
  18484. data["config"] = config
  18485. data["begin_time"] = begin_time
  18486. bytesData, _ := json.Marshal(data)
  18487. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18488. resp, _ := client.Do(req)
  18489. defer resp.Body.Close()
  18490. body, ioErr := ioutil.ReadAll(resp.Body)
  18491. if ioErr != nil {
  18492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18494. return
  18495. }
  18496. var respJSON map[string]interface{}
  18497. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18500. return
  18501. }
  18502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18503. userJSONBytes, _ := json.Marshal(respJSON)
  18504. fmt.Println("log")
  18505. fmt.Println(string(userJSONBytes))
  18506. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18507. utils.ErrorLog("解析失败:%v", err)
  18508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18509. return
  18510. }
  18511. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18512. data := make(map[string]interface{})
  18513. client := &http.Client{}
  18514. data["psn_no"] = his.PsnNo
  18515. data["mdtrt_id"] = his.Number
  18516. data["opter"] = roles.UserName
  18517. data["org_name"] = miConfig.OrgName
  18518. if reg_type == 11 && his.Insutype == "390" {
  18519. data["med_type"] = "110104"
  18520. } else {
  18521. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18522. }
  18523. data["doctor_id"] = doctor_info.DoctorNumber
  18524. data["doctor_name"] = doctor_info.UserName
  18525. data["department"] = department.Name
  18526. data["fixmedins_code"] = miConfig.Code
  18527. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18528. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18529. data["secret_key"] = miConfig.SecretKey
  18530. data["sick_code"] = sickConfig.CountryCode
  18531. data["sick_name"] = sickConfig.ClassName
  18532. data["dept"] = strconv.FormatInt(department.ID, 10)
  18533. data["config"] = config
  18534. data["begin_time"] = begin_time
  18535. bytesData, _ := json.Marshal(data)
  18536. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18537. resp, _ := client.Do(req)
  18538. defer resp.Body.Close()
  18539. body, ioErr := ioutil.ReadAll(resp.Body)
  18540. if ioErr != nil {
  18541. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18543. return
  18544. }
  18545. var respJSON map[string]interface{}
  18546. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18547. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18549. return
  18550. }
  18551. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18552. userJSONBytes, _ := json.Marshal(respJSON)
  18553. fmt.Println("log")
  18554. fmt.Println(string(userJSONBytes))
  18555. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18556. utils.ErrorLog("解析失败:%v", err)
  18557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18558. return
  18559. }
  18560. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18561. data := make(map[string]interface{})
  18562. client := &http.Client{}
  18563. data["psn_no"] = his.PsnNo
  18564. data["mdtrt_id"] = his.Number
  18565. data["doctor"] = roles.UserName
  18566. data["department"] = department.Name
  18567. data["org_name"] = miConfig.OrgName
  18568. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18569. data["doctor_id"] = doctor_info.DoctorNumber
  18570. data["new_doctor_name"] = doctor_info.UserName
  18571. data["fixmedins_code"] = miConfig.Code
  18572. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18573. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18574. data["secret_key"] = miConfig.SecretKey
  18575. data["sick_code"] = sickConfig.CountryCode
  18576. data["sick_name"] = sickConfig.ClassName
  18577. data["url"] = miConfig.Url
  18578. data["ak"] = miConfig.AccessKey
  18579. data["begin_time"] = begin_time
  18580. data["cainfo"] = miConfig.Cainfo
  18581. data["dept"] = strconv.FormatInt(department.ID, 10)
  18582. data["config"] = config
  18583. bytesData, _ := json.Marshal(data)
  18584. var req *http.Request
  18585. if miConfig.MdtrtareaAdmvs == "320921" {
  18586. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18587. //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 +
  18588. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18589. } else {
  18590. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18591. }
  18592. resp, _ := client.Do(req)
  18593. defer resp.Body.Close()
  18594. body, ioErr := ioutil.ReadAll(resp.Body)
  18595. if ioErr != nil {
  18596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18598. return
  18599. }
  18600. var respJSON map[string]interface{}
  18601. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18604. return
  18605. }
  18606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18607. userJSONBytes, _ := json.Marshal(respJSON)
  18608. fmt.Println("log")
  18609. fmt.Println(string(userJSONBytes))
  18610. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18611. utils.ErrorLog("解析失败:%v", err)
  18612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18613. return
  18614. }
  18615. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18616. res2.Output = ressix10265.Output
  18617. res2.ErrMsg = ressix10265.ErrMsg
  18618. res2.Cainfo = ressix10265.Cainfo
  18619. res2.WarnMsg = ressix10265.WarnMsg
  18620. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18621. res2.Infcode = infocode
  18622. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18623. data := make(map[string]interface{})
  18624. client := &http.Client{}
  18625. data["psn_no"] = his.PsnNo
  18626. data["mdtrt_id"] = his.Number
  18627. data["doctor"] = roles.UserName
  18628. data["department"] = department.Name
  18629. data["org_name"] = miConfig.OrgName
  18630. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18631. data["doctor_id"] = doctor_info.DoctorNumber
  18632. data["new_doctor_name"] = doctor_info.UserName
  18633. data["fixmedins_code"] = miConfig.Code
  18634. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18635. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18636. data["secret_key"] = miConfig.SecretKey
  18637. data["sick_code"] = sickConfig.CountryCode
  18638. data["sick_name"] = sickConfig.ClassName
  18639. data["url"] = miConfig.Url
  18640. data["ak"] = miConfig.AccessKey
  18641. data["begin_time"] = begin_time
  18642. data["cainfo"] = miConfig.Cainfo
  18643. data["dept"] = strconv.FormatInt(department.ID, 10)
  18644. data["config"] = config
  18645. bytesData, _ := json.Marshal(data)
  18646. var req *http.Request
  18647. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18648. resp, _ := client.Do(req)
  18649. defer resp.Body.Close()
  18650. body, ioErr := ioutil.ReadAll(resp.Body)
  18651. if ioErr != nil {
  18652. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18654. return
  18655. }
  18656. var respJSON map[string]interface{}
  18657. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18658. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18660. return
  18661. }
  18662. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18663. userJSONBytes, _ := json.Marshal(respJSON)
  18664. fmt.Println("log")
  18665. fmt.Println(string(userJSONBytes))
  18666. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18667. utils.ErrorLog("解析失败:%v", err)
  18668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18669. return
  18670. }
  18671. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18672. res2.Output = ressix10265.Output
  18673. res2.ErrMsg = ressix10265.ErrMsg
  18674. res2.Cainfo = ressix10265.Cainfo
  18675. res2.WarnMsg = ressix10265.WarnMsg
  18676. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18677. res2.Infcode = infocode
  18678. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18679. 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)
  18680. saveLog(result, requestLog, "2203", "上传就诊信息")
  18681. var respJSON2 map[string]interface{}
  18682. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18685. return
  18686. }
  18687. userJSONBytes2, _ := json.Marshal(respJSON2)
  18688. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18689. utils.ErrorLog("解析失败:%v", err)
  18690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18691. return
  18692. }
  18693. 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)
  18694. fmt.Println(result2)
  18695. fmt.Println(src_request)
  18696. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18697. data := make(map[string]interface{})
  18698. client := &http.Client{}
  18699. data["psn_no"] = his.PsnNo
  18700. data["mdtrt_id"] = his.Number
  18701. data["doctor"] = roles.UserName
  18702. data["department"] = department.Name
  18703. data["org_name"] = miConfig.OrgName
  18704. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18705. data["doctor_id"] = doctor_info.DoctorNumber
  18706. data["new_doctor_name"] = doctor_info.UserName
  18707. data["fixmedins_code"] = miConfig.Code
  18708. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18709. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18710. data["secret_key"] = miConfig.SecretKey
  18711. data["sick_code"] = sickConfig.CountryCode
  18712. data["sick_name"] = sickConfig.ClassName
  18713. data["url"] = miConfig.Url
  18714. data["ak"] = miConfig.AccessKey
  18715. data["begin_time"] = begin_time
  18716. data["cainfo"] = miConfig.Cainfo
  18717. data["dept"] = strconv.FormatInt(department.ID, 10)
  18718. data["config"] = config
  18719. bytesData, _ := json.Marshal(data)
  18720. var req *http.Request
  18721. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18722. resp, _ := client.Do(req)
  18723. defer resp.Body.Close()
  18724. body, ioErr := ioutil.ReadAll(resp.Body)
  18725. if ioErr != nil {
  18726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18728. return
  18729. }
  18730. var respJSON map[string]interface{}
  18731. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18734. return
  18735. }
  18736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18737. userJSONBytes, _ := json.Marshal(respJSON)
  18738. fmt.Println("log")
  18739. fmt.Println(string(userJSONBytes))
  18740. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18741. utils.ErrorLog("解析失败:%v", err)
  18742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18743. return
  18744. }
  18745. } else {
  18746. if miConfig.MdtrtareaAdmvs == "440781" { //
  18747. 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)
  18748. } else {
  18749. if miConfig.Code == "H15049901371" {
  18750. //赤峰地区国家医保医疗类别
  18751. //职工透析:医疗类别选特殊情况门诊990502
  18752. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18753. var med_type string
  18754. if his.Insutype == "390" {
  18755. if reg_type == 14 {
  18756. med_type = "9933"
  18757. } else if reg_type == 11 {
  18758. med_type = "11"
  18759. }
  18760. } else if his.Insutype == "310" {
  18761. if reg_type == 14 {
  18762. med_type = "990502"
  18763. } else if reg_type == 11 {
  18764. med_type = "11"
  18765. }
  18766. }
  18767. 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)
  18768. } else {
  18769. 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)
  18770. }
  18771. }
  18772. saveLog(result, requestLog, "2203", "上传就诊信息")
  18773. var respJSON2 map[string]interface{}
  18774. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18777. return
  18778. }
  18779. userJSONBytes2, _ := json.Marshal(respJSON2)
  18780. if miConfig.Code == "H15049901371" {
  18781. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18782. utils.ErrorLog("解析失败:%v", err)
  18783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18784. return
  18785. }
  18786. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18787. res2.Output = ressix10265.Output
  18788. res2.ErrMsg = ressix10265.ErrMsg
  18789. res2.Cainfo = ressix10265.Cainfo
  18790. res2.WarnMsg = ressix10265.WarnMsg
  18791. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18792. res2.Infcode = infocode
  18793. } else {
  18794. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18795. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18796. utils.ErrorLog("解析失败:%v", err)
  18797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18798. return
  18799. }
  18800. res2.Infcode = res3.Infcode
  18801. } else {
  18802. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18803. utils.ErrorLog("解析失败:%v", err)
  18804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18805. return
  18806. }
  18807. }
  18808. }
  18809. }
  18810. if res2.Infcode != 0 {
  18811. adminUser := c.GetAdminUserInfo()
  18812. errlog := &models.HisOrderError{
  18813. UserOrgId: adminUser.CurrentOrgId,
  18814. Ctime: time.Now().Unix(),
  18815. Mtime: time.Now().Unix(),
  18816. ErrMsg: res2.ErrMsg,
  18817. Status: 1,
  18818. PatientId: id,
  18819. RecordTime: recordDateTime,
  18820. Stage: 3,
  18821. }
  18822. service.CreateErrMsgLog(errlog)
  18823. c.ServeSuccessJSON(map[string]interface{}{
  18824. "failed_code": -10,
  18825. "msg": res2.ErrMsg,
  18826. })
  18827. return
  18828. } else {
  18829. his.Diagnosis = diagnosis_id
  18830. his.SickType = sickConfig.ID
  18831. //var p_type int64
  18832. //if reg_type == 1111 || reg_type == 1112 {
  18833. // p_type = 11
  18834. //
  18835. //}
  18836. his.PType = fmt.Sprintf("%d", reg_type)
  18837. service.UpdateHisPatientThree(&his)
  18838. data := make(map[string]interface{})
  18839. if settle_accounts_type == 1 { //日结
  18840. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18841. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18842. } else {
  18843. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18844. }
  18845. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18846. data["pre"] = prescriptions
  18847. } else { //月结
  18848. start_time_str := c.GetString("start_time")
  18849. end_time_str := c.GetString("end_time")
  18850. timeLayout := "2006-01-02"
  18851. loc, _ := time.LoadLocation("Local")
  18852. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18853. if err != nil {
  18854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18855. return
  18856. }
  18857. recordStartTime := theStartTime.Unix()
  18858. start_time = recordStartTime
  18859. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18860. if err != nil {
  18861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18862. return
  18863. }
  18864. recordEndTime := theEndTime.Unix()
  18865. end_time = recordEndTime
  18866. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18867. data["pre"] = prescriptions
  18868. }
  18869. timestamp := time.Now().Unix()
  18870. tempTime := time.Unix(timestamp, 0)
  18871. timeFormat := tempTime.Format("20060102150405")
  18872. chrgBchno := rand.Intn(100000) + 10000
  18873. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18874. strconv.FormatInt(his.PatientId, 10)
  18875. client := &http.Client{}
  18876. data["psn_no"] = his.PsnNo
  18877. data["mdtrt_id"] = his.Number
  18878. data["chrg_bchno"] = chrg_bchno
  18879. data["org_name"] = miConfig.OrgName
  18880. data["doctor"] = doctor_info.UserName
  18881. data["doctor_id"] = doctor_info.DoctorNumber
  18882. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18883. data["fixmedins_code"] = miConfig.Code
  18884. data["dept_code"] = department.Number
  18885. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18886. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18887. data["secret_key"] = miConfig.SecretKey
  18888. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18889. data["url"] = miConfig.Url
  18890. data["ak"] = miConfig.AccessKey
  18891. data["new_doctor_name"] = patientPrescription.Doctor
  18892. data["diag_code"] = sickConfig.CountryCode
  18893. data["cainfo"] = miConfig.Cainfo
  18894. data["opter"] = roles.UserName
  18895. var ids []int64
  18896. for _, item := range prescriptions {
  18897. ids = append(ids, item.ID)
  18898. }
  18899. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18900. if config.IsOpen == 1 { //对接了医保,走医保流程
  18901. var res ResultFour
  18902. var resFour10265 ResultFour10265
  18903. if miConfig.MdtrtareaAdmvs == "421300" {
  18904. bytesData, _ := json.Marshal(data)
  18905. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18906. resp, _ := client.Do(req)
  18907. defer resp.Body.Close()
  18908. body, ioErr := ioutil.ReadAll(resp.Body)
  18909. if ioErr != nil {
  18910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18912. return
  18913. }
  18914. var respJSON map[string]interface{}
  18915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18918. return
  18919. }
  18920. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18921. userJSONBytes, _ := json.Marshal(respJSON)
  18922. fmt.Println("log")
  18923. fmt.Println(string(userJSONBytes))
  18924. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18925. utils.ErrorLog("解析失败:%v", err)
  18926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18927. return
  18928. }
  18929. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18930. bytesData, _ := json.Marshal(data)
  18931. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18932. resp, _ := client.Do(req)
  18933. defer resp.Body.Close()
  18934. body, ioErr := ioutil.ReadAll(resp.Body)
  18935. if ioErr != nil {
  18936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18938. return
  18939. }
  18940. var respJSON map[string]interface{}
  18941. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18944. return
  18945. }
  18946. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18947. userJSONBytes, _ := json.Marshal(respJSON)
  18948. fmt.Println("log")
  18949. fmt.Println(string(userJSONBytes))
  18950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18951. utils.ErrorLog("解析失败:%v", err)
  18952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18953. return
  18954. }
  18955. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18956. bytesData, _ := json.Marshal(data)
  18957. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18958. resp, _ := client.Do(req)
  18959. defer resp.Body.Close()
  18960. body, ioErr := ioutil.ReadAll(resp.Body)
  18961. if ioErr != nil {
  18962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18964. return
  18965. }
  18966. var respJSON map[string]interface{}
  18967. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18970. return
  18971. }
  18972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18973. userJSONBytes, _ := json.Marshal(respJSON)
  18974. fmt.Println("log")
  18975. fmt.Println(string(userJSONBytes))
  18976. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18977. utils.ErrorLog("解析失败:%v", err)
  18978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18979. return
  18980. }
  18981. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18982. bytesData, _ := json.Marshal(data)
  18983. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18984. resp, _ := client.Do(req)
  18985. defer resp.Body.Close()
  18986. body, ioErr := ioutil.ReadAll(resp.Body)
  18987. if ioErr != nil {
  18988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18990. return
  18991. }
  18992. var respJSON map[string]interface{}
  18993. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18996. return
  18997. }
  18998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18999. userJSONBytes, _ := json.Marshal(respJSON)
  19000. fmt.Println("log")
  19001. fmt.Println(string(userJSONBytes))
  19002. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19003. utils.ErrorLog("解析失败:%v", err)
  19004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19005. return
  19006. }
  19007. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19008. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  19009. if result3101.Infcode == "0" {
  19010. if len(result3101.Output.Result) > 0 {
  19011. var errMsgs []string
  19012. for _, item := range result3101.Output.Result {
  19013. errMsgs = append(errMsgs, item.VolaCont)
  19014. }
  19015. c.ServeSuccessJSON(map[string]interface{}{
  19016. "failed_code": -10,
  19017. "msg": errMsgs,
  19018. })
  19019. return
  19020. }
  19021. }
  19022. bytesData, _ := json.Marshal(data)
  19023. var req *http.Request
  19024. if miConfig.MdtrtareaAdmvs == "320921" {
  19025. data["diag_code"] = sickConfig.CountryCode
  19026. fmt.Println(data)
  19027. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19028. } else {
  19029. data["diag_code"] = sickConfig.CountryCode
  19030. fmt.Println(data)
  19031. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19032. }
  19033. resp, _ := client.Do(req)
  19034. defer resp.Body.Close()
  19035. body, ioErr := ioutil.ReadAll(resp.Body)
  19036. if ioErr != nil {
  19037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19039. return
  19040. }
  19041. var respJSON map[string]interface{}
  19042. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19045. return
  19046. }
  19047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19048. userJSONBytes, _ := json.Marshal(respJSON)
  19049. fmt.Println("log")
  19050. fmt.Println(string(userJSONBytes))
  19051. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19052. utils.ErrorLog("解析失败:%v", err)
  19053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19054. return
  19055. }
  19056. res.InfRefmsgid = resFour10265.InfRefmsgid
  19057. res.Output = resFour10265.Output
  19058. res.ErrMsg = resFour10265.ErrMsg
  19059. res.Cainfo = resFour10265.Cainfo
  19060. res.WarnMsg = resFour10265.WarnMsg
  19061. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19062. res.Infcode = infocode
  19063. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19064. var pagesize int = 2
  19065. var start int = 1
  19066. var stop int
  19067. var pagecount int
  19068. var curpage int
  19069. var isSuccess bool = true
  19070. data["doctor_id"] = doctor_info.DoctorNumber
  19071. //总页数,向上取整,注意除之前要先转换类型为float64
  19072. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  19073. for curpage = 1; curpage <= pagecount; curpage++ {
  19074. if curpage == 1 {
  19075. start = 1
  19076. } else {
  19077. start = (curpage-1)*pagesize + 1
  19078. }
  19079. stop = curpage * pagesize
  19080. if stop > len(prescriptions) {
  19081. stop = len(prescriptions)
  19082. }
  19083. //var requestLog string
  19084. data["pre"] = prescriptions[start-1 : stop]
  19085. fmt.Println(data["pre"])
  19086. bytesData, _ := json.Marshal(data)
  19087. var req *http.Request
  19088. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  19089. resp, _ := client.Do(req)
  19090. defer resp.Body.Close()
  19091. body, ioErr := ioutil.ReadAll(resp.Body)
  19092. if ioErr != nil {
  19093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19095. return
  19096. }
  19097. var respJSON map[string]interface{}
  19098. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19101. return
  19102. }
  19103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19104. userJSONBytes, _ := json.Marshal(respJSON)
  19105. fmt.Println("log")
  19106. fmt.Println(string(userJSONBytes))
  19107. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19108. utils.ErrorLog("解析失败:%v", err)
  19109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19110. return
  19111. }
  19112. res.InfRefmsgid = resFour10265.InfRefmsgid
  19113. res.Output = resFour10265.Output
  19114. res.ErrMsg = resFour10265.ErrMsg
  19115. res.Cainfo = resFour10265.Cainfo
  19116. res.WarnMsg = resFour10265.WarnMsg
  19117. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19118. res.Infcode = infocode
  19119. if infocode == 0 {
  19120. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19121. } else {
  19122. isSuccess = false
  19123. errlog := &models.HisOrderError{
  19124. UserOrgId: adminUser.CurrentOrgId,
  19125. Ctime: time.Now().Unix(),
  19126. Mtime: time.Now().Unix(),
  19127. Number: chrg_bchno,
  19128. ErrMsg: "",
  19129. Status: 1,
  19130. PatientId: id,
  19131. RecordTime: recordDateTime,
  19132. Stage: 4,
  19133. }
  19134. service.CreateErrMsgLog(errlog)
  19135. c.ServeSuccessJSON(map[string]interface{}{
  19136. "failed_code": -10,
  19137. "msg": res.ErrMsg,
  19138. })
  19139. return
  19140. }
  19141. }
  19142. if isSuccess {
  19143. res.Infcode = 0
  19144. }
  19145. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19146. 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)
  19147. var dat map[string]interface{}
  19148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19149. fmt.Println(dat)
  19150. } else {
  19151. fmt.Println(err)
  19152. }
  19153. saveLog(result, request_log, "2204", "上传费用明细")
  19154. userJSONBytes, _ := json.Marshal(dat)
  19155. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19156. utils.ErrorLog("解析失败:%v", err)
  19157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19158. return
  19159. }
  19160. res.InfRefmsgid = resFour10265.InfRefmsgid
  19161. res.Output = resFour10265.Output
  19162. res.ErrMsg = resFour10265.ErrMsg
  19163. res.Cainfo = resFour10265.Cainfo
  19164. res.WarnMsg = resFour10265.WarnMsg
  19165. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19166. res.Infcode = infocode
  19167. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19168. bytesData, _ := json.Marshal(data)
  19169. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19170. resp, _ := client.Do(req)
  19171. defer resp.Body.Close()
  19172. body, ioErr := ioutil.ReadAll(resp.Body)
  19173. if ioErr != nil {
  19174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19176. return
  19177. }
  19178. var respJSON map[string]interface{}
  19179. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19182. return
  19183. }
  19184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19185. userJSONBytes, _ := json.Marshal(respJSON)
  19186. fmt.Println("log")
  19187. fmt.Println(string(userJSONBytes))
  19188. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19189. utils.ErrorLog("解析失败:%v", err)
  19190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19191. return
  19192. }
  19193. } else {
  19194. if miConfig.Code == "H15049901371" {
  19195. 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)
  19196. var dat map[string]interface{}
  19197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19198. fmt.Println(dat)
  19199. } else {
  19200. fmt.Println(err)
  19201. }
  19202. saveLog(result, request_log, "2204", "上传费用明细")
  19203. userJSONBytes, _ := json.Marshal(dat)
  19204. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19205. utils.ErrorLog("解析失败:%v", err)
  19206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19207. return
  19208. }
  19209. res.InfRefmsgid = resFour10265.InfRefmsgid
  19210. res.Output = resFour10265.Output
  19211. res.ErrMsg = resFour10265.ErrMsg
  19212. res.Cainfo = resFour10265.Cainfo
  19213. res.WarnMsg = resFour10265.WarnMsg
  19214. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19215. res.Infcode = infocode
  19216. } else {
  19217. 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)
  19218. var dat map[string]interface{}
  19219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19220. fmt.Println(dat)
  19221. } else {
  19222. fmt.Println(err)
  19223. }
  19224. saveLog(result, request_log, "2204", "上传费用明细")
  19225. userJSONBytes, _ := json.Marshal(dat)
  19226. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19227. utils.ErrorLog("解析失败:%v", err)
  19228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19229. return
  19230. }
  19231. }
  19232. }
  19233. if res.Infcode == 0 {
  19234. order := &models.HisOrder{
  19235. UserOrgId: adminUser.CurrentOrgId,
  19236. HisPatientId: his.ID,
  19237. PatientId: his.PatientId,
  19238. SettleAccountsDate: recordDateTime,
  19239. MdtrtId: his.Number,
  19240. PsnNo: his.PsnNo,
  19241. MedType: strconv.FormatInt(reg_type, 10),
  19242. Ctime: time.Now().Unix(),
  19243. Mtime: time.Now().Unix(),
  19244. Status: 1,
  19245. Number: chrg_bchno,
  19246. Infcode: res.Infcode,
  19247. WarnMsg: res.WarnMsg,
  19248. Cainfo: res.Cainfo,
  19249. ErrMsg: res.ErrMsg,
  19250. RespondTime: res.RefmsgTime,
  19251. InfRefmsgid: res.InfRefmsgid,
  19252. OrderStatus: 1,
  19253. PayWay: pay_way,
  19254. PayWays: pay_ways,
  19255. OthDesc: oth_desc,
  19256. PayPrice: pay_price,
  19257. PayCardNo: pay_card_no,
  19258. DiscountPrice: discount_price,
  19259. PreferentialPrice: preferential_price,
  19260. RealityPrice: reality_price,
  19261. FoundPrice: found_price,
  19262. MedicalInsurancePrice: medical_insurance_price,
  19263. PrivatePrice: private_price,
  19264. IsMedicineInsurance: 1,
  19265. SettleType: settle_accounts_type,
  19266. SettleStartTime: start_time,
  19267. SettleEndTime: end_time,
  19268. Creator: roles.AdminUserId,
  19269. Modify: roles.AdminUserId,
  19270. FaPiaoNumber: fapiao_number,
  19271. FaPiaoCode: fapiao_code,
  19272. PType: 2,
  19273. Diagnosis: diagnosis_id,
  19274. CashPay: cash_pay,
  19275. WechatPay: wechat_pay,
  19276. AliPay: ali_pay,
  19277. JifenPay: jifen_pay,
  19278. BandCardPay: band_card_pay,
  19279. }
  19280. err = service.CreateOrder(order)
  19281. if err != nil {
  19282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19283. return
  19284. }
  19285. for _, item := range res.Output.Result {
  19286. temp := strings.Split(item.FeedetlSn, "-")
  19287. var advice_id int64 = 0
  19288. var project_id int64 = 0
  19289. var types int64 = 0
  19290. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19291. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19292. if temp[1] == "1" {
  19293. advice_id = id
  19294. project_id = 0
  19295. } else if temp[1] == "2" {
  19296. advice_id = 0
  19297. project_id = id
  19298. }
  19299. if item.MedChrgitmType == "9" {
  19300. item.MedChrgitmType = "09"
  19301. }
  19302. info := &models.HisOrderInfo{
  19303. OrderNumber: order.Number,
  19304. FeedetlSn: item.FeedetlSn,
  19305. UploadDate: time.Now().Unix(),
  19306. AdviceId: advice_id,
  19307. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19308. Cnt: item.Cnt,
  19309. Pric: float64(item.Pric),
  19310. PatientId: his.PatientId,
  19311. PricUplmtAmt: item.PricUplmtAmt,
  19312. SelfpayProp: item.SelfpayProp,
  19313. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19314. OverlmtAmt: item.OverlmtAmt,
  19315. PreselfpayAmt: item.PreselfpayAmt,
  19316. BasMednFlag: item.BasMednFlag,
  19317. MedChrgitmType: item.MedChrgitmType,
  19318. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19319. Status: 1,
  19320. Memo: item.Memo,
  19321. Mtime: time.Now().Unix(),
  19322. InscpScpAmt: item.InscpScpAmt,
  19323. DrtReimFlag: item.DrtReimFlag,
  19324. Ctime: time.Now().Unix(),
  19325. ListSpItemFlag: item.ListSpItemFlag,
  19326. ChldMedcFlag: item.ChldMedcFlag,
  19327. LmtUsedFlag: item.LmtUsedFlag,
  19328. ChrgitmLv: item.ChrgitmLv,
  19329. UserOrgId: adminUser.CurrentOrgId,
  19330. HisPatientId: his.ID,
  19331. OrderId: order.ID,
  19332. ProjectId: project_id,
  19333. Type: types,
  19334. }
  19335. service.CreateOrderInfo(info)
  19336. }
  19337. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19338. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19339. var total float64
  19340. for _, item := range prescriptions {
  19341. if item.Type == 1 { //药品
  19342. for _, subItem := range item.HisDoctorAdviceInfo {
  19343. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19344. total_one := price * subItem.PrescribingNumber
  19345. total = total + total_one
  19346. }
  19347. }
  19348. if item.Type == 2 { //项目
  19349. for _, subItem := range item.HisPrescriptionProject {
  19350. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19351. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19352. total_one := price * cnt
  19353. total = total + total_one
  19354. }
  19355. }
  19356. }
  19357. allTotal := fmt.Sprintf("%.2f", total)
  19358. //if adminUser.CurrentOrgId == 9919 {
  19359. //
  19360. // allTotal = fmt.Sprintf("%.2f", total)
  19361. //
  19362. //} else {
  19363. //
  19364. // allTotal = fmt.Sprintf("%.2f", total)
  19365. //
  19366. //}
  19367. if res.Infcode == 0 {
  19368. var rf []*ResultFive
  19369. json.Unmarshal([]byte(his.Iinfo), &rf)
  19370. chrg_bchno := chrg_bchno
  19371. cert_no := his.Certno
  19372. var insutypes []string
  19373. var insutype string
  19374. var is390 int = 0
  19375. var is310 int = 0
  19376. for _, item := range rf {
  19377. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19378. insutypes = append(insutypes, item.Insutype)
  19379. }
  19380. }
  19381. if len(insutypes) == 1 {
  19382. insutype = insutypes[0]
  19383. } else {
  19384. for _, i := range insutypes {
  19385. if i == "390" {
  19386. is390 = 1
  19387. }
  19388. if i == "310" {
  19389. is310 = 1
  19390. }
  19391. }
  19392. }
  19393. if is390 == 1 {
  19394. insutype = "390"
  19395. }
  19396. if is310 == 1 {
  19397. insutype = "310"
  19398. }
  19399. if len(insutypes) == 0 {
  19400. insutype = "310"
  19401. }
  19402. if len(insutypes) == 2 {
  19403. insutype = strconv.FormatInt(his.SocialType, 10)
  19404. }
  19405. insutype = strconv.FormatInt(his.SocialType, 10)
  19406. //insutype = "390"
  19407. if his.IdCardType == 1 {
  19408. // cert_no = his.MedicalInsuranceNumber
  19409. cert_no = his.Certno
  19410. } else {
  19411. cert_no = his.Certno
  19412. }
  19413. var res ResultSeven
  19414. var resSeven10265 ResultSeven10265
  19415. var gzresSeven10265Two GZResultSeven10265Two
  19416. var src_resquest string
  19417. var result2 string
  19418. if miConfig.MdtrtareaAdmvs == "421300" {
  19419. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19420. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19421. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19422. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19423. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19424. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19425. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19426. resp, requestErr := http.Get(api)
  19427. if requestErr != nil {
  19428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19429. return
  19430. }
  19431. body, ioErr := ioutil.ReadAll(resp.Body)
  19432. if ioErr != nil {
  19433. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19435. return
  19436. }
  19437. var respJSON map[string]interface{}
  19438. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19439. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19441. return
  19442. }
  19443. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19444. result, _ := json.Marshal(respJSON)
  19445. if miConfig.Code == "H15049901371" {
  19446. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19447. utils.ErrorLog("解析失败:%v", err)
  19448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19449. return
  19450. }
  19451. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19452. res.Output = resSeven10265.Output
  19453. res.ErrMsg = resSeven10265.ErrMsg
  19454. res.Cainfo = resSeven10265.Cainfo
  19455. res.WarnMsg = resSeven10265.WarnMsg
  19456. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19457. res.Infcode = infocode
  19458. } else {
  19459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19460. utils.ErrorLog("解析失败:%v", err)
  19461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19462. return
  19463. }
  19464. }
  19465. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19466. if reg_type == 11 && his.Insutype == "390" {
  19467. reg_type = 110104
  19468. }
  19469. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19470. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19471. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19472. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19473. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19474. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19475. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19476. resp, requestErr := http.Get(api)
  19477. if requestErr != nil {
  19478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19479. return
  19480. }
  19481. body, ioErr := ioutil.ReadAll(resp.Body)
  19482. if ioErr != nil {
  19483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19485. return
  19486. }
  19487. var respJSON map[string]interface{}
  19488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19491. return
  19492. }
  19493. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19494. result, _ := json.Marshal(respJSON)
  19495. if miConfig.Code == "H15049901371" {
  19496. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19497. utils.ErrorLog("解析失败:%v", err)
  19498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19499. return
  19500. }
  19501. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19502. res.Output = resSeven10265.Output
  19503. res.ErrMsg = resSeven10265.ErrMsg
  19504. res.Cainfo = resSeven10265.Cainfo
  19505. res.WarnMsg = resSeven10265.WarnMsg
  19506. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19507. res.Infcode = infocode
  19508. } else {
  19509. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19510. utils.ErrorLog("解析失败:%v", err)
  19511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19512. return
  19513. }
  19514. }
  19515. } else if miConfig.MdtrtareaAdmvs == "420902" {
  19516. if reg_type == 11 && his.Insutype == "390" {
  19517. reg_type = 110104
  19518. }
  19519. api := miConfig.Url+ "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19520. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19521. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19522. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19523. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19524. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19525. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19526. resp, requestErr := http.Get(api)
  19527. if requestErr != nil {
  19528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19529. return
  19530. }
  19531. body, ioErr := ioutil.ReadAll(resp.Body)
  19532. if ioErr != nil {
  19533. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19535. return
  19536. }
  19537. var respJSON map[string]interface{}
  19538. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19539. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19541. return
  19542. }
  19543. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19544. result, _ := json.Marshal(respJSON)
  19545. if miConfig.Code == "H15049901371" {
  19546. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19547. utils.ErrorLog("解析失败:%v", err)
  19548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19549. return
  19550. }
  19551. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19552. res.Output = resSeven10265.Output
  19553. res.ErrMsg = resSeven10265.ErrMsg
  19554. res.Cainfo = resSeven10265.Cainfo
  19555. res.WarnMsg = resSeven10265.WarnMsg
  19556. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19557. res.Infcode = infocode
  19558. } else {
  19559. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19560. utils.ErrorLog("解析失败:%v", err)
  19561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19562. return
  19563. }
  19564. }
  19565. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19566. if reg_type == 11 && his.Insutype == "390" {
  19567. reg_type = 110104
  19568. }
  19569. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19570. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19571. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19573. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19574. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19575. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19576. resp, requestErr := http.Get(api)
  19577. if requestErr != nil {
  19578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19579. return
  19580. }
  19581. body, ioErr := ioutil.ReadAll(resp.Body)
  19582. if ioErr != nil {
  19583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19585. return
  19586. }
  19587. var respJSON map[string]interface{}
  19588. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19591. return
  19592. }
  19593. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19594. result, _ := json.Marshal(respJSON)
  19595. if miConfig.Code == "H15049901371" {
  19596. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19597. utils.ErrorLog("解析失败:%v", err)
  19598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19599. return
  19600. }
  19601. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19602. res.Output = resSeven10265.Output
  19603. res.ErrMsg = resSeven10265.ErrMsg
  19604. res.Cainfo = resSeven10265.Cainfo
  19605. res.WarnMsg = resSeven10265.WarnMsg
  19606. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19607. res.Infcode = infocode
  19608. } else {
  19609. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19610. utils.ErrorLog("解析失败:%v", err)
  19611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19612. return
  19613. }
  19614. }
  19615. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19616. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19617. if result3101.Infcode == "0" {
  19618. if len(result3101.Output.Result) > 0 {
  19619. var errMsgs []string
  19620. for _, item := range result3101.Output.Result {
  19621. errMsgs = append(errMsgs, item.VolaCont)
  19622. }
  19623. c.ServeSuccessJSON(map[string]interface{}{
  19624. "failed_code": -10,
  19625. "msg": errMsgs,
  19626. })
  19627. return
  19628. } else {
  19629. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19630. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19631. bas := strings.Split(psn_info.CardInfo, "|")
  19632. if his.IdCardType == 1 {
  19633. cert_no = bas[2]
  19634. } else if his.IdCardType == 3 {
  19635. cert_no = his.Certno
  19636. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19637. } else if his.IdCardType == 4 {
  19638. cert_no = his.Certno
  19639. psn_info.VerifyNumber = psn_info.VerifyNumber
  19640. }
  19641. var api string
  19642. if miConfig.MdtrtareaAdmvs == "320921" {
  19643. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19644. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19645. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19647. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19648. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19649. "&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
  19650. } else {
  19651. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19652. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19653. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19654. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19655. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19656. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19657. "&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
  19658. }
  19659. resp, requestErr := http.Get(api)
  19660. if requestErr != nil {
  19661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19662. return
  19663. }
  19664. body, ioErr := ioutil.ReadAll(resp.Body)
  19665. if ioErr != nil {
  19666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19668. return
  19669. }
  19670. var respJSON map[string]interface{}
  19671. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19674. return
  19675. }
  19676. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19677. result, _ := json.Marshal(respJSON)
  19678. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19679. utils.ErrorLog("解析失败:%v", err)
  19680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19681. return
  19682. }
  19683. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19684. res.Output = resSeven10265.Output
  19685. res.ErrMsg = resSeven10265.ErrMsg
  19686. res.Cainfo = resSeven10265.Cainfo
  19687. res.WarnMsg = resSeven10265.WarnMsg
  19688. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19689. res.Infcode = infocode
  19690. }
  19691. }
  19692. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19693. psn_info, _ := service.GetPsnByPatientId(id)
  19694. var verify_number string
  19695. if psn_info.IdCardType == 4 {
  19696. verify_number = psn_info.VerifyNumber
  19697. } else if psn_info.IdCardType == 1 {
  19698. bas := strings.Split(psn_info.CardInfo, "|")
  19699. cardNumber := bas[2]
  19700. verify_number = cardNumber
  19701. } else {
  19702. psn_info.IdCardType = 2
  19703. verify_number = psn_info.Certno
  19704. }
  19705. var api string
  19706. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19707. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19708. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19709. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19710. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19711. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19712. "&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
  19713. resp, requestErr := http.Get(api)
  19714. if requestErr != nil {
  19715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19716. return
  19717. }
  19718. body, ioErr := ioutil.ReadAll(resp.Body)
  19719. if ioErr != nil {
  19720. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19722. return
  19723. }
  19724. var respJSON map[string]interface{}
  19725. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19726. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19728. return
  19729. }
  19730. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19731. result, _ := json.Marshal(respJSON)
  19732. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19733. utils.ErrorLog("解析失败:%v", err)
  19734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19735. return
  19736. }
  19737. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19738. res.Output = resSeven10265.Output
  19739. res.ErrMsg = resSeven10265.ErrMsg
  19740. res.Cainfo = resSeven10265.Cainfo
  19741. res.WarnMsg = resSeven10265.WarnMsg
  19742. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19743. res.Infcode = infocode
  19744. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19745. var cert_no string
  19746. if his.IdCardType == 4 {
  19747. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19748. cert_no = psn_info.VerifyNumber
  19749. 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)
  19750. } else if his.IdCardType == 1 {
  19751. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19752. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19753. 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)
  19754. }
  19755. //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)
  19756. var dat map[string]interface{}
  19757. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19758. fmt.Println(dat)
  19759. } else {
  19760. fmt.Println(err)
  19761. }
  19762. saveLog(result2, src_resquest, "2207", "结算")
  19763. userJSONBytes, _ := json.Marshal(dat)
  19764. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19765. utils.ErrorLog("解析失败:%v", err)
  19766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19767. return
  19768. }
  19769. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19770. res.Output = resSeven10265.Output
  19771. res.ErrMsg = resSeven10265.ErrMsg
  19772. res.Cainfo = resSeven10265.Cainfo
  19773. res.WarnMsg = resSeven10265.WarnMsg
  19774. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19775. res.Infcode = infocode
  19776. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19777. res2 := c.GetoleInfo()
  19778. if res2.Infcode == 0 {
  19779. var result string
  19780. var request_log string
  19781. var result_log string
  19782. if res2.Output.MdtrtCertType == "02" {
  19783. 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)
  19784. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19785. } else if res2.Output.MdtrtCertType == "01" {
  19786. 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)
  19787. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19788. } else {
  19789. 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)
  19790. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19791. }
  19792. var dat map[string]interface{}
  19793. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19794. fmt.Println(dat)
  19795. } else {
  19796. fmt.Println(err)
  19797. }
  19798. userJSONBytes, _ := json.Marshal(dat)
  19799. var res5 ResultTwo
  19800. //var resTwo10265 ResultTwo10265
  19801. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19802. utils.ErrorLog("解析失败:%v", err)
  19803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19804. return
  19805. }
  19806. if res5.Infcode == -1 {
  19807. c.ServeSuccessJSON(map[string]interface{}{
  19808. "failed_code": -10,
  19809. "msg": res5.ErrMsg,
  19810. })
  19811. return
  19812. }
  19813. var insutypes []string
  19814. var insutype string
  19815. var is390 int = 0
  19816. var is310 int = 0
  19817. for _, item := range res5.Output.Iinfo {
  19818. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19819. insutypes = append(insutypes, item.Insutype)
  19820. }
  19821. }
  19822. if len(insutypes) == 1 {
  19823. insutype = insutypes[0]
  19824. } else {
  19825. for _, i := range insutypes {
  19826. if i == "390" {
  19827. is390 = 1
  19828. }
  19829. if i == "310" {
  19830. is310 = 1
  19831. }
  19832. }
  19833. }
  19834. if is390 == 1 {
  19835. insutype = "390"
  19836. }
  19837. if is310 == 1 {
  19838. insutype = "310"
  19839. }
  19840. if len(insutypes) == 0 {
  19841. insutype = "310"
  19842. }
  19843. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19844. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19845. infoStr := string(Iinfos)
  19846. idetinfoStr := string(Idetinfos)
  19847. psn := &models.HisPsn{
  19848. PsnNo: res5.Output.Baseinfo.PsnNo,
  19849. PatientId: id,
  19850. Certno: res5.Output.Baseinfo.Certno,
  19851. Gend: res5.Output.Baseinfo.Gend,
  19852. Naty: res5.Output.Baseinfo.Naty,
  19853. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19854. PsnName: res5.Output.Baseinfo.PsnName,
  19855. Idetinfo: idetinfoStr,
  19856. Insuinfo: infoStr,
  19857. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19858. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19859. VerifyNumber: res2.Output.EcToken,
  19860. }
  19861. if res2.Output.MdtrtCertType == "01" {
  19862. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19863. psn.VerifyNumber = res2.Output.EcToken
  19864. } else if res2.Output.MdtrtCertType == "02" {
  19865. psn.VerifyNumber = res2.Output.CardNo
  19866. } else {
  19867. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19868. }
  19869. service.CreateHisPsn(psn)
  19870. if res2.Output.MdtrtCertType == "01" {
  19871. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19872. token := res2.Output.EcToken
  19873. 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)
  19874. } else if res2.Output.MdtrtCertType == "02" {
  19875. 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)
  19876. } else {
  19877. 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)
  19878. }
  19879. var dat2 map[string]interface{}
  19880. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19881. fmt.Println(dat2)
  19882. } else {
  19883. fmt.Println(err)
  19884. }
  19885. userJSONBytes3, _ := json.Marshal(dat2)
  19886. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19887. utils.ErrorLog("解析失败:%v", err)
  19888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19889. return
  19890. }
  19891. saveLog(result2, src_resquest, "2207", "结算")
  19892. } else {
  19893. c.ServeSuccessJSON(map[string]interface{}{
  19894. "failed_code": -10,
  19895. "msg": res2.ErrMsg,
  19896. })
  19897. return
  19898. }
  19899. } else {
  19900. if miConfig.Code == "H15049901371" {
  19901. //赤峰地区国家医保医疗类别
  19902. //职工透析:医疗类别选特殊情况门诊990502
  19903. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19904. var med_type string
  19905. if his.Insutype == "390" {
  19906. if reg_type == 14 {
  19907. med_type = "9933"
  19908. } else if reg_type == 11 {
  19909. med_type = "11"
  19910. }
  19911. } else if his.Insutype == "310" {
  19912. if reg_type == 14 {
  19913. med_type = "990502"
  19914. } else if reg_type == 11 {
  19915. med_type = "11"
  19916. }
  19917. }
  19918. 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)
  19919. } else {
  19920. if his.IdCardType == 4 {
  19921. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19922. var token string
  19923. token = psn_info.VerifyNumber
  19924. 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)
  19925. } else {
  19926. if his.IdCardType == 1 {
  19927. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19928. bas := strings.Split(psn_info.CardInfo, "|")
  19929. basNumber := bas[2]
  19930. cert_no = basNumber
  19931. }
  19932. 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)
  19933. }
  19934. }
  19935. //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)
  19936. var dat map[string]interface{}
  19937. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19938. fmt.Println(dat)
  19939. } else {
  19940. fmt.Println(err)
  19941. }
  19942. saveLog(result2, src_resquest, "2207", "结算")
  19943. userJSONBytes, _ := json.Marshal(dat)
  19944. if miConfig.Code == "H15049901371" {
  19945. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19946. utils.ErrorLog("解析失败:%v", err)
  19947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19948. return
  19949. }
  19950. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19951. res.Output = resSeven10265.Output
  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. } else {
  19958. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19959. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19960. utils.ErrorLog("解析失败:%v", err)
  19961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19962. return
  19963. }
  19964. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19965. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19966. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19967. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19968. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19969. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19970. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19971. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19972. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19973. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19974. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19975. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19976. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19977. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19978. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19979. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19980. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19981. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19982. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19983. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19984. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19985. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19986. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19987. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19988. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19989. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19990. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19991. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19992. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19993. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19994. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19995. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19996. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19997. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19998. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19999. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20000. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20001. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20002. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20003. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20004. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20005. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20006. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20007. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20008. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20009. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20010. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20011. res.Cainfo = gzresSeven10265Two.Cainfo
  20012. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20013. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20014. //res.Infcode = infocode
  20015. } else {
  20016. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20017. utils.ErrorLog("解析失败:%v", err)
  20018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20019. return
  20020. }
  20021. }
  20022. }
  20023. }
  20024. if res.Infcode == -1 {
  20025. errlog := &models.HisOrderError{
  20026. UserOrgId: adminUser.CurrentOrgId,
  20027. Ctime: time.Now().Unix(),
  20028. Mtime: time.Now().Unix(),
  20029. Number: chrg_bchno,
  20030. ErrMsg: res.ErrMsg,
  20031. Status: 1,
  20032. PatientId: id,
  20033. RecordTime: recordDateTime,
  20034. Stage: 6,
  20035. }
  20036. service.CreateErrMsgLog(errlog)
  20037. c.ServeSuccessJSON(map[string]interface{}{
  20038. "failed_code": -10,
  20039. "msg": res.ErrMsg,
  20040. })
  20041. return
  20042. } else {
  20043. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20044. order.OrderStatus = 2
  20045. order.Status = 1
  20046. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20047. order.SetlId = res.Output.Setlinfo.SetlID
  20048. order.PsnNo = res.Output.Setlinfo.PsnNo
  20049. order.PsnName = res.Output.Setlinfo.PsnName
  20050. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20051. order.Certno = res.Output.Setlinfo.Certno
  20052. order.Gend = res.Output.Setlinfo.Gend
  20053. order.Naty = res.Output.Setlinfo.Naty
  20054. order.Age = res.Output.Setlinfo.Age
  20055. order.Insutype = res.Output.Setlinfo.Insutype
  20056. order.PsnType = res.Output.Setlinfo.PsnType
  20057. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20058. order.SetlTime = res.Output.Setlinfo.SetlTime
  20059. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20060. if res.Output.Setlinfo.MedType == "140101" {
  20061. order.MedType = "14"
  20062. } else {
  20063. if res.Output.Setlinfo.MedType == "110104" {
  20064. order.MedType = "11"
  20065. } else {
  20066. order.MedType = res.Output.Setlinfo.MedType
  20067. }
  20068. }
  20069. if reg_type == 1112 {
  20070. order.MedType = "1112"
  20071. }
  20072. if reg_type == 1111 {
  20073. order.MedType = "1111"
  20074. }
  20075. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20076. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20077. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20078. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20079. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20080. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20081. order.HifpPay = res.Output.Setlinfo.HifpPay
  20082. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20083. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20084. order.HifesPay = res.Output.Setlinfo.HifesPay
  20085. order.HifobPay = res.Output.Setlinfo.HifobPay
  20086. order.MafPay = res.Output.Setlinfo.MafPay
  20087. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20088. order.OthPay = res.Output.Setlinfo.OthPay
  20089. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20090. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20091. order.AcctPay = res.Output.Setlinfo.AcctPay
  20092. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20093. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20094. order.Balc = res.Output.Setlinfo.Balc
  20095. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20096. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20097. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20098. order.ClrType = res.Output.Setlinfo.ClrType
  20099. order.ClrWay = res.Output.Setlinfo.ClrWay
  20100. order.Creator = order.Creator
  20101. order.Modify = roles.AdminUserId
  20102. order.RequestLog = src_resquest
  20103. order.FaPiaoNumber = fapiao_number
  20104. order.FaPiaoCode = fapiao_code
  20105. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20106. //detailStr := string(setlDetail)
  20107. //order.SetlDetail = detailStr
  20108. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20109. err = service.UpDateOrder(order)
  20110. if err == nil {
  20111. //判断是否使用了押金
  20112. if dec_way == "true" {
  20113. tmpstring := strconv.FormatInt(order.ID, 10)
  20114. order.Decimal = decimal
  20115. service.UpDateOrder(order)
  20116. //扣押金
  20117. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20118. if errmsg != nil {
  20119. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20120. return
  20121. }
  20122. }
  20123. c.ServeSuccessJSON(map[string]interface{}{
  20124. "msg": "结算成功",
  20125. })
  20126. } else {
  20127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20128. return
  20129. }
  20130. }
  20131. } else {
  20132. adminUser := c.GetAdminUserInfo()
  20133. errlog := &models.HisOrderError{
  20134. UserOrgId: adminUser.CurrentOrgId,
  20135. Ctime: time.Now().Unix(),
  20136. Mtime: time.Now().Unix(),
  20137. ErrMsg: res.ErrMsg,
  20138. Status: 1,
  20139. PatientId: id,
  20140. RecordTime: recordDateTime,
  20141. Stage: 4,
  20142. }
  20143. service.CreateErrMsgLog(errlog)
  20144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20145. return
  20146. }
  20147. } else {
  20148. adminUser := c.GetAdminUserInfo()
  20149. errlog := &models.HisOrderError{
  20150. UserOrgId: adminUser.CurrentOrgId,
  20151. Ctime: time.Now().Unix(),
  20152. Mtime: time.Now().Unix(),
  20153. ErrMsg: res.ErrMsg,
  20154. Status: 1,
  20155. PatientId: id,
  20156. RecordTime: recordDateTime,
  20157. Stage: 4,
  20158. }
  20159. service.CreateErrMsgLog(errlog)
  20160. c.ServeSuccessJSON(map[string]interface{}{
  20161. "failed_code": -10,
  20162. "msg": res.ErrMsg,
  20163. })
  20164. return
  20165. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20166. //return
  20167. }
  20168. }
  20169. }
  20170. } else if tempOrder.ID > 0 {
  20171. if tempOrder.IsPre == 1 {
  20172. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20173. var rf []*ResultFive
  20174. json.Unmarshal([]byte(his.Iinfo), &rf)
  20175. chrg_bchno := tempOrder.Number
  20176. cert_no := his.Certno
  20177. var insutypes []string
  20178. var insutype string
  20179. var is390 int = 0
  20180. var is310 int = 0
  20181. for _, item := range rf {
  20182. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20183. insutypes = append(insutypes, item.Insutype)
  20184. }
  20185. }
  20186. if len(insutypes) == 1 {
  20187. insutype = insutypes[0]
  20188. } else {
  20189. for _, i := range insutypes {
  20190. if i == "390" {
  20191. is390 = 1
  20192. }
  20193. if i == "310" {
  20194. is310 = 1
  20195. }
  20196. }
  20197. }
  20198. if is390 == 1 {
  20199. insutype = "390"
  20200. }
  20201. if is310 == 1 {
  20202. insutype = "310"
  20203. }
  20204. if len(insutypes) == 0 {
  20205. insutype = "310"
  20206. }
  20207. if len(insutypes) == 2 {
  20208. insutype = strconv.FormatInt(his.SocialType, 10)
  20209. }
  20210. //insutype = "390"
  20211. if his.IdCardType == 1 {
  20212. // cert_no = his.MedicalInsuranceNumber
  20213. cert_no = his.Certno
  20214. } else {
  20215. cert_no = his.Certno
  20216. }
  20217. var res ResultSeven
  20218. var ahres ResultSevenAH
  20219. var resSeven10265 ResultSeven10265
  20220. var gzresSeven10265Two GZResultSeven10265Two
  20221. var src_resquest string
  20222. var result2 string
  20223. if miConfig.MdtrtareaAdmvs == "450721" {
  20224. res2 := c.GetoleInfo()
  20225. if res2.Infcode == 0 {
  20226. var result string
  20227. var request_log string
  20228. var result_log string
  20229. if res2.Output.MdtrtCertType == "02" {
  20230. 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)
  20231. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20232. } else if res2.Output.MdtrtCertType == "01" {
  20233. 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)
  20234. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20235. } else {
  20236. 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)
  20237. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20238. }
  20239. var dat map[string]interface{}
  20240. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20241. fmt.Println(dat)
  20242. } else {
  20243. fmt.Println(err)
  20244. }
  20245. userJSONBytes, _ := json.Marshal(dat)
  20246. var res5 ResultTwo
  20247. //var resTwo10265 ResultTwo10265
  20248. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20249. utils.ErrorLog("解析失败:%v", err)
  20250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20251. return
  20252. }
  20253. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20254. if res5.Infcode == -1 {
  20255. c.ServeSuccessJSON(map[string]interface{}{
  20256. "failed_code": -10,
  20257. "msg": res5.ErrMsg,
  20258. })
  20259. return
  20260. }
  20261. var insutypes []string
  20262. var insutype string
  20263. var is390 int = 0
  20264. var is310 int = 0
  20265. for _, item := range res5.Output.Iinfo {
  20266. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20267. insutypes = append(insutypes, item.Insutype)
  20268. }
  20269. }
  20270. if len(insutypes) == 1 {
  20271. insutype = insutypes[0]
  20272. } else {
  20273. for _, i := range insutypes {
  20274. if i == "390" {
  20275. is390 = 1
  20276. }
  20277. if i == "310" {
  20278. is310 = 1
  20279. }
  20280. }
  20281. }
  20282. if is390 == 1 {
  20283. insutype = "390"
  20284. }
  20285. if is310 == 1 {
  20286. insutype = "310"
  20287. }
  20288. if len(insutypes) == 0 {
  20289. insutype = "310"
  20290. }
  20291. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20292. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20293. infoStr := string(Iinfos)
  20294. idetinfoStr := string(Idetinfos)
  20295. psn := &models.HisPsn{
  20296. PsnNo: res5.Output.Baseinfo.PsnNo,
  20297. PatientId: id,
  20298. Certno: res5.Output.Baseinfo.Certno,
  20299. Gend: res5.Output.Baseinfo.Gend,
  20300. Naty: res5.Output.Baseinfo.Naty,
  20301. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20302. PsnName: res5.Output.Baseinfo.PsnName,
  20303. Idetinfo: idetinfoStr,
  20304. Insuinfo: infoStr,
  20305. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20306. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20307. VerifyNumber: res2.Output.EcToken,
  20308. }
  20309. service.CreateHisPsn(psn)
  20310. if res2.Output.MdtrtCertType == "01" {
  20311. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20312. token := res2.Output.EcToken
  20313. 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)
  20314. } else if res2.Output.MdtrtCertType == "02" {
  20315. 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)
  20316. } else {
  20317. 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)
  20318. }
  20319. var dat2 map[string]interface{}
  20320. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20321. fmt.Println(dat2)
  20322. } else {
  20323. fmt.Println(err)
  20324. }
  20325. userJSONBytes3, _ := json.Marshal(dat2)
  20326. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20327. utils.ErrorLog("解析失败:%v", err)
  20328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20329. return
  20330. }
  20331. saveLog(result2, src_resquest, "2207", "结算")
  20332. } else {
  20333. c.ServeSuccessJSON(map[string]interface{}{
  20334. "failed_code": -10,
  20335. "msg": res2.ErrMsg,
  20336. })
  20337. return
  20338. }
  20339. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20340. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20341. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20342. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20343. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20344. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20345. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20346. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20347. resp, requestErr := http.Get(api)
  20348. if requestErr != nil {
  20349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20350. return
  20351. }
  20352. body, ioErr := ioutil.ReadAll(resp.Body)
  20353. if ioErr != nil {
  20354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20356. return
  20357. }
  20358. var respJSON map[string]interface{}
  20359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20362. return
  20363. }
  20364. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20365. result, _ := json.Marshal(respJSON)
  20366. fmt.Println("log")
  20367. fmt.Println(string(result))
  20368. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20369. utils.ErrorLog("解析失败:%v", err)
  20370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20371. return
  20372. }
  20373. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20374. if reg_type == 11 && his.Insutype == "390" {
  20375. reg_type = 110104
  20376. }
  20377. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20378. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20379. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20380. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20381. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20382. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20383. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20384. resp, requestErr := http.Get(api)
  20385. if requestErr != nil {
  20386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20387. return
  20388. }
  20389. body, ioErr := ioutil.ReadAll(resp.Body)
  20390. if ioErr != nil {
  20391. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20393. return
  20394. }
  20395. var respJSON map[string]interface{}
  20396. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20397. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20399. return
  20400. }
  20401. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20402. result, _ := json.Marshal(respJSON)
  20403. fmt.Println("log")
  20404. fmt.Println(string(result))
  20405. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20406. utils.ErrorLog("解析失败:%v", err)
  20407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20408. return
  20409. }
  20410. }else if miConfig.MdtrtareaAdmvs == "420902" {
  20411. if reg_type == 11 && his.Insutype == "390" {
  20412. reg_type = 110104
  20413. }
  20414. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20415. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20416. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20417. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20418. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20419. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20420. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20421. resp, requestErr := http.Get(api)
  20422. if requestErr != nil {
  20423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20424. return
  20425. }
  20426. body, ioErr := ioutil.ReadAll(resp.Body)
  20427. if ioErr != nil {
  20428. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20430. return
  20431. }
  20432. var respJSON map[string]interface{}
  20433. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20434. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20436. return
  20437. }
  20438. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20439. result, _ := json.Marshal(respJSON)
  20440. fmt.Println("log")
  20441. fmt.Println(string(result))
  20442. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20443. utils.ErrorLog("解析失败:%v", err)
  20444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20445. return
  20446. }
  20447. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20448. if reg_type == 11 && his.Insutype == "390" {
  20449. reg_type = 110104
  20450. }
  20451. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20452. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20453. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20454. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20455. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20456. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20457. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20458. resp, requestErr := http.Get(api)
  20459. if requestErr != nil {
  20460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20461. return
  20462. }
  20463. body, ioErr := ioutil.ReadAll(resp.Body)
  20464. if ioErr != nil {
  20465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20467. return
  20468. }
  20469. var respJSON map[string]interface{}
  20470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20473. return
  20474. }
  20475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20476. result, _ := json.Marshal(respJSON)
  20477. fmt.Println("log")
  20478. fmt.Println(string(result))
  20479. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20480. utils.ErrorLog("解析失败:%v", err)
  20481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20482. return
  20483. }
  20484. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20485. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20486. if result3101.Infcode == "0" {
  20487. if len(result3101.Output.Result) > 0 {
  20488. var errMsgs []string
  20489. for _, item := range result3101.Output.Result {
  20490. errMsgs = append(errMsgs, item.VolaCont)
  20491. }
  20492. c.ServeSuccessJSON(map[string]interface{}{
  20493. "failed_code": -10,
  20494. "msg": errMsgs,
  20495. })
  20496. return
  20497. } else {
  20498. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20499. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20500. bas := strings.Split(psn_info.CardInfo, "|")
  20501. if his.IdCardType == 1 {
  20502. cert_no = bas[2]
  20503. } else if his.IdCardType == 3 {
  20504. cert_no = his.Certno
  20505. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20506. } else if his.IdCardType == 4 {
  20507. cert_no = his.Certno
  20508. psn_info.VerifyNumber = psn_info.VerifyNumber
  20509. }
  20510. //江苏地区国家医保医疗类别
  20511. //职工透析:医疗类别选特殊情况门诊9933
  20512. //居民血透门慢: 医疗类别选门诊慢病1402
  20513. //var med_type string
  20514. //if his.Insutype == "310" {
  20515. // if reg_type == 14 {
  20516. // med_type = "9933"
  20517. // } else if reg_type == 11 {
  20518. // med_type = "11"
  20519. //
  20520. // }
  20521. //} else if his.Insutype == "390" {
  20522. // if reg_type == 14 {
  20523. // med_type = "1402"
  20524. // } else if reg_type == 11 {
  20525. // med_type = "11"
  20526. // }
  20527. //}
  20528. var api string
  20529. if miConfig.MdtrtareaAdmvs == "320921" {
  20530. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20531. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20532. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20533. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20534. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20535. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20536. "&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
  20537. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20538. } else {
  20539. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20540. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20541. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20542. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20543. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20544. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20545. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20546. "&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
  20547. }
  20548. resp, requestErr := http.Get(api)
  20549. if requestErr != nil {
  20550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20551. return
  20552. }
  20553. body, ioErr := ioutil.ReadAll(resp.Body)
  20554. if ioErr != nil {
  20555. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20557. return
  20558. }
  20559. var respJSON map[string]interface{}
  20560. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20561. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20563. return
  20564. }
  20565. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20566. result, _ := json.Marshal(respJSON)
  20567. fmt.Println("log")
  20568. fmt.Println(string(result))
  20569. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20570. utils.ErrorLog("解析失败:%v", err)
  20571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20572. return
  20573. }
  20574. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20575. res.Output = resSeven10265.Output
  20576. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20577. res.ErrMsg = resSeven10265.ErrMsg
  20578. res.Cainfo = resSeven10265.Cainfo
  20579. res.WarnMsg = resSeven10265.WarnMsg
  20580. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20581. res.Infcode = infocode
  20582. }
  20583. }
  20584. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20585. psn_info, _ := service.GetPsnByPatientId(id)
  20586. var verify_number string
  20587. if psn_info.IdCardType == 4 {
  20588. verify_number = psn_info.VerifyNumber
  20589. } else if psn_info.IdCardType == 1 {
  20590. bas := strings.Split(psn_info.CardInfo, "|")
  20591. cardNumber := bas[2]
  20592. verify_number = cardNumber
  20593. } else {
  20594. verify_number = psn_info.Certno
  20595. psn_info.IdCardType = 2
  20596. }
  20597. var api string
  20598. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20599. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20600. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20602. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20603. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20604. "&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
  20605. resp, requestErr := http.Get(api)
  20606. if requestErr != nil {
  20607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20608. return
  20609. }
  20610. body, ioErr := ioutil.ReadAll(resp.Body)
  20611. if ioErr != nil {
  20612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20614. return
  20615. }
  20616. var respJSON map[string]interface{}
  20617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20620. return
  20621. }
  20622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20623. result, _ := json.Marshal(respJSON)
  20624. fmt.Println("log")
  20625. fmt.Println(string(result))
  20626. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20627. utils.ErrorLog("解析失败:%v", err)
  20628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20629. return
  20630. }
  20631. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20632. res.Output = resSeven10265.Output
  20633. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20634. res.ErrMsg = resSeven10265.ErrMsg
  20635. res.Cainfo = resSeven10265.Cainfo
  20636. res.WarnMsg = resSeven10265.WarnMsg
  20637. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20638. res.Infcode = infocode
  20639. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20640. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20641. var cert_no string
  20642. if his.IdCardType == 1 {
  20643. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20644. } else {
  20645. cert_no = psn_info.VerifyNumber
  20646. }
  20647. 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)
  20648. var dat map[string]interface{}
  20649. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20650. fmt.Println(dat)
  20651. } else {
  20652. fmt.Println(err)
  20653. }
  20654. saveLog(result2, src_resquest, "2207", "结算")
  20655. userJSONBytes, _ := json.Marshal(dat)
  20656. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20657. utils.ErrorLog("解析失败:%v", err)
  20658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20659. return
  20660. }
  20661. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20662. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20663. var cert_no string
  20664. var card_sn string
  20665. if his.IdCardType == 1 {
  20666. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20667. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20668. bas := strings.Split(psn_info.CardInfo, "|")
  20669. card_sn = bas[3]
  20670. } else if his.IdCardType == 2 {
  20671. cert_no = his.IdCardNo
  20672. } else {
  20673. cert_no = psn_info.VerifyNumber
  20674. }
  20675. var rf []*ResultFive
  20676. json.Unmarshal([]byte(his.Iinfo), &rf)
  20677. var psn_type string
  20678. for _, item := range rf {
  20679. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20680. psn_type = item.PsnType
  20681. }
  20682. }
  20683. 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)
  20684. var dat map[string]interface{}
  20685. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20686. fmt.Println(dat)
  20687. } else {
  20688. fmt.Println(err)
  20689. }
  20690. saveLog(result2, src_resquest, "2207", "结算")
  20691. userJSONBytes, _ := json.Marshal(dat)
  20692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20693. utils.ErrorLog("解析失败:%v", err)
  20694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20695. return
  20696. }
  20697. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20698. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20699. if his.IdCardType == 1 {
  20700. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20701. bas := strings.Split(psn_info.CardInfo, "|")
  20702. cert_no = bas[2]
  20703. } else if his.IdCardType == 3 {
  20704. cert_no = his.Certno
  20705. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20706. } else if his.IdCardType == 4 {
  20707. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20708. cert_no = his.Certno
  20709. psn_info.VerifyNumber = psn_info.VerifyNumber
  20710. } else {
  20711. cert_no = his.Certno
  20712. psn_info.VerifyNumber = his.Certno
  20713. }
  20714. var api string
  20715. var med_type string
  20716. if his.Insutype == "390" {
  20717. if reg_type == 992102 {
  20718. med_type = "992102"
  20719. }
  20720. if reg_type == 140104 {
  20721. med_type = "140104"
  20722. }
  20723. if reg_type == 14 {
  20724. med_type = "14"
  20725. }
  20726. } else if his.Insutype == "310" {
  20727. if reg_type == 992102 {
  20728. med_type = "992102"
  20729. }
  20730. if reg_type == 14 {
  20731. med_type = "14"
  20732. }
  20733. }
  20734. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20735. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20736. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20738. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20739. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20740. "&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
  20741. resp, requestErr := http.Get(api)
  20742. if requestErr != nil {
  20743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20744. return
  20745. }
  20746. body, ioErr := ioutil.ReadAll(resp.Body)
  20747. if ioErr != nil {
  20748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20750. return
  20751. }
  20752. var respJSON map[string]interface{}
  20753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20756. return
  20757. }
  20758. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20759. if status == "0" {
  20760. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20761. c.ServeSuccessJSON(map[string]interface{}{
  20762. "failed_code": -10,
  20763. "msg": err_msg,
  20764. })
  20765. return
  20766. }
  20767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20768. result, _ := json.Marshal(respJSON)
  20769. fmt.Println("log")
  20770. fmt.Println(string(result))
  20771. if err := json.Unmarshal(result, &ahres); err != nil {
  20772. utils.ErrorLog("解析失败:%v", err)
  20773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20774. return
  20775. }
  20776. res.InfRefmsgid = ahres.InfRefmsgid
  20777. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20778. // 创建对应的Time类型
  20779. t := time.UnixMilli(timestamp)
  20780. // 格式化成指定的日期字符串
  20781. str := t.Format("2006-01-02 15:04:05")
  20782. res.Output.Setlinfo.SetlTime = str
  20783. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20784. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20785. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20786. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20787. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20788. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20789. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20790. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20791. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20792. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20793. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20794. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20795. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20796. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20797. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20798. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20799. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20800. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20801. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20802. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20803. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20804. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20805. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20806. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20807. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20808. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20809. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20810. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20811. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20812. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20813. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20814. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20815. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20816. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20817. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20818. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20819. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20820. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20821. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20822. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20823. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20824. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20825. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20826. res.Output.Setldetail = ahres.Output.Setldetail
  20827. res.ErrMsg = ahres.ErrMsg
  20828. res.Cainfo = ahres.Cainfo
  20829. res.WarnMsg = ahres.WarnMsg
  20830. res.Infcode = ahres.Infcode
  20831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20832. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20833. var cert_no string
  20834. if his.IdCardType == 1 {
  20835. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20836. } else if his.IdCardType == 2 {
  20837. cert_no = his.IdCardNo
  20838. } else {
  20839. cert_no = psn_info.VerifyNumber
  20840. }
  20841. 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, "")
  20842. var dat map[string]interface{}
  20843. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20844. fmt.Println(dat)
  20845. } else {
  20846. fmt.Println(err)
  20847. }
  20848. saveLog(result2, src_resquest, "2207", "结算")
  20849. userJSONBytes, _ := json.Marshal(dat)
  20850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20851. utils.ErrorLog("解析失败:%v", err)
  20852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20853. return
  20854. }
  20855. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20856. psn_info, _ := service.GetPsnByPatientId(id)
  20857. var verify_number string
  20858. if psn_info.IdCardType == 4 {
  20859. verify_number = psn_info.VerifyNumber
  20860. } else if psn_info.IdCardType == 1 {
  20861. bas := strings.Split(psn_info.CardInfo, "|")
  20862. cardNumber := bas[2]
  20863. verify_number = cardNumber
  20864. } else {
  20865. verify_number = psn_info.Certno
  20866. psn_info.IdCardType = 2
  20867. }
  20868. var api string
  20869. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20870. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20871. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20873. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20874. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20875. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20876. resp, requestErr := http.Get(api)
  20877. if requestErr != nil {
  20878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20879. return
  20880. }
  20881. body, ioErr := ioutil.ReadAll(resp.Body)
  20882. if ioErr != nil {
  20883. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20885. return
  20886. }
  20887. var respJSON map[string]interface{}
  20888. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20889. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20891. return
  20892. }
  20893. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20894. result, _ := json.Marshal(respJSON)
  20895. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20896. utils.ErrorLog("解析失败:%v", err)
  20897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20898. return
  20899. }
  20900. } else {
  20901. var src_resquest string
  20902. if miConfig.Code == "H15049901371" {
  20903. //赤峰地区国家医保医疗类别
  20904. //职工透析:医疗类别选特殊情况门诊990502
  20905. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20906. var med_type string
  20907. if his.Insutype == "390" {
  20908. if reg_type == 14 {
  20909. med_type = "9933"
  20910. } else if reg_type == 11 {
  20911. med_type = "11"
  20912. }
  20913. } else if his.Insutype == "310" {
  20914. if reg_type == 14 {
  20915. med_type = "990502"
  20916. } else if reg_type == 11 {
  20917. med_type = "11"
  20918. }
  20919. }
  20920. 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)
  20921. } else {
  20922. if his.IdCardType == 4 {
  20923. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20924. token := psn_info.VerifyNumber
  20925. 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)
  20926. } else {
  20927. 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)
  20928. }
  20929. }
  20930. var dat map[string]interface{}
  20931. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20932. fmt.Println(dat)
  20933. } else {
  20934. fmt.Println(err)
  20935. }
  20936. saveLog(result2, src_resquest, "2207", "结算")
  20937. userJSONBytes, _ := json.Marshal(dat)
  20938. if miConfig.Code == "H15049901371" {
  20939. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20940. utils.ErrorLog("解析失败:%v", err)
  20941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20942. return
  20943. }
  20944. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20945. res.Output = resSeven10265.Output
  20946. res.ErrMsg = resSeven10265.ErrMsg
  20947. res.Cainfo = resSeven10265.Cainfo
  20948. res.WarnMsg = resSeven10265.WarnMsg
  20949. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20950. res.Infcode = infocode
  20951. } else {
  20952. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20953. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20954. utils.ErrorLog("解析失败:%v", err)
  20955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20956. return
  20957. }
  20958. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20959. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20960. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20961. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20962. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20963. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20964. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20965. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20966. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20967. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20968. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20969. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20970. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20971. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20972. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20973. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20974. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20975. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20976. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20977. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20978. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20979. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20980. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20981. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20982. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20983. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20984. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20985. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20986. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20987. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20988. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20989. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20990. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20991. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20992. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20993. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20994. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20995. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20996. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20997. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20998. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20999. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  21000. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  21001. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  21002. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  21003. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  21004. res.ErrMsg = gzresSeven10265Two.ErrMsg
  21005. res.Cainfo = gzresSeven10265Two.Cainfo
  21006. res.WarnMsg = gzresSeven10265Two.WarnMsg
  21007. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21008. //res.Infcode = infocode
  21009. } else {
  21010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21011. utils.ErrorLog("解析失败:%v", err)
  21012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21013. return
  21014. }
  21015. }
  21016. }
  21017. }
  21018. if res.Infcode != 0 {
  21019. errlog := &models.HisOrderError{
  21020. UserOrgId: adminUser.CurrentOrgId,
  21021. Ctime: time.Now().Unix(),
  21022. Mtime: time.Now().Unix(),
  21023. Number: chrg_bchno,
  21024. ErrMsg: res.ErrMsg,
  21025. Status: 1,
  21026. PatientId: id,
  21027. RecordTime: recordDateTime,
  21028. Stage: 6,
  21029. }
  21030. service.CreateErrMsgLog(errlog)
  21031. c.ServeSuccessJSON(map[string]interface{}{
  21032. "failed_code": -10,
  21033. "msg": res.ErrMsg,
  21034. })
  21035. return
  21036. } else {
  21037. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  21038. order.OrderStatus = 2
  21039. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  21040. order.SetlId = res.Output.Setlinfo.SetlID
  21041. order.PsnNo = res.Output.Setlinfo.PsnNo
  21042. order.PsnName = res.Output.Setlinfo.PsnName
  21043. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  21044. order.Certno = res.Output.Setlinfo.Certno
  21045. order.Gend = res.Output.Setlinfo.Gend
  21046. order.Naty = res.Output.Setlinfo.Naty
  21047. order.Age = res.Output.Setlinfo.Age
  21048. order.Insutype = res.Output.Setlinfo.Insutype
  21049. order.PsnType = res.Output.Setlinfo.PsnType
  21050. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  21051. order.SetlTime = res.Output.Setlinfo.SetlTime
  21052. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  21053. order.PayWays = pay_ways
  21054. order.AcctUsedFlag = acct_used_flag
  21055. order.WechatPay = wechat_pay
  21056. order.AliPay = ali_pay
  21057. order.JifenPay = jifen_pay
  21058. order.BandCardPay = band_card_pay
  21059. order.CashPay = cash_pay
  21060. order.OthDesc = oth_desc
  21061. //order.MedType = res.Output.Setlinfo.MedType
  21062. if reg_type == 1112 {
  21063. order.MedType = "1112"
  21064. }
  21065. if reg_type == 1111 {
  21066. order.MedType = "1111"
  21067. }
  21068. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  21069. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  21070. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  21071. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  21072. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  21073. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  21074. order.HifpPay = res.Output.Setlinfo.HifpPay
  21075. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  21076. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  21077. order.HifesPay = res.Output.Setlinfo.HifesPay
  21078. order.HifobPay = res.Output.Setlinfo.HifobPay
  21079. order.MafPay = res.Output.Setlinfo.MafPay
  21080. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  21081. order.OthPay = res.Output.Setlinfo.OthPay
  21082. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  21083. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  21084. order.AcctPay = res.Output.Setlinfo.AcctPay
  21085. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  21086. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  21087. order.Balc = res.Output.Setlinfo.Balc
  21088. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  21089. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  21090. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  21091. order.ClrWay = res.Output.Setlinfo.ClrWay
  21092. order.Creator = order.Creator
  21093. order.ClrType = res.Output.Setlinfo.ClrType
  21094. order.Modify = roles.AdminUserId
  21095. order.RequestLog = src_resquest
  21096. order.Diagnosis = diagnosis_id
  21097. order.FaPiaoNumber = fapiao_number
  21098. order.FaPiaoCode = fapiao_code
  21099. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21100. detailStr := string(setlDetail)
  21101. order.SetlDetail = detailStr
  21102. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21103. err = service.UpDateOrder(order)
  21104. if err == nil {
  21105. //判断是否使用了押金
  21106. if dec_way == "true" {
  21107. tmpstring := strconv.FormatInt(order.ID, 10)
  21108. //扣押金
  21109. order.Decimal = decimal
  21110. service.UpDateOrder(order)
  21111. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21112. if errmsg != nil {
  21113. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21114. return
  21115. }
  21116. }
  21117. c.ServeSuccessJSON(map[string]interface{}{
  21118. "msg": "结算成功",
  21119. })
  21120. } else {
  21121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21122. return
  21123. }
  21124. }
  21125. }
  21126. }
  21127. }
  21128. // 上传明细-预结算-
  21129. func (c *HisApiController) GetPreUploadInfo() {
  21130. id, _ := c.GetInt64("id")
  21131. record_time := c.GetString("record_time")
  21132. his_patient_id, _ := c.GetInt64("his_patient_id")
  21133. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21134. admin_user_id, _ := c.GetInt64("admin_user_id")
  21135. diagnosis_id := c.GetString("diagnosis")
  21136. sick_type, _ := c.GetInt64("sick_type")
  21137. reg_type, _ := c.GetInt64("p_type")
  21138. begin_time := c.GetString("begin_time")
  21139. acct_used_flag := c.GetString("acct_used_flag")
  21140. id_str := c.GetString("ids")
  21141. ids_arr := strings.Split(id_str, ",")
  21142. timeLayout := "2006-01-02"
  21143. loc, _ := time.LoadLocation("Local")
  21144. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21145. if err != nil {
  21146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21147. return
  21148. }
  21149. recordDateTime := theTime.Unix()
  21150. adminUser := c.GetAdminUserInfo()
  21151. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21152. var config []*models.HisXtDiagnoseConfig
  21153. for _, item := range diagnosis_ids {
  21154. id, _ := strconv.ParseInt(item, 10, 64)
  21155. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21156. config = append(config, &diagnosisConfig)
  21157. }
  21158. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21159. sickConfig, _ := service.FindSickById(sick_type)
  21160. var prescriptions []*models.HisPrescription
  21161. var start_time int64
  21162. var end_time int64
  21163. var isSuccess bool = true
  21164. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21165. fmt.Println(his_patient_id)
  21166. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21167. timestamp := time.Now().Unix()
  21168. tempTime := time.Unix(timestamp, 0)
  21169. timeFormat := tempTime.Format("20060102150405")
  21170. chrgBchno := rand.Intn(100000) + 10000
  21171. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21172. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21173. var patientPrescription models.HisPrescriptionInfo
  21174. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21175. if patientPrescription.ID == 0 {
  21176. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21177. }
  21178. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21179. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21180. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21181. strconv.FormatInt(his.PatientId, 10)
  21182. var res2406 Result2406
  21183. //安徽单病种处理
  21184. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21185. data := make(map[string]interface{})
  21186. client := &http.Client{}
  21187. data["psn_no"] = his.PsnNo
  21188. data["mdtrt_id"] = his.Number
  21189. data["operator"] = roles.UserName
  21190. data["cert_no"] = his.IdCardNo
  21191. data["org_name"] = miConfig.OrgName
  21192. data["psn_name"] = his.Name
  21193. data["ipt_otp_no"] = his.IptOtpNo
  21194. data["ipt_psn_sp_flag_type"] = "0901"
  21195. data["ipt_psn_sp_flag"] = "1"
  21196. data["fixmedins_code"] = miConfig.Code
  21197. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21198. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21199. data["url"] = miConfig.Url
  21200. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21201. bytesData, _ := json.Marshal(data)
  21202. var req *http.Request
  21203. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21204. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21205. resp, _ := client.Do(req)
  21206. defer resp.Body.Close()
  21207. body, ioErr := ioutil.ReadAll(resp.Body)
  21208. if ioErr != nil {
  21209. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21211. return
  21212. }
  21213. var respJSON map[string]interface{}
  21214. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21215. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21217. return
  21218. }
  21219. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21220. if status == "0" {
  21221. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21222. c.ServeSuccessJSON(map[string]interface{}{
  21223. "failed_code": -10,
  21224. "msg": err_msg,
  21225. })
  21226. return
  21227. }
  21228. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21229. userJSONBytes, _ := json.Marshal(respJSON)
  21230. fmt.Println("log")
  21231. fmt.Println(string(userJSONBytes))
  21232. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21233. utils.ErrorLog("解析失败:%v", err)
  21234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21235. return
  21236. }
  21237. }
  21238. if res2406.Infcode != 0 {
  21239. adminUser := c.GetAdminUserInfo()
  21240. errlog := &models.HisOrderError{
  21241. UserOrgId: adminUser.CurrentOrgId,
  21242. Ctime: time.Now().Unix(),
  21243. Mtime: time.Now().Unix(),
  21244. ErrMsg: res2406.ErrMsg,
  21245. Status: 1,
  21246. PatientId: id,
  21247. RecordTime: recordDateTime,
  21248. Stage: 3,
  21249. }
  21250. service.CreateErrMsgLog(errlog)
  21251. c.ServeSuccessJSON(map[string]interface{}{
  21252. "failed_code": -10,
  21253. "msg": res2406.ErrMsg,
  21254. })
  21255. return
  21256. }
  21257. var res2 ResultSix
  21258. var res3 GZResultSix
  21259. var resSix10265 ResultSix10265
  21260. //var time_stamp string
  21261. if miConfig.MdtrtareaAdmvs == "421300" {
  21262. data := make(map[string]interface{})
  21263. client := &http.Client{}
  21264. data["psn_no"] = his.PsnNo
  21265. data["mdtrt_id"] = his.Number
  21266. data["department"] = department.Name
  21267. data["org_name"] = miConfig.OrgName
  21268. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21269. data["doctor_id"] = doctor_info.DoctorNumber
  21270. data["doctor_name"] = roles.UserName
  21271. data["fixmedins_code"] = miConfig.Code
  21272. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21273. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21274. data["secret_key"] = miConfig.SecretKey
  21275. data["sick_code"] = sickConfig.CountryCode
  21276. data["sick_name"] = sickConfig.ClassName
  21277. data["begin_time"] = begin_time
  21278. data["dept"] = strconv.FormatInt(department.ID, 10)
  21279. data["config"] = config
  21280. data["opter"] = roles.UserName
  21281. fmt.Println(data)
  21282. bytesData, _ := json.Marshal(data)
  21283. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21284. resp, _ := client.Do(req)
  21285. defer resp.Body.Close()
  21286. body, ioErr := ioutil.ReadAll(resp.Body)
  21287. if ioErr != nil {
  21288. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21290. return
  21291. }
  21292. var respJSON map[string]interface{}
  21293. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21294. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21296. return
  21297. }
  21298. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21299. userJSONBytes, _ := json.Marshal(respJSON)
  21300. fmt.Println("log")
  21301. fmt.Println(string(userJSONBytes))
  21302. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21303. utils.ErrorLog("解析失败:%v", err)
  21304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21305. return
  21306. }
  21307. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21308. data := make(map[string]interface{})
  21309. client := &http.Client{}
  21310. data["psn_no"] = his.PsnNo
  21311. data["mdtrt_id"] = his.Number
  21312. data["department"] = department.Name
  21313. data["org_name"] = miConfig.OrgName
  21314. if reg_type == 11 && his.Insutype == "390" {
  21315. data["med_type"] = "110104"
  21316. } else {
  21317. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21318. }
  21319. data["doctor_id"] = doctor_info.DoctorNumber
  21320. data["doctor_name"] = roles.UserName
  21321. data["fixmedins_code"] = miConfig.Code
  21322. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21323. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21324. data["secret_key"] = miConfig.SecretKey
  21325. data["sick_code"] = sickConfig.CountryCode
  21326. data["sick_name"] = sickConfig.ClassName
  21327. data["begin_time"] = begin_time
  21328. data["dept"] = strconv.FormatInt(department.ID, 10)
  21329. data["config"] = config
  21330. data["opter"] = roles.UserName
  21331. fmt.Println(data)
  21332. bytesData, _ := json.Marshal(data)
  21333. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21334. resp, _ := client.Do(req)
  21335. defer resp.Body.Close()
  21336. body, ioErr := ioutil.ReadAll(resp.Body)
  21337. if ioErr != nil {
  21338. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21340. return
  21341. }
  21342. var respJSON map[string]interface{}
  21343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21346. return
  21347. }
  21348. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21349. userJSONBytes, _ := json.Marshal(respJSON)
  21350. fmt.Println("log")
  21351. fmt.Println(string(userJSONBytes))
  21352. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21353. utils.ErrorLog("解析失败:%v", err)
  21354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21355. return
  21356. }
  21357. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21358. data := make(map[string]interface{})
  21359. client := &http.Client{}
  21360. data["psn_no"] = his.PsnNo
  21361. data["mdtrt_id"] = his.Number
  21362. data["department"] = department.Name
  21363. data["org_name"] = miConfig.OrgName
  21364. if reg_type == 11 && his.Insutype == "390" {
  21365. data["med_type"] = "110104"
  21366. } else {
  21367. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21368. }
  21369. data["doctor_id"] = doctor_info.DoctorNumber
  21370. data["doctor_name"] = roles.UserName
  21371. data["fixmedins_code"] = miConfig.Code
  21372. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21373. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21374. data["secret_key"] = miConfig.SecretKey
  21375. data["sick_code"] = sickConfig.CountryCode
  21376. data["sick_name"] = sickConfig.ClassName
  21377. data["begin_time"] = begin_time
  21378. data["dept"] = strconv.FormatInt(department.ID, 10)
  21379. data["config"] = config
  21380. data["opter"] = roles.UserName
  21381. fmt.Println(data)
  21382. bytesData, _ := json.Marshal(data)
  21383. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21384. resp, _ := client.Do(req)
  21385. defer resp.Body.Close()
  21386. body, ioErr := ioutil.ReadAll(resp.Body)
  21387. if ioErr != nil {
  21388. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21390. return
  21391. }
  21392. var respJSON map[string]interface{}
  21393. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21394. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21396. return
  21397. }
  21398. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21399. userJSONBytes, _ := json.Marshal(respJSON)
  21400. fmt.Println("log")
  21401. fmt.Println(string(userJSONBytes))
  21402. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21403. utils.ErrorLog("解析失败:%v", err)
  21404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21405. return
  21406. }
  21407. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21408. data := make(map[string]interface{})
  21409. client := &http.Client{}
  21410. data["psn_no"] = his.PsnNo
  21411. data["mdtrt_id"] = his.Number
  21412. data["department"] = department.Name
  21413. data["org_name"] = miConfig.OrgName
  21414. if reg_type == 11 && his.Insutype == "390" {
  21415. data["med_type"] = "110104"
  21416. } else {
  21417. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21418. }
  21419. data["doctor_id"] = doctor_info.DoctorNumber
  21420. data["doctor_name"] = roles.UserName
  21421. data["fixmedins_code"] = miConfig.Code
  21422. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21423. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21424. data["secret_key"] = miConfig.SecretKey
  21425. data["sick_code"] = sickConfig.CountryCode
  21426. data["sick_name"] = sickConfig.ClassName
  21427. data["begin_time"] = begin_time
  21428. data["dept"] = strconv.FormatInt(department.ID, 10)
  21429. data["config"] = config
  21430. data["opter"] = roles.UserName
  21431. fmt.Println(data)
  21432. bytesData, _ := json.Marshal(data)
  21433. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21434. resp, _ := client.Do(req)
  21435. defer resp.Body.Close()
  21436. body, ioErr := ioutil.ReadAll(resp.Body)
  21437. if ioErr != nil {
  21438. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21440. return
  21441. }
  21442. var respJSON map[string]interface{}
  21443. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21444. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21446. return
  21447. }
  21448. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21449. userJSONBytes, _ := json.Marshal(respJSON)
  21450. fmt.Println("log")
  21451. fmt.Println(string(userJSONBytes))
  21452. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21453. utils.ErrorLog("解析失败:%v", err)
  21454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21455. return
  21456. }
  21457. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21458. data := make(map[string]interface{})
  21459. client := &http.Client{}
  21460. data["psn_no"] = his.PsnNo
  21461. data["mdtrt_id"] = his.Number
  21462. data["doctor"] = roles.UserName
  21463. data["department"] = department.Name
  21464. data["org_name"] = miConfig.OrgName
  21465. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21466. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21467. data["fixmedins_code"] = miConfig.Code
  21468. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21469. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21470. data["secret_key"] = miConfig.SecretKey
  21471. data["sick_code"] = sickConfig.CountryCode
  21472. data["sick_name"] = sickConfig.ClassName
  21473. data["begin_time"] = begin_time
  21474. data["dept"] = strconv.FormatInt(department.ID, 10)
  21475. data["config"] = config
  21476. data["url"] = miConfig.Url
  21477. data["ak"] = miConfig.AccessKey
  21478. data["cainfo"] = miConfig.Cainfo
  21479. bytesData, _ := json.Marshal(data)
  21480. var req *http.Request
  21481. if miConfig.MdtrtareaAdmvs == "320921" {
  21482. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21483. } else {
  21484. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21485. }
  21486. resp, _ := client.Do(req)
  21487. defer resp.Body.Close()
  21488. body, ioErr := ioutil.ReadAll(resp.Body)
  21489. if ioErr != nil {
  21490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21492. return
  21493. }
  21494. var respJSON map[string]interface{}
  21495. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21498. return
  21499. }
  21500. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21501. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21502. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21504. userJSONBytes, _ := json.Marshal(respJSON)
  21505. fmt.Println("log")
  21506. fmt.Println(string(userJSONBytes))
  21507. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21508. utils.ErrorLog("解析失败:%v", err)
  21509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21510. return
  21511. }
  21512. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21513. res2.Output = resSix10265.Output
  21514. res2.ErrMsg = resSix10265.ErrMsg
  21515. res2.Cainfo = resSix10265.Cainfo
  21516. res2.WarnMsg = resSix10265.WarnMsg
  21517. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21518. res2.Infcode = infocode
  21519. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21520. data := make(map[string]interface{})
  21521. client := &http.Client{}
  21522. data["psn_no"] = his.PsnNo
  21523. data["mdtrt_id"] = his.Number
  21524. data["doctor"] = roles.UserName
  21525. data["department"] = department.Name
  21526. data["org_name"] = miConfig.OrgName
  21527. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21528. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21529. data["fixmedins_code"] = miConfig.Code
  21530. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21531. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21532. data["secret_key"] = miConfig.SecretKey
  21533. data["sick_code"] = sickConfig.CountryCode
  21534. data["sick_name"] = sickConfig.ClassName
  21535. data["begin_time"] = begin_time
  21536. data["dept"] = strconv.FormatInt(department.ID, 10)
  21537. data["config"] = config
  21538. //data["url"] = miConfig.Url
  21539. //data["ak"] = miConfig.AccessKey
  21540. data["cainfo"] = miConfig.Cainfo
  21541. fmt.Println(data)
  21542. bytesData, _ := json.Marshal(data)
  21543. var req *http.Request
  21544. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21545. resp, _ := client.Do(req)
  21546. defer resp.Body.Close()
  21547. body, ioErr := ioutil.ReadAll(resp.Body)
  21548. if ioErr != nil {
  21549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21551. return
  21552. }
  21553. var respJSON map[string]interface{}
  21554. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21557. return
  21558. }
  21559. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21560. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21561. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21563. userJSONBytes, _ := json.Marshal(respJSON)
  21564. fmt.Println("log")
  21565. fmt.Println(string(userJSONBytes))
  21566. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21567. utils.ErrorLog("解析失败:%v", err)
  21568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21569. return
  21570. }
  21571. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21572. res2.Output = resSix10265.Output
  21573. res2.ErrMsg = resSix10265.ErrMsg
  21574. res2.Cainfo = resSix10265.Cainfo
  21575. res2.WarnMsg = resSix10265.WarnMsg
  21576. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21577. res2.Infcode = infocode
  21578. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21579. 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)
  21580. saveLog(result, requestLog, "2203", "上传就诊信息")
  21581. var respJSON2 map[string]interface{}
  21582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21585. return
  21586. }
  21587. userJSONBytes2, _ := json.Marshal(respJSON2)
  21588. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21589. utils.ErrorLog("解析失败:%v", err)
  21590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21591. return
  21592. }
  21593. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21594. var result string
  21595. var requestLog string
  21596. 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, "")
  21597. saveLog(result, requestLog, "2203", "上传就诊信息")
  21598. var respJSON2 map[string]interface{}
  21599. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21602. return
  21603. }
  21604. userJSONBytes2, _ := json.Marshal(respJSON2)
  21605. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21606. utils.ErrorLog("解析失败:%v", err)
  21607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21608. return
  21609. }
  21610. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21611. data := make(map[string]interface{})
  21612. client := &http.Client{}
  21613. data["psn_no"] = his.PsnNo
  21614. data["mdtrt_id"] = his.Number
  21615. data["operator"] = roles.UserName
  21616. data["department"] = department.Name
  21617. data["org_name"] = miConfig.OrgName
  21618. var med_type string
  21619. if his.Insutype == "390" {
  21620. if reg_type == 992102 {
  21621. med_type = "992102"
  21622. data["sick_code"] = "ZDZ940"
  21623. data["sick_name"] = "慢性肾衰竭"
  21624. }
  21625. if reg_type == 140104 {
  21626. med_type = "140104"
  21627. data["sick_code"] = sickConfig.CountryCode
  21628. data["sick_name"] = sickConfig.ClassName
  21629. }
  21630. if reg_type == 14 {
  21631. med_type = "140104"
  21632. data["sick_code"] = sickConfig.CountryCode
  21633. data["sick_name"] = sickConfig.ClassName
  21634. }
  21635. } else if his.Insutype == "310" {
  21636. if reg_type == 992102 {
  21637. med_type = "992102"
  21638. data["sick_code"] = "ZDZ940"
  21639. data["sick_name"] = "慢性肾衰竭"
  21640. }
  21641. if reg_type == 140104 {
  21642. med_type = "140104"
  21643. data["sick_code"] = sickConfig.CountryCode
  21644. data["sick_name"] = sickConfig.ClassName
  21645. }
  21646. if reg_type == 14 {
  21647. med_type = "14"
  21648. data["sick_code"] = sickConfig.CountryCode
  21649. data["sick_name"] = sickConfig.ClassName
  21650. }
  21651. }
  21652. data["med_type"] = med_type
  21653. data["doctor_number"] = doctor_info.DoctorNumber
  21654. data["doctor_name"] = doctor_info.UserName
  21655. data["fixmedins_code"] = miConfig.Code
  21656. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21657. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21658. data["secret_key"] = miConfig.SecretKey
  21659. data["begin_time"] = begin_time
  21660. data["dept"] = strconv.FormatInt(department.ID, 10)
  21661. data["config"] = config
  21662. data["url"] = miConfig.Url
  21663. data["ak"] = miConfig.AccessKey
  21664. data["cainfo"] = miConfig.Cainfo
  21665. bytesData, _ := json.Marshal(data)
  21666. var req *http.Request
  21667. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21668. resp, _ := client.Do(req)
  21669. defer resp.Body.Close()
  21670. body, ioErr := ioutil.ReadAll(resp.Body)
  21671. if ioErr != nil {
  21672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21674. return
  21675. }
  21676. var respJSON map[string]interface{}
  21677. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21680. return
  21681. }
  21682. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21683. if status == "0" {
  21684. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21685. c.ServeSuccessJSON(map[string]interface{}{
  21686. "failed_code": -10,
  21687. "msg": err_msg,
  21688. })
  21689. return
  21690. }
  21691. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21692. userJSONBytes, _ := json.Marshal(respJSON)
  21693. fmt.Println("log")
  21694. fmt.Println(string(userJSONBytes))
  21695. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21696. utils.ErrorLog("解析失败:%v", err)
  21697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21698. return
  21699. }
  21700. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21701. var result string
  21702. var requestLog string
  21703. 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, "")
  21704. saveLog(result, requestLog, "2203", "上传就诊信息")
  21705. var respJSON2 map[string]interface{}
  21706. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21707. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21709. return
  21710. }
  21711. userJSONBytes2, _ := json.Marshal(respJSON2)
  21712. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21713. utils.ErrorLog("解析失败:%v", err)
  21714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21715. return
  21716. }
  21717. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21718. data := make(map[string]interface{})
  21719. client := &http.Client{}
  21720. data["psn_no"] = his.PsnNo
  21721. data["mdtrt_id"] = his.Number
  21722. data["doctor"] = roles.UserName
  21723. data["department"] = department.Name
  21724. data["org_name"] = miConfig.OrgName
  21725. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21726. data["doctor_id"] = doctor_info.DoctorNumber
  21727. data["fixmedins_code"] = miConfig.Code
  21728. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21729. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21730. data["secret_key"] = miConfig.SecretKey
  21731. data["sick_code"] = sickConfig.CountryCode
  21732. data["sick_name"] = sickConfig.ClassName
  21733. data["begin_time"] = begin_time
  21734. data["new_doctor_name"] = doctor_info.UserName
  21735. data["dept"] = strconv.FormatInt(department.ID, 10)
  21736. data["config"] = config
  21737. bytesData, _ := json.Marshal(data)
  21738. var req *http.Request
  21739. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21740. resp, _ := client.Do(req)
  21741. defer resp.Body.Close()
  21742. body, ioErr := ioutil.ReadAll(resp.Body)
  21743. if ioErr != nil {
  21744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21746. return
  21747. }
  21748. var respJSON map[string]interface{}
  21749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21752. return
  21753. }
  21754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21755. userJSONBytes, _ := json.Marshal(respJSON)
  21756. fmt.Println("log")
  21757. fmt.Println(string(userJSONBytes))
  21758. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21759. utils.ErrorLog("解析失败:%v", err)
  21760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21761. return
  21762. }
  21763. } else {
  21764. var result string
  21765. var requestLog string
  21766. if miConfig.MdtrtareaAdmvs == "440781" { //
  21767. 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)
  21768. } else {
  21769. if miConfig.Code == "H15049901371" {
  21770. //赤峰地区国家医保医疗类别
  21771. //职工透析:医疗类别选特殊情况门诊990502
  21772. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21773. var med_type string
  21774. if his.Insutype == "390" {
  21775. if reg_type == 14 {
  21776. med_type = "9933"
  21777. } else if reg_type == 11 {
  21778. med_type = "11"
  21779. }
  21780. } else if his.Insutype == "310" {
  21781. if reg_type == 14 {
  21782. med_type = "990502"
  21783. } else if reg_type == 11 {
  21784. med_type = "11"
  21785. }
  21786. }
  21787. 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)
  21788. } else {
  21789. 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)
  21790. }
  21791. saveLog(result, requestLog, "2203", "上传就诊信息")
  21792. var respJSON2 map[string]interface{}
  21793. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21794. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21796. return
  21797. }
  21798. userJSONBytes2, _ := json.Marshal(respJSON2)
  21799. if miConfig.Code == "H15049901371" {
  21800. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21801. utils.ErrorLog("解析失败:%v", err)
  21802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21803. return
  21804. }
  21805. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21806. res2.Output = resSix10265.Output
  21807. res2.ErrMsg = resSix10265.ErrMsg
  21808. res2.Cainfo = resSix10265.Cainfo
  21809. res2.WarnMsg = resSix10265.WarnMsg
  21810. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21811. res2.Infcode = infocode
  21812. } else {
  21813. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21814. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21815. utils.ErrorLog("解析失败:%v", err)
  21816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21817. return
  21818. }
  21819. res2.Infcode = res3.Infcode
  21820. } else {
  21821. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21822. utils.ErrorLog("解析失败:%v", err)
  21823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21824. return
  21825. }
  21826. }
  21827. }
  21828. }
  21829. }
  21830. if res2.Infcode == -1 {
  21831. adminUser := c.GetAdminUserInfo()
  21832. errlog := &models.HisOrderError{
  21833. UserOrgId: adminUser.CurrentOrgId,
  21834. Ctime: time.Now().Unix(),
  21835. Mtime: time.Now().Unix(),
  21836. ErrMsg: res2.ErrMsg,
  21837. Status: 1,
  21838. PatientId: id,
  21839. RecordTime: recordDateTime,
  21840. Stage: 3,
  21841. }
  21842. service.CreateErrMsgLog(errlog)
  21843. c.ServeSuccessJSON(map[string]interface{}{
  21844. "failed_code": -10,
  21845. "msg": res2.ErrMsg,
  21846. })
  21847. return
  21848. }
  21849. if res2.Infcode != 0 {
  21850. adminUser := c.GetAdminUserInfo()
  21851. errlog := &models.HisOrderError{
  21852. UserOrgId: adminUser.CurrentOrgId,
  21853. Ctime: time.Now().Unix(),
  21854. Mtime: time.Now().Unix(),
  21855. ErrMsg: res2.ErrMsg,
  21856. Status: 1,
  21857. PatientId: id,
  21858. RecordTime: recordDateTime,
  21859. Stage: 3,
  21860. }
  21861. service.CreateErrMsgLog(errlog)
  21862. c.ServeSuccessJSON(map[string]interface{}{
  21863. "failed_code": -10,
  21864. "msg": res2.ErrMsg,
  21865. })
  21866. return
  21867. } else {
  21868. his.Diagnosis = diagnosis_id
  21869. his.SickType = sickConfig.ID
  21870. his.PType = fmt.Sprintf("%d", reg_type)
  21871. service.UpdateHisPatientThree(&his)
  21872. data := make(map[string]interface{})
  21873. if settle_accounts_type == 1 { //日结
  21874. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21875. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21876. } else {
  21877. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21878. }
  21879. data["pre"] = prescriptions
  21880. } else { //月结
  21881. start_time_str := c.GetString("start_time")
  21882. end_time_str := c.GetString("end_time")
  21883. timeLayout := "2006-01-02"
  21884. loc, _ := time.LoadLocation("Local")
  21885. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21886. if err != nil {
  21887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21888. return
  21889. }
  21890. recordStartTime := theStartTime.Unix()
  21891. start_time = recordStartTime
  21892. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21893. if err != nil {
  21894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21895. return
  21896. }
  21897. recordEndTime := theEndTime.Unix()
  21898. end_time = recordEndTime
  21899. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21900. data["pre"] = prescriptions
  21901. }
  21902. client := &http.Client{}
  21903. data["psn_no"] = his.PsnNo
  21904. data["mdtrt_id"] = his.Number
  21905. data["chrg_bchno"] = chrg_bchno
  21906. data["org_name"] = miConfig.OrgName
  21907. data["doctor"] = doctor_info.UserName
  21908. data["doctor_id"] = doctor_info.DoctorNumber
  21909. data["dept"] = department.Name
  21910. data["fixmedins_code"] = miConfig.Code
  21911. data["opter"] = roles.UserName
  21912. data["dept_code"] = department.Number
  21913. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21914. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21915. data["secret_key"] = miConfig.SecretKey
  21916. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21917. data["url"] = miConfig.Url
  21918. data["ak"] = miConfig.AccessKey
  21919. data["new_doctor_name"] = patientPrescription.Doctor
  21920. if his.Insutype == "390" {
  21921. if reg_type == 992102 {
  21922. data["diag_code"] = "ZDZ940"
  21923. }
  21924. if reg_type == 140104 {
  21925. data["diag_code"] = sickConfig.CountryCode
  21926. }
  21927. if reg_type == 14 {
  21928. data["diag_code"] = sickConfig.CountryCode
  21929. }
  21930. } else if his.Insutype == "310" {
  21931. if reg_type == 992102 {
  21932. data["diag_code"] = "ZDZ940"
  21933. }
  21934. if reg_type == 14 {
  21935. data["diag_code"] = sickConfig.CountryCode
  21936. }
  21937. }
  21938. data["cainfo"] = miConfig.Cainfo
  21939. data["opter"] = roles.UserName
  21940. var ids []int64
  21941. for _, item := range prescriptions {
  21942. ids = append(ids, item.ID)
  21943. }
  21944. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21945. if config.IsOpen == 1 { //对接了医保,走医保流程
  21946. var res ResultFour
  21947. var resFour10265 ResultFour10265
  21948. if miConfig.MdtrtareaAdmvs == "421300" {
  21949. bytesData, _ := json.Marshal(data)
  21950. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21951. resp, _ := client.Do(req)
  21952. defer resp.Body.Close()
  21953. body, ioErr := ioutil.ReadAll(resp.Body)
  21954. if ioErr != nil {
  21955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21957. return
  21958. }
  21959. var respJSON map[string]interface{}
  21960. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21963. return
  21964. }
  21965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21966. userJSONBytes, _ := json.Marshal(respJSON)
  21967. fmt.Println("log")
  21968. fmt.Println(string(userJSONBytes))
  21969. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21970. utils.ErrorLog("解析失败:%v", err)
  21971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21972. return
  21973. }
  21974. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21975. bytesData, _ := json.Marshal(data)
  21976. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21977. resp, _ := client.Do(req)
  21978. defer resp.Body.Close()
  21979. body, ioErr := ioutil.ReadAll(resp.Body)
  21980. if ioErr != nil {
  21981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21983. return
  21984. }
  21985. var respJSON map[string]interface{}
  21986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21989. return
  21990. }
  21991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21992. userJSONBytes, _ := json.Marshal(respJSON)
  21993. fmt.Println("log")
  21994. fmt.Println(string(userJSONBytes))
  21995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21996. utils.ErrorLog("解析失败:%v", err)
  21997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21998. return
  21999. }
  22000. }else if miConfig.MdtrtareaAdmvs == "420902" {
  22001. bytesData, _ := json.Marshal(data)
  22002. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22003. resp, _ := client.Do(req)
  22004. defer resp.Body.Close()
  22005. body, ioErr := ioutil.ReadAll(resp.Body)
  22006. if ioErr != nil {
  22007. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22009. return
  22010. }
  22011. var respJSON map[string]interface{}
  22012. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22013. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22015. return
  22016. }
  22017. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22018. userJSONBytes, _ := json.Marshal(respJSON)
  22019. fmt.Println("log")
  22020. fmt.Println(string(userJSONBytes))
  22021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22022. utils.ErrorLog("解析失败:%v", err)
  22023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22024. return
  22025. }
  22026. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22027. bytesData, _ := json.Marshal(data)
  22028. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  22029. resp, _ := client.Do(req)
  22030. defer resp.Body.Close()
  22031. body, ioErr := ioutil.ReadAll(resp.Body)
  22032. if ioErr != nil {
  22033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22035. return
  22036. }
  22037. var respJSON map[string]interface{}
  22038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22041. return
  22042. }
  22043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22044. userJSONBytes, _ := json.Marshal(respJSON)
  22045. fmt.Println("log")
  22046. fmt.Println(string(userJSONBytes))
  22047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22048. utils.ErrorLog("解析失败:%v", err)
  22049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22050. return
  22051. }
  22052. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22053. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22054. if result3101.Infcode == "0" {
  22055. if len(result3101.Output.Result) > 0 {
  22056. var errMsgs []string
  22057. for _, item := range result3101.Output.Result {
  22058. errMsgs = append(errMsgs, item.VolaCont)
  22059. }
  22060. c.ServeSuccessJSON(map[string]interface{}{
  22061. "failed_code": -10,
  22062. "msg": errMsgs,
  22063. })
  22064. return
  22065. } else {
  22066. if miConfig.MdtrtareaAdmvs == "320921" {
  22067. data["doctor_id"] = "D320923012139"
  22068. } else {
  22069. data["doctor_id"] = "D371621008686"
  22070. }
  22071. bytesData, _ := json.Marshal(data)
  22072. var req *http.Request
  22073. if miConfig.MdtrtareaAdmvs == "320921" {
  22074. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22075. } else {
  22076. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22077. }
  22078. resp, _ := client.Do(req)
  22079. defer resp.Body.Close()
  22080. body, ioErr := ioutil.ReadAll(resp.Body)
  22081. if ioErr != nil {
  22082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22084. return
  22085. }
  22086. var respJSON map[string]interface{}
  22087. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22090. return
  22091. }
  22092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22093. userJSONBytes, _ := json.Marshal(respJSON)
  22094. fmt.Println("log")
  22095. fmt.Println(string(userJSONBytes))
  22096. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22097. utils.ErrorLog("解析失败:%v", err)
  22098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22099. return
  22100. }
  22101. res.InfRefmsgid = resFour10265.InfRefmsgid
  22102. res.Output = resFour10265.Output
  22103. res.ErrMsg = resFour10265.ErrMsg
  22104. res.Cainfo = resFour10265.Cainfo
  22105. res.WarnMsg = resFour10265.WarnMsg
  22106. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22107. res.Infcode = infocode
  22108. }
  22109. }
  22110. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22111. var pagesize int = 5
  22112. var start int = 1
  22113. var stop int
  22114. var pagecount int
  22115. var curpage int
  22116. data["doctor_id"] = doctor_info.DoctorNumber
  22117. var res2 ResultFour
  22118. //var result res.
  22119. //总页数,向上取整,注意除之前要先转换类型为float64
  22120. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22121. for curpage = 1; curpage <= pagecount; curpage++ {
  22122. if curpage == 1 {
  22123. start = 1
  22124. } else {
  22125. start = (curpage-1)*pagesize + 1
  22126. }
  22127. stop = curpage * pagesize
  22128. if stop > len(prescriptions) {
  22129. stop = len(prescriptions)
  22130. }
  22131. //var requestLog string
  22132. data["pre"] = prescriptions[start-1 : stop]
  22133. fmt.Println(data["pre"])
  22134. bytesData, _ := json.Marshal(data)
  22135. var req *http.Request
  22136. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22137. resp, _ := client.Do(req)
  22138. defer resp.Body.Close()
  22139. body, ioErr := ioutil.ReadAll(resp.Body)
  22140. if ioErr != nil {
  22141. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22143. return
  22144. }
  22145. var respJSON map[string]interface{}
  22146. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22147. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22149. return
  22150. }
  22151. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22152. userJSONBytes, _ := json.Marshal(respJSON)
  22153. fmt.Println("log")
  22154. fmt.Println(string(userJSONBytes))
  22155. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22156. utils.ErrorLog("解析失败:%v", err)
  22157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22158. return
  22159. }
  22160. res.InfRefmsgid = resFour10265.InfRefmsgid
  22161. res.Output = resFour10265.Output
  22162. res.ErrMsg = resFour10265.ErrMsg
  22163. res.Cainfo = resFour10265.Cainfo
  22164. res.WarnMsg = resFour10265.WarnMsg
  22165. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22166. res.Infcode = infocode
  22167. if infocode == 0 {
  22168. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22169. } else {
  22170. isSuccess = false
  22171. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22172. res.Infcode = -1
  22173. res.ErrMsg = resFour10265.ErrMsg
  22174. errlog := &models.HisOrderError{
  22175. UserOrgId: adminUser.CurrentOrgId,
  22176. Ctime: time.Now().Unix(),
  22177. Mtime: time.Now().Unix(),
  22178. Number: chrg_bchno,
  22179. ErrMsg: "",
  22180. Status: 1,
  22181. PatientId: id,
  22182. RecordTime: recordDateTime,
  22183. Stage: 4,
  22184. }
  22185. service.CreateErrMsgLog(errlog)
  22186. }
  22187. }
  22188. if isSuccess {
  22189. res.Infcode = 0
  22190. res.Output.Result = res2.Output.Result
  22191. } else {
  22192. order := &models.HisOrder{
  22193. UserOrgId: adminUser.CurrentOrgId,
  22194. HisPatientId: his.ID,
  22195. PatientId: his.PatientId,
  22196. SettleAccountsDate: recordDateTime,
  22197. Ctime: time.Now().Unix(),
  22198. Mtime: time.Now().Unix(),
  22199. MdtrtId: his.Number,
  22200. PsnNo: his.PsnNo,
  22201. MedType: strconv.FormatInt(reg_type, 10),
  22202. Status: 1,
  22203. Number: chrg_bchno,
  22204. Infcode: res.Infcode,
  22205. WarnMsg: res.WarnMsg,
  22206. Cainfo: res.Cainfo,
  22207. ErrMsg: res.ErrMsg,
  22208. RespondTime: res.RefmsgTime,
  22209. InfRefmsgid: res.InfRefmsgid,
  22210. OrderStatus: 1,
  22211. IsMedicineInsurance: 1,
  22212. SettleType: settle_accounts_type,
  22213. SettleStartTime: start_time,
  22214. SettleEndTime: end_time,
  22215. Creator: roles.AdminUserId,
  22216. Modify: roles.AdminUserId,
  22217. PType: 2,
  22218. Diagnosis: diagnosis_id,
  22219. }
  22220. err = service.CreateOrder(order)
  22221. if err != nil {
  22222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22223. return
  22224. }
  22225. c.ServeSuccessJSON(map[string]interface{}{
  22226. "failed_code": -10,
  22227. "msg": res2.ErrMsg,
  22228. })
  22229. return
  22230. }
  22231. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22232. 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)
  22233. var dat map[string]interface{}
  22234. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22235. fmt.Println(dat)
  22236. } else {
  22237. fmt.Println(err)
  22238. }
  22239. saveLog(result, request_log, "2204", "上传费用明细")
  22240. userJSONBytes, _ := json.Marshal(dat)
  22241. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22242. utils.ErrorLog("解析失败:%v", err)
  22243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22244. return
  22245. }
  22246. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22247. 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, "", "")
  22248. var dat map[string]interface{}
  22249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22250. fmt.Println(dat)
  22251. } else {
  22252. fmt.Println(err)
  22253. }
  22254. saveLog(result, request_log, "2204", "上传费用明细")
  22255. userJSONBytes, _ := json.Marshal(dat)
  22256. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22257. utils.ErrorLog("解析失败:%v", err)
  22258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22259. return
  22260. }
  22261. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22262. bytesData, _ := json.Marshal(data)
  22263. var req *http.Request
  22264. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22265. resp, _ := client.Do(req)
  22266. defer resp.Body.Close()
  22267. body, ioErr := ioutil.ReadAll(resp.Body)
  22268. if ioErr != nil {
  22269. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22271. return
  22272. }
  22273. var respJSON map[string]interface{}
  22274. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22275. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22277. return
  22278. }
  22279. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22280. if status == "0" {
  22281. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22282. c.ServeSuccessJSON(map[string]interface{}{
  22283. "failed_code": -10,
  22284. "msg": err_msg,
  22285. })
  22286. return
  22287. }
  22288. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22289. userJSONBytes, _ := json.Marshal(respJSON)
  22290. fmt.Println("log")
  22291. fmt.Println(string(userJSONBytes))
  22292. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22293. utils.ErrorLog("解析失败:%v", err)
  22294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22295. return
  22296. }
  22297. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22298. 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, "", "")
  22299. var dat map[string]interface{}
  22300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22301. fmt.Println(dat)
  22302. } else {
  22303. fmt.Println(err)
  22304. }
  22305. saveLog(result, request_log, "2204", "上传费用明细")
  22306. userJSONBytes, _ := json.Marshal(dat)
  22307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22308. utils.ErrorLog("解析失败:%v", err)
  22309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22310. return
  22311. }
  22312. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22313. bytesData, _ := json.Marshal(data)
  22314. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22315. resp, _ := client.Do(req)
  22316. defer resp.Body.Close()
  22317. body, ioErr := ioutil.ReadAll(resp.Body)
  22318. if ioErr != nil {
  22319. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22321. return
  22322. }
  22323. var respJSON map[string]interface{}
  22324. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22327. return
  22328. }
  22329. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22330. userJSONBytes, _ := json.Marshal(respJSON)
  22331. fmt.Println("log")
  22332. fmt.Println(string(userJSONBytes))
  22333. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22334. utils.ErrorLog("解析失败:%v", err)
  22335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22336. return
  22337. }
  22338. } else {
  22339. if miConfig.MdtrtareaAdmvs == "441202" {
  22340. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22341. if result3101.Infcode == 0 {
  22342. if len(result3101.Output.Result) > 0 {
  22343. var errMsgs []string
  22344. for _, item := range result3101.Output.Result {
  22345. errMsgs = append(errMsgs, item.VolaCont)
  22346. }
  22347. c.ServeSuccessJSON(map[string]interface{}{
  22348. "failed_code": -10,
  22349. "msg": errMsgs,
  22350. })
  22351. return
  22352. } else {
  22353. 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)
  22354. var dat map[string]interface{}
  22355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22356. fmt.Println(dat)
  22357. } else {
  22358. fmt.Println(err)
  22359. }
  22360. saveLog(result, request_log, "2204", "上传费用明细")
  22361. userJSONBytes, _ := json.Marshal(dat)
  22362. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22363. utils.ErrorLog("解析失败:%v", err)
  22364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22365. return
  22366. }
  22367. }
  22368. } else {
  22369. c.ServeSuccessJSON(map[string]interface{}{
  22370. "failed_code": -10,
  22371. "msg": result3101.ErrMsg,
  22372. })
  22373. return
  22374. }
  22375. } else {
  22376. if miConfig.Code == "H15049901371" {
  22377. 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)
  22378. var dat map[string]interface{}
  22379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22380. fmt.Println(dat)
  22381. } else {
  22382. fmt.Println(err)
  22383. }
  22384. saveLog(result, request_log, "2204", "上传费用明细")
  22385. userJSONBytes, _ := json.Marshal(dat)
  22386. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22387. utils.ErrorLog("解析失败:%v", err)
  22388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22389. return
  22390. }
  22391. res.InfRefmsgid = resFour10265.InfRefmsgid
  22392. res.Output = resFour10265.Output
  22393. res.ErrMsg = resFour10265.ErrMsg
  22394. res.Cainfo = resFour10265.Cainfo
  22395. res.WarnMsg = resFour10265.WarnMsg
  22396. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22397. res.Infcode = infocode
  22398. } else {
  22399. 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)
  22400. var dat map[string]interface{}
  22401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22402. fmt.Println(dat)
  22403. } else {
  22404. fmt.Println(err)
  22405. }
  22406. saveLog(result, request_log, "2204", "上传费用明细")
  22407. userJSONBytes, _ := json.Marshal(dat)
  22408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22409. utils.ErrorLog("解析失败:%v", err)
  22410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22411. return
  22412. }
  22413. }
  22414. }
  22415. }
  22416. var total_two float64
  22417. if res.Infcode == 0 {
  22418. order := &models.HisOrder{
  22419. UserOrgId: adminUser.CurrentOrgId,
  22420. HisPatientId: his.ID,
  22421. PatientId: his.PatientId,
  22422. SettleAccountsDate: recordDateTime,
  22423. Ctime: time.Now().Unix(),
  22424. Mtime: time.Now().Unix(),
  22425. MdtrtId: his.Number,
  22426. PsnNo: his.PsnNo,
  22427. MedType: strconv.FormatInt(reg_type, 10),
  22428. Status: 1,
  22429. Number: chrg_bchno,
  22430. Infcode: res.Infcode,
  22431. WarnMsg: res.WarnMsg,
  22432. Cainfo: res.Cainfo,
  22433. ErrMsg: res.ErrMsg,
  22434. RespondTime: res.RefmsgTime,
  22435. InfRefmsgid: res.InfRefmsgid,
  22436. OrderStatus: 1,
  22437. IsMedicineInsurance: 1,
  22438. SettleType: settle_accounts_type,
  22439. SettleStartTime: start_time,
  22440. SettleEndTime: end_time,
  22441. Creator: roles.AdminUserId,
  22442. Modify: roles.AdminUserId,
  22443. PType: 2,
  22444. Diagnosis: diagnosis_id,
  22445. }
  22446. err = service.CreateOrder(order)
  22447. if err != nil {
  22448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22449. return
  22450. }
  22451. for _, item := range res.Output.Result {
  22452. temp := strings.Split(item.FeedetlSn, "-")
  22453. var advice_id int64 = 0
  22454. var project_id int64 = 0
  22455. var types int64 = 0
  22456. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22457. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22458. if temp[1] == "1" {
  22459. advice_id = id
  22460. project_id = 0
  22461. } else if temp[1] == "2" {
  22462. advice_id = 0
  22463. project_id = id
  22464. }
  22465. total_two = total_two + item.DetItemFeeSumamt
  22466. info := &models.HisOrderInfo{
  22467. OrderNumber: order.Number,
  22468. FeedetlSn: item.FeedetlSn,
  22469. UploadDate: time.Now().Unix(),
  22470. AdviceId: advice_id,
  22471. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22472. Cnt: item.Cnt,
  22473. Pric: float64(item.Pric),
  22474. PatientId: his.PatientId,
  22475. PricUplmtAmt: item.PricUplmtAmt,
  22476. SelfpayProp: item.SelfpayProp,
  22477. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22478. OverlmtAmt: item.OverlmtAmt,
  22479. PreselfpayAmt: item.PreselfpayAmt,
  22480. BasMednFlag: item.BasMednFlag,
  22481. MedChrgitmType: item.MedChrgitmType,
  22482. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22483. Status: 1,
  22484. Memo: item.Memo,
  22485. Mtime: time.Now().Unix(),
  22486. InscpScpAmt: item.InscpScpAmt,
  22487. DrtReimFlag: item.DrtReimFlag,
  22488. Ctime: time.Now().Unix(),
  22489. ListSpItemFlag: item.ListSpItemFlag,
  22490. ChldMedcFlag: item.ChldMedcFlag,
  22491. LmtUsedFlag: item.LmtUsedFlag,
  22492. ChrgitmLv: item.ChrgitmLv,
  22493. UserOrgId: adminUser.CurrentOrgId,
  22494. HisPatientId: his.ID,
  22495. OrderId: order.ID,
  22496. ProjectId: project_id,
  22497. Type: types,
  22498. }
  22499. service.CreateOrderInfo(info)
  22500. }
  22501. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22502. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22503. var total float64
  22504. for _, item := range prescriptions {
  22505. if item.Type == 1 { //药品
  22506. for _, subItem := range item.HisDoctorAdviceInfo {
  22507. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22508. total_one := price * subItem.PrescribingNumber
  22509. fmt.Println("subItem")
  22510. fmt.Println(subItem.Price)
  22511. fmt.Println("price")
  22512. fmt.Println(price)
  22513. fmt.Println("total_one")
  22514. fmt.Println(total_one)
  22515. total = total + total_one
  22516. fmt.Println(total)
  22517. }
  22518. }
  22519. if item.Type == 2 { //项目
  22520. for _, subItem := range item.HisPrescriptionProject {
  22521. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22522. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22523. total_one := price * cnt
  22524. total = total + total_one
  22525. }
  22526. }
  22527. }
  22528. allTotal := fmt.Sprintf("%.2f", total)
  22529. if res.Infcode == 0 {
  22530. var rf []*ResultFive
  22531. json.Unmarshal([]byte(his.Iinfo), &rf)
  22532. chrg_bchno := chrg_bchno
  22533. cert_no := his.Certno
  22534. var insutypes []string
  22535. var insutype string
  22536. var is390 int = 0
  22537. var is310 int = 0
  22538. for _, item := range rf {
  22539. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22540. insutypes = append(insutypes, item.Insutype)
  22541. }
  22542. }
  22543. if len(insutypes) == 1 {
  22544. insutype = insutypes[0]
  22545. } else {
  22546. for _, i := range insutypes {
  22547. if i == "390" {
  22548. is390 = 1
  22549. }
  22550. if i == "310" {
  22551. is310 = 1
  22552. }
  22553. }
  22554. }
  22555. if is390 == 1 {
  22556. insutype = "390"
  22557. }
  22558. if is310 == 1 {
  22559. insutype = "310"
  22560. }
  22561. if len(insutypes) == 0 {
  22562. insutype = "390"
  22563. }
  22564. if len(insutypes) == 2 {
  22565. insutype = strconv.FormatInt(his.SocialType, 10)
  22566. }
  22567. //insutype = "390"
  22568. if his.IdCardType == 1 {
  22569. cert_no = his.MedicalInsuranceNumber
  22570. } else {
  22571. cert_no = his.Certno
  22572. }
  22573. var res ResultSeven
  22574. var ahres ResultSevenAH
  22575. var resSeven10265 ResultSeven10265
  22576. var resSeven10265Two ResultSeven10265Two
  22577. var gzresSeven10265Two GZResultSeven10265Two
  22578. if miConfig.MdtrtareaAdmvs == "421300" {
  22579. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22580. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22581. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22582. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22583. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22584. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22585. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22586. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22587. resp, requestErr := http.Get(api)
  22588. if requestErr != nil {
  22589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22590. return
  22591. }
  22592. body, ioErr := ioutil.ReadAll(resp.Body)
  22593. if ioErr != nil {
  22594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22596. return
  22597. }
  22598. var respJSON map[string]interface{}
  22599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22602. return
  22603. }
  22604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22605. result, _ := json.Marshal(respJSON)
  22606. fmt.Println("log")
  22607. fmt.Println(string(result))
  22608. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22609. utils.ErrorLog("解析失败:%v", err)
  22610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22611. return
  22612. }
  22613. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22614. if reg_type == 11 && his.Insutype == "390" {
  22615. reg_type = 110104
  22616. }
  22617. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22618. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22619. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22620. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22621. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22622. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22623. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22624. resp, requestErr := http.Get(api)
  22625. if requestErr != nil {
  22626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22627. return
  22628. }
  22629. body, ioErr := ioutil.ReadAll(resp.Body)
  22630. if ioErr != nil {
  22631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22633. return
  22634. }
  22635. var respJSON map[string]interface{}
  22636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22639. return
  22640. }
  22641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22642. result, _ := json.Marshal(respJSON)
  22643. fmt.Println("log")
  22644. fmt.Println(string(result))
  22645. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22646. utils.ErrorLog("解析失败:%v", err)
  22647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22648. return
  22649. }
  22650. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22651. if reg_type == 11 && his.Insutype == "390" {
  22652. reg_type = 110104
  22653. }
  22654. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22655. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22656. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22657. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22658. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22659. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22660. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22661. resp, requestErr := http.Get(api)
  22662. if requestErr != nil {
  22663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22664. return
  22665. }
  22666. body, ioErr := ioutil.ReadAll(resp.Body)
  22667. if ioErr != nil {
  22668. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22670. return
  22671. }
  22672. var respJSON map[string]interface{}
  22673. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22674. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22676. return
  22677. }
  22678. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22679. result, _ := json.Marshal(respJSON)
  22680. fmt.Println("log")
  22681. fmt.Println(string(result))
  22682. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22683. utils.ErrorLog("解析失败:%v", err)
  22684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22685. return
  22686. }
  22687. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22688. if reg_type == 11 && his.Insutype == "390" {
  22689. reg_type = 110104
  22690. }
  22691. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22692. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22693. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22694. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22695. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22696. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22697. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22698. resp, requestErr := http.Get(api)
  22699. if requestErr != nil {
  22700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22701. return
  22702. }
  22703. body, ioErr := ioutil.ReadAll(resp.Body)
  22704. if ioErr != nil {
  22705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22707. return
  22708. }
  22709. var respJSON map[string]interface{}
  22710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22713. return
  22714. }
  22715. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22716. result, _ := json.Marshal(respJSON)
  22717. fmt.Println("log")
  22718. fmt.Println(string(result))
  22719. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22720. utils.ErrorLog("解析失败:%v", err)
  22721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22722. return
  22723. }
  22724. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22725. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22726. if result3101.Infcode == "0" {
  22727. if len(result3101.Output.Result) > 0 {
  22728. var errMsgs []string
  22729. for _, item := range result3101.Output.Result {
  22730. errMsgs = append(errMsgs, item.VolaCont)
  22731. }
  22732. c.ServeSuccessJSON(map[string]interface{}{
  22733. "failed_code": -10,
  22734. "msg": errMsgs,
  22735. })
  22736. return
  22737. } else {
  22738. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22739. if his.IdCardType != 4 {
  22740. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22741. bas := strings.Split(psn_info.CardInfo, "|")
  22742. if his.IdCardType == 1 {
  22743. cert_no = bas[2]
  22744. } else {
  22745. cert_no = bas[1]
  22746. }
  22747. } else {
  22748. cert_no = his.Certno
  22749. }
  22750. //江苏地区国家医保医疗类别
  22751. //职工透析:医疗类别选特殊情况门诊9933
  22752. //居民血透门慢: 医疗类别选门诊慢病1402
  22753. //var med_type string
  22754. //if his.Insutype == "310" {
  22755. // if reg_type == 14 {
  22756. // med_type = "9933"
  22757. // } else if reg_type == 11 {
  22758. // med_type = "11"
  22759. //
  22760. // }
  22761. //} else if his.Insutype == "390" {
  22762. // if reg_type == 14 {
  22763. // med_type = "1402"
  22764. // } else if reg_type == 11 {
  22765. // med_type = "11"
  22766. // }
  22767. //}
  22768. var api string
  22769. if miConfig.MdtrtareaAdmvs == "320921" {
  22770. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22771. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22772. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22773. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22774. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22775. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22776. "&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
  22777. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22778. } else {
  22779. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22780. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22781. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22782. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22784. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22785. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22786. "&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
  22787. }
  22788. resp, requestErr := http.Get(api)
  22789. if requestErr != nil {
  22790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22791. return
  22792. }
  22793. body, ioErr := ioutil.ReadAll(resp.Body)
  22794. if ioErr != nil {
  22795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22797. return
  22798. }
  22799. var respJSON map[string]interface{}
  22800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22803. return
  22804. }
  22805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22806. result, _ := json.Marshal(respJSON)
  22807. fmt.Println("log")
  22808. fmt.Println(string(result))
  22809. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22810. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22811. utils.ErrorLog("解析失败:%v", err)
  22812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22813. return
  22814. }
  22815. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22816. res.Output = resSeven10265.Output
  22817. res.ErrMsg = resSeven10265.ErrMsg
  22818. res.Cainfo = resSeven10265.Cainfo
  22819. res.WarnMsg = resSeven10265.WarnMsg
  22820. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22821. res.Infcode = infocode
  22822. } else {
  22823. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22824. utils.ErrorLog("解析失败:%v", err)
  22825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22826. return
  22827. }
  22828. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22829. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22830. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22831. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22832. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22833. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22834. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22835. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22836. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22837. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22838. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22839. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22840. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22841. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22842. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22843. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22844. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22845. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22846. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22847. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22848. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22849. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22850. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22851. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22852. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22853. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22854. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22855. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22856. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22857. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22858. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22859. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22860. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22861. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22862. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22863. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22864. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22865. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22866. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22867. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22868. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22869. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22870. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22871. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22872. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22873. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22874. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22875. res.ErrMsg = resSeven10265Two.ErrMsg
  22876. res.Cainfo = resSeven10265Two.Cainfo
  22877. res.WarnMsg = resSeven10265Two.WarnMsg
  22878. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22879. res.Infcode = infocode
  22880. }
  22881. }
  22882. }
  22883. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22884. psn_info, _ := service.GetPsnByPatientId(id)
  22885. var verify_number string
  22886. if psn_info.IdCardType == 4 {
  22887. verify_number = psn_info.VerifyNumber
  22888. } else if psn_info.IdCardType == 1 {
  22889. bas := strings.Split(psn_info.CardInfo, "|")
  22890. cardNumber := bas[2]
  22891. verify_number = cardNumber
  22892. } else {
  22893. psn_info.IdCardType = 2
  22894. verify_number = psn_info.Certno
  22895. }
  22896. var api string
  22897. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22898. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22899. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22901. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22902. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22903. "&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
  22904. resp, requestErr := http.Get(api)
  22905. if requestErr != nil {
  22906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22907. return
  22908. }
  22909. body, ioErr := ioutil.ReadAll(resp.Body)
  22910. if ioErr != nil {
  22911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22913. return
  22914. }
  22915. var respJSON map[string]interface{}
  22916. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22917. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22919. return
  22920. }
  22921. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22922. result, _ := json.Marshal(respJSON)
  22923. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22924. utils.ErrorLog("解析失败:%v", err)
  22925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22926. return
  22927. }
  22928. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22929. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22930. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22931. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22932. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22933. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22934. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22935. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22936. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22937. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22938. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22939. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22940. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22941. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22942. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22943. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22944. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22945. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22946. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22947. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22948. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22949. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22950. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22951. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22952. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22953. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22954. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22955. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22956. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22957. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22958. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22959. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22960. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22961. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22962. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22963. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22964. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22965. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22966. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22967. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22968. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22969. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22970. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22971. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22972. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22973. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22974. res.ErrMsg = resSeven10265.ErrMsg
  22975. res.Cainfo = resSeven10265.Cainfo
  22976. res.WarnMsg = resSeven10265.WarnMsg
  22977. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22978. res.Infcode = infocode
  22979. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22980. acct_used_flag := "1"
  22981. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22982. var result string
  22983. var request_log string
  22984. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22985. 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)
  22986. } else {
  22987. 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)
  22988. }
  22989. var dat map[string]interface{}
  22990. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22991. fmt.Println(dat)
  22992. } else {
  22993. fmt.Println(err)
  22994. }
  22995. saveLog(result, request_log, "2206", "预结算")
  22996. userJSONBytes, _ := json.Marshal(dat)
  22997. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22998. utils.ErrorLog("解析失败:%v", err)
  22999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23000. return
  23001. }
  23002. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23003. var result string
  23004. var request_log string
  23005. if his.IdCardType == 2 {
  23006. 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, "")
  23007. } else if his.IdCardType == 1 {
  23008. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23009. bas := strings.Split(psn_info.CardInfo, "|")
  23010. basNumber := bas[2]
  23011. card_sn := bas[3]
  23012. var rf []*ResultFive
  23013. json.Unmarshal([]byte(his.Iinfo), &rf)
  23014. var psn_type string
  23015. for _, item := range rf {
  23016. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  23017. psn_type = item.PsnType
  23018. }
  23019. }
  23020. 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)
  23021. } else {
  23022. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23023. 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, "")
  23024. }
  23025. var dat map[string]interface{}
  23026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23027. fmt.Println(dat)
  23028. } else {
  23029. fmt.Println(err)
  23030. }
  23031. saveLog(result, request_log, "2206", "预结算")
  23032. userJSONBytes, _ := json.Marshal(dat)
  23033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23034. utils.ErrorLog("解析失败:%v", err)
  23035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23036. return
  23037. }
  23038. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23039. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23040. if his.IdCardType == 4 {
  23041. psn_info.VerifyNumber = psn_info.VerifyNumber
  23042. cert_no = psn_info.Certno
  23043. } else if his.IdCardType == 2 {
  23044. cert_no = psn_info.Certno
  23045. psn_info.VerifyNumber = psn_info.Certno
  23046. } else {
  23047. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  23048. bas := strings.Split(psn_info.CardInfo, "|")
  23049. if his.IdCardType == 1 {
  23050. cert_no = bas[2]
  23051. } else {
  23052. cert_no = bas[1]
  23053. }
  23054. }
  23055. var api string
  23056. var med_type string
  23057. if his.Insutype == "390" {
  23058. if reg_type == 992102 {
  23059. med_type = "992102"
  23060. }
  23061. if reg_type == 140104 {
  23062. med_type = "140104"
  23063. }
  23064. if reg_type == 14 {
  23065. med_type = "140104"
  23066. }
  23067. } else if his.Insutype == "310" {
  23068. if reg_type == 992102 {
  23069. med_type = "992102"
  23070. }
  23071. if reg_type == 14 {
  23072. med_type = "14"
  23073. }
  23074. }
  23075. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23076. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23077. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23078. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23079. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23080. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23081. "&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
  23082. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23083. resp, requestErr := http.Get(api)
  23084. if requestErr != nil {
  23085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23086. return
  23087. }
  23088. body, ioErr := ioutil.ReadAll(resp.Body)
  23089. if ioErr != nil {
  23090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23092. return
  23093. }
  23094. var respJSON map[string]interface{}
  23095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23098. return
  23099. }
  23100. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23101. if status == "0" {
  23102. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23103. c.ServeSuccessJSON(map[string]interface{}{
  23104. "failed_code": -10,
  23105. "msg": err_msg,
  23106. })
  23107. return
  23108. }
  23109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23110. result, _ := json.Marshal(respJSON)
  23111. fmt.Println("log")
  23112. fmt.Println(string(result))
  23113. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23114. utils.ErrorLog("解析失败:%v", err)
  23115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23116. return
  23117. }
  23118. res.InfRefmsgid = ahres.InfRefmsgid
  23119. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23120. // 创建对应的Time类型
  23121. t := time.UnixMilli(timestamp)
  23122. // 格式化成指定的日期字符串
  23123. str := t.Format("2006-01-02 15:04:05")
  23124. res.Output.Setlinfo.SetlTime = str
  23125. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23126. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23127. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23128. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23129. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23130. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23131. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23132. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23133. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23134. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23135. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23136. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23137. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23138. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23139. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23140. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23141. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23142. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23143. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23144. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23145. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23146. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23147. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23148. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23149. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23150. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23151. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23152. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23153. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23154. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23155. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23156. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23157. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23158. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23159. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23160. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23161. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23162. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23163. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23164. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23165. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23166. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23167. //res.Output.Setldetail = ahres.Output.Setldetail
  23168. res.ErrMsg = ahres.ErrMsg
  23169. res.Cainfo = ahres.Cainfo
  23170. res.WarnMsg = ahres.WarnMsg
  23171. res.Infcode = ahres.Infcode
  23172. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23173. var result string
  23174. var request_log string
  23175. if his.IdCardType == 2 {
  23176. 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")
  23177. } else if his.IdCardType == 1 {
  23178. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23179. bas := strings.Split(psn_info.CardInfo, "|")
  23180. basNumber := bas[2]
  23181. card_sn := bas[3]
  23182. 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")
  23183. } else {
  23184. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23185. 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")
  23186. }
  23187. var dat map[string]interface{}
  23188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23189. fmt.Println(dat)
  23190. } else {
  23191. fmt.Println(err)
  23192. }
  23193. saveLog(result, request_log, "2206", "预结算")
  23194. userJSONBytes, _ := json.Marshal(dat)
  23195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23196. utils.ErrorLog("解析失败:%v", err)
  23197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23198. return
  23199. }
  23200. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23201. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23202. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23203. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23205. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23206. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23207. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23208. resp, requestErr := http.Get(api)
  23209. if requestErr != nil {
  23210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23211. return
  23212. }
  23213. body, ioErr := ioutil.ReadAll(resp.Body)
  23214. if ioErr != nil {
  23215. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23217. return
  23218. }
  23219. var respJSON map[string]interface{}
  23220. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23221. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23223. return
  23224. }
  23225. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23226. result, _ := json.Marshal(respJSON)
  23227. fmt.Println("log")
  23228. fmt.Println(string(result))
  23229. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23230. utils.ErrorLog("解析失败:%v", err)
  23231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23232. return
  23233. }
  23234. } else {
  23235. if miConfig.MdtrtareaAdmvs == "441202" {
  23236. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23237. if result3101.Infcode == 0 {
  23238. if len(result3101.Output.Result) > 0 {
  23239. var errMsgs []string
  23240. for _, item := range result3101.Output.Result {
  23241. errMsgs = append(errMsgs, item.VolaCont)
  23242. }
  23243. c.ServeSuccessJSON(map[string]interface{}{
  23244. "failed_code": -10,
  23245. "msg": errMsgs,
  23246. })
  23247. return
  23248. } else {
  23249. var result string
  23250. var request_log string
  23251. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23252. allTotal = fmt.Sprintf("%.2f", total_two)
  23253. if his.IdCardType == 4 {
  23254. 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)
  23255. } else {
  23256. 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)
  23257. }
  23258. var dat map[string]interface{}
  23259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23260. fmt.Println(dat)
  23261. } else {
  23262. fmt.Println(err)
  23263. }
  23264. saveLog(result, request_log, "2206", "预结算")
  23265. //userJSONBytes, _ := json.Marshal(dat)
  23266. //
  23267. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23268. // utils.ErrorLog("解析失败:%v", err)
  23269. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23270. // return
  23271. //}
  23272. userJSONBytes, _ := json.Marshal(dat)
  23273. if miConfig.Code == "H15049901371" {
  23274. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23275. utils.ErrorLog("解析失败:%v", err)
  23276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23277. return
  23278. }
  23279. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23280. res.Output = resSeven10265.Output
  23281. res.ErrMsg = resSeven10265.ErrMsg
  23282. res.Cainfo = resSeven10265.Cainfo
  23283. res.WarnMsg = resSeven10265.WarnMsg
  23284. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23285. res.Infcode = infocode
  23286. } else {
  23287. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23288. utils.ErrorLog("解析失败:%v", err)
  23289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23290. return
  23291. }
  23292. }
  23293. }
  23294. } else {
  23295. c.ServeSuccessJSON(map[string]interface{}{
  23296. "failed_code": -10,
  23297. "msg": result3101.ErrMsg,
  23298. })
  23299. return
  23300. }
  23301. } else {
  23302. var result string
  23303. var request_log string
  23304. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23305. allTotal = fmt.Sprintf("%.2f", total_two)
  23306. if his.IdCardType == 4 {
  23307. 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)
  23308. } else {
  23309. 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)
  23310. }
  23311. var dat map[string]interface{}
  23312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23313. fmt.Println(dat)
  23314. } else {
  23315. fmt.Println(err)
  23316. }
  23317. saveLog(result, request_log, "2206", "预结算")
  23318. //userJSONBytes, _ := json.Marshal(dat)
  23319. //
  23320. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23321. // utils.ErrorLog("解析失败:%v", err)
  23322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23323. // return
  23324. //}
  23325. userJSONBytes, _ := json.Marshal(dat)
  23326. if miConfig.Code == "H15049901371" {
  23327. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23328. utils.ErrorLog("解析失败:%v", err)
  23329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23330. return
  23331. }
  23332. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23333. res.Output = resSeven10265.Output
  23334. res.ErrMsg = resSeven10265.ErrMsg
  23335. res.Cainfo = resSeven10265.Cainfo
  23336. res.WarnMsg = resSeven10265.WarnMsg
  23337. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23338. res.Infcode = infocode
  23339. } else {
  23340. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23341. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23342. utils.ErrorLog("解析失败:%v", err)
  23343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23344. return
  23345. }
  23346. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23347. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23348. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23349. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23350. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23351. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23352. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23353. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23354. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23355. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23356. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23357. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23358. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23359. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23360. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23361. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23362. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23363. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23364. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23365. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23366. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23367. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23368. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23369. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23370. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23371. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23372. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23373. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23374. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23375. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23376. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23377. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23378. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23379. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23380. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23381. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23382. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23383. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23384. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23385. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23386. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23387. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23388. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23389. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23390. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23391. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23392. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23393. res.Cainfo = gzresSeven10265Two.Cainfo
  23394. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23395. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23396. //res.Infcode = infocode
  23397. } else {
  23398. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23399. utils.ErrorLog("解析失败:%v", err)
  23400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23401. return
  23402. }
  23403. }
  23404. }
  23405. }
  23406. }
  23407. utils.ErrorLog("解析失败:%v", res.Infcode)
  23408. if res.Infcode == -1 {
  23409. errlog := &models.HisOrderError{
  23410. UserOrgId: adminUser.CurrentOrgId,
  23411. Ctime: time.Now().Unix(),
  23412. Mtime: time.Now().Unix(),
  23413. Number: chrg_bchno,
  23414. ErrMsg: res.ErrMsg,
  23415. Status: 1,
  23416. PatientId: id,
  23417. RecordTime: recordDateTime,
  23418. Stage: 20,
  23419. }
  23420. service.CreateErrMsgLog(errlog)
  23421. c.ServeSuccessJSON(map[string]interface{}{
  23422. "failed_code": -10,
  23423. "msg": res.ErrMsg,
  23424. })
  23425. return
  23426. }
  23427. if res.Infcode != 0 {
  23428. errlog := &models.HisOrderError{
  23429. UserOrgId: adminUser.CurrentOrgId,
  23430. Ctime: time.Now().Unix(),
  23431. Mtime: time.Now().Unix(),
  23432. Number: chrg_bchno,
  23433. ErrMsg: res.ErrMsg,
  23434. Status: 1,
  23435. PatientId: id,
  23436. RecordTime: recordDateTime,
  23437. Stage: 20,
  23438. }
  23439. service.CreateErrMsgLog(errlog)
  23440. c.ServeSuccessJSON(map[string]interface{}{
  23441. "failed_code": -10,
  23442. "msg": res.ErrMsg,
  23443. })
  23444. return
  23445. } else {
  23446. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23447. order.OrderStatus = 1
  23448. order.IsPre = 1
  23449. order.Status = 1
  23450. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23451. order.SetlId = res.Output.Setlinfo.SetlID
  23452. order.PsnNo = res.Output.Setlinfo.PsnNo
  23453. order.PsnName = res.Output.Setlinfo.PsnName
  23454. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23455. order.Certno = res.Output.Setlinfo.Certno
  23456. order.Gend = res.Output.Setlinfo.Gend
  23457. order.Naty = res.Output.Setlinfo.Naty
  23458. order.Age = res.Output.Setlinfo.Age
  23459. order.Insutype = res.Output.Setlinfo.Insutype
  23460. order.PsnType = res.Output.Setlinfo.PsnType
  23461. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23462. order.SetlTime = res.Output.Setlinfo.SetlTime
  23463. order.AcctUsedFlag = acct_used_flag
  23464. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23465. if res.Output.Setlinfo.MedType == "140101" {
  23466. order.MedType = "14"
  23467. } else {
  23468. if res.Output.Setlinfo.MedType == "110104" {
  23469. order.MedType = "11"
  23470. } else {
  23471. order.MedType = res.Output.Setlinfo.MedType
  23472. }
  23473. }
  23474. if res.Output.Setlinfo.MedType == "992102" {
  23475. order.MedType = "992102"
  23476. }
  23477. if res.Output.Setlinfo.MedType == "140104" {
  23478. order.MedType = "140104"
  23479. }
  23480. if res.Output.Setlinfo.MedType == "14" {
  23481. order.MedType = "14"
  23482. }
  23483. if reg_type == 1112 {
  23484. order.MedType = "1112"
  23485. }
  23486. if reg_type == 1111 {
  23487. order.MedType = "1111"
  23488. }
  23489. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23490. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23491. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23492. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23493. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23494. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23495. order.HifpPay = res.Output.Setlinfo.HifpPay
  23496. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23497. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23498. order.HifesPay = res.Output.Setlinfo.HifesPay
  23499. order.HifobPay = res.Output.Setlinfo.HifobPay
  23500. order.MafPay = res.Output.Setlinfo.MafPay
  23501. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23502. order.OthPay = res.Output.Setlinfo.OthPay
  23503. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23504. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23505. order.AcctPay = res.Output.Setlinfo.AcctPay
  23506. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23507. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23508. order.Balc = res.Output.Setlinfo.Balc
  23509. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23510. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23511. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23512. order.ClrWay = res.Output.Setlinfo.ClrWay
  23513. order.Creator = order.Creator
  23514. order.Modify = roles.AdminUserId
  23515. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23516. //detailStr := string(setlDetail)
  23517. //order.SetlDetail = detailStr
  23518. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23519. err = service.UpDateOrder(order)
  23520. if err == nil {
  23521. c.ServeSuccessJSON(map[string]interface{}{
  23522. "msg": "预结算成功",
  23523. })
  23524. } else {
  23525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23526. return
  23527. }
  23528. }
  23529. } else {
  23530. adminUser := c.GetAdminUserInfo()
  23531. errlog := &models.HisOrderError{
  23532. UserOrgId: adminUser.CurrentOrgId,
  23533. Ctime: time.Now().Unix(),
  23534. Mtime: time.Now().Unix(),
  23535. ErrMsg: res.ErrMsg,
  23536. Status: 1,
  23537. PatientId: id,
  23538. RecordTime: recordDateTime,
  23539. Stage: 4,
  23540. }
  23541. service.CreateErrMsgLog(errlog)
  23542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23543. return
  23544. }
  23545. } else {
  23546. if miConfig.MdtrtareaAdmvs == "150499" {
  23547. order := &models.HisOrder{
  23548. UserOrgId: adminUser.CurrentOrgId,
  23549. HisPatientId: his.ID,
  23550. PatientId: his.PatientId,
  23551. SettleAccountsDate: recordDateTime,
  23552. Ctime: time.Now().Unix(),
  23553. Mtime: time.Now().Unix(),
  23554. MdtrtId: his.Number,
  23555. PsnNo: his.PsnNo,
  23556. MedType: strconv.FormatInt(reg_type, 10),
  23557. Status: 1,
  23558. Number: chrg_bchno,
  23559. Infcode: res.Infcode,
  23560. WarnMsg: res.WarnMsg,
  23561. Cainfo: res.Cainfo,
  23562. ErrMsg: res.ErrMsg,
  23563. RespondTime: res.RefmsgTime,
  23564. InfRefmsgid: res.InfRefmsgid,
  23565. OrderStatus: 1,
  23566. IsMedicineInsurance: 1,
  23567. SettleType: settle_accounts_type,
  23568. SettleStartTime: start_time,
  23569. SettleEndTime: end_time,
  23570. Creator: roles.AdminUserId,
  23571. Modify: roles.AdminUserId,
  23572. PType: 2,
  23573. Diagnosis: diagnosis_id,
  23574. }
  23575. err = service.CreateOrder(order)
  23576. if err != nil {
  23577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23578. return
  23579. }
  23580. }
  23581. adminUser := c.GetAdminUserInfo()
  23582. errlog := &models.HisOrderError{
  23583. UserOrgId: adminUser.CurrentOrgId,
  23584. Ctime: time.Now().Unix(),
  23585. Mtime: time.Now().Unix(),
  23586. ErrMsg: res.ErrMsg,
  23587. Status: 1,
  23588. PatientId: id,
  23589. RecordTime: recordDateTime,
  23590. Stage: 4,
  23591. }
  23592. service.CreateErrMsgLog(errlog)
  23593. c.ServeSuccessJSON(map[string]interface{}{
  23594. "failed_code": -10,
  23595. "msg": res.ErrMsg,
  23596. })
  23597. return
  23598. }
  23599. }
  23600. }
  23601. }
  23602. // 退款
  23603. func (c *HisApiController) Refund() {
  23604. order_id, _ := c.GetInt64("order_id")
  23605. admin_user_id, _ := c.GetInt64("admin_user_id")
  23606. adminUser := c.GetAdminUserInfo()
  23607. var order models.HisOrder
  23608. order, _ = service.GetHisOrderByID(order_id)
  23609. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23610. if order.ID == 0 {
  23611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23612. return
  23613. }
  23614. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23615. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23616. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23617. if config.IsOpen == 1 { //对接了医保,走医保流程
  23618. var res ResultSixteen
  23619. var ahres ResultSevenAH
  23620. var resSixteen10265 ResultSixteen10265
  23621. var resSixteen10265Two ResultSixteen10265Two
  23622. var gz ResultgzSixteen10265Two
  23623. var src_resquest string
  23624. var result string
  23625. if miConfig.MdtrtareaAdmvs == "421300" {
  23626. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23627. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23628. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23629. resp3, requestErr3 := http.Get(api3)
  23630. if requestErr3 != nil {
  23631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23632. return
  23633. }
  23634. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23635. if ioErr3 != nil {
  23636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23638. return
  23639. }
  23640. var respJSON3 map[string]interface{}
  23641. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23644. return
  23645. }
  23646. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23647. userJSONBytes3, _ := json.Marshal(respJSON3)
  23648. fmt.Println("log")
  23649. fmt.Println(string(userJSONBytes3))
  23650. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23651. utils.ErrorLog("解析失败:%v", err)
  23652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23653. return
  23654. }
  23655. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23656. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23657. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23658. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23659. resp3, requestErr3 := http.Get(api3)
  23660. if requestErr3 != nil {
  23661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23662. return
  23663. }
  23664. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23665. if ioErr3 != nil {
  23666. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23668. return
  23669. }
  23670. var respJSON3 map[string]interface{}
  23671. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23672. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23674. return
  23675. }
  23676. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23677. userJSONBytes3, _ := json.Marshal(respJSON3)
  23678. fmt.Println("log")
  23679. fmt.Println(string(userJSONBytes3))
  23680. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23681. utils.ErrorLog("解析失败:%v", err)
  23682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23683. return
  23684. }
  23685. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23686. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23687. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23688. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23689. resp3, requestErr3 := http.Get(api3)
  23690. if requestErr3 != nil {
  23691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23692. return
  23693. }
  23694. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23695. if ioErr3 != nil {
  23696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23698. return
  23699. }
  23700. var respJSON3 map[string]interface{}
  23701. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23704. return
  23705. }
  23706. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23707. userJSONBytes3, _ := json.Marshal(respJSON3)
  23708. fmt.Println("log")
  23709. fmt.Println(string(userJSONBytes3))
  23710. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23711. utils.ErrorLog("解析失败:%v", err)
  23712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23713. return
  23714. }
  23715. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23716. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23717. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23719. resp3, requestErr3 := http.Get(api3)
  23720. if requestErr3 != nil {
  23721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23722. return
  23723. }
  23724. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23725. if ioErr3 != nil {
  23726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23728. return
  23729. }
  23730. var respJSON3 map[string]interface{}
  23731. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23734. return
  23735. }
  23736. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23737. userJSONBytes3, _ := json.Marshal(respJSON3)
  23738. fmt.Println("log")
  23739. fmt.Println(string(userJSONBytes3))
  23740. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23741. utils.ErrorLog("解析失败:%v", err)
  23742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23743. return
  23744. }
  23745. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23746. var api3 string
  23747. if miConfig.MdtrtareaAdmvs == "320921" {
  23748. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23749. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23750. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23751. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23752. } else {
  23753. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23754. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23755. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23757. }
  23758. resp3, requestErr3 := http.Get(api3)
  23759. if requestErr3 != nil {
  23760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23761. return
  23762. }
  23763. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23764. if ioErr3 != nil {
  23765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23767. return
  23768. }
  23769. var respJSON3 map[string]interface{}
  23770. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23773. return
  23774. }
  23775. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23776. userJSONBytes3, _ := json.Marshal(respJSON3)
  23777. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23778. utils.ErrorLog("解析失败:%v", err)
  23779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23780. return
  23781. }
  23782. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23783. res.Output = resSixteen10265.Output
  23784. res.ErrMsg = resSixteen10265.ErrMsg
  23785. res.Cainfo = resSixteen10265.Cainfo
  23786. res.WarnMsg = resSixteen10265.WarnMsg
  23787. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23788. res.Infcode = infocode
  23789. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23790. var api3 string
  23791. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23792. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23793. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23794. resp3, requestErr3 := http.Get(api3)
  23795. if requestErr3 != nil {
  23796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23797. return
  23798. }
  23799. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23800. if ioErr3 != nil {
  23801. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23803. return
  23804. }
  23805. var respJSON3 map[string]interface{}
  23806. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23807. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23809. return
  23810. }
  23811. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23812. userJSONBytes3, _ := json.Marshal(respJSON3)
  23813. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23814. utils.ErrorLog("解析失败:%v", err)
  23815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23816. return
  23817. }
  23818. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23819. res.Output = resSixteen10265.Output
  23820. res.ErrMsg = resSixteen10265.ErrMsg
  23821. res.Cainfo = resSixteen10265.Cainfo
  23822. res.WarnMsg = resSixteen10265.WarnMsg
  23823. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23824. res.Infcode = infocode
  23825. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23826. 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)
  23827. var dat map[string]interface{}
  23828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23829. fmt.Println(dat)
  23830. } else {
  23831. fmt.Println(err)
  23832. }
  23833. saveLog(result, src_resquest, "2208", "退费")
  23834. userJSONBytes, _ := json.Marshal(dat)
  23835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23836. utils.ErrorLog("解析失败:%v", err)
  23837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23838. return
  23839. }
  23840. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23841. 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, "")
  23842. var dat map[string]interface{}
  23843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23844. fmt.Println(dat)
  23845. } else {
  23846. fmt.Println(err)
  23847. }
  23848. saveLog(result, src_resquest, "2208", "退费")
  23849. userJSONBytes, _ := json.Marshal(dat)
  23850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23851. utils.ErrorLog("解析失败:%v", err)
  23852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23853. return
  23854. }
  23855. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23856. var api3 string
  23857. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23858. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23859. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23860. resp3, requestErr3 := http.Get(api3)
  23861. if requestErr3 != nil {
  23862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23863. return
  23864. }
  23865. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23866. if ioErr3 != nil {
  23867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23869. return
  23870. }
  23871. var respJSON3 map[string]interface{}
  23872. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23875. return
  23876. }
  23877. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23878. if status == "0" {
  23879. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23880. c.ServeSuccessJSON(map[string]interface{}{
  23881. "failed_code": -10,
  23882. "msg": err_msg,
  23883. })
  23884. return
  23885. }
  23886. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23887. userJSONBytes3, _ := json.Marshal(respJSON3)
  23888. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23889. // utils.ErrorLog("解析失败:%v", err)
  23890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23891. // return
  23892. //}
  23893. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23894. utils.ErrorLog("解析失败:%v", err)
  23895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23896. return
  23897. }
  23898. res.InfRefmsgid = ahres.InfRefmsgid
  23899. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23900. // 创建对应的Time类型
  23901. t := time.UnixMilli(timestamp)
  23902. // 格式化成指定的日期字符串
  23903. str := t.Format("2006-01-02 15:04:05")
  23904. res.Output.Setlinfo.SetlTime = str
  23905. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23906. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23907. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23908. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23909. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23910. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23911. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23912. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23913. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23914. //
  23915. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23916. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23917. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23918. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23919. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23920. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23921. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23922. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23923. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23924. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23925. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23926. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23927. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23928. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23929. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23930. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23931. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23932. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23933. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23934. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23935. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23936. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23937. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23938. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23939. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23940. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23941. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23942. //res.Output.Setldetail = ahres.Output.Setldetail
  23943. res.ErrMsg = ahres.ErrMsg
  23944. res.Cainfo = ahres.Cainfo
  23945. res.WarnMsg = ahres.WarnMsg
  23946. res.Infcode = ahres.Infcode
  23947. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23948. 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, "")
  23949. var dat map[string]interface{}
  23950. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23951. fmt.Println(dat)
  23952. } else {
  23953. fmt.Println(err)
  23954. }
  23955. saveLog(result, src_resquest, "2208", "退费")
  23956. userJSONBytes, _ := json.Marshal(dat)
  23957. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23958. utils.ErrorLog("解析失败:%v", err)
  23959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23960. return
  23961. }
  23962. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23963. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23964. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23965. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23966. resp3, requestErr3 := http.Get(api3)
  23967. if requestErr3 != nil {
  23968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23969. return
  23970. }
  23971. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23972. if ioErr3 != nil {
  23973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23975. return
  23976. }
  23977. var respJSON3 map[string]interface{}
  23978. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23981. return
  23982. }
  23983. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23984. userJSONBytes3, _ := json.Marshal(respJSON3)
  23985. fmt.Println("log")
  23986. fmt.Println(string(userJSONBytes3))
  23987. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23988. utils.ErrorLog("解析失败:%v", err)
  23989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23990. return
  23991. }
  23992. } else {
  23993. if miConfig.Code == "H15049901371" {
  23994. 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)
  23995. var dat map[string]interface{}
  23996. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23997. fmt.Println(dat)
  23998. } else {
  23999. fmt.Println(err)
  24000. }
  24001. saveLog(result, src_resquest, "2208", "退费")
  24002. userJSONBytes, _ := json.Marshal(dat)
  24003. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  24004. utils.ErrorLog("解析失败:%v", err)
  24005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24006. return
  24007. }
  24008. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  24009. res.Output = resSixteen10265.Output
  24010. res.ErrMsg = resSixteen10265.ErrMsg
  24011. res.Cainfo = resSixteen10265.Cainfo
  24012. res.WarnMsg = resSixteen10265.WarnMsg
  24013. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  24014. res.Infcode = infocode
  24015. } else {
  24016. 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)
  24017. var dat map[string]interface{}
  24018. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24019. fmt.Println(dat)
  24020. } else {
  24021. fmt.Println(err)
  24022. }
  24023. saveLog(result, src_resquest, "2208", "退费")
  24024. userJSONBytes, _ := json.Marshal(dat)
  24025. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24026. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  24027. utils.ErrorLog("解析失败:%v", err)
  24028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24029. return
  24030. }
  24031. res.Infcode = gz.Infcode
  24032. } else {
  24033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24034. utils.ErrorLog("解析失败:%v", err)
  24035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24036. return
  24037. }
  24038. }
  24039. }
  24040. }
  24041. if res.Infcode == 0 {
  24042. var res2 ResultSix
  24043. var resSix10265 ResultSix10265
  24044. if miConfig.MdtrtareaAdmvs == "421300" {
  24045. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24046. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24047. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24048. resp3, requestErr3 := http.Get(api3)
  24049. if requestErr3 != nil {
  24050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24051. return
  24052. }
  24053. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24054. if ioErr3 != nil {
  24055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24057. return
  24058. }
  24059. var respJSON3 map[string]interface{}
  24060. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24063. return
  24064. }
  24065. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24066. userJSONBytes3, _ := json.Marshal(respJSON3)
  24067. fmt.Println("log")
  24068. fmt.Println(string(userJSONBytes3))
  24069. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24070. utils.ErrorLog("解析失败:%v", err)
  24071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24072. return
  24073. }
  24074. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24075. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24076. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24077. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24078. resp3, requestErr3 := http.Get(api3)
  24079. if requestErr3 != nil {
  24080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24081. return
  24082. }
  24083. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24084. if ioErr3 != nil {
  24085. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24087. return
  24088. }
  24089. var respJSON3 map[string]interface{}
  24090. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24096. userJSONBytes3, _ := json.Marshal(respJSON3)
  24097. fmt.Println("log")
  24098. fmt.Println(string(userJSONBytes3))
  24099. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24100. utils.ErrorLog("解析失败:%v", err)
  24101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24102. return
  24103. }
  24104. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24105. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24106. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24107. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24108. resp3, requestErr3 := http.Get(api3)
  24109. if requestErr3 != nil {
  24110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24111. return
  24112. }
  24113. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24114. if ioErr3 != nil {
  24115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24117. return
  24118. }
  24119. var respJSON3 map[string]interface{}
  24120. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24123. return
  24124. }
  24125. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24126. userJSONBytes3, _ := json.Marshal(respJSON3)
  24127. fmt.Println("log")
  24128. fmt.Println(string(userJSONBytes3))
  24129. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24130. utils.ErrorLog("解析失败:%v", err)
  24131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24132. return
  24133. }
  24134. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24135. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24136. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24137. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24138. resp3, requestErr3 := http.Get(api3)
  24139. if requestErr3 != nil {
  24140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24141. return
  24142. }
  24143. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24144. if ioErr3 != nil {
  24145. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24147. return
  24148. }
  24149. var respJSON3 map[string]interface{}
  24150. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24151. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24153. return
  24154. }
  24155. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24156. userJSONBytes3, _ := json.Marshal(respJSON3)
  24157. fmt.Println("log")
  24158. fmt.Println(string(userJSONBytes3))
  24159. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24160. utils.ErrorLog("解析失败:%v", err)
  24161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24162. return
  24163. }
  24164. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24165. var api3 string
  24166. if miConfig.MdtrtareaAdmvs == "320921" {
  24167. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24168. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24169. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24170. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24171. } else {
  24172. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24173. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24174. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24175. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24176. }
  24177. resp3, requestErr3 := http.Get(api3)
  24178. if requestErr3 != nil {
  24179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24180. return
  24181. }
  24182. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24183. if ioErr3 != nil {
  24184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24186. return
  24187. }
  24188. var respJSON3 map[string]interface{}
  24189. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24192. return
  24193. }
  24194. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24195. userJSONBytes3, _ := json.Marshal(respJSON3)
  24196. fmt.Println("log")
  24197. fmt.Println(string(userJSONBytes3))
  24198. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24199. utils.ErrorLog("解析失败:%v", err)
  24200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24201. return
  24202. }
  24203. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24204. res2.Output = resSix10265.Output
  24205. res2.ErrMsg = resSix10265.ErrMsg
  24206. res2.Cainfo = resSix10265.Cainfo
  24207. res2.WarnMsg = resSix10265.WarnMsg
  24208. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24209. res2.Infcode = infocode
  24210. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24211. var api3 string
  24212. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24213. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&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. resp3, requestErr3 := http.Get(api3)
  24216. if requestErr3 != nil {
  24217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24218. return
  24219. }
  24220. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24221. if ioErr3 != nil {
  24222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24224. return
  24225. }
  24226. var respJSON3 map[string]interface{}
  24227. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24230. return
  24231. }
  24232. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24233. userJSONBytes3, _ := json.Marshal(respJSON3)
  24234. fmt.Println("log")
  24235. fmt.Println(string(userJSONBytes3))
  24236. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24237. utils.ErrorLog("解析失败:%v", err)
  24238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24239. return
  24240. }
  24241. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24242. res2.Output = resSix10265.Output
  24243. res2.ErrMsg = resSix10265.ErrMsg
  24244. res2.Cainfo = resSix10265.Cainfo
  24245. res2.WarnMsg = resSix10265.WarnMsg
  24246. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24247. res2.Infcode = infocode
  24248. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24249. 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)
  24250. var dat map[string]interface{}
  24251. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24252. fmt.Println(dat)
  24253. } else {
  24254. fmt.Println(err)
  24255. }
  24256. saveLog(result2, src_request, "2205", "撤销明细")
  24257. userJSONBytes, _ := json.Marshal(dat)
  24258. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24259. utils.ErrorLog("解析失败:%v", err)
  24260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24261. return
  24262. }
  24263. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24264. 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, "")
  24265. var dat map[string]interface{}
  24266. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24267. fmt.Println(dat)
  24268. } else {
  24269. fmt.Println(err)
  24270. }
  24271. saveLog(result2, src_request, "2205", "撤销明细")
  24272. userJSONBytes, _ := json.Marshal(dat)
  24273. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24274. utils.ErrorLog("解析失败:%v", err)
  24275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24276. return
  24277. }
  24278. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24279. var api3 string
  24280. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24281. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24283. resp3, requestErr3 := http.Get(api3)
  24284. if requestErr3 != nil {
  24285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24286. return
  24287. }
  24288. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24289. if ioErr3 != nil {
  24290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24292. return
  24293. }
  24294. var respJSON3 map[string]interface{}
  24295. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24298. return
  24299. }
  24300. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24301. if status == "0" {
  24302. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24303. c.ServeSuccessJSON(map[string]interface{}{
  24304. "failed_code": -10,
  24305. "msg": err_msg,
  24306. })
  24307. return
  24308. }
  24309. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24310. userJSONBytes3, _ := json.Marshal(respJSON3)
  24311. fmt.Println("log")
  24312. fmt.Println(string(userJSONBytes3))
  24313. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24314. utils.ErrorLog("解析失败:%v", err)
  24315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24316. return
  24317. }
  24318. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24319. 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, "")
  24320. var dat map[string]interface{}
  24321. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24322. fmt.Println(dat)
  24323. } else {
  24324. fmt.Println(err)
  24325. }
  24326. saveLog(result2, src_request, "2205", "撤销明细")
  24327. userJSONBytes, _ := json.Marshal(dat)
  24328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24329. utils.ErrorLog("解析失败:%v", err)
  24330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24331. return
  24332. }
  24333. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24334. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24335. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24336. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24337. resp3, requestErr3 := http.Get(api3)
  24338. if requestErr3 != nil {
  24339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24340. return
  24341. }
  24342. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24343. if ioErr3 != nil {
  24344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24346. return
  24347. }
  24348. var respJSON3 map[string]interface{}
  24349. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24352. return
  24353. }
  24354. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24355. userJSONBytes3, _ := json.Marshal(respJSON3)
  24356. fmt.Println("log")
  24357. fmt.Println(string(userJSONBytes3))
  24358. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24359. utils.ErrorLog("解析失败:%v", err)
  24360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24361. return
  24362. }
  24363. } else {
  24364. if miConfig.Code == "H15049901371" {
  24365. 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)
  24366. var dat map[string]interface{}
  24367. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24368. fmt.Println(dat)
  24369. } else {
  24370. fmt.Println(err)
  24371. }
  24372. saveLog(result2, src_request, "2205", "撤销明细")
  24373. userJSONBytes, _ := json.Marshal(dat)
  24374. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24375. utils.ErrorLog("解析失败:%v", err)
  24376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24377. return
  24378. }
  24379. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24380. res2.Output = resSix10265.Output
  24381. res2.ErrMsg = resSix10265.ErrMsg
  24382. res2.Cainfo = resSix10265.Cainfo
  24383. res2.WarnMsg = resSix10265.WarnMsg
  24384. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24385. res2.Infcode = infocode
  24386. } else {
  24387. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24388. res2.Infcode = 0
  24389. } else {
  24390. 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)
  24391. var dat map[string]interface{}
  24392. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24393. fmt.Println(dat)
  24394. } else {
  24395. fmt.Println(err)
  24396. }
  24397. saveLog(result2, src_request, "2205", "撤销明细")
  24398. userJSONBytes, _ := json.Marshal(dat)
  24399. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24400. utils.ErrorLog("解析失败:%v", err)
  24401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24402. return
  24403. }
  24404. }
  24405. }
  24406. }
  24407. if res2.Infcode == -1 {
  24408. c.ServeSuccessJSON(map[string]interface{}{
  24409. "failed_code": -10,
  24410. "msg": res2.ErrMsg,
  24411. })
  24412. return
  24413. }
  24414. if res2.Infcode == 0 {
  24415. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24416. if err == nil {
  24417. //当押金不为零时产生退费记录
  24418. if order.Decimal != 0 {
  24419. tmp := strconv.FormatInt(order.ID, 10)
  24420. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24421. if err != nil {
  24422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24423. return
  24424. }
  24425. }
  24426. c.ServeSuccessJSON(map[string]interface{}{
  24427. "msg": "退费成功",
  24428. })
  24429. } else {
  24430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24431. return
  24432. }
  24433. } else {
  24434. c.ServeSuccessJSON(map[string]interface{}{
  24435. "failed_code": -10,
  24436. "msg": res2.ErrMsg,
  24437. })
  24438. }
  24439. } else {
  24440. c.ServeSuccessJSON(map[string]interface{}{
  24441. "failed_code": -10,
  24442. "msg": res.ErrMsg,
  24443. })
  24444. }
  24445. }
  24446. }
  24447. func (c *HisApiController) RefundNumber() {
  24448. record_time := c.GetString("record_time")
  24449. //patient_id, _ := c.GetInt64("patient_id")
  24450. admin_user_id, _ := c.GetInt64("admin_user_id")
  24451. his_patient_id, _ := c.GetInt64("id")
  24452. timeLayout := "2006-01-02"
  24453. loc, _ := time.LoadLocation("Local")
  24454. adminUser := c.GetAdminUserInfo()
  24455. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24456. fmt.Println(err)
  24457. if err != nil {
  24458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24459. return
  24460. }
  24461. recordDateTime := theTime.Unix()
  24462. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24463. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24464. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24465. //order, _ := service.GetHisOrderByID(order_id)
  24466. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24467. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24468. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24469. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24470. if count > 0 {
  24471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24472. return
  24473. }
  24474. if config.IsOpen == 1 { //对接了医保,走医保流程
  24475. var res2 ResultSix
  24476. var res3 GZResultSix
  24477. var resSix10265 ResultSix10265
  24478. if miConfig.MdtrtareaAdmvs == "421300" {
  24479. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24480. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24481. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24482. resp3, requestErr3 := http.Get(api3)
  24483. if requestErr3 != nil {
  24484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24485. return
  24486. }
  24487. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24488. if ioErr3 != nil {
  24489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24491. return
  24492. }
  24493. var respJSON3 map[string]interface{}
  24494. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24497. return
  24498. }
  24499. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24500. userJSONBytes3, _ := json.Marshal(respJSON3)
  24501. fmt.Println("log")
  24502. fmt.Println(string(userJSONBytes3))
  24503. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24504. utils.ErrorLog("解析失败:%v", err)
  24505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24506. return
  24507. }
  24508. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24509. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24510. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24511. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24512. resp3, requestErr3 := http.Get(api3)
  24513. if requestErr3 != nil {
  24514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24515. return
  24516. }
  24517. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24518. if ioErr3 != nil {
  24519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24521. return
  24522. }
  24523. var respJSON3 map[string]interface{}
  24524. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24527. return
  24528. }
  24529. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24530. userJSONBytes3, _ := json.Marshal(respJSON3)
  24531. fmt.Println("log")
  24532. fmt.Println(string(userJSONBytes3))
  24533. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24534. utils.ErrorLog("解析失败:%v", err)
  24535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24536. return
  24537. }
  24538. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24539. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24540. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24542. resp3, requestErr3 := http.Get(api3)
  24543. if requestErr3 != nil {
  24544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24545. return
  24546. }
  24547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24548. if ioErr3 != nil {
  24549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24551. return
  24552. }
  24553. var respJSON3 map[string]interface{}
  24554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24560. userJSONBytes3, _ := json.Marshal(respJSON3)
  24561. fmt.Println("log")
  24562. fmt.Println(string(userJSONBytes3))
  24563. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24564. utils.ErrorLog("解析失败:%v", err)
  24565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24566. return
  24567. }
  24568. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24569. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24570. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24571. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24572. resp3, requestErr3 := http.Get(api3)
  24573. if requestErr3 != nil {
  24574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24575. return
  24576. }
  24577. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24578. if ioErr3 != nil {
  24579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24581. return
  24582. }
  24583. var respJSON3 map[string]interface{}
  24584. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24587. return
  24588. }
  24589. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24590. userJSONBytes3, _ := json.Marshal(respJSON3)
  24591. fmt.Println("log")
  24592. fmt.Println(string(userJSONBytes3))
  24593. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24594. utils.ErrorLog("解析失败:%v", err)
  24595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24596. return
  24597. }
  24598. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24599. var api3 string
  24600. if miConfig.MdtrtareaAdmvs == "320921" {
  24601. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24602. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24603. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24604. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24605. } else {
  24606. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24607. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24608. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24609. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24610. }
  24611. resp3, requestErr3 := http.Get(api3)
  24612. if requestErr3 != nil {
  24613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24614. return
  24615. }
  24616. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24617. if ioErr3 != nil {
  24618. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24620. return
  24621. }
  24622. var respJSON3 map[string]interface{}
  24623. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24624. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24626. return
  24627. }
  24628. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24629. userJSONBytes3, _ := json.Marshal(respJSON3)
  24630. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24631. utils.ErrorLog("解析失败:%v", err)
  24632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24633. return
  24634. }
  24635. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24636. res2.Output = resSix10265.Output
  24637. res2.ErrMsg = resSix10265.ErrMsg
  24638. res2.Cainfo = resSix10265.Cainfo
  24639. res2.WarnMsg = resSix10265.WarnMsg
  24640. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24641. res2.Infcode = infocode
  24642. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24643. var api3 string
  24644. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24645. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24646. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24647. resp3, requestErr3 := http.Get(api3)
  24648. if requestErr3 != nil {
  24649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24650. return
  24651. }
  24652. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24653. if ioErr3 != nil {
  24654. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24656. return
  24657. }
  24658. var respJSON3 map[string]interface{}
  24659. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24662. return
  24663. }
  24664. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24665. userJSONBytes3, _ := json.Marshal(respJSON3)
  24666. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24667. utils.ErrorLog("解析失败:%v", err)
  24668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24669. return
  24670. }
  24671. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24672. res2.Output = resSix10265.Output
  24673. res2.ErrMsg = resSix10265.ErrMsg
  24674. res2.Cainfo = resSix10265.Cainfo
  24675. res2.WarnMsg = resSix10265.WarnMsg
  24676. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24677. res2.Infcode = infocode
  24678. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24679. 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)
  24680. var dat map[string]interface{}
  24681. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24682. fmt.Println(dat)
  24683. } else {
  24684. fmt.Println(err)
  24685. }
  24686. saveLog(result, request, "2202", "退号")
  24687. userJSONBytes, _ := json.Marshal(dat)
  24688. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24689. utils.ErrorLog("解析失败:%v", err)
  24690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24691. return
  24692. }
  24693. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24694. 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, "")
  24695. var dat map[string]interface{}
  24696. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24697. fmt.Println(dat)
  24698. } else {
  24699. fmt.Println(err)
  24700. }
  24701. saveLog(result, request, "2202", "退号")
  24702. userJSONBytes, _ := json.Marshal(dat)
  24703. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24704. utils.ErrorLog("解析失败:%v", err)
  24705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24706. return
  24707. }
  24708. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24709. var api3 string
  24710. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24711. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24713. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24714. resp3, requestErr3 := http.Get(api3)
  24715. if requestErr3 != nil {
  24716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24717. return
  24718. }
  24719. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24720. if ioErr3 != nil {
  24721. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24723. return
  24724. }
  24725. var respJSON3 map[string]interface{}
  24726. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24727. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24729. return
  24730. }
  24731. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24732. if status == "0" {
  24733. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24734. c.ServeSuccessJSON(map[string]interface{}{
  24735. "failed_code": -10,
  24736. "msg": err_msg,
  24737. })
  24738. return
  24739. }
  24740. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24741. userJSONBytes3, _ := json.Marshal(respJSON3)
  24742. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24743. utils.ErrorLog("解析失败:%v", err)
  24744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24745. return
  24746. }
  24747. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24748. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24749. 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, "")
  24750. var dat map[string]interface{}
  24751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24752. fmt.Println(dat)
  24753. } else {
  24754. fmt.Println(err)
  24755. }
  24756. saveLog(result, request, "2202", "退号")
  24757. userJSONBytes, _ := json.Marshal(dat)
  24758. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24759. utils.ErrorLog("解析失败:%v", err)
  24760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24761. return
  24762. }
  24763. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24764. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24765. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24767. resp3, requestErr3 := http.Get(api3)
  24768. if requestErr3 != nil {
  24769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24770. return
  24771. }
  24772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24773. if ioErr3 != nil {
  24774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24776. return
  24777. }
  24778. var respJSON3 map[string]interface{}
  24779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24782. return
  24783. }
  24784. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24785. userJSONBytes3, _ := json.Marshal(respJSON3)
  24786. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24787. utils.ErrorLog("解析失败:%v", err)
  24788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24789. return
  24790. }
  24791. } else {
  24792. var api3 string
  24793. if miConfig.Code == "H15049901371" {
  24794. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24795. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24797. } else {
  24798. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24799. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24800. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24801. }
  24802. resp3, requestErr3 := http.Get(api3)
  24803. if requestErr3 != nil {
  24804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24805. return
  24806. }
  24807. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24808. if ioErr3 != nil {
  24809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24811. return
  24812. }
  24813. var respJSON3 map[string]interface{}
  24814. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24817. return
  24818. }
  24819. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24820. userJSONBytes3, _ := json.Marshal(respJSON3)
  24821. if miConfig.Code == "H15049901371" {
  24822. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24823. utils.ErrorLog("解析失败:%v", err)
  24824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24825. return
  24826. }
  24827. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24828. res2.Output = resSix10265.Output
  24829. res2.ErrMsg = resSix10265.ErrMsg
  24830. res2.Cainfo = resSix10265.Cainfo
  24831. res2.WarnMsg = resSix10265.WarnMsg
  24832. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24833. res2.Infcode = infocode
  24834. } else {
  24835. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24836. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24837. utils.ErrorLog("解析失败:%v", err)
  24838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24839. return
  24840. }
  24841. res2.Infcode = res3.Infcode
  24842. } else {
  24843. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24844. utils.ErrorLog("解析失败:%v", err)
  24845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24846. return
  24847. }
  24848. }
  24849. }
  24850. }
  24851. if res2.Infcode == -1 {
  24852. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24853. c.ServeSuccessJSON(map[string]interface{}{
  24854. "failed_code": -10,
  24855. "msg": res2.ErrMsg,
  24856. })
  24857. return
  24858. }
  24859. if res2.Infcode == 0 {
  24860. if err == nil {
  24861. c.ServeSuccessJSON(map[string]interface{}{
  24862. "msg": "退号成功",
  24863. })
  24864. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24865. } else {
  24866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24867. return
  24868. }
  24869. }
  24870. } else {
  24871. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24872. //if err == nil {
  24873. // c.ServeSuccessJSON(map[string]interface{}{
  24874. // "msg": "退费成功",
  24875. // })
  24876. //} else {
  24877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24878. // return
  24879. //}
  24880. }
  24881. }
  24882. func (c *HisApiController) RefundDetail() {
  24883. order_id, _ := c.GetInt64("order_id")
  24884. admin_user_id, _ := c.GetInt64("admin_user_id")
  24885. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24886. number := c.GetString("number")
  24887. record_time := c.GetString("record_time")
  24888. patient_id, _ := c.GetInt64("patient_id")
  24889. //med_type, _ := c.GetInt64("med_type")
  24890. timeLayout := "2006-01-02"
  24891. loc, _ := time.LoadLocation("Local")
  24892. adminUser := c.GetAdminUserInfo()
  24893. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24894. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24895. fmt.Println(err)
  24896. if err != nil {
  24897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24898. return
  24899. }
  24900. recordDateTime := theTime.Unix()
  24901. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24902. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24903. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24904. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24905. var order models.HisOrder
  24906. order, _ = service.GetHisOrderByID(order_id)
  24907. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24908. if config.IsOpen == 1 { //对接了医保,走医保流程
  24909. var res2 ResultSix
  24910. if miConfig.MdtrtareaAdmvs == "421300" {
  24911. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24912. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24913. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24914. resp3, requestErr3 := http.Get(api3)
  24915. if requestErr3 != nil {
  24916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24917. return
  24918. }
  24919. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24920. if ioErr3 != nil {
  24921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24923. return
  24924. }
  24925. var respJSON3 map[string]interface{}
  24926. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24929. return
  24930. }
  24931. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24932. userJSONBytes3, _ := json.Marshal(respJSON3)
  24933. fmt.Println("log")
  24934. fmt.Println(string(userJSONBytes3))
  24935. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24936. utils.ErrorLog("解析失败:%v", err)
  24937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24938. return
  24939. }
  24940. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24941. if err == nil {
  24942. c.ServeSuccessJSON(map[string]interface{}{
  24943. "msg": "撤销明细成功",
  24944. })
  24945. return
  24946. } else {
  24947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24948. return
  24949. }
  24950. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24951. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24952. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24953. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24954. resp3, requestErr3 := http.Get(api3)
  24955. if requestErr3 != nil {
  24956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24957. return
  24958. }
  24959. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24960. if ioErr3 != nil {
  24961. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24963. return
  24964. }
  24965. var respJSON3 map[string]interface{}
  24966. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24967. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24969. return
  24970. }
  24971. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24972. userJSONBytes3, _ := json.Marshal(respJSON3)
  24973. fmt.Println("log")
  24974. fmt.Println(string(userJSONBytes3))
  24975. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24976. utils.ErrorLog("解析失败:%v", err)
  24977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24978. return
  24979. }
  24980. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24981. if err == nil {
  24982. c.ServeSuccessJSON(map[string]interface{}{
  24983. "msg": "撤销明细成功",
  24984. })
  24985. return
  24986. } else {
  24987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24988. return
  24989. }
  24990. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24991. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24992. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24993. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24994. resp3, requestErr3 := http.Get(api3)
  24995. if requestErr3 != nil {
  24996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24997. return
  24998. }
  24999. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25000. if ioErr3 != nil {
  25001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25003. return
  25004. }
  25005. var respJSON3 map[string]interface{}
  25006. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25009. return
  25010. }
  25011. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25012. userJSONBytes3, _ := json.Marshal(respJSON3)
  25013. fmt.Println("log")
  25014. fmt.Println(string(userJSONBytes3))
  25015. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25016. utils.ErrorLog("解析失败:%v", err)
  25017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25018. return
  25019. }
  25020. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25021. if err == nil {
  25022. c.ServeSuccessJSON(map[string]interface{}{
  25023. "msg": "撤销明细成功",
  25024. })
  25025. return
  25026. } else {
  25027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25028. return
  25029. }
  25030. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25031. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  25032. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25033. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25034. resp3, requestErr3 := http.Get(api3)
  25035. if requestErr3 != nil {
  25036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25037. return
  25038. }
  25039. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25040. if ioErr3 != nil {
  25041. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25043. return
  25044. }
  25045. var respJSON3 map[string]interface{}
  25046. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25047. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25049. return
  25050. }
  25051. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25052. userJSONBytes3, _ := json.Marshal(respJSON3)
  25053. fmt.Println("log")
  25054. fmt.Println(string(userJSONBytes3))
  25055. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25056. utils.ErrorLog("解析失败:%v", err)
  25057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25058. return
  25059. }
  25060. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25061. if err == nil {
  25062. c.ServeSuccessJSON(map[string]interface{}{
  25063. "msg": "撤销明细成功",
  25064. })
  25065. return
  25066. } else {
  25067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25068. return
  25069. }
  25070. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25071. var resSix10265 ResultSix10265
  25072. var api3 string
  25073. if miConfig.MdtrtareaAdmvs == "320921" {
  25074. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25075. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25077. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25078. } else {
  25079. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25080. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  25081. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25083. }
  25084. resp3, requestErr3 := http.Get(api3)
  25085. utils.ErrorLog("接口: %v", requestErr3)
  25086. if requestErr3 != nil {
  25087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25088. return
  25089. }
  25090. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25091. if ioErr3 != nil {
  25092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25094. return
  25095. }
  25096. var respJSON3 map[string]interface{}
  25097. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25100. return
  25101. }
  25102. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25103. userJSONBytes3, _ := json.Marshal(respJSON3)
  25104. fmt.Println("log")
  25105. fmt.Println(string(userJSONBytes3))
  25106. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25107. utils.ErrorLog("解析失败:%v", err)
  25108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25109. return
  25110. }
  25111. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25112. res2.Output = resSix10265.Output
  25113. res2.ErrMsg = resSix10265.ErrMsg
  25114. res2.Cainfo = resSix10265.Cainfo
  25115. res2.WarnMsg = resSix10265.WarnMsg
  25116. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25117. res2.Infcode = infocode
  25118. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25119. if err == nil {
  25120. c.ServeSuccessJSON(map[string]interface{}{
  25121. "msg": "撤销明细成功",
  25122. })
  25123. return
  25124. } else {
  25125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25126. return
  25127. }
  25128. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25129. var api3 string
  25130. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25131. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25133. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25134. resp3, requestErr3 := http.Get(api3)
  25135. utils.ErrorLog("接口: %v", requestErr3)
  25136. if requestErr3 != nil {
  25137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25138. return
  25139. }
  25140. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25141. if ioErr3 != nil {
  25142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25144. return
  25145. }
  25146. var respJSON3 map[string]interface{}
  25147. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25150. return
  25151. }
  25152. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25153. if status == "0" {
  25154. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25155. c.ServeSuccessJSON(map[string]interface{}{
  25156. "failed_code": -10,
  25157. "msg": err_msg,
  25158. })
  25159. return
  25160. }
  25161. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25162. userJSONBytes3, _ := json.Marshal(respJSON3)
  25163. fmt.Println("log")
  25164. fmt.Println(string(userJSONBytes3))
  25165. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25166. utils.ErrorLog("解析失败:%v", err)
  25167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25168. return
  25169. }
  25170. fmt.Println(res2.Infcode)
  25171. if res2.Infcode == -1 {
  25172. c.ServeSuccessJSON(map[string]interface{}{
  25173. "failed_code": -10,
  25174. "msg": res2.ErrMsg,
  25175. })
  25176. return
  25177. }
  25178. if res2.Infcode == 0 {
  25179. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25180. if err == nil {
  25181. c.ServeSuccessJSON(map[string]interface{}{
  25182. "msg": "撤销明细成功",
  25183. })
  25184. return
  25185. } else {
  25186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25187. return
  25188. }
  25189. } else {
  25190. c.ServeSuccessJSON(map[string]interface{}{
  25191. "failed_code": -10,
  25192. "msg": res2.ErrMsg,
  25193. })
  25194. }
  25195. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25196. if err == nil {
  25197. c.ServeSuccessJSON(map[string]interface{}{
  25198. "msg": "撤销明细成功",
  25199. })
  25200. return
  25201. } else {
  25202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25203. return
  25204. }
  25205. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25206. var resSix10265 ResultSix10265
  25207. var api3 string
  25208. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25209. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25211. resp3, requestErr3 := http.Get(api3)
  25212. if requestErr3 != nil {
  25213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25214. return
  25215. }
  25216. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25217. if ioErr3 != nil {
  25218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25220. return
  25221. }
  25222. var respJSON3 map[string]interface{}
  25223. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25226. return
  25227. }
  25228. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25229. userJSONBytes3, _ := json.Marshal(respJSON3)
  25230. fmt.Println("log")
  25231. fmt.Println(string(userJSONBytes3))
  25232. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25233. utils.ErrorLog("解析失败:%v", err)
  25234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25235. return
  25236. }
  25237. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25238. res2.Output = resSix10265.Output
  25239. res2.ErrMsg = resSix10265.ErrMsg
  25240. res2.Cainfo = resSix10265.Cainfo
  25241. res2.WarnMsg = resSix10265.WarnMsg
  25242. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25243. res2.Infcode = infocode
  25244. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25245. if err == nil {
  25246. c.ServeSuccessJSON(map[string]interface{}{
  25247. "msg": "撤销明细成功",
  25248. })
  25249. return
  25250. } else {
  25251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25252. return
  25253. }
  25254. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25255. 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)
  25256. var dat map[string]interface{}
  25257. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25258. fmt.Println(dat)
  25259. } else {
  25260. fmt.Println(err)
  25261. }
  25262. saveLog(result2, src_request, "2205", "撤销明细")
  25263. userJSONBytes, _ := json.Marshal(dat)
  25264. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25265. utils.ErrorLog("解析失败:%v", err)
  25266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25267. return
  25268. }
  25269. if res2.Infcode == 0 {
  25270. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25271. if err == nil {
  25272. c.ServeSuccessJSON(map[string]interface{}{
  25273. "msg": "撤销明细成功",
  25274. })
  25275. return
  25276. } else {
  25277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25278. return
  25279. }
  25280. } else {
  25281. c.ServeSuccessJSON(map[string]interface{}{
  25282. "failed_code": -10,
  25283. "msg": res2.ErrMsg,
  25284. })
  25285. }
  25286. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25287. 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, "")
  25288. var dat map[string]interface{}
  25289. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25290. fmt.Println(dat)
  25291. } else {
  25292. fmt.Println(err)
  25293. }
  25294. saveLog(result2, src_request, "2205", "撤销明细")
  25295. userJSONBytes, _ := json.Marshal(dat)
  25296. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25297. utils.ErrorLog("解析失败:%v", err)
  25298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25299. return
  25300. }
  25301. if res2.Infcode == 0 {
  25302. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25303. if err == nil {
  25304. c.ServeSuccessJSON(map[string]interface{}{
  25305. "msg": "撤销明细成功",
  25306. })
  25307. return
  25308. } else {
  25309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25310. return
  25311. }
  25312. } else {
  25313. c.ServeSuccessJSON(map[string]interface{}{
  25314. "failed_code": -10,
  25315. "msg": res2.ErrMsg,
  25316. })
  25317. }
  25318. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25319. 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, "")
  25320. var dat map[string]interface{}
  25321. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25322. fmt.Println(dat)
  25323. } else {
  25324. fmt.Println(err)
  25325. }
  25326. saveLog(result2, src_request, "2205", "撤销明细")
  25327. userJSONBytes, _ := json.Marshal(dat)
  25328. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25329. utils.ErrorLog("解析失败:%v", err)
  25330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25331. return
  25332. }
  25333. if res2.Infcode == 0 {
  25334. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25335. if err == nil {
  25336. c.ServeSuccessJSON(map[string]interface{}{
  25337. "msg": "撤销明细成功",
  25338. })
  25339. return
  25340. } else {
  25341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25342. return
  25343. }
  25344. } else {
  25345. c.ServeSuccessJSON(map[string]interface{}{
  25346. "failed_code": -10,
  25347. "msg": res2.ErrMsg,
  25348. })
  25349. }
  25350. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25351. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25352. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25353. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25354. resp2, requestErr2 := http.Get(api2)
  25355. if requestErr2 != nil {
  25356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25357. return
  25358. }
  25359. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25360. if ioErr2 != nil {
  25361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25363. return
  25364. }
  25365. var respJSON2 map[string]interface{}
  25366. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25369. return
  25370. }
  25371. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25372. userJSONBytes3, _ := json.Marshal(respJSON2)
  25373. fmt.Println("log")
  25374. fmt.Println(string(userJSONBytes3))
  25375. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25376. utils.ErrorLog("解析失败:%v", err)
  25377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25378. return
  25379. }
  25380. if res2.Infcode == 0 {
  25381. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25382. if err == nil {
  25383. c.ServeSuccessJSON(map[string]interface{}{
  25384. "msg": "撤销明细成功",
  25385. })
  25386. return
  25387. } else {
  25388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25389. return
  25390. }
  25391. } else {
  25392. c.ServeSuccessJSON(map[string]interface{}{
  25393. "failed_code": -10,
  25394. "msg": res2.ErrMsg,
  25395. })
  25396. }
  25397. } else {
  25398. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25399. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25400. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25401. resp2, requestErr2 := http.Get(api2)
  25402. if requestErr2 != nil {
  25403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25404. return
  25405. }
  25406. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25407. if ioErr2 != nil {
  25408. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25410. return
  25411. }
  25412. var respJSON2 map[string]interface{}
  25413. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25414. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25416. return
  25417. }
  25418. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25419. if err == nil {
  25420. c.ServeSuccessJSON(map[string]interface{}{
  25421. "msg": "撤销明细成功",
  25422. })
  25423. return
  25424. } else {
  25425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25426. return
  25427. }
  25428. }
  25429. } else {
  25430. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25431. if err == nil {
  25432. c.ServeSuccessJSON(map[string]interface{}{
  25433. "msg": "退费成功",
  25434. })
  25435. } else {
  25436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25437. return
  25438. }
  25439. }
  25440. }
  25441. // 对账
  25442. func (c *HisApiController) GetCheckAccount() {
  25443. start_time := c.GetString("start_time")
  25444. end_time := c.GetString("end_time")
  25445. insutype := c.GetString("insutype")
  25446. clr_type := c.GetString("clr_type")
  25447. clr_org := c.GetString("clr_optins")
  25448. admin_user_id, _ := c.GetInt64("admin_user_id")
  25449. adminUser := c.GetAdminUserInfo()
  25450. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25451. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25452. if len(clr_org) == 0 {
  25453. clr_org = miConfig.InsuplcAdmdvs
  25454. }
  25455. timeLayout := "2006-01-02"
  25456. loc, _ := time.LoadLocation("Local")
  25457. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25458. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25459. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25460. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25461. fixmedins_setl_cnt := int64(len(orders))
  25462. var medfee_sumamt float64
  25463. var acct_pay float64
  25464. var fund_pay_sumamt float64
  25465. for _, item := range orders {
  25466. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25467. acct_pay = acct_pay + item.AcctPay
  25468. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25469. }
  25470. var user_name string
  25471. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25472. if role.ID == 0 {
  25473. user_name = "xxx"
  25474. } else {
  25475. user_name = role.UserName
  25476. }
  25477. var res ResultEight
  25478. var res10188 ResultEightFor10188
  25479. if config.IsOpen == 1 {
  25480. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25481. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25482. "insutype=" + insutype +
  25483. "&clr_type=" + clr_type +
  25484. "&setl_optins=" + clr_org +
  25485. "&stmt_begndate=" + start_time +
  25486. "&stm_enddate=" + end_time +
  25487. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25488. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25489. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25490. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25491. "&fixmedins_code=" + miConfig.Code +
  25492. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25493. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25494. "&secret_key=" + miConfig.SecretKey +
  25495. "&org_name=" + miConfig.OrgName +
  25496. "&doctor=" + user_name +
  25497. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25498. fmt.Println(api)
  25499. resp, requestErr := http.Get(api)
  25500. if requestErr != nil {
  25501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25502. return
  25503. }
  25504. body, ioErr := ioutil.ReadAll(resp.Body)
  25505. fmt.Println(body)
  25506. if ioErr != nil {
  25507. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25509. return
  25510. }
  25511. var respJSON map[string]interface{}
  25512. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25513. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25515. return
  25516. }
  25517. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25518. userJSONBytes, _ := json.Marshal(respJSON)
  25519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25520. utils.ErrorLog("解析失败:%v", err)
  25521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25522. return
  25523. }
  25524. res.InfRefmsgid = res10188.InfRefmsgid
  25525. res.Output = res10188.Output
  25526. res.ErrMsg = res10188.ErrMsg
  25527. res.Cainfo = res10188.Cainfo
  25528. res.WarnMsg = res10188.WarnMsg
  25529. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25530. res.Infcode = infocode
  25531. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25532. if clr_type != "9903" {
  25533. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25534. }
  25535. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25536. "insutype=" + insutype +
  25537. "&clr_type=" + clr_type +
  25538. "&setl_optins=" + clr_org +
  25539. "&stmt_begndate=" + start_time +
  25540. "&stm_enddate=" + end_time +
  25541. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25542. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25543. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25544. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25545. "&fixmedins_code=" + miConfig.Code +
  25546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25547. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25548. "&secret_key=" + miConfig.SecretKey +
  25549. "&org_name=" + miConfig.OrgName +
  25550. "&doctor=" + user_name
  25551. resp, requestErr := http.Get(api)
  25552. if requestErr != nil {
  25553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25554. return
  25555. }
  25556. body, ioErr := ioutil.ReadAll(resp.Body)
  25557. if ioErr != nil {
  25558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25560. return
  25561. }
  25562. var respJSON map[string]interface{}
  25563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25566. return
  25567. }
  25568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25569. result, _ := json.Marshal(respJSON)
  25570. fmt.Println("log")
  25571. fmt.Println(string(result))
  25572. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25573. utils.ErrorLog("解析失败:%v", err)
  25574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25575. return
  25576. }
  25577. res.InfRefmsgid = res10188.InfRefmsgid
  25578. res.Output = res10188.Output
  25579. res.ErrMsg = res10188.ErrMsg
  25580. res.Cainfo = res10188.Cainfo
  25581. res.WarnMsg = res10188.WarnMsg
  25582. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25583. res.Infcode = infocode
  25584. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25585. var baseParams models.BaseParams
  25586. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25587. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25588. baseParams.SecretKey = miConfig.SecretKey
  25589. baseParams.OrgName = miConfig.OrgName
  25590. baseParams.FixmedinsCode = miConfig.Code
  25591. baseParams.EncKey = miConfig.EncKey
  25592. baseParams.AppSecret = miConfig.AppSecret
  25593. baseParams.SignKey = miConfig.SignKey
  25594. baseParams.AppID = miConfig.Code
  25595. baseParams.Doctor = role.UserName
  25596. baseParams.RequestUrl = miConfig.Url
  25597. businessParams := models.BusinessParams{
  25598. Insutype: insutype,
  25599. ClrType: clr_type,
  25600. SetlOptins: clr_org,
  25601. StmtBegndate: start_time,
  25602. StmtEnddate: end_time,
  25603. MedfeeSumamt: medfee_sumamt,
  25604. FundPaySumamt: fund_pay_sumamt,
  25605. AcctPay: acct_pay,
  25606. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25607. }
  25608. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25609. fmt.Println(requestLog)
  25610. fmt.Println(result)
  25611. fmt.Println(err_msg)
  25612. var dat map[string]interface{}
  25613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25614. fmt.Println(dat)
  25615. } else {
  25616. fmt.Println(err)
  25617. }
  25618. userJSONBytes, _ := json.Marshal(dat)
  25619. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25620. utils.ErrorLog("解析失败:%v", err)
  25621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25622. return
  25623. }
  25624. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25625. var baseParams models.BaseParams
  25626. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25627. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25628. baseParams.SecretKey = miConfig.SecretKey
  25629. baseParams.OrgName = miConfig.OrgName
  25630. baseParams.FixmedinsCode = miConfig.Code
  25631. baseParams.EncKey = miConfig.EncKey
  25632. baseParams.AppSecret = miConfig.AppSecret
  25633. baseParams.SignKey = miConfig.SignKey
  25634. baseParams.AppID = miConfig.Code
  25635. baseParams.Doctor = role.UserName
  25636. baseParams.RequestUrl = miConfig.Url
  25637. baseParams.AccessKey = miConfig.AccessKey
  25638. businessParams := models.BusinessParams{
  25639. Insutype: insutype,
  25640. ClrType: clr_type,
  25641. SetlOptins: "430822",
  25642. StmtBegndate: start_time,
  25643. StmtEnddate: end_time,
  25644. MedfeeSumamt: medfee_sumamt,
  25645. FundPaySumamt: fund_pay_sumamt,
  25646. AcctPay: acct_pay,
  25647. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25648. }
  25649. 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)
  25650. fmt.Println(requestLog)
  25651. fmt.Println(result)
  25652. var dat map[string]interface{}
  25653. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25654. fmt.Println(dat)
  25655. } else {
  25656. fmt.Println(err)
  25657. }
  25658. userJSONBytes, _ := json.Marshal(dat)
  25659. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25660. utils.ErrorLog("解析失败:%v", err)
  25661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25662. return
  25663. }
  25664. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25665. var baseParams models.BaseParams
  25666. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25667. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25668. baseParams.SecretKey = miConfig.SecretKey
  25669. baseParams.OrgName = miConfig.OrgName
  25670. baseParams.FixmedinsCode = miConfig.Code
  25671. baseParams.EncKey = miConfig.EncKey
  25672. baseParams.AppSecret = miConfig.AppSecret
  25673. baseParams.SignKey = miConfig.SignKey
  25674. baseParams.AppID = miConfig.Code
  25675. baseParams.Doctor = role.UserName
  25676. baseParams.RequestUrl = miConfig.Url
  25677. businessParams := models.BusinessParams{
  25678. Insutype: insutype,
  25679. ClrType: clr_type,
  25680. SetlOptins: clr_org,
  25681. StmtBegndate: start_time,
  25682. StmtEnddate: end_time,
  25683. MedfeeSumamt: medfee_sumamt,
  25684. FundPaySumamt: fund_pay_sumamt,
  25685. AcctPay: acct_pay,
  25686. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25687. }
  25688. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25689. fmt.Println(requestLog)
  25690. fmt.Println(result)
  25691. fmt.Println(err_msg)
  25692. var dat map[string]interface{}
  25693. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25694. fmt.Println(dat)
  25695. } else {
  25696. fmt.Println(err)
  25697. }
  25698. userJSONBytes, _ := json.Marshal(dat)
  25699. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25700. utils.ErrorLog("解析失败:%v", err)
  25701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25702. return
  25703. }
  25704. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25705. if len(clr_type) == 0 {
  25706. clr_type = "11"
  25707. }
  25708. api := miConfig.Url + "gdyb/ten?" +
  25709. "insutype=" + insutype +
  25710. "&clr_type=" + clr_type +
  25711. "&setl_optins=" + clr_org +
  25712. "&stmt_begndate=" + start_time +
  25713. "&stm_enddate=" + end_time +
  25714. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25715. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25716. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25717. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25718. "&fixmedins_code=" + miConfig.Code +
  25719. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25720. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25721. "&secret_key=" + miConfig.SecretKey +
  25722. "&org_name=" + miConfig.OrgName +
  25723. "&doctor=" + user_name
  25724. fmt.Println(api)
  25725. resp, requestErr := http.Get(api)
  25726. if requestErr != nil {
  25727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25728. return
  25729. }
  25730. body, ioErr := ioutil.ReadAll(resp.Body)
  25731. fmt.Println(body)
  25732. if ioErr != nil {
  25733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25735. return
  25736. }
  25737. var respJSON map[string]interface{}
  25738. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25741. return
  25742. }
  25743. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25744. userJSONBytes, _ := json.Marshal(respJSON)
  25745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25746. utils.ErrorLog("解析失败:%v", err)
  25747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25748. return
  25749. }
  25750. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25751. var baseParams models.BaseParams
  25752. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25753. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25754. baseParams.SecretKey = miConfig.SecretKey
  25755. baseParams.OrgName = miConfig.OrgName
  25756. baseParams.FixmedinsCode = miConfig.Code
  25757. baseParams.EncKey = miConfig.EncKey
  25758. baseParams.AppSecret = miConfig.AppSecret
  25759. baseParams.SignKey = miConfig.SignKey
  25760. baseParams.AppID = miConfig.Code
  25761. baseParams.Doctor = role.UserName
  25762. baseParams.RequestUrl = miConfig.Url
  25763. if clr_type == "9903" {
  25764. clr_type = "9901"
  25765. }
  25766. businessParams := models.BusinessParams{
  25767. Insutype: insutype,
  25768. ClrType: clr_type,
  25769. SetlOptins: "360302",
  25770. StmtBegndate: start_time,
  25771. StmtEnddate: end_time,
  25772. MedfeeSumamt: 0,
  25773. FundPaySumamt: 0,
  25774. AcctPay: 0,
  25775. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25776. }
  25777. 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))
  25778. fmt.Println(requestLog)
  25779. fmt.Println(result)
  25780. var dat map[string]interface{}
  25781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25782. fmt.Println(dat)
  25783. } else {
  25784. fmt.Println(err)
  25785. }
  25786. userJSONBytes, _ := json.Marshal(dat)
  25787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25788. utils.ErrorLog("解析失败:%v", err)
  25789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25790. return
  25791. }
  25792. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25793. var api string
  25794. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25795. "&clr_type=" + clr_type +
  25796. "&setl_optins=" + clr_org +
  25797. "&stmt_begndate=" + start_time +
  25798. "&stm_enddate=" + end_time +
  25799. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25800. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25801. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25802. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25803. "&fixmedins_code=" + miConfig.Code +
  25804. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25805. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25806. "&secret_key=" + miConfig.SecretKey +
  25807. "&org_name=" + miConfig.OrgName +
  25808. "&doctor=" + user_name + "&url=" + miConfig.Url
  25809. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25810. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25811. resp, requestErr := http.Get(api)
  25812. if requestErr != nil {
  25813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25814. return
  25815. }
  25816. body, ioErr := ioutil.ReadAll(resp.Body)
  25817. if ioErr != nil {
  25818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25820. return
  25821. }
  25822. var respJSON map[string]interface{}
  25823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25826. return
  25827. }
  25828. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25829. if status == "0" {
  25830. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25831. c.ServeSuccessJSON(map[string]interface{}{
  25832. "failed_code": -10,
  25833. "msg": err_msg,
  25834. })
  25835. return
  25836. }
  25837. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25838. userJSONBytes, _ := json.Marshal(respJSON)
  25839. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25840. utils.ErrorLog("解析失败:%v", err)
  25841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25842. return
  25843. }
  25844. } else {
  25845. if len(clr_type) == 0 {
  25846. clr_type = "11"
  25847. }
  25848. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25849. "insutype=" + insutype +
  25850. "&clr_type=" + clr_type +
  25851. "&setl_optins=" + clr_org +
  25852. "&stmt_begndate=" + start_time +
  25853. "&stm_enddate=" + end_time +
  25854. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25855. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25856. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25857. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25858. "&fixmedins_code=" + miConfig.Code +
  25859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25860. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25861. "&secret_key=" + miConfig.SecretKey +
  25862. "&org_name=" + miConfig.OrgName +
  25863. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25864. fmt.Println(api)
  25865. resp, requestErr := http.Get(api)
  25866. if requestErr != nil {
  25867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25868. return
  25869. }
  25870. body, ioErr := ioutil.ReadAll(resp.Body)
  25871. fmt.Println(body)
  25872. if ioErr != nil {
  25873. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25875. return
  25876. }
  25877. var respJSON map[string]interface{}
  25878. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25879. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25881. return
  25882. }
  25883. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25884. userJSONBytes, _ := json.Marshal(respJSON)
  25885. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25886. utils.ErrorLog("解析失败:%v", err)
  25887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25888. return
  25889. }
  25890. }
  25891. if res.Infcode == 0 {
  25892. if res.Output.Stmtinfo.StmtRslt == "0" {
  25893. micc := &models.MedicalInsuranceCostCompare{
  25894. StartTime: startime.Unix(),
  25895. EndTime: endtime.Unix(),
  25896. Insutype: insutype,
  25897. CheckType: 1,
  25898. Num: fixmedins_setl_cnt,
  25899. Mtime: time.Now().Unix(),
  25900. Status: 1,
  25901. UserOrgId: adminUser.CurrentOrgId,
  25902. CostTotal: medfee_sumamt,
  25903. FuncTotal: fund_pay_sumamt,
  25904. PsnPay: acct_pay,
  25905. Creator: admin_user_id,
  25906. Ctime: time.Now().Unix(),
  25907. ClrType: clr_type,
  25908. }
  25909. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25910. if err == nil {
  25911. c.ServeSuccessJSON(map[string]interface{}{
  25912. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25913. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25914. })
  25915. } else {
  25916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25917. }
  25918. } else {
  25919. c.ServeSuccessJSON(map[string]interface{}{
  25920. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25921. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25922. })
  25923. }
  25924. } else {
  25925. c.ServeSuccessJSON(map[string]interface{}{
  25926. "failed_code": -10,
  25927. "msg": res.ErrMsg,
  25928. })
  25929. }
  25930. }
  25931. }
  25932. func (c *HisApiController) Check310() {
  25933. adminUser := c.GetAdminUserInfo()
  25934. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25935. var user_name string
  25936. user_name = "高慧裕"
  25937. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25938. "insutype=" + "310" +
  25939. "&clr_type=" + "" +
  25940. "&setl_optins=" + "441202" +
  25941. "&stmt_begndate=" + "2022-03-01" +
  25942. "&stm_enddate=" + "2022-03-31" +
  25943. "&medfee_sumamt=" + "194930.12" +
  25944. "&fund_pay_sumamt=" + "188741.46" +
  25945. "&acct_pay=" + "0" +
  25946. "&fixmedins_setl_cnt=" + "452" +
  25947. "&fixmedins_code=" + miConfig.Code +
  25948. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25949. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25950. "&secret_key=" + miConfig.SecretKey +
  25951. "&org_name=" + miConfig.OrgName +
  25952. "&doctor=" + user_name
  25953. fmt.Println(api)
  25954. resp, requestErr := http.Get(api)
  25955. if requestErr != nil {
  25956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25957. return
  25958. }
  25959. body, ioErr := ioutil.ReadAll(resp.Body)
  25960. fmt.Println(body)
  25961. if ioErr != nil {
  25962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25964. return
  25965. }
  25966. var respJSON map[string]interface{}
  25967. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25970. return
  25971. }
  25972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25973. userJSONBytes, _ := json.Marshal(respJSON)
  25974. var res ResultEight
  25975. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25976. utils.ErrorLog("解析失败:%v", err)
  25977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25978. return
  25979. }
  25980. }
  25981. func (c *HisApiController) Check390() {
  25982. adminUser := c.GetAdminUserInfo()
  25983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25984. var user_name string
  25985. user_name = "高慧裕"
  25986. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25987. "insutype=" + "390" +
  25988. "&clr_type=" + "" +
  25989. "&setl_optins=" + "441202" +
  25990. "&stmt_begndate=" + "2022-03-01" +
  25991. "&stm_enddate=" + "2022-03-31" +
  25992. "&medfee_sumamt=" + "1068448.89" +
  25993. "&fund_pay_sumamt=" + "1014677.62" +
  25994. "&acct_pay=" + "0" +
  25995. "&fixmedins_setl_cnt=" + "1950" +
  25996. "&fixmedins_code=" + miConfig.Code +
  25997. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25998. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25999. "&secret_key=" + miConfig.SecretKey +
  26000. "&org_name=" + miConfig.OrgName +
  26001. "&doctor=" + user_name
  26002. fmt.Println(api)
  26003. resp, requestErr := http.Get(api)
  26004. if requestErr != nil {
  26005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26006. return
  26007. }
  26008. body, ioErr := ioutil.ReadAll(resp.Body)
  26009. fmt.Println(body)
  26010. if ioErr != nil {
  26011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26013. return
  26014. }
  26015. var respJSON map[string]interface{}
  26016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26019. return
  26020. }
  26021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26022. userJSONBytes, _ := json.Marshal(respJSON)
  26023. var res ResultEight
  26024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26025. utils.ErrorLog("解析失败:%v", err)
  26026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26027. return
  26028. }
  26029. }
  26030. // 对账明细
  26031. func (c *HisApiController) GetCheckDetailAccount() {
  26032. start_time := c.GetString("start_time")
  26033. end_time := c.GetString("end_time")
  26034. admin_user_id, _ := c.GetInt64("admin_user_id")
  26035. adminUser := c.GetAdminUserInfo()
  26036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26037. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26038. timeLayout := "2006-01-02"
  26039. loc, _ := time.LoadLocation("Local")
  26040. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  26041. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  26042. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  26043. rand.Seed(time.Now().UnixNano())
  26044. num := rand.Intn(30000)
  26045. Mkdir(miConfig.OrgName)
  26046. file := strconv.FormatInt(int64(num), 10)
  26047. file_name := file + ".txt"
  26048. zip_name := file + ".zip"
  26049. zip_path := miConfig.OrgName + "/" + zip_name
  26050. file_path := miConfig.OrgName + "/" + file_name
  26051. decimal.DivisionPrecision = 2
  26052. var medfee_sumamt float64
  26053. var psn_cash_pay float64
  26054. var fund_pay_sumamt float64
  26055. fixmedins_setl_cnt := int64(len(orders))
  26056. for _, item := range orders {
  26057. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  26058. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  26059. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  26060. }
  26061. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  26062. defer f.Close()
  26063. if err != nil {
  26064. fmt.Println(err.Error())
  26065. } else {
  26066. for _, item := range orders {
  26067. var refd_setl_flag string
  26068. if item.OrderStatus == 2 {
  26069. refd_setl_flag = "0"
  26070. var str string
  26071. str = item.SetlId + " " +
  26072. item.MdtrtId + " " +
  26073. item.PsnNo + " " +
  26074. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26075. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26076. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  26077. _, err = f.Write([]byte(str))
  26078. }
  26079. if item.OrderStatus == 3 {
  26080. var str string
  26081. str = item.SetlId + " " +
  26082. item.MdtrtId + " " +
  26083. item.PsnNo + " " +
  26084. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  26085. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  26086. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  26087. _, err = f.Write([]byte(str))
  26088. var str2 string
  26089. str2 = item.SetlId + " " +
  26090. item.MdtrtId + " " +
  26091. item.PsnNo + " " +
  26092. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26093. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26094. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26095. _, err = f.Write([]byte(str2))
  26096. }
  26097. }
  26098. }
  26099. Zip(file_path, zip_path)
  26100. fmt.Println(ReadFile(zip_path))
  26101. fmt.Println(string(ReadFile(zip_path)))
  26102. if config.IsOpen == 1 {
  26103. var user_name string
  26104. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26105. if role.ID == 0 {
  26106. user_name = "管理员"
  26107. } else {
  26108. user_name = role.UserName
  26109. }
  26110. baseParams := models.BaseParams{
  26111. SecretKey: miConfig.SecretKey,
  26112. FixmedinsCode: miConfig.Code,
  26113. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26114. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26115. OrgName: miConfig.OrgName,
  26116. Doctor: user_name,
  26117. }
  26118. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26119. var dat map[string]interface{}
  26120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26121. fmt.Println(dat)
  26122. } else {
  26123. fmt.Println(err)
  26124. }
  26125. userJSONBytes, _ := json.Marshal(dat)
  26126. var res ResultNine
  26127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26128. utils.ErrorLog("解析失败:%v", err)
  26129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26130. return
  26131. }
  26132. if res.Infcode == 0 {
  26133. fileNo := res.Output.FileQuryNo
  26134. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26135. "file_qury_no=" + fileNo +
  26136. "&setl_optins=" + "定点医保中心" +
  26137. "&stmt_begndate=" + start_time +
  26138. "&stm_enddate=" + end_time +
  26139. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26140. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26141. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26142. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26143. "&fixmedins_code=" + miConfig.Code +
  26144. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26145. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26146. "&secret_key=" + miConfig.SecretKey +
  26147. "&org_name=" + miConfig.OrgName +
  26148. "&doctor=" + user_name
  26149. resp, requestErr := http.Get(api)
  26150. if requestErr != nil {
  26151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26152. return
  26153. }
  26154. body, ioErr := ioutil.ReadAll(resp.Body)
  26155. if ioErr != nil {
  26156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26158. return
  26159. }
  26160. var respJSON map[string]interface{}
  26161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26164. return
  26165. }
  26166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26167. userJSONBytes, _ := json.Marshal(respJSON)
  26168. var res ResultTen
  26169. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26170. utils.ErrorLog("解析失败:%v", err)
  26171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26172. return
  26173. }
  26174. if res.Infcode == 0 {
  26175. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26176. micc := &models.MedicalInsuranceCostCompare{
  26177. StartTime: startime.Unix(),
  26178. EndTime: endtime.Unix(),
  26179. Insutype: "0",
  26180. CheckType: 2,
  26181. Num: fixmedins_setl_cnt,
  26182. Mtime: time.Now().Unix(),
  26183. Status: 1,
  26184. UserOrgId: adminUser.CurrentOrgId,
  26185. CostTotal: medfee_sumamt,
  26186. FuncTotal: fund_pay_sumamt,
  26187. PsnPay: psn_cash_pay,
  26188. Creator: admin_user_id,
  26189. Ctime: time.Now().Unix(),
  26190. }
  26191. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26192. c.ServeSuccessJSON(map[string]interface{}{
  26193. "msg": "明细对账成功",
  26194. })
  26195. }
  26196. } else {
  26197. }
  26198. }
  26199. }
  26200. type CustomOrderInfo struct {
  26201. Name string
  26202. Spec string
  26203. Unit string
  26204. Count float64
  26205. Price float64
  26206. Total float64
  26207. }
  26208. func (c *HisApiController) GetBatchSettleAccounts() {
  26209. admin_user_id, _ := c.GetInt64("admin_user_id")
  26210. order_ids := c.GetString("order_ids")
  26211. order_ids_arr := strings.Split(order_ids, ",")
  26212. data3 := []map[string]interface{}{}
  26213. for _, item := range order_ids_arr {
  26214. id, _ := strconv.ParseInt(item, 10, 64)
  26215. order_id := id
  26216. adminUser := c.GetAdminUserInfo()
  26217. order, _ := service.GetHisOrderByID(order_id)
  26218. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26219. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26220. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26221. orderInfos = append(orderInfos, orderInfos_two...)
  26222. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26223. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26224. var diagnosis_ids []string
  26225. if his.ID > 0 {
  26226. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26227. } else {
  26228. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26229. }
  26230. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26231. var dia_config []*models.HisXtDiagnoseConfig
  26232. var name string
  26233. for _, item := range diagnosis_ids {
  26234. id, _ := strconv.ParseInt(item, 10, 64)
  26235. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26236. dia_config = append(dia_config, &diagnosisConfig)
  26237. if len(name) == 0 {
  26238. name = diagnosisConfig.ClassName
  26239. }
  26240. //} else {
  26241. // name = name + "," + diagnosisConfig.ClassName
  26242. //}
  26243. }
  26244. var bedCostTotal float64 = 0 //床位总费
  26245. var bedCostSelfTotal float64 = 0 //床位自费
  26246. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26247. var bedSelfTotal float64 = 0 //床位部分项目自费
  26248. var bedInscpTotal float64 = 0 //床位部分项目自费
  26249. var operationCostTotal float64 = 0 //手术费
  26250. var operationCostSelfTotal float64 = 0 //手术费
  26251. var operationCostPartSelfTotal float64 = 0 //手术费
  26252. var operationSelfTotal float64 = 0 //床位部分项目自费
  26253. var operationInscpTotal float64 = 0 //床位部分项目自费
  26254. var otherCostTotal float64 = 0 //其他费用
  26255. var otherCostSelfTotal float64 = 0 //其他费用
  26256. var otherCostPartSelfTotal float64 = 0 //其他费用
  26257. var otherSelfTotal float64 = 0 //床位部分项目自费
  26258. var otherInscpTotal float64 = 0 //床位部分项目自费
  26259. var materialCostTotal float64 = 0 //材料费
  26260. var materialCostSelfTotal float64 = 0 //材料费
  26261. var materialCostPartSelfTotal float64 = 0 //材料费
  26262. var materialSelfTotal float64 = 0 //床位部分项目自费
  26263. var materialInscpTotal float64 = 0 //床位部分项目自费
  26264. var westernMedicineCostTotal float64 = 0 //西药费
  26265. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26266. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26267. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26268. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26269. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26270. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26271. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26272. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26273. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26274. var checkCostTotal float64 = 0 //检查费
  26275. var checkCostSelfTotal float64 = 0 //检查费
  26276. var checkCostPartSelfTotal float64 = 0 //检查费
  26277. var checkSelfTotal float64 = 0 //床位部分项目自费
  26278. var checkInscpTotal float64 = 0 //床位部分项目自费
  26279. var laboratoryCostTotal float64 = 0 //化验费
  26280. var laboratoryCostSelfTotal float64 = 0 //化验费
  26281. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26282. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26283. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26284. var treatCostTotal float64 = 0 //治疗费用
  26285. var treatCostSelfTotal float64 = 0 //治疗费用
  26286. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26287. var treatSelfTotal float64 = 0 //床位部分项目自费
  26288. var treatInscpTotal float64 = 0 //床位部分项目自费
  26289. decimal.DivisionPrecision = 2
  26290. for _, item := range orderInfos {
  26291. if item.MedChrgitmType == "01" { //床位费
  26292. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26293. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26294. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26295. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26296. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26297. }
  26298. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26299. if item.MedChrgitmType == "03" { //检查费
  26300. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26301. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26302. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26303. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26304. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26305. }
  26306. } else {
  26307. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26308. fmt.Println("------------")
  26309. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26310. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26311. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26312. }
  26313. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26314. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26315. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26316. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26317. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26318. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26319. }
  26320. }
  26321. if item.MedChrgitmType == "04" { //化验费
  26322. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26323. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26324. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26325. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26326. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26327. }
  26328. if item.MedChrgitmType == "05" { //治疗费
  26329. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26330. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26331. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26332. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26333. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26334. }
  26335. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26336. fmt.Println("------------")
  26337. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26338. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26339. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26340. }
  26341. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26342. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26343. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26344. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26345. }
  26346. //if item.MedChrgitmType == "06" { //手术费
  26347. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26348. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26349. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26350. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26351. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26352. //
  26353. //}
  26354. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26355. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26356. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26357. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26358. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26359. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26360. }
  26361. if item.MedChrgitmType == "09" { //西药费
  26362. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26363. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26364. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26365. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26366. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26367. }
  26368. if item.MedChrgitmType == "11" { //中成费
  26369. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26370. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26371. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26372. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26373. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26374. }
  26375. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26376. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26377. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26378. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26379. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26380. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26381. }
  26382. }
  26383. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26384. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26385. var user_name string
  26386. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26387. if role.ID == 0 {
  26388. user_name = "管理员"
  26389. } else {
  26390. user_name = role.UserName
  26391. }
  26392. baseParams := models.BaseParams{
  26393. SecretKey: miConfig.SecretKey,
  26394. FixmedinsCode: miConfig.Code,
  26395. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26396. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26397. OrgName: miConfig.OrgName,
  26398. Doctor: user_name,
  26399. RequestUrl: miConfig.Url,
  26400. AccessKey: miConfig.AccessKey,
  26401. }
  26402. businessParams := models.BusinessParams{
  26403. PsnNo: order.PsnNo,
  26404. MdtrtId: order.MdtrtId,
  26405. SetlId: order.SetlId,
  26406. }
  26407. var res ResultEleven
  26408. var resEleven10265 ResultEleven10265
  26409. if config.IsOpen == 1 {
  26410. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26411. result := service.Gdyb5203(baseParams, businessParams)
  26412. service.Gdyb5204(baseParams, businessParams)
  26413. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26414. var dat map[string]interface{}
  26415. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26416. fmt.Println(dat)
  26417. } else {
  26418. fmt.Println(err)
  26419. }
  26420. userJSONBytes, _ := json.Marshal(dat)
  26421. if miConfig.Code == "H15049901371" {
  26422. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26423. utils.ErrorLog("解析失败:%v", err)
  26424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26425. return
  26426. }
  26427. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26428. res.Output = resEleven10265.Output
  26429. res.ErrMsg = resEleven10265.ErrMsg
  26430. res.Cainfo = resEleven10265.Cainfo
  26431. res.WarnMsg = resEleven10265.WarnMsg
  26432. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26433. res.Infcode = infocode
  26434. } else {
  26435. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26436. utils.ErrorLog("解析失败:%v", err)
  26437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26438. return
  26439. }
  26440. }
  26441. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26442. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26443. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26444. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26445. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26446. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26447. var doctor_name string
  26448. if roles.ID == 0 {
  26449. doctor_name = "管理员"
  26450. } else {
  26451. doctor_name = roles.UserName
  26452. }
  26453. yiliao_leibie := ""
  26454. switch order.MedType {
  26455. case "11":
  26456. yiliao_leibie = "普通门诊"
  26457. break
  26458. case "12":
  26459. yiliao_leibie = "门诊挂号"
  26460. break
  26461. case "13":
  26462. yiliao_leibie = "急诊"
  26463. break
  26464. case "14":
  26465. yiliao_leibie = "门诊特殊病"
  26466. break
  26467. case "15":
  26468. yiliao_leibie = "门诊统筹"
  26469. break
  26470. case "16":
  26471. yiliao_leibie = "门诊慢性病"
  26472. break
  26473. case "21":
  26474. yiliao_leibie = "普通住院"
  26475. break
  26476. }
  26477. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26478. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26479. if res.Infcode == 0 {
  26480. data2 := map[string]interface{}{
  26481. "diagnosis": name,
  26482. "order_infos": orderInfos,
  26483. "number": order.MdtrtId,
  26484. "date": order.SettleAccountsDate,
  26485. "charge_admin": charge_admin,
  26486. "printor_admin": printor_admin,
  26487. "info": res.Output.Setlinfo,
  26488. "order": order,
  26489. "bedCostTotal": bedCostTotal,
  26490. "bedCostSelfTotal": bedCostSelfTotal,
  26491. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26492. "bedSelfTotal": bedSelfTotal,
  26493. "bedInscpTotal": bedInscpTotal,
  26494. "operationCostTotal": operationCostTotal,
  26495. "operationCostSelfTotal": operationCostSelfTotal,
  26496. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26497. "operationSelfTotal": operationSelfTotal,
  26498. "operationInscpTotal": operationInscpTotal,
  26499. "otherCostTotal": otherCostTotal,
  26500. "otherCostSelfTotal": otherCostSelfTotal,
  26501. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26502. "otherSelfTotal": otherSelfTotal,
  26503. "otherInscpTotal": otherInscpTotal,
  26504. "materialCostTotal": materialCostTotal,
  26505. "materialCostSelfTotal": materialCostSelfTotal,
  26506. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26507. "materialSelfTotal": materialSelfTotal,
  26508. "materialInscpTotal": materialInscpTotal,
  26509. "westernMedicineCostTotal": westernMedicineCostTotal,
  26510. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26511. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26512. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26513. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26514. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26515. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26516. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26517. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26518. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26519. "checkCostTotal": checkCostTotal,
  26520. "checkCostSelfTotal": checkCostSelfTotal,
  26521. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26522. "checkSelfTotal": checkSelfTotal,
  26523. "checkInscpTotal": checkInscpTotal,
  26524. "laboratoryCostTotal": laboratoryCostTotal,
  26525. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26526. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26527. "laboratorySelfTotal": laboratorySelfTotal,
  26528. "laboratoryInscpTotal": laboratoryInscpTotal,
  26529. "treatCostTotal": treatCostTotal,
  26530. "treatCostSelfTotal": treatCostSelfTotal,
  26531. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26532. "treatSelfTotal": treatSelfTotal,
  26533. "treatInscpTotal": treatInscpTotal,
  26534. "doctor_info": doctor_info,
  26535. "doctor_code": adminRole_two.DoctorCode,
  26536. "doctor_name": doctor_name,
  26537. "health_card_no": order.PsnNo,
  26538. "department": departments.Name,
  26539. "yiliao_leibie": yiliao_leibie,
  26540. "after_money": order.AccountPrice,
  26541. "patient": patient,
  26542. "org_name": miConfig.OrgName,
  26543. "org_code": miConfig.Code,
  26544. "order_number": order.Number,
  26545. "his_hospital": his_hospital,
  26546. "his": his,
  26547. "dia_config": dia_config,
  26548. "psn_cash_pay": order.PsnCashPay,
  26549. //"check_order_info": cus_slice,
  26550. }
  26551. data3 = append(data3, data2)
  26552. }
  26553. }
  26554. }
  26555. c.ServeSuccessJSON(map[string]interface{}{
  26556. "infos": data3,
  26557. })
  26558. }
  26559. func (c *HisApiController) GetSettleAccounts() {
  26560. //id, _ := c.GetInt64("id")
  26561. //record_time := c.GetString("record_time")
  26562. order_id, _ := c.GetInt64("order_id")
  26563. admin_user_id, _ := c.GetInt64("admin_user_id")
  26564. //timeLayout := "2006-01-02"
  26565. //loc, _ := time.LoadLocation("Local")
  26566. //
  26567. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26568. //if err != nil {
  26569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26570. // return
  26571. //}Hbyb5203
  26572. //recordDateTime := theTime.Unix()
  26573. adminUser := c.GetAdminUserInfo()
  26574. order, _ := service.GetHisOrderByID(order_id)
  26575. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26576. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26577. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26578. orderInfos = append(orderInfos, orderInfos_two...)
  26579. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26580. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26581. var diagnosis_ids []string
  26582. if his.ID > 0 {
  26583. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26584. } else {
  26585. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26586. }
  26587. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26588. var dia_config []*models.HisXtDiagnoseConfig
  26589. var name string
  26590. for _, item := range diagnosis_ids {
  26591. id, _ := strconv.ParseInt(item, 10, 64)
  26592. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26593. dia_config = append(dia_config, &diagnosisConfig)
  26594. if len(name) == 0 {
  26595. name = diagnosisConfig.ClassName
  26596. } else {
  26597. name = name + "," + diagnosisConfig.ClassName
  26598. }
  26599. }
  26600. if patient.UserOrgId == 10215 {
  26601. name = "慢性肾功能不全(血透治疗)"
  26602. }
  26603. var bedCostTotal float64 = 0 //床位总费
  26604. var bedCostSelfTotal float64 = 0 //床位自费
  26605. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26606. var bedSelfTotal float64 = 0 //床位部分项目自费
  26607. var bedInscpTotal float64 = 0 //床位部分项目自费
  26608. var operationCostTotal float64 = 0 //手术费
  26609. var operationCostSelfTotal float64 = 0 //手术费
  26610. var operationCostPartSelfTotal float64 = 0 //手术费
  26611. var operationSelfTotal float64 = 0 //床位部分项目自费
  26612. var operationInscpTotal float64 = 0 //床位部分项目自费
  26613. var otherCostTotal float64 = 0 //其他费用
  26614. var otherCostSelfTotal float64 = 0 //其他费用
  26615. var otherCostPartSelfTotal float64 = 0 //其他费用
  26616. var otherSelfTotal float64 = 0 //床位部分项目自费
  26617. var otherInscpTotal float64 = 0 //床位部分项目自费
  26618. var materialCostTotal float64 = 0 //材料费
  26619. var materialCostSelfTotal float64 = 0 //材料费
  26620. var materialCostPartSelfTotal float64 = 0 //材料费
  26621. var materialSelfTotal float64 = 0 //床位部分项目自费
  26622. var materialInscpTotal float64 = 0 //床位部分项目自费
  26623. var westernMedicineCostTotal float64 = 0 //西药费
  26624. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26625. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26626. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26627. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26628. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26629. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26630. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26631. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26632. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26633. var checkCostTotal float64 = 0 //检查费
  26634. var checkCostSelfTotal float64 = 0 //检查费
  26635. var checkCostPartSelfTotal float64 = 0 //检查费
  26636. var checkSelfTotal float64 = 0 //床位部分项目自费
  26637. var checkInscpTotal float64 = 0 //床位部分项目自费
  26638. var laboratoryCostTotal float64 = 0 //化验费
  26639. var laboratoryCostSelfTotal float64 = 0 //化验费
  26640. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26641. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26642. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26643. var treatCostTotal float64 = 0 //治疗费用
  26644. var treatCostSelfTotal float64 = 0 //治疗费用
  26645. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26646. var treatSelfTotal float64 = 0 //床位部分项目自费
  26647. var treatInscpTotal float64 = 0 //床位部分项目自费
  26648. decimal.DivisionPrecision = 2
  26649. for _, item := range orderInfos {
  26650. if item.MedChrgitmType == "01" { //床位费
  26651. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26652. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26653. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26654. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26655. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26656. }
  26657. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26658. if item.MedChrgitmType == "03" { //检查费
  26659. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26660. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26661. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26662. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26663. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26664. }
  26665. } else {
  26666. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26667. fmt.Println("------------")
  26668. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26669. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26670. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26671. }
  26672. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26673. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26674. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26675. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26676. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26677. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26678. }
  26679. }
  26680. if item.MedChrgitmType == "04" { //化验费
  26681. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26682. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26683. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26684. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26685. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26686. }
  26687. if item.MedChrgitmType == "05" { //治疗费
  26688. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26689. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26690. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26691. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26692. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26693. }
  26694. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26695. fmt.Println("------------")
  26696. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26697. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26698. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26699. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26700. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26701. }
  26702. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26703. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26704. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26705. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26706. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26707. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26708. }
  26709. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26710. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26711. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26712. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26713. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26714. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26715. }
  26716. if item.MedChrgitmType == "09" { //西药费
  26717. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26718. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26719. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26720. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26721. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26722. }
  26723. if item.MedChrgitmType == "11" { //中成费
  26724. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26725. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26726. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26727. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26728. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26729. }
  26730. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26731. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26732. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26733. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26734. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26735. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26736. }
  26737. }
  26738. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26740. var user_name string
  26741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26742. if role.ID == 0 {
  26743. user_name = "管理员"
  26744. } else {
  26745. user_name = role.UserName
  26746. }
  26747. baseParams := models.BaseParams{
  26748. SecretKey: miConfig.SecretKey,
  26749. FixmedinsCode: miConfig.Code,
  26750. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26751. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26752. OrgName: miConfig.OrgName,
  26753. Doctor: user_name,
  26754. RequestUrl: miConfig.Url,
  26755. AccessKey: miConfig.AccessKey,
  26756. }
  26757. businessParams := models.BusinessParams{
  26758. PsnNo: order.PsnNo,
  26759. MdtrtId: order.MdtrtId,
  26760. SetlId: order.SetlId,
  26761. }
  26762. var res ResultEleven
  26763. var resah ResultElevenah
  26764. var resEleven10265 ResultEleven10265
  26765. if config.IsOpen == 1 {
  26766. if miConfig.MdtrtareaAdmvs == "421300" {
  26767. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26768. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26769. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26770. resp, requestErr := http.Get(api)
  26771. if requestErr != nil {
  26772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26773. return
  26774. }
  26775. body, ioErr := ioutil.ReadAll(resp.Body)
  26776. if ioErr != nil {
  26777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26779. return
  26780. }
  26781. var respJSON map[string]interface{}
  26782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26785. return
  26786. }
  26787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26788. result, _ := json.Marshal(respJSON)
  26789. fmt.Println("log")
  26790. fmt.Println(string(result))
  26791. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26792. utils.ErrorLog("解析失败:%v", err)
  26793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26794. return
  26795. }
  26796. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26797. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26798. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26799. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26800. resp, requestErr := http.Get(api)
  26801. if requestErr != nil {
  26802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26803. return
  26804. }
  26805. body, ioErr := ioutil.ReadAll(resp.Body)
  26806. if ioErr != nil {
  26807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26809. return
  26810. }
  26811. var respJSON map[string]interface{}
  26812. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26815. return
  26816. }
  26817. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26818. result, _ := json.Marshal(respJSON)
  26819. fmt.Println("log")
  26820. fmt.Println(string(result))
  26821. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26822. utils.ErrorLog("解析失败:%v", err)
  26823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26824. return
  26825. }
  26826. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26827. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26828. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26829. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26830. resp, requestErr := http.Get(api)
  26831. if requestErr != nil {
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. body, ioErr := ioutil.ReadAll(resp.Body)
  26836. if ioErr != nil {
  26837. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26839. return
  26840. }
  26841. var respJSON map[string]interface{}
  26842. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26845. return
  26846. }
  26847. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26848. result, _ := json.Marshal(respJSON)
  26849. fmt.Println("log")
  26850. fmt.Println(string(result))
  26851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26852. utils.ErrorLog("解析失败:%v", err)
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26854. return
  26855. }
  26856. }else if miConfig.MdtrtareaAdmvs == "421182" {
  26857. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26858. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  26860. resp, requestErr := http.Get(api)
  26861. if requestErr != nil {
  26862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26863. return
  26864. }
  26865. body, ioErr := ioutil.ReadAll(resp.Body)
  26866. if ioErr != nil {
  26867. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26869. return
  26870. }
  26871. var respJSON map[string]interface{}
  26872. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26873. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26878. result, _ := json.Marshal(respJSON)
  26879. fmt.Println("log")
  26880. fmt.Println(string(result))
  26881. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26882. utils.ErrorLog("解析失败:%v", err)
  26883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26884. return
  26885. }
  26886. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26887. var api string
  26888. if miConfig.MdtrtareaAdmvs == "320921" {
  26889. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26890. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26891. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26892. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26893. } else {
  26894. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26895. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26896. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26897. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26898. }
  26899. resp, requestErr := http.Get(api)
  26900. if requestErr != nil {
  26901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26902. return
  26903. }
  26904. body, ioErr := ioutil.ReadAll(resp.Body)
  26905. if ioErr != nil {
  26906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26908. return
  26909. }
  26910. var respJSON map[string]interface{}
  26911. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26914. return
  26915. }
  26916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26917. result, _ := json.Marshal(respJSON)
  26918. fmt.Println("log")
  26919. fmt.Println(string(result))
  26920. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26921. utils.ErrorLog("解析失败:%v", err)
  26922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26923. return
  26924. }
  26925. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26926. res.Output = resEleven10265.Output
  26927. res.ErrMsg = resEleven10265.ErrMsg
  26928. res.Cainfo = resEleven10265.Cainfo
  26929. res.WarnMsg = resEleven10265.WarnMsg
  26930. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26931. res.Infcode = infocode
  26932. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26933. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26934. saveLog(result, requestLog, "5203", "结算单")
  26935. var dat map[string]interface{}
  26936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26937. fmt.Println(dat)
  26938. } else {
  26939. fmt.Println(err)
  26940. }
  26941. userJSONBytes, _ := json.Marshal(dat)
  26942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26943. utils.ErrorLog("解析失败:%v", err)
  26944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26945. return
  26946. }
  26947. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26948. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26949. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26950. fmt.Println(result3)
  26951. fmt.Println(requestLog3)
  26952. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26953. fmt.Println(result2)
  26954. fmt.Println(requestLog2)
  26955. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26956. saveLog(result, requestLog, "5203", "结算单")
  26957. var dat map[string]interface{}
  26958. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26959. fmt.Println(dat)
  26960. } else {
  26961. fmt.Println(err)
  26962. }
  26963. userJSONBytes, _ := json.Marshal(dat)
  26964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26965. utils.ErrorLog("解析失败:%v", err)
  26966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26967. return
  26968. }
  26969. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26970. var api string
  26971. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26972. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26973. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26974. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26975. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26976. resp, requestErr := http.Get(api)
  26977. if requestErr != nil {
  26978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26979. return
  26980. }
  26981. body, ioErr := ioutil.ReadAll(resp.Body)
  26982. if ioErr != nil {
  26983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26985. return
  26986. }
  26987. var respJSON map[string]interface{}
  26988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26991. return
  26992. }
  26993. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26994. if status == "0" {
  26995. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26996. c.ServeSuccessJSON(map[string]interface{}{
  26997. "failed_code": -10,
  26998. "msg": err_msg,
  26999. })
  27000. return
  27001. }
  27002. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27003. result, _ := json.Marshal(respJSON)
  27004. fmt.Println("log")
  27005. fmt.Println(string(result))
  27006. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  27007. utils.ErrorLog("解析失败:%v", err)
  27008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27009. return
  27010. }
  27011. res.InfRefmsgid = resah.InfRefmsgid
  27012. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27013. // 创建对应的Time类型
  27014. t := time.UnixMilli(timestamp)
  27015. // 格式化成指定的日期字符串
  27016. str := t.Format("2006-01-02 15:04:05")
  27017. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  27018. // 创建对应的Time类型
  27019. t3 := time.UnixMilli(timestamp2)
  27020. // 格式化成指定的日期字符串
  27021. str2 := t3.Format("2006-01-02 15:04:05")
  27022. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  27023. // 创建对应的Time类型
  27024. t4 := time.UnixMilli(timestamp3)
  27025. // 格式化成指定的日期字符串
  27026. str3 := t4.Format("2006-01-02 15:04:05")
  27027. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  27028. // 创建对应的Time类型
  27029. t5 := time.UnixMilli(timestamp4)
  27030. // 格式化成指定的日期字符串
  27031. str5 := t5.Format("2006-01-02 15:04:05")
  27032. res.Output.Setlinfo.Brdy = str2
  27033. res.Output.Setlinfo.SetlTime = str
  27034. res.Output.Setlinfo.Begndate = str3
  27035. res.Output.Setlinfo.Enddate = str5
  27036. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  27037. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  27038. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  27039. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  27040. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27041. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27042. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  27043. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  27044. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27045. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  27046. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  27047. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  27048. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  27049. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  27050. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  27051. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  27052. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  27053. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  27054. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  27055. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  27056. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  27057. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  27058. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  27059. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  27060. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  27061. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  27062. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  27063. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  27064. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  27065. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  27066. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  27067. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  27068. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  27069. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  27070. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  27071. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  27072. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  27073. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  27074. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  27075. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  27076. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  27077. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  27078. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  27079. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  27080. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  27081. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  27082. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  27083. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  27084. //res.Output.Setldetail = resah.Output.Setldetail
  27085. res.ErrMsg = resah.ErrMsg
  27086. res.Cainfo = resah.Cainfo
  27087. res.WarnMsg = resah.WarnMsg
  27088. } else if miConfig.MdtrtareaAdmvs == "430800" {
  27089. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  27090. saveLog(result, requestLog, "5203", "结算单")
  27091. var dat map[string]interface{}
  27092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27093. fmt.Println(dat)
  27094. } else {
  27095. fmt.Println(err)
  27096. }
  27097. userJSONBytes, _ := json.Marshal(dat)
  27098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27099. utils.ErrorLog("解析失败:%v", err)
  27100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27101. return
  27102. }
  27103. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27104. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27105. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27107. resp, requestErr := http.Get(api)
  27108. if requestErr != nil {
  27109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27110. return
  27111. }
  27112. body, ioErr := ioutil.ReadAll(resp.Body)
  27113. if ioErr != nil {
  27114. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27116. return
  27117. }
  27118. var respJSON map[string]interface{}
  27119. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27120. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27122. return
  27123. }
  27124. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27125. result, _ := json.Marshal(respJSON)
  27126. fmt.Println("log")
  27127. fmt.Println(string(result))
  27128. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27129. utils.ErrorLog("解析失败:%v", err)
  27130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27131. return
  27132. }
  27133. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27134. res.Output = resEleven10265.Output
  27135. res.ErrMsg = resEleven10265.ErrMsg
  27136. res.Cainfo = resEleven10265.Cainfo
  27137. res.WarnMsg = resEleven10265.WarnMsg
  27138. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27139. res.Infcode = infocode
  27140. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27141. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27142. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27143. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27144. resp, requestErr := http.Get(api)
  27145. if requestErr != nil {
  27146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27147. return
  27148. }
  27149. body, ioErr := ioutil.ReadAll(resp.Body)
  27150. if ioErr != nil {
  27151. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27153. return
  27154. }
  27155. var respJSON map[string]interface{}
  27156. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27157. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27159. return
  27160. }
  27161. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27162. result, _ := json.Marshal(respJSON)
  27163. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27164. utils.ErrorLog("解析失败:%v", err)
  27165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27166. return
  27167. }
  27168. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27169. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27170. //return
  27171. } else {
  27172. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27173. if len(his.InsuplcAdmdvs) == 0 {
  27174. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27175. } else {
  27176. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27177. }
  27178. result := service.Gdyb5203(baseParams, businessParams)
  27179. //service.Gdyb5204(baseParams, businessParams)
  27180. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27181. var dat map[string]interface{}
  27182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27183. fmt.Println(dat)
  27184. } else {
  27185. fmt.Println(err)
  27186. }
  27187. userJSONBytes, _ := json.Marshal(dat)
  27188. if miConfig.Code == "H15049901371" {
  27189. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27190. utils.ErrorLog("解析失败:%v", err)
  27191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27192. return
  27193. }
  27194. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27195. res.Output = resEleven10265.Output
  27196. res.ErrMsg = resEleven10265.ErrMsg
  27197. res.Cainfo = resEleven10265.Cainfo
  27198. res.WarnMsg = resEleven10265.WarnMsg
  27199. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27200. res.Infcode = infocode
  27201. } else {
  27202. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27203. utils.ErrorLog("解析失败:%v", err)
  27204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27205. return
  27206. }
  27207. }
  27208. }
  27209. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27210. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27211. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27212. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27213. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27214. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27215. var doctor_name string
  27216. if roles.ID == 0 {
  27217. doctor_name = "管理员"
  27218. } else {
  27219. doctor_name = roles.UserName
  27220. }
  27221. yiliao_leibie := ""
  27222. switch order.MedType {
  27223. case "11":
  27224. yiliao_leibie = "普通门诊"
  27225. break
  27226. case "12":
  27227. yiliao_leibie = "门诊挂号"
  27228. break
  27229. case "13":
  27230. yiliao_leibie = "急诊"
  27231. break
  27232. case "14":
  27233. yiliao_leibie = "门诊特殊病"
  27234. break
  27235. case "15":
  27236. yiliao_leibie = "门诊统筹"
  27237. break
  27238. case "16":
  27239. yiliao_leibie = "门诊慢性病"
  27240. break
  27241. case "21":
  27242. yiliao_leibie = "普通住院"
  27243. break
  27244. }
  27245. //var rf []CustomFundPay
  27246. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27247. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27248. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27249. if res.Infcode == 0 {
  27250. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27251. c.ServeSuccessJSON(map[string]interface{}{
  27252. "diagnosis": name,
  27253. "order_infos": orderInfos,
  27254. "number": order.MdtrtId,
  27255. "date": order.SettleAccountsDate,
  27256. "charge_admin": charge_admin,
  27257. "printor_admin": printor_admin,
  27258. "info": res.Output.Setlinfo,
  27259. "order": order,
  27260. "bedCostTotal": bedCostTotal,
  27261. "bedCostSelfTotal": bedCostSelfTotal,
  27262. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27263. "bedSelfTotal": bedSelfTotal,
  27264. "bedInscpTotal": bedInscpTotal,
  27265. "operationCostTotal": operationCostTotal,
  27266. "operationCostSelfTotal": operationCostSelfTotal,
  27267. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27268. "operationSelfTotal": operationSelfTotal,
  27269. "operationInscpTotal": operationInscpTotal,
  27270. "otherCostTotal": otherCostTotal,
  27271. "otherCostSelfTotal": otherCostSelfTotal,
  27272. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27273. "otherSelfTotal": otherSelfTotal,
  27274. "otherInscpTotal": otherInscpTotal,
  27275. "materialCostTotal": materialCostTotal,
  27276. "materialCostSelfTotal": materialCostSelfTotal,
  27277. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27278. "materialSelfTotal": materialSelfTotal,
  27279. "materialInscpTotal": materialInscpTotal,
  27280. "westernMedicineCostTotal": westernMedicineCostTotal,
  27281. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27282. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27283. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27284. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27285. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27286. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27287. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27288. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27289. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27290. "checkCostTotal": checkCostTotal,
  27291. "checkCostSelfTotal": checkCostSelfTotal,
  27292. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27293. "checkSelfTotal": checkSelfTotal,
  27294. "checkInscpTotal": checkInscpTotal,
  27295. "laboratoryCostTotal": laboratoryCostTotal,
  27296. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27297. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27298. "laboratorySelfTotal": laboratorySelfTotal,
  27299. "laboratoryInscpTotal": laboratoryInscpTotal,
  27300. "treatCostTotal": treatCostTotal,
  27301. "treatCostSelfTotal": treatCostSelfTotal,
  27302. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27303. "treatSelfTotal": treatSelfTotal,
  27304. "treatInscpTotal": treatInscpTotal,
  27305. "doctor_info": doctor_info,
  27306. "doctor_code": adminRole_two.DoctorCode,
  27307. "doctor_name": doctor_name,
  27308. "health_card_no": order.PsnNo,
  27309. "department": departments.Name,
  27310. "yiliao_leibie": yiliao_leibie,
  27311. "after_money": order.AccountPrice,
  27312. "patient": patient,
  27313. "org_name": miConfig.OrgName,
  27314. "org_code": miConfig.Code,
  27315. "order_number": order.Number,
  27316. "his_hospital": his_hospital,
  27317. "his": his,
  27318. "dia_config": dia_config,
  27319. "psn_cash_pay": order.PsnCashPay,
  27320. //"funds": rf,
  27321. //"check_order_info": cus_slice,
  27322. })
  27323. } else {
  27324. c.ServeSuccessJSON(map[string]interface{}{
  27325. "diagnosis": name,
  27326. "order_infos": orderInfos,
  27327. "number": order.MdtrtId,
  27328. "date": order.SettleAccountsDate,
  27329. "charge_admin": charge_admin,
  27330. "printor_admin": printor_admin,
  27331. "info": order,
  27332. "order": order,
  27333. "bedCostTotal": bedCostTotal,
  27334. "bedCostSelfTotal": bedCostSelfTotal,
  27335. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27336. "bedSelfTotal": bedSelfTotal,
  27337. "bedInscpTotal": bedInscpTotal,
  27338. "operationCostTotal": operationCostTotal,
  27339. "operationCostSelfTotal": operationCostSelfTotal,
  27340. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27341. "operationSelfTotal": operationSelfTotal,
  27342. "operationInscpTotal": operationInscpTotal,
  27343. "otherCostTotal": otherCostTotal,
  27344. "otherCostSelfTotal": otherCostSelfTotal,
  27345. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27346. "otherSelfTotal": otherSelfTotal,
  27347. "otherInscpTotal": otherInscpTotal,
  27348. "materialCostTotal": materialCostTotal,
  27349. "materialCostSelfTotal": materialCostSelfTotal,
  27350. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27351. "materialSelfTotal": materialSelfTotal,
  27352. "materialInscpTotal": materialInscpTotal,
  27353. "westernMedicineCostTotal": westernMedicineCostTotal,
  27354. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27355. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27356. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27357. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27358. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27359. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27360. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27361. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27362. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27363. "checkCostTotal": checkCostTotal,
  27364. "checkCostSelfTotal": checkCostSelfTotal,
  27365. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27366. "checkSelfTotal": checkSelfTotal,
  27367. "checkInscpTotal": checkInscpTotal,
  27368. "laboratoryCostTotal": laboratoryCostTotal,
  27369. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27370. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27371. "laboratorySelfTotal": laboratorySelfTotal,
  27372. "laboratoryInscpTotal": laboratoryInscpTotal,
  27373. "treatCostTotal": treatCostTotal,
  27374. "treatCostSelfTotal": treatCostSelfTotal,
  27375. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27376. "treatSelfTotal": treatSelfTotal,
  27377. "treatInscpTotal": treatInscpTotal,
  27378. "doctor_info": doctor_info,
  27379. "doctor_code": adminRole_two.DoctorCode,
  27380. "doctor_name": doctor_name,
  27381. "health_card_no": order.PsnNo,
  27382. "department": departments.Name,
  27383. "yiliao_leibie": yiliao_leibie,
  27384. "after_money": order.AccountPrice,
  27385. "patient": patient,
  27386. "org_name": miConfig.OrgName,
  27387. "org_code": miConfig.Code,
  27388. "order_number": order.Number,
  27389. "his_hospital": his_hospital,
  27390. "his": his,
  27391. "dia_config": dia_config,
  27392. "psn_cash_pay": order.PsnCashPay,
  27393. //"funds": rf,
  27394. //"check_order_info": cus_slice,
  27395. })
  27396. }
  27397. }
  27398. }
  27399. }
  27400. //func (c *HisApiController) CheckTreatment() {
  27401. // patient_id, _ := c.GetInt64("patient_id")
  27402. // id_card_no := c.GetString("id_card_no")
  27403. // insutype := c.GetString("insutype")
  27404. // med_type := c.GetString("med_type")
  27405. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27406. //
  27407. // adminUser := c.GetAdminUserInfo()
  27408. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27409. //
  27410. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27411. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27412. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27413. //
  27414. // if miConfig.MdtrtareaAdmvs == "421300" {
  27415. // var res ResultTwo
  27416. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27417. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27418. // "&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)
  27419. // resp, requestErr := http.Get(api)
  27420. // if requestErr != nil {
  27421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27422. // return
  27423. // }
  27424. //
  27425. // body, ioErr := ioutil.ReadAll(resp.Body)
  27426. // if ioErr != nil {
  27427. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27429. // return
  27430. // }
  27431. // var respJSON map[string]interface{}
  27432. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27433. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27435. // return
  27436. // }
  27437. //
  27438. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27439. // result, _ := json.Marshal(respJSON)
  27440. //
  27441. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27442. // utils.ErrorLog("解析失败:%v", err)
  27443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27444. // return
  27445. // }
  27446. //
  27447. // if res.Infcode == 0 {
  27448. //
  27449. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27450. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27451. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27452. // resp, requestErr := http.Get(api)
  27453. // if requestErr != nil {
  27454. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27455. // return
  27456. // }
  27457. //
  27458. // body, ioErr := ioutil.ReadAll(resp.Body)
  27459. // if ioErr != nil {
  27460. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27462. // return
  27463. // }
  27464. // var respJSON map[string]interface{}
  27465. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27466. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27468. // return
  27469. // }
  27470. // var res Result2001
  27471. //
  27472. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27473. // result2, _ := json.Marshal(respJSON)
  27474. //
  27475. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27476. // utils.ErrorLog("解析失败:%v", err)
  27477. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27478. // return
  27479. // }
  27480. //
  27481. // if res.Infcode == 0 {
  27482. // c.ServeSuccessJSON(map[string]interface{}{
  27483. // "msg": res.Output.Trtinfo,
  27484. // })
  27485. // }
  27486. //
  27487. // } else {
  27488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27489. // return
  27490. // }
  27491. //
  27492. // } else {
  27493. //
  27494. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27495. // var dat map[string]interface{}
  27496. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27497. // fmt.Println(dat)
  27498. // } else {
  27499. // fmt.Println(err)
  27500. // }
  27501. // userJSONBytes, _ := json.Marshal(dat)
  27502. // var res ResultTwo
  27503. // var res10265 ResultTwo10265
  27504. // if miConfig.Code == "H15049901371" {
  27505. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27506. // utils.ErrorLog("解析失败:%v", err)
  27507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27508. // return
  27509. // }
  27510. // res.ErrMsg = res10265.ErrMsg
  27511. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27512. // res.Infcode = infocode
  27513. // res.Output = res10265.Output
  27514. // res.InfRefmsgid = res10265.InfRefmsgid
  27515. // } else {
  27516. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27517. // utils.ErrorLog("解析失败:%v", err)
  27518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27519. // return
  27520. // }
  27521. // }
  27522. //
  27523. // var user_name string
  27524. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27525. // if role.ID == 0 {
  27526. // user_name = "xxx"
  27527. // } else {
  27528. // user_name = role.UserName
  27529. // }
  27530. //
  27531. // baseParams := models.BaseParams{
  27532. // SecretKey: miConfig.SecretKey,
  27533. // FixmedinsCode: miConfig.Code,
  27534. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27535. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27536. // OrgName: miConfig.OrgName,
  27537. // Doctor: user_name,
  27538. // }
  27539. //
  27540. // if config.IsOpen == 1 {
  27541. // if miConfig.Code == "H15049901371" {
  27542. // if med_type == "14" {
  27543. // if insutype == "390" {
  27544. // med_type = "9933"
  27545. // } else if insutype == "310" {
  27546. // med_type = "990502"
  27547. // }
  27548. // } else if med_type == "11" {
  27549. // med_type = "11"
  27550. // }
  27551. // }
  27552. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27553. // var dat map[string]interface{}
  27554. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27555. // fmt.Println(dat)
  27556. // } else {
  27557. // fmt.Println(err)
  27558. // }
  27559. // var res Result2001
  27560. // var res10265 Result2001Org10265
  27561. // if miConfig.Code == "H15049901371" {
  27562. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27563. // utils.ErrorLog("解析失败:%v", err)
  27564. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27565. // return
  27566. // }
  27567. // res.ErrMsg = res10265.ErrMsg
  27568. // res.Output = res10265.Output
  27569. // res.InfRefmsgid = res10265.InfRefmsgid
  27570. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27571. // res.Infcode = infocode
  27572. // } else {
  27573. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27574. // utils.ErrorLog("解析失败:%v", err)
  27575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27576. // return
  27577. // }
  27578. // }
  27579. // if res.Infcode == 0 {
  27580. // c.ServeSuccessJSON(map[string]interface{}{
  27581. // "msg": res.Output.Trtinfo,
  27582. // })
  27583. // }
  27584. // }
  27585. // }
  27586. //}
  27587. //func (c *HisApiController) PutRecord() {
  27588. // id, _ := c.GetInt64("id")
  27589. // record_time := c.GetString("record_time")
  27590. // timeLayout := "2006-01-02"
  27591. // loc, _ := time.LoadLocation("Local")
  27592. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27593. // if err != nil {
  27594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27595. // return
  27596. // }
  27597. // recordDateTime := theTime.Unix()
  27598. //
  27599. // adminInfo := c.GetAdminUserInfo()
  27600. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27601. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27602. //
  27603. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27604. //
  27605. // fmt.Println(miConfig.SecretKey)
  27606. //
  27607. // if patient == nil {
  27608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27609. // return
  27610. // }
  27611. // if len(patient.IdCardNo) == 0 {
  27612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27613. // return
  27614. // }
  27615. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27616. // if config.IsOpen == 1 {
  27617. // 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
  27618. // resp, requestErr := http.Get(api)
  27619. // if requestErr != nil {
  27620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27621. // return
  27622. // }
  27623. // defer resp.Body.Close()
  27624. // body, ioErr := ioutil.ReadAll(resp.Body)
  27625. // if ioErr != nil {
  27626. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27627. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27628. // return
  27629. // }
  27630. // var respJSON map[string]interface{}
  27631. //
  27632. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27633. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27634. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27635. // return
  27636. // }
  27637. //
  27638. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27639. // userJSONBytes, _ := json.Marshal(userJSON)
  27640. // var res ResultTwo
  27641. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27642. // utils.ErrorLog("解析失败:%v", err)
  27643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27644. // return
  27645. // }
  27646. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27647. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27648. // infoStr := string(Iinfos)
  27649. // idetinfoStr := string(Idetinfos)
  27650. //
  27651. // if res.Infcode == 0 {
  27652. // his := models.VMHisPatient{
  27653. // Status: 1,
  27654. // Ctime: time.Now().Unix(),
  27655. // Mtime: time.Now().Unix(),
  27656. // PsnNo: res.Output.Baseinfo.PsnNo,
  27657. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27658. // Certno: res.Output.Baseinfo.Certno,
  27659. // PsnName: res.Output.Baseinfo.PsnName,
  27660. // Gend: res.Output.Baseinfo.Gend,
  27661. // Naty: res.Output.Baseinfo.Naty,
  27662. // Brdy: res.Output.Baseinfo.Brdy,
  27663. // Age: res.Output.Baseinfo.Age,
  27664. // Iinfo: infoStr,
  27665. // Idetinfo: idetinfoStr,
  27666. // PatientId: patient.ID,
  27667. // RecordDate: theTime.Unix(),
  27668. // UserOrgId: adminInfo.CurrentOrgId,
  27669. // AdminUserId: adminInfo.AdminUser.Id,
  27670. // IsReturn: 1,
  27671. // }
  27672. //
  27673. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27674. // //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")
  27675. // //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")
  27676. //
  27677. // //var dat map[string]interface{}
  27678. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27679. // // fmt.Println(dat)
  27680. // //} else {
  27681. // // fmt.Println(err)
  27682. // //}
  27683. //
  27684. // var dat2 map[string]interface{}
  27685. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27686. // fmt.Println(dat2)
  27687. // } else {
  27688. // fmt.Println(err)
  27689. // }
  27690. //
  27691. // } else {
  27692. // adminUser := c.GetAdminUserInfo()
  27693. // errlog := &models.HisOrderError{
  27694. // UserOrgId: adminUser.CurrentOrgId,
  27695. // Ctime: time.Now().Unix(),
  27696. // Mtime: time.Now().Unix(),
  27697. // ErrMsg: res.ErrMsg,
  27698. // Status: 1,
  27699. // PatientId: id,
  27700. // RecordTime: recordDateTime,
  27701. // Stage: 1,
  27702. // }
  27703. // service.CreateErrMsgLog(errlog)
  27704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27705. // return
  27706. // }
  27707. // }
  27708. //
  27709. //}
  27710. //func (c *HisApiController) GetUploadDiag() {
  27711. // id, _ := c.GetInt64("id")
  27712. // record_time := c.GetString("record_time")
  27713. //
  27714. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27715. // sick_type, _ := c.GetInt64("sick_type")
  27716. // reg_type, _ := c.GetInt64("reg_type")
  27717. //
  27718. // timeLayout := "2006-01-02"
  27719. // loc, _ := time.LoadLocation("Local")
  27720. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27721. // if err != nil {
  27722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27723. // return
  27724. // }
  27725. //
  27726. // var patientPrescription models.HisPrescriptionInfo
  27727. // recordDateTime := theTime.Unix()
  27728. // adminInfo := c.GetAdminUserInfo()
  27729. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27730. //
  27731. // if patientPrescription.ID == 0 {
  27732. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27733. // }
  27734. //
  27735. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27736. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27737. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27738. // sickConfig, _ := service.FindSickById(sick_type)
  27739. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27740. //
  27741. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27742. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27743. // "&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 +
  27744. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27745. // resp2, requestErr2 := http.Get(api2)
  27746. // if requestErr2 != nil {
  27747. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27748. // return
  27749. // }
  27750. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27751. // if ioErr2 != nil {
  27752. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27754. // return
  27755. // }
  27756. // var respJSON2 map[string]interface{}
  27757. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27758. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27760. // return
  27761. // }
  27762. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27763. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27764. //
  27765. // var res2 ResultSix
  27766. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27767. // utils.ErrorLog("解析失败:%v", err)
  27768. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27769. // return
  27770. // }
  27771. // if res2.Infcode != 0 {
  27772. // adminUser := c.GetAdminUserInfo()
  27773. // errlog := &models.HisOrderError{
  27774. // UserOrgId: adminUser.CurrentOrgId,
  27775. // Ctime: time.Now().Unix(),
  27776. // Mtime: time.Now().Unix(),
  27777. // ErrMsg: res2.ErrMsg,
  27778. // Status: 1,
  27779. // PatientId: id,
  27780. // RecordTime: recordDateTime,
  27781. // Stage: 3,
  27782. // }
  27783. // service.CreateErrMsgLog(errlog)
  27784. //
  27785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27786. // return
  27787. // }
  27788. //
  27789. // c.ServeSuccessJSON(map[string]interface{}{
  27790. // "msg": "上传成功",
  27791. // })
  27792. //
  27793. //}
  27794. type QueryResult struct {
  27795. ID int64
  27796. Name string
  27797. Code string
  27798. List_type_code string
  27799. }
  27800. func (c *HisApiController) GetCheckCode() {
  27801. ids_str := c.GetString("ids")
  27802. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27803. ids_arr := strings.Split(ids_str, ",")
  27804. var queryResult []QueryResult
  27805. ids := make([]int64, 0)
  27806. for _, item := range ids_arr {
  27807. id, _ := strconv.ParseInt(item, 10, 64)
  27808. ids = append(ids, id)
  27809. }
  27810. if record_type == 1 {
  27811. drugs, _ := service.GetBatchDrugList(ids)
  27812. for _, item := range drugs {
  27813. result := QueryResult{
  27814. ID: item.ID,
  27815. Name: item.DrugName,
  27816. Code: item.MedicalInsuranceNumber,
  27817. List_type_code: "101",
  27818. }
  27819. queryResult = append(queryResult, result)
  27820. }
  27821. } else if record_type == 2 {
  27822. goods, _ := service.GetBatchGoodInformationList(ids)
  27823. fmt.Println(goods)
  27824. for _, item := range goods {
  27825. result := QueryResult{
  27826. ID: item.ID,
  27827. Name: item.GoodName,
  27828. Code: item.SocialSecurityDirectoryCode,
  27829. List_type_code: "301",
  27830. }
  27831. queryResult = append(queryResult, result)
  27832. }
  27833. } else if record_type == 3 {
  27834. projects, _ := service.GetBathchMyPorjecgList(ids)
  27835. for _, item := range projects {
  27836. result := QueryResult{
  27837. ID: item.ID,
  27838. Name: item.ProjectName,
  27839. Code: item.MedicalCode,
  27840. List_type_code: "201",
  27841. }
  27842. queryResult = append(queryResult, result)
  27843. }
  27844. }
  27845. admin_user_id, _ := c.GetInt64("admin_user_id")
  27846. adminUser := c.GetAdminUserInfo()
  27847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27848. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27849. var user_name string
  27850. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27851. if role.ID == 0 {
  27852. user_name = "管理员"
  27853. } else {
  27854. user_name = role.UserName
  27855. }
  27856. baseParams := models.BaseParams{
  27857. SecretKey: miConfig.SecretKey,
  27858. FixmedinsCode: miConfig.Code,
  27859. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27860. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27861. OrgName: miConfig.OrgName,
  27862. Doctor: user_name,
  27863. }
  27864. var result string
  27865. if miConfig.MdtrtareaAdmvs == "430800" {
  27866. for _, item := range queryResult {
  27867. if record_type == 1 {
  27868. 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)
  27869. } else if record_type == 2 {
  27870. fmt.Println(item.Code)
  27871. 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)
  27872. } else if record_type == 3 {
  27873. 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)
  27874. }
  27875. var dat map[string]interface{}
  27876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27877. fmt.Println(dat)
  27878. } else {
  27879. fmt.Println(err)
  27880. }
  27881. userJSONBytes, _ := json.Marshal(dat)
  27882. var res ResultSix
  27883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27884. utils.ErrorLog("解析失败:%v", err)
  27885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27886. return
  27887. }
  27888. if res.Infcode == 0 {
  27889. if record_type == 1 {
  27890. service.UpdateBaseDrugById(item.ID)
  27891. } else if record_type == 2 {
  27892. service.UpdateGoodInformaitonByDetail(item.ID)
  27893. } else if record_type == 3 {
  27894. service.UpdateProjectById(item.ID)
  27895. }
  27896. c.ServeSuccessJSON(map[string]interface{}{
  27897. "failed_code": 0,
  27898. "msg": "目录对照成功",
  27899. })
  27900. } else {
  27901. c.ServeSuccessJSON(map[string]interface{}{
  27902. "failed_code": -10,
  27903. "msg": res.ErrMsg,
  27904. })
  27905. }
  27906. }
  27907. } else {
  27908. for _, item := range queryResult {
  27909. var result string
  27910. if record_type == 1 {
  27911. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27912. } else if record_type == 2 {
  27913. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27914. } else if record_type == 3 {
  27915. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27916. }
  27917. var dat map[string]interface{}
  27918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27919. fmt.Println(dat)
  27920. } else {
  27921. fmt.Println(err)
  27922. }
  27923. userJSONBytes, _ := json.Marshal(dat)
  27924. var res ResultSix
  27925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27926. utils.ErrorLog("解析失败:%v", err)
  27927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27928. return
  27929. }
  27930. if res.Infcode == 0 {
  27931. if record_type == 1 {
  27932. service.UpdateBaseDrugById(item.ID)
  27933. } else if record_type == 2 {
  27934. service.UpdateGoodInformaitonByDetail(item.ID)
  27935. } else if record_type == 3 {
  27936. service.UpdateProjectById(item.ID)
  27937. }
  27938. c.ServeSuccessJSON(map[string]interface{}{
  27939. "failed_code": 0,
  27940. "msg": "目录对照成功",
  27941. })
  27942. } else {
  27943. c.ServeSuccessJSON(map[string]interface{}{
  27944. "failed_code": -10,
  27945. "msg": res.ErrMsg,
  27946. })
  27947. }
  27948. }
  27949. }
  27950. }
  27951. func (c *HisApiController) UnCheckCode() {
  27952. ids_str := c.GetString("ids")
  27953. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27954. admin_user_id, _ := c.GetInt64("admin_user_id")
  27955. ids_arr := strings.Split(ids_str, ",")
  27956. var queryResult []QueryResult
  27957. ids := make([]int64, 0)
  27958. for _, item := range ids_arr {
  27959. id, _ := strconv.ParseInt(item, 10, 64)
  27960. ids = append(ids, id)
  27961. }
  27962. if record_type == 1 {
  27963. drugs, _ := service.GetBatchDrugList(ids)
  27964. for _, item := range drugs {
  27965. result := QueryResult{
  27966. ID: item.ID,
  27967. Name: item.DrugName,
  27968. Code: item.MedicalInsuranceNumber,
  27969. List_type_code: "101",
  27970. }
  27971. queryResult = append(queryResult, result)
  27972. }
  27973. } else if record_type == 2 {
  27974. goods, _ := service.GetBatchGoodInformationList(ids)
  27975. for _, item := range goods {
  27976. result := QueryResult{
  27977. ID: item.ID,
  27978. Name: item.GoodName,
  27979. Code: item.SocialSecurityDirectoryCode,
  27980. List_type_code: "301",
  27981. }
  27982. queryResult = append(queryResult, result)
  27983. }
  27984. } else if record_type == 3 {
  27985. projects, _ := service.GetBathchMyPorjecgList(ids)
  27986. for _, item := range projects {
  27987. result := QueryResult{
  27988. ID: item.ID,
  27989. Name: item.ProjectName,
  27990. Code: item.MedicalCode,
  27991. List_type_code: "201",
  27992. }
  27993. queryResult = append(queryResult, result)
  27994. }
  27995. }
  27996. adminUser := c.GetAdminUserInfo()
  27997. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27998. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27999. var user_name string
  28000. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28001. if role.ID == 0 {
  28002. user_name = "xxx"
  28003. } else {
  28004. user_name = role.UserName
  28005. }
  28006. baseParams := &models.BaseParams{
  28007. SecretKey: miConfig.SecretKey,
  28008. FixmedinsCode: miConfig.Code,
  28009. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  28010. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  28011. OrgName: miConfig.OrgName,
  28012. Doctor: user_name,
  28013. }
  28014. if config.IsOpen == 1 {
  28015. if miConfig.MdtrtareaAdmvs == "430800" {
  28016. for _, item := range queryResult {
  28017. var result string
  28018. if record_type == 1 {
  28019. 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)
  28020. } else if record_type == 2 {
  28021. fmt.Println(item.Code)
  28022. 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)
  28023. } else if record_type == 3 {
  28024. 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)
  28025. }
  28026. var dat map[string]interface{}
  28027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28028. fmt.Println(dat)
  28029. } else {
  28030. fmt.Println(err)
  28031. }
  28032. userJSONBytes, _ := json.Marshal(dat)
  28033. var res ResultSix
  28034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28035. utils.ErrorLog("解析失败:%v", err)
  28036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28037. return
  28038. }
  28039. if res.Infcode == 0 {
  28040. if record_type == 1 {
  28041. service.UpdateBaseDrugById(item.ID)
  28042. } else if record_type == 2 {
  28043. service.UpdateGoodInformaitonByDetail(item.ID)
  28044. } else if record_type == 3 {
  28045. service.UpdateProjectById(item.ID)
  28046. }
  28047. c.ServeSuccessJSON(map[string]interface{}{
  28048. "failed_code": 0,
  28049. "msg": "目录对照成功",
  28050. })
  28051. } else {
  28052. c.ServeSuccessJSON(map[string]interface{}{
  28053. "failed_code": -10,
  28054. "msg": res.ErrMsg,
  28055. })
  28056. }
  28057. }
  28058. } else {
  28059. for _, item := range queryResult {
  28060. var result string
  28061. if record_type == 1 {
  28062. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28063. } else if record_type == 2 {
  28064. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28065. } else if record_type == 3 {
  28066. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  28067. }
  28068. var dat2 map[string]interface{}
  28069. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28070. fmt.Println(dat2)
  28071. } else {
  28072. fmt.Println(err)
  28073. }
  28074. userJSONBytes, _ := json.Marshal(dat2)
  28075. var res ResultSix
  28076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28077. utils.ErrorLog("解析失败:%v", err)
  28078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28079. return
  28080. }
  28081. if res.Infcode == 0 {
  28082. if record_type == 1 {
  28083. service.UpdateDrugByIdDetail(item.ID)
  28084. } else if record_type == 2 {
  28085. service.UpdateGoodInfoById(item.ID)
  28086. } else if record_type == 3 {
  28087. service.UpdateMyProjectById(item.ID)
  28088. }
  28089. c.ServeSuccessJSON(map[string]interface{}{
  28090. "failed_code": 0,
  28091. "msg": "撤销目录对照成功",
  28092. })
  28093. } else {
  28094. c.ServeSuccessJSON(map[string]interface{}{
  28095. "failed_code": -10,
  28096. "msg": res.ErrMsg,
  28097. })
  28098. }
  28099. }
  28100. }
  28101. }
  28102. }
  28103. func (c *HisApiController) GetPatientInfo() {
  28104. id_card_no := c.GetString("id_card_no")
  28105. admin_user_id, _ := c.GetInt64("admin_user_id")
  28106. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28107. if patient.ID == 0 {
  28108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28109. return
  28110. }
  28111. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28112. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28113. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28114. var res ResultTwo
  28115. var res10265 ResultTwo10265
  28116. if config.IsOpen == 1 {
  28117. if miConfig.MdtrtareaAdmvs == "150499" {
  28118. //请求内网数据
  28119. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28120. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28121. "&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
  28122. resp, requestErr := http.Get(api)
  28123. if requestErr != nil {
  28124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28125. return
  28126. }
  28127. body, ioErr := ioutil.ReadAll(resp.Body)
  28128. if ioErr != nil {
  28129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28131. return
  28132. }
  28133. var respJSON map[string]interface{}
  28134. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28137. return
  28138. }
  28139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28140. result_byte, _ := json.Marshal(respJSON)
  28141. result := string(result_byte)
  28142. var dat map[string]interface{}
  28143. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28144. fmt.Println(dat)
  28145. } else {
  28146. fmt.Println(err)
  28147. }
  28148. userJSONBytes, _ := json.Marshal(dat)
  28149. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28150. utils.ErrorLog("解析失败:%v", err)
  28151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28152. return
  28153. }
  28154. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28155. res.Infcode = Infcode
  28156. res.ErrMsg = res10265.ErrMsg
  28157. res.Output = res10265.Output
  28158. res.InfRefmsgid = res10265.InfRefmsgid
  28159. res.RespondTime = res10265.RespondTime
  28160. res.WarnInfo = res10265.WarnInfo
  28161. } else {
  28162. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28163. var dat map[string]interface{}
  28164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28165. fmt.Println(dat)
  28166. } else {
  28167. fmt.Println(err)
  28168. }
  28169. userJSONBytes, _ := json.Marshal(dat)
  28170. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28171. utils.ErrorLog("解析失败:%v", err)
  28172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28173. return
  28174. }
  28175. }
  28176. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28177. // utils.ErrorLog("解析失败:%v", err)
  28178. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28179. // return
  28180. //}
  28181. for index, item := range res.Output.Iinfo {
  28182. if item.PsnInsuStas == "2" {
  28183. fmt.Println("--------")
  28184. res.Output.Iinfo[index].Insutype = "300"
  28185. res.Output.Iinfo[index].PsnInsuStas = "1"
  28186. }
  28187. }
  28188. fmt.Println(res.Output.Iinfo)
  28189. if res.Infcode != 0 {
  28190. c.ServeSuccessJSON(map[string]interface{}{
  28191. "failed_code": -10,
  28192. "msg": res.ErrMsg,
  28193. })
  28194. } else {
  28195. c.ServeSuccessJSON(map[string]interface{}{
  28196. "failed_code": 0,
  28197. "info": res,
  28198. })
  28199. }
  28200. }
  28201. }
  28202. func (c *HisApiController) PsnPutOnRecord() {
  28203. record_type, _ := c.GetInt64("type")
  28204. patient_id, _ := c.GetInt64("patient_id")
  28205. admin_user_id, _ := c.GetInt64("admin_user_id")
  28206. start_time := c.GetString("start_time")
  28207. end_time := c.GetString("end_time")
  28208. adminUser := c.GetAdminUserInfo()
  28209. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28210. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28211. var patients []*models.Patients
  28212. if record_type == 1 { //全部备案
  28213. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28214. patients = append(patients, patient...)
  28215. } else { //单个备案
  28216. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28217. patients = append(patients, patient)
  28218. }
  28219. var user_name string
  28220. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28221. if role.ID == 0 {
  28222. user_name = "xxx"
  28223. } else {
  28224. user_name = role.UserName
  28225. }
  28226. if config.IsOpen == 1 {
  28227. for _, item := range patients {
  28228. 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
  28229. resp, requestErr := http.Get(api)
  28230. if requestErr != nil {
  28231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28232. return
  28233. }
  28234. defer resp.Body.Close()
  28235. body, ioErr := ioutil.ReadAll(resp.Body)
  28236. if ioErr != nil {
  28237. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28239. return
  28240. }
  28241. var respJSON map[string]interface{}
  28242. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28243. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28245. return
  28246. }
  28247. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28248. userJSONBytes, _ := json.Marshal(userJSON)
  28249. var res ResultTwo
  28250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28251. utils.ErrorLog("解析失败:%v", err)
  28252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28253. return
  28254. }
  28255. if res.Infcode == 0 {
  28256. 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)
  28257. var dat map[string]interface{}
  28258. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28259. fmt.Println(dat)
  28260. } else {
  28261. fmt.Println(err)
  28262. }
  28263. userJSONBytes, _ := json.Marshal(dat)
  28264. var res2 ResultThirteen
  28265. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28266. utils.ErrorLog("解析失败:%v", err)
  28267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28268. return
  28269. }
  28270. if res2.Infcode == 0 {
  28271. psnResult := &models.GdybPsnRecord{
  28272. UserOrgId: adminUser.CurrentOrgId,
  28273. PatientId: item.ID,
  28274. PsnNo: res.Output.Baseinfo.PsnNo,
  28275. Ctime: time.Now().Unix(),
  28276. Mtime: time.Now().Unix(),
  28277. Status: 1,
  28278. IsCancel: 1,
  28279. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28280. }
  28281. service.CreatePsnRecord(psnResult)
  28282. } else {
  28283. c.ServeSuccessJSON(map[string]interface{}{
  28284. "failed_code": -10,
  28285. "msg": res2.ErrMsg,
  28286. })
  28287. return
  28288. }
  28289. }
  28290. }
  28291. }
  28292. }
  28293. func (c *HisApiController) PsnUnPutOnRecord() {
  28294. id, _ := c.GetInt64("id")
  28295. //record_type, _ := c.GetInt64("type")
  28296. admin_user_id, _ := c.GetInt64("admin_user_id")
  28297. adminUser := c.GetAdminUserInfo()
  28298. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28299. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28300. var user_name string
  28301. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28302. if role.ID == 0 {
  28303. user_name = "xxx"
  28304. } else {
  28305. user_name = role.UserName
  28306. }
  28307. psn_record, _ := service.GetPsnRecordById(id)
  28308. if psn_record.ID == 0 {
  28309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28310. return
  28311. }
  28312. if config.IsOpen == 1 {
  28313. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28314. var dat map[string]interface{}
  28315. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28316. fmt.Println(dat)
  28317. } else {
  28318. fmt.Println(err)
  28319. }
  28320. userJSONBytes, _ := json.Marshal(dat)
  28321. var res ResultFourteen
  28322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28323. utils.ErrorLog("解析失败:%v", err)
  28324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28325. return
  28326. }
  28327. if res.Infcode == 0 {
  28328. psn_record.IsCancel = 2
  28329. service.CreatePsnRecord(&psn_record)
  28330. } else {
  28331. c.ServeSuccessJSON(map[string]interface{}{
  28332. "failed_code": -10,
  28333. "msg": res.ErrMsg,
  28334. })
  28335. return
  28336. }
  28337. }
  28338. }
  28339. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28340. patient_id, _ := c.GetInt64("patient_id")
  28341. insutype_two := c.GetString("insutype")
  28342. psn_no := c.GetString("psn_no")
  28343. doctor_id, _ := c.GetInt64("doctor_id")
  28344. sick_id, _ := c.GetInt64("sick_id")
  28345. department_id, _ := c.GetInt64("department_id")
  28346. start_time := c.GetString("start_time")
  28347. end_time := c.GetString("end_time")
  28348. check_time := c.GetString("check_time")
  28349. hospital_code := c.GetString("hospital_code")
  28350. hospital_name := c.GetString("hospital_name")
  28351. adminUser := c.GetAdminUserInfo()
  28352. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28353. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28354. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28355. sick, _ := service.FindSickById(sick_id)
  28356. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28357. if len(hospital_code) == 0 {
  28358. hospital_code = miConfig.Code
  28359. }
  28360. if len(hospital_name) == 0 {
  28361. hospital_name = miConfig.OrgName
  28362. }
  28363. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28364. var res ResultTwo
  28365. var res10265 ResultTwo10265
  28366. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28367. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28368. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28369. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28370. "&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
  28371. resp, requestErr := http.Get(api)
  28372. if requestErr != nil {
  28373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28374. return
  28375. }
  28376. body, ioErr := ioutil.ReadAll(resp.Body)
  28377. if ioErr != nil {
  28378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28380. return
  28381. }
  28382. var respJSON map[string]interface{}
  28383. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28386. return
  28387. }
  28388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28389. result, _ := json.Marshal(respJSON)
  28390. fmt.Println("log")
  28391. fmt.Println(string(result))
  28392. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28393. utils.ErrorLog("解析失败:%v", err)
  28394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28395. return
  28396. }
  28397. res.ErrMsg = res10265.ErrMsg
  28398. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28399. res.Infcode = infocode
  28400. res.Output = res10265.Output
  28401. res.InfRefmsgid = res10265.InfRefmsgid
  28402. } else {
  28403. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28404. if miConfig.Code == "H15049901371" {
  28405. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28406. utils.ErrorLog("解析失败:%v", err)
  28407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28408. return
  28409. }
  28410. res.ErrMsg = res10265.ErrMsg
  28411. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28412. res.Infcode = infocode
  28413. res.Output = res10265.Output
  28414. res.InfRefmsgid = res10265.InfRefmsgid
  28415. } else {
  28416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28417. utils.ErrorLog("解析失败:%v", err)
  28418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28419. return
  28420. }
  28421. }
  28422. }
  28423. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28424. infoStr := string(Iinfos)
  28425. var rf []*ResultFive
  28426. json.Unmarshal([]byte(infoStr), &rf)
  28427. var insuplc_admdvs string
  28428. var insutype string
  28429. var is390 int = 0
  28430. var is310 int = 0
  28431. var insutypes []*ResultFive
  28432. for _, item := range rf {
  28433. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28434. insutypes = append(insutypes, item)
  28435. }
  28436. }
  28437. if len(insutypes) == 1 {
  28438. insutype = insutypes[0].Insutype
  28439. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28440. } else {
  28441. for _, i := range insutypes {
  28442. if i.Insutype == "390" {
  28443. is390 = 1
  28444. }
  28445. if i.Insutype == "310" {
  28446. is310 = 1
  28447. }
  28448. }
  28449. }
  28450. if is390 == 1 {
  28451. insutype = "390"
  28452. }
  28453. if is310 == 1 {
  28454. insutype = "310"
  28455. }
  28456. if len(insutypes) == 2 {
  28457. insutype = insutype_two
  28458. }
  28459. if len(insutypes) == 0 {
  28460. insutype = "310"
  28461. }
  28462. insutype = insutype_two
  28463. fmt.Println(insutype)
  28464. for _, item := range rf {
  28465. fmt.Println(item.Insutype)
  28466. fmt.Println(insutype)
  28467. if item.Insutype == insutype {
  28468. fmt.Println(item.Insutype)
  28469. fmt.Println(insutype)
  28470. insuplc_admdvs = item.InsuplcAdmdvs
  28471. }
  28472. }
  28473. fmt.Println(insuplc_admdvs)
  28474. var res2 ResultThirteen
  28475. var res10265_2 ResultThirteen10265
  28476. if config.IsOpen == 1 {
  28477. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28478. } else {
  28479. if miConfig.MdtrtareaAdmvs == "150499" {
  28480. //
  28481. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28482. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28483. // "&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
  28484. //resp, requestErr := http.Get(api)
  28485. //if requestErr != nil {
  28486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28487. // return
  28488. //}
  28489. //
  28490. //body, ioErr := ioutil.ReadAll(resp.Body)
  28491. //if ioErr != nil {
  28492. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28493. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28494. // return
  28495. //}
  28496. //var respJSON map[string]interface{}
  28497. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28498. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28500. // return
  28501. //}
  28502. //
  28503. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28504. //result, _ := json.Marshal(respJSON)
  28505. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28506. // utils.ErrorLog("解析失败:%v", err)
  28507. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28508. // return
  28509. //}
  28510. //infocode = resThree.Infcode
  28511. //result, _ := json.Marshal(respJSON)
  28512. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28513. // utils.ErrorLog("解析失败:%v", err)
  28514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28515. // return
  28516. //}
  28517. //
  28518. //resThree.ErrMsg = resThree10265.ErrMsg
  28519. //
  28520. //resThree.Output = resThree10265.Output
  28521. //
  28522. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28523. //
  28524. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28525. //
  28526. } else {
  28527. 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)
  28528. var dat map[string]interface{}
  28529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28530. fmt.Println(dat)
  28531. } else {
  28532. fmt.Println(err)
  28533. }
  28534. userJSONBytes, _ := json.Marshal(dat)
  28535. if miConfig.Code == "H15049901371" {
  28536. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28537. utils.ErrorLog("解析失败:%v", err)
  28538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28539. return
  28540. }
  28541. res2.ErrMsg = res10265_2.ErrMsg
  28542. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28543. res2.Infcode = infocode
  28544. res2.Output = res10265_2.Output
  28545. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28546. } else {
  28547. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28548. utils.ErrorLog("解析失败:%v", err)
  28549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28550. return
  28551. }
  28552. }
  28553. }
  28554. }
  28555. if res2.Infcode == 0 {
  28556. psnResult := &models.GdybPsnNcdsRecord{
  28557. UserOrgId: adminUser.CurrentOrgId,
  28558. PatientId: patient.ID,
  28559. PsnNo: psn_no,
  28560. DoctorId: doctor.AdminUserId,
  28561. DepartmentId: department_id,
  28562. SickType: sick_id,
  28563. Insutype: insutype,
  28564. Ctime: time.Now().Unix(),
  28565. Mtime: time.Now().Unix(),
  28566. Status: 1,
  28567. IsCancel: 1,
  28568. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28569. }
  28570. service.CreatePsnNCDSRecord(psnResult)
  28571. c.ServeSuccessJSON(map[string]interface{}{
  28572. "failed_code": 0,
  28573. "msg": "备案成功",
  28574. "result": psnResult,
  28575. })
  28576. } else {
  28577. c.ServeSuccessJSON(map[string]interface{}{
  28578. "failed_code": -10,
  28579. "msg": res2.ErrMsg,
  28580. })
  28581. return
  28582. }
  28583. }
  28584. }
  28585. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28586. id, _ := c.GetInt64("id")
  28587. admin_user_id, _ := c.GetInt64("admin_user_id")
  28588. adminUser := c.GetAdminUserInfo()
  28589. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28590. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28591. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28592. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28593. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28594. //var user_name string
  28595. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28596. //if role.ID == 0 {
  28597. // user_name = "xxx"
  28598. //} else {
  28599. // user_name = role.UserName
  28600. //}
  28601. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28602. if psn_record.ID == 0 {
  28603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28604. return
  28605. }
  28606. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28607. var res ResultTwo
  28608. var res10265 ResultTwo10265
  28609. if miConfig.Code == "H15049901371" {
  28610. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28611. utils.ErrorLog("解析失败:%v", err)
  28612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28613. return
  28614. }
  28615. res.ErrMsg = res10265.ErrMsg
  28616. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28617. res.Infcode = infocode
  28618. res.Output = res10265.Output
  28619. res.InfRefmsgid = res10265.InfRefmsgid
  28620. } else {
  28621. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28622. utils.ErrorLog("解析失败:%v", err)
  28623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28624. return
  28625. }
  28626. }
  28627. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28628. infoStr := string(Iinfos)
  28629. var rf []*ResultFive
  28630. json.Unmarshal([]byte(infoStr), &rf)
  28631. var insuplc_admdvs string
  28632. var insutype string
  28633. var is390 int = 0
  28634. var is310 int = 0
  28635. var insutypes []*ResultFive
  28636. for _, item := range rf {
  28637. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28638. insutypes = append(insutypes, item)
  28639. }
  28640. }
  28641. if len(insutypes) == 1 {
  28642. insutype = insutypes[0].Insutype
  28643. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28644. } else {
  28645. for _, i := range insutypes {
  28646. if i.Insutype == "390" {
  28647. is390 = 1
  28648. }
  28649. if i.Insutype == "310" {
  28650. is310 = 1
  28651. }
  28652. }
  28653. }
  28654. if is390 == 1 {
  28655. insutype = "390"
  28656. }
  28657. if is310 == 1 {
  28658. insutype = "310"
  28659. }
  28660. if len(insutypes) == 0 {
  28661. insutype = "310"
  28662. }
  28663. insutype = psn_record.Insutype
  28664. for _, item := range rf {
  28665. if item.Insutype == insutype {
  28666. insuplc_admdvs = item.InsuplcAdmdvs
  28667. }
  28668. }
  28669. if config.IsOpen == 1 {
  28670. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28671. var dat map[string]interface{}
  28672. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28673. fmt.Println(dat)
  28674. } else {
  28675. fmt.Println(err)
  28676. }
  28677. userJSONBytes, _ := json.Marshal(dat)
  28678. var res ResultFourteen
  28679. var res10265 ResultFourteen10265
  28680. if miConfig.Code == "H15049901371" {
  28681. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28682. utils.ErrorLog("解析失败:%v", err)
  28683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28684. return
  28685. }
  28686. res.ErrMsg = res10265.ErrMsg
  28687. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28688. res.Infcode = infocode
  28689. res.Output = res10265.Output
  28690. res.InfRefmsgid = res10265.InfRefmsgid
  28691. } else {
  28692. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28693. utils.ErrorLog("解析失败:%v", err)
  28694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28695. return
  28696. }
  28697. }
  28698. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28699. // utils.ErrorLog("解析失败:%v", err)
  28700. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28701. // return
  28702. //}
  28703. if res.Infcode == 0 {
  28704. psn_record.IsCancel = 2
  28705. service.CreatePsnNCDSRecord(&psn_record)
  28706. c.ServeSuccessJSON(map[string]interface{}{
  28707. "failed_code": 0,
  28708. "msg": "撤销备案成功",
  28709. })
  28710. } else {
  28711. c.ServeSuccessJSON(map[string]interface{}{
  28712. "failed_code": -10,
  28713. "msg": res.ErrMsg,
  28714. })
  28715. return
  28716. }
  28717. }
  28718. }
  28719. func (c *HisApiController) TestTest() {
  28720. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28721. fmt.Println(patient.Iinfo)
  28722. }
  28723. type CustomData struct {
  28724. MsgId string
  28725. PsnNo string
  28726. Info string
  28727. }
  28728. func (c *HisApiController) ReversalData() {
  28729. var customData []*CustomData
  28730. custom := &CustomData{
  28731. MsgId: "H44022900158202103301714472004",
  28732. PsnNo: "44020000001101329945",
  28733. Info: "2207",
  28734. }
  28735. customData = append(customData, custom)
  28736. custom1 := &CustomData{
  28737. MsgId: "H4402290015820210330172057803",
  28738. PsnNo: "44020000001101161813",
  28739. Info: "2207",
  28740. }
  28741. customData = append(customData, custom1)
  28742. custom2 := &CustomData{
  28743. MsgId: "H44022900158202103301705198813",
  28744. PsnNo: "44190000133097375417",
  28745. Info: "2207",
  28746. }
  28747. customData = append(customData, custom2)
  28748. custom3 := &CustomData{
  28749. MsgId: "H44022900158202103301715524756",
  28750. PsnNo: "44020000001100187221",
  28751. Info: "2207",
  28752. }
  28753. customData = append(customData, custom3)
  28754. custom4 := &CustomData{
  28755. MsgId: "H44022900158202103301730376224",
  28756. PsnNo: "44020000001101959155",
  28757. Info: "2207",
  28758. }
  28759. customData = append(customData, custom4)
  28760. custom5 := &CustomData{
  28761. MsgId: "H44022900158202103301748008725",
  28762. PsnNo: "44020000001104246641",
  28763. Info: "2207",
  28764. }
  28765. customData = append(customData, custom5)
  28766. custom6 := &CustomData{
  28767. MsgId: "H44022900158202103301718096755",
  28768. PsnNo: "44020000001102211860",
  28769. Info: "2207",
  28770. }
  28771. customData = append(customData, custom6)
  28772. custom7 := &CustomData{
  28773. MsgId: "H44022900158202103301736551640",
  28774. PsnNo: "44020000001102687718",
  28775. Info: "2207",
  28776. }
  28777. customData = append(customData, custom7)
  28778. custom8 := &CustomData{
  28779. MsgId: "H44022900158202103301743097676",
  28780. PsnNo: "44020000001102127785",
  28781. Info: "2207",
  28782. }
  28783. customData = append(customData, custom8)
  28784. custom9 := &CustomData{
  28785. MsgId: "H44022900158202103301712304203",
  28786. PsnNo: "44020000001101518097",
  28787. Info: "2207",
  28788. }
  28789. customData = append(customData, custom9)
  28790. custom10 := &CustomData{
  28791. MsgId: "H44022900158202103301738448785",
  28792. PsnNo: "44020000001100500813",
  28793. Info: "2207",
  28794. }
  28795. customData = append(customData, custom10)
  28796. custom11 := &CustomData{
  28797. MsgId: "H44022900158202103301732455843",
  28798. PsnNo: "44020000001102690557",
  28799. Info: "2207",
  28800. }
  28801. customData = append(customData, custom11)
  28802. custom12 := &CustomData{
  28803. MsgId: "H44022900158202103301745421708",
  28804. PsnNo: "44020000001102211928",
  28805. Info: "2207",
  28806. }
  28807. customData = append(customData, custom12)
  28808. custom1212 := &CustomData{
  28809. MsgId: "H440229001582021033017351627",
  28810. PsnNo: "44020000001102481733",
  28811. Info: "2207",
  28812. }
  28813. customData = append(customData, custom1212)
  28814. custom13 := &CustomData{
  28815. MsgId: "H44022900158202103301740327951",
  28816. PsnNo: "44020000001103174866",
  28817. Info: "2207",
  28818. }
  28819. customData = append(customData, custom13)
  28820. custom14 := &CustomData{
  28821. MsgId: "H4402290015820210330174922668",
  28822. PsnNo: "44020000001102927272",
  28823. Info: "2207",
  28824. }
  28825. customData = append(customData, custom14)
  28826. custom15 := &CustomData{
  28827. MsgId: "H44022900158202103301752362273",
  28828. PsnNo: "44020000001102942890",
  28829. Info: "2207",
  28830. }
  28831. customData = append(customData, custom15)
  28832. custom16 := &CustomData{
  28833. MsgId: "H44022900158202103301751082917",
  28834. PsnNo: "44020000001101662162",
  28835. Info: "2207",
  28836. }
  28837. customData = append(customData, custom16)
  28838. custom17 := &CustomData{
  28839. MsgId: "H44022900158202103301754147728",
  28840. PsnNo: "44020000000229014511",
  28841. Info: "2207",
  28842. }
  28843. customData = append(customData, custom17)
  28844. adminUser := c.GetAdminUserInfo()
  28845. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28846. for _, item := range customData {
  28847. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28848. fmt.Println(result)
  28849. }
  28850. }
  28851. func (c *HisApiController) GetAllopatry() {
  28852. year := c.GetString("year")
  28853. month := c.GetString("month")
  28854. admin_user_id, _ := c.GetInt64("admin_user_id")
  28855. adminUser := c.GetAdminUserInfo()
  28856. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28857. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28858. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28859. var dat map[string]interface{}
  28860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28861. fmt.Println(dat)
  28862. } else {
  28863. fmt.Println(err)
  28864. }
  28865. userJSONBytes, _ := json.Marshal(dat)
  28866. var res models.Result9001
  28867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28868. utils.ErrorLog("解析失败:%v", err)
  28869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28870. return
  28871. }
  28872. fmt.Println(res.Output.Signinoutb)
  28873. fmt.Println(res.Output.Signinoutb.SignNo)
  28874. fmt.Println(string(userJSONBytes))
  28875. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28876. var dat3 map[string]interface{}
  28877. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  28878. fmt.Println(dat3)
  28879. } else {
  28880. fmt.Println(err)
  28881. }
  28882. userJSONBytes3, _ := json.Marshal(dat3)
  28883. var res3 models.Result3260
  28884. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  28885. utils.ErrorLog("解析失败:%v", err)
  28886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28887. return
  28888. }
  28889. var curpage int
  28890. var pagesize int = 100
  28891. var start int = 1
  28892. //var stop int
  28893. //pagecount := 10
  28894. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  28895. var res22 []models.Result3260
  28896. for curpage = 1; curpage <= pagecount; curpage++ {
  28897. if curpage == 1 {
  28898. start = 0
  28899. } else {
  28900. start = (curpage-1)*pagesize + 1
  28901. }
  28902. fmt.Println(start)
  28903. //stop = curpage * pagesize
  28904. //if stop > int(res3.Output.Totalrow) {
  28905. // stop =int(res3.Output.Totalrow)
  28906. //}
  28907. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28908. var dat2 map[string]interface{}
  28909. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28910. fmt.Println(dat)
  28911. } else {
  28912. fmt.Println(err)
  28913. }
  28914. userJSONBytes2, _ := json.Marshal(dat2)
  28915. var res2 models.Result3260
  28916. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28917. utils.ErrorLog("解析失败:%v", err)
  28918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28919. return
  28920. }
  28921. if res2.Infcode == 0 {
  28922. res22 = append(res22, res2)
  28923. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28924. //var dat2 map[string]interface{}
  28925. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28926. // fmt.Println(dat)
  28927. //} else {
  28928. // fmt.Println(err)
  28929. //}
  28930. //c.ServeSuccessJSON(map[string]interface{}{
  28931. // "list": res2.Output.Data,
  28932. //})
  28933. //continue
  28934. }
  28935. }
  28936. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28937. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28938. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28939. //var dat2 map[string]interface{}
  28940. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28941. // fmt.Println(dat)
  28942. //} else {
  28943. // fmt.Println(err)
  28944. //}
  28945. //userJSONBytes2, _ := json.Marshal(dat2)
  28946. //var res2 models.Result3260
  28947. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28948. // utils.ErrorLog("解析失败:%v", err)
  28949. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28950. // return
  28951. //}
  28952. //if res2.Infcode == 0 {
  28953. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28954. // var dat2 map[string]interface{}
  28955. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28956. // fmt.Println(dat)
  28957. // } else {
  28958. // fmt.Println(err)
  28959. // }
  28960. // c.ServeSuccessJSON(map[string]interface{}{
  28961. // "list": res2.Output.Data,
  28962. // })
  28963. //}
  28964. }
  28965. func (c *HisApiController) ComfirmAllopatry() {
  28966. year := c.GetString("year")
  28967. month := c.GetString("month")
  28968. admin_user_id, _ := c.GetInt64("admin_user_id")
  28969. adminUser := c.GetAdminUserInfo()
  28970. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28971. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28972. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28973. var dat map[string]interface{}
  28974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28975. fmt.Println(dat)
  28976. } else {
  28977. fmt.Println(err)
  28978. }
  28979. userJSONBytes, _ := json.Marshal(dat)
  28980. var res models.Result9001
  28981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28982. utils.ErrorLog("解析失败:%v", err)
  28983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28984. return
  28985. }
  28986. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28987. var dat2 map[string]interface{}
  28988. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28989. fmt.Println(dat)
  28990. } else {
  28991. fmt.Println(err)
  28992. }
  28993. userJSONBytes2, _ := json.Marshal(dat2)
  28994. var res2 models.Result3260
  28995. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28996. utils.ErrorLog("解析失败:%v", err)
  28997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28998. return
  28999. }
  29000. //if res2.Infcode == 0 {
  29001. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  29002. // var dat map[string]interface{}
  29003. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  29004. // fmt.Println(dat)
  29005. // } else {
  29006. // fmt.Println(err)
  29007. // }
  29008. // userJSONBytes, _ := json.Marshal(dat)
  29009. // var res3 models.Result3261
  29010. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  29011. // utils.ErrorLog("解析失败:%v", err)
  29012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29013. // return
  29014. // }
  29015. //
  29016. // if res3.Infcode == 0 {
  29017. // record := &models.HisYidiClearRecord{
  29018. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29019. // Ctime: time.Now().Unix(),
  29020. // Mtime: time.Now().Unix(),
  29021. // Status: 1,
  29022. // MsgId: msgId,
  29023. // }
  29024. // service.SaveClearRecord(record)
  29025. // c.ServeSuccessJSON(map[string]interface{}{
  29026. // "msg": "提取成功",
  29027. // })
  29028. // }
  29029. //}
  29030. }
  29031. func (c *HisApiController) RefundAllopatry() {
  29032. year := c.GetString("year")
  29033. month := c.GetString("month")
  29034. //id, _ := c.GetInt64("id")
  29035. admin_user_id, _ := c.GetInt64("admin_user_id")
  29036. adminUser := c.GetAdminUserInfo()
  29037. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29038. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29039. //record, _ := service.GetClearRecordById(id)
  29040. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  29041. var dat map[string]interface{}
  29042. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  29043. fmt.Println(dat)
  29044. } else {
  29045. fmt.Println(err)
  29046. }
  29047. userJSONBytes, _ := json.Marshal(dat)
  29048. var res models.Result9001
  29049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29050. utils.ErrorLog("解析失败:%v", err)
  29051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29052. return
  29053. }
  29054. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  29055. var dat2 map[string]interface{}
  29056. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  29057. fmt.Println(dat)
  29058. } else {
  29059. fmt.Println(err)
  29060. }
  29061. userJSONBytes2, _ := json.Marshal(dat2)
  29062. var empty ResultFourteen
  29063. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  29064. utils.ErrorLog("解析失败:%v", err)
  29065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29066. return
  29067. }
  29068. if empty.Infcode == 0 {
  29069. c.ServeSuccessJSON(map[string]interface{}{
  29070. "msg": "撤销成功",
  29071. })
  29072. return
  29073. }
  29074. }
  29075. func (c *HisApiController) ReversalOtherData() {
  29076. var customData []*CustomData
  29077. custom := &CustomData{
  29078. MsgId: "H44022900158202103301714472004",
  29079. PsnNo: "44020000001101329945",
  29080. Info: "2208",
  29081. }
  29082. customData = append(customData, custom)
  29083. custom1 := &CustomData{
  29084. MsgId: "H4402290015820210330172057803",
  29085. PsnNo: "44020000001101161813",
  29086. Info: "2208",
  29087. }
  29088. customData = append(customData, custom1)
  29089. custom2 := &CustomData{
  29090. MsgId: "H44022900158202103301705198813",
  29091. PsnNo: "44190000133097375417",
  29092. Info: "2208",
  29093. }
  29094. customData = append(customData, custom2)
  29095. custom3 := &CustomData{
  29096. MsgId: "H44022900158202103301715524756",
  29097. PsnNo: "44020000001100187221",
  29098. Info: "2208",
  29099. }
  29100. customData = append(customData, custom3)
  29101. custom4 := &CustomData{
  29102. MsgId: "H44022900158202103301730376224",
  29103. PsnNo: "44020000001101959155",
  29104. Info: "2208",
  29105. }
  29106. customData = append(customData, custom4)
  29107. custom5 := &CustomData{
  29108. MsgId: "H44022900158202103301748008725",
  29109. PsnNo: "44020000001104246641",
  29110. Info: "2208",
  29111. }
  29112. customData = append(customData, custom5)
  29113. custom6 := &CustomData{
  29114. MsgId: "H44022900158202103301718096755",
  29115. PsnNo: "44020000001102211860",
  29116. Info: "2208",
  29117. }
  29118. customData = append(customData, custom6)
  29119. custom7 := &CustomData{
  29120. MsgId: "H44022900158202103301736551640",
  29121. PsnNo: "44020000001102687718",
  29122. Info: "2208",
  29123. }
  29124. customData = append(customData, custom7)
  29125. custom8 := &CustomData{
  29126. MsgId: "H44022900158202103301743097676",
  29127. PsnNo: "44020000001102127785",
  29128. Info: "2208",
  29129. }
  29130. customData = append(customData, custom8)
  29131. custom9 := &CustomData{
  29132. MsgId: "H44022900158202103301712304203",
  29133. PsnNo: "44020000001101518097",
  29134. Info: "2208",
  29135. }
  29136. customData = append(customData, custom9)
  29137. custom10 := &CustomData{
  29138. MsgId: "H44022900158202103301738448785",
  29139. PsnNo: "44020000001100500813",
  29140. Info: "2208",
  29141. }
  29142. customData = append(customData, custom10)
  29143. custom11 := &CustomData{
  29144. MsgId: "H44022900158202103301732455843",
  29145. PsnNo: "44020000001102690557",
  29146. Info: "2208",
  29147. }
  29148. customData = append(customData, custom11)
  29149. custom12 := &CustomData{
  29150. MsgId: "H44022900158202103301745421708",
  29151. PsnNo: "44020000001102211928",
  29152. Info: "2208",
  29153. }
  29154. customData = append(customData, custom12)
  29155. custom1212 := &CustomData{
  29156. MsgId: "H440229001582021033017351627",
  29157. PsnNo: "44020000001102481733",
  29158. Info: "2208",
  29159. }
  29160. customData = append(customData, custom1212)
  29161. custom13 := &CustomData{
  29162. MsgId: "H44022900158202103301740327951",
  29163. PsnNo: "44020000001103174866",
  29164. Info: "2208",
  29165. }
  29166. customData = append(customData, custom13)
  29167. custom14 := &CustomData{
  29168. MsgId: "H4402290015820210330174922668",
  29169. PsnNo: "44020000001102927272",
  29170. Info: "2208",
  29171. }
  29172. customData = append(customData, custom14)
  29173. custom15 := &CustomData{
  29174. MsgId: "H44022900158202103301752362273",
  29175. PsnNo: "44020000001102942890",
  29176. Info: "2208",
  29177. }
  29178. customData = append(customData, custom15)
  29179. custom16 := &CustomData{
  29180. MsgId: "H44022900158202103301751082917",
  29181. PsnNo: "44020000001101662162",
  29182. Info: "2208",
  29183. }
  29184. customData = append(customData, custom16)
  29185. custom17 := &CustomData{
  29186. MsgId: "H44022900158202103301754147728",
  29187. PsnNo: "44020000000229014511",
  29188. Info: "2208",
  29189. }
  29190. customData = append(customData, custom17)
  29191. adminUser := c.GetAdminUserInfo()
  29192. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29193. for _, item := range customData {
  29194. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29195. fmt.Println(result)
  29196. }
  29197. }
  29198. func PathExists(path string) (bool, error) {
  29199. _, err := os.Stat(path)
  29200. if err == nil {
  29201. return true, nil
  29202. }
  29203. if os.IsNotExist(err) {
  29204. return false, nil
  29205. }
  29206. return false, err
  29207. }
  29208. // 创建文件夹
  29209. func Mkdir(dir string) {
  29210. // 创建文件夹
  29211. exist, err := PathExists(dir)
  29212. if err != nil {
  29213. fmt.Println(err.Error())
  29214. } else {
  29215. if exist {
  29216. fmt.Println(dir + "文件夹已存在!")
  29217. } else {
  29218. // 文件夹名称,权限
  29219. err := os.Mkdir(dir, os.ModePerm)
  29220. if err != nil {
  29221. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29222. } else {
  29223. fmt.Println(dir + "文件夹创建成功!")
  29224. }
  29225. }
  29226. }
  29227. }
  29228. // 压缩文件
  29229. func Zip(srcFile string, destZip string) error {
  29230. zipfile, err := os.Create(destZip)
  29231. if err != nil {
  29232. return err
  29233. }
  29234. defer zipfile.Close()
  29235. archive := zip.NewWriter(zipfile)
  29236. defer archive.Close()
  29237. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29238. if err != nil {
  29239. return err
  29240. }
  29241. header, err := zip.FileInfoHeader(info)
  29242. if err != nil {
  29243. return err
  29244. }
  29245. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29246. // header.Name = path
  29247. if info.IsDir() {
  29248. header.Name += "/"
  29249. } else {
  29250. header.Method = zip.Deflate
  29251. }
  29252. writer, err := archive.CreateHeader(header)
  29253. if err != nil {
  29254. return err
  29255. }
  29256. if !info.IsDir() {
  29257. file, err := os.Open(path)
  29258. if err != nil {
  29259. return err
  29260. }
  29261. defer file.Close()
  29262. _, err = io.Copy(writer, file)
  29263. }
  29264. return err
  29265. })
  29266. return err
  29267. }
  29268. func ReadFile(filePath string) []byte {
  29269. f, err := os.Open(filePath)
  29270. if err != nil {
  29271. fmt.Println("read file fail", err)
  29272. return nil
  29273. }
  29274. defer f.Close()
  29275. fd, err := ioutil.ReadAll(f)
  29276. if err != nil {
  29277. fmt.Println("read to fd fail", err)
  29278. return nil
  29279. }
  29280. return fd
  29281. }
  29282. func saveLogq(result string, request string, infno string, desc string) {
  29283. dir := "日志"
  29284. utils.Mkdir(dir)
  29285. month := time.Unix(1557042972, 0).Format("1")
  29286. year := time.Now().Format("2006")
  29287. month = time.Now().Format("01")
  29288. day := time.Now().Format("02")
  29289. hour := time.Now().Format("15")
  29290. min := time.Now().Format("04")
  29291. sec := time.Now().Format("05")
  29292. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29293. file := year + month + day + "_log"
  29294. file_name := file + ".txt"
  29295. file_path := "日志" + "/" + file_name
  29296. exist, _ := utils.PathExists(file_path)
  29297. if exist { //存在
  29298. fmt.Println("存在")
  29299. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29300. if err != nil {
  29301. fmt.Println("read fail")
  29302. }
  29303. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29304. n, _ := f.Seek(0, 2)
  29305. _, err = f.WriteAt([]byte(content), n)
  29306. } else { //不存在
  29307. fmt.Println("文件不存在,创建文件")
  29308. f, err := os.Create("日志" + "/" + file_name)
  29309. defer f.Close()
  29310. if err != nil {
  29311. } else {
  29312. _, err = f.Write([]byte("记录日志"))
  29313. }
  29314. }
  29315. }
  29316. func saveLog(result string, request string, infno string, desc string) {
  29317. org_id, _ := beego.AppConfig.Int64("org_id")
  29318. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29319. dir := miConfig.OrgName + "日志"
  29320. utils.Mkdir(dir)
  29321. month := time.Unix(1557042972, 0).Format("1")
  29322. year := time.Now().Format("2006")
  29323. month = time.Now().Format("01")
  29324. day := time.Now().Format("02")
  29325. hour := time.Now().Format("15")
  29326. min := time.Now().Format("04")
  29327. sec := time.Now().Format("05")
  29328. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29329. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29330. file_name := file + ".txt"
  29331. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29332. exist, _ := utils.PathExists(file_path)
  29333. if exist { //存在
  29334. fmt.Println("存在")
  29335. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29336. if err != nil {
  29337. fmt.Println("read fail")
  29338. }
  29339. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29340. n, _ := f.Seek(0, 2)
  29341. _, err = f.WriteAt([]byte(content), n)
  29342. } else { //不存在
  29343. fmt.Println("文件不存在,创建文件")
  29344. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29345. defer f.Close()
  29346. if err != nil {
  29347. } else {
  29348. _, err = f.Write([]byte("记录日志"))
  29349. }
  29350. }
  29351. }
  29352. type Charset string
  29353. const (
  29354. UTF8 = Charset("UTF-8")
  29355. GB18030 = Charset("GB18030")
  29356. )
  29357. func ConvertToString(src string, srcCode string, tagCode string) string {
  29358. srcCoder := mahonia.NewDecoder(srcCode)
  29359. srcResult := srcCoder.ConvertString(src)
  29360. tagCoder := mahonia.NewDecoder(tagCode)
  29361. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29362. result := string(cdata)
  29363. return result
  29364. }
  29365. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29366. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29367. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29368. var token string
  29369. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29370. var api string
  29371. if miConfig.MdtrtareaAdmvs == "320921" {
  29372. 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 +
  29373. "&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
  29374. fmt.Println(api)
  29375. } else {
  29376. 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 +
  29377. "&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
  29378. }
  29379. resp, requestErr := http.Get(api)
  29380. if requestErr != nil {
  29381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29382. return ""
  29383. }
  29384. body, ioErr := ioutil.ReadAll(resp.Body)
  29385. if ioErr != nil {
  29386. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29388. return ""
  29389. }
  29390. var respJSON map[string]interface{}
  29391. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29392. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29394. return ""
  29395. }
  29396. var status string
  29397. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29398. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29399. var res ResultTwo //1101结果
  29400. var res10265 ResultTwo10265 //1101结果
  29401. if status == "0" { //读卡成功
  29402. var card_info string //卡信息
  29403. var busi_card_info string
  29404. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29405. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29406. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29407. fmt.Println(card_info)
  29408. fmt.Println(busi_card_info)
  29409. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29410. result, _ := json.Marshal(respJSON)
  29411. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29412. utils.ErrorLog("解析失败:%v", err)
  29413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29414. return ""
  29415. }
  29416. res.ErrMsg = res10265.ErrMsg
  29417. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29418. res.Infcode = infocode
  29419. res.Output = res10265.Output
  29420. res.InfRefmsgid = res10265.InfRefmsgid
  29421. if res.Infcode == 0 {
  29422. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29423. if err == gorm.ErrRecordNotFound {
  29424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29425. return ""
  29426. } else if err != nil {
  29427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29428. return ""
  29429. } else {
  29430. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29431. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29432. infoStr := string(Iinfos)
  29433. idetinfoStr := string(Idetinfos)
  29434. psn := &models.HisPsn{
  29435. PsnNo: res.Output.Baseinfo.PsnNo,
  29436. PatientId: patient.ID,
  29437. Certno: res.Output.Baseinfo.Certno,
  29438. Gend: res.Output.Baseinfo.Gend,
  29439. Naty: res.Output.Baseinfo.Naty,
  29440. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29441. PsnName: res.Output.Baseinfo.PsnName,
  29442. Idetinfo: idetinfoStr,
  29443. Insuinfo: infoStr,
  29444. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29445. CardInfo: card_info,
  29446. VerifyNumber: token,
  29447. }
  29448. service.CreateHisPsn(psn)
  29449. return token
  29450. }
  29451. }
  29452. } else {
  29453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29454. return ""
  29455. }
  29456. } else { //读卡失败
  29457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29458. return ""
  29459. }
  29460. return token
  29461. }
  29462. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29463. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29464. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29465. var token string
  29466. var api string
  29467. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29468. "&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
  29469. fmt.Println(api)
  29470. resp, requestErr := http.Get(api)
  29471. if requestErr != nil {
  29472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29473. return ""
  29474. }
  29475. body, ioErr := ioutil.ReadAll(resp.Body)
  29476. if ioErr != nil {
  29477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29479. return ""
  29480. }
  29481. var respJSON map[string]interface{}
  29482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29485. return ""
  29486. }
  29487. var status string
  29488. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29489. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29490. var res ResultTwo //1101结果
  29491. if status == "1" { //读卡成功
  29492. var card_info string //卡信息
  29493. var busi_card_info string
  29494. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29495. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29496. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29497. fmt.Println(card_info)
  29498. fmt.Println(busi_card_info)
  29499. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29500. result, _ := json.Marshal(respJSON)
  29501. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29502. utils.ErrorLog("解析失败:%v", err)
  29503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29504. return ""
  29505. }
  29506. if res.Infcode == 0 {
  29507. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29508. if err == gorm.ErrRecordNotFound {
  29509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29510. return ""
  29511. } else if err != nil {
  29512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29513. return ""
  29514. } else {
  29515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29517. infoStr := string(Iinfos)
  29518. idetinfoStr := string(Idetinfos)
  29519. psn := &models.HisPsn{
  29520. PsnNo: res.Output.Baseinfo.PsnNo,
  29521. PatientId: patient.ID,
  29522. Certno: res.Output.Baseinfo.Certno,
  29523. Gend: res.Output.Baseinfo.Gend,
  29524. Naty: res.Output.Baseinfo.Naty,
  29525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29526. PsnName: res.Output.Baseinfo.PsnName,
  29527. Idetinfo: idetinfoStr,
  29528. Insuinfo: infoStr,
  29529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29530. CardInfo: card_info,
  29531. VerifyNumber: token,
  29532. }
  29533. service.CreateHisPsn(psn)
  29534. return token
  29535. }
  29536. }
  29537. } else {
  29538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29539. return ""
  29540. }
  29541. return token
  29542. }
  29543. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29544. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29545. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29546. var token string
  29547. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29548. var api string
  29549. if miConfig.MdtrtareaAdmvs == "320921" {
  29550. 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 +
  29551. "&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
  29552. fmt.Println(api)
  29553. } else {
  29554. 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 +
  29555. "&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
  29556. }
  29557. resp, requestErr := http.Get(api)
  29558. if requestErr != nil {
  29559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29560. return ""
  29561. }
  29562. body, ioErr := ioutil.ReadAll(resp.Body)
  29563. if ioErr != nil {
  29564. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29566. return ""
  29567. }
  29568. var respJSON map[string]interface{}
  29569. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29570. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29572. return ""
  29573. }
  29574. var status string
  29575. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29576. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29577. var res ResultTwo //1101结果
  29578. var res10265 ResultTwo10265 //1101结果
  29579. if status == "0" { //读卡成功
  29580. var card_info string //卡信息
  29581. var busi_card_info string
  29582. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29583. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29584. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29585. fmt.Println(card_info)
  29586. fmt.Println(busi_card_info)
  29587. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29588. result, _ := json.Marshal(respJSON)
  29589. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29590. utils.ErrorLog("解析失败:%v", err)
  29591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29592. return ""
  29593. }
  29594. res.ErrMsg = res10265.ErrMsg
  29595. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29596. res.Infcode = infocode
  29597. res.Output = res10265.Output
  29598. res.InfRefmsgid = res10265.InfRefmsgid
  29599. if res.Infcode == 0 {
  29600. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29601. if err == gorm.ErrRecordNotFound {
  29602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29603. return ""
  29604. } else if err != nil {
  29605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29606. return ""
  29607. } else {
  29608. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29609. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29610. infoStr := string(Iinfos)
  29611. idetinfoStr := string(Idetinfos)
  29612. psn := &models.HisPsn{
  29613. PsnNo: res.Output.Baseinfo.PsnNo,
  29614. PatientId: patient.ID,
  29615. Certno: res.Output.Baseinfo.Certno,
  29616. Gend: res.Output.Baseinfo.Gend,
  29617. Naty: res.Output.Baseinfo.Naty,
  29618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29619. PsnName: res.Output.Baseinfo.PsnName,
  29620. Idetinfo: idetinfoStr,
  29621. Insuinfo: infoStr,
  29622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29623. CardInfo: card_info,
  29624. VerifyNumber: token,
  29625. }
  29626. service.CreateHisPsn(psn)
  29627. return token
  29628. }
  29629. }
  29630. } else {
  29631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29632. return ""
  29633. }
  29634. } else { //读卡失败
  29635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29636. return ""
  29637. }
  29638. return token
  29639. }
  29640. func DeleteExtraSpaceTwo(s string) string {
  29641. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29642. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29643. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29644. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29645. s2 := make([]byte, len(s1)) //定义字符数组切片
  29646. copy(s2, s1) //将字符串复制到切片
  29647. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29648. for len(spc_index) > 0 { //找到适配项
  29649. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29650. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29651. }
  29652. return string(s2)
  29653. }
  29654. func Remove0000(s string) string {
  29655. str := make([]rune, 0, len(s))
  29656. for _, v := range []rune(s) {
  29657. if v == 0 {
  29658. continue
  29659. }
  29660. str = append(str, v)
  29661. }
  29662. return string(str)
  29663. }
  29664. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29665. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29666. readCard := DllDef.MustFindProc("EcQuery")
  29667. pCardInfo := make([]byte, 8192)
  29668. pBusiCardInfo := make([]byte, 8192)
  29669. data := make(map[string]interface{})
  29670. //pData := make(map[string]interface{})
  29671. inputData := make(map[string]interface{})
  29672. inputData["orgId"] = code
  29673. inputData["businessType"] = "01101"
  29674. inputData["operatorId"] = operator_id
  29675. inputData["operatorName"] = operator_name
  29676. inputData["officeId"] = "001"
  29677. inputData["officeName"] = "血透室"
  29678. //
  29679. data["data"] = inputData
  29680. data["transType"] = "ec.query"
  29681. data["orgId"] = code
  29682. bytesData, _ := json.Marshal(data)
  29683. pCardInfo = bytesData
  29684. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29685. fmt.Println(ret2)
  29686. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29687. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29688. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29689. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29690. if ret2 != 0 {
  29691. return "", ""
  29692. }
  29693. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29694. }
  29695. func DeleteExtraSpace(s string) string {
  29696. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29697. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29698. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29699. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29700. s2 := make([]byte, len(s1)) //定义字符数组切片
  29701. copy(s2, s1) //将字符串复制到切片
  29702. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29703. for len(spc_index) > 0 { //找到适配项
  29704. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29705. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29706. }
  29707. return string(s2)
  29708. }
  29709. // 对账
  29710. func (c *HisApiController) Post3202() {
  29711. start_time := c.GetString("start_time")
  29712. end_time := c.GetString("end_time")
  29713. //insutype := c.GetString("insutype")
  29714. clr_type := c.GetString("clr_type")
  29715. clr_org := c.GetString("clr_optins")
  29716. admin_user_id, _ := c.GetInt64("admin_user_id")
  29717. adminUser := c.GetAdminUserInfo()
  29718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29719. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29720. if len(clr_org) == 0 {
  29721. clr_org = miConfig.MdtrtareaAdmvs
  29722. }
  29723. timeLayout := "2006-01-02"
  29724. loc, _ := time.LoadLocation("Local")
  29725. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29726. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29727. var orders []*models.HisOrder
  29728. if clr_org == "421300" {
  29729. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29730. } else {
  29731. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29732. }
  29733. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29734. //fixmedins_setl_cnt := int64(len(orders))
  29735. var medfee_sumamt float64
  29736. var acct_pay float64
  29737. var fund_pay_sumamt float64
  29738. for _, item := range orders {
  29739. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29740. acct_pay = acct_pay + item.AcctPay
  29741. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29742. }
  29743. //var medfee_sumamt_two float64
  29744. //var acct_pay_two float64
  29745. //var fund_pay_sumamt_two float64
  29746. //for _, item := range orders_two {
  29747. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29748. // acct_pay_two = acct_pay_two + item.AcctPay
  29749. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29750. //}
  29751. //var user_name string
  29752. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29753. //if role.ID == 0 {
  29754. // user_name = "xxx"
  29755. //} else {
  29756. // user_name = role.UserName
  29757. //}
  29758. var res ResultSix
  29759. if config.IsOpen == 1 {
  29760. var bps []*models.BusinessParamsTwo
  29761. var bp models.BusinessParamsTwo
  29762. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29763. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29764. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29765. bp.MedfeeSumamt = medfee_sumamt_str
  29766. bp.AcctPay = acct_pay_str
  29767. bp.FundPaySumamt = fund_pay_sumamt_str
  29768. bp.Insutype = ""
  29769. bp.StmtBegndate = start_time
  29770. bp.ClrType = clr_type
  29771. bp.SetlOptins = clr_org
  29772. bp.StmtEnddate = end_time
  29773. bps = append(bps, &bp)
  29774. data := make(map[string]interface{})
  29775. data["bps"] = bps
  29776. data["org_name"] = miConfig.OrgName
  29777. data["doctor"] = role.UserName
  29778. data["fixmedins_code"] = miConfig.Code
  29779. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29780. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29781. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29782. if miConfig.MdtrtareaAdmvs == "421300" {
  29783. client := &http.Client{}
  29784. bytesData, _ := json.Marshal(data)
  29785. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29786. resp, _ := client.Do(req)
  29787. defer resp.Body.Close()
  29788. body, ioErr := ioutil.ReadAll(resp.Body)
  29789. if ioErr != nil {
  29790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29792. return
  29793. }
  29794. var respJSON map[string]interface{}
  29795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29798. return
  29799. }
  29800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29801. userJSONBytes, _ := json.Marshal(respJSON)
  29802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29803. utils.ErrorLog("解析失败:%v", err)
  29804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29805. return
  29806. }
  29807. }
  29808. if miConfig.MdtrtareaAdmvs == "420200" {
  29809. client := &http.Client{}
  29810. bytesData, _ := json.Marshal(data)
  29811. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29812. resp, _ := client.Do(req)
  29813. defer resp.Body.Close()
  29814. body, ioErr := ioutil.ReadAll(resp.Body)
  29815. if ioErr != nil {
  29816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29818. return
  29819. }
  29820. var respJSON map[string]interface{}
  29821. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29824. return
  29825. }
  29826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29827. userJSONBytes, _ := json.Marshal(respJSON)
  29828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29829. utils.ErrorLog("解析失败:%v", err)
  29830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29831. return
  29832. }
  29833. }
  29834. if miConfig.MdtrtareaAdmvs == "421182" {
  29835. client := &http.Client{}
  29836. bytesData, _ := json.Marshal(data)
  29837. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  29838. resp, _ := client.Do(req)
  29839. defer resp.Body.Close()
  29840. body, ioErr := ioutil.ReadAll(resp.Body)
  29841. if ioErr != nil {
  29842. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29844. return
  29845. }
  29846. var respJSON map[string]interface{}
  29847. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29848. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29850. return
  29851. }
  29852. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29853. userJSONBytes, _ := json.Marshal(respJSON)
  29854. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29855. utils.ErrorLog("解析失败:%v", err)
  29856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29857. return
  29858. }
  29859. }
  29860. if res.Infcode == 0 {
  29861. c.ServeSuccessJSON(map[string]interface{}{
  29862. "msg": "发起成功",
  29863. })
  29864. } else {
  29865. c.ServeSuccessJSON(map[string]interface{}{
  29866. "failed_code": -10,
  29867. "msg": res.ErrMsg,
  29868. })
  29869. }
  29870. }
  29871. }
  29872. func (c *HisApiController) Post3202b() {
  29873. start_time := c.GetString("start_time")
  29874. end_time := c.GetString("end_time")
  29875. //insutype := c.GetString("insutype")
  29876. clr_type := c.GetString("clr_type")
  29877. clr_org := c.GetString("clr_optins")
  29878. admin_user_id, _ := c.GetInt64("admin_user_id")
  29879. adminUser := c.GetAdminUserInfo()
  29880. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29881. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29882. if len(clr_org) == 0 {
  29883. clr_org = miConfig.MdtrtareaAdmvs
  29884. }
  29885. timeLayout := "2006-01-02"
  29886. loc, _ := time.LoadLocation("Local")
  29887. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29888. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29889. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29890. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29891. //fixmedins_setl_cnt := int64(len(orders))
  29892. var medfee_sumamt float64
  29893. var acct_pay float64
  29894. var fund_pay_sumamt float64
  29895. for _, item := range orders {
  29896. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29897. acct_pay = acct_pay + item.AcctPay
  29898. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29899. }
  29900. //var medfee_sumamt_two float64
  29901. //var acct_pay_two float64
  29902. //var fund_pay_sumamt_two float64
  29903. //for _, item := range orders_two {
  29904. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29905. // acct_pay_two = acct_pay_two + item.AcctPay
  29906. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29907. //}
  29908. //var user_name string
  29909. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29910. //if role.ID == 0 {
  29911. // user_name = "xxx"
  29912. //} else {
  29913. // user_name = role.UserName
  29914. //}
  29915. var res ResultSix
  29916. if config.IsOpen == 1 {
  29917. var bps []*models.BusinessParamsTwo
  29918. var bp models.BusinessParamsTwo
  29919. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29920. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29921. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29922. bp.MedfeeSumamt = medfee_sumamt_str
  29923. bp.AcctPay = acct_pay_str
  29924. bp.FundPaySumamt = fund_pay_sumamt_str
  29925. bp.Insutype = "390"
  29926. bp.StmtBegndate = start_time
  29927. bp.ClrType = clr_type
  29928. bp.SetlOptins = clr_org
  29929. bp.StmtEnddate = end_time
  29930. bps = append(bps, &bp)
  29931. data := make(map[string]interface{})
  29932. data["bps"] = bps
  29933. data["org_name"] = miConfig.OrgName
  29934. data["doctor"] = role.UserName
  29935. data["fixmedins_code"] = miConfig.Code
  29936. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29937. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29938. if miConfig.MdtrtareaAdmvs == "421300" {
  29939. client := &http.Client{}
  29940. bytesData, _ := json.Marshal(data)
  29941. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29942. resp, _ := client.Do(req)
  29943. defer resp.Body.Close()
  29944. body, ioErr := ioutil.ReadAll(resp.Body)
  29945. if ioErr != nil {
  29946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29948. return
  29949. }
  29950. var respJSON map[string]interface{}
  29951. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29954. return
  29955. }
  29956. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29957. userJSONBytes, _ := json.Marshal(respJSON)
  29958. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29959. utils.ErrorLog("解析失败:%v", err)
  29960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29961. return
  29962. }
  29963. }
  29964. if miConfig.MdtrtareaAdmvs == "420200" {
  29965. client := &http.Client{}
  29966. bytesData, _ := json.Marshal(data)
  29967. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29968. resp, _ := client.Do(req)
  29969. defer resp.Body.Close()
  29970. body, ioErr := ioutil.ReadAll(resp.Body)
  29971. if ioErr != nil {
  29972. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29974. return
  29975. }
  29976. var respJSON map[string]interface{}
  29977. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29978. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29980. return
  29981. }
  29982. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29983. userJSONBytes, _ := json.Marshal(respJSON)
  29984. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29985. utils.ErrorLog("解析失败:%v", err)
  29986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29987. return
  29988. }
  29989. }
  29990. if miConfig.MdtrtareaAdmvs == "421182" {
  29991. client := &http.Client{}
  29992. bytesData, _ := json.Marshal(data)
  29993. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29994. resp, _ := client.Do(req)
  29995. defer resp.Body.Close()
  29996. body, ioErr := ioutil.ReadAll(resp.Body)
  29997. if ioErr != nil {
  29998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30000. return
  30001. }
  30002. var respJSON map[string]interface{}
  30003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30006. return
  30007. }
  30008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30009. userJSONBytes, _ := json.Marshal(respJSON)
  30010. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30011. utils.ErrorLog("解析失败:%v", err)
  30012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30013. return
  30014. }
  30015. }
  30016. if res.Infcode == 0 {
  30017. c.ServeSuccessJSON(map[string]interface{}{
  30018. "msg": "发起成功",
  30019. })
  30020. } else {
  30021. c.ServeSuccessJSON(map[string]interface{}{
  30022. "failed_code": -10,
  30023. "msg": res.ErrMsg,
  30024. })
  30025. }
  30026. }
  30027. }
  30028. func (c *HisApiController) Post1608() {
  30029. start_time := c.GetString("start_time")
  30030. end_time := c.GetString("end_time")
  30031. admin_user_id, _ := c.GetInt64("admin_user_id")
  30032. adminUser := c.GetAdminUserInfo()
  30033. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30034. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30035. timeLayout := "2006-01-02"
  30036. loc, _ := time.LoadLocation("Local")
  30037. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  30038. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  30039. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  30040. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  30041. fixmedins_setl_cnt := int64(len(orders))
  30042. var medfee_sumamt float64
  30043. var func_smamt float64
  30044. for _, item := range orders {
  30045. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  30046. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  30047. }
  30048. times := strings.Split(start_time, "-")
  30049. time_tows := strings.Split(end_time, "-")
  30050. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30051. var res ResultSix
  30052. if config.IsOpen == 1 {
  30053. //var bps []*models.BusinessParamsTwo
  30054. //var bp models.BusinessParamsTwo
  30055. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  30056. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  30057. data := make(map[string]interface{})
  30058. data["org_name"] = miConfig.OrgName
  30059. data["doctor"] = role.UserName
  30060. data["func_smamt"] = func_smamt_str
  30061. data["fixmedins_code"] = miConfig.Code
  30062. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30063. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30064. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  30065. data["medfee_sumamt"] = medfee_sumamt_str
  30066. data["start_time"] = times[0] + times[1] + times[2]
  30067. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  30068. if miConfig.MdtrtareaAdmvs == "421300" {
  30069. client := &http.Client{}
  30070. bytesData, _ := json.Marshal(data)
  30071. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30072. resp, _ := client.Do(req)
  30073. defer resp.Body.Close()
  30074. body, ioErr := ioutil.ReadAll(resp.Body)
  30075. if ioErr != nil {
  30076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30078. return
  30079. }
  30080. var respJSON map[string]interface{}
  30081. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30084. return
  30085. }
  30086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30087. userJSONBytes, _ := json.Marshal(respJSON)
  30088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30089. utils.ErrorLog("解析失败:%v", err)
  30090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30091. return
  30092. }
  30093. }
  30094. if miConfig.MdtrtareaAdmvs == "420200" {
  30095. client := &http.Client{}
  30096. bytesData, _ := json.Marshal(data)
  30097. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30098. resp, _ := client.Do(req)
  30099. defer resp.Body.Close()
  30100. body, ioErr := ioutil.ReadAll(resp.Body)
  30101. if ioErr != nil {
  30102. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30104. return
  30105. }
  30106. var respJSON map[string]interface{}
  30107. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30108. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30110. return
  30111. }
  30112. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30113. userJSONBytes, _ := json.Marshal(respJSON)
  30114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30115. utils.ErrorLog("解析失败:%v", err)
  30116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30117. return
  30118. }
  30119. }
  30120. if miConfig.MdtrtareaAdmvs == "421182" {
  30121. client := &http.Client{}
  30122. bytesData, _ := json.Marshal(data)
  30123. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30124. resp, _ := client.Do(req)
  30125. defer resp.Body.Close()
  30126. body, ioErr := ioutil.ReadAll(resp.Body)
  30127. if ioErr != nil {
  30128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. var respJSON map[string]interface{}
  30133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30136. return
  30137. }
  30138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30139. userJSONBytes, _ := json.Marshal(respJSON)
  30140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30141. utils.ErrorLog("解析失败:%v", err)
  30142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30143. return
  30144. }
  30145. }
  30146. if res.Infcode == 0 {
  30147. c.ServeSuccessJSON(map[string]interface{}{
  30148. "msg": "发起成功",
  30149. })
  30150. } else {
  30151. c.ServeSuccessJSON(map[string]interface{}{
  30152. "failed_code": -10,
  30153. "msg": res.ErrMsg,
  30154. })
  30155. }
  30156. }
  30157. }
  30158. // 5.11.1.1【5262】结算信息按时间段查询
  30159. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30160. admin_user_id, _ := c.GetInt64("admin_user_id")
  30161. adminUser := c.GetAdminUserInfo()
  30162. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30163. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30164. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30165. var res Result5262
  30166. if config.IsOpen == 1 {
  30167. if miConfig.MdtrtareaAdmvs == "421300" {
  30168. data := make(map[string]interface{})
  30169. data["bps"] = bp
  30170. data["org_name"] = miConfig.OrgName
  30171. data["doctor"] = role.UserName
  30172. data["fixmedins_code"] = miConfig.Code
  30173. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30174. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30175. data["page"] = strconv.FormatInt(page, 10)
  30176. data["limit"] = strconv.FormatInt(limit, 10)
  30177. fmt.Println(data)
  30178. client := &http.Client{}
  30179. bytesData, _ := json.Marshal(data)
  30180. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30181. resp, _ := client.Do(req)
  30182. defer resp.Body.Close()
  30183. body, ioErr := ioutil.ReadAll(resp.Body)
  30184. if ioErr != nil {
  30185. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30187. return
  30188. }
  30189. var respJSON map[string]interface{}
  30190. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30191. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30193. return
  30194. }
  30195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30196. userJSONBytes, _ := json.Marshal(respJSON)
  30197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30198. utils.ErrorLog("解析失败:%v", err)
  30199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30200. return
  30201. }
  30202. }
  30203. if miConfig.MdtrtareaAdmvs == "420200" {
  30204. data := make(map[string]interface{})
  30205. data["bps"] = bp
  30206. data["org_name"] = miConfig.OrgName
  30207. data["doctor"] = role.UserName
  30208. data["fixmedins_code"] = miConfig.Code
  30209. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30210. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30211. data["page"] = strconv.FormatInt(page, 10)
  30212. data["limit"] = strconv.FormatInt(limit, 10)
  30213. fmt.Println(data)
  30214. client := &http.Client{}
  30215. bytesData, _ := json.Marshal(data)
  30216. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30217. resp, _ := client.Do(req)
  30218. defer resp.Body.Close()
  30219. body, ioErr := ioutil.ReadAll(resp.Body)
  30220. if ioErr != nil {
  30221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30223. return
  30224. }
  30225. var respJSON map[string]interface{}
  30226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30229. return
  30230. }
  30231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30232. userJSONBytes, _ := json.Marshal(respJSON)
  30233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30234. utils.ErrorLog("解析失败:%v", err)
  30235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30236. return
  30237. }
  30238. }
  30239. if miConfig.MdtrtareaAdmvs == "421182" {
  30240. data := make(map[string]interface{})
  30241. data["bps"] = bp
  30242. data["org_name"] = miConfig.OrgName
  30243. data["doctor"] = role.UserName
  30244. data["fixmedins_code"] = miConfig.Code
  30245. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30246. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30247. data["page"] = strconv.FormatInt(page, 10)
  30248. data["limit"] = strconv.FormatInt(limit, 10)
  30249. fmt.Println(data)
  30250. client := &http.Client{}
  30251. bytesData, _ := json.Marshal(data)
  30252. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30253. resp, _ := client.Do(req)
  30254. defer resp.Body.Close()
  30255. body, ioErr := ioutil.ReadAll(resp.Body)
  30256. if ioErr != nil {
  30257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30259. return
  30260. }
  30261. var respJSON map[string]interface{}
  30262. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30265. return
  30266. }
  30267. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30268. userJSONBytes, _ := json.Marshal(respJSON)
  30269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30270. utils.ErrorLog("解析失败:%v", err)
  30271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30272. return
  30273. }
  30274. }
  30275. if res.Infcode == 0 {
  30276. c.ServeSuccessJSON(map[string]interface{}{
  30277. "order": res.Output.Result,
  30278. "total": res.Output.PageInfo.RecordCounts,
  30279. })
  30280. } else {
  30281. c.ServeSuccessJSON(map[string]interface{}{
  30282. "failed_code": -10,
  30283. "msg": res.ErrMsg,
  30284. })
  30285. }
  30286. }
  30287. }
  30288. // 5.11.1.2【5267】异地结算信息时间段查询
  30289. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30290. admin_user_id, _ := c.GetInt64("admin_user_id")
  30291. adminUser := c.GetAdminUserInfo()
  30292. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30293. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30294. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30295. var res Result5267
  30296. if config.IsOpen == 1 {
  30297. if miConfig.MdtrtareaAdmvs == "421300" {
  30298. data := make(map[string]interface{})
  30299. data["bps"] = bp
  30300. data["org_name"] = miConfig.OrgName
  30301. data["doctor"] = role.UserName
  30302. data["fixmedins_code"] = miConfig.Code
  30303. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30304. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30305. data["page"] = page
  30306. data["limit"] = limit
  30307. fmt.Println(data)
  30308. client := &http.Client{}
  30309. bytesData, _ := json.Marshal(data)
  30310. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30311. resp, _ := client.Do(req)
  30312. defer resp.Body.Close()
  30313. body, ioErr := ioutil.ReadAll(resp.Body)
  30314. if ioErr != nil {
  30315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30317. return
  30318. }
  30319. var respJSON map[string]interface{}
  30320. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30323. return
  30324. }
  30325. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30326. userJSONBytes, _ := json.Marshal(respJSON)
  30327. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30328. utils.ErrorLog("解析失败:%v", err)
  30329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30330. return
  30331. }
  30332. }
  30333. if miConfig.MdtrtareaAdmvs == "420200" {
  30334. data := make(map[string]interface{})
  30335. data["bps"] = bp
  30336. data["org_name"] = miConfig.OrgName
  30337. data["doctor"] = role.UserName
  30338. data["fixmedins_code"] = miConfig.Code
  30339. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30340. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30341. data["page"] = page
  30342. data["limit"] = limit
  30343. fmt.Println(data)
  30344. client := &http.Client{}
  30345. bytesData, _ := json.Marshal(data)
  30346. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30347. resp, _ := client.Do(req)
  30348. defer resp.Body.Close()
  30349. body, ioErr := ioutil.ReadAll(resp.Body)
  30350. if ioErr != nil {
  30351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30353. return
  30354. }
  30355. var respJSON map[string]interface{}
  30356. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30359. return
  30360. }
  30361. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30362. userJSONBytes, _ := json.Marshal(respJSON)
  30363. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30364. utils.ErrorLog("解析失败:%v", err)
  30365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30366. return
  30367. }
  30368. }
  30369. if miConfig.MdtrtareaAdmvs == "421182" {
  30370. data := make(map[string]interface{})
  30371. data["bps"] = bp
  30372. data["org_name"] = miConfig.OrgName
  30373. data["doctor"] = role.UserName
  30374. data["fixmedins_code"] = miConfig.Code
  30375. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30376. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30377. data["page"] = page
  30378. data["limit"] = limit
  30379. fmt.Println(data)
  30380. client := &http.Client{}
  30381. bytesData, _ := json.Marshal(data)
  30382. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30383. resp, _ := client.Do(req)
  30384. defer resp.Body.Close()
  30385. body, ioErr := ioutil.ReadAll(resp.Body)
  30386. if ioErr != nil {
  30387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30389. return
  30390. }
  30391. var respJSON map[string]interface{}
  30392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30395. return
  30396. }
  30397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30398. userJSONBytes, _ := json.Marshal(respJSON)
  30399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30400. utils.ErrorLog("解析失败:%v", err)
  30401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30402. return
  30403. }
  30404. }
  30405. if res.Infcode == 0 {
  30406. c.ServeSuccessJSON(map[string]interface{}{
  30407. "order": res.Output.Result,
  30408. "total": res.Output.PageInfo.RecordCounts,
  30409. })
  30410. } else {
  30411. c.ServeSuccessJSON(map[string]interface{}{
  30412. "failed_code": -10,
  30413. "msg": res.ErrMsg,
  30414. })
  30415. }
  30416. }
  30417. }
  30418. func (c *HisApiController) Post3501() {
  30419. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30420. data := make(map[string]interface{})
  30421. var struct3501s []models.Struct3501
  30422. var struct3501 models.Struct3501
  30423. struct3501.OrgName = miConfig.OrgName
  30424. struct3501.AccessKey = miConfig.AccessKey
  30425. struct3501.RequestUrl = miConfig.Url
  30426. struct3501.SecretKey = miConfig.SecretKey
  30427. struct3501.ManuDate = "2022-08-17"
  30428. struct3501.FixmedinsBchno = ""
  30429. struct3501.ManuLotnum = ""
  30430. struct3501.RxFlag = "0"
  30431. struct3501.ExpyEnd = "2022-08-17"
  30432. struct3501.Invdate = "2022-08-17"
  30433. struct3501.InvCnt = "20.25"
  30434. struct3501.Memo = ""
  30435. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30436. struct3501.FixmedinsHilistId = miConfig.Code
  30437. struct3501.FixmedinsHilistName = miConfig.OrgName
  30438. struct3501s = append(struct3501s, struct3501)
  30439. data["struct_3501s"] = struct3501s
  30440. client := &http.Client{}
  30441. bytesData, _ := json.Marshal(data)
  30442. var req *http.Request
  30443. if miConfig.MdtrtareaAdmvs == "320921" {
  30444. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30445. } else {
  30446. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30447. }
  30448. resp, _ := client.Do(req)
  30449. defer resp.Body.Close()
  30450. body, ioErr := ioutil.ReadAll(resp.Body)
  30451. if ioErr != nil {
  30452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30454. return
  30455. }
  30456. var respJSON map[string]interface{}
  30457. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30460. return
  30461. }
  30462. var res ResultSix
  30463. var resSix10265 ResultSix10265 //1101结果
  30464. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30465. result, _ := json.Marshal(respJSON)
  30466. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30467. utils.ErrorLog("解析失败:%v", err)
  30468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30469. return
  30470. }
  30471. res.InfRefmsgid = resSix10265.InfRefmsgid
  30472. res.Output = resSix10265.Output
  30473. res.ErrMsg = resSix10265.ErrMsg
  30474. res.Cainfo = resSix10265.Cainfo
  30475. res.WarnMsg = resSix10265.WarnMsg
  30476. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30477. res.Infcode = infocode
  30478. if infocode == 0 {
  30479. c.ServeSuccessJSON(map[string]interface{}{
  30480. "msg": "上传成功",
  30481. })
  30482. return
  30483. } else {
  30484. c.ServeSuccessJSON(map[string]interface{}{
  30485. "failed_code": -10,
  30486. "msg": res.ErrMsg,
  30487. })
  30488. return
  30489. }
  30490. }
  30491. func (c *HisApiController) Post3502() {
  30492. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30493. data := make(map[string]interface{})
  30494. var struct3502s []models.Struct3502
  30495. var struct3502 models.Struct3502
  30496. struct3502.OrgName = miConfig.OrgName
  30497. struct3502.AccessKey = miConfig.AccessKey
  30498. struct3502.RequestUrl = miConfig.Url
  30499. struct3502.SecretKey = miConfig.SecretKey
  30500. struct3502.ManuDate = "2022-08-15"
  30501. struct3502.FixmedinsBchno = ""
  30502. struct3502.ManuLotnum = ""
  30503. struct3502.RxFlag = "0"
  30504. struct3502.ExpyEnd = "2022-08-15"
  30505. struct3502.Invdate = "2022-08-15"
  30506. struct3502.InvCnt = "20.25"
  30507. struct3502.Memo = ""
  30508. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30509. struct3502.FixmedinsHilistId = miConfig.Code
  30510. struct3502.FixmedinsHilistName = miConfig.OrgName
  30511. struct3502s = append(struct3502s, struct3502)
  30512. data["struct_3502s"] = struct3502s
  30513. client := &http.Client{}
  30514. bytesData, _ := json.Marshal(data)
  30515. var req *http.Request
  30516. if miConfig.MdtrtareaAdmvs == "320921" {
  30517. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30518. } else {
  30519. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30520. }
  30521. resp, _ := client.Do(req)
  30522. defer resp.Body.Close()
  30523. body, ioErr := ioutil.ReadAll(resp.Body)
  30524. if ioErr != nil {
  30525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30527. return
  30528. }
  30529. var respJSON map[string]interface{}
  30530. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30533. return
  30534. }
  30535. var res ResultSix
  30536. var resSix10265 ResultSix10265 //1101结果
  30537. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30538. result, _ := json.Marshal(respJSON)
  30539. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30540. utils.ErrorLog("解析失败:%v", err)
  30541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30542. return
  30543. }
  30544. res.InfRefmsgid = resSix10265.InfRefmsgid
  30545. res.Output = resSix10265.Output
  30546. res.ErrMsg = resSix10265.ErrMsg
  30547. res.Cainfo = resSix10265.Cainfo
  30548. res.WarnMsg = resSix10265.WarnMsg
  30549. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30550. res.Infcode = infocode
  30551. if infocode == 0 {
  30552. c.ServeSuccessJSON(map[string]interface{}{
  30553. "msg": "上传成功",
  30554. })
  30555. return
  30556. } else {
  30557. c.ServeSuccessJSON(map[string]interface{}{
  30558. "failed_code": -10,
  30559. "msg": res.ErrMsg,
  30560. })
  30561. return
  30562. }
  30563. }
  30564. func (c *HisApiController) Post3503() {
  30565. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30566. data := make(map[string]interface{})
  30567. var struct3501s []models.Struct3501
  30568. var struct3501 models.Struct3501
  30569. struct3501.OrgName = miConfig.OrgName
  30570. struct3501.AccessKey = miConfig.AccessKey
  30571. struct3501.RequestUrl = miConfig.Url
  30572. struct3501.SecretKey = miConfig.SecretKey
  30573. struct3501.ManuDate = "2022-08-15"
  30574. struct3501.FixmedinsBchno = ""
  30575. struct3501.ManuLotnum = ""
  30576. struct3501.RxFlag = "0"
  30577. struct3501.ExpyEnd = "2022-08-15"
  30578. struct3501.Invdate = "2022-08-15"
  30579. struct3501.InvCnt = "20.25"
  30580. struct3501.Memo = ""
  30581. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30582. struct3501.FixmedinsHilistId = miConfig.Code
  30583. struct3501.FixmedinsHilistName = miConfig.OrgName
  30584. struct3501s = append(struct3501s, struct3501)
  30585. data["struct_3501s"] = struct3501s
  30586. client := &http.Client{}
  30587. bytesData, _ := json.Marshal(data)
  30588. var req *http.Request
  30589. if miConfig.MdtrtareaAdmvs == "320921" {
  30590. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30591. } else {
  30592. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30593. }
  30594. resp, _ := client.Do(req)
  30595. defer resp.Body.Close()
  30596. body, ioErr := ioutil.ReadAll(resp.Body)
  30597. if ioErr != nil {
  30598. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30600. return
  30601. }
  30602. var respJSON map[string]interface{}
  30603. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30604. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30606. return
  30607. }
  30608. var res ResultSix
  30609. var resSix10265 ResultSix10265 //1101结果
  30610. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30611. result, _ := json.Marshal(respJSON)
  30612. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30613. utils.ErrorLog("解析失败:%v", err)
  30614. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30615. return
  30616. }
  30617. res.InfRefmsgid = resSix10265.InfRefmsgid
  30618. res.Output = resSix10265.Output
  30619. res.ErrMsg = resSix10265.ErrMsg
  30620. res.Cainfo = resSix10265.Cainfo
  30621. res.WarnMsg = resSix10265.WarnMsg
  30622. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30623. res.Infcode = infocode
  30624. if infocode == 0 {
  30625. c.ServeSuccessJSON(map[string]interface{}{
  30626. "msg": "上传成功",
  30627. })
  30628. return
  30629. } else {
  30630. c.ServeSuccessJSON(map[string]interface{}{
  30631. "failed_code": -10,
  30632. "msg": res.ErrMsg,
  30633. })
  30634. return
  30635. }
  30636. }
  30637. func (c *HisApiController) Post3504() {
  30638. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30639. data := make(map[string]interface{})
  30640. var struct3501s []models.Struct3501
  30641. var struct3501 models.Struct3501
  30642. struct3501.OrgName = miConfig.OrgName
  30643. struct3501.AccessKey = miConfig.AccessKey
  30644. struct3501.RequestUrl = miConfig.Url
  30645. struct3501.SecretKey = miConfig.SecretKey
  30646. struct3501.ManuDate = "2022-08-15"
  30647. struct3501.FixmedinsBchno = ""
  30648. struct3501.ManuLotnum = ""
  30649. struct3501.RxFlag = "0"
  30650. struct3501.ExpyEnd = "2022-08-15"
  30651. struct3501.Invdate = "2022-08-15"
  30652. struct3501.InvCnt = "20.25"
  30653. struct3501.Memo = ""
  30654. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30655. struct3501.FixmedinsHilistId = miConfig.Code
  30656. struct3501.FixmedinsHilistName = miConfig.OrgName
  30657. struct3501s = append(struct3501s, struct3501)
  30658. data["struct_3501s"] = struct3501s
  30659. client := &http.Client{}
  30660. bytesData, _ := json.Marshal(data)
  30661. var req *http.Request
  30662. if miConfig.MdtrtareaAdmvs == "320921" {
  30663. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30664. } else {
  30665. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30666. }
  30667. resp, _ := client.Do(req)
  30668. defer resp.Body.Close()
  30669. body, ioErr := ioutil.ReadAll(resp.Body)
  30670. if ioErr != nil {
  30671. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30673. return
  30674. }
  30675. var respJSON map[string]interface{}
  30676. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30677. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30679. return
  30680. }
  30681. var res ResultSix
  30682. var resSix10265 ResultSix10265 //1101结果
  30683. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30684. result, _ := json.Marshal(respJSON)
  30685. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30686. utils.ErrorLog("解析失败:%v", err)
  30687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30688. return
  30689. }
  30690. res.InfRefmsgid = resSix10265.InfRefmsgid
  30691. res.Output = resSix10265.Output
  30692. res.ErrMsg = resSix10265.ErrMsg
  30693. res.Cainfo = resSix10265.Cainfo
  30694. res.WarnMsg = resSix10265.WarnMsg
  30695. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30696. res.Infcode = infocode
  30697. if infocode == 0 {
  30698. c.ServeSuccessJSON(map[string]interface{}{
  30699. "msg": "上传成功",
  30700. })
  30701. return
  30702. } else {
  30703. c.ServeSuccessJSON(map[string]interface{}{
  30704. "failed_code": -10,
  30705. "msg": res.ErrMsg,
  30706. })
  30707. return
  30708. }
  30709. }
  30710. func (c *HisApiController) Post3505() {
  30711. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30712. data := make(map[string]interface{})
  30713. var struct3501s []models.Struct3501
  30714. var struct3501 models.Struct3501
  30715. struct3501.OrgName = miConfig.OrgName
  30716. struct3501.AccessKey = miConfig.AccessKey
  30717. struct3501.RequestUrl = miConfig.Url
  30718. struct3501.SecretKey = miConfig.SecretKey
  30719. struct3501.ManuDate = "2022-08-15"
  30720. struct3501.FixmedinsBchno = ""
  30721. struct3501.ManuLotnum = ""
  30722. struct3501.RxFlag = "0"
  30723. struct3501.ExpyEnd = "2022-08-15"
  30724. struct3501.Invdate = "2022-08-15"
  30725. struct3501.InvCnt = "20.25"
  30726. struct3501.Memo = ""
  30727. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30728. struct3501.FixmedinsHilistId = miConfig.Code
  30729. struct3501.FixmedinsHilistName = miConfig.OrgName
  30730. struct3501s = append(struct3501s, struct3501)
  30731. data["struct_3501s"] = struct3501s
  30732. client := &http.Client{}
  30733. bytesData, _ := json.Marshal(data)
  30734. var req *http.Request
  30735. if miConfig.MdtrtareaAdmvs == "320921" {
  30736. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30737. } else {
  30738. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30739. }
  30740. resp, _ := client.Do(req)
  30741. defer resp.Body.Close()
  30742. body, ioErr := ioutil.ReadAll(resp.Body)
  30743. if ioErr != nil {
  30744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30746. return
  30747. }
  30748. var respJSON map[string]interface{}
  30749. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30752. return
  30753. }
  30754. var res ResultSix
  30755. var resSix10265 ResultSix10265 //1101结果
  30756. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30757. result, _ := json.Marshal(respJSON)
  30758. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30759. utils.ErrorLog("解析失败:%v", err)
  30760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30761. return
  30762. }
  30763. res.InfRefmsgid = resSix10265.InfRefmsgid
  30764. res.Output = resSix10265.Output
  30765. res.ErrMsg = resSix10265.ErrMsg
  30766. res.Cainfo = resSix10265.Cainfo
  30767. res.WarnMsg = resSix10265.WarnMsg
  30768. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30769. res.Infcode = infocode
  30770. if infocode == 0 {
  30771. c.ServeSuccessJSON(map[string]interface{}{
  30772. "msg": "上传成功",
  30773. })
  30774. return
  30775. } else {
  30776. c.ServeSuccessJSON(map[string]interface{}{
  30777. "failed_code": -10,
  30778. "msg": res.ErrMsg,
  30779. })
  30780. return
  30781. }
  30782. }
  30783. func (c *HisApiController) Post3506() {
  30784. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30785. data := make(map[string]interface{})
  30786. var struct3501s []models.Struct3501
  30787. var struct3501 models.Struct3501
  30788. struct3501.OrgName = miConfig.OrgName
  30789. struct3501.AccessKey = miConfig.AccessKey
  30790. struct3501.RequestUrl = miConfig.Url
  30791. struct3501.SecretKey = miConfig.SecretKey
  30792. struct3501.ManuDate = "2022-08-15"
  30793. struct3501.FixmedinsBchno = ""
  30794. struct3501.ManuLotnum = ""
  30795. struct3501.RxFlag = "0"
  30796. struct3501.ExpyEnd = "2022-08-15"
  30797. struct3501.Invdate = "2022-08-15"
  30798. struct3501.InvCnt = "20.25"
  30799. struct3501.Memo = ""
  30800. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30801. struct3501.FixmedinsHilistId = miConfig.Code
  30802. struct3501.FixmedinsHilistName = miConfig.OrgName
  30803. struct3501s = append(struct3501s, struct3501)
  30804. data["struct_3501s"] = struct3501s
  30805. client := &http.Client{}
  30806. bytesData, _ := json.Marshal(data)
  30807. var req *http.Request
  30808. if miConfig.MdtrtareaAdmvs == "320921" {
  30809. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30810. } else {
  30811. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30812. }
  30813. resp, _ := client.Do(req)
  30814. defer resp.Body.Close()
  30815. body, ioErr := ioutil.ReadAll(resp.Body)
  30816. if ioErr != nil {
  30817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30819. return
  30820. }
  30821. var respJSON map[string]interface{}
  30822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30825. return
  30826. }
  30827. var res ResultSix
  30828. var resSix10265 ResultSix10265 //1101结果
  30829. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30830. result, _ := json.Marshal(respJSON)
  30831. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30832. utils.ErrorLog("解析失败:%v", err)
  30833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30834. return
  30835. }
  30836. res.InfRefmsgid = resSix10265.InfRefmsgid
  30837. res.Output = resSix10265.Output
  30838. res.ErrMsg = resSix10265.ErrMsg
  30839. res.Cainfo = resSix10265.Cainfo
  30840. res.WarnMsg = resSix10265.WarnMsg
  30841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30842. res.Infcode = infocode
  30843. if infocode == 0 {
  30844. c.ServeSuccessJSON(map[string]interface{}{
  30845. "msg": "上传成功",
  30846. })
  30847. return
  30848. } else {
  30849. c.ServeSuccessJSON(map[string]interface{}{
  30850. "failed_code": -10,
  30851. "msg": res.ErrMsg,
  30852. })
  30853. return
  30854. }
  30855. }
  30856. func (c *HisApiController) Post3507() {
  30857. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30858. data := make(map[string]interface{})
  30859. var struct3501s []models.Struct3501
  30860. var struct3501 models.Struct3501
  30861. struct3501.OrgName = miConfig.OrgName
  30862. struct3501.AccessKey = miConfig.AccessKey
  30863. struct3501.RequestUrl = miConfig.Url
  30864. struct3501.SecretKey = miConfig.SecretKey
  30865. struct3501.ManuDate = "2022-08-15"
  30866. struct3501.FixmedinsBchno = ""
  30867. struct3501.ManuLotnum = ""
  30868. struct3501.RxFlag = "0"
  30869. struct3501.ExpyEnd = "2022-08-15"
  30870. struct3501.Invdate = "2022-08-15"
  30871. struct3501.InvCnt = "20.25"
  30872. struct3501.Memo = ""
  30873. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30874. struct3501.FixmedinsHilistId = miConfig.Code
  30875. struct3501.FixmedinsHilistName = miConfig.OrgName
  30876. struct3501s = append(struct3501s, struct3501)
  30877. data["struct_3501s"] = struct3501s
  30878. client := &http.Client{}
  30879. bytesData, _ := json.Marshal(data)
  30880. var req *http.Request
  30881. if miConfig.MdtrtareaAdmvs == "320921" {
  30882. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30883. } else {
  30884. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30885. }
  30886. resp, _ := client.Do(req)
  30887. defer resp.Body.Close()
  30888. body, ioErr := ioutil.ReadAll(resp.Body)
  30889. if ioErr != nil {
  30890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30892. return
  30893. }
  30894. var respJSON map[string]interface{}
  30895. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30898. return
  30899. }
  30900. var res ResultSix
  30901. var resSix10265 ResultSix10265 //1101结果
  30902. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30903. result, _ := json.Marshal(respJSON)
  30904. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30905. utils.ErrorLog("解析失败:%v", err)
  30906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30907. return
  30908. }
  30909. res.InfRefmsgid = resSix10265.InfRefmsgid
  30910. res.Output = resSix10265.Output
  30911. res.ErrMsg = resSix10265.ErrMsg
  30912. res.Cainfo = resSix10265.Cainfo
  30913. res.WarnMsg = resSix10265.WarnMsg
  30914. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30915. res.Infcode = infocode
  30916. if infocode == 0 {
  30917. c.ServeSuccessJSON(map[string]interface{}{
  30918. "msg": "上传成功",
  30919. })
  30920. return
  30921. } else {
  30922. c.ServeSuccessJSON(map[string]interface{}{
  30923. "failed_code": -10,
  30924. "msg": res.ErrMsg,
  30925. })
  30926. return
  30927. }
  30928. }
  30929. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30930. // WebSocket服务器地址
  30931. serverURL := "ws://127.0.0.1:8899"
  30932. // 解析WebSocket服务器地址
  30933. u, err := url.Parse(serverURL)
  30934. if err != nil {
  30935. }
  30936. // 建立WebSocket连接
  30937. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30938. if err != nil {
  30939. }
  30940. defer conn.Close()
  30941. input2 := make(map[string]interface{})
  30942. input := make(map[string]interface{})
  30943. inputData := make(map[string]interface{})
  30944. inputData["orgId"] = code
  30945. inputData["businessType"] = "01101"
  30946. inputData["operatorId"] = operator_id
  30947. inputData["operatorName"] = operator_name
  30948. inputData["officeId"] = "001"
  30949. inputData["officeName"] = "血透室"
  30950. inputData["deviceType"] = ""
  30951. input["data"] = inputData
  30952. input["orgId"] = code
  30953. input["transType"] = "ec.query"
  30954. //if md == ""
  30955. if md[:4] == "4403" {
  30956. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30957. } else if md[:4] == "4401" {
  30958. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30959. } else {
  30960. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30961. }
  30962. input2["indata"] = input
  30963. fmt.Println(input2)
  30964. bytesData, _ := json.Marshal(input2)
  30965. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30966. if err != nil {
  30967. fmt.Println(err)
  30968. }
  30969. // 接收消息
  30970. _, receivedMessage, err := conn.ReadMessage()
  30971. if err != nil {
  30972. fmt.Println(err)
  30973. }
  30974. return "", string(receivedMessage)
  30975. }
  30976. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30977. // WebSocket服务器地址
  30978. serverURL := "ws://127.0.0.1:8899"
  30979. // 解析WebSocket服务器地址
  30980. u, err := url.Parse(serverURL)
  30981. if err != nil {
  30982. }
  30983. // 建立WebSocket连接
  30984. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30985. if err != nil {
  30986. }
  30987. defer conn.Close()
  30988. input2 := make(map[string]interface{})
  30989. input := make(map[string]interface{})
  30990. inputData := make(map[string]interface{})
  30991. inputData["orgId"] = code
  30992. inputData["businessType"] = "01103"
  30993. inputData["operatorId"] = operator_id
  30994. inputData["operatorName"] = operator_name
  30995. inputData["officeId"] = "001"
  30996. inputData["officeName"] = "血透室"
  30997. inputData["deviceType"] = ""
  30998. input["data"] = inputData
  30999. input["orgId"] = code
  31000. input["transType"] = "ec.query"
  31001. //if md ==
  31002. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  31003. input2["indata"] = input
  31004. fmt.Println(input2)
  31005. bytesData, _ := json.Marshal(input2)
  31006. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31007. if err != nil {
  31008. fmt.Println(err)
  31009. }
  31010. // 接收消息
  31011. _, receivedMessage, err := conn.ReadMessage()
  31012. if err != nil {
  31013. fmt.Println(err)
  31014. }
  31015. return "", string(receivedMessage)
  31016. }
  31017. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  31018. // WebSocket服务器地址
  31019. serverURL := "ws://127.0.0.1:8899"
  31020. // 解析WebSocket服务器地址
  31021. u, err := url.Parse(serverURL)
  31022. if err != nil {
  31023. }
  31024. // 建立WebSocket连接
  31025. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31026. if err != nil {
  31027. }
  31028. defer conn.Close()
  31029. input2 := make(map[string]interface{})
  31030. input := make(map[string]interface{})
  31031. inputData := make(map[string]interface{})
  31032. inputData["orgId"] = code
  31033. inputData["businessType"] = "01101"
  31034. inputData["operatorId"] = operator_id
  31035. inputData["operatorName"] = operator_name
  31036. inputData["officeId"] = "001"
  31037. inputData["officeName"] = "血透室"
  31038. inputData["deviceType"] = ""
  31039. input["data"] = inputData
  31040. input["orgId"] = code
  31041. input["transType"] = "ec.query"
  31042. //if md == ""
  31043. if md[:4] == "4403" {
  31044. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31045. } else if md[:4] == "4401" {
  31046. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31047. } else {
  31048. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31049. }
  31050. input2["indata"] = input
  31051. fmt.Println(input2)
  31052. bytesData, _ := json.Marshal(input2)
  31053. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31054. if err != nil {
  31055. fmt.Println(err)
  31056. }
  31057. // 接收消息
  31058. _, receivedMessage, err := conn.ReadMessage()
  31059. if err != nil {
  31060. fmt.Println(err)
  31061. }
  31062. return "", string(receivedMessage)
  31063. }
  31064. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  31065. // WebSocket服务器地址
  31066. serverURL := "ws://127.0.0.1:8899"
  31067. // 解析WebSocket服务器地址
  31068. u, err := url.Parse(serverURL)
  31069. if err != nil {
  31070. }
  31071. // 建立WebSocket连接
  31072. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  31073. if err != nil {
  31074. }
  31075. defer conn.Close()
  31076. input2 := make(map[string]interface{})
  31077. input := make(map[string]interface{})
  31078. inputData := make(map[string]interface{})
  31079. inputData["orgId"] = code
  31080. inputData["businessType"] = "01301"
  31081. inputData["operatorId"] = operator_id
  31082. inputData["operatorName"] = operator_name
  31083. inputData["officeId"] = "001"
  31084. inputData["officeName"] = "血透室"
  31085. inputData["deviceType"] = ""
  31086. input["data"] = inputData
  31087. input["orgId"] = code
  31088. input["transType"] = "ec.query"
  31089. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  31090. input2["indata"] = input
  31091. bytesData, _ := json.Marshal(input2)
  31092. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31093. if err != nil {
  31094. fmt.Println(err)
  31095. }
  31096. // 接收消息
  31097. _, receivedMessage, err := conn.ReadMessage()
  31098. if err != nil {
  31099. fmt.Println(err)
  31100. }
  31101. return "", string(receivedMessage)
  31102. }
  31103. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31104. newArr = make([]string, 0)
  31105. for i := 0; i < len(arr); i++ {
  31106. repeat := false
  31107. for j := i + 1; j < len(arr); j++ {
  31108. if arr[i] == arr[j] {
  31109. repeat = true
  31110. break
  31111. }
  31112. }
  31113. if !repeat {
  31114. newArr = append(newArr, arr[i])
  31115. }
  31116. }
  31117. return
  31118. }
  31119. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31120. if len(idNumber) != 18 {
  31121. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31122. }
  31123. // 提取出生日期
  31124. year, err := strconv.Atoi(idNumber[6:10])
  31125. if err != nil {
  31126. return "", 0, err
  31127. }
  31128. month, err := strconv.Atoi(idNumber[10:12])
  31129. if err != nil {
  31130. return "", 0, err
  31131. }
  31132. day, err := strconv.Atoi(idNumber[12:14])
  31133. if err != nil {
  31134. return "", 0, err
  31135. }
  31136. // 格式化生日字符串
  31137. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31138. birthdateFormatted := birthdate.Format("2006-01-02")
  31139. // 计算年龄
  31140. today := time.Now()
  31141. age := today.Year() - birthdate.Year()
  31142. if today.YearDay() < birthdate.YearDay() {
  31143. age--
  31144. }
  31145. return birthdateFormatted, age, nil
  31146. }