his_api_controller.go 1.2MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138
  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. //"github.com/tjfoc/gmsm/sm2"
  13. //"github.com/tjfoc/gmsm/sm3"
  14. "github.com/go-ole/go-ole"
  15. "gdyb/controllers"
  16. "gdyb/enums"
  17. "gdyb/models"
  18. "gdyb/service"
  19. "gdyb/utils"
  20. "github.com/astaxie/beego"
  21. "github.com/axgle/mahonia"
  22. "github.com/gorilla/websocket"
  23. "github.com/jinzhu/gorm"
  24. "github.com/shopspring/decimal"
  25. "io"
  26. "io/ioutil"
  27. //"math"
  28. "math/rand"
  29. "net/http"
  30. "net/url"
  31. "os"
  32. "path/filepath"
  33. "regexp"
  34. "strconv"
  35. "strings"
  36. "syscall"
  37. "time"
  38. "unsafe"
  39. "github.com/go-ole/go-ole/oleutil"
  40. )
  41. type HisApiController struct {
  42. controllers.BaseAuthAPIController
  43. }
  44. func HisManagerApiRegistRouters() {
  45. //挂号
  46. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  47. //上传就诊信息-上传明细-结算
  48. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  49. //查询
  50. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  51. //对总账
  52. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  53. //对明细
  54. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  55. //退费,退明细
  56. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  57. //退号
  58. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  59. //退明细
  60. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  61. //上传就诊信息-上传明细-预结算
  62. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  63. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  64. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  65. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  66. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  67. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  68. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  69. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  70. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  71. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  72. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  73. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  74. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  75. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  76. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  77. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  78. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  79. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  80. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  81. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  82. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  83. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  84. beego.Router("/api/check", &HisApiController{}, "get:Check")
  85. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  86. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  87. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  88. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  89. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  90. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  91. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  92. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  93. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  94. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  95. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  96. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  97. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  98. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  99. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  100. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  101. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  102. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  103. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  104. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  105. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  106. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  107. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  108. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  109. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  110. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  111. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  112. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  113. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  114. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  115. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  116. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  117. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  118. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  119. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  120. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  121. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  122. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  123. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  124. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  125. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  126. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  127. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  128. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  129. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  130. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  131. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  132. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  133. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  134. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  135. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  136. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  137. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  138. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  139. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  140. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  141. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  142. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  143. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  144. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  145. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  146. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  147. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  148. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  149. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  150. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  151. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  152. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  153. }
  154. func (c *HisApiController) Get1318() {
  155. adminUser := c.GetAdminUserInfo()
  156. admin_user_id, _ := c.GetInt64("admin_user_id")
  157. code := c.GetString("code")
  158. code = ""
  159. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  160. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  161. api := ""
  162. if miConfig.MdtrtareaAdmvs == "320921" {
  163. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  164. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  165. } else {
  166. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  167. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  168. }
  169. resp, requestErr := http.Get(api)
  170. if requestErr != nil {
  171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  172. return
  173. }
  174. body, ioErr := ioutil.ReadAll(resp.Body)
  175. if ioErr != nil {
  176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  178. return
  179. }
  180. var respJSON map[string]interface{}
  181. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  184. return
  185. }
  186. //var res Result2406
  187. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  188. result, _ := json.Marshal(respJSON)
  189. if err := json.Unmarshal([]byte(result), &res); err != nil {
  190. utils.ErrorLog("解析失败:%v", err)
  191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  192. return
  193. }
  194. if res.Infcode == "0" {
  195. c.ServeSuccessJSON(map[string]interface{}{
  196. "result": "",
  197. })
  198. } else {
  199. c.ServeSuccessJSON(map[string]interface{}{
  200. "failed_code": -10,
  201. "msg": res.ErrMsg,
  202. })
  203. */return
  204. //}
  205. }
  206. func (c *HisApiController) Get2503() {
  207. adminUser := c.GetAdminUserInfo()
  208. admin_user_id, _ := c.GetInt64("admin_user_id")
  209. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  210. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  211. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  212. }
  213. func (c *HisApiController) Get2406() {
  214. id, _ := c.GetInt64("id")
  215. record_time := c.GetString("record_time")
  216. his_patient_id, _ := c.GetInt64("his_patient_id")
  217. admin_user_id, _ := c.GetInt64("admin_user_id")
  218. diagnosis_id := c.GetString("diagnosis")
  219. timeLayout := "2006-01-02"
  220. loc, _ := time.LoadLocation("Local")
  221. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  222. if err != nil {
  223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  224. return
  225. }
  226. recordDateTime := theTime.Unix()
  227. adminUser := c.GetAdminUserInfo()
  228. diagnosis_ids := strings.Split(diagnosis_id, ",")
  229. var config []*models.HisXtDiagnoseConfig
  230. for _, item := range diagnosis_ids {
  231. id, _ := strconv.ParseInt(item, 10, 64)
  232. diagnosisConfig, _ := service.FindDiagnoseById(id)
  233. config = append(config, &diagnosisConfig)
  234. }
  235. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  236. fmt.Println(his_patient_id)
  237. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  238. //timestamp := time.Now().Unix()
  239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  240. var patientPrescription models.HisPrescriptionInfo
  241. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  242. if patientPrescription.ID == 0 {
  243. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  244. }
  245. var res2 Result2406
  246. if miConfig.MdtrtareaAdmvs == "341203" {
  247. data := make(map[string]interface{})
  248. client := &http.Client{}
  249. data["psn_no"] = his.PsnNo
  250. data["mdtrt_id"] = his.Number
  251. data["operator"] = roles.UserName
  252. data["cert_no"] = his.IdCardNo
  253. data["org_name"] = miConfig.OrgName
  254. data["psn_name"] = his.Name
  255. data["ipt_otp_no"] = his.IptOtpNo
  256. data["ipt_psn_sp_flag_type"] = "0901"
  257. data["ipt_psn_sp_flag"] = "1"
  258. data["fixmedins_code"] = miConfig.Code
  259. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  260. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  261. data["url"] = miConfig.Url
  262. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  263. bytesData, _ := json.Marshal(data)
  264. var req *http.Request
  265. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  266. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  267. resp, _ := client.Do(req)
  268. defer resp.Body.Close()
  269. body, ioErr := ioutil.ReadAll(resp.Body)
  270. if ioErr != nil {
  271. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  273. return
  274. }
  275. var respJSON map[string]interface{}
  276. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  277. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  279. return
  280. }
  281. status := respJSON["data"].(map[string]interface{})["status"].(string)
  282. if status == "0" {
  283. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  284. c.ServeSuccessJSON(map[string]interface{}{
  285. "failed_code": -10,
  286. "msg": err_msg,
  287. })
  288. return
  289. }
  290. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  291. userJSONBytes, _ := json.Marshal(respJSON)
  292. fmt.Println("log")
  293. fmt.Println(string(userJSONBytes))
  294. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  295. utils.ErrorLog("解析失败:%v", err)
  296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  297. return
  298. }
  299. }
  300. if res2.Infcode != 0 {
  301. adminUser := c.GetAdminUserInfo()
  302. errlog := &models.HisOrderError{
  303. UserOrgId: adminUser.CurrentOrgId,
  304. Ctime: time.Now().Unix(),
  305. Mtime: time.Now().Unix(),
  306. ErrMsg: res2.ErrMsg,
  307. Status: 1,
  308. PatientId: id,
  309. RecordTime: recordDateTime,
  310. Stage: 3,
  311. }
  312. service.CreateErrMsgLog(errlog)
  313. c.ServeSuccessJSON(map[string]interface{}{
  314. "failed_code": -10,
  315. "msg": res2.ErrMsg,
  316. })
  317. return
  318. } else {
  319. c.ServeSuccessJSON(map[string]interface{}{
  320. "msg": "上传成功",
  321. })
  322. return
  323. }
  324. }
  325. func (c *HisApiController) Get4105() {
  326. }
  327. func (c *HisApiController) Post5302() {
  328. patient_id, _ := c.GetInt64("id")
  329. admin_user_id, _ := c.GetInt64("admin_user_id")
  330. p, _ := service.GetHisPatientById(patient_id)
  331. adminUser := c.GetAdminUserInfo()
  332. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  333. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  334. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  335. }
  336. func (c *HisApiController) Get4104() {
  337. }
  338. type Output struct {
  339. CertNo string `json:"certno"`
  340. PsnName string `json:"psn_name"`
  341. CardNo string `json:"card_no"`
  342. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  343. CardSN string `json:"card_sn"`
  344. PsnCertType string `json:"psn_cert_type"`
  345. MdtrtCertNo string `json:"mdtrt_cert_no"`
  346. MdtrtCertType string `json:"mdtrt_cert_type"`
  347. QRCode string `json:"qrCode"`
  348. EcToken string `json:"ecToken"`
  349. }
  350. type AHResponse struct {
  351. Body AHBody `json:"body"`
  352. Code int `json:"code"`
  353. CSBCode int `json:"csbCode"`
  354. Message string `json:"message"`
  355. RequestID string `json:"requestId"`
  356. State struct{} `json:"state"`
  357. }
  358. type AHBody struct {
  359. ErrMsg string `json:"err_msg"`
  360. InfRefMsgID string `json:"inf_refmsgid"`
  361. InfCode int `json:"infcode"`
  362. Output struct {
  363. Result []struct {
  364. BasMednFlag string `json:"bas_medn_flag"`
  365. ChldMedcFlag string `json:"chld_medc_flag"`
  366. ChrgitmLv string `json:"chrgitm_lv"`
  367. Cnt float64 `json:"cnt"`
  368. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  369. DrtReimFlag string `json:"drt_reim_flag"`
  370. FeedetlSn string `json:"feedetl_sn"`
  371. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  372. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  373. InscpScpAmt float64 `json:"inscp_scp_amt"`
  374. ListSpItemFlag string `json:"list_sp_item_flag"`
  375. LmtUsedFlag string `json:"lmt_used_flag"`
  376. MedChrgitmType string `json:"med_chrgitm_type"`
  377. Memo string `json:"memo"`
  378. OverlmtAmt float64 `json:"overlmt_amt"`
  379. PreselfpayAmt float64 `json:"preselfpay_amt"`
  380. Pric float64 `json:"pric"`
  381. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  382. SelfpayProp float64 `json:"selfpay_prop"`
  383. } `json:"result"`
  384. } `json:"output"`
  385. }
  386. type Response struct {
  387. Output Output `json:"output"`
  388. Infcode int `json:"infcode"`
  389. InfRefMsgID string `json:"inf_refmsgid"`
  390. RefMsgTime string `json:"refmsg_time"`
  391. RespondTime string `json:"respond_time"`
  392. ErrMsg string `json:"err_msg"`
  393. WarnMsg string `json:"warn_msg"`
  394. SignType string `json:"signtype"`
  395. CAInfo string `json:"cainfo"`
  396. }
  397. func (c *HisApiController) Getquerydata() {
  398. query_type, _ := c.GetInt64("type")
  399. refd_setl_flag := c.GetString("refd_setl_flag")
  400. med_type := c.GetString("med_type")
  401. //admin_user_id,_ := c.GetInt64("admin_user_id")
  402. cert_no := c.GetString("cert_no")
  403. psn_no := c.GetString("psn_no")
  404. start_time := c.GetString("start_time")
  405. end_time := c.GetString("end_time")
  406. page, _ := c.GetInt64("page")
  407. limit, _ := c.GetInt64("limit")
  408. var bp models.BusinessParams5262
  409. bp.RefdSetlFlag = refd_setl_flag
  410. bp.MedType = med_type
  411. bp.Certno = cert_no
  412. bp.Psnno = psn_no
  413. bp.QBegntime = start_time
  414. bp.QEndtime = end_time
  415. if query_type == 1 { //本地
  416. Post5262(c, bp, page, limit)
  417. } else { //异地
  418. Post5267(c, bp, page, limit)
  419. }
  420. }
  421. func (c *HisApiController) Drugscheck() {
  422. admin_user_id, _ := c.GetInt64("admin_user_id")
  423. adminUser := c.GetAdminUserInfo()
  424. var queryResult []QueryResult
  425. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  426. for _, item := range drugs {
  427. result := QueryResult{
  428. ID: item.ID,
  429. Name: item.DrugName,
  430. Code: item.MedicalInsuranceNumber,
  431. List_type_code: "101",
  432. }
  433. queryResult = append(queryResult, result)
  434. }
  435. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  436. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  437. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  438. for _, item := range queryResult {
  439. 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)
  440. }
  441. }
  442. func (c *HisApiController) Goodcheck() {
  443. admin_user_id, _ := c.GetInt64("admin_user_id")
  444. adminUser := c.GetAdminUserInfo()
  445. var queryResult []QueryResult
  446. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  447. for _, item := range goods {
  448. result := QueryResult{
  449. ID: item.ID,
  450. Name: item.GoodName,
  451. Code: item.SocialSecurityDirectoryCode,
  452. List_type_code: "301",
  453. }
  454. queryResult = append(queryResult, result)
  455. }
  456. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  457. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  458. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  459. for _, item := range queryResult {
  460. 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)
  461. //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)
  462. }
  463. }
  464. func (c *HisApiController) Projectcheck() {
  465. admin_user_id, _ := c.GetInt64("admin_user_id")
  466. adminUser := c.GetAdminUserInfo()
  467. var queryResult []QueryResult
  468. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  469. for _, item := range projects {
  470. result := QueryResult{
  471. ID: item.ID,
  472. Name: item.ProjectName,
  473. Code: item.MedicalCode,
  474. List_type_code: "201",
  475. }
  476. queryResult = append(queryResult, result)
  477. }
  478. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  479. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  480. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  481. for _, item := range queryResult {
  482. 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)
  483. }
  484. }
  485. //func (c *HisApiController)CancleDia(){
  486. //
  487. // id, _ := c.GetInt64("id")
  488. // record_time := c.GetString("record_time")
  489. // his_patient_id, _ := c.GetInt64("his_patient_id")
  490. //
  491. // admin_user_id, _ := c.GetInt64("admin_user_id")
  492. //
  493. // diagnosis_id := c.GetString("diagnosis")
  494. // sick_type, _ := c.GetInt64("sick_type")
  495. // reg_type, _ := c.GetInt64("p_type")
  496. // begin_time := c.GetString("begin_time")
  497. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  498. //
  499. //
  500. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  501. //
  502. // fmt.Println(acct_used_flag)
  503. //
  504. //
  505. // timeLayout := "2006-01-02"
  506. // loc, _ := time.LoadLocation("Local")
  507. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  508. // if err != nil {
  509. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  510. // return
  511. // }
  512. // recordDateTime := theTime.Unix()
  513. // adminUser := c.GetAdminUserInfo()
  514. //
  515. //
  516. //
  517. //
  518. //
  519. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  520. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  521. // var patientPrescription models.HisPrescriptionInfo
  522. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  523. // if patientPrescription.ID == 0 {
  524. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  525. // }
  526. // //if patientPrescription.Do
  527. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  528. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  529. //
  530. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  531. //
  532. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  533. //
  534. // var config []*models.HisXtDiagnoseConfig
  535. // for _, item := range diagnosis_ids {
  536. // id, _ := strconv.ParseInt(item, 10, 64)
  537. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  538. // config = append(config, &diagnosisConfig)
  539. // }
  540. //
  541. // sickConfig, _ := service.FindSickById(sick_type)
  542. //
  543. //
  544. // data := make(map[string]interface{})
  545. // client := &http.Client{}
  546. // data["psn_no"] = his.PsnNo
  547. // data["mdtrt_id"] = his.Number
  548. // data["doctor"] = roles.UserName
  549. // data["department"] = department.Name
  550. // data["org_name"] = miConfig.OrgName
  551. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  552. // data["doctor_id"] = doctor_info.DoctorNumber
  553. // data["new_doctor_name"] = doctor_info.UserName
  554. // data["fixmedins_code"] = miConfig.Code
  555. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  556. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  557. // data["secret_key"] = miConfig.SecretKey
  558. // data["sick_code"] = sickConfig.CountryCode
  559. // data["sick_name"] = sickConfig.ClassName
  560. // data["url"] = miConfig.Url
  561. // data["ak"] = miConfig.AccessKey
  562. // data["begin_time"] = begin_time
  563. // data["cainfo"] = miConfig.Cainfo
  564. // data["is_vaild"] = "0"
  565. //
  566. // data["dept"] = strconv.FormatInt(department.ID, 10)
  567. // data["config"] = config
  568. // bytesData, _ := json.Marshal(data)
  569. //
  570. // var req *http.Request
  571. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  572. // resp, _ := client.Do(req)
  573. // defer resp.Body.Close()
  574. // body, ioErr := ioutil.ReadAll(resp.Body)
  575. // if ioErr != nil {
  576. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. // return
  579. // }
  580. // var respJSON map[string]interface{}
  581. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  582. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  583. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  584. // return
  585. // }
  586. //
  587. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  588. // userJSONBytes, _ := json.Marshal(respJSON)
  589. // fmt.Println("log")
  590. // fmt.Println(string(userJSONBytes))
  591. //
  592. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  593. // utils.ErrorLog("解析失败:%v", err)
  594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  595. // return
  596. // }
  597. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  598. // res2.Output = ressix10265.Output
  599. // res2.ErrMsg = ressix10265.ErrMsg
  600. // res2.Cainfo = ressix10265.Cainfo
  601. // res2.WarnMsg = ressix10265.WarnMsg
  602. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  603. // res2.Infcode = infocode
  604. //
  605. //}
  606. func (c *HisApiController) Get4102() {
  607. order_id, _ := c.GetInt64("order_id")
  608. admin_user_id, _ := c.GetInt64("admin_user_id")
  609. stas_type := c.GetString("stas_type")
  610. order, _ := service.GetHisOrderByIDTwo(order_id)
  611. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  612. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  613. var pp models.PublicParams
  614. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  615. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  616. pp.FixmedinsName = miConfig.OrgName
  617. pp.FixmedinsCode = miConfig.Code
  618. pp.RequestUrl = miConfig.Url
  619. pp.Cainfo = miConfig.Cainfo
  620. pp.SecretKey = miConfig.SecretKey
  621. pp.AccessKey = miConfig.AccessKey
  622. pp.OpterName = curRoles.UserName
  623. if miConfig.MdtrtareaAdmvs == "350500" {
  624. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  625. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  626. saveLog(result, request, "4102", "清单确认")
  627. var dat map[string]interface{}
  628. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  629. fmt.Println(dat)
  630. } else {
  631. fmt.Println(err)
  632. }
  633. var empty ResultFourteen
  634. userJSONBytes, _ := json.Marshal(dat)
  635. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  636. utils.ErrorLog("解析失败:%v", err)
  637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  638. return
  639. }
  640. if empty.Infcode == 0 {
  641. c.ServeSuccessJSON(map[string]interface{}{
  642. "msg": "确认成功",
  643. })
  644. return
  645. }
  646. } else {
  647. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  648. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  649. result3, request3 := service.Jxyb4105(pp)
  650. saveLog(result, request, "4102", "清单确认")
  651. saveLog(result2, request2, "4103", "清单确认")
  652. saveLog(result3, request3, "4105", "清单统计")
  653. var dat map[string]interface{}
  654. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  655. fmt.Println(dat)
  656. } else {
  657. fmt.Println(err)
  658. }
  659. var empty ResultFourteen
  660. userJSONBytes, _ := json.Marshal(dat)
  661. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  662. utils.ErrorLog("解析失败:%v", err)
  663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  664. return
  665. }
  666. if empty.Infcode == 0 {
  667. c.ServeSuccessJSON(map[string]interface{}{
  668. "msg": "确认成功",
  669. })
  670. return
  671. }
  672. }
  673. }
  674. // 对账权限查询
  675. func (c *HisApiController) Get3260() {
  676. admin_user_id, _ := c.GetInt64("admin_user_id")
  677. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  678. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  679. var api string
  680. var res models.JSResult3260
  681. if miConfig.MdtrtareaAdmvs == "320921" {
  682. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  683. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  684. } else {
  685. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  686. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  687. }
  688. resp, requestErr := http.Get(api)
  689. if requestErr != nil {
  690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  691. return
  692. }
  693. body, ioErr := ioutil.ReadAll(resp.Body)
  694. if ioErr != nil {
  695. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  697. return
  698. }
  699. var respJSON map[string]interface{}
  700. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  703. return
  704. }
  705. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  706. result, _ := json.Marshal(respJSON)
  707. if err := json.Unmarshal([]byte(result), &res); err != nil {
  708. utils.ErrorLog("解析失败:%v", err)
  709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  710. return
  711. }
  712. if res.Infcode == "0" {
  713. c.ServeSuccessJSON(map[string]interface{}{
  714. "result": res.Output.Data,
  715. })
  716. } else {
  717. c.ServeSuccessJSON(map[string]interface{}{
  718. "failed_code": -10,
  719. "msg": res.ErrMsg,
  720. })
  721. return
  722. }
  723. }
  724. func (c *HisApiController) Get3261() {
  725. admin_user_id, _ := c.GetInt64("admin_user_id")
  726. //month := c.GetString("month")
  727. startTime := c.GetString("start_time")
  728. //endTime, _ := c.GetString("end_time")
  729. times := strings.Split(startTime, "-")
  730. stmt_mon := times[0] + times[1]
  731. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  732. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  733. var api string
  734. var res models.JSResult3261
  735. //var res10265 Result5301For10265
  736. if miConfig.MdtrtareaAdmvs == "320921" {
  737. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  738. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  739. } else {
  740. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  741. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  742. }
  743. resp, requestErr := http.Get(api)
  744. if requestErr != nil {
  745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  746. return
  747. }
  748. body, ioErr := ioutil.ReadAll(resp.Body)
  749. if ioErr != nil {
  750. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  752. return
  753. }
  754. var respJSON map[string]interface{}
  755. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  756. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  758. return
  759. }
  760. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  761. result, _ := json.Marshal(respJSON)
  762. if err := json.Unmarshal([]byte(result), &res); err != nil {
  763. utils.ErrorLog("解析失败:%v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. if res.Infcode == "0" {
  768. c.ServeSuccessJSON(map[string]interface{}{
  769. "result": res.Output,
  770. })
  771. } else {
  772. c.ServeSuccessJSON(map[string]interface{}{
  773. "failed_code": -10,
  774. "msg": res.ErrMsg,
  775. })
  776. return
  777. }
  778. }
  779. type TempFun struct {
  780. FundKey string
  781. FundCode string
  782. }
  783. func (c *HisApiController) Get3262() {
  784. admin_user_id, _ := c.GetInt64("admin_user_id")
  785. startTime := c.GetString("start_time")
  786. endTime := c.GetString("end_time")
  787. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  788. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  789. //timeLayout := "2006-01-02"
  790. //loc, _ := time.LoadLocation("Local")
  791. //var theStartTIme int64
  792. //if len(startTime) > 0 {
  793. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  794. // if err != nil {
  795. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  796. // return
  797. // }
  798. // theStartTIme = theTime.Unix()
  799. //}
  800. //var theEndtTIme int64
  801. //if len(endTime) > 0 {
  802. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  803. // if err != nil {
  804. // utils.ErrorLog(err.Error())
  805. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  806. // return
  807. // }
  808. // theEndtTIme = theTime.Unix()
  809. //}
  810. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  811. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  812. for _, team := range datas {
  813. fmt.Println(team.PsnTime)
  814. for _, team_two := range datas_two {
  815. fmt.Println(team_two.PsnTime)
  816. if team.FundKey == team_two.FundKey {
  817. fmt.Println(team_two.PsnTime)
  818. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  819. fmt.Println(team.PsnTime)
  820. }
  821. }
  822. }
  823. fmt.Println("1111")
  824. fmt.Println(datas)
  825. fmt.Println("1111")
  826. var twos []models.FixMonRecDetailFileInTwo
  827. for _, team := range datas {
  828. var two models.FixMonRecDetailFileInTwo
  829. two.MedType = team.MedType
  830. two.Insutype = team.Insutype
  831. two.PsnType = team.PsnType
  832. two.MedType = team.MedType
  833. two.FixBlngAdmdvs = "999999"
  834. two.InsuAdmdvs = "555555"
  835. two.PsnTime = team.PsnTime
  836. two.PsnCnt = team.PsnCnt
  837. two.FundKey = team.FundKey
  838. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  839. fps, _ := strconv.ParseFloat(team.Fund, 64)
  840. ia, _ := strconv.ParseFloat(team.Amt, 64)
  841. two.MedfeeSumAmt = ms
  842. two.InscpAmt = ia
  843. two.FundPaySumAmt = fps
  844. twos = append(twos, two)
  845. }
  846. //startTime := c.GetString("start_time")
  847. //endTime, _ := c.GetString("end_time")
  848. times := strings.Split(startTime, "-")
  849. stmt_mon := times[0] + times[1]
  850. var funs []models.FundDetail
  851. for _, item := range datas {
  852. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  853. funs = append(funs, fun...)
  854. }
  855. var funInfos []models.Fund
  856. //for _, item := range funs {
  857. // var rf []models.FundInfo
  858. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  859. // for _, subitem := range rf {
  860. // var fund models.Fund
  861. // fund.FundCode = subitem.FundPayType
  862. // fund.FundName = subitem.FundPayTypeName
  863. // fund.FundAmt = subitem.FundPayAmt
  864. // fund.FundKey = item.FundKey
  865. // fund.InsuAdmdvs = "555555"
  866. // fund.FixBlngAdmdvs = "999999"
  867. // funInfos = append(funInfos, fund)
  868. // }
  869. //}
  870. var tempFuns []TempFun
  871. for _, funInfo := range funInfos {
  872. var tempFun TempFun
  873. tempFun.FundKey = funInfo.FundKey
  874. tempFun.FundCode = funInfo.FundCode
  875. tempFuns = append(tempFuns, tempFun)
  876. }
  877. tempFuns = RemoveRepeatedFunElement(tempFuns)
  878. fmt.Println(tempFuns)
  879. var funInfosTwo []models.Fund
  880. decimal.DivisionPrecision = 2
  881. for _, item := range tempFuns {
  882. var fund models.Fund
  883. for _, subItem := range funInfos {
  884. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  885. fund.FundKey = subItem.FundKey
  886. fund.InsuAdmdvs = subItem.InsuAdmdvs
  887. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  888. fund.FundName = subItem.FundName
  889. fund.FundCode = subItem.FundCode
  890. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  891. }
  892. }
  893. funInfosTwo = append(funInfosTwo, fund)
  894. }
  895. fmt.Println("funInfosTwo")
  896. fmt.Println(funInfosTwo)
  897. var upld_btch string
  898. var empty models.JSResultEmpty
  899. data := make(map[string]interface{})
  900. data["org_name"] = miConfig.OrgName
  901. data["doctor"] = curRoles.UserName
  902. data["doctor_name"] = curRoles.UserName
  903. data["fixmedins_code"] = miConfig.Code
  904. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  905. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  906. data["secret_key"] = miConfig.SecretKey
  907. data["url"] = miConfig.Url
  908. data["ak"] = miConfig.AccessKey
  909. data["cainfo"] = miConfig.Cainfo
  910. data["datas"] = twos
  911. data["fund"] = funInfosTwo
  912. fmt.Println(twos)
  913. month := time.Unix(1557042972, 0).Format("1")
  914. year := time.Now().Format("2006")
  915. month = time.Now().Format("01")
  916. day := time.Now().Format("02")
  917. hour := time.Now().Format("15")
  918. min := time.Now().Format("04")
  919. sec := time.Now().Format("05")
  920. fix_fill_date := year + month + day + hour + min + sec
  921. data["fix_fill_dept"] = miConfig.OrgName
  922. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  923. data["fix_fill_psn"] = curRoles.UserName
  924. data["fix_fill_date"] = fix_fill_date
  925. data["stmt_loc"] = "2"
  926. data["setl_mon"] = stmt_mon
  927. upld_btch = "0"
  928. data["upld_btch"] = upld_btch
  929. //fmt.Println(data)
  930. client := &http.Client{}
  931. bytesData, _ := json.Marshal(data)
  932. var req *http.Request
  933. if miConfig.MdtrtareaAdmvs == "320921" {
  934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  935. } else {
  936. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  937. }
  938. resp, _ := client.Do(req)
  939. defer resp.Body.Close()
  940. body, ioErr := ioutil.ReadAll(resp.Body)
  941. if ioErr != nil {
  942. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  944. }
  945. var respJSON map[string]interface{}
  946. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  947. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  949. }
  950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  951. //fmt.Println(respJSON)
  952. result, _ := json.Marshal(respJSON)
  953. //fmt.Println(result)
  954. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  955. utils.ErrorLog("解析失败:%v", err)
  956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  957. }
  958. if empty.Infcode != "0" {
  959. c.ServeSuccessJSON(map[string]interface{}{
  960. "failed_code": -10,
  961. "msg": empty.ErrMsg,
  962. })
  963. return
  964. } else {
  965. c.ServeSuccessJSON(map[string]interface{}{
  966. "msg": "上传成功",
  967. })
  968. return
  969. }
  970. }
  971. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  972. newArr = make([]TempFun, 0)
  973. for i := 0; i < len(arr); i++ {
  974. repeat := false
  975. for j := i + 1; j < len(arr); j++ {
  976. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  977. repeat = true
  978. break
  979. }
  980. }
  981. if !repeat {
  982. newArr = append(newArr, arr[i])
  983. }
  984. }
  985. return
  986. }
  987. func (c *HisApiController) Get3263() {
  988. admin_user_id, _ := c.GetInt64("admin_user_id")
  989. startTime := c.GetString("start_time")
  990. //endTime, _ := c.GetString("end_time")
  991. times := strings.Split(startTime, "-")
  992. setl_mon := times[0] + times[1]
  993. upld_btch := "0"
  994. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  995. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  996. var result3263 models.JSResult3263
  997. data := make(map[string]interface{})
  998. data["org_name"] = miConfig.OrgName
  999. data["doctor"] = curRoles.UserName
  1000. data["doctor_name"] = curRoles.UserName
  1001. data["fixmedins_code"] = miConfig.Code
  1002. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1003. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1004. data["secret_key"] = miConfig.SecretKey
  1005. data["url"] = miConfig.Url
  1006. data["ak"] = miConfig.AccessKey
  1007. data["cainfo"] = miConfig.Cainfo
  1008. data["setl_mon"] = setl_mon
  1009. data["stmt_loc"] = "2"
  1010. data["upld_btch"] = upld_btch
  1011. client := &http.Client{}
  1012. bytesData, _ := json.Marshal(data)
  1013. var req *http.Request
  1014. if miConfig.MdtrtareaAdmvs == "320921" {
  1015. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1016. } else {
  1017. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1018. }
  1019. resp, _ := client.Do(req)
  1020. defer resp.Body.Close()
  1021. body, ioErr := ioutil.ReadAll(resp.Body)
  1022. if ioErr != nil {
  1023. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. }
  1031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1032. fmt.Println(respJSON)
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println(result)
  1035. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1036. utils.ErrorLog("解析失败:%v", err)
  1037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1038. }
  1039. if result3263.Infcode != "0" {
  1040. c.ServeSuccessJSON(map[string]interface{}{
  1041. "failed_code": -10,
  1042. "msg": result3263.ErrMsg,
  1043. })
  1044. return
  1045. } else {
  1046. c.ServeSuccessJSON(map[string]interface{}{
  1047. "list": result3263.Output,
  1048. })
  1049. return
  1050. }
  1051. }
  1052. func (c *HisApiController) Get3264() {
  1053. admin_user_id, _ := c.GetInt64("admin_user_id")
  1054. startTime := c.GetString("start_time")
  1055. //endTime, _ := c.GetString("end_time")
  1056. times := strings.Split(startTime, "-")
  1057. setl_mon := times[0] + times[1]
  1058. upld_btch := "0"
  1059. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1060. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1061. //solidify_id := []
  1062. var result3263 models.JSResult3263
  1063. data := make(map[string]interface{})
  1064. data["org_name"] = miConfig.OrgName
  1065. data["doctor"] = curRoles.UserName
  1066. data["doctor_name"] = curRoles.UserName
  1067. data["fixmedins_code"] = miConfig.Code
  1068. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1069. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1070. data["secret_key"] = miConfig.SecretKey
  1071. data["url"] = miConfig.Url
  1072. data["ak"] = miConfig.AccessKey
  1073. data["cainfo"] = miConfig.Cainfo
  1074. data["setl_mon"] = setl_mon
  1075. data["stmt_loc"] = "2"
  1076. data["upld_btch"] = upld_btch
  1077. client := &http.Client{}
  1078. bytesData, _ := json.Marshal(data)
  1079. var req3263 *http.Request
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1082. } else {
  1083. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1084. }
  1085. resp, _ := client.Do(req3263)
  1086. defer resp.Body.Close()
  1087. body, ioErr := ioutil.ReadAll(resp.Body)
  1088. if ioErr != nil {
  1089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. }
  1092. var respJSON3263 map[string]interface{}
  1093. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. }
  1097. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1098. fmt.Println(respJSON3263)
  1099. result, _ := json.Marshal(respJSON3263)
  1100. fmt.Println(result)
  1101. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1102. utils.ErrorLog("解析失败:%v", err)
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1104. }
  1105. var ids []string
  1106. for _, item := range result3263.Output {
  1107. ids = append(ids, item.SolidifyID)
  1108. }
  1109. var empty models.JSResultEmpty
  1110. data2 := make(map[string]interface{})
  1111. data2["org_name"] = miConfig.OrgName
  1112. data2["doctor"] = curRoles.UserName
  1113. data2["doctor_name"] = curRoles.UserName
  1114. data2["fixmedins_code"] = miConfig.Code
  1115. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1116. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1117. data2["secret_key"] = miConfig.SecretKey
  1118. data2["url"] = miConfig.Url
  1119. data2["ak"] = miConfig.AccessKey
  1120. data2["cainfo"] = miConfig.Cainfo
  1121. data2["setl_mon"] = setl_mon
  1122. data2["stmt_loc"] = "2"
  1123. data2["upld_btch"] = upld_btch
  1124. data2["solidify_id"] = ids
  1125. client2 := &http.Client{}
  1126. bytesData2, _ := json.Marshal(data2)
  1127. var req *http.Request
  1128. if miConfig.MdtrtareaAdmvs == "320921" {
  1129. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1130. } else {
  1131. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1132. }
  1133. resp2, _ := client2.Do(req)
  1134. defer resp.Body.Close()
  1135. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1136. if ioErr2 != nil {
  1137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. }
  1140. var respJSON map[string]interface{}
  1141. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1142. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. }
  1145. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1146. fmt.Println(respJSON)
  1147. result2, _ := json.Marshal(respJSON)
  1148. fmt.Println(result2)
  1149. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1150. utils.ErrorLog("解析失败:%v", err)
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1152. }
  1153. if empty.Infcode != "0" {
  1154. c.ServeSuccessJSON(map[string]interface{}{
  1155. "failed_code": -10,
  1156. "msg": empty.ErrMsg,
  1157. })
  1158. return
  1159. } else {
  1160. c.ServeSuccessJSON(map[string]interface{}{
  1161. "msg": "",
  1162. })
  1163. return
  1164. }
  1165. }
  1166. func (c *HisApiController) Get3265() {
  1167. admin_user_id, _ := c.GetInt64("admin_user_id")
  1168. startTime := c.GetString("start_time")
  1169. //endTime, _ := c.GetString("end_time")
  1170. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1171. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1172. times := strings.Split(startTime, "-")
  1173. setl_mon := times[0] + times[1]
  1174. var upld_btch string
  1175. upld_btch = "0"
  1176. //var empty models.JSResultEmpty
  1177. var result3265 models.JSResult3264
  1178. var result3263 models.JSResult3263
  1179. data2 := make(map[string]interface{})
  1180. data2["org_name"] = miConfig.OrgName
  1181. data2["doctor"] = curRoles.UserName
  1182. data2["doctor_name"] = curRoles.UserName
  1183. data2["fixmedins_code"] = miConfig.Code
  1184. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1185. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1186. data2["secret_key"] = miConfig.SecretKey
  1187. data2["url"] = miConfig.Url
  1188. data2["ak"] = miConfig.AccessKey
  1189. data2["cainfo"] = miConfig.Cainfo
  1190. data2["setl_mon"] = setl_mon
  1191. data2["stmt_loc"] = "2"
  1192. data2["upld_btch"] = upld_btch
  1193. client2 := &http.Client{}
  1194. bytesData2, _ := json.Marshal(data2)
  1195. var req3263 *http.Request
  1196. if miConfig.MdtrtareaAdmvs == "320921" {
  1197. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1198. } else {
  1199. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1200. }
  1201. resp2, _ := client2.Do(req3263)
  1202. defer resp2.Body.Close()
  1203. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1204. if ioErr2 != nil {
  1205. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1207. }
  1208. var respJSON3263 map[string]interface{}
  1209. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1210. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1212. }
  1213. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1214. fmt.Println(respJSON3263)
  1215. result2, _ := json.Marshal(respJSON3263)
  1216. fmt.Println(result2)
  1217. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1218. utils.ErrorLog("解析失败:%v", err)
  1219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1220. }
  1221. var ids []string
  1222. for _, item := range result3263.Output {
  1223. ids = append(ids, item.SolidifyID)
  1224. }
  1225. data := make(map[string]interface{})
  1226. data["org_name"] = miConfig.OrgName
  1227. data["doctor"] = curRoles.UserName
  1228. data["doctor_name"] = curRoles.UserName
  1229. data["fixmedins_code"] = miConfig.Code
  1230. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1231. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1232. data["secret_key"] = miConfig.SecretKey
  1233. data["url"] = miConfig.Url
  1234. data["ak"] = miConfig.AccessKey
  1235. data["cainfo"] = miConfig.Cainfo
  1236. data["setl_mon"] = setl_mon
  1237. data["solidify_id"] = ids
  1238. month := time.Unix(1557042972, 0).Format("1")
  1239. year := time.Now().Format("2006")
  1240. month = time.Now().Format("01")
  1241. day := time.Now().Format("02")
  1242. hour := time.Now().Format("15")
  1243. min := time.Now().Format("04")
  1244. sec := time.Now().Format("05")
  1245. fix_fill_date := year + month + day + hour + min + sec
  1246. data["fix_fill_dept"] = miConfig.OrgName
  1247. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1248. data["fix_fill_psn"] = curRoles.UserName
  1249. data["fix_fill_date"] = fix_fill_date
  1250. data["stmt_loc"] = "2"
  1251. data["upld_btch"] = upld_btch
  1252. client := &http.Client{}
  1253. bytesData, _ := json.Marshal(data)
  1254. var req *http.Request
  1255. if miConfig.MdtrtareaAdmvs == "320921" {
  1256. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1257. } else {
  1258. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1259. }
  1260. resp, _ := client.Do(req)
  1261. defer resp.Body.Close()
  1262. body, ioErr := ioutil.ReadAll(resp.Body)
  1263. if ioErr != nil {
  1264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1266. }
  1267. var respJSON map[string]interface{}
  1268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1271. }
  1272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1273. fmt.Println(respJSON)
  1274. result, _ := json.Marshal(respJSON)
  1275. fmt.Println(result)
  1276. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. }
  1280. if result3265.Infcode != "0" {
  1281. c.ServeSuccessJSON(map[string]interface{}{
  1282. "failed_code": -10,
  1283. "msg": result3265.ErrMsg,
  1284. })
  1285. return
  1286. } else {
  1287. c.ServeSuccessJSON(map[string]interface{}{
  1288. "info": result3265.Output,
  1289. })
  1290. return
  1291. }
  1292. }
  1293. func (c *HisApiController) Get3266() {
  1294. admin_user_id, _ := c.GetInt64("admin_user_id")
  1295. startTime := c.GetString("start_time")
  1296. //endTime, _ := c.GetString("end_time")
  1297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1299. times := strings.Split(startTime, "-")
  1300. stmt_mon := times[0] + times[1]
  1301. var upld_btch string
  1302. //var empty models.JSResultEmpty
  1303. var result3265 models.JSResult3264
  1304. data := make(map[string]interface{})
  1305. data["org_name"] = miConfig.OrgName
  1306. data["doctor"] = curRoles.UserName
  1307. data["doctor_name"] = curRoles.UserName
  1308. data["fixmedins_code"] = miConfig.Code
  1309. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1310. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1311. data["secret_key"] = miConfig.SecretKey
  1312. data["url"] = miConfig.Url
  1313. data["ak"] = miConfig.AccessKey
  1314. data["cainfo"] = miConfig.Cainfo
  1315. data["setl_mon"] = stmt_mon
  1316. month := time.Unix(1557042972, 0).Format("1")
  1317. year := time.Now().Format("2006")
  1318. month = time.Now().Format("01")
  1319. day := time.Now().Format("02")
  1320. hour := time.Now().Format("15")
  1321. min := time.Now().Format("04")
  1322. sec := time.Now().Format("05")
  1323. fix_fill_date := year + month + day + hour + min + sec
  1324. data["fix_fill_dept"] = miConfig.OrgName
  1325. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1326. data["fix_fill_psn"] = curRoles.UserName
  1327. data["fix_fill_date"] = fix_fill_date
  1328. data["stmt_loc"] = "2"
  1329. upld_btch = "0"
  1330. data["upld_btch"] = upld_btch
  1331. client := &http.Client{}
  1332. bytesData, _ := json.Marshal(data)
  1333. var req *http.Request
  1334. if miConfig.MdtrtareaAdmvs == "320921" {
  1335. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1336. } else {
  1337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1338. }
  1339. resp, _ := client.Do(req)
  1340. defer resp.Body.Close()
  1341. body, ioErr := ioutil.ReadAll(resp.Body)
  1342. if ioErr != nil {
  1343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. }
  1346. var respJSON map[string]interface{}
  1347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1350. }
  1351. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1352. fmt.Println(respJSON)
  1353. result, _ := json.Marshal(respJSON)
  1354. fmt.Println(result)
  1355. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1356. utils.ErrorLog("解析失败:%v", err)
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1358. }
  1359. if result3265.Infcode != "0" {
  1360. c.ServeSuccessJSON(map[string]interface{}{
  1361. "failed_code": -10,
  1362. "msg": result3265.ErrMsg,
  1363. })
  1364. return
  1365. } else {
  1366. c.ServeSuccessJSON(map[string]interface{}{
  1367. "info": result3265.Output,
  1368. })
  1369. return
  1370. }
  1371. }
  1372. func (c *HisApiController) Get3267() {
  1373. admin_user_id, _ := c.GetInt64("admin_user_id")
  1374. startTime := c.GetString("start_time")
  1375. //endTime, _ := c.GetString("end_time")
  1376. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1377. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1378. times := strings.Split(startTime, "-")
  1379. setl_mon := times[0] + times[1]
  1380. var upld_btch string
  1381. //var empty models.JSResultEmpty
  1382. var result3265 models.JSResult3264
  1383. upld_btch = "0"
  1384. data := make(map[string]interface{})
  1385. data["org_name"] = miConfig.OrgName
  1386. data["doctor"] = curRoles.UserName
  1387. data["doctor_name"] = curRoles.UserName
  1388. data["fixmedins_code"] = miConfig.Code
  1389. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1390. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1391. data["secret_key"] = miConfig.SecretKey
  1392. data["url"] = miConfig.Url
  1393. data["ak"] = miConfig.AccessKey
  1394. data["cainfo"] = miConfig.Cainfo
  1395. data["setl_mon"] = setl_mon
  1396. data["stmt_loc"] = "2"
  1397. data["upld_btch"] = upld_btch
  1398. client := &http.Client{}
  1399. bytesData, _ := json.Marshal(data)
  1400. var req *http.Request
  1401. if miConfig.MdtrtareaAdmvs == "320921" {
  1402. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1403. } else {
  1404. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1405. }
  1406. resp, _ := client.Do(req)
  1407. defer resp.Body.Close()
  1408. body, ioErr := ioutil.ReadAll(resp.Body)
  1409. if ioErr != nil {
  1410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. }
  1413. var respJSON map[string]interface{}
  1414. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1417. }
  1418. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1419. fmt.Println(respJSON)
  1420. result, _ := json.Marshal(respJSON)
  1421. fmt.Println(result)
  1422. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1423. utils.ErrorLog("解析失败:%v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. }
  1426. if result3265.Infcode != "0" {
  1427. c.ServeSuccessJSON(map[string]interface{}{
  1428. "failed_code": -10,
  1429. "msg": result3265.ErrMsg,
  1430. })
  1431. return
  1432. } else {
  1433. c.ServeSuccessJSON(map[string]interface{}{
  1434. "info": result3265.Output.Data,
  1435. })
  1436. return
  1437. }
  1438. }
  1439. func (c *HisApiController) Get3268() {
  1440. admin_user_id, _ := c.GetInt64("admin_user_id")
  1441. startTime := c.GetString("start_time")
  1442. endTime := c.GetString("end_time")
  1443. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1445. times := strings.Split(startTime, "-")
  1446. setl_mon := times[0] + times[1]
  1447. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1448. var twos []models.FixMonRecDetailFileInTwo
  1449. var funs []models.FundDetail
  1450. for _, item := range datas {
  1451. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1452. funs = append(funs, fun...)
  1453. }
  1454. var funInfos []models.Fund
  1455. //for _, item := range funs {
  1456. // var rf []models.FundInfo
  1457. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1458. // for _, subitem := range rf {
  1459. // var fund models.Fund
  1460. // fund.FundCode = subitem.FundPayType
  1461. // fund.FundName = subitem.FundPayTypeName
  1462. // fund.FundAmt = subitem.FundPayAmt
  1463. // fund.FundKey = item.FundKey
  1464. // fund.InsuAdmdvs = "555555"
  1465. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1466. // funInfos = append(funInfos, fund)
  1467. // }
  1468. //}
  1469. for _, team := range datas {
  1470. var two models.FixMonRecDetailFileInTwo
  1471. two.SetlDate = time.Now().Format("2006-01-02")
  1472. two.MedType = team.MedType
  1473. two.Insutype = team.Insutype
  1474. two.PsnType = team.PsnType
  1475. two.MedType = team.MedType
  1476. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1477. two.InsuAdmdvs = team.InsuAdmdvs
  1478. two.PsnTime = team.PsnTime
  1479. two.PsnCnt = team.PsnCnt
  1480. two.FundKey = team.FundKey
  1481. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1482. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1483. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1484. two.MedfeeSumAmt = ms
  1485. two.InscpAmt = ia
  1486. two.FundPaySumAmt = fps
  1487. twos = append(twos, two)
  1488. }
  1489. var upld_btch string
  1490. upld_btch = "0"
  1491. var empty models.JSResultEmpty
  1492. data := make(map[string]interface{})
  1493. data["org_name"] = miConfig.OrgName
  1494. data["doctor"] = curRoles.UserName
  1495. data["doctor_name"] = curRoles.UserName
  1496. data["fixmedins_code"] = miConfig.Code
  1497. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1498. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1499. data["secret_key"] = miConfig.SecretKey
  1500. data["url"] = miConfig.Url
  1501. data["ak"] = miConfig.AccessKey
  1502. data["cainfo"] = miConfig.Cainfo
  1503. data["datas"] = twos
  1504. data["fund"] = funInfos
  1505. data["setl_mon"] = setl_mon
  1506. month := time.Unix(1557042972, 0).Format("1")
  1507. year := time.Now().Format("2006")
  1508. month = time.Now().Format("01")
  1509. day := time.Now().Format("02")
  1510. hour := time.Now().Format("15")
  1511. min := time.Now().Format("04")
  1512. sec := time.Now().Format("05")
  1513. fix_fill_date := year + month + day + hour + min + sec
  1514. data["fix_fill_dept"] = miConfig.OrgName
  1515. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1516. data["fix_fill_psn"] = curRoles.UserName
  1517. data["fix_fill_date"] = fix_fill_date
  1518. data["stmt_loc"] = "2"
  1519. data["upld_btch"] = upld_btch
  1520. client := &http.Client{}
  1521. bytesData, _ := json.Marshal(data)
  1522. var req *http.Request
  1523. if miConfig.MdtrtareaAdmvs == "320921" {
  1524. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1525. } else {
  1526. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1527. }
  1528. resp, _ := client.Do(req)
  1529. defer resp.Body.Close()
  1530. body, ioErr := ioutil.ReadAll(resp.Body)
  1531. if ioErr != nil {
  1532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1534. }
  1535. var respJSON map[string]interface{}
  1536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. }
  1540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1541. fmt.Println(respJSON)
  1542. result, _ := json.Marshal(respJSON)
  1543. fmt.Println(result)
  1544. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1545. utils.ErrorLog("解析失败:%v", err)
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1547. }
  1548. if empty.Infcode != "0" {
  1549. c.ServeSuccessJSON(map[string]interface{}{
  1550. "failed_code": -10,
  1551. "msg": empty.ErrMsg,
  1552. })
  1553. return
  1554. } else {
  1555. c.ServeSuccessJSON(map[string]interface{}{
  1556. "msg": "上传成功",
  1557. })
  1558. return
  1559. }
  1560. }
  1561. func (c *HisApiController) Get3269() {
  1562. admin_user_id, _ := c.GetInt64("admin_user_id")
  1563. startTime := c.GetString("start_time")
  1564. //endTime, _ := c.GetString("end_time")
  1565. times := strings.Split(startTime, "-")
  1566. setl_mon := times[0] + times[1]
  1567. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1568. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1569. var result3263 models.JSResult3263
  1570. data := make(map[string]interface{})
  1571. data["org_name"] = miConfig.OrgName
  1572. data["doctor"] = curRoles.UserName
  1573. data["doctor_name"] = curRoles.UserName
  1574. data["fixmedins_code"] = miConfig.Code
  1575. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1576. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1577. data["secret_key"] = miConfig.SecretKey
  1578. data["url"] = miConfig.Url
  1579. data["ak"] = miConfig.AccessKey
  1580. data["cainfo"] = miConfig.Cainfo
  1581. data["setl_mon"] = setl_mon
  1582. data["stmt_loc"] = "2"
  1583. client := &http.Client{}
  1584. bytesData, _ := json.Marshal(data)
  1585. var req *http.Request
  1586. if miConfig.MdtrtareaAdmvs == "320921" {
  1587. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1588. } else {
  1589. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1590. }
  1591. resp, _ := client.Do(req)
  1592. defer resp.Body.Close()
  1593. body, ioErr := ioutil.ReadAll(resp.Body)
  1594. if ioErr != nil {
  1595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1597. }
  1598. var respJSON map[string]interface{}
  1599. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1602. }
  1603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1604. fmt.Println(respJSON)
  1605. result, _ := json.Marshal(respJSON)
  1606. fmt.Println(result)
  1607. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1608. utils.ErrorLog("解析失败:%v", err)
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1610. }
  1611. if result3263.Infcode != "0" {
  1612. c.ServeSuccessJSON(map[string]interface{}{
  1613. "failed_code": -10,
  1614. "msg": result3263.ErrMsg,
  1615. })
  1616. return
  1617. } else {
  1618. c.ServeSuccessJSON(map[string]interface{}{
  1619. "msg": "上传成功",
  1620. })
  1621. return
  1622. }
  1623. }
  1624. func (c *HisApiController) Get3270() {
  1625. admin_user_id, _ := c.GetInt64("admin_user_id")
  1626. startTime := c.GetString("start_time")
  1627. //endTime, _ := c.GetString("end_time")
  1628. times := strings.Split(startTime, "-")
  1629. setl_mon := times[0] + times[1]
  1630. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1631. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1632. var result3263 models.JSResult3263
  1633. data2 := make(map[string]interface{})
  1634. data2["org_name"] = miConfig.OrgName
  1635. data2["doctor"] = curRoles.UserName
  1636. data2["doctor_name"] = curRoles.UserName
  1637. data2["fixmedins_code"] = miConfig.Code
  1638. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1639. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1640. data2["secret_key"] = miConfig.SecretKey
  1641. data2["url"] = miConfig.Url
  1642. data2["ak"] = miConfig.AccessKey
  1643. data2["cainfo"] = miConfig.Cainfo
  1644. data2["setl_mon"] = setl_mon
  1645. data2["stmt_loc"] = "2"
  1646. client2 := &http.Client{}
  1647. bytesData2, _ := json.Marshal(data2)
  1648. var req3263 *http.Request
  1649. if miConfig.MdtrtareaAdmvs == "320921" {
  1650. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1651. } else {
  1652. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1653. }
  1654. resp2, _ := client2.Do(req3263)
  1655. defer resp2.Body.Close()
  1656. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1657. if ioErr2 != nil {
  1658. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1660. }
  1661. var respJSON3263 map[string]interface{}
  1662. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1665. }
  1666. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1667. fmt.Println(respJSON3263)
  1668. result2, _ := json.Marshal(respJSON3263)
  1669. fmt.Println(result2)
  1670. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1671. utils.ErrorLog("解析失败:%v", err)
  1672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1673. }
  1674. var ids []string
  1675. for _, item := range result3263.Output {
  1676. ids = append(ids, item.SolidifyID)
  1677. }
  1678. var result3264 models.JSResult3264
  1679. data := make(map[string]interface{})
  1680. data["org_name"] = miConfig.OrgName
  1681. data["doctor"] = curRoles.UserName
  1682. data["doctor_name"] = curRoles.UserName
  1683. data["fixmedins_code"] = miConfig.Code
  1684. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1685. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1686. data["secret_key"] = miConfig.SecretKey
  1687. data["url"] = miConfig.Url
  1688. data["ak"] = miConfig.AccessKey
  1689. data["cainfo"] = miConfig.Cainfo
  1690. data["setl_mon"] = setl_mon
  1691. data["stmt_loc"] = "2"
  1692. data["solidify_id"] = ids
  1693. client := &http.Client{}
  1694. bytesData, _ := json.Marshal(data)
  1695. var req *http.Request
  1696. if miConfig.MdtrtareaAdmvs == "320921" {
  1697. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1698. } else {
  1699. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  1700. }
  1701. resp, _ := client.Do(req)
  1702. defer resp.Body.Close()
  1703. body, ioErr := ioutil.ReadAll(resp.Body)
  1704. if ioErr != nil {
  1705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1707. }
  1708. var respJSON map[string]interface{}
  1709. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1710. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1712. }
  1713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1714. fmt.Println(respJSON)
  1715. result, _ := json.Marshal(respJSON)
  1716. fmt.Println(result)
  1717. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  1718. utils.ErrorLog("解析失败:%v", err)
  1719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1720. }
  1721. if result3264.Infcode != "0" {
  1722. c.ServeSuccessJSON(map[string]interface{}{
  1723. "failed_code": -10,
  1724. "msg": result3264.ErrMsg,
  1725. })
  1726. return
  1727. } else {
  1728. c.ServeSuccessJSON(map[string]interface{}{
  1729. "info": result3264.Output,
  1730. })
  1731. return
  1732. }
  1733. }
  1734. func (c *HisApiController) Get3271() {
  1735. admin_user_id, _ := c.GetInt64("admin_user_id")
  1736. startTime := c.GetString("start_time")
  1737. //endTime, _ := c.GetString("end_time")
  1738. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1740. times := strings.Split(startTime, "-")
  1741. setl_mon := times[0] + times[1]
  1742. //var empty models.JSResultEmpty
  1743. var result3265 models.JSResult3264
  1744. var result3263 models.JSResult3263
  1745. data2 := make(map[string]interface{})
  1746. data2["org_name"] = miConfig.OrgName
  1747. data2["doctor"] = curRoles.UserName
  1748. data2["doctor_name"] = curRoles.UserName
  1749. data2["fixmedins_code"] = miConfig.Code
  1750. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1751. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1752. data2["secret_key"] = miConfig.SecretKey
  1753. data2["url"] = miConfig.Url
  1754. data2["ak"] = miConfig.AccessKey
  1755. data2["cainfo"] = miConfig.Cainfo
  1756. data2["setl_mon"] = setl_mon
  1757. data2["stmt_loc"] = "2"
  1758. client2 := &http.Client{}
  1759. bytesData2, _ := json.Marshal(data2)
  1760. var req3263 *http.Request
  1761. if miConfig.MdtrtareaAdmvs == "320921" {
  1762. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1763. } else {
  1764. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1765. }
  1766. resp2, _ := client2.Do(req3263)
  1767. defer resp2.Body.Close()
  1768. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1769. if ioErr2 != nil {
  1770. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1772. }
  1773. var respJSON3263 map[string]interface{}
  1774. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1775. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1777. }
  1778. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1779. fmt.Println(respJSON3263)
  1780. result2, _ := json.Marshal(respJSON3263)
  1781. fmt.Println(result2)
  1782. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1783. utils.ErrorLog("解析失败:%v", err)
  1784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1785. }
  1786. var ids []string
  1787. for _, item := range result3263.Output {
  1788. ids = append(ids, item.SolidifyID)
  1789. }
  1790. data := make(map[string]interface{})
  1791. data["org_name"] = miConfig.OrgName
  1792. data["doctor"] = curRoles.UserName
  1793. data["doctor_name"] = curRoles.UserName
  1794. data["fixmedins_code"] = miConfig.Code
  1795. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1796. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1797. data["secret_key"] = miConfig.SecretKey
  1798. data["url"] = miConfig.Url
  1799. data["ak"] = miConfig.AccessKey
  1800. data["cainfo"] = miConfig.Cainfo
  1801. data["setl_mon"] = setl_mon
  1802. data["solidify_id"] = ids
  1803. month := time.Unix(1557042972, 0).Format("1")
  1804. year := time.Now().Format("2006")
  1805. month = time.Now().Format("01")
  1806. day := time.Now().Format("02")
  1807. hour := time.Now().Format("15")
  1808. min := time.Now().Format("04")
  1809. sec := time.Now().Format("05")
  1810. fix_fill_date := year + month + day + hour + min + sec
  1811. data["fix_fill_dept"] = miConfig.OrgName
  1812. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1813. data["fix_fill_psn"] = curRoles.UserName
  1814. data["fix_fill_date"] = fix_fill_date
  1815. data["stmt_loc"] = "2"
  1816. client := &http.Client{}
  1817. bytesData, _ := json.Marshal(data)
  1818. var req *http.Request
  1819. if miConfig.MdtrtareaAdmvs == "320921" {
  1820. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1821. } else {
  1822. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  1823. }
  1824. resp, _ := client.Do(req)
  1825. defer resp.Body.Close()
  1826. body, ioErr := ioutil.ReadAll(resp.Body)
  1827. if ioErr != nil {
  1828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. }
  1831. var respJSON map[string]interface{}
  1832. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1833. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1835. }
  1836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1837. fmt.Println(respJSON)
  1838. result, _ := json.Marshal(respJSON)
  1839. fmt.Println(result)
  1840. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1841. utils.ErrorLog("解析失败:%v", err)
  1842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1843. }
  1844. if result3265.Infcode != "0" {
  1845. c.ServeSuccessJSON(map[string]interface{}{
  1846. "failed_code": -10,
  1847. "msg": result3265.ErrMsg,
  1848. })
  1849. return
  1850. } else {
  1851. c.ServeSuccessJSON(map[string]interface{}{
  1852. "info": result3265.Output.Data,
  1853. })
  1854. return
  1855. }
  1856. }
  1857. func (c *HisApiController) Get3272() {
  1858. admin_user_id, _ := c.GetInt64("admin_user_id")
  1859. startTime := c.GetString("start_time")
  1860. //endTime, _ := c.GetString("end_time")
  1861. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1862. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1863. times := strings.Split(startTime, "-")
  1864. setl_mon := times[0] + times[1]
  1865. var upld_btch string
  1866. //var empty models.JSResultEmpty
  1867. var result3265 models.JSResult3264
  1868. data := make(map[string]interface{})
  1869. data["org_name"] = miConfig.OrgName
  1870. data["doctor"] = curRoles.UserName
  1871. data["doctor_name"] = curRoles.UserName
  1872. data["fixmedins_code"] = miConfig.Code
  1873. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1874. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1875. data["secret_key"] = miConfig.SecretKey
  1876. data["url"] = miConfig.Url
  1877. data["ak"] = miConfig.AccessKey
  1878. data["cainfo"] = miConfig.Cainfo
  1879. data["setl_mon"] = setl_mon
  1880. month := time.Unix(1557042972, 0).Format("1")
  1881. year := time.Now().Format("2006")
  1882. month = time.Now().Format("01")
  1883. day := time.Now().Format("02")
  1884. hour := time.Now().Format("15")
  1885. min := time.Now().Format("04")
  1886. sec := time.Now().Format("05")
  1887. fix_fill_date := year + month + day + hour + min + sec
  1888. data["fix_fill_dept"] = miConfig.OrgName
  1889. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1890. data["fix_fill_psn"] = curRoles.UserName
  1891. data["fix_fill_date"] = fix_fill_date
  1892. data["stmt_loc"] = "2"
  1893. data["upld_btch"] = upld_btch
  1894. client := &http.Client{}
  1895. bytesData, _ := json.Marshal(data)
  1896. var req *http.Request
  1897. if miConfig.MdtrtareaAdmvs == "320921" {
  1898. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1899. } else {
  1900. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  1901. }
  1902. resp, _ := client.Do(req)
  1903. defer resp.Body.Close()
  1904. body, ioErr := ioutil.ReadAll(resp.Body)
  1905. if ioErr != nil {
  1906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1908. }
  1909. var respJSON map[string]interface{}
  1910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. }
  1914. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1915. fmt.Println(respJSON)
  1916. result, _ := json.Marshal(respJSON)
  1917. fmt.Println(result)
  1918. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1919. utils.ErrorLog("解析失败:%v", err)
  1920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1921. }
  1922. if result3265.Infcode != "0" {
  1923. c.ServeSuccessJSON(map[string]interface{}{
  1924. "failed_code": -10,
  1925. "msg": result3265.ErrMsg,
  1926. })
  1927. return
  1928. } else {
  1929. c.ServeSuccessJSON(map[string]interface{}{
  1930. "info": result3265.Output,
  1931. })
  1932. return
  1933. }
  1934. }
  1935. func (c *HisApiController) Get3273() {
  1936. admin_user_id, _ := c.GetInt64("admin_user_id")
  1937. startTime := c.GetString("start_time")
  1938. //endTime, _ := c.GetString("end_time")
  1939. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1940. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1941. times := strings.Split(startTime, "-")
  1942. setl_mon := times[0] + times[1]
  1943. var result3265 models.JSResult3264
  1944. data := make(map[string]interface{})
  1945. data["org_name"] = miConfig.OrgName
  1946. data["doctor"] = curRoles.UserName
  1947. data["doctor_name"] = curRoles.UserName
  1948. data["fixmedins_code"] = miConfig.Code
  1949. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1950. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1951. data["secret_key"] = miConfig.SecretKey
  1952. data["url"] = miConfig.Url
  1953. data["ak"] = miConfig.AccessKey
  1954. data["cainfo"] = miConfig.Cainfo
  1955. data["setl_mon"] = setl_mon
  1956. data["stmt_loc"] = "2"
  1957. client := &http.Client{}
  1958. bytesData, _ := json.Marshal(data)
  1959. var req *http.Request
  1960. if miConfig.MdtrtareaAdmvs == "320921" {
  1961. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1962. } else {
  1963. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  1964. }
  1965. resp, _ := client.Do(req)
  1966. defer resp.Body.Close()
  1967. body, ioErr := ioutil.ReadAll(resp.Body)
  1968. if ioErr != nil {
  1969. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1971. }
  1972. var respJSON map[string]interface{}
  1973. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1974. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1976. }
  1977. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1978. fmt.Println(respJSON)
  1979. result, _ := json.Marshal(respJSON)
  1980. fmt.Println(result)
  1981. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1982. utils.ErrorLog("解析失败:%v", err)
  1983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1984. }
  1985. if result3265.Infcode != "0" {
  1986. c.ServeSuccessJSON(map[string]interface{}{
  1987. "failed_code": -10,
  1988. "msg": result3265.ErrMsg,
  1989. })
  1990. return
  1991. } else {
  1992. c.ServeSuccessJSON(map[string]interface{}{
  1993. "info": result3265.Output.Data,
  1994. })
  1995. return
  1996. }
  1997. }
  1998. func (c *HisApiController) Get3274() {
  1999. //if miConfig.MdtrtareaAdmvs == "320921" {
  2000. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2001. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2002. // "&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
  2003. //
  2004. //} else {
  2005. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2006. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2007. // "&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
  2008. //
  2009. //}
  2010. }
  2011. func (c *HisApiController) Get3275() {
  2012. //if miConfig.MdtrtareaAdmvs == "320921" {
  2013. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2014. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2015. // "&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
  2016. //
  2017. //} else {
  2018. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2019. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2020. // "&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
  2021. //
  2022. //}
  2023. }
  2024. func (c *HisApiController) Get3276() {
  2025. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2026. //month := c.GetString("month")
  2027. //
  2028. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2029. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2030. //var api string
  2031. //var res Result5301
  2032. //
  2033. //if miConfig.MdtrtareaAdmvs == "320921" {
  2034. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2035. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2036. //} else {
  2037. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2038. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2039. //}
  2040. //
  2041. //resp, requestErr := http.Get(api)
  2042. //if requestErr != nil {
  2043. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2044. // return
  2045. //}
  2046. //
  2047. //body, ioErr := ioutil.ReadAll(resp.Body)
  2048. //if ioErr != nil {
  2049. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2050. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2051. // return
  2052. //}
  2053. //var respJSON map[string]interface{}
  2054. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2055. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2056. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2057. // return
  2058. //}
  2059. //
  2060. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2061. //result, _ := json.Marshal(respJSON)
  2062. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2063. // utils.ErrorLog("解析失败:%v", err)
  2064. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2065. // return
  2066. //}
  2067. }
  2068. func (c *HisApiController) Get3277() {
  2069. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2070. //month := c.GetString("month")
  2071. //
  2072. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2073. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2074. //var api string
  2075. //var res Result5301
  2076. //
  2077. //if miConfig.MdtrtareaAdmvs == "320921" {
  2078. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2079. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2080. //} else {
  2081. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2082. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2083. //}
  2084. //
  2085. //resp, requestErr := http.Get(api)
  2086. //if requestErr != nil {
  2087. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. // return
  2089. //}
  2090. //
  2091. //body, ioErr := ioutil.ReadAll(resp.Body)
  2092. //if ioErr != nil {
  2093. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2095. // return
  2096. //}
  2097. //var respJSON map[string]interface{}
  2098. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2099. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. // return
  2102. //}
  2103. //
  2104. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2105. //result, _ := json.Marshal(respJSON)
  2106. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2107. // utils.ErrorLog("解析失败:%v", err)
  2108. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2109. // return
  2110. //}
  2111. }
  2112. func (c *HisApiController) GetCFYLJG001() {
  2113. admin_user_id, _ := c.GetInt64("admin_user_id")
  2114. patient_id, _ := c.GetInt64("patient_id")
  2115. his_patient_id, _ := c.GetInt64("his_patient_id")
  2116. record_time := c.GetString("record_time")
  2117. admin_user_id = 3626
  2118. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2119. psn, _ := service.GetPsnByPatientId(patient_id)
  2120. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2122. var cFYLJG001 models.CFYLJG001
  2123. timeLayout := "2006-01-02"
  2124. loc, _ := time.LoadLocation("Local")
  2125. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2126. if err != nil {
  2127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2128. return
  2129. }
  2130. recordDateTime := theTime.Unix()
  2131. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2132. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2133. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2134. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2135. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2136. for _, item := range prescriptions {
  2137. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2138. if his.IdCardType == 1 {
  2139. bas := strings.Split(psn.CardInfo, "|")
  2140. basNumber := bas[1]
  2141. fmt.Println(basNumber)
  2142. card_sn := bas[3]
  2143. card_no := bas[2]
  2144. cFYLJG001.MdtrtCertType = "03"
  2145. cFYLJG001.CardSn = card_sn
  2146. cFYLJG001.MdtrtCertNo = card_no
  2147. cFYLJG001.EcToken = ""
  2148. cFYLJG001.AuthNo = ""
  2149. } else if his.IdCardType == 2 {
  2150. cFYLJG001.MdtrtCertType = "02"
  2151. cFYLJG001.CardSn = ""
  2152. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2153. cFYLJG001.EcToken = ""
  2154. cFYLJG001.AuthNo = ""
  2155. } else if his.IdCardType == 4 {
  2156. cFYLJG001.MdtrtCertType = "01"
  2157. cFYLJG001.CardSn = ""
  2158. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2159. cFYLJG001.EcToken = psn.VerifyNumber
  2160. cFYLJG001.AuthNo = ""
  2161. }
  2162. cFYLJG001.BizTypeCode = "01"
  2163. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2164. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2165. cFYLJG001.RxTypeCode = "1"
  2166. tempTime := time.Unix(item.PreTime, 0)
  2167. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2168. cFYLJG001.PrscTime = timeFormatOne
  2169. var count float64
  2170. if item.Type == 1 {
  2171. for _, sumItem := range item.HisDoctorAdviceInfo {
  2172. count = count + sumItem.PrescribingNumber
  2173. }
  2174. }
  2175. cFYLJG001.RxDrugCnt = count
  2176. cFYLJG001.ValiDays = "5"
  2177. ts := time.Unix(item.PreTime, 0)
  2178. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2179. tempTime3 := time.Unix(record_time2, 0)
  2180. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2181. cFYLJG001.ValiEndTime = timeFormat3
  2182. cFYLJG001.RxCotnFlag = "0"
  2183. for _, subItem := range item.HisDoctorAdviceInfo {
  2184. var drug models.RxDrug
  2185. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2186. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2187. drug.RxItemTypeCode = "11"
  2188. drug.DrugDosform = "乳膏剂" //TODO
  2189. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2190. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2191. }
  2192. drug.MedcWayDscr = subItem.DeliveryWay
  2193. tempTime2 := time.Unix(subItem.StartTime, 0)
  2194. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2195. drug.MedcBegntime = timeFormatTwo
  2196. if subItem.Day > 0 {
  2197. ts := time.Unix(subItem.StartTime, 0)
  2198. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2199. tempTime4 := time.Unix(record_time, 0)
  2200. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2201. drug.MedcEndtime = timeFormat5
  2202. } else {
  2203. tempTime2 := time.Unix(subItem.StartTime, 0)
  2204. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2205. drug.MedcEndtime = timeFormatTwo
  2206. }
  2207. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2208. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2209. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2210. drug.DrugCnt = subItem.PrescribingNumber
  2211. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2212. drug.DrugGenname = subItem.AdviceName
  2213. drug.MedcWayCodg = subItem.DeliveryWay
  2214. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2215. drug.SinDoscnt = subItem.SingleDose
  2216. drug.SinDosunt = subItem.SingleDoseUnit
  2217. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2218. drug.UsedFrquName = subItem.ExecutionFrequency
  2219. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2220. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2221. drug.HospApprFlag = "1"
  2222. cFYLJG001.List = append(cFYLJG001.List, drug)
  2223. }
  2224. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2225. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2226. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2227. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2228. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2229. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2230. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2231. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2232. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2233. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2234. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2235. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2236. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2237. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2238. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2239. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2240. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2241. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2242. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2243. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2244. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2245. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2246. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2247. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2248. tempTime2 := time.Now().Unix()
  2249. tempTime6 := time.Unix(tempTime2, 0)
  2250. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2251. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2252. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2253. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2254. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2255. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2256. //memo := make(map[string]interface{})
  2257. //inputData := make(map[string]interface{}, 0)
  2258. //type MyData struct {
  2259. // Insutype string `json:"insutype"`
  2260. //}
  2261. //
  2262. // data := MyData{
  2263. // Insutype: his.Insutype,
  2264. //}
  2265. //
  2266. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2267. var config []*models.HisXtDiagnoseConfig
  2268. for _, item := range diagnosis_ids {
  2269. id, _ := strconv.ParseInt(item, 10, 64)
  2270. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2271. config = append(config, &diagnosisConfig)
  2272. }
  2273. for index, subitem := range config {
  2274. if index == 0 {
  2275. var dia models.DiseInfo
  2276. dia.DiagType = "1"
  2277. dia.MaindiagFlag = "1"
  2278. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2279. dia.DiagCode = subitem.CountryCode
  2280. dia.DiagName = subitem.ClassName
  2281. dia.DiagDept = "肾内科"
  2282. dia.DiagDrNo = doctor.DoctorNumber
  2283. dia.DiagDrName = doctor.UserName
  2284. tempTime3 := time.Unix(item.PreTime, 0)
  2285. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2286. dia.DiagTime = timeFormatTwo
  2287. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2288. } else {
  2289. var dia models.DiseInfo
  2290. dia.DiagType = "1"
  2291. dia.MaindiagFlag = "0"
  2292. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2293. dia.DiagCode = subitem.CountryCode
  2294. dia.DiagName = subitem.ClassName
  2295. dia.DiagDept = "肾内科"
  2296. dia.DiagDrNo = doctor.DoctorNumber
  2297. dia.DiagDrName = doctor.UserName
  2298. tempTime3 := time.Unix(item.PreTime, 0)
  2299. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2300. dia.DiagTime = timeFormatTwo
  2301. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2302. }
  2303. }
  2304. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2305. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2306. var res ResultCFYLJG001
  2307. var respJSON2 map[string]interface{}
  2308. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2309. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2311. return
  2312. }
  2313. userJSONBytes2, _ := json.Marshal(respJSON2)
  2314. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2315. utils.ErrorLog("解析失败:%v", err)
  2316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2317. return
  2318. }
  2319. if res.Infcode == -1 {
  2320. c.ServeSuccessJSON(map[string]interface{}{
  2321. "failed_code": -10,
  2322. "msg": res.ErrMsg,
  2323. })
  2324. return
  2325. } else {
  2326. var flow models.HisPrescriptionFlow
  2327. flow.Ctime = time.Now().Unix()
  2328. flow.SignDigest = ""
  2329. flow.RxTraceCode = res.Output.RxTraceCode
  2330. flow.HiRxno = res.Output.HiRxno
  2331. flow.MID = his.Number
  2332. flow.Status = 1
  2333. flow.DCode = doctor_info.DoctorNumber
  2334. flow.OriginalRxFile = ""
  2335. flow.OriginalValue = ""
  2336. flow.SignCertDn = ""
  2337. flow.UserOrgId = 10454
  2338. flow.SignCertSn = ""
  2339. flow.Mtime = time.Now().Unix()
  2340. service.Createflow(&flow)
  2341. c.ServeSuccessJSON(map[string]interface{}{
  2342. "msg": "上传成功",
  2343. })
  2344. }
  2345. }
  2346. }
  2347. func (c *HisApiController) GetCFYLJG002() {
  2348. admin_user_id, _ := c.GetInt64("admin_user_id")
  2349. his_patient_id, _ := c.GetInt64("his_patient_id")
  2350. record_time := c.GetString("record_time")
  2351. admin_user_id = 3626
  2352. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2353. //id, _ := c.GetInt64("id")
  2354. admin_user_id = 3626
  2355. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2356. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2357. flow, _ := service.Getflowtwo(his.Number)
  2358. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2359. //record_time := c.GetString("record_time")
  2360. patient_id, _ := c.GetInt64("patient_id")
  2361. //patient_id = 23834
  2362. //record_time = "2023-09-18"
  2363. timeLayout := "2006-01-02"
  2364. loc, _ := time.LoadLocation("Local")
  2365. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2366. if err != nil {
  2367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2368. return
  2369. }
  2370. recordDateTime := theTime.Unix()
  2371. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2372. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2373. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2374. dept, _ := service.GetDepartMentDetail(info.Departments)
  2375. inputData := make(map[string]interface{})
  2376. inputData["rxTraceCode"] = flow.RxTraceCode
  2377. inputData["hiRxno"] = flow.HiRxno
  2378. inputData["mdtrtId"] = flow.MID
  2379. inputData["patnName"] = his.PsnName
  2380. inputData["psnCertType"] = his.PsnCertType
  2381. inputData["certno"] = his.Certno
  2382. inputData["fixmedinsName"] = miConfig.OrgName
  2383. inputData["fixmedinsCode"] = miConfig.Code
  2384. inputData["drCode"] = doctor_info.DoctorNumber
  2385. inputData["prscDrName"] = doctor_info.UserName
  2386. inputData["pharDeptName"] = dept.Name
  2387. inputData["pharDeptCode"] = dept.Number
  2388. inputData["pharProfttlCodg"] = dept.Name
  2389. inputData["pharProfttlName"] = ""
  2390. inputData["pharCode"] = "HY440309002107"
  2391. inputData["pharCertType"] = "01"
  2392. inputData["pharCertno"] = "430482199408260023"
  2393. inputData["pharName"] = "彭斯遥"
  2394. inputData["pharPracCertNo"] = ""
  2395. tempTime2 := time.Unix(info.Ctime, 0)
  2396. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2397. inputData["pharChkTime"] = timeFormatTwo
  2398. bytesData, _ := json.Marshal(inputData)
  2399. fmt.Println(string(bytesData))
  2400. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2401. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2402. if err != nil {
  2403. fmt.Println("Error reading PDF file:", err)
  2404. return
  2405. }
  2406. // 将 PDF 文件内容进行 Base64 编码
  2407. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2408. fmt.Println(err)
  2409. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2410. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2411. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2412. var res2 Result002
  2413. var respJSON2 map[string]interface{}
  2414. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. return
  2418. }
  2419. userJSONBytes2, _ := json.Marshal(respJSON2)
  2420. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. if res2.Infcode == 0 {
  2426. flow.Ctime = time.Now().Unix()
  2427. flow.SignDigest = res2.Output.SignDigest
  2428. flow.RxFile = res2.Output.RxFile
  2429. flow.MID = his.Number
  2430. flow.Status = 1
  2431. flow.DCode = doctor_info.DoctorNumber
  2432. flow.OriginalRxFile = rx_encoded
  2433. flow.OriginalValue = encoded
  2434. flow.SignCertDn = res2.Output.SignCertDn
  2435. flow.SignCertSn = res2.Output.SignCertSn
  2436. flow.Mtime = time.Now().Unix()
  2437. service.Saveflow(flow)
  2438. c.ServeSuccessJSON(map[string]interface{}{
  2439. "msg": "预签名成功",
  2440. })
  2441. } else {
  2442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2443. return
  2444. }
  2445. }
  2446. func (c *HisApiController) GetCFYLJG003() {
  2447. admin_user_id, _ := c.GetInt64("admin_user_id")
  2448. his_patient_id, _ := c.GetInt64("his_patient_id")
  2449. record_time := c.GetString("record_time")
  2450. admin_user_id = 3626
  2451. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2452. //id, _ := c.GetInt64("id")
  2453. admin_user_id = 3626
  2454. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2455. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2456. flow, _ := service.Getflowtwo(his.Number)
  2457. //id = 3
  2458. patient_id, _ := c.GetInt64("patient_id")
  2459. //patient_id = 23834
  2460. //record_time = "2023-09-18"
  2461. timeLayout := "2006-01-02"
  2462. loc, _ := time.LoadLocation("Local")
  2463. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2464. if err != nil {
  2465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2466. return
  2467. }
  2468. recordDateTime := theTime.Unix()
  2469. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2470. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2471. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2472. dept, _ := service.GetDepartMentDetail(info.Departments)
  2473. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2474. var cFYLJG003 models.CFYLJG003
  2475. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2476. cFYLJG003.HiRxno = flow.HiRxno
  2477. cFYLJG003.MdtrtID = flow.MID
  2478. cFYLJG003.PatnName = his.Name
  2479. cFYLJG003.Certno = his.Certno
  2480. cFYLJG003.FixmedinsName = miConfig.OrgName
  2481. cFYLJG003.FixmedinsCode = miConfig.Code
  2482. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2483. cFYLJG003.PrscDrName = doctor_info.UserName
  2484. cFYLJG003.PharDeptName = dept.Name
  2485. cFYLJG003.PharDeptCode = dept.Number
  2486. cFYLJG003.PharCode = "HY440309002107"
  2487. cFYLJG003.PharCertType = "01"
  2488. cFYLJG003.PharCertno = "430482199408260023"
  2489. cFYLJG003.PharName = "彭斯遥"
  2490. cFYLJG003.PsnCertType = "01"
  2491. cFYLJG003.RxFile = flow.RxFile
  2492. cFYLJG003.SignDigest = flow.SignDigest
  2493. cFYLJG003.FixmedinsCode = miConfig.Code
  2494. cFYLJG003.PsnCertType = "01"
  2495. cFYLJG003.PharProfttlCodg = dept.Name
  2496. //inputData["pharProfttlCodg"] =dept.Name
  2497. tempTime2 := time.Unix(info.Ctime, 0)
  2498. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2499. cFYLJG003.PharChkTime = timeFormatTwo
  2500. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2501. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2502. var res ResultCFYLJG003
  2503. var respJSON2 map[string]interface{}
  2504. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2507. return
  2508. }
  2509. userJSONBytes2, _ := json.Marshal(respJSON2)
  2510. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2511. utils.ErrorLog("解析失败:%v", err)
  2512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2513. return
  2514. }
  2515. if res.Infcode == -1 {
  2516. c.ServeSuccessJSON(map[string]interface{}{
  2517. "failed_code": -10,
  2518. "msg": res.ErrMsg,
  2519. })
  2520. return
  2521. } else {
  2522. c.ServeSuccessJSON(map[string]interface{}{
  2523. "info": res.Output,
  2524. })
  2525. }
  2526. }
  2527. func (c *HisApiController) GetCFYLJG004() {
  2528. admin_user_id, _ := c.GetInt64("admin_user_id")
  2529. his_patient_id, _ := c.GetInt64("his_patient_id")
  2530. record_time := c.GetString("record_time")
  2531. admin_user_id = 3626
  2532. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2533. //id, _ := c.GetInt64("id")
  2534. admin_user_id = 3626
  2535. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2536. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2537. flow, _ := service.Getflowtwo(his.Number)
  2538. //id = 3
  2539. patient_id, _ := c.GetInt64("patient_id")
  2540. //patient_id = 23834
  2541. //record_time = "2023-09-18"
  2542. timeLayout := "2006-01-02"
  2543. loc, _ := time.LoadLocation("Local")
  2544. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2545. if err != nil {
  2546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2547. return
  2548. }
  2549. recordDateTime := theTime.Unix()
  2550. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2551. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2552. var cFYLJG004 models.CFYLJG004
  2553. cFYLJG004.HiRxno = flow.HiRxno
  2554. cFYLJG004.FixmedinsCode = miConfig.Code
  2555. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2556. cFYLJG004.UndoDrCertType = "01"
  2557. cFYLJG004.UndoRea = "撤销处方"
  2558. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2559. cFYLJG004.UndoDrName = doctor_info.UserName
  2560. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2561. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2562. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2563. var res ResultCFYLJG004
  2564. var respJSON2 map[string]interface{}
  2565. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2568. return
  2569. }
  2570. userJSONBytes2, _ := json.Marshal(respJSON2)
  2571. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2572. utils.ErrorLog("解析失败:%v", err)
  2573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2574. return
  2575. }
  2576. if res.Infcode == -1 {
  2577. c.ServeSuccessJSON(map[string]interface{}{
  2578. "failed_code": -10,
  2579. "msg": res.ErrMsg,
  2580. })
  2581. return
  2582. } else {
  2583. flow.Status = 0
  2584. service.Saveflow(flow)
  2585. c.ServeSuccessJSON(map[string]interface{}{
  2586. "msg": "撤销成功",
  2587. })
  2588. return
  2589. }
  2590. }
  2591. func (c *HisApiController) GetCFYLJG005() {
  2592. admin_user_id, _ := c.GetInt64("admin_user_id")
  2593. his_patient_id, _ := c.GetInt64("his_patient_id")
  2594. //record_time := c.GetString("record_time")
  2595. admin_user_id = 3626
  2596. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2597. //id, _ := c.GetInt64("id")
  2598. admin_user_id = 3626
  2599. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2600. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2601. flow, _ := service.Getflowtwo(his.Number)
  2602. //id = 3
  2603. var cFYLJG005 models.CFYLJG005
  2604. //patient_id, _ := c.GetInt64("patient_id")
  2605. cFYLJG005.HiRxno = flow.HiRxno
  2606. cFYLJG005.MdtrtID = flow.MID
  2607. cFYLJG005.EcToken = ""
  2608. cFYLJG005.PsnName = his.Name
  2609. cFYLJG005.PsnCertType = "01"
  2610. cFYLJG005.Certno = his.IdCardNo
  2611. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2612. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2613. var res ResultCFYLJG005
  2614. var respJSON2 map[string]interface{}
  2615. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2618. return
  2619. }
  2620. userJSONBytes2, _ := json.Marshal(respJSON2)
  2621. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2622. utils.ErrorLog("解析失败:%v", err)
  2623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2624. return
  2625. }
  2626. if res.Infcode == -1 {
  2627. c.ServeSuccessJSON(map[string]interface{}{
  2628. "failed_code": -10,
  2629. "msg": res.ErrMsg,
  2630. })
  2631. return
  2632. } else {
  2633. c.ServeSuccessJSON(map[string]interface{}{
  2634. "info": res.Output,
  2635. })
  2636. return
  2637. }
  2638. }
  2639. func (c *HisApiController) GetCFYLJG006() {
  2640. admin_user_id, _ := c.GetInt64("admin_user_id")
  2641. his_patient_id, _ := c.GetInt64("his_patient_id")
  2642. admin_user_id = 3626
  2643. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2644. //id, _ := c.GetInt64("id")
  2645. admin_user_id = 3626
  2646. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2648. flow, _ := service.Getflowtwo(his.Number)
  2649. //id = 3
  2650. patient_id, _ := c.GetInt64("patient_id")
  2651. var cFYLJG006 models.CFYLJG006
  2652. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2653. cFYLJG006.HiRxno = flow.HiRxno
  2654. cFYLJG006.MdtrtID = flow.MID
  2655. cFYLJG006.PsnName = patient.Name
  2656. cFYLJG006.PsnCertType = "01"
  2657. cFYLJG006.Certno = patient.IdCardNo
  2658. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2659. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2660. var res ResultCFYLJG006
  2661. var respJSON2 map[string]interface{}
  2662. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2665. return
  2666. }
  2667. userJSONBytes2, _ := json.Marshal(respJSON2)
  2668. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2669. utils.ErrorLog("解析失败:%v", err)
  2670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2671. return
  2672. }
  2673. if res.Infcode == -1 {
  2674. c.ServeSuccessJSON(map[string]interface{}{
  2675. "failed_code": -10,
  2676. "msg": res.ErrMsg,
  2677. })
  2678. return
  2679. } else {
  2680. c.ServeSuccessJSON(map[string]interface{}{
  2681. "info": res.Output,
  2682. })
  2683. return
  2684. }
  2685. }
  2686. func (c *HisApiController) GetCFYLJG007() {
  2687. admin_user_id, _ := c.GetInt64("admin_user_id")
  2688. his_patient_id, _ := c.GetInt64("his_patient_id")
  2689. admin_user_id = 3626
  2690. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2691. //id, _ := c.GetInt64("id")
  2692. admin_user_id = 3626
  2693. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2694. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2695. flow, _ := service.Getflowtwo(his.Number)
  2696. //id = 3
  2697. patient_id, _ := c.GetInt64("patient_id")
  2698. var cFYLJG007 models.CFYLJG007
  2699. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2700. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2701. cFYLJG007.HiRxno = flow.HiRxno
  2702. cFYLJG007.MdtrtID = flow.MID
  2703. cFYLJG007.PsnNo = his.PsnNo
  2704. cFYLJG007.PsnCertType = "01"
  2705. cFYLJG007.Certno = patient.IdCardNo
  2706. cFYLJG007.PsnName = patient.Name
  2707. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  2708. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  2709. var res ResultCFYLJG007
  2710. var respJSON2 map[string]interface{}
  2711. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2712. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2714. return
  2715. }
  2716. userJSONBytes2, _ := json.Marshal(respJSON2)
  2717. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2718. utils.ErrorLog("解析失败:%v", err)
  2719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2720. return
  2721. }
  2722. if res.Infcode == -1 {
  2723. c.ServeSuccessJSON(map[string]interface{}{
  2724. "failed_code": -10,
  2725. "msg": res.ErrMsg,
  2726. })
  2727. return
  2728. } else {
  2729. c.ServeSuccessJSON(map[string]interface{}{
  2730. "info": res,
  2731. })
  2732. return
  2733. }
  2734. }
  2735. func (c *HisApiController) GetCFYLJG008() {
  2736. admin_user_id, _ := c.GetInt64("admin_user_id")
  2737. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2739. var cFYLJG008 models.CFYLJG008
  2740. //id, _ := c.GetInt64("id")
  2741. patient_id, _ := c.GetInt64("patient_id")
  2742. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2743. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  2744. //id = 3
  2745. //flow, _ := service.Getflow(id)
  2746. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2747. //
  2748. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2749. //patient_id, _ := c.GetInt64("patient_id")
  2750. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2751. record_time := c.GetString("record_time")
  2752. admin_user_id = 3626
  2753. patient_id = 19424
  2754. //his_patient_id = 263947
  2755. record_time = "2023-08-29"
  2756. timeLayout := "2006-01-02"
  2757. loc, _ := time.LoadLocation("Local")
  2758. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2759. if err != nil {
  2760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2761. return
  2762. }
  2763. recordDateTime := theTime.Unix()
  2764. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2765. cFYLJG008.FixmedinsName = ""
  2766. cFYLJG008.Lat = ""
  2767. cFYLJG008.Lng = ""
  2768. cFYLJG008.OrderType = "1"
  2769. cFYLJG008.PoolareaNo = ""
  2770. cFYLJG008.Lng = ""
  2771. cFYLJG008.PageNum = 1
  2772. cFYLJG008.PageSize = 10
  2773. var MPI models.MedinsProdInvChgDDTO
  2774. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  2775. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  2776. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  2777. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  2778. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  2779. var res ResultCFYLJG008
  2780. var respJSON2 map[string]interface{}
  2781. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2782. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2784. return
  2785. }
  2786. userJSONBytes2, _ := json.Marshal(respJSON2)
  2787. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2788. utils.ErrorLog("解析失败:%v", err)
  2789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2790. return
  2791. }
  2792. if res.Infcode == -1 {
  2793. c.ServeSuccessJSON(map[string]interface{}{
  2794. "failed_code": -10,
  2795. "msg": res.ErrMsg,
  2796. })
  2797. return
  2798. } else {
  2799. c.ServeSuccessJSON(map[string]interface{}{
  2800. "info": res.Output,
  2801. })
  2802. return
  2803. }
  2804. }
  2805. func (c *HisApiController) GetBL4201A() {
  2806. order_id, _ := c.GetInt64("order_id")
  2807. admin_user_id, _ := c.GetInt64("admin_user_id")
  2808. order, _ := service.GetHisOrderByIDTwo(order_id)
  2809. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2810. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  2811. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  2812. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2814. department, _ := service.GetDepartMentDetail(his.Departments)
  2815. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  2816. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  2817. if order.ID == 0 {
  2818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2819. return
  2820. }
  2821. var struct4201A models.Struct4201A
  2822. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  2823. for _, items := range order_info {
  2824. memo := make(map[string]interface{})
  2825. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2826. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2827. fsiOPFLD.MedType = "14"
  2828. fsiOPFLD.BkkpSn = items.FeedetlSn
  2829. fsiOPFLD.FixmedinsCode = miConfig.Code
  2830. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2831. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2832. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2833. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2834. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2835. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2836. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2837. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2838. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2839. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2840. fsiOPFLD.BilgDeptName = department.Name
  2841. fsiOPFLD.BilgDeptCodg = department.Number
  2842. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2843. fsiOPFLD.BilgDrName = doctor.UserName
  2844. fsiOPFLD.MedChrgitmType = "09"
  2845. memo["hosp_appr_flag"] = "1"
  2846. memo["invoice_no"] = order.MdtrtId
  2847. memo["memo"] = "自费"
  2848. bytesData, _ := json.Marshal(memo)
  2849. fsiOPFLD.Memo = string(bytesData)
  2850. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2851. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2852. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2853. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2854. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2855. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2856. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2857. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2858. fsiOPFLD.BilgDeptName = department.Name
  2859. fsiOPFLD.BilgDeptCodg = department.Number
  2860. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2861. fsiOPFLD.BilgDrName = doctor.UserName
  2862. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2863. case 0:
  2864. break
  2865. case 1:
  2866. fsiOPFLD.MedChrgitmType = "14"
  2867. break
  2868. case 2:
  2869. fsiOPFLD.MedChrgitmType = "05"
  2870. break
  2871. case 3:
  2872. fsiOPFLD.MedChrgitmType = "03"
  2873. break
  2874. case 4:
  2875. fsiOPFLD.MedChrgitmType = "03"
  2876. break
  2877. case 5:
  2878. fsiOPFLD.MedChrgitmType = "08"
  2879. break
  2880. case 6:
  2881. fsiOPFLD.MedChrgitmType = "14"
  2882. break
  2883. case 7:
  2884. fsiOPFLD.MedChrgitmType = "14"
  2885. break
  2886. case 8:
  2887. fsiOPFLD.MedChrgitmType = "03"
  2888. break
  2889. case 9:
  2890. fsiOPFLD.MedChrgitmType = "14"
  2891. break
  2892. case 10:
  2893. fsiOPFLD.MedChrgitmType = "14"
  2894. break
  2895. case 11:
  2896. fsiOPFLD.MedChrgitmType = "06"
  2897. break
  2898. case 12:
  2899. fsiOPFLD.MedChrgitmType = "12"
  2900. break
  2901. case 13:
  2902. fsiOPFLD.MedChrgitmType = "01"
  2903. break
  2904. case 14:
  2905. fsiOPFLD.MedChrgitmType = "04"
  2906. break
  2907. case 15:
  2908. fsiOPFLD.MedChrgitmType = "14"
  2909. break
  2910. }
  2911. memo["hosp_appr_flag"] = "1"
  2912. memo["invoice_no"] = order.MdtrtId
  2913. memo["memo"] = "自费"
  2914. bytesData, _ := json.Marshal(memo)
  2915. fsiOPFLD.Memo = string(bytesData)
  2916. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2917. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  2918. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2919. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2920. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  2921. fsiOPFLD.BilgDeptName = department.Name
  2922. fsiOPFLD.BilgDeptCodg = department.Number
  2923. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2924. fsiOPFLD.BilgDrName = doctor.UserName
  2925. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  2926. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  2927. fsiOPFLD.MedChrgitmType = "08"
  2928. memo["hosp_appr_flag"] = "1"
  2929. memo["invoice_no"] = order.MdtrtId
  2930. memo["memo"] = "自费"
  2931. bytesData, _ := json.Marshal(memo)
  2932. fsiOPFLD.Memo = string(bytesData)
  2933. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2934. }
  2935. }
  2936. }
  2937. for _, items := range order_info_two {
  2938. memo := make(map[string]interface{})
  2939. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  2940. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  2941. fsiOPFLD.MedType = "14"
  2942. fsiOPFLD.BkkpSn = items.FeedetlSn
  2943. fsiOPFLD.FixmedinsCode = miConfig.Code
  2944. fsiOPFLD.FixmedinsName = miConfig.OrgName
  2945. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  2946. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  2947. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  2948. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2949. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  2950. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2951. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  2952. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2953. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  2954. fsiOPFLD.BilgDeptName = department.Name
  2955. fsiOPFLD.BilgDeptCodg = department.Number
  2956. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2957. fsiOPFLD.BilgDrName = doctor.UserName
  2958. fsiOPFLD.MedChrgitmType = "09"
  2959. memo["hosp_appr_flag"] = "1"
  2960. memo["invoice_no"] = order.MdtrtId
  2961. memo["memo"] = "自费"
  2962. bytesData, _ := json.Marshal(memo)
  2963. fsiOPFLD.Memo = string(bytesData)
  2964. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  2965. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  2966. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  2967. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  2968. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2969. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  2970. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  2971. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  2972. fsiOPFLD.BilgDeptName = department.Name
  2973. fsiOPFLD.BilgDeptCodg = department.Number
  2974. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  2975. fsiOPFLD.BilgDrName = doctor.UserName
  2976. switch items.HisPrescriptionProject.HisProject.CostClassify {
  2977. case 0:
  2978. break
  2979. case 1:
  2980. fsiOPFLD.MedChrgitmType = "14"
  2981. break
  2982. case 2:
  2983. fsiOPFLD.MedChrgitmType = "05"
  2984. break
  2985. case 3:
  2986. fsiOPFLD.MedChrgitmType = "03"
  2987. break
  2988. case 4:
  2989. fsiOPFLD.MedChrgitmType = "03"
  2990. break
  2991. case 5:
  2992. fsiOPFLD.MedChrgitmType = "08"
  2993. break
  2994. case 6:
  2995. fsiOPFLD.MedChrgitmType = "14"
  2996. break
  2997. case 7:
  2998. fsiOPFLD.MedChrgitmType = "14"
  2999. break
  3000. case 8:
  3001. fsiOPFLD.MedChrgitmType = "03"
  3002. break
  3003. case 9:
  3004. fsiOPFLD.MedChrgitmType = "14"
  3005. break
  3006. case 10:
  3007. fsiOPFLD.MedChrgitmType = "14"
  3008. break
  3009. case 11:
  3010. fsiOPFLD.MedChrgitmType = "06"
  3011. break
  3012. case 12:
  3013. fsiOPFLD.MedChrgitmType = "12"
  3014. break
  3015. case 13:
  3016. fsiOPFLD.MedChrgitmType = "01"
  3017. break
  3018. case 14:
  3019. fsiOPFLD.MedChrgitmType = "04"
  3020. break
  3021. case 15:
  3022. fsiOPFLD.MedChrgitmType = "14"
  3023. break
  3024. }
  3025. memo["hosp_appr_flag"] = "1"
  3026. memo["invoice_no"] = order.MdtrtId
  3027. memo["memo"] = "自费"
  3028. bytesData, _ := json.Marshal(memo)
  3029. fsiOPFLD.Memo = string(bytesData)
  3030. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3031. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3032. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3033. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3034. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3035. fsiOPFLD.BilgDeptName = department.Name
  3036. fsiOPFLD.BilgDeptCodg = department.Number
  3037. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3038. fsiOPFLD.BilgDrName = doctor.UserName
  3039. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3040. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3041. fsiOPFLD.MedChrgitmType = "08"
  3042. memo["hosp_appr_flag"] = "1"
  3043. memo["invoice_no"] = order.MdtrtId
  3044. memo["memo"] = "自费"
  3045. bytesData, _ := json.Marshal(memo)
  3046. fsiOPFLD.Memo = string(bytesData)
  3047. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3048. }
  3049. }
  3050. }
  3051. fmt.Println(fsiOPFLDs)
  3052. struct4201A.Fopfd = fsiOPFLDs
  3053. fmt.Println(struct4201A.Fopfd)
  3054. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3055. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3056. var res2 ResultSix
  3057. var respJSON2 map[string]interface{}
  3058. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3061. return
  3062. }
  3063. userJSONBytes2, _ := json.Marshal(respJSON2)
  3064. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3065. utils.ErrorLog("解析失败:%v", err)
  3066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3067. return
  3068. }
  3069. if res2.Infcode != 0 {
  3070. c.ServeSuccessJSON(map[string]interface{}{
  3071. "failed_code": -10,
  3072. "msg": res2.ErrMsg,
  3073. })
  3074. return
  3075. } else {
  3076. order.IsUploadOrderInfo = 1
  3077. service.UpdateOrder(order)
  3078. c.ServeSuccessJSON(map[string]interface{}{
  3079. "msg": "上传成功",
  3080. })
  3081. }
  3082. }
  3083. func (c *HisApiController) Get2505() {
  3084. admin_user_id, _ := c.GetInt64("admin_user_id")
  3085. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3086. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3087. 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)
  3088. }
  3089. func (c *HisApiController) Get4201A() {
  3090. order_id, _ := c.GetInt64("order_id")
  3091. admin_user_id, _ := c.GetInt64("admin_user_id")
  3092. order, _ := service.GetHisOrderByIDTwo(order_id)
  3093. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3094. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3095. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3096. //order_info = append(order_info, order_info_two...)
  3097. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3098. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3099. department, _ := service.GetDepartMentDetail(his.Departments)
  3100. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3101. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3102. if order.ID == 0 {
  3103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3104. return
  3105. }
  3106. var struct4201A models.Struct4201A
  3107. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3108. for _, items := range order_info {
  3109. memo := make(map[string]interface{})
  3110. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3111. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3112. fsiOPFLD.MedType = "14"
  3113. fsiOPFLD.BkkpSn = items.FeedetlSn
  3114. fsiOPFLD.FixmedinsCode = miConfig.Code
  3115. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3116. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3117. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3118. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3119. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3120. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3121. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3122. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3123. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3124. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3125. fsiOPFLD.BilgDeptName = department.Name
  3126. fsiOPFLD.BilgDeptCodg = department.Number
  3127. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3128. fsiOPFLD.BilgDrName = doctor.UserName
  3129. fsiOPFLD.MedChrgitmType = "09"
  3130. memo["hosp_appr_flag"] = "1"
  3131. memo["invoice_no"] = order.MdtrtId
  3132. memo["memo"] = "自费"
  3133. bytesData, _ := json.Marshal(memo)
  3134. fsiOPFLD.Memo = string(bytesData)
  3135. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3136. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3137. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3138. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3139. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3140. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3141. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3142. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3143. fsiOPFLD.BilgDeptName = department.Name
  3144. fsiOPFLD.BilgDeptCodg = department.Number
  3145. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3146. fsiOPFLD.BilgDrName = doctor.UserName
  3147. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3148. case 0:
  3149. break
  3150. case 1:
  3151. fsiOPFLD.MedChrgitmType = "14"
  3152. break
  3153. case 2:
  3154. fsiOPFLD.MedChrgitmType = "05"
  3155. break
  3156. case 3:
  3157. fsiOPFLD.MedChrgitmType = "03"
  3158. break
  3159. case 4:
  3160. fsiOPFLD.MedChrgitmType = "03"
  3161. break
  3162. case 5:
  3163. fsiOPFLD.MedChrgitmType = "08"
  3164. break
  3165. case 6:
  3166. fsiOPFLD.MedChrgitmType = "14"
  3167. break
  3168. case 7:
  3169. fsiOPFLD.MedChrgitmType = "14"
  3170. break
  3171. case 8:
  3172. fsiOPFLD.MedChrgitmType = "03"
  3173. break
  3174. case 9:
  3175. fsiOPFLD.MedChrgitmType = "14"
  3176. break
  3177. case 10:
  3178. fsiOPFLD.MedChrgitmType = "14"
  3179. break
  3180. case 11:
  3181. fsiOPFLD.MedChrgitmType = "06"
  3182. break
  3183. case 12:
  3184. fsiOPFLD.MedChrgitmType = "12"
  3185. break
  3186. case 13:
  3187. fsiOPFLD.MedChrgitmType = "01"
  3188. break
  3189. case 14:
  3190. fsiOPFLD.MedChrgitmType = "04"
  3191. break
  3192. case 15:
  3193. fsiOPFLD.MedChrgitmType = "14"
  3194. break
  3195. }
  3196. memo["hosp_appr_flag"] = "1"
  3197. memo["invoice_no"] = order.MdtrtId
  3198. memo["memo"] = "自费"
  3199. bytesData, _ := json.Marshal(memo)
  3200. fsiOPFLD.Memo = string(bytesData)
  3201. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3202. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3203. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3204. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3205. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3206. fsiOPFLD.BilgDeptName = department.Name
  3207. fsiOPFLD.BilgDeptCodg = department.Number
  3208. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3209. fsiOPFLD.BilgDrName = doctor.UserName
  3210. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3211. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3212. fsiOPFLD.MedChrgitmType = "08"
  3213. memo["hosp_appr_flag"] = "1"
  3214. memo["invoice_no"] = order.MdtrtId
  3215. memo["memo"] = "自费"
  3216. bytesData, _ := json.Marshal(memo)
  3217. fsiOPFLD.Memo = string(bytesData)
  3218. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3219. }
  3220. }
  3221. }
  3222. for _, items := range order_info_two {
  3223. memo := make(map[string]interface{})
  3224. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3225. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3226. fsiOPFLD.MedType = "14"
  3227. fsiOPFLD.BkkpSn = items.FeedetlSn
  3228. fsiOPFLD.FixmedinsCode = miConfig.Code
  3229. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3230. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3231. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3232. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3233. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3234. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3235. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3236. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3237. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3238. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3239. fsiOPFLD.BilgDeptName = department.Name
  3240. fsiOPFLD.BilgDeptCodg = department.Number
  3241. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3242. fsiOPFLD.BilgDrName = doctor.UserName
  3243. fsiOPFLD.MedChrgitmType = "09"
  3244. memo["hosp_appr_flag"] = "1"
  3245. memo["invoice_no"] = order.MdtrtId
  3246. memo["memo"] = "自费"
  3247. bytesData, _ := json.Marshal(memo)
  3248. fsiOPFLD.Memo = string(bytesData)
  3249. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3250. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3251. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3252. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3253. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3254. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3255. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3256. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3257. fsiOPFLD.BilgDeptName = department.Name
  3258. fsiOPFLD.BilgDeptCodg = department.Number
  3259. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3260. fsiOPFLD.BilgDrName = doctor.UserName
  3261. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3262. case 0:
  3263. break
  3264. case 1:
  3265. fsiOPFLD.MedChrgitmType = "14"
  3266. break
  3267. case 2:
  3268. fsiOPFLD.MedChrgitmType = "05"
  3269. break
  3270. case 3:
  3271. fsiOPFLD.MedChrgitmType = "03"
  3272. break
  3273. case 4:
  3274. fsiOPFLD.MedChrgitmType = "03"
  3275. break
  3276. case 5:
  3277. fsiOPFLD.MedChrgitmType = "08"
  3278. break
  3279. case 6:
  3280. fsiOPFLD.MedChrgitmType = "14"
  3281. break
  3282. case 7:
  3283. fsiOPFLD.MedChrgitmType = "14"
  3284. break
  3285. case 8:
  3286. fsiOPFLD.MedChrgitmType = "03"
  3287. break
  3288. case 9:
  3289. fsiOPFLD.MedChrgitmType = "14"
  3290. break
  3291. case 10:
  3292. fsiOPFLD.MedChrgitmType = "14"
  3293. break
  3294. case 11:
  3295. fsiOPFLD.MedChrgitmType = "06"
  3296. break
  3297. case 12:
  3298. fsiOPFLD.MedChrgitmType = "12"
  3299. break
  3300. case 13:
  3301. fsiOPFLD.MedChrgitmType = "01"
  3302. break
  3303. case 14:
  3304. fsiOPFLD.MedChrgitmType = "04"
  3305. break
  3306. case 15:
  3307. fsiOPFLD.MedChrgitmType = "14"
  3308. break
  3309. }
  3310. memo["hosp_appr_flag"] = "1"
  3311. memo["invoice_no"] = order.MdtrtId
  3312. memo["memo"] = "自费"
  3313. bytesData, _ := json.Marshal(memo)
  3314. fsiOPFLD.Memo = string(bytesData)
  3315. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3316. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3317. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3318. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3319. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3320. fsiOPFLD.BilgDeptName = department.Name
  3321. fsiOPFLD.BilgDeptCodg = department.Number
  3322. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3323. fsiOPFLD.BilgDrName = doctor.UserName
  3324. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3325. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3326. fsiOPFLD.MedChrgitmType = "08"
  3327. memo["hosp_appr_flag"] = "1"
  3328. memo["invoice_no"] = order.MdtrtId
  3329. memo["memo"] = "自费"
  3330. bytesData, _ := json.Marshal(memo)
  3331. fsiOPFLD.Memo = string(bytesData)
  3332. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3333. }
  3334. }
  3335. }
  3336. fmt.Println(fsiOPFLDs)
  3337. struct4201A.Fopfd = fsiOPFLDs
  3338. fmt.Println(struct4201A.Fopfd)
  3339. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3340. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3341. var res2 ResultSix
  3342. var respJSON2 map[string]interface{}
  3343. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3346. return
  3347. }
  3348. userJSONBytes2, _ := json.Marshal(respJSON2)
  3349. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3350. utils.ErrorLog("解析失败:%v", err)
  3351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3352. return
  3353. }
  3354. if res2.Infcode != 0 {
  3355. c.ServeSuccessJSON(map[string]interface{}{
  3356. "failed_code": -10,
  3357. "msg": res2.ErrMsg,
  3358. })
  3359. return
  3360. } else {
  3361. order.IsUploadOrderInfo = 1
  3362. service.UpdateOrder(order)
  3363. c.ServeSuccessJSON(map[string]interface{}{
  3364. "msg": "上传成功",
  3365. })
  3366. }
  3367. }
  3368. func (c *HisApiController) Get4202() {
  3369. order_id, _ := c.GetInt64("order_id")
  3370. admin_user_id, _ := c.GetInt64("admin_user_id")
  3371. order, _ := service.GetHisOrderByIDTwo(order_id)
  3372. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3373. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3374. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3375. if order.ID == 0 {
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3377. return
  3378. }
  3379. var struct4202 models.Struct4202
  3380. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3381. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3382. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3383. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3384. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3385. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3386. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3387. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3388. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3389. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3390. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3391. var config []*models.HisXtDiagnoseConfig
  3392. for _, item := range diagnosis_ids {
  3393. id, _ := strconv.ParseInt(item, 10, 64)
  3394. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3395. config = append(config, &diagnosisConfig)
  3396. }
  3397. var tempDiaginfos []models.OwnPayPatnDiagListD
  3398. for index, item := range config {
  3399. if index == 0 {
  3400. var tempDiaginfo models.OwnPayPatnDiagListD
  3401. tempDiaginfo.InoutDiagType = "1"
  3402. tempDiaginfo.DiagCode = item.CountryCode
  3403. tempDiaginfo.DiagName = item.CountryContentName
  3404. tempDiaginfo.DiagType = "1"
  3405. tempDiaginfo.DiagSrtNo = "1"
  3406. tempDiaginfo.MaindiagFlag = "1"
  3407. tempDiaginfo.ValiFlag = "1"
  3408. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3409. } else {
  3410. var tempDiaginfo models.OwnPayPatnDiagListD
  3411. tempDiaginfo.DiagCode = item.CountryCode
  3412. tempDiaginfo.DiagName = item.CountryContentName
  3413. tempDiaginfo.DiagType = "2"
  3414. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3415. tempDiaginfo.MaindiagFlag = "0"
  3416. tempDiaginfo.ValiFlag = "1"
  3417. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3418. }
  3419. }
  3420. struct4202.ODiagListD = tempDiaginfos
  3421. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3422. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3423. var res2 ResultSix
  3424. var respJSON2 map[string]interface{}
  3425. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3426. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3428. return
  3429. }
  3430. userJSONBytes2, _ := json.Marshal(respJSON2)
  3431. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3432. utils.ErrorLog("解析失败:%v", err)
  3433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3434. return
  3435. }
  3436. if res2.Infcode != 0 {
  3437. c.ServeSuccessJSON(map[string]interface{}{
  3438. "failed_code": -10,
  3439. "msg": res2.ErrMsg,
  3440. })
  3441. return
  3442. } else {
  3443. order.IsUploadDiagnose = 1
  3444. service.UpdateOrder(order)
  3445. c.ServeSuccessJSON(map[string]interface{}{
  3446. "msg": "上传成功",
  3447. })
  3448. }
  3449. }
  3450. func (c *HisApiController) Get4203() {
  3451. admin_user_id, _ := c.GetInt64("admin_user_id")
  3452. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3453. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3454. order_id, _ := c.GetInt64("order_id")
  3455. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3456. number := ""
  3457. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3458. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3459. if his.ID == 0 {
  3460. number = hospital.Number
  3461. } else {
  3462. number = his.Number
  3463. }
  3464. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3465. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3466. var res2 ResultSix
  3467. var respJSON2 map[string]interface{}
  3468. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3471. return
  3472. }
  3473. userJSONBytes2, _ := json.Marshal(respJSON2)
  3474. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3475. utils.ErrorLog("解析失败:%v", err)
  3476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3477. return
  3478. }
  3479. if res2.Infcode != 0 {
  3480. c.ServeSuccessJSON(map[string]interface{}{
  3481. "failed_code": -10,
  3482. "msg": res2.ErrMsg,
  3483. })
  3484. return
  3485. } else {
  3486. order.IsUploadSuccess = 1
  3487. service.UpdateOrderTwo(order)
  3488. c.ServeSuccessJSON(map[string]interface{}{
  3489. "msg": "上传成功",
  3490. })
  3491. }
  3492. }
  3493. func (c *HisApiController) Get4205() {
  3494. order_id, _ := c.GetInt64("order_id")
  3495. admin_user_id, _ := c.GetInt64("admin_user_id")
  3496. fapiao_code := c.GetString("fapiao_code")
  3497. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3498. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3499. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3500. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3501. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3502. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3503. //order_info = append(order_info, order_info_two...)
  3504. department, _ := service.GetDepartMentDetail(his.Departments)
  3505. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3506. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3507. if order.ID == 0 {
  3508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3509. return
  3510. }
  3511. var struct4201A models.Struct4201A
  3512. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3513. for _, items := range order_info {
  3514. memo := make(map[string]interface{})
  3515. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3516. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3517. fsiOPFLD.MedType = pre.MedType
  3518. fsiOPFLD.FixmedinsCode = miConfig.Code
  3519. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3520. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3521. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3522. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3523. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3524. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3525. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3526. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3527. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3528. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3529. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3530. fsiOPFLD.BilgDeptName = department.Name
  3531. fsiOPFLD.BilgDeptCodg = department.Number
  3532. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3533. fsiOPFLD.BilgDrName = doctor.UserName
  3534. fsiOPFLD.MedChrgitmType = "09"
  3535. memo["hosp_appr_flag"] = "1"
  3536. memo["invoice_no"] = fapiao_code
  3537. memo["memo"] = "自费"
  3538. bytesData, _ := json.Marshal(memo)
  3539. fsiOPFLD.Memo = string(bytesData)
  3540. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3541. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3542. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3543. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3544. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3545. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3546. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3547. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3548. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3549. fsiOPFLD.BilgDeptName = department.Name
  3550. fsiOPFLD.BilgDeptCodg = department.Number
  3551. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3552. fsiOPFLD.BilgDrName = doctor.UserName
  3553. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3554. case 0:
  3555. break
  3556. case 1:
  3557. fsiOPFLD.MedChrgitmType = "14"
  3558. break
  3559. case 2:
  3560. fsiOPFLD.MedChrgitmType = "05"
  3561. break
  3562. case 3:
  3563. fsiOPFLD.MedChrgitmType = "03"
  3564. break
  3565. case 4:
  3566. fsiOPFLD.MedChrgitmType = "03"
  3567. break
  3568. case 5:
  3569. fsiOPFLD.MedChrgitmType = "08"
  3570. break
  3571. case 6:
  3572. fsiOPFLD.MedChrgitmType = "14"
  3573. break
  3574. case 7:
  3575. fsiOPFLD.MedChrgitmType = "14"
  3576. break
  3577. case 8:
  3578. fsiOPFLD.MedChrgitmType = "03"
  3579. break
  3580. case 9:
  3581. fsiOPFLD.MedChrgitmType = "14"
  3582. break
  3583. case 10:
  3584. fsiOPFLD.MedChrgitmType = "14"
  3585. break
  3586. case 11:
  3587. fsiOPFLD.MedChrgitmType = "06"
  3588. break
  3589. case 12:
  3590. fsiOPFLD.MedChrgitmType = "12"
  3591. break
  3592. case 13:
  3593. fsiOPFLD.MedChrgitmType = "01"
  3594. break
  3595. case 14:
  3596. fsiOPFLD.MedChrgitmType = "04"
  3597. break
  3598. case 15:
  3599. fsiOPFLD.MedChrgitmType = "14"
  3600. break
  3601. }
  3602. memo["hosp_appr_flag"] = "1"
  3603. memo["invoice_no"] = fapiao_code
  3604. memo["memo"] = "自费"
  3605. bytesData, _ := json.Marshal(memo)
  3606. fsiOPFLD.Memo = string(bytesData)
  3607. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3608. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3609. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3610. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3611. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3612. fsiOPFLD.BilgDeptName = department.Name
  3613. fsiOPFLD.BilgDeptCodg = department.Number
  3614. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3615. fsiOPFLD.BilgDrName = doctor.UserName
  3616. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3617. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3618. fsiOPFLD.MedChrgitmType = "08"
  3619. memo["hosp_appr_flag"] = "1"
  3620. memo["invoice_no"] = fapiao_code
  3621. memo["memo"] = "自费"
  3622. bytesData, _ := json.Marshal(memo)
  3623. fsiOPFLD.Memo = string(bytesData)
  3624. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3625. }
  3626. }
  3627. }
  3628. for _, items := range order_info_two {
  3629. memo := make(map[string]interface{})
  3630. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3631. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3632. fsiOPFLD.MedType = pre.MedType
  3633. fsiOPFLD.BkkpSn = items.FeedetlSn
  3634. fsiOPFLD.FixmedinsCode = miConfig.Code
  3635. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3636. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3637. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3638. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3639. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3640. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3641. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3642. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3643. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3644. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3645. fsiOPFLD.BilgDeptName = department.Name
  3646. fsiOPFLD.BilgDeptCodg = department.Number
  3647. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3648. fsiOPFLD.BilgDrName = doctor.UserName
  3649. fsiOPFLD.MedChrgitmType = "09"
  3650. memo["hosp_appr_flag"] = "1"
  3651. memo["invoice_no"] = fapiao_code
  3652. memo["memo"] = "自费"
  3653. bytesData, _ := json.Marshal(memo)
  3654. fsiOPFLD.Memo = string(bytesData)
  3655. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3656. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3657. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3658. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3659. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3660. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3661. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3662. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3663. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3664. fsiOPFLD.BilgDeptName = department.Name
  3665. fsiOPFLD.BilgDeptCodg = department.Number
  3666. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3667. fsiOPFLD.BilgDrName = doctor.UserName
  3668. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3669. case 0:
  3670. break
  3671. case 1:
  3672. fsiOPFLD.MedChrgitmType = "14"
  3673. break
  3674. case 2:
  3675. fsiOPFLD.MedChrgitmType = "05"
  3676. break
  3677. case 3:
  3678. fsiOPFLD.MedChrgitmType = "03"
  3679. break
  3680. case 4:
  3681. fsiOPFLD.MedChrgitmType = "03"
  3682. break
  3683. case 5:
  3684. fsiOPFLD.MedChrgitmType = "08"
  3685. break
  3686. case 6:
  3687. fsiOPFLD.MedChrgitmType = "14"
  3688. break
  3689. case 7:
  3690. fsiOPFLD.MedChrgitmType = "14"
  3691. break
  3692. case 8:
  3693. fsiOPFLD.MedChrgitmType = "03"
  3694. break
  3695. case 9:
  3696. fsiOPFLD.MedChrgitmType = "14"
  3697. break
  3698. case 10:
  3699. fsiOPFLD.MedChrgitmType = "14"
  3700. break
  3701. case 11:
  3702. fsiOPFLD.MedChrgitmType = "06"
  3703. break
  3704. case 12:
  3705. fsiOPFLD.MedChrgitmType = "12"
  3706. break
  3707. case 13:
  3708. fsiOPFLD.MedChrgitmType = "01"
  3709. break
  3710. case 14:
  3711. fsiOPFLD.MedChrgitmType = "04"
  3712. break
  3713. case 15:
  3714. fsiOPFLD.MedChrgitmType = "14"
  3715. break
  3716. }
  3717. memo["hosp_appr_flag"] = "1"
  3718. memo["invoice_no"] = fapiao_code
  3719. memo["memo"] = "自费"
  3720. bytesData, _ := json.Marshal(memo)
  3721. fsiOPFLD.Memo = string(bytesData)
  3722. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3723. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3724. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3725. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3726. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3727. fsiOPFLD.BilgDeptName = department.Name
  3728. fsiOPFLD.BilgDeptCodg = department.Number
  3729. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3730. fsiOPFLD.BilgDrName = doctor.UserName
  3731. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3732. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3733. fsiOPFLD.MedChrgitmType = "08"
  3734. memo["hosp_appr_flag"] = "1"
  3735. memo["invoice_no"] = fapiao_code
  3736. memo["memo"] = "自费"
  3737. bytesData, _ := json.Marshal(memo)
  3738. fsiOPFLD.Memo = string(bytesData)
  3739. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3740. }
  3741. }
  3742. }
  3743. fmt.Println(fsiOPFLDs)
  3744. struct4201A.Fopfd = fsiOPFLDs
  3745. fmt.Println(struct4201A.Fopfd)
  3746. var struct4202 models.Struct4202
  3747. timeLayout := "2006-01-02 15:04:05"
  3748. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  3749. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3750. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3751. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3752. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3753. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3754. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3755. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  3756. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  3757. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3758. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3759. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3760. var config []*models.HisXtDiagnoseConfig
  3761. for _, item := range diagnosis_ids {
  3762. id, _ := strconv.ParseInt(item, 10, 64)
  3763. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3764. config = append(config, &diagnosisConfig)
  3765. }
  3766. var tempDiaginfos []models.OwnPayPatnDiagListD
  3767. for index, item := range config {
  3768. if index == 0 {
  3769. var tempDiaginfo models.OwnPayPatnDiagListD
  3770. tempDiaginfo.InoutDiagType = "1"
  3771. tempDiaginfo.DiagCode = item.CountryCode
  3772. tempDiaginfo.DiagName = item.CountryContentName
  3773. tempDiaginfo.DiagType = "1"
  3774. tempDiaginfo.DiagSrtNo = "1"
  3775. tempDiaginfo.MaindiagFlag = "1"
  3776. tempDiaginfo.ValiFlag = "1"
  3777. tempDiaginfo.DiagDrName = doctor.UserName
  3778. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3779. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3780. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3781. } else {
  3782. var tempDiaginfo models.OwnPayPatnDiagListD
  3783. tempDiaginfo.DiagCode = item.CountryCode
  3784. tempDiaginfo.DiagName = item.CountryContentName
  3785. tempDiaginfo.DiagType = "2"
  3786. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3787. tempDiaginfo.MaindiagFlag = "0"
  3788. tempDiaginfo.ValiFlag = "1"
  3789. tempDiaginfo.DiagDrName = doctor.UserName
  3790. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  3791. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  3792. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3793. }
  3794. }
  3795. struct4202.ODiagListD = tempDiaginfos
  3796. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  3797. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  3798. var res2 ResultSix
  3799. var respJSON2 map[string]interface{}
  3800. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3803. return
  3804. }
  3805. userJSONBytes2, _ := json.Marshal(respJSON2)
  3806. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3807. utils.ErrorLog("解析失败:%v", err)
  3808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3809. return
  3810. }
  3811. if res2.Infcode != 0 {
  3812. c.ServeSuccessJSON(map[string]interface{}{
  3813. "failed_code": -10,
  3814. "msg": res2.ErrMsg,
  3815. })
  3816. return
  3817. } else {
  3818. order.IsUploadDiagnose = 1
  3819. order.IsUploadOrderInfo = 1
  3820. service.UpdateOrderTwo(order)
  3821. c.ServeSuccessJSON(map[string]interface{}{
  3822. "msg": "上传成功",
  3823. })
  3824. }
  3825. }
  3826. func (c *HisApiController) Get4207() {
  3827. admin_user_id, _ := c.GetInt64("admin_user_id")
  3828. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3829. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3830. order_id, _ := c.GetInt64("order_id")
  3831. order, _ := service.GetHisOrderByIDTwo(order_id)
  3832. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3833. var struct4207 models.Struct4207
  3834. struct4207.PageNum = "1"
  3835. struct4207.PageSize = "1000"
  3836. struct4207.FixmedinsCode = miConfig.Code
  3837. struct4207.FixmedinsMdtrtID = order.Number
  3838. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  3839. saveLog(result, requestLog, "4207", "查询")
  3840. var res2 ResultSix
  3841. var respJSON2 map[string]interface{}
  3842. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3843. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3845. return
  3846. }
  3847. userJSONBytes2, _ := json.Marshal(respJSON2)
  3848. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3849. utils.ErrorLog("解析失败:%v", err)
  3850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3851. return
  3852. }
  3853. if res2.Infcode != 0 {
  3854. c.ServeSuccessJSON(map[string]interface{}{
  3855. "failed_code": -10,
  3856. "msg": res2.ErrMsg,
  3857. })
  3858. return
  3859. } else {
  3860. c.ServeSuccessJSON(map[string]interface{}{
  3861. "msg": "查询成功",
  3862. })
  3863. }
  3864. }
  3865. func (c *HisApiController) Get4208() {
  3866. admin_user_id, _ := c.GetInt64("admin_user_id")
  3867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3868. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3869. order_id, _ := c.GetInt64("order_id")
  3870. order, _ := service.GetHisOrderByIDTwo(order_id)
  3871. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3872. var struct4208 models.Struct4208
  3873. struct4208.PageNum = "1"
  3874. struct4208.PageSize = "1000"
  3875. struct4208.PsnCertType = "01"
  3876. struct4208.Certno = his.Certno
  3877. struct4208.MedType = order.MedType
  3878. struct4208.PsnName = his.Name
  3879. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  3880. saveLog(result, requestLog, "4208", "查询")
  3881. var res2 ResultSix
  3882. var respJSON2 map[string]interface{}
  3883. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3884. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. userJSONBytes2, _ := json.Marshal(respJSON2)
  3889. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3890. utils.ErrorLog("解析失败:%v", err)
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3892. return
  3893. }
  3894. if res2.Infcode != 0 {
  3895. c.ServeSuccessJSON(map[string]interface{}{
  3896. "failed_code": -10,
  3897. "msg": res2.ErrMsg,
  3898. })
  3899. return
  3900. } else {
  3901. c.ServeSuccessJSON(map[string]interface{}{
  3902. "msg": "查询成功",
  3903. })
  3904. }
  3905. }
  3906. func (c *HisApiController) Get4209() {
  3907. admin_user_id, _ := c.GetInt64("admin_user_id")
  3908. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3910. order_id, _ := c.GetInt64("order_id")
  3911. order, _ := service.GetHisOrderByIDTwo(order_id)
  3912. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3913. var struct4209 models.Struct4209
  3914. struct4209.FixmedinsMdtrtID = order.Number
  3915. struct4209.FixmedinsCode = miConfig.Code
  3916. struct4209.PageSize = "1000"
  3917. struct4209.PageNum = "1"
  3918. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  3919. saveLog(result, requestLog, "4209", "查询")
  3920. var res2 ResultSix
  3921. var respJSON2 map[string]interface{}
  3922. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. userJSONBytes2, _ := json.Marshal(respJSON2)
  3928. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3929. utils.ErrorLog("解析失败:%v", err)
  3930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3931. return
  3932. }
  3933. if res2.Infcode != 0 {
  3934. c.ServeSuccessJSON(map[string]interface{}{
  3935. "failed_code": -10,
  3936. "msg": res2.ErrMsg,
  3937. })
  3938. return
  3939. } else {
  3940. c.ServeSuccessJSON(map[string]interface{}{
  3941. "msg": "查询成功",
  3942. })
  3943. }
  3944. }
  3945. type Result3101 struct {
  3946. Infcode string `json:"infcode"`
  3947. InfRefmsgid string `json:"inf_refmsgid"`
  3948. RefmsgTime string `json:"refmsg_time"`
  3949. RespondTime string `json:"respond_time"`
  3950. Enctype string `json:"enctype"`
  3951. Signtype string `json:"signtype"`
  3952. ErrMsg string `json:"err_msg"`
  3953. Output struct {
  3954. Result []struct {
  3955. JudgeResultDetailDtos []struct {
  3956. VolaItemType string `json:"vola_item_type"`
  3957. MdtrtID string `json:"mdtrt_id"`
  3958. JrdID string `json:"jrd_id"`
  3959. PatnID string `json:"patn_id"`
  3960. RxID string `json:"rx_id"`
  3961. VolaAmt interface{} `json:"vola_amt"`
  3962. } `json:"judge_result_detail_dtos"`
  3963. RuleID string `json:"rule_id"`
  3964. VolaEvid string `json:"vola_evid"`
  3965. MdtrtID string `json:"mdtrt_id"`
  3966. RuleName string `json:"rule_name"`
  3967. VolaAmtStas string `json:"vola_amt_stas"`
  3968. JrID string `json:"jr_id"`
  3969. PatnID string `json:"patn_id"`
  3970. SevDeg string `json:"sev_deg"`
  3971. VolaAmt float64 `json:"vola_amt"`
  3972. VolaBhvrType string `json:"vola_bhvr_type"`
  3973. VolaCont string `json:"vola_cont"`
  3974. } `json:"result"`
  3975. } `json:"output"`
  3976. }
  3977. type Resultgd3101 struct {
  3978. Infcode int64 `json:"infcode"`
  3979. InfRefmsgid string `json:"inf_refmsgid"`
  3980. RefmsgTime string `json:"refmsg_time"`
  3981. RespondTime string `json:"respond_time"`
  3982. Enctype string `json:"enctype"`
  3983. Signtype string `json:"signtype"`
  3984. ErrMsg string `json:"err_msg"`
  3985. Output struct {
  3986. Result []struct {
  3987. JudgeResultDetailDtos []struct {
  3988. VolaItemType string `json:"vola_item_type"`
  3989. MdtrtID string `json:"mdtrt_id"`
  3990. JrdID string `json:"jrd_id"`
  3991. PatnID string `json:"patn_id"`
  3992. RxID string `json:"rx_id"`
  3993. VolaAmt interface{} `json:"vola_amt"`
  3994. } `json:"judge_result_detail_dtos"`
  3995. RuleID string `json:"rule_id"`
  3996. VolaEvid string `json:"vola_evid"`
  3997. MdtrtID string `json:"mdtrt_id"`
  3998. RuleName string `json:"rule_name"`
  3999. VolaAmtStas string `json:"vola_amt_stas"`
  4000. JrID string `json:"jr_id"`
  4001. PatnID string `json:"patn_id"`
  4002. SevDeg string `json:"sev_deg"`
  4003. VolaAmt float64 `json:"vola_amt"`
  4004. VolaBhvrType string `json:"vola_bhvr_type"`
  4005. VolaCont string `json:"vola_cont"`
  4006. } `json:"result"`
  4007. } `json:"output"`
  4008. }
  4009. func (c *HisApiController) ReadEleToken() {
  4010. admin_user_id, _ := c.GetInt64("admin_user_id")
  4011. his_patient_id, _ := c.GetInt64("his_patient_id")
  4012. adminUser := c.GetAdminUserInfo()
  4013. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4014. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4015. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4016. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4017. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4018. if len(tokens) > 0 {
  4019. c.ServeSuccessJSON(map[string]interface{}{
  4020. "msg": "读取成功",
  4021. })
  4022. } else {
  4023. c.ServeSuccessJSON(map[string]interface{}{
  4024. "failed_code": -10,
  4025. "msg": "读取失败",
  4026. })
  4027. }
  4028. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4029. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4030. if len(tokens) > 0 {
  4031. c.ServeSuccessJSON(map[string]interface{}{
  4032. "msg": "读取成功",
  4033. })
  4034. } else {
  4035. c.ServeSuccessJSON(map[string]interface{}{
  4036. "failed_code": -10,
  4037. "msg": "读取失败",
  4038. })
  4039. }
  4040. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4041. var api string
  4042. 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 +
  4043. "&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"
  4044. resp, requestErr := http.Get(api)
  4045. if requestErr != nil {
  4046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4047. }
  4048. body, ioErr := ioutil.ReadAll(resp.Body)
  4049. if ioErr != nil {
  4050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4052. }
  4053. var respJSON map[string]interface{}
  4054. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4057. return
  4058. }
  4059. var status string
  4060. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4061. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4062. var token string
  4063. var res ResultTwo //1101结果
  4064. var res10265 ResultTwo10265 //1101结果
  4065. if status == "0" { //读卡成功
  4066. var card_info string //卡信息
  4067. var busi_card_info string
  4068. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4069. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4070. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4071. fmt.Println(card_info)
  4072. fmt.Println(busi_card_info)
  4073. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4074. result, _ := json.Marshal(respJSON)
  4075. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4076. utils.ErrorLog("解析失败:%v", err)
  4077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4078. return
  4079. }
  4080. res.ErrMsg = res10265.ErrMsg
  4081. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4082. res.Infcode = infocode
  4083. res.Output = res10265.Output
  4084. res.InfRefmsgid = res10265.InfRefmsgid
  4085. if res.Infcode == 0 {
  4086. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4087. if err == gorm.ErrRecordNotFound {
  4088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4089. return
  4090. } else if err != nil {
  4091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4092. return
  4093. } else {
  4094. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4095. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4096. infoStr := string(Iinfos)
  4097. idetinfoStr := string(Idetinfos)
  4098. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4099. b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4100. psn := &models.HisPsn{
  4101. PsnNo: res.Output.Baseinfo.PsnNo,
  4102. PatientId: patient.ID,
  4103. Certno: res.Output.Baseinfo.Certno,
  4104. Gend: res.Output.Baseinfo.Gend,
  4105. Naty: res.Output.Baseinfo.Naty,
  4106. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4107. PsnName: res.Output.Baseinfo.PsnName,
  4108. Age:float64(age),
  4109. Brdy:b,
  4110. Idetinfo: idetinfoStr,
  4111. Insuinfo: infoStr,
  4112. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4113. CardInfo: card_info,
  4114. VerifyNumber: token,
  4115. IdCardType: 4,
  4116. }
  4117. var rf []*ResultFive
  4118. json.Unmarshal([]byte(infoStr), &rf)
  4119. var insutypes []*ResultFive
  4120. var insutype string
  4121. var is390 int = 0
  4122. var is310 int = 0
  4123. for _, item := range rf {
  4124. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4125. insutypes = append(insutypes, item)
  4126. }
  4127. }
  4128. if len(insutypes) == 1 {
  4129. insutype = insutypes[0].Insutype
  4130. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4131. } else {
  4132. for _, i := range insutypes {
  4133. if i.Insutype == "390" {
  4134. is390 = 1
  4135. }
  4136. if i.Insutype == "310" {
  4137. is310 = 1
  4138. }
  4139. }
  4140. }
  4141. if is390 == 1 {
  4142. insutype = "390"
  4143. }
  4144. if is310 == 1 {
  4145. insutype = "310"
  4146. }
  4147. if len(insutypes) == 0 {
  4148. insutype = "310"
  4149. }
  4150. service.CreateHisPsn(psn)
  4151. c.ServeSuccessJSON(map[string]interface{}{
  4152. "patient": patient,
  4153. "number": token,
  4154. "insutype": insutype,
  4155. })
  4156. }
  4157. } else {
  4158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4159. return
  4160. }
  4161. } else { //读卡失败
  4162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4163. return
  4164. }
  4165. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4166. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4167. if len(errMsg) == 0 {
  4168. type ELeData struct {
  4169. Data struct {
  4170. IdNo string `json:"idNo"`
  4171. IdType string `json:"idType"`
  4172. UserName string `json:"userName"`
  4173. EcToken string `json:"ecToken"`
  4174. InsuOrg string `json:"insuOrg"`
  4175. Gender string `json:"gender"`
  4176. Birthday string `json:"birthday"`
  4177. Nationality string `json:"nationality"`
  4178. Email string `json:"email"`
  4179. Extra string `json:"extra"`
  4180. } `json:"data"`
  4181. Code int `json:"code"`
  4182. Message string `json:"message"`
  4183. }
  4184. var ele ELeData
  4185. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4186. if err != nil {
  4187. utils.ErrorLog("解析失败:%v", err)
  4188. }
  4189. token := ele.Data.EcToken
  4190. if len(token) > 0 {
  4191. psn := &models.HisPsn{
  4192. PsnNo: his.PsnNo,
  4193. Age: 0,
  4194. PatientId: his.PatientId,
  4195. Certno: his.Certno,
  4196. Brdy: his.Brdy,
  4197. Gend: his.Gend,
  4198. Naty: his.Naty,
  4199. PsnCertType: his.PsnCertType,
  4200. PsnName: his.PsnName,
  4201. Idetinfo: his.Idetinfo,
  4202. Insuinfo: his.Iinfo,
  4203. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4204. CardInfo: outPutInfo,
  4205. VerifyNumber: token,
  4206. }
  4207. service.CreateHisPsn(psn)
  4208. }
  4209. if len(token) > 0 {
  4210. c.ServeSuccessJSON(map[string]interface{}{
  4211. "msg": "读取成功",
  4212. })
  4213. } else {
  4214. c.ServeSuccessJSON(map[string]interface{}{
  4215. "failed_code": -10,
  4216. "msg": "读取失败",
  4217. })
  4218. }
  4219. }
  4220. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4221. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4222. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4223. type ELeData struct {
  4224. Data struct {
  4225. IdNo string `json:"idNo"`
  4226. IdType string `json:"idType"`
  4227. UserName string `json:"userName"`
  4228. EcToken string `json:"ecToken"`
  4229. InsuOrg string `json:"insuOrg"`
  4230. Gender string `json:"gender"`
  4231. Birthday string `json:"birthday"`
  4232. Nationality string `json:"nationality"`
  4233. Email string `json:"email"`
  4234. Extra string `json:"extra"`
  4235. } `json:"data"`
  4236. Code int `json:"code"`
  4237. Message string `json:"message"`
  4238. }
  4239. var ele ELeData
  4240. err := json.Unmarshal([]byte(result), &ele)
  4241. if err != nil {
  4242. utils.ErrorLog("解析失败:%v", err)
  4243. }
  4244. token := ele.Data.EcToken
  4245. token = Remove0000(token)
  4246. fmt.Println(ele.Data.UserName)
  4247. 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)
  4248. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4249. var res ResultTwo
  4250. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4251. utils.ErrorLog("解析失败:%v", err)
  4252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4253. return
  4254. }
  4255. if res.Infcode == 0 {
  4256. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4257. if err == gorm.ErrRecordNotFound {
  4258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4259. return
  4260. } else if err != nil {
  4261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4262. return
  4263. } else {
  4264. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4265. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4266. infoStr := string(Iinfos)
  4267. idetinfoStr := string(Idetinfos)
  4268. psn := &models.HisPsn{
  4269. PsnNo: res.Output.Baseinfo.PsnNo,
  4270. PatientId: patient.ID,
  4271. Certno: res.Output.Baseinfo.Certno,
  4272. Gend: res.Output.Baseinfo.Gend,
  4273. Naty: res.Output.Baseinfo.Naty,
  4274. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4275. PsnName: res.Output.Baseinfo.PsnName,
  4276. Idetinfo: idetinfoStr,
  4277. Insuinfo: infoStr,
  4278. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4279. CardInfo: "",
  4280. VerifyNumber: token,
  4281. }
  4282. service.CreateHisPsn(psn)
  4283. c.ServeSuccessJSON(map[string]interface{}{
  4284. "patient": patient,
  4285. "number": token,
  4286. })
  4287. }
  4288. } else {
  4289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4290. return
  4291. }
  4292. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4293. idNo := c.GetString("idNo")
  4294. userName := c.GetString("userName")
  4295. ecToken := c.GetString("ecToken")
  4296. insuOrg := c.GetString("insuOrg")
  4297. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4298. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4299. var res ResultTwo
  4300. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4301. utils.ErrorLog("解析失败:%v", err)
  4302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4303. return
  4304. }
  4305. if res.Infcode == 0 {
  4306. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4307. if err == gorm.ErrRecordNotFound {
  4308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4309. return
  4310. } else if err != nil {
  4311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4312. return
  4313. } else {
  4314. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4315. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4316. infoStr := string(Iinfos)
  4317. idetinfoStr := string(Idetinfos)
  4318. psn := &models.HisPsn{
  4319. PsnNo: res.Output.Baseinfo.PsnNo,
  4320. PatientId: patient.ID,
  4321. Certno: res.Output.Baseinfo.Certno,
  4322. Gend: res.Output.Baseinfo.Gend,
  4323. Naty: res.Output.Baseinfo.Naty,
  4324. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4325. PsnName: res.Output.Baseinfo.PsnName,
  4326. Idetinfo: idetinfoStr,
  4327. Insuinfo: infoStr,
  4328. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4329. CardInfo: "",
  4330. VerifyNumber: ecToken,
  4331. InsuplcAdmdvs: insuOrg,
  4332. }
  4333. service.CreateHisPsn(psn)
  4334. c.ServeSuccessJSON(map[string]interface{}{
  4335. "patient": patient,
  4336. "number": ecToken,
  4337. })
  4338. }
  4339. } else {
  4340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4341. return
  4342. }
  4343. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4344. res := c.GetoleInfo()
  4345. if res.Infcode == 0 {
  4346. var result string
  4347. if res.Output.MdtrtCertType == "01" {
  4348. 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)
  4349. } else if res.Output.MdtrtCertType == "02" {
  4350. 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)
  4351. } else if res.Output.MdtrtCertType == "03" {
  4352. 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)
  4353. }
  4354. var dat map[string]interface{}
  4355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4356. fmt.Println(dat)
  4357. } else {
  4358. fmt.Println(err)
  4359. }
  4360. userJSONBytes, _ := json.Marshal(dat)
  4361. var res2 ResultTwo
  4362. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4363. utils.ErrorLog("解析失败:%v", err)
  4364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4365. return
  4366. }
  4367. if res2.Infcode == 0 {
  4368. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4369. if err == gorm.ErrRecordNotFound {
  4370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4371. return
  4372. } else if err != nil {
  4373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4374. return
  4375. } else {
  4376. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4377. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4378. infoStr := string(Iinfos)
  4379. idetinfoStr := string(Idetinfos)
  4380. var rf []*ResultFive
  4381. json.Unmarshal([]byte(infoStr), &rf)
  4382. var insutypes []*ResultFive
  4383. var insutype string
  4384. var is390 int = 0
  4385. var is310 int = 0
  4386. //var insuplc_admdvs string
  4387. for _, item := range rf {
  4388. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4389. insutypes = append(insutypes, item)
  4390. }
  4391. }
  4392. if len(insutypes) == 1 {
  4393. insutype = insutypes[0].Insutype
  4394. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4395. } else {
  4396. for _, i := range insutypes {
  4397. if i.Insutype == "390" {
  4398. is390 = 1
  4399. }
  4400. if i.Insutype == "310" {
  4401. is310 = 1
  4402. }
  4403. }
  4404. }
  4405. if is390 == 1 {
  4406. insutype = "390"
  4407. }
  4408. if is310 == 1 {
  4409. insutype = "310"
  4410. }
  4411. if len(insutypes) == 0 {
  4412. insutype = "310"
  4413. }
  4414. psn := &models.HisPsn{
  4415. PsnNo: res2.Output.Baseinfo.PsnNo,
  4416. PatientId: patient.ID,
  4417. Certno: res2.Output.Baseinfo.Certno,
  4418. Gend: res2.Output.Baseinfo.Gend,
  4419. Naty: res2.Output.Baseinfo.Naty,
  4420. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4421. PsnName: res2.Output.Baseinfo.PsnName,
  4422. Idetinfo: idetinfoStr,
  4423. Insuinfo: infoStr,
  4424. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4425. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4426. VerifyNumber: res.Output.EcToken,
  4427. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4428. }
  4429. service.CreateHisPsn(psn)
  4430. c.ServeSuccessJSON(map[string]interface{}{
  4431. "patient": patient,
  4432. "number": res.Output.CardNo,
  4433. "insutype": insutype,
  4434. })
  4435. }
  4436. } else {
  4437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4438. return
  4439. }
  4440. } else {
  4441. c.ServeSuccessJSON(map[string]interface{}{
  4442. "failed_code": -10,
  4443. "msg": res.ErrMsg,
  4444. })
  4445. }
  4446. } else {
  4447. //if initFlag == 0 {
  4448. // c.TestGetBasBaseInit()
  4449. //}
  4450. //token := c.GetEleBaseInfo()
  4451. //token = Remove0000(token)
  4452. type ELeData struct {
  4453. Code string `json:"code"`
  4454. Data struct {
  4455. Aac002 string `json:"aac002"`
  4456. Aaz500 string `json:"aaz500"`
  4457. ActCardNo string `json:"actCardNo"`
  4458. Bab520 string `json:"bab520"`
  4459. Bkz543 string `json:"bkz543"`
  4460. BusinessType string `json:"businessType"`
  4461. CertfCodg string `json:"certfCodg"`
  4462. EcIndexNo string `json:"ecIndexNo"`
  4463. EcToken string `json:"ecToken"`
  4464. ID0000 string `json:"id0000"`
  4465. IDNo string `json:"idNo"`
  4466. IDType string `json:"idType"`
  4467. Idcode string `json:"idcode"`
  4468. IdentityToken string `json:"identity_token"`
  4469. InsuOrg string `json:"insuOrg"`
  4470. OfficeID string `json:"officeId"`
  4471. OfficeName string `json:"officeName"`
  4472. OperatorID string `json:"operatorId"`
  4473. OperatorName string `json:"operatorName"`
  4474. OrgID string `json:"orgId"`
  4475. UserName string `json:"userName"`
  4476. } `json:"data"`
  4477. Infno interface{} `json:"infno"`
  4478. Message string `json:"message"`
  4479. OrgID string `json:"orgId"`
  4480. TransType string `json:"transType"`
  4481. }
  4482. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4483. fmt.Println(result)
  4484. outPutInfo := Remove0000(result)
  4485. fmt.Println(outPutInfo)
  4486. var ele ELeData
  4487. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4488. if err != nil {
  4489. utils.ErrorLog("解析失败:%v", err)
  4490. }
  4491. token := ele.Data.EcToken
  4492. var result2 string
  4493. var requestLog2 string
  4494. if len(token) > 0 {
  4495. if strings.Contains(ele.Data.IDNo, "HKG") {
  4496. 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)
  4497. } else {
  4498. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4499. }
  4500. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4501. var res ResultTwo
  4502. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4503. utils.ErrorLog("解析失败:%v", err)
  4504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4505. return
  4506. }
  4507. if res.Infcode == 0 {
  4508. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4509. if err == gorm.ErrRecordNotFound {
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4511. return
  4512. } else if err != nil {
  4513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4514. return
  4515. } else {
  4516. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4517. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4518. infoStr := string(Iinfos)
  4519. idetinfoStr := string(Idetinfos)
  4520. psn := &models.HisPsn{
  4521. PsnNo: res.Output.Baseinfo.PsnNo,
  4522. PatientId: patient.ID,
  4523. Certno: res.Output.Baseinfo.Certno,
  4524. Gend: res.Output.Baseinfo.Gend,
  4525. Naty: res.Output.Baseinfo.Naty,
  4526. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4527. PsnName: res.Output.Baseinfo.PsnName,
  4528. Idetinfo: idetinfoStr,
  4529. Insuinfo: infoStr,
  4530. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4531. CardInfo: "",
  4532. VerifyNumber: token,
  4533. }
  4534. service.CreateHisPsn(psn)
  4535. c.ServeSuccessJSON(map[string]interface{}{
  4536. "msg": "读取成功",
  4537. })
  4538. }
  4539. } else {
  4540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4541. return
  4542. }
  4543. } else {
  4544. c.ServeSuccessJSON(map[string]interface{}{
  4545. "failed_code": -10,
  4546. "msg": "读取失败",
  4547. })
  4548. }
  4549. }
  4550. }
  4551. func (c *HisApiController) ReadEleFace() {
  4552. admin_user_id, _ := c.GetInt64("admin_user_id")
  4553. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4554. adminUser := c.GetAdminUserInfo()
  4555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4556. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4557. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4558. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4559. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4560. if len(tokens) > 0 {
  4561. c.ServeSuccessJSON(map[string]interface{}{
  4562. "msg": "读取成功",
  4563. })
  4564. } else {
  4565. c.ServeSuccessJSON(map[string]interface{}{
  4566. "failed_code": -10,
  4567. "msg": "读取失败",
  4568. })
  4569. }
  4570. }
  4571. }
  4572. func (c *HisApiController) Get9001() {
  4573. adminUser := c.GetAdminUserInfo()
  4574. admin_user_id, _ := c.GetInt64("admin_user_id")
  4575. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4576. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4577. if miConfig.MdtrtareaAdmvs == "350500" {
  4578. service.GetFjAuthorizationInfo(miConfig.Code)
  4579. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4580. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4581. var dat map[string]interface{}
  4582. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4583. fmt.Println(dat)
  4584. } else {
  4585. fmt.Println(err)
  4586. }
  4587. userJSONBytes, _ := json.Marshal(dat)
  4588. var res models.Result9001
  4589. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4590. utils.ErrorLog("解析失败:%v", err)
  4591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4592. return
  4593. }
  4594. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4595. fmt.Println(miConfig.SecretKey)
  4596. var res models.Result9001Two
  4597. 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 +
  4598. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4599. resp, requestErr := http.Get(api)
  4600. if requestErr != nil {
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. body, ioErr := ioutil.ReadAll(resp.Body)
  4605. if ioErr != nil {
  4606. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4608. return
  4609. }
  4610. var respJSON map[string]interface{}
  4611. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4612. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4614. return
  4615. }
  4616. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4617. if status == "0" {
  4618. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4619. c.ServeSuccessJSON(map[string]interface{}{
  4620. "failed_code": -10,
  4621. "msg": err_msg,
  4622. })
  4623. return
  4624. }
  4625. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4626. result, _ := json.Marshal(respJSON)
  4627. fmt.Println("log")
  4628. fmt.Println(string(result))
  4629. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4630. utils.ErrorLog("解析失败:%v", err)
  4631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4632. return
  4633. }
  4634. if res.Infcode == 0 {
  4635. sign := models.HisSignIn{
  4636. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4637. SignNo: res.Output.Signinoutb.SignNo,
  4638. SignTime: "",
  4639. Ctime: time.Now().Unix(),
  4640. Mtime: time.Now().Unix(),
  4641. Status: 1,
  4642. InputLog: "",
  4643. OutputLog: "",
  4644. FixmedinsCode: miConfig.Code,
  4645. }
  4646. err := service.CreateSignIn(&sign)
  4647. if err == nil {
  4648. c.ServeSuccessJSON(map[string]interface{}{
  4649. "msg": "签到成功",
  4650. })
  4651. }
  4652. } else {
  4653. c.ServeSuccessJSON(map[string]interface{}{
  4654. "failed_code": -10,
  4655. "msg": res.ErrMsg,
  4656. })
  4657. return
  4658. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4659. //return
  4660. }
  4661. } else {
  4662. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4663. var dat map[string]interface{}
  4664. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4665. fmt.Println(dat)
  4666. } else {
  4667. fmt.Println(err)
  4668. }
  4669. userJSONBytes, _ := json.Marshal(dat)
  4670. var res models.Result9001
  4671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4672. utils.ErrorLog("解析失败:%v", err)
  4673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4674. return
  4675. }
  4676. if res.Infcode == 0 {
  4677. sign := models.HisSignIn{
  4678. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4679. SignNo: res.Output.Signinoutb.SignNo,
  4680. SignTime: res.Output.Signinoutb.SignTime,
  4681. Ctime: time.Now().Unix(),
  4682. Mtime: time.Now().Unix(),
  4683. Status: 1,
  4684. InputLog: "",
  4685. OutputLog: "",
  4686. FixmedinsCode: miConfig.Code,
  4687. }
  4688. err := service.CreateSignIn(&sign)
  4689. if err == nil {
  4690. c.ServeSuccessJSON(map[string]interface{}{
  4691. "msg": "签到成功",
  4692. })
  4693. }
  4694. }
  4695. }
  4696. }
  4697. 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) {
  4698. var res Result3101
  4699. adminUser := c.GetAdminUserInfo()
  4700. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4701. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4702. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4703. //record_time := c.GetString("record_time")
  4704. //trig_scen := c.GetString("trig_scen")
  4705. timeLayout := "2006-01-02"
  4706. loc, _ := time.LoadLocation("Local")
  4707. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4708. if err != nil {
  4709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4710. return res
  4711. }
  4712. recordDateTime := theTime.Unix()
  4713. var patientPrescription models.HisPrescriptionInfo
  4714. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4715. //if patientPrescription.ID == 0 {
  4716. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4717. //}
  4718. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4719. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4720. //
  4721. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  4722. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4723. var pp models.PublicParams
  4724. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  4725. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  4726. pp.FixmedinsName = miConfig.OrgName
  4727. pp.FixmedinsCode = miConfig.Code
  4728. pp.RequestUrl = miConfig.Url
  4729. pp.Cainfo = miConfig.Cainfo
  4730. pp.SecretKey = miConfig.SecretKey
  4731. pp.AccessKey = miConfig.AccessKey
  4732. pp.OpterName = roles.UserName
  4733. var config []*models.HisXtDiagnoseConfig
  4734. for _, item := range diagnosis_ids {
  4735. id, _ := strconv.ParseInt(item, 10, 64)
  4736. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4737. config = append(config, &diagnosisConfig)
  4738. }
  4739. var pd models.PatientDtos
  4740. pd.PatnID = his.PsnNo
  4741. pd.PatnName = his.Name
  4742. pd.Gend = his.Gend
  4743. pd.Brdy = his.Brdy
  4744. pd.Poolarea = miConfig.MdtrtareaAdmvs
  4745. pd.CurrMdtrtID = his.Number
  4746. var fed models.FsiEncounterDtos
  4747. fed.MdtrtID = his.Number
  4748. fed.MedinsID = miConfig.Code
  4749. fed.MedinsName = miConfig.OrgName
  4750. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  4751. fed.MedMdtrtType = "1"
  4752. fed.MedinsType = "1"
  4753. fed.MedinsLv = "11"
  4754. tm := time.Unix(his.RecordDate, 0)
  4755. s_tm := tm.Format("2006-01-02 15:04:05")
  4756. fed.AdmDate = s_tm
  4757. fed.DscgDate = s_tm
  4758. fed.DscgMainDiseCodg = config[0].CountryCode
  4759. fed.DscgMainDiseName = config[0].CountryContentName
  4760. //诊断信息
  4761. var fdds []*models.FsiDiagnoseDtos
  4762. for index, item := range config {
  4763. if index == 0 {
  4764. var fdd models.FsiDiagnoseDtos
  4765. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4766. fdd.InoutDiseType = "1"
  4767. fdd.MaindiseFlag = "1"
  4768. fdd.DiseDate = s_tm
  4769. fdd.DiasSrtNo = "1"
  4770. fdd.DiseName = item.CountryContentName
  4771. fdd.DiseCodg = item.CountryCode
  4772. fdds = append(fdds, &fdd)
  4773. } else {
  4774. var fdd models.FsiDiagnoseDtos
  4775. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  4776. fdd.InoutDiseType = "1"
  4777. fdd.MaindiseFlag = "1"
  4778. fdd.DiseDate = s_tm
  4779. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  4780. fdd.DiseName = item.CountryContentName
  4781. fdd.DiseCodg = item.CountryCode
  4782. fdds = append(fdds, &fdd)
  4783. }
  4784. }
  4785. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  4786. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  4787. fed.AdmDeptName = department.Name
  4788. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  4789. fed.DscgDeptName = department.Name
  4790. fed.MedMdtrtType = "1"
  4791. fed.MedType = "11"
  4792. //if his.Insutype == "390" {
  4793. // fed.MedType = "1402"
  4794. //} else {
  4795. // fed.MedType = "9933"
  4796. //}
  4797. var orders []*models.FsiOrderDtos
  4798. if trig_scen == "2" {
  4799. //处方医嘱信息
  4800. for _, item := range prescriptions {
  4801. for _, subItem := range item.HisDoctorAdviceInfo {
  4802. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  4803. var order models.FsiOrderDtos
  4804. order.RxID = strconv.FormatInt(item.ID, 10)
  4805. order.Rxno = strconv.FormatInt(item.ID, 10)
  4806. order.LongDrordFlag = "0"
  4807. order.HilistType = "1"
  4808. order.ChrgType = "1"
  4809. order.DrordBhvr = "-"
  4810. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4811. order.HosplistName = subItem.BaseDrugLib.DrugName
  4812. order.HilistLv = "1"
  4813. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4814. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  4815. order.HosplistName = subItem.BaseDrugLib.DrugName
  4816. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  4817. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4818. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  4819. order.OwnpayAmt = ""
  4820. order.SelfpayAmt = ""
  4821. order.Spec = ""
  4822. order.SpecUnt = ""
  4823. order.DrordBegnDate = s_tm
  4824. order.DrordStopDate = ""
  4825. order.DrordDrCodg = doctor_info.DoctorNumber
  4826. order.DrordDeptName = department.Name
  4827. order.DrordDeptCodg = department.Number
  4828. order.DrordDrName = doctor_info.UserName
  4829. order.DrordDrProfttl = "234"
  4830. order.CurrDrordFlag = "1"
  4831. orders = append(orders, &order)
  4832. }
  4833. }
  4834. for _, subItem := range item.HisPrescriptionProject {
  4835. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  4836. var order models.FsiOrderDtos
  4837. order.RxID = strconv.FormatInt(item.ID, 10)
  4838. order.Rxno = strconv.FormatInt(item.ID, 10)
  4839. order.LongDrordFlag = "0"
  4840. order.HilistType = "1"
  4841. order.ChrgType = "1"
  4842. order.DrordBhvr = "-"
  4843. order.HilistCode = subItem.HisProject.MedicalCode
  4844. order.HosplistName = subItem.HisProject.ProjectName
  4845. order.HilistLv = "1"
  4846. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4847. order.HosplistCode = subItem.HisProject.MedicalCode
  4848. order.HosplistName = subItem.HisProject.ProjectName
  4849. order.Cnt = subItem.Count
  4850. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4851. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4852. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4853. order.OwnpayAmt = ""
  4854. order.SelfpayAmt = ""
  4855. order.Spec = ""
  4856. order.SpecUnt = ""
  4857. order.DrordBegnDate = s_tm
  4858. order.DrordStopDate = ""
  4859. order.DrordDrCodg = doctor_info.DoctorNumber
  4860. order.DrordDeptName = department.Name
  4861. order.DrordDeptCodg = department.Number
  4862. order.DrordDrName = doctor_info.UserName
  4863. order.DrordDrProfttl = "234"
  4864. order.CurrDrordFlag = "1"
  4865. orders = append(orders, &order)
  4866. }
  4867. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  4868. var order models.FsiOrderDtos
  4869. order.RxID = strconv.FormatInt(item.ID, 10)
  4870. order.Rxno = strconv.FormatInt(item.ID, 10)
  4871. order.LongDrordFlag = "0"
  4872. order.HilistType = "1"
  4873. order.ChrgType = "1"
  4874. order.DrordBhvr = "-"
  4875. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4876. order.HosplistName = subItem.GoodInfo.GoodName
  4877. order.HilistLv = "1"
  4878. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  4879. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  4880. order.HosplistName = subItem.GoodInfo.GoodName
  4881. order.Cnt = subItem.Count
  4882. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4883. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  4884. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  4885. order.OwnpayAmt = ""
  4886. order.SelfpayAmt = ""
  4887. order.Spec = ""
  4888. order.SpecUnt = ""
  4889. order.DrordBegnDate = s_tm
  4890. order.DrordStopDate = ""
  4891. order.DrordDrCodg = doctor_info.DoctorNumber
  4892. order.DrordDeptName = department.Name
  4893. order.DrordDeptCodg = department.Number
  4894. order.DrordDrName = doctor_info.UserName
  4895. order.DrordDrProfttl = "234"
  4896. order.CurrDrordFlag = "1"
  4897. orders = append(orders, &order)
  4898. }
  4899. }
  4900. }
  4901. //处方医嘱信息
  4902. }
  4903. fed.MatnStas = "0"
  4904. fed.MedfeeSumamt = "0"
  4905. fed.OwnpayAmt = "0"
  4906. fed.SelfpayAmt = "0"
  4907. fed.AcctPayamt = "0"
  4908. fed.MaAmt = "0"
  4909. fed.HifpPayamt = "0"
  4910. fed.SetlTotlnum = "1"
  4911. fed.Insutype = his.Insutype
  4912. fed.ReimFlag = "0"
  4913. fed.OutSetlFlag = "0"
  4914. var fopd []*models.FsiOperationDtosData
  4915. data := make(map[string]interface{})
  4916. data["fed"] = fed
  4917. data["fdd"] = fdds
  4918. data["fod"] = orders
  4919. data["pd"] = pd
  4920. data["pp"] = pp
  4921. data["fopd"] = fopd
  4922. data["trig_scen"] = trig_scen
  4923. fmt.Println(data)
  4924. fmt.Println(fed)
  4925. fmt.Println(fdds)
  4926. fmt.Println(orders)
  4927. fmt.Println(pd)
  4928. fmt.Println(pp)
  4929. fmt.Println(fopd)
  4930. client := &http.Client{}
  4931. bytesData, _ := json.Marshal(data)
  4932. var req *http.Request
  4933. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4934. if miConfig.MdtrtareaAdmvs == "320921" {
  4935. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4936. } else {
  4937. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  4938. }
  4939. resp, _ := client.Do(req)
  4940. defer resp.Body.Close()
  4941. body, ioErr := ioutil.ReadAll(resp.Body)
  4942. if ioErr != nil {
  4943. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4945. return res
  4946. }
  4947. var respJSON map[string]interface{}
  4948. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4949. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4951. return res
  4952. }
  4953. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  4954. fmt.Println(respJSON)
  4955. result, _ := json.Marshal(respJSON)
  4956. fmt.Println(result)
  4957. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4958. utils.ErrorLog("解析失败:%v", err)
  4959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4960. return res
  4961. }
  4962. return res
  4963. } else {
  4964. //if miConfig.MdtrtareaAdmvs == "441202" {
  4965. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  4966. saveLog(output, input, "3101", "事前")
  4967. if err := json.Unmarshal([]byte(output), &res); err != nil {
  4968. utils.ErrorLog("解析失败:%v", err)
  4969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4970. return
  4971. }
  4972. return res
  4973. //}
  4974. }
  4975. }
  4976. 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) {
  4977. adminUser := c.GetAdminUserInfo()
  4978. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4979. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4980. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4981. //record_time := c.GetString("record_time")
  4982. //trig_scen := c.GetString("trig_scen")
  4983. timeLayout := "2006-01-02"
  4984. loc, _ := time.LoadLocation("Local")
  4985. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4986. if err != nil {
  4987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4988. return res
  4989. }
  4990. recordDateTime := theTime.Unix()
  4991. var patientPrescription models.HisPrescriptionInfo
  4992. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4993. if patientPrescription.ID == 0 {
  4994. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4995. }
  4996. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4997. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4998. //
  4999. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5000. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5001. var pp models.PublicParams
  5002. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5003. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5004. pp.FixmedinsName = miConfig.OrgName
  5005. pp.FixmedinsCode = miConfig.Code
  5006. pp.RequestUrl = miConfig.Url
  5007. pp.Cainfo = miConfig.Cainfo
  5008. pp.SecretKey = miConfig.SecretKey
  5009. pp.AccessKey = miConfig.AccessKey
  5010. pp.OpterName = roles.UserName
  5011. var config []*models.HisXtDiagnoseConfig
  5012. for _, item := range diagnosis_ids {
  5013. id, _ := strconv.ParseInt(item, 10, 64)
  5014. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5015. config = append(config, &diagnosisConfig)
  5016. }
  5017. var pd models.PatientDtos
  5018. pd.PatnID = his.PsnNo
  5019. pd.PatnName = his.Name
  5020. pd.Gend = his.Gend
  5021. pd.Brdy = his.Brdy
  5022. pd.Poolarea = his.InsuplcAdmdvs
  5023. pd.CurrMdtrtID = his.Number
  5024. var fed models.FsiEncounterDtos
  5025. fed.MdtrtID = his.Number
  5026. fed.MedinsID = miConfig.Code
  5027. fed.MedinsName = miConfig.OrgName
  5028. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5029. fed.MedMdtrtType = "1"
  5030. fed.MedinsType = "1"
  5031. fed.MedinsLv = "11"
  5032. tm := time.Unix(his.RecordDate, 0)
  5033. s_tm := tm.Format("2006-01-02 15:04:05")
  5034. fed.AdmDate = s_tm
  5035. fed.DscgDate = s_tm
  5036. fed.DscgMainDiseCodg = config[0].CountryCode
  5037. fed.DscgMainDiseName = config[0].CountryContentName
  5038. //诊断信息
  5039. var fdds []*models.FsiDiagnoseDtos
  5040. for index, item := range config {
  5041. if index == 0 {
  5042. var fdd models.FsiDiagnoseDtos
  5043. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5044. fdd.InoutDiseType = "1"
  5045. fdd.MaindiseFlag = "1"
  5046. fdd.DiseDate = s_tm
  5047. fdd.DiasSrtNo = "1"
  5048. fdd.DiseName = item.CountryContentName
  5049. fdd.DiseCodg = item.CountryCode
  5050. fdds = append(fdds, &fdd)
  5051. } else {
  5052. var fdd models.FsiDiagnoseDtos
  5053. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5054. fdd.InoutDiseType = "1"
  5055. fdd.MaindiseFlag = "1"
  5056. fdd.DiseDate = s_tm
  5057. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5058. fdd.DiseName = item.CountryContentName
  5059. fdd.DiseCodg = item.CountryCode
  5060. fdds = append(fdds, &fdd)
  5061. }
  5062. }
  5063. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5064. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5065. fed.AdmDeptName = department.Name
  5066. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5067. fed.DscgDeptName = department.Name
  5068. fed.MedMdtrtType = "1"
  5069. fed.MedType = "11"
  5070. //if his.Insutype == "390" {
  5071. // fed.MedType = "1402"
  5072. //} else {
  5073. // fed.MedType = "9933"
  5074. //}
  5075. var orders []*models.FsiOrderDtos
  5076. if trig_scen == "2" {
  5077. //处方医嘱信息
  5078. for _, item := range prescriptions {
  5079. for _, subItem := range item.HisDoctorAdviceInfo {
  5080. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5081. var order models.FsiOrderDtos
  5082. order.RxID = strconv.FormatInt(item.ID, 10)
  5083. order.Rxno = strconv.FormatInt(item.ID, 10)
  5084. order.LongDrordFlag = "0"
  5085. order.HilistType = "1"
  5086. order.ChrgType = "1"
  5087. order.DrordBhvr = "-"
  5088. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5089. order.HosplistName = subItem.BaseDrugLib.DrugName
  5090. order.HilistLv = "1"
  5091. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5092. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5093. order.HosplistName = subItem.BaseDrugLib.DrugName
  5094. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5095. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5096. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5097. order.OwnpayAmt = ""
  5098. order.SelfpayAmt = ""
  5099. order.Spec = ""
  5100. order.SpecUnt = ""
  5101. order.DrordBegnDate = s_tm
  5102. order.DrordStopDate = ""
  5103. order.DrordDrCodg = doctor_info.DoctorNumber
  5104. order.DrordDeptName = department.Name
  5105. order.DrordDeptCodg = department.Number
  5106. order.DrordDrName = doctor_info.UserName
  5107. order.DrordDrProfttl = "234"
  5108. order.CurrDrordFlag = "1"
  5109. orders = append(orders, &order)
  5110. }
  5111. }
  5112. for _, subItem := range item.HisPrescriptionProject {
  5113. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5114. var order models.FsiOrderDtos
  5115. order.RxID = strconv.FormatInt(item.ID, 10)
  5116. order.Rxno = strconv.FormatInt(item.ID, 10)
  5117. order.LongDrordFlag = "0"
  5118. order.HilistType = "1"
  5119. order.ChrgType = "1"
  5120. order.DrordBhvr = "-"
  5121. order.HilistCode = subItem.HisProject.MedicalCode
  5122. order.HosplistName = subItem.HisProject.ProjectName
  5123. order.HilistLv = "1"
  5124. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5125. order.HosplistCode = subItem.HisProject.MedicalCode
  5126. order.HosplistName = subItem.HisProject.ProjectName
  5127. order.Cnt = subItem.Count
  5128. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5129. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5130. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5131. order.OwnpayAmt = ""
  5132. order.SelfpayAmt = ""
  5133. order.Spec = ""
  5134. order.SpecUnt = ""
  5135. order.DrordBegnDate = s_tm
  5136. order.DrordStopDate = ""
  5137. order.DrordDrCodg = doctor_info.DoctorNumber
  5138. order.DrordDeptName = department.Name
  5139. order.DrordDeptCodg = department.Number
  5140. order.DrordDrName = doctor_info.UserName
  5141. order.DrordDrProfttl = "234"
  5142. order.CurrDrordFlag = "1"
  5143. orders = append(orders, &order)
  5144. }
  5145. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5146. var order models.FsiOrderDtos
  5147. order.RxID = strconv.FormatInt(item.ID, 10)
  5148. order.Rxno = strconv.FormatInt(item.ID, 10)
  5149. order.LongDrordFlag = "0"
  5150. order.HilistType = "1"
  5151. order.ChrgType = "1"
  5152. order.DrordBhvr = "-"
  5153. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5154. order.HosplistName = subItem.GoodInfo.GoodName
  5155. order.HilistLv = "1"
  5156. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5157. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5158. order.HosplistName = subItem.GoodInfo.GoodName
  5159. order.Cnt = subItem.Count
  5160. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5161. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5162. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5163. order.OwnpayAmt = ""
  5164. order.SelfpayAmt = ""
  5165. order.Spec = ""
  5166. order.SpecUnt = ""
  5167. order.DrordBegnDate = s_tm
  5168. order.DrordStopDate = ""
  5169. order.DrordDrCodg = doctor_info.DoctorNumber
  5170. order.DrordDeptName = department.Name
  5171. order.DrordDeptCodg = department.Number
  5172. order.DrordDrName = doctor_info.UserName
  5173. order.DrordDrProfttl = "234"
  5174. order.CurrDrordFlag = "1"
  5175. orders = append(orders, &order)
  5176. }
  5177. }
  5178. }
  5179. //处方医嘱信息
  5180. }
  5181. fed.MatnStas = "0"
  5182. fed.MedfeeSumamt = "0"
  5183. fed.OwnpayAmt = "0"
  5184. fed.SelfpayAmt = "0"
  5185. fed.AcctPayamt = "0"
  5186. fed.MaAmt = "0"
  5187. fed.HifpPayamt = "0"
  5188. fed.SetlTotlnum = "1"
  5189. fed.Insutype = his.Insutype
  5190. fed.ReimFlag = "0"
  5191. fed.OutSetlFlag = "0"
  5192. var fopd []*models.FsiOperationDtosData
  5193. data := make(map[string]interface{})
  5194. data["fed"] = fed
  5195. data["fdd"] = fdds
  5196. data["fod"] = orders
  5197. data["pd"] = pd
  5198. data["pp"] = pp
  5199. data["fopd"] = fopd
  5200. data["trig_scen"] = trig_scen
  5201. fmt.Println(data)
  5202. fmt.Println(fed)
  5203. fmt.Println(fdds)
  5204. fmt.Println(orders)
  5205. fmt.Println(pd)
  5206. fmt.Println(pp)
  5207. fmt.Println(fopd)
  5208. client := &http.Client{}
  5209. bytesData, _ := json.Marshal(data)
  5210. var req *http.Request
  5211. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5212. if miConfig.MdtrtareaAdmvs == "320921" {
  5213. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5214. } else {
  5215. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5216. }
  5217. resp, _ := client.Do(req)
  5218. defer resp.Body.Close()
  5219. body, ioErr := ioutil.ReadAll(resp.Body)
  5220. if ioErr != nil {
  5221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5223. return res
  5224. }
  5225. var respJSON map[string]interface{}
  5226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5229. return res
  5230. }
  5231. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5232. fmt.Println(respJSON)
  5233. result, _ := json.Marshal(respJSON)
  5234. fmt.Println(result)
  5235. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5236. utils.ErrorLog("解析失败:%v", err)
  5237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5238. return res
  5239. }
  5240. return res
  5241. } else {
  5242. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5243. saveLog(output, input, "3101", "事前")
  5244. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5245. utils.ErrorLog("解析失败:%v", err)
  5246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5247. return
  5248. }
  5249. return res
  5250. }
  5251. return res
  5252. }
  5253. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5254. ////patient_id, _ := c.GetInt64("patient_id")
  5255. //order_id, _ := c.GetInt64("order_id")
  5256. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5257. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5258. //trig_scen := c.GetString("trig_scen")
  5259. adminUser := c.GetAdminUserInfo()
  5260. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5261. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5262. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5263. record_time := c.GetString("record_time")
  5264. order, _ := service.GetHisOrderByID(order_id)
  5265. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5266. timeLayout := "2006-01-02"
  5267. loc, _ := time.LoadLocation("Local")
  5268. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5269. if err != nil {
  5270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5271. return
  5272. }
  5273. recordDateTime := theTime.Unix()
  5274. var patientPrescription models.HisPrescriptionInfo
  5275. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5276. if patientPrescription.ID == 0 {
  5277. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5278. }
  5279. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5280. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5281. //
  5282. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5283. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5284. var pp models.PublicParams
  5285. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5286. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5287. pp.FixmedinsName = miConfig.OrgName
  5288. pp.FixmedinsCode = miConfig.Code
  5289. pp.RequestUrl = miConfig.Url
  5290. pp.Cainfo = miConfig.Cainfo
  5291. pp.SecretKey = miConfig.SecretKey
  5292. pp.AccessKey = miConfig.AccessKey
  5293. pp.OpterName = roles.UserName
  5294. var config []*models.HisXtDiagnoseConfig
  5295. for _, item := range diagnosis_ids {
  5296. id, _ := strconv.ParseInt(item, 10, 64)
  5297. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5298. config = append(config, &diagnosisConfig)
  5299. }
  5300. var pd models.PatientDtos
  5301. pd.PatnID = his.PsnNo
  5302. pd.PatnName = his.Name
  5303. pd.Gend = his.Gend
  5304. pd.Brdy = psn_info.Brdy
  5305. pd.Poolarea = his.InsuplcAdmdvs
  5306. pd.CurrMdtrtID = his.Number
  5307. var fed models.FsiEncounterDtos
  5308. fed.MdtrtID = his.Number
  5309. fed.MedinsID = miConfig.Code
  5310. fed.MedinsName = miConfig.OrgName
  5311. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5312. fed.MedMdtrtType = "1"
  5313. fed.MedinsType = "1"
  5314. fed.MedinsLv = "11"
  5315. tm := time.Unix(his.RecordDate, 0)
  5316. s_tm := tm.Format("2006-01-02 15:04:05")
  5317. fed.AdmDate = s_tm
  5318. fed.DscgDate = s_tm
  5319. fed.DscgMainDiseCodg = config[0].CountryCode
  5320. fed.DscgMainDiseName = config[0].CountryContentName
  5321. //诊断信息
  5322. var fdds []*models.FsiDiagnoseDtos
  5323. for index, item := range config {
  5324. if index == 0 {
  5325. var fdd models.FsiDiagnoseDtos
  5326. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5327. fdd.InoutDiseType = "1"
  5328. fdd.MaindiseFlag = "1"
  5329. fdd.DiseDate = s_tm
  5330. fdd.DiasSrtNo = "1"
  5331. fdd.DiseName = item.CountryContentName
  5332. fdd.DiseCodg = item.CountryCode
  5333. fdds = append(fdds, &fdd)
  5334. } else {
  5335. var fdd models.FsiDiagnoseDtos
  5336. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5337. fdd.InoutDiseType = "1"
  5338. fdd.MaindiseFlag = "1"
  5339. fdd.DiseDate = s_tm
  5340. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5341. fdd.DiseName = item.CountryContentName
  5342. fdd.DiseCodg = item.CountryCode
  5343. fdds = append(fdds, &fdd)
  5344. }
  5345. }
  5346. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5347. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5348. fed.AdmDeptName = department.Name
  5349. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5350. fed.DscgDeptName = department.Name
  5351. fed.MedType = order.MedType
  5352. //处方医嘱信息
  5353. var orders []*models.FsiOrderDtos
  5354. //for _, item := range prescriptions {
  5355. // for _, subItem := range item.HisDoctorAdviceInfo {
  5356. // var order models.FsiOrderDtos
  5357. // order.RxID = strconv.FormatInt(item.ID, 10)
  5358. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5359. // order.LongDrordFlag = "0"
  5360. // order.HilistType = "1"
  5361. // order.ChrgType = "1"
  5362. // order.DrordBhvr = "-"
  5363. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5364. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5365. // order.HilistLv = "1"
  5366. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5367. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5368. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5369. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5370. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5371. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5372. // order.OwnpayAmt = ""
  5373. // order.SelfpayAmt = ""
  5374. // order.Spec = ""
  5375. // order.SpecUnt = ""
  5376. // order.DrordBegnDate = s_tm
  5377. // order.DrordStopDate = ""
  5378. // order.DrordDrCodg = "1"
  5379. // order.DrordDeptName = department.Name
  5380. // order.DrordDrCodg = "1"
  5381. // order.DrordDrName = doctor_info.UserName
  5382. // order.DrordDrProfttl = ""
  5383. // order.CurrDrordFlag = "1"
  5384. // orders = append(orders, &order)
  5385. // }
  5386. // for _, subItem := range item.HisPrescriptionProject {
  5387. // if subItem.Type == 2 {
  5388. // var order models.FsiOrderDtos
  5389. // order.RxID = strconv.FormatInt(item.ID, 10)
  5390. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5391. // order.LongDrordFlag = "0"
  5392. // order.HilistType = "1"
  5393. // order.ChrgType = "1"
  5394. // order.DrordBhvr = "-"
  5395. // order.HilistCode = subItem.HisProject.MedicalCode
  5396. // order.HosplistName = subItem.HisProject.ProjectName
  5397. // order.HilistLv = "1"
  5398. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5399. // order.HosplistCode = subItem.HisProject.MedicalCode
  5400. // order.HosplistName = subItem.HisProject.ProjectName
  5401. // order.Cnt = subItem.Count
  5402. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5403. //
  5404. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5405. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5406. // order.OwnpayAmt = ""
  5407. // order.SelfpayAmt = ""
  5408. // order.Spec = ""
  5409. // order.SpecUnt = ""
  5410. // order.DrordBegnDate = s_tm
  5411. // order.DrordStopDate = ""
  5412. // order.DrordDrCodg = "1"
  5413. // order.DrordDeptName = department.Name
  5414. // order.DrordDrCodg = "1"
  5415. // order.DrordDrName = doctor_info.UserName
  5416. // order.DrordDrProfttl = ""
  5417. // order.CurrDrordFlag = "1"
  5418. // orders = append(orders, &order)
  5419. //
  5420. // }
  5421. // if subItem.Type == 3 {
  5422. //
  5423. // var order models.FsiOrderDtos
  5424. // order.RxID = strconv.FormatInt(item.ID, 10)
  5425. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5426. // order.LongDrordFlag = "0"
  5427. // order.HilistType = "1"
  5428. // order.ChrgType = "1"
  5429. // order.DrordBhvr = "-"
  5430. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5431. // order.HosplistName = subItem.GoodInfo.GoodName
  5432. // order.HilistLv = "1"
  5433. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5434. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5435. // order.HosplistName = subItem.GoodInfo.GoodName
  5436. // order.Cnt = subItem.Count
  5437. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5438. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5439. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5440. // order.OwnpayAmt = ""
  5441. // order.SelfpayAmt = ""
  5442. // order.Spec = ""
  5443. // order.SpecUnt = ""
  5444. // order.DrordBegnDate = s_tm
  5445. // order.DrordStopDate = ""
  5446. // order.DrordDrCodg = "1"
  5447. // order.DrordDeptName = department.Name
  5448. // order.DrordDrCodg = "1"
  5449. // order.DrordDrName = doctor_info.UserName
  5450. // order.DrordDrProfttl = ""
  5451. // order.CurrDrordFlag = "1"
  5452. // orders = append(orders, &order)
  5453. //
  5454. // }
  5455. // }
  5456. //}
  5457. for _, item := range prescriptions {
  5458. for _, subItem := range item.HisDoctorAdviceInfo {
  5459. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5460. var order models.FsiOrderDtos
  5461. order.RxID = strconv.FormatInt(item.ID, 10)
  5462. order.Rxno = strconv.FormatInt(item.ID, 10)
  5463. order.LongDrordFlag = "0"
  5464. order.HilistType = "1"
  5465. order.ChrgType = "1"
  5466. order.DrordBhvr = "-"
  5467. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5468. order.HosplistName = subItem.BaseDrugLib.DrugName
  5469. order.HilistLv = "1"
  5470. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5471. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5472. order.HosplistName = subItem.BaseDrugLib.DrugName
  5473. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5474. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5475. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5476. order.OwnpayAmt = ""
  5477. order.SelfpayAmt = ""
  5478. order.Spec = ""
  5479. order.SpecUnt = ""
  5480. order.DrordBegnDate = s_tm
  5481. order.DrordStopDate = ""
  5482. order.DrordDrCodg = doctor_info.DoctorNumber
  5483. order.DrordDeptName = department.Name
  5484. order.DrordDeptCodg = department.Number
  5485. order.DrordDrName = doctor_info.UserName
  5486. order.DrordDrProfttl = "234"
  5487. order.CurrDrordFlag = "1"
  5488. orders = append(orders, &order)
  5489. }
  5490. }
  5491. for _, subItem := range item.HisPrescriptionProject {
  5492. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5493. var order models.FsiOrderDtos
  5494. order.RxID = strconv.FormatInt(item.ID, 10)
  5495. order.Rxno = strconv.FormatInt(item.ID, 10)
  5496. order.LongDrordFlag = "0"
  5497. order.HilistType = "1"
  5498. order.ChrgType = "1"
  5499. order.DrordBhvr = "-"
  5500. order.HilistCode = subItem.HisProject.MedicalCode
  5501. order.HosplistName = subItem.HisProject.ProjectName
  5502. order.HilistLv = "1"
  5503. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5504. order.HosplistCode = subItem.HisProject.MedicalCode
  5505. order.HosplistName = subItem.HisProject.ProjectName
  5506. order.Cnt = subItem.Count
  5507. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5508. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5509. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5510. order.OwnpayAmt = ""
  5511. order.SelfpayAmt = ""
  5512. order.Spec = ""
  5513. order.SpecUnt = ""
  5514. order.DrordBegnDate = s_tm
  5515. order.DrordStopDate = ""
  5516. order.DrordDrCodg = doctor_info.DoctorNumber
  5517. order.DrordDeptName = department.Name
  5518. order.DrordDeptCodg = department.Number
  5519. order.DrordDrName = doctor_info.UserName
  5520. order.DrordDrProfttl = "234"
  5521. order.CurrDrordFlag = "1"
  5522. orders = append(orders, &order)
  5523. }
  5524. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5525. var order models.FsiOrderDtos
  5526. order.RxID = strconv.FormatInt(item.ID, 10)
  5527. order.Rxno = strconv.FormatInt(item.ID, 10)
  5528. order.LongDrordFlag = "0"
  5529. order.HilistType = "1"
  5530. order.ChrgType = "1"
  5531. order.DrordBhvr = "0"
  5532. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5533. order.HosplistName = subItem.GoodInfo.GoodName
  5534. order.HilistLv = "1"
  5535. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5536. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5537. order.HosplistName = subItem.GoodInfo.GoodName
  5538. order.Cnt = subItem.Count
  5539. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5540. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5541. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5542. order.OwnpayAmt = ""
  5543. order.SelfpayAmt = ""
  5544. order.Spec = ""
  5545. order.SpecUnt = ""
  5546. order.DrordBegnDate = s_tm
  5547. order.DrordStopDate = ""
  5548. order.DrordDrCodg = doctor_info.DoctorNumber
  5549. order.DrordDeptName = department.Name
  5550. order.DrordDeptCodg = department.Number
  5551. order.DrordDrName = doctor_info.UserName
  5552. order.DrordDrProfttl = "234"
  5553. order.CurrDrordFlag = "1"
  5554. orders = append(orders, &order)
  5555. }
  5556. }
  5557. }
  5558. //处方医嘱信息
  5559. fed.MatnStas = "0"
  5560. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5561. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5562. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5563. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5564. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5565. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5566. fed.SetlTotlnum = "1"
  5567. fed.Insutype = his.Insutype
  5568. fed.ReimFlag = "0"
  5569. fed.OutSetlFlag = "0"
  5570. var fopd []*models.FsiOperationDtosData
  5571. data := make(map[string]interface{})
  5572. data["fed"] = fed
  5573. data["fdd"] = fdds
  5574. data["fod"] = orders
  5575. data["pd"] = pd
  5576. data["pp"] = pp
  5577. data["fopd"] = fopd
  5578. data["trig_scen"] = trig_scen
  5579. client := &http.Client{}
  5580. bytesData, _ := json.Marshal(data)
  5581. var req *http.Request
  5582. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5583. if miConfig.MdtrtareaAdmvs == "320921" {
  5584. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5585. } else {
  5586. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5587. }
  5588. resp, _ := client.Do(req)
  5589. defer resp.Body.Close()
  5590. body, ioErr := ioutil.ReadAll(resp.Body)
  5591. if ioErr != nil {
  5592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5594. return res
  5595. }
  5596. var respJSON map[string]interface{}
  5597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5600. return res
  5601. }
  5602. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5603. result, _ := json.Marshal(respJSON)
  5604. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5605. utils.ErrorLog("解析失败:%v", err)
  5606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5607. return res
  5608. }
  5609. return res
  5610. } else {
  5611. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5612. saveLog(output, input, "3102", "事中")
  5613. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5614. utils.ErrorLog("解析失败:%v", err)
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5616. return
  5617. }
  5618. return res
  5619. }
  5620. return res
  5621. }
  5622. 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) {
  5623. var res Resultgd3101
  5624. adminUser := c.GetAdminUserInfo()
  5625. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5626. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5627. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5628. //record_time := c.GetString("record_time")
  5629. //trig_scen := c.GetString("trig_scen")
  5630. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5631. timeLayout := "2006-01-02"
  5632. loc, _ := time.LoadLocation("Local")
  5633. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5634. if err != nil {
  5635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5636. return res
  5637. }
  5638. recordDateTime := theTime.Unix()
  5639. var patientPrescription models.HisPrescriptionInfo
  5640. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5641. //if patientPrescription.ID == 0 {
  5642. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5643. //}
  5644. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5645. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5646. //
  5647. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5648. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5649. var pp models.PublicParams
  5650. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5651. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5652. pp.FixmedinsName = miConfig.OrgName
  5653. pp.FixmedinsCode = miConfig.Code
  5654. pp.RequestUrl = miConfig.Url
  5655. pp.Cainfo = miConfig.Cainfo
  5656. pp.SecretKey = miConfig.SecretKey
  5657. pp.AccessKey = miConfig.AccessKey
  5658. pp.OpterName = roles.UserName
  5659. var config []*models.HisXtDiagnoseConfig
  5660. for _, item := range diagnosis_ids {
  5661. id, _ := strconv.ParseInt(item, 10, 64)
  5662. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5663. config = append(config, &diagnosisConfig)
  5664. }
  5665. var pd models.PatientDtos
  5666. pd.PatnID = his.PsnNo
  5667. pd.PatnName = his.Name
  5668. pd.Gend = his.Gend
  5669. pd.Brdy = psn_info.Brdy
  5670. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5671. pd.CurrMdtrtID = his.Number
  5672. var fed models.FsiEncounterDtos
  5673. fed.MdtrtID = his.Number
  5674. fed.MedinsID = miConfig.Code
  5675. fed.MedinsName = miConfig.OrgName
  5676. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5677. fed.MedMdtrtType = "1"
  5678. fed.MedinsType = "1"
  5679. fed.MedinsLv = "11"
  5680. tm := time.Unix(his.RecordDate, 0)
  5681. s_tm := tm.Format("2006-01-02 15:04:05")
  5682. fed.AdmDate = s_tm
  5683. fed.DscgDate = s_tm
  5684. fed.DscgMainDiseCodg = config[0].CountryCode
  5685. fed.DscgMainDiseName = config[0].CountryContentName
  5686. //诊断信息
  5687. var fdds []*models.FsiDiagnoseDtos
  5688. for index, item := range config {
  5689. if index == 0 {
  5690. var fdd models.FsiDiagnoseDtos
  5691. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5692. fdd.InoutDiseType = "1"
  5693. fdd.MaindiseFlag = "1"
  5694. fdd.DiseDate = s_tm
  5695. fdd.DiasSrtNo = "1"
  5696. fdd.DiseName = item.CountryContentName
  5697. fdd.DiseCodg = item.CountryCode
  5698. fdds = append(fdds, &fdd)
  5699. } else {
  5700. var fdd models.FsiDiagnoseDtos
  5701. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5702. fdd.InoutDiseType = "1"
  5703. fdd.MaindiseFlag = "1"
  5704. fdd.DiseDate = s_tm
  5705. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5706. fdd.DiseName = item.CountryContentName
  5707. fdd.DiseCodg = item.CountryCode
  5708. fdds = append(fdds, &fdd)
  5709. }
  5710. }
  5711. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5712. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5713. fed.AdmDeptName = department.Name
  5714. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5715. fed.DscgDeptName = department.Name
  5716. fed.MedMdtrtType = "1"
  5717. fed.MedType = "11"
  5718. //if his.Insutype == "390" {
  5719. // fed.MedType = "1402"
  5720. //} else {
  5721. // fed.MedType = "9933"
  5722. //}
  5723. var orders []*models.FsiOrderDtos
  5724. if trig_scen == "2" {
  5725. //处方医嘱信息
  5726. for _, item := range prescriptions {
  5727. for _, subItem := range item.HisDoctorAdviceInfo {
  5728. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5729. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  5730. var order models.FsiOrderDtos
  5731. order.RxID = strconv.FormatInt(item.ID, 10)
  5732. order.Rxno = strconv.FormatInt(item.ID, 10)
  5733. order.LongDrordFlag = "0"
  5734. order.HilistType = "1"
  5735. order.ChrgType = "1"
  5736. order.DrordBhvr = "0"
  5737. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5738. order.HosplistName = subItem.BaseDrugLib.DrugName
  5739. order.HilistLv = "1"
  5740. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5741. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5742. order.HosplistName = subItem.BaseDrugLib.DrugName
  5743. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5744. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5745. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5746. order.OwnpayAmt = ""
  5747. order.SelfpayAmt = ""
  5748. order.Spec = spec
  5749. order.SpecUnt = subItem.PrescribingNumberUnit
  5750. order.DrordBegnDate = s_tm
  5751. order.DrordStopDate = ""
  5752. order.DrordDrCodg = doctor_info.DoctorNumber
  5753. order.DrordDeptName = department.Name
  5754. order.DrordDeptCodg = department.Number
  5755. order.DrordDrName = doctor_info.UserName
  5756. order.DrordDrProfttl = "234"
  5757. order.CurrDrordFlag = "1"
  5758. orders = append(orders, &order)
  5759. }
  5760. }
  5761. for _, subItem := range item.HisPrescriptionProject {
  5762. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5763. var order models.FsiOrderDtos
  5764. order.RxID = strconv.FormatInt(item.ID, 10)
  5765. order.Rxno = strconv.FormatInt(item.ID, 10)
  5766. order.LongDrordFlag = "0"
  5767. order.HilistType = "1"
  5768. order.ChrgType = "1"
  5769. order.DrordBhvr = "0"
  5770. order.HilistCode = subItem.HisProject.MedicalCode
  5771. order.HosplistName = subItem.HisProject.ProjectName
  5772. order.HilistLv = "1"
  5773. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5774. order.HosplistCode = subItem.HisProject.MedicalCode
  5775. order.HosplistName = subItem.HisProject.ProjectName
  5776. order.Cnt = subItem.Count
  5777. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5778. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5779. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5780. order.OwnpayAmt = ""
  5781. order.SelfpayAmt = ""
  5782. order.Spec = subItem.Unit
  5783. order.SpecUnt = subItem.Unit
  5784. order.DrordBegnDate = s_tm
  5785. order.DrordStopDate = ""
  5786. order.DrordDrCodg = doctor_info.DoctorNumber
  5787. order.DrordDeptName = department.Name
  5788. order.DrordDeptCodg = department.Number
  5789. order.DrordDrName = doctor_info.UserName
  5790. order.DrordDrProfttl = "234"
  5791. order.CurrDrordFlag = "1"
  5792. orders = append(orders, &order)
  5793. }
  5794. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5795. var order models.FsiOrderDtos
  5796. order.RxID = strconv.FormatInt(item.ID, 10)
  5797. order.Rxno = strconv.FormatInt(item.ID, 10)
  5798. order.LongDrordFlag = "0"
  5799. order.HilistType = "1"
  5800. order.ChrgType = "1"
  5801. order.DrordBhvr = "0"
  5802. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5803. order.HosplistName = subItem.GoodInfo.GoodName
  5804. order.HilistLv = "1"
  5805. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5806. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5807. order.HosplistName = subItem.GoodInfo.GoodName
  5808. order.Cnt = subItem.Count
  5809. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5810. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5811. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5812. order.OwnpayAmt = ""
  5813. order.SelfpayAmt = ""
  5814. order.Spec = subItem.GoodInfo.SpecificationName
  5815. order.SpecUnt = subItem.Unit
  5816. order.DrordBegnDate = s_tm
  5817. order.DrordStopDate = ""
  5818. order.DrordDrCodg = doctor_info.DoctorNumber
  5819. order.DrordDeptName = department.Name
  5820. order.DrordDeptCodg = department.Number
  5821. order.DrordDrName = doctor_info.UserName
  5822. order.DrordDrProfttl = "234"
  5823. order.CurrDrordFlag = "1"
  5824. orders = append(orders, &order)
  5825. }
  5826. }
  5827. }
  5828. //处方医嘱信息
  5829. }
  5830. fed.MatnStas = "0"
  5831. fed.MedfeeSumamt = "0"
  5832. fed.OwnpayAmt = "0"
  5833. fed.SelfpayAmt = "0"
  5834. fed.AcctPayamt = "0"
  5835. fed.MaAmt = "0"
  5836. fed.HifpPayamt = "0"
  5837. fed.SetlTotlnum = "1"
  5838. fed.Insutype = his.Insutype
  5839. fed.ReimFlag = "0"
  5840. fed.OutSetlFlag = "0"
  5841. var fopd []*models.FsiOperationDtosData
  5842. data := make(map[string]interface{})
  5843. data["fed"] = fed
  5844. data["fdd"] = fdds
  5845. data["fod"] = orders
  5846. data["pd"] = pd
  5847. data["pp"] = pp
  5848. data["fopd"] = fopd
  5849. data["trig_scen"] = trig_scen
  5850. fmt.Println(data)
  5851. fmt.Println(fed)
  5852. fmt.Println(fdds)
  5853. fmt.Println(orders)
  5854. fmt.Println(pd)
  5855. fmt.Println(pp)
  5856. fmt.Println(fopd)
  5857. client := &http.Client{}
  5858. bytesData, _ := json.Marshal(data)
  5859. var req *http.Request
  5860. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5861. if miConfig.MdtrtareaAdmvs == "320921" {
  5862. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5863. } else {
  5864. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5865. }
  5866. resp, _ := client.Do(req)
  5867. defer resp.Body.Close()
  5868. body, ioErr := ioutil.ReadAll(resp.Body)
  5869. if ioErr != nil {
  5870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5872. return res
  5873. }
  5874. var respJSON map[string]interface{}
  5875. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. return res
  5879. }
  5880. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5881. fmt.Println(respJSON)
  5882. result, _ := json.Marshal(respJSON)
  5883. fmt.Println(result)
  5884. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5885. utils.ErrorLog("解析失败:%v", err)
  5886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5887. return res
  5888. }
  5889. return res
  5890. } else {
  5891. //if miConfig.MdtrtareaAdmvs == "441202" {
  5892. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5893. saveLog(output, input, "3101", "事前")
  5894. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5895. utils.ErrorLog("解析失败:%v", err)
  5896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5897. return
  5898. }
  5899. return res
  5900. //}
  5901. }
  5902. }
  5903. 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) {
  5904. adminUser := c.GetAdminUserInfo()
  5905. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5906. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5907. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5908. //record_time := c.GetString("record_time")
  5909. //trig_scen := c.GetString("trig_scen")
  5910. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5911. timeLayout := "2006-01-02"
  5912. loc, _ := time.LoadLocation("Local")
  5913. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5914. if err != nil {
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5916. return res
  5917. }
  5918. recordDateTime := theTime.Unix()
  5919. var patientPrescription models.HisPrescriptionInfo
  5920. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5921. if patientPrescription.ID == 0 {
  5922. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5923. }
  5924. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5925. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5926. //
  5927. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5928. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5929. var pp models.PublicParams
  5930. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5931. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5932. pp.FixmedinsName = miConfig.OrgName
  5933. pp.FixmedinsCode = miConfig.Code
  5934. pp.RequestUrl = miConfig.Url
  5935. pp.Cainfo = miConfig.Cainfo
  5936. pp.SecretKey = miConfig.SecretKey
  5937. pp.AccessKey = miConfig.AccessKey
  5938. pp.OpterName = roles.UserName
  5939. var config []*models.HisXtDiagnoseConfig
  5940. for _, item := range diagnosis_ids {
  5941. id, _ := strconv.ParseInt(item, 10, 64)
  5942. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5943. config = append(config, &diagnosisConfig)
  5944. }
  5945. var pd models.PatientDtos
  5946. pd.PatnID = his.PsnNo
  5947. pd.PatnName = his.Name
  5948. pd.Gend = his.Gend
  5949. pd.Brdy = psn_info.Brdy
  5950. pd.Poolarea = his.InsuplcAdmdvs
  5951. pd.CurrMdtrtID = his.Number
  5952. var fed models.FsiEncounterDtos
  5953. fed.MdtrtID = his.Number
  5954. fed.MedinsID = miConfig.Code
  5955. fed.MedinsName = miConfig.OrgName
  5956. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5957. fed.MedMdtrtType = "1"
  5958. fed.MedinsType = "1"
  5959. fed.MedinsLv = "11"
  5960. tm := time.Unix(his.RecordDate, 0)
  5961. s_tm := tm.Format("2006-01-02 15:04:05")
  5962. fed.AdmDate = s_tm
  5963. fed.DscgDate = s_tm
  5964. fed.DscgMainDiseCodg = config[0].CountryCode
  5965. fed.DscgMainDiseName = config[0].CountryContentName
  5966. //诊断信息
  5967. var fdds []*models.FsiDiagnoseDtos
  5968. for index, item := range config {
  5969. if index == 0 {
  5970. var fdd models.FsiDiagnoseDtos
  5971. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5972. fdd.InoutDiseType = "1"
  5973. fdd.MaindiseFlag = "1"
  5974. fdd.DiseDate = s_tm
  5975. fdd.DiasSrtNo = "1"
  5976. fdd.DiseName = item.CountryContentName
  5977. fdd.DiseCodg = item.CountryCode
  5978. fdds = append(fdds, &fdd)
  5979. } else {
  5980. var fdd models.FsiDiagnoseDtos
  5981. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5982. fdd.InoutDiseType = "1"
  5983. fdd.MaindiseFlag = "1"
  5984. fdd.DiseDate = s_tm
  5985. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5986. fdd.DiseName = item.CountryContentName
  5987. fdd.DiseCodg = item.CountryCode
  5988. fdds = append(fdds, &fdd)
  5989. }
  5990. }
  5991. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5992. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5993. fed.AdmDeptName = department.Name
  5994. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5995. fed.DscgDeptName = department.Name
  5996. fed.MedMdtrtType = "1"
  5997. fed.MedType = "11"
  5998. //if his.Insutype == "390" {
  5999. // fed.MedType = "1402"
  6000. //} else {
  6001. // fed.MedType = "9933"
  6002. //}
  6003. var orders []*models.FsiOrderDtos
  6004. if trig_scen == "2" {
  6005. //处方医嘱信息
  6006. for _, item := range prescriptions {
  6007. for _, subItem := range item.HisDoctorAdviceInfo {
  6008. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6009. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6010. var order models.FsiOrderDtos
  6011. order.RxID = strconv.FormatInt(item.ID, 10)
  6012. order.Rxno = strconv.FormatInt(item.ID, 10)
  6013. order.LongDrordFlag = "0"
  6014. order.HilistType = "1"
  6015. order.ChrgType = "1"
  6016. order.DrordBhvr = "0"
  6017. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6018. order.HosplistName = subItem.BaseDrugLib.DrugName
  6019. order.HilistLv = "1"
  6020. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6021. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6022. order.HosplistName = subItem.BaseDrugLib.DrugName
  6023. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6024. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6025. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6026. order.OwnpayAmt = ""
  6027. order.SelfpayAmt = ""
  6028. order.Spec = spec
  6029. order.SpecUnt = subItem.PrescribingNumberUnit
  6030. order.DrordBegnDate = s_tm
  6031. order.DrordStopDate = ""
  6032. order.DrordDrCodg = doctor_info.DoctorNumber
  6033. order.DrordDeptName = department.Name
  6034. order.DrordDeptCodg = department.Number
  6035. order.DrordDrName = doctor_info.UserName
  6036. order.DrordDrProfttl = "234"
  6037. order.CurrDrordFlag = "1"
  6038. orders = append(orders, &order)
  6039. }
  6040. }
  6041. for _, subItem := range item.HisPrescriptionProject {
  6042. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6043. var order models.FsiOrderDtos
  6044. order.RxID = strconv.FormatInt(item.ID, 10)
  6045. order.Rxno = strconv.FormatInt(item.ID, 10)
  6046. order.LongDrordFlag = "0"
  6047. order.HilistType = "1"
  6048. order.ChrgType = "1"
  6049. order.DrordBhvr = "0"
  6050. order.HilistCode = subItem.HisProject.MedicalCode
  6051. order.HosplistName = subItem.HisProject.ProjectName
  6052. order.HilistLv = "1"
  6053. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6054. order.HosplistCode = subItem.HisProject.MedicalCode
  6055. order.HosplistName = subItem.HisProject.ProjectName
  6056. order.Cnt = subItem.Count
  6057. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6058. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6059. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6060. order.OwnpayAmt = ""
  6061. order.SelfpayAmt = ""
  6062. order.Spec = subItem.Unit
  6063. order.SpecUnt = subItem.Unit
  6064. order.DrordBegnDate = s_tm
  6065. order.DrordStopDate = ""
  6066. order.DrordDrCodg = doctor_info.DoctorNumber
  6067. order.DrordDeptName = department.Name
  6068. order.DrordDeptCodg = department.Number
  6069. order.DrordDrName = doctor_info.UserName
  6070. order.DrordDrProfttl = "234"
  6071. order.CurrDrordFlag = "1"
  6072. orders = append(orders, &order)
  6073. }
  6074. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6075. var order models.FsiOrderDtos
  6076. order.RxID = strconv.FormatInt(item.ID, 10)
  6077. order.Rxno = strconv.FormatInt(item.ID, 10)
  6078. order.LongDrordFlag = "0"
  6079. order.HilistType = "1"
  6080. order.ChrgType = "1"
  6081. order.DrordBhvr = "0"
  6082. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6083. order.HosplistName = subItem.GoodInfo.GoodName
  6084. order.HilistLv = "1"
  6085. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6086. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6087. order.HosplistName = subItem.GoodInfo.GoodName
  6088. order.Cnt = subItem.Count
  6089. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6090. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6091. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6092. order.OwnpayAmt = ""
  6093. order.SelfpayAmt = ""
  6094. order.Spec = subItem.GoodInfo.SpecificationName
  6095. order.SpecUnt = subItem.Unit
  6096. order.DrordBegnDate = s_tm
  6097. order.DrordStopDate = ""
  6098. order.DrordDrCodg = doctor_info.DoctorNumber
  6099. order.DrordDeptName = department.Name
  6100. order.DrordDeptCodg = department.Number
  6101. order.DrordDrName = doctor_info.UserName
  6102. order.DrordDrProfttl = "234"
  6103. order.CurrDrordFlag = "1"
  6104. orders = append(orders, &order)
  6105. }
  6106. }
  6107. }
  6108. //处方医嘱信息
  6109. }
  6110. fed.MatnStas = "0"
  6111. fed.MedfeeSumamt = "0"
  6112. fed.OwnpayAmt = "0"
  6113. fed.SelfpayAmt = "0"
  6114. fed.AcctPayamt = "0"
  6115. fed.MaAmt = "0"
  6116. fed.HifpPayamt = "0"
  6117. fed.SetlTotlnum = "1"
  6118. fed.Insutype = his.Insutype
  6119. fed.ReimFlag = "0"
  6120. fed.OutSetlFlag = "0"
  6121. var fopd []*models.FsiOperationDtosData
  6122. data := make(map[string]interface{})
  6123. data["fed"] = fed
  6124. data["fdd"] = fdds
  6125. data["fod"] = orders
  6126. data["pd"] = pd
  6127. data["pp"] = pp
  6128. data["fopd"] = fopd
  6129. data["trig_scen"] = trig_scen
  6130. fmt.Println(data)
  6131. fmt.Println(fed)
  6132. fmt.Println(fdds)
  6133. fmt.Println(orders)
  6134. fmt.Println(pd)
  6135. fmt.Println(pp)
  6136. fmt.Println(fopd)
  6137. client := &http.Client{}
  6138. bytesData, _ := json.Marshal(data)
  6139. var req *http.Request
  6140. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6141. if miConfig.MdtrtareaAdmvs == "320921" {
  6142. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6143. } else {
  6144. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6145. }
  6146. resp, _ := client.Do(req)
  6147. defer resp.Body.Close()
  6148. body, ioErr := ioutil.ReadAll(resp.Body)
  6149. if ioErr != nil {
  6150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6152. return res
  6153. }
  6154. var respJSON map[string]interface{}
  6155. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return res
  6159. }
  6160. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6161. fmt.Println(respJSON)
  6162. result, _ := json.Marshal(respJSON)
  6163. fmt.Println(result)
  6164. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6165. utils.ErrorLog("解析失败:%v", err)
  6166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6167. return res
  6168. }
  6169. return res
  6170. } else {
  6171. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6172. saveLog(output, input, "3101", "事前")
  6173. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6174. utils.ErrorLog("解析失败:%v", err)
  6175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6176. return
  6177. }
  6178. return res
  6179. }
  6180. return res
  6181. }
  6182. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6183. ////patient_id, _ := c.GetInt64("patient_id")
  6184. //order_id, _ := c.GetInt64("order_id")
  6185. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6186. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6187. //trig_scen := c.GetString("trig_scen")
  6188. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6189. utils.ErrorLog("解析失败:%v", psn_info)
  6190. adminUser := c.GetAdminUserInfo()
  6191. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6192. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6193. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6194. record_time := c.GetString("record_time")
  6195. order, _ := service.GetHisOrderByID(order_id)
  6196. timeLayout := "2006-01-02"
  6197. loc, _ := time.LoadLocation("Local")
  6198. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6199. if err != nil {
  6200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6201. return
  6202. }
  6203. recordDateTime := theTime.Unix()
  6204. var patientPrescription models.HisPrescriptionInfo
  6205. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6206. if patientPrescription.ID == 0 {
  6207. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6208. }
  6209. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6210. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6211. //
  6212. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6213. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6214. var pp models.PublicParams
  6215. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6216. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6217. pp.FixmedinsName = miConfig.OrgName
  6218. pp.FixmedinsCode = miConfig.Code
  6219. pp.RequestUrl = miConfig.Url
  6220. pp.Cainfo = miConfig.Cainfo
  6221. pp.SecretKey = miConfig.SecretKey
  6222. pp.AccessKey = miConfig.AccessKey
  6223. pp.OpterName = roles.UserName
  6224. var config []*models.HisXtDiagnoseConfig
  6225. for _, item := range diagnosis_ids {
  6226. id, _ := strconv.ParseInt(item, 10, 64)
  6227. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6228. config = append(config, &diagnosisConfig)
  6229. }
  6230. var pd models.PatientDtos
  6231. pd.PatnID = his.PsnNo
  6232. pd.PatnName = his.Name
  6233. pd.Gend = his.Gend
  6234. pd.Brdy = psn_info.Brdy
  6235. pd.Poolarea = his.InsuplcAdmdvs
  6236. pd.CurrMdtrtID = his.Number
  6237. var fed models.FsiEncounterDtos
  6238. fed.MdtrtID = his.Number
  6239. fed.MedinsID = miConfig.Code
  6240. fed.MedinsName = miConfig.OrgName
  6241. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6242. fed.MedMdtrtType = "1"
  6243. fed.MedinsType = "1"
  6244. fed.MedinsLv = "11"
  6245. tm := time.Unix(his.RecordDate, 0)
  6246. s_tm := tm.Format("2006-01-02 15:04:05")
  6247. fed.AdmDate = s_tm
  6248. fed.DscgDate = s_tm
  6249. fed.DscgMainDiseCodg = config[0].CountryCode
  6250. fed.DscgMainDiseName = config[0].CountryContentName
  6251. //诊断信息
  6252. var fdds []*models.FsiDiagnoseDtos
  6253. for index, item := range config {
  6254. if index == 0 {
  6255. var fdd models.FsiDiagnoseDtos
  6256. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6257. fdd.InoutDiseType = "1"
  6258. fdd.MaindiseFlag = "1"
  6259. fdd.DiseDate = s_tm
  6260. fdd.DiasSrtNo = "1"
  6261. fdd.DiseName = item.CountryContentName
  6262. fdd.DiseCodg = item.CountryCode
  6263. fdds = append(fdds, &fdd)
  6264. } else {
  6265. var fdd models.FsiDiagnoseDtos
  6266. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6267. fdd.InoutDiseType = "1"
  6268. fdd.MaindiseFlag = "1"
  6269. fdd.DiseDate = s_tm
  6270. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6271. fdd.DiseName = item.CountryContentName
  6272. fdd.DiseCodg = item.CountryCode
  6273. fdds = append(fdds, &fdd)
  6274. }
  6275. }
  6276. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6277. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6278. fed.AdmDeptName = department.Name
  6279. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6280. fed.DscgDeptName = department.Name
  6281. fed.MedType = order.MedType
  6282. //处方医嘱信息
  6283. var orders []*models.FsiOrderDtos
  6284. //for _, item := range prescriptions {
  6285. // for _, subItem := range item.HisDoctorAdviceInfo {
  6286. // var order models.FsiOrderDtos
  6287. // order.RxID = strconv.FormatInt(item.ID, 10)
  6288. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6289. // order.LongDrordFlag = "0"
  6290. // order.HilistType = "1"
  6291. // order.ChrgType = "1"
  6292. // order.DrordBhvr = "-"
  6293. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6294. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6295. // order.HilistLv = "1"
  6296. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6297. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6298. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6299. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6300. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6301. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6302. // order.OwnpayAmt = ""
  6303. // order.SelfpayAmt = ""
  6304. // order.Spec = ""
  6305. // order.SpecUnt = ""
  6306. // order.DrordBegnDate = s_tm
  6307. // order.DrordStopDate = ""
  6308. // order.DrordDrCodg = "1"
  6309. // order.DrordDeptName = department.Name
  6310. // order.DrordDrCodg = "1"
  6311. // order.DrordDrName = doctor_info.UserName
  6312. // order.DrordDrProfttl = ""
  6313. // order.CurrDrordFlag = "1"
  6314. // orders = append(orders, &order)
  6315. // }
  6316. // for _, subItem := range item.HisPrescriptionProject {
  6317. // if subItem.Type == 2 {
  6318. // var order models.FsiOrderDtos
  6319. // order.RxID = strconv.FormatInt(item.ID, 10)
  6320. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6321. // order.LongDrordFlag = "0"
  6322. // order.HilistType = "1"
  6323. // order.ChrgType = "1"
  6324. // order.DrordBhvr = "-"
  6325. // order.HilistCode = subItem.HisProject.MedicalCode
  6326. // order.HosplistName = subItem.HisProject.ProjectName
  6327. // order.HilistLv = "1"
  6328. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6329. // order.HosplistCode = subItem.HisProject.MedicalCode
  6330. // order.HosplistName = subItem.HisProject.ProjectName
  6331. // order.Cnt = subItem.Count
  6332. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6333. //
  6334. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6335. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6336. // order.OwnpayAmt = ""
  6337. // order.SelfpayAmt = ""
  6338. // order.Spec = ""
  6339. // order.SpecUnt = ""
  6340. // order.DrordBegnDate = s_tm
  6341. // order.DrordStopDate = ""
  6342. // order.DrordDrCodg = "1"
  6343. // order.DrordDeptName = department.Name
  6344. // order.DrordDrCodg = "1"
  6345. // order.DrordDrName = doctor_info.UserName
  6346. // order.DrordDrProfttl = ""
  6347. // order.CurrDrordFlag = "1"
  6348. // orders = append(orders, &order)
  6349. //
  6350. // }
  6351. // if subItem.Type == 3 {
  6352. //
  6353. // var order models.FsiOrderDtos
  6354. // order.RxID = strconv.FormatInt(item.ID, 10)
  6355. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6356. // order.LongDrordFlag = "0"
  6357. // order.HilistType = "1"
  6358. // order.ChrgType = "1"
  6359. // order.DrordBhvr = "-"
  6360. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6361. // order.HosplistName = subItem.GoodInfo.GoodName
  6362. // order.HilistLv = "1"
  6363. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6364. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6365. // order.HosplistName = subItem.GoodInfo.GoodName
  6366. // order.Cnt = subItem.Count
  6367. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6368. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6369. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6370. // order.OwnpayAmt = ""
  6371. // order.SelfpayAmt = ""
  6372. // order.Spec = ""
  6373. // order.SpecUnt = ""
  6374. // order.DrordBegnDate = s_tm
  6375. // order.DrordStopDate = ""
  6376. // order.DrordDrCodg = "1"
  6377. // order.DrordDeptName = department.Name
  6378. // order.DrordDrCodg = "1"
  6379. // order.DrordDrName = doctor_info.UserName
  6380. // order.DrordDrProfttl = ""
  6381. // order.CurrDrordFlag = "1"
  6382. // orders = append(orders, &order)
  6383. //
  6384. // }
  6385. // }
  6386. //}
  6387. for _, item := range prescriptions {
  6388. for _, subItem := range item.HisDoctorAdviceInfo {
  6389. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6390. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6391. var order models.FsiOrderDtos
  6392. order.RxID = strconv.FormatInt(item.ID, 10)
  6393. order.Rxno = strconv.FormatInt(item.ID, 10)
  6394. order.LongDrordFlag = "0"
  6395. order.HilistType = "1"
  6396. order.ChrgType = "1"
  6397. order.DrordBhvr = "0"
  6398. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6399. order.HosplistName = subItem.BaseDrugLib.DrugName
  6400. order.HilistLv = "1"
  6401. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6402. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6403. order.HosplistName = subItem.BaseDrugLib.DrugName
  6404. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6405. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6406. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6407. order.OwnpayAmt = ""
  6408. order.SelfpayAmt = ""
  6409. order.Spec = spec
  6410. order.SpecUnt = subItem.PrescribingNumberUnit
  6411. order.DrordBegnDate = s_tm
  6412. order.DrordStopDate = ""
  6413. order.DrordDrCodg = doctor_info.DoctorNumber
  6414. order.DrordDeptName = department.Name
  6415. order.DrordDeptCodg = department.Number
  6416. order.DrordDrName = doctor_info.UserName
  6417. order.DrordDrProfttl = "234"
  6418. order.CurrDrordFlag = "1"
  6419. orders = append(orders, &order)
  6420. }
  6421. }
  6422. for _, subItem := range item.HisPrescriptionProject {
  6423. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6424. var order models.FsiOrderDtos
  6425. order.RxID = strconv.FormatInt(item.ID, 10)
  6426. order.Rxno = strconv.FormatInt(item.ID, 10)
  6427. order.LongDrordFlag = "0"
  6428. order.HilistType = "1"
  6429. order.ChrgType = "1"
  6430. order.DrordBhvr = "0"
  6431. order.HilistCode = subItem.HisProject.MedicalCode
  6432. order.HosplistName = subItem.HisProject.ProjectName
  6433. order.HilistLv = "1"
  6434. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6435. order.HosplistCode = subItem.HisProject.MedicalCode
  6436. order.HosplistName = subItem.HisProject.ProjectName
  6437. order.Cnt = subItem.Count
  6438. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6439. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6440. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6441. order.OwnpayAmt = ""
  6442. order.SelfpayAmt = ""
  6443. order.Spec = subItem.Unit
  6444. order.SpecUnt = subItem.Unit
  6445. order.DrordBegnDate = s_tm
  6446. order.DrordStopDate = ""
  6447. order.DrordDrCodg = doctor_info.DoctorNumber
  6448. order.DrordDeptName = department.Name
  6449. order.DrordDeptCodg = department.Number
  6450. order.DrordDrName = doctor_info.UserName
  6451. order.DrordDrProfttl = "234"
  6452. order.CurrDrordFlag = "1"
  6453. orders = append(orders, &order)
  6454. }
  6455. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6456. var order models.FsiOrderDtos
  6457. order.RxID = strconv.FormatInt(item.ID, 10)
  6458. order.Rxno = strconv.FormatInt(item.ID, 10)
  6459. order.LongDrordFlag = "0"
  6460. order.HilistType = "1"
  6461. order.ChrgType = "1"
  6462. order.DrordBhvr = "0"
  6463. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6464. order.HosplistName = subItem.GoodInfo.GoodName
  6465. order.HilistLv = "1"
  6466. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6467. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6468. order.HosplistName = subItem.GoodInfo.GoodName
  6469. order.Cnt = subItem.Count
  6470. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6471. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6472. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6473. order.OwnpayAmt = ""
  6474. order.SelfpayAmt = ""
  6475. order.Spec = subItem.GoodInfo.SpecificationName
  6476. order.SpecUnt = subItem.Unit
  6477. order.DrordBegnDate = s_tm
  6478. order.DrordStopDate = ""
  6479. order.DrordDrCodg = doctor_info.DoctorNumber
  6480. order.DrordDeptName = department.Name
  6481. order.DrordDeptCodg = department.Number
  6482. order.DrordDrName = doctor_info.UserName
  6483. order.DrordDrProfttl = "234"
  6484. order.CurrDrordFlag = "1"
  6485. orders = append(orders, &order)
  6486. }
  6487. }
  6488. }
  6489. //处方医嘱信息
  6490. fed.MatnStas = "0"
  6491. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6492. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6493. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6494. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6495. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6496. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6497. fed.SetlTotlnum = "1"
  6498. fed.Insutype = his.Insutype
  6499. fed.ReimFlag = "0"
  6500. fed.OutSetlFlag = "0"
  6501. var fopd []*models.FsiOperationDtosData
  6502. data := make(map[string]interface{})
  6503. data["fed"] = fed
  6504. data["fdd"] = fdds
  6505. data["fod"] = orders
  6506. data["pd"] = pd
  6507. data["pp"] = pp
  6508. data["fopd"] = fopd
  6509. data["trig_scen"] = trig_scen
  6510. client := &http.Client{}
  6511. bytesData, _ := json.Marshal(data)
  6512. var req *http.Request
  6513. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6514. if miConfig.MdtrtareaAdmvs == "320921" {
  6515. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6516. } else {
  6517. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6518. }
  6519. resp, _ := client.Do(req)
  6520. defer resp.Body.Close()
  6521. body, ioErr := ioutil.ReadAll(resp.Body)
  6522. if ioErr != nil {
  6523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6525. return res
  6526. }
  6527. var respJSON map[string]interface{}
  6528. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6531. return res
  6532. }
  6533. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6534. result, _ := json.Marshal(respJSON)
  6535. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6536. utils.ErrorLog("解析失败:%v", err)
  6537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6538. return res
  6539. }
  6540. return res
  6541. } else {
  6542. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6543. saveLog(output, input, "3102", "事中")
  6544. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6545. utils.ErrorLog("解析失败:%v", err)
  6546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6547. return
  6548. }
  6549. return res
  6550. }
  6551. return res
  6552. }
  6553. func (c *HisApiController) Check() {
  6554. psn_no := c.GetString("psn_no")
  6555. in := c.GetString("in")
  6556. mt := c.GetString("mt")
  6557. baseParams := models.BaseParams{
  6558. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6559. FixmedinsCode: "H15049901371",
  6560. InsuplcAdmdvs: "150499",
  6561. MdtrtareaAdmvs: "150499",
  6562. OrgName: "赤峰费森血液透析中心",
  6563. Doctor: "1111",
  6564. }
  6565. service.Gdyb2001(baseParams, psn_no, in, mt)
  6566. }
  6567. func (c *HisApiController) GetPsnNcdsInfo() {
  6568. admin_user_id, _ := c.GetInt64("admin_user_id")
  6569. patient_id, _ := c.GetInt64("patient_id")
  6570. id, _ := c.GetInt64("id")
  6571. adminUser := c.GetAdminUserInfo()
  6572. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6573. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6574. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6575. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6576. psn_record, _ := service.GetPsnNCDSRecordById(id)
  6577. //
  6578. //if psn_record.ID == 0 {
  6579. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6580. // return
  6581. //}
  6582. var res Result5301
  6583. var res10265 Result5301For10265
  6584. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6585. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6586. var api string
  6587. if miConfig.MdtrtareaAdmvs == "320921" {
  6588. 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 +
  6589. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6590. } else {
  6591. 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 +
  6592. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6593. }
  6594. resp, requestErr := http.Get(api)
  6595. if requestErr != nil {
  6596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6597. return
  6598. }
  6599. body, ioErr := ioutil.ReadAll(resp.Body)
  6600. if ioErr != nil {
  6601. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6603. return
  6604. }
  6605. var respJSON map[string]interface{}
  6606. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6607. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6609. return
  6610. }
  6611. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6612. result, _ := json.Marshal(respJSON)
  6613. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6614. utils.ErrorLog("解析失败:%v", err)
  6615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6616. return
  6617. }
  6618. res.ErrMsg = res10265.ErrMsg
  6619. res.Output = res10265.Output
  6620. res.InfRefmsgid = res10265.InfRefmsgid
  6621. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6622. res.Infcode = infocode
  6623. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6624. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6625. var api string
  6626. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6627. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6628. resp, requestErr := http.Get(api)
  6629. if requestErr != nil {
  6630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6631. return
  6632. }
  6633. body, ioErr := ioutil.ReadAll(resp.Body)
  6634. if ioErr != nil {
  6635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6637. return
  6638. }
  6639. var respJSON map[string]interface{}
  6640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6643. return
  6644. }
  6645. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6646. if status == "0" {
  6647. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6648. c.ServeSuccessJSON(map[string]interface{}{
  6649. "failed_code": -10,
  6650. "msg": err_msg,
  6651. })
  6652. return
  6653. }
  6654. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6655. result, _ := json.Marshal(respJSON)
  6656. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6657. utils.ErrorLog("解析失败:%v", err)
  6658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6659. return
  6660. }
  6661. } else if miConfig.MdtrtareaAdmvs == "360302" {
  6662. p, _ := service.GetHisPatientById(patient_id)
  6663. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6664. var dat map[string]interface{}
  6665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6666. fmt.Println(dat)
  6667. } else {
  6668. fmt.Println(err)
  6669. }
  6670. userJSONBytes, _ := json.Marshal(dat)
  6671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6672. utils.ErrorLog("解析失败:%v", err)
  6673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6674. return
  6675. }
  6676. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6677. p, _ := service.GetHisPatientById(patient_id)
  6678. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6679. var dat map[string]interface{}
  6680. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6681. fmt.Println(dat)
  6682. } else {
  6683. fmt.Println(err)
  6684. }
  6685. userJSONBytes, _ := json.Marshal(dat)
  6686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6687. utils.ErrorLog("解析失败:%v", err)
  6688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6689. return
  6690. }
  6691. } else if miConfig.MdtrtareaAdmvs == "420200" {
  6692. p, _ := service.GetHisPatientById(patient_id)
  6693. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6694. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6695. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6696. resp, requestErr := http.Get(api)
  6697. if requestErr != nil {
  6698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6699. return
  6700. }
  6701. body, ioErr := ioutil.ReadAll(resp.Body)
  6702. if ioErr != nil {
  6703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6705. return
  6706. }
  6707. var respJSON map[string]interface{}
  6708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6711. return
  6712. }
  6713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6714. result, _ := json.Marshal(respJSON)
  6715. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6716. utils.ErrorLog("解析失败:%v", err)
  6717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6718. return
  6719. }
  6720. } else if miConfig.MdtrtareaAdmvs == "421182" {
  6721. p, _ := service.GetHisPatientById(patient_id)
  6722. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  6723. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6724. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6725. resp, requestErr := http.Get(api)
  6726. if requestErr != nil {
  6727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6728. return
  6729. }
  6730. body, ioErr := ioutil.ReadAll(resp.Body)
  6731. if ioErr != nil {
  6732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6734. return
  6735. }
  6736. var respJSON map[string]interface{}
  6737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6740. return
  6741. }
  6742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6743. result, _ := json.Marshal(respJSON)
  6744. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6745. utils.ErrorLog("解析失败:%v", err)
  6746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6747. return
  6748. }
  6749. } else if miConfig.MdtrtareaAdmvs == "421300" {
  6750. p, _ := service.GetHisPatientById(patient_id)
  6751. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  6752. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6753. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6754. resp, requestErr := http.Get(api)
  6755. if requestErr != nil {
  6756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6757. return
  6758. }
  6759. body, ioErr := ioutil.ReadAll(resp.Body)
  6760. if ioErr != nil {
  6761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6763. return
  6764. }
  6765. var respJSON map[string]interface{}
  6766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6769. return
  6770. }
  6771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6772. result, _ := json.Marshal(respJSON)
  6773. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6774. utils.ErrorLog("解析失败:%v", err)
  6775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6776. return
  6777. }
  6778. } else if miConfig.MdtrtareaAdmvs == "441799" {
  6779. p, _ := service.GetHisPatientById(patient_id)
  6780. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  6781. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  6782. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  6783. resp, requestErr := http.Get(api)
  6784. if requestErr != nil {
  6785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6786. return
  6787. }
  6788. body, ioErr := ioutil.ReadAll(resp.Body)
  6789. if ioErr != nil {
  6790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6792. return
  6793. }
  6794. var respJSON map[string]interface{}
  6795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6798. return
  6799. }
  6800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6801. result, _ := json.Marshal(respJSON)
  6802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6803. utils.ErrorLog("解析失败:%v", err)
  6804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6805. return
  6806. }
  6807. } else {
  6808. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  6809. var dat map[string]interface{}
  6810. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6811. fmt.Println(dat)
  6812. } else {
  6813. fmt.Println(err)
  6814. }
  6815. userJSONBytes, _ := json.Marshal(dat)
  6816. if miConfig.Code == "H15049901371" {
  6817. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  6818. utils.ErrorLog("解析失败:%v", err)
  6819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6820. return
  6821. }
  6822. res.InfRefmsgid = res10265.InfRefmsgid
  6823. res.Output = res10265.Output
  6824. res.ErrMsg = res10265.ErrMsg
  6825. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6826. res.Infcode = infocode
  6827. } else {
  6828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6829. utils.ErrorLog("解析失败:%v", err)
  6830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6831. return
  6832. }
  6833. }
  6834. }
  6835. if res.Infcode == 0 {
  6836. c.ServeSuccessJSON(map[string]interface{}{
  6837. "result": res.Output.Result,
  6838. })
  6839. }
  6840. }
  6841. func (c *HisApiController) CheckInsutype() {
  6842. his_patient_id, _ := c.GetInt64("his_patient_id")
  6843. admin_user_id, _ := c.GetInt64("admin_user_id")
  6844. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6845. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6846. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6847. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  6848. var dat map[string]interface{}
  6849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6850. fmt.Println(dat)
  6851. } else {
  6852. fmt.Println(err)
  6853. }
  6854. userJSONBytes, _ := json.Marshal(dat)
  6855. var res Result90100
  6856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6857. utils.ErrorLog("解析失败:%v", err)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. return
  6860. }
  6861. if res.Infcode != 0 {
  6862. c.ServeSuccessJSON(map[string]interface{}{
  6863. "failed_code": -10,
  6864. "msg": res.ErrMsg,
  6865. })
  6866. return
  6867. } else {
  6868. fmt.Println(res)
  6869. }
  6870. }
  6871. func (c *HisApiController) CheckCardPWD() {
  6872. card_pwd := c.GetString("card_pwd")
  6873. his_patient_id, _ := c.GetInt64("his_patient_id")
  6874. admin_user_id, _ := c.GetInt64("admin_user_id")
  6875. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6876. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6877. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6878. psn, _ := service.GetPsnByPatientId(his.PatientId)
  6879. bas := strings.Split(psn.CardInfo, "|")
  6880. basNumber := bas[2]
  6881. if psn.InsuplcAdmdvs[:4] == "4403" {
  6882. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  6883. var dat map[string]interface{}
  6884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6885. fmt.Println(dat)
  6886. } else {
  6887. fmt.Println(err)
  6888. }
  6889. userJSONBytes, _ := json.Marshal(dat)
  6890. var res Result90991
  6891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6892. utils.ErrorLog("解析失败:%v", err)
  6893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6894. return
  6895. }
  6896. if res.Infcode != 0 {
  6897. c.ServeSuccessJSON(map[string]interface{}{
  6898. "failed_code": -10,
  6899. "msg": res.ErrMsg,
  6900. })
  6901. return
  6902. } else {
  6903. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  6904. var msg string
  6905. switch res.Output.Result.CardStat {
  6906. case "00":
  6907. msg = "未激活"
  6908. break
  6909. case "10":
  6910. msg = "激活"
  6911. break
  6912. case "20":
  6913. msg = "窗口挂失"
  6914. break
  6915. case "21":
  6916. msg = "电话挂失"
  6917. break
  6918. case "22":
  6919. msg = "单位网上申报挂失"
  6920. break
  6921. case "23":
  6922. msg = "保健办挂失"
  6923. break
  6924. case "24":
  6925. msg = "个人网上挂失"
  6926. break
  6927. case "25":
  6928. msg = "网上服务大厅挂失"
  6929. break
  6930. case "30":
  6931. msg = "注销"
  6932. break
  6933. case "40":
  6934. msg = "回收"
  6935. break
  6936. case "99":
  6937. msg = "制卡中(无效卡)"
  6938. break
  6939. }
  6940. c.ServeSuccessJSON(map[string]interface{}{
  6941. "failed_code": -10,
  6942. "msg": msg,
  6943. })
  6944. return
  6945. } else {
  6946. c.ServeSuccessJSON(map[string]interface{}{
  6947. "msg": "校验成功",
  6948. })
  6949. return
  6950. }
  6951. }
  6952. } else {
  6953. c.ServeSuccessJSON(map[string]interface{}{
  6954. "msg": "校验成功",
  6955. })
  6956. return
  6957. }
  6958. }
  6959. func (c *HisApiController) CheckCardPWDTwo() {
  6960. //card_pwd := c.GetString("card_pwd")
  6961. //his_patient_id, _ := c.GetInt64("his_patient_id")
  6962. admin_user_id, _ := c.GetInt64("admin_user_id")
  6963. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6964. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6965. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  6966. var dat map[string]interface{}
  6967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6968. fmt.Println(dat)
  6969. } else {
  6970. fmt.Println(err)
  6971. }
  6972. userJSONBytes, _ := json.Marshal(dat)
  6973. var res Result90991
  6974. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6975. utils.ErrorLog("解析失败:%v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. if res.Infcode != 0 {
  6980. c.ServeSuccessJSON(map[string]interface{}{
  6981. "failed_code": -10,
  6982. "msg": res.ErrMsg,
  6983. })
  6984. return
  6985. } else {
  6986. if res.Output.Result.SscnoCheckStat == "0" {
  6987. var msg string
  6988. switch res.Output.Result.CardStat {
  6989. case "00":
  6990. msg = "未激活"
  6991. break
  6992. case "10":
  6993. msg = "激活"
  6994. break
  6995. case "20":
  6996. msg = "窗口挂失"
  6997. break
  6998. case "21":
  6999. msg = "电话挂失"
  7000. break
  7001. case "22":
  7002. msg = "单位网上申报挂失"
  7003. break
  7004. case "23":
  7005. msg = "保健办挂失"
  7006. break
  7007. case "24":
  7008. msg = "个人网上挂失"
  7009. break
  7010. case "25":
  7011. msg = "网上服务大厅挂失"
  7012. break
  7013. case "30":
  7014. msg = "注销"
  7015. break
  7016. case "40":
  7017. msg = "回收"
  7018. break
  7019. case "99":
  7020. msg = "制卡中(无效卡)"
  7021. break
  7022. }
  7023. c.ServeSuccessJSON(map[string]interface{}{
  7024. "failed_code": -10,
  7025. "msg": msg,
  7026. })
  7027. return
  7028. } else {
  7029. c.ServeSuccessJSON(map[string]interface{}{
  7030. "msg": "校验成功",
  7031. })
  7032. return
  7033. }
  7034. }
  7035. }
  7036. type ELeCertData struct {
  7037. Data struct {
  7038. Extra string `json:"extra"`
  7039. IDNo string `json:"idNo"`
  7040. IDType string `json:"idType"`
  7041. EcToken string `json:"ecToken"`
  7042. InsuOrg string `json:"insuOrg"`
  7043. UserName string `json:"userName"`
  7044. EcIndexNo string `json:"ecIndexNo"`
  7045. Gender string `json:"gender"`
  7046. Birthday string `json:"birthday"`
  7047. Nationality string `json:"nationality"`
  7048. Email string `json:"email"`
  7049. } `json:"OutData"`
  7050. }
  7051. func (c *HisApiController) ReadCard() {
  7052. id_card_type, _ := c.GetInt64("id_card_type")
  7053. admin_user_id, _ := c.GetInt64("admin_user_id")
  7054. certificates, _ := c.GetInt64("certificates")
  7055. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7056. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7057. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7058. switch id_card_type {
  7059. case 1:
  7060. if miConfig.MdtrtareaAdmvs == "421300" {
  7061. var res ResultTwo
  7062. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7063. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7064. "&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)
  7065. resp, requestErr := http.Get(api)
  7066. if requestErr != nil {
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. body, ioErr := ioutil.ReadAll(resp.Body)
  7071. if ioErr != nil {
  7072. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7074. return
  7075. }
  7076. var respJSON map[string]interface{}
  7077. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7078. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7080. return
  7081. }
  7082. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7083. result, _ := json.Marshal(respJSON)
  7084. fmt.Println("log")
  7085. fmt.Println(string(result))
  7086. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7087. utils.ErrorLog("解析失败:%v", err)
  7088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7089. return
  7090. }
  7091. if res.Infcode == 0 {
  7092. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7093. if err == gorm.ErrRecordNotFound {
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7095. return
  7096. } else if err != nil {
  7097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7098. return
  7099. } else {
  7100. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7101. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7102. infoStr := string(Iinfos)
  7103. idetinfoStr := string(Idetinfos)
  7104. var rf []*ResultFive
  7105. json.Unmarshal([]byte(infoStr), &rf)
  7106. var insutypes []*ResultFive
  7107. var insutype string
  7108. var is390 int = 0
  7109. var is310 int = 0
  7110. for _, item := range rf {
  7111. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7112. insutypes = append(insutypes, item)
  7113. }
  7114. }
  7115. if len(insutypes) == 1 {
  7116. insutype = insutypes[0].Insutype
  7117. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7118. } else {
  7119. for _, i := range insutypes {
  7120. if i.Insutype == "390" {
  7121. is390 = 1
  7122. }
  7123. if i.Insutype == "310" {
  7124. is310 = 1
  7125. }
  7126. }
  7127. }
  7128. if is390 == 1 {
  7129. insutype = "390"
  7130. }
  7131. if is310 == 1 {
  7132. insutype = "310"
  7133. }
  7134. if len(insutypes) == 0 {
  7135. insutype = "390"
  7136. }
  7137. var insuplc_admdvs string
  7138. for _, item := range rf {
  7139. if item.Insutype == insutype {
  7140. insuplc_admdvs = item.InsuplcAdmdvs
  7141. }
  7142. }
  7143. if strings.Contains(insuplc_admdvs, "4213") {
  7144. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7145. }
  7146. psn := &models.HisPsn{
  7147. PsnNo: res.Output.Baseinfo.PsnNo,
  7148. PatientId: patient.ID,
  7149. Certno: res.Output.Baseinfo.Certno,
  7150. Gend: res.Output.Baseinfo.Gend,
  7151. Naty: res.Output.Baseinfo.Naty,
  7152. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7153. PsnName: res.Output.Baseinfo.PsnName,
  7154. Idetinfo: idetinfoStr,
  7155. Insuinfo: infoStr,
  7156. InsuplcAdmdvs: insuplc_admdvs,
  7157. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7158. }
  7159. service.CreateHisPsn(psn)
  7160. c.ServeSuccessJSON(map[string]interface{}{
  7161. "patient": patient,
  7162. "number": res.Output.Baseinfo.Certno,
  7163. })
  7164. }
  7165. } else {
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7167. return
  7168. }
  7169. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7170. var res ResultTwo
  7171. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7172. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7173. "&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)
  7174. resp, requestErr := http.Get(api)
  7175. if requestErr != nil {
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. body, ioErr := ioutil.ReadAll(resp.Body)
  7180. if ioErr != nil {
  7181. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7183. return
  7184. }
  7185. var respJSON map[string]interface{}
  7186. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7187. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7189. return
  7190. }
  7191. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7192. result, _ := json.Marshal(respJSON)
  7193. fmt.Println("log")
  7194. fmt.Println(string(result))
  7195. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7196. utils.ErrorLog("解析失败:%v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. if res.Infcode == 0 {
  7201. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7202. if err == gorm.ErrRecordNotFound {
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7204. return
  7205. } else if err != nil {
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7207. return
  7208. } else {
  7209. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7210. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7211. infoStr := string(Iinfos)
  7212. idetinfoStr := string(Idetinfos)
  7213. psn := &models.HisPsn{
  7214. PsnNo: res.Output.Baseinfo.PsnNo,
  7215. PatientId: patient.ID,
  7216. Certno: res.Output.Baseinfo.Certno,
  7217. Gend: res.Output.Baseinfo.Gend,
  7218. Naty: res.Output.Baseinfo.Naty,
  7219. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7220. PsnName: res.Output.Baseinfo.PsnName,
  7221. Idetinfo: idetinfoStr,
  7222. Insuinfo: infoStr,
  7223. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7224. }
  7225. service.CreateHisPsn(psn)
  7226. var rf []*ResultFive
  7227. json.Unmarshal([]byte(infoStr), &rf)
  7228. var insutypes []*ResultFive
  7229. var insutype string
  7230. var is390 int = 0
  7231. var is310 int = 0
  7232. for _, item := range rf {
  7233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7234. insutypes = append(insutypes, item)
  7235. }
  7236. }
  7237. if len(insutypes) == 1 {
  7238. insutype = insutypes[0].Insutype
  7239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7240. } else {
  7241. for _, i := range insutypes {
  7242. if i.Insutype == "390" {
  7243. is390 = 1
  7244. }
  7245. if i.Insutype == "310" {
  7246. is310 = 1
  7247. }
  7248. }
  7249. }
  7250. if is390 == 1 {
  7251. insutype = "390"
  7252. }
  7253. if is310 == 1 {
  7254. insutype = "310"
  7255. }
  7256. if len(insutypes) == 0 {
  7257. insutype = "310"
  7258. }
  7259. c.ServeSuccessJSON(map[string]interface{}{
  7260. "patient": patient,
  7261. "number": res.Output.Baseinfo.Certno,
  7262. "insutype": insutype,
  7263. })
  7264. }
  7265. } else {
  7266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7267. return
  7268. }
  7269. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7270. var res ResultTwo
  7271. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7272. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7273. "&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)
  7274. resp, requestErr := http.Get(api)
  7275. if requestErr != nil {
  7276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7277. return
  7278. }
  7279. body, ioErr := ioutil.ReadAll(resp.Body)
  7280. if ioErr != nil {
  7281. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7283. return
  7284. }
  7285. var respJSON map[string]interface{}
  7286. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7287. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. return
  7290. }
  7291. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7292. result, _ := json.Marshal(respJSON)
  7293. fmt.Println("log")
  7294. fmt.Println(string(result))
  7295. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7296. utils.ErrorLog("解析失败:%v", err)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. if res.Infcode == 0 {
  7301. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7302. if err == gorm.ErrRecordNotFound {
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7304. return
  7305. } else if err != nil {
  7306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7307. return
  7308. } else {
  7309. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7310. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7311. infoStr := string(Iinfos)
  7312. idetinfoStr := string(Idetinfos)
  7313. b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7314. psn := &models.HisPsn{
  7315. PsnNo: res.Output.Baseinfo.PsnNo,
  7316. PatientId: patient.ID,
  7317. Certno: res.Output.Baseinfo.Certno,
  7318. Brdy: b,
  7319. Age:float64(age),
  7320. Gend: res.Output.Baseinfo.Gend,
  7321. Naty: res.Output.Baseinfo.Naty,
  7322. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7323. PsnName: res.Output.Baseinfo.PsnName,
  7324. Idetinfo: idetinfoStr,
  7325. Insuinfo: infoStr,
  7326. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7327. }
  7328. service.CreateHisPsn(psn)
  7329. var rf []*ResultFive
  7330. json.Unmarshal([]byte(infoStr), &rf)
  7331. var insutypes []*ResultFive
  7332. var insutype string
  7333. var is390 int = 0
  7334. var is310 int = 0
  7335. for _, item := range rf {
  7336. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7337. insutypes = append(insutypes, item)
  7338. }
  7339. }
  7340. if len(insutypes) == 1 {
  7341. insutype = insutypes[0].Insutype
  7342. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7343. } else {
  7344. for _, i := range insutypes {
  7345. if i.Insutype == "390" {
  7346. is390 = 1
  7347. }
  7348. if i.Insutype == "310" {
  7349. is310 = 1
  7350. }
  7351. }
  7352. }
  7353. if is390 == 1 {
  7354. insutype = "390"
  7355. }
  7356. if is310 == 1 {
  7357. insutype = "310"
  7358. }
  7359. if len(insutypes) == 0 {
  7360. insutype = "310"
  7361. }
  7362. c.ServeSuccessJSON(map[string]interface{}{
  7363. "patient": patient,
  7364. "number": res.Output.Baseinfo.Certno,
  7365. "insutype": insutype,
  7366. })
  7367. }
  7368. } else {
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7370. return
  7371. }
  7372. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7373. var api string
  7374. if miConfig.MdtrtareaAdmvs == "320921" {
  7375. 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 +
  7376. "&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
  7377. fmt.Println(api)
  7378. } else {
  7379. 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 +
  7380. "&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)
  7381. }
  7382. resp, requestErr := http.Get(api)
  7383. if requestErr != nil {
  7384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7385. return
  7386. }
  7387. body, ioErr := ioutil.ReadAll(resp.Body)
  7388. if ioErr != nil {
  7389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. return
  7392. }
  7393. var respJSON map[string]interface{}
  7394. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7397. return
  7398. }
  7399. var status string
  7400. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7401. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7402. //console.log()
  7403. fmt.Println("type===")
  7404. fmt.Println(card_type)
  7405. var token string
  7406. var res ResultTwo //1101结果
  7407. var res10265 ResultTwo10265 //1101结果
  7408. var card_info string //卡信息
  7409. var busi_card_info string
  7410. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7411. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7412. if status == "0" { //读卡成功
  7413. if card_type == "1" {
  7414. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7415. result, _ := json.Marshal(respJSON)
  7416. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7417. utils.ErrorLog("解析失败:%v", err)
  7418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7419. return
  7420. }
  7421. res.ErrMsg = res10265.ErrMsg
  7422. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7423. res.Infcode = infocode
  7424. res.Output = res10265.Output
  7425. res.InfRefmsgid = res10265.InfRefmsgid
  7426. } else {
  7427. //var card_info string //卡信息
  7428. //var busi_card_info string
  7429. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7430. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7431. //fmt.Println(card_info)
  7432. //fmt.Println(busi_card_info)
  7433. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7434. result, _ := json.Marshal(respJSON)
  7435. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7436. utils.ErrorLog("解析失败:%v", err)
  7437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7438. return
  7439. }
  7440. res.ErrMsg = res10265.ErrMsg
  7441. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7442. res.Infcode = infocode
  7443. res.Output = res10265.Output
  7444. res.InfRefmsgid = res10265.InfRefmsgid
  7445. }
  7446. if res.Infcode == 0 {
  7447. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7448. if err == gorm.ErrRecordNotFound {
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7450. return
  7451. } else if err != nil {
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7453. return
  7454. } else {
  7455. if card_type == "1" {
  7456. bas := strings.Split(card_info, "|")
  7457. basNumber := bas[2]
  7458. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7459. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7460. infoStr := string(Iinfos)
  7461. idetinfoStr := string(Idetinfos)
  7462. b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7463. psn := &models.HisPsn{
  7464. PsnNo: res.Output.Baseinfo.PsnNo,
  7465. PatientId: patient.ID,
  7466. Certno: res.Output.Baseinfo.Certno,
  7467. Brdy: b,
  7468. Age:float64(age),
  7469. Gend: res.Output.Baseinfo.Gend,
  7470. Naty: res.Output.Baseinfo.Naty,
  7471. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7472. PsnName: res.Output.Baseinfo.PsnName,
  7473. Idetinfo: idetinfoStr,
  7474. Insuinfo: infoStr,
  7475. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7476. CardInfo: card_info,
  7477. VerifyNumber: busi_card_info,
  7478. }
  7479. service.CreateHisPsn(psn)
  7480. var rf []*ResultFive
  7481. json.Unmarshal([]byte(infoStr), &rf)
  7482. var insutypes []*ResultFive
  7483. var insutype string
  7484. var is390 int = 0
  7485. var is310 int = 0
  7486. for _, item := range rf {
  7487. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7488. insutypes = append(insutypes, item)
  7489. }
  7490. }
  7491. if len(insutypes) == 1 {
  7492. insutype = insutypes[0].Insutype
  7493. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7494. } else {
  7495. for _, i := range insutypes {
  7496. if i.Insutype == "390" {
  7497. is390 = 1
  7498. }
  7499. if i.Insutype == "310" {
  7500. is310 = 1
  7501. }
  7502. }
  7503. }
  7504. if is390 == 1 {
  7505. insutype = "390"
  7506. }
  7507. if is310 == 1 {
  7508. insutype = "310"
  7509. }
  7510. if len(insutypes) == 0 {
  7511. insutype = "310"
  7512. }
  7513. c.ServeSuccessJSON(map[string]interface{}{
  7514. "patient": patient,
  7515. "number": basNumber,
  7516. "insutype": insutype,
  7517. })
  7518. } else {
  7519. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7520. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7521. infoStr := string(Iinfos)
  7522. idetinfoStr := string(Idetinfos)
  7523. psn := &models.HisPsn{
  7524. PsnNo: res.Output.Baseinfo.PsnNo,
  7525. PatientId: patient.ID,
  7526. Certno: res.Output.Baseinfo.Certno,
  7527. Gend: res.Output.Baseinfo.Gend,
  7528. Naty: res.Output.Baseinfo.Naty,
  7529. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7530. PsnName: res.Output.Baseinfo.PsnName,
  7531. Idetinfo: idetinfoStr,
  7532. Insuinfo: infoStr,
  7533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7534. CardInfo: card_info,
  7535. VerifyNumber: token,
  7536. }
  7537. service.CreateHisPsn(psn)
  7538. c.ServeSuccessJSON(map[string]interface{}{
  7539. "patient": patient,
  7540. "number": token,
  7541. })
  7542. }
  7543. }
  7544. } else {
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7546. return
  7547. }
  7548. } else { //读卡失败
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7550. return
  7551. }
  7552. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7553. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  7554. cardnum = DeleteExtraSpaceTwo(cardnum)
  7555. cardCode = DeleteExtraSpaceTwo(cardCode)
  7556. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  7557. name = DeleteExtraSpaceTwo(name)
  7558. errmsg = DeleteExtraSpaceTwo(errmsg)
  7559. cardnum = Remove0000(cardnum)
  7560. cardCode = Remove0000(cardCode)
  7561. id_card_no = Remove0000(id_card_no)
  7562. name = Remove0000(name)
  7563. errmsg = Remove0000(errmsg)
  7564. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  7565. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  7566. //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)
  7567. //fmt.Println(result2)
  7568. //fmt.Println(requestLog2)
  7569. //fmt.Println(errMsgLog2)
  7570. 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)
  7571. saveLog(result, requestLog, "1101", "获取人员信息")
  7572. fmt.Println(errMsgLog)
  7573. if len(errMsgLog) > 0 {
  7574. } else {
  7575. var dat map[string]interface{}
  7576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7577. fmt.Println(dat)
  7578. } else {
  7579. fmt.Println(err)
  7580. }
  7581. userJSONBytes, _ := json.Marshal(dat)
  7582. var res ResultTwo
  7583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7584. utils.ErrorLog("解析失败:%v", err)
  7585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7586. return
  7587. }
  7588. res.ErrMsg = errMsgLog
  7589. if res.Infcode == 0 {
  7590. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  7591. if err == gorm.ErrRecordNotFound {
  7592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7593. return
  7594. } else if err != nil {
  7595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7596. return
  7597. } else {
  7598. fmt.Println(res)
  7599. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7600. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7601. infoStr := string(Iinfos)
  7602. idetinfoStr := string(Idetinfos)
  7603. var rf []*ResultFive
  7604. json.Unmarshal([]byte(infoStr), &rf)
  7605. var insutypes []*ResultFive
  7606. var insutype string
  7607. var is390 int = 0
  7608. var is310 int = 0
  7609. for _, item := range rf {
  7610. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7611. insutypes = append(insutypes, item)
  7612. }
  7613. }
  7614. if len(insutypes) == 1 {
  7615. insutype = insutypes[0].Insutype
  7616. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7617. } else {
  7618. for _, i := range insutypes {
  7619. if i.Insutype == "390" {
  7620. is390 = 1
  7621. }
  7622. if i.Insutype == "310" {
  7623. is310 = 1
  7624. }
  7625. }
  7626. }
  7627. if is390 == 1 {
  7628. insutype = "390"
  7629. }
  7630. if is310 == 1 {
  7631. insutype = "310"
  7632. }
  7633. if len(insutypes) == 0 {
  7634. insutype = "390"
  7635. }
  7636. var insuplc_admdvs string
  7637. for _, item := range rf {
  7638. if item.Insutype == insutype {
  7639. insuplc_admdvs = item.InsuplcAdmdvs
  7640. }
  7641. }
  7642. psn := &models.HisPsn{
  7643. PsnNo: res.Output.Baseinfo.PsnNo,
  7644. PatientId: patient.ID,
  7645. Certno: res.Output.Baseinfo.Certno,
  7646. Gend: res.Output.Baseinfo.Gend,
  7647. Naty: res.Output.Baseinfo.Naty,
  7648. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7649. PsnName: res.Output.Baseinfo.PsnName,
  7650. Idetinfo: idetinfoStr,
  7651. Insuinfo: infoStr,
  7652. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7653. CardInfo: basStr,
  7654. VerifyNumber: "",
  7655. InsuplcAdmdvs: insuplc_admdvs,
  7656. }
  7657. service.CreateHisPsn(psn)
  7658. c.ServeSuccessJSON(map[string]interface{}{
  7659. "patient": patient,
  7660. "number": cardnum,
  7661. "insutype": insutype,
  7662. })
  7663. }
  7664. } else {
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7666. return
  7667. }
  7668. }
  7669. } else if miConfig.MdtrtareaAdmvs == "360302" {
  7670. fmt.Println(initFlag)
  7671. fmt.Println("initFlag")
  7672. if initFlag == 0 {
  7673. c.TestGetJiangXiBasBaseInit()
  7674. }
  7675. basStr := c.GetBasBaseInfo()
  7676. if len(basStr) == 0 {
  7677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7678. return
  7679. }
  7680. fmt.Println(basStr)
  7681. bas := strings.Split(basStr, "|")
  7682. basNumber := bas[1]
  7683. fmt.Println(basNumber)
  7684. card_sn := bas[3]
  7685. fmt.Println(card_sn)
  7686. 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, "")
  7687. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7688. var dat map[string]interface{}
  7689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7690. fmt.Println(dat)
  7691. } else {
  7692. fmt.Println(err)
  7693. }
  7694. userJSONBytes, _ := json.Marshal(dat)
  7695. var res ResultTwo
  7696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7697. utils.ErrorLog("解析失败:%v", err)
  7698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7699. return
  7700. }
  7701. if res.Infcode == 0 {
  7702. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7703. if err == gorm.ErrRecordNotFound {
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7705. return
  7706. } else if err != nil {
  7707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7708. return
  7709. } else {
  7710. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7711. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7712. infoStr := string(Iinfos)
  7713. idetinfoStr := string(Idetinfos)
  7714. var rf []*ResultFive
  7715. json.Unmarshal([]byte(infoStr), &rf)
  7716. var insutypes []*ResultFive
  7717. var insutype string
  7718. var is390 int = 0
  7719. var is310 int = 0
  7720. var insuplc_admdvs string
  7721. for _, item := range rf {
  7722. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7723. insutypes = append(insutypes, item)
  7724. }
  7725. }
  7726. if len(insutypes) == 1 {
  7727. insutype = insutypes[0].Insutype
  7728. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7729. } else {
  7730. for _, i := range insutypes {
  7731. if i.Insutype == "390" {
  7732. is390 = 1
  7733. }
  7734. if i.Insutype == "310" {
  7735. is310 = 1
  7736. }
  7737. }
  7738. }
  7739. if is390 == 1 {
  7740. insutype = "390"
  7741. }
  7742. if is310 == 1 {
  7743. insutype = "310"
  7744. }
  7745. if len(insutypes) == 0 {
  7746. insutype = "310"
  7747. }
  7748. for _, item := range rf {
  7749. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  7750. insuplc_admdvs = item.InsuplcAdmdvs
  7751. }
  7752. }
  7753. psn := &models.HisPsn{
  7754. PsnNo: res.Output.Baseinfo.PsnNo,
  7755. PatientId: patient.ID,
  7756. Certno: res.Output.Baseinfo.Certno,
  7757. Gend: res.Output.Baseinfo.Gend,
  7758. Naty: res.Output.Baseinfo.Naty,
  7759. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7760. PsnName: res.Output.Baseinfo.PsnName,
  7761. Idetinfo: idetinfoStr,
  7762. Insuinfo: infoStr,
  7763. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7764. CardInfo: basStr,
  7765. InsuplcAdmdvs: insuplc_admdvs,
  7766. VerifyNumber: "",
  7767. }
  7768. service.CreateHisPsn(psn)
  7769. c.ServeSuccessJSON(map[string]interface{}{
  7770. "patient": patient,
  7771. "number": basNumber,
  7772. "insutype": insutype,
  7773. })
  7774. }
  7775. } else {
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7777. return
  7778. }
  7779. } else if miConfig.MdtrtareaAdmvs == "430800" {
  7780. fmt.Println(initFlag)
  7781. fmt.Println("initFlag")
  7782. if initFlag == 0 {
  7783. c.TestGetHnBasBaseInit()
  7784. }
  7785. basStr := c.GetBasBaseInfo()
  7786. if len(basStr) == 0 {
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  7788. return
  7789. }
  7790. fmt.Println(basStr)
  7791. bas := strings.Split(basStr, "|")
  7792. basNumber := bas[1]
  7793. fmt.Println(basNumber)
  7794. card_sn := bas[3]
  7795. card_no := bas[2]
  7796. fmt.Println(card_sn)
  7797. name := bas[4]
  7798. name = ConvertToString(name, "gbk", "utf-8")
  7799. 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)
  7800. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  7801. var dat map[string]interface{}
  7802. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7803. fmt.Println(dat)
  7804. } else {
  7805. fmt.Println(err)
  7806. }
  7807. userJSONBytes, _ := json.Marshal(dat)
  7808. var res ResultTwo
  7809. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. if res.Infcode == 0 {
  7815. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  7816. if err == gorm.ErrRecordNotFound {
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7818. return
  7819. } else if err != nil {
  7820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7821. return
  7822. } else {
  7823. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7824. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7825. infoStr := string(Iinfos)
  7826. idetinfoStr := string(Idetinfos)
  7827. psn := &models.HisPsn{
  7828. PsnNo: res.Output.Baseinfo.PsnNo,
  7829. PatientId: patient.ID,
  7830. Certno: res.Output.Baseinfo.Certno,
  7831. Gend: res.Output.Baseinfo.Gend,
  7832. Naty: res.Output.Baseinfo.Naty,
  7833. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7834. PsnName: res.Output.Baseinfo.PsnName,
  7835. Idetinfo: idetinfoStr,
  7836. Insuinfo: infoStr,
  7837. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7838. CardInfo: basStr,
  7839. VerifyNumber: "",
  7840. }
  7841. service.CreateHisPsn(psn)
  7842. var rf []*ResultFive
  7843. json.Unmarshal([]byte(infoStr), &rf)
  7844. var insutypes []*ResultFive
  7845. var insutype string
  7846. var is390 int = 0
  7847. var is310 int = 0
  7848. for _, item := range rf {
  7849. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7850. insutypes = append(insutypes, item)
  7851. }
  7852. }
  7853. if len(insutypes) == 1 {
  7854. insutype = insutypes[0].Insutype
  7855. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7856. } else {
  7857. for _, i := range insutypes {
  7858. if i.Insutype == "390" {
  7859. is390 = 1
  7860. }
  7861. if i.Insutype == "310" {
  7862. is310 = 1
  7863. }
  7864. }
  7865. }
  7866. if is390 == 1 {
  7867. insutype = "390"
  7868. }
  7869. if is310 == 1 {
  7870. insutype = "310"
  7871. }
  7872. if len(insutypes) == 0 {
  7873. insutype = "310"
  7874. }
  7875. c.ServeSuccessJSON(map[string]interface{}{
  7876. "patient": patient,
  7877. "number": basNumber,
  7878. "insutype": insutype,
  7879. })
  7880. }
  7881. } else {
  7882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7883. return
  7884. }
  7885. } else if miConfig.MdtrtareaAdmvs == "150499" {
  7886. var api string
  7887. 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 +
  7888. "&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
  7889. fmt.Println(api)
  7890. resp, requestErr := http.Get(api)
  7891. if requestErr != nil {
  7892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7893. return
  7894. }
  7895. body, ioErr := ioutil.ReadAll(resp.Body)
  7896. if ioErr != nil {
  7897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. var respJSON map[string]interface{}
  7902. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. var res ResultTwo //1101结果
  7908. var res10265 ResultTwo10265 //1101结果
  7909. var card_info string //卡信息
  7910. token := respJSON["data"].(map[string]interface{})["token"].(string)
  7911. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7912. result, _ := json.Marshal(respJSON)
  7913. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7914. utils.ErrorLog("解析失败:%v", err)
  7915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7916. return
  7917. }
  7918. res.ErrMsg = res10265.ErrMsg
  7919. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7920. res.Infcode = infocode
  7921. res.Output = res10265.Output
  7922. res.InfRefmsgid = res10265.InfRefmsgid
  7923. if res.Infcode == 0 {
  7924. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7925. if err == gorm.ErrRecordNotFound {
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7927. return
  7928. } else if err != nil {
  7929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7930. return
  7931. } else {
  7932. bas := strings.Split(card_info, "|")
  7933. basNumber := bas[2]
  7934. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7935. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7936. infoStr := string(Iinfos)
  7937. idetinfoStr := string(Idetinfos)
  7938. psn := &models.HisPsn{
  7939. PsnNo: res.Output.Baseinfo.PsnNo,
  7940. PatientId: patient.ID,
  7941. Certno: res.Output.Baseinfo.Certno,
  7942. Gend: res.Output.Baseinfo.Gend,
  7943. Naty: res.Output.Baseinfo.Naty,
  7944. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7945. PsnName: res.Output.Baseinfo.PsnName,
  7946. Idetinfo: idetinfoStr,
  7947. Insuinfo: infoStr,
  7948. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7949. CardInfo: card_info,
  7950. VerifyNumber: token,
  7951. }
  7952. service.CreateHisPsn(psn)
  7953. var rf []*ResultFive
  7954. json.Unmarshal([]byte(infoStr), &rf)
  7955. var insutypes []*ResultFive
  7956. var insutype string
  7957. var is390 int = 0
  7958. var is310 int = 0
  7959. for _, item := range rf {
  7960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7961. insutypes = append(insutypes, item)
  7962. }
  7963. }
  7964. if len(insutypes) == 1 {
  7965. insutype = insutypes[0].Insutype
  7966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7967. } else {
  7968. for _, i := range insutypes {
  7969. if i.Insutype == "390" {
  7970. is390 = 1
  7971. }
  7972. if i.Insutype == "310" {
  7973. is310 = 1
  7974. }
  7975. }
  7976. }
  7977. if is390 == 1 {
  7978. insutype = "390"
  7979. }
  7980. if is310 == 1 {
  7981. insutype = "310"
  7982. }
  7983. if len(insutypes) == 0 {
  7984. insutype = "310"
  7985. }
  7986. c.ServeSuccessJSON(map[string]interface{}{
  7987. "patient": patient,
  7988. "number": basNumber,
  7989. "insutype": insutype,
  7990. })
  7991. }
  7992. } else {
  7993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7994. return
  7995. }
  7996. } else if miConfig.MdtrtareaAdmvs == "450721" {
  7997. res := c.GetoleInfo()
  7998. if res.Infcode == 0 {
  7999. var result string
  8000. if res.Output.MdtrtCertType == "01" {
  8001. 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)
  8002. } else if res.Output.MdtrtCertType == "02" {
  8003. 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)
  8004. } else if res.Output.MdtrtCertType == "03" {
  8005. 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)
  8006. }
  8007. var dat map[string]interface{}
  8008. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8009. fmt.Println(dat)
  8010. } else {
  8011. fmt.Println(err)
  8012. }
  8013. userJSONBytes, _ := json.Marshal(dat)
  8014. var res2 ResultTwo
  8015. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8016. utils.ErrorLog("解析失败:%v", err)
  8017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8018. return
  8019. }
  8020. if res2.Infcode == 0 {
  8021. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8022. if err == gorm.ErrRecordNotFound {
  8023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8024. return
  8025. } else if err != nil {
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8027. return
  8028. } else {
  8029. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8030. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8031. infoStr := string(Iinfos)
  8032. idetinfoStr := string(Idetinfos)
  8033. var rf []*ResultFive
  8034. json.Unmarshal([]byte(infoStr), &rf)
  8035. var insutypes []*ResultFive
  8036. var insutype string
  8037. var is390 int = 0
  8038. var is310 int = 0
  8039. //var insuplc_admdvs string
  8040. for _, item := range rf {
  8041. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8042. insutypes = append(insutypes, item)
  8043. }
  8044. }
  8045. if len(insutypes) == 1 {
  8046. insutype = insutypes[0].Insutype
  8047. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8048. } else {
  8049. for _, i := range insutypes {
  8050. if i.Insutype == "390" {
  8051. is390 = 1
  8052. }
  8053. if i.Insutype == "310" {
  8054. is310 = 1
  8055. }
  8056. }
  8057. }
  8058. if is390 == 1 {
  8059. insutype = "390"
  8060. }
  8061. if is310 == 1 {
  8062. insutype = "310"
  8063. }
  8064. if len(insutypes) == 0 {
  8065. insutype = "310"
  8066. }
  8067. psn := &models.HisPsn{
  8068. PsnNo: res2.Output.Baseinfo.PsnNo,
  8069. PatientId: patient.ID,
  8070. Certno: res2.Output.Baseinfo.Certno,
  8071. Gend: res2.Output.Baseinfo.Gend,
  8072. Naty: res2.Output.Baseinfo.Naty,
  8073. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8074. PsnName: res2.Output.Baseinfo.PsnName,
  8075. Idetinfo: idetinfoStr,
  8076. Insuinfo: infoStr,
  8077. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8078. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8079. VerifyNumber: res.Output.EcToken,
  8080. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8081. }
  8082. if res.Output.MdtrtCertType == "01" {
  8083. psn.VerifyNumber = res.Output.EcToken
  8084. //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)
  8085. } else if res.Output.MdtrtCertType == "02" {
  8086. psn.VerifyNumber = res.Output.MdtrtCertNo
  8087. //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)
  8088. } else if res.Output.MdtrtCertType == "03" {
  8089. psn.VerifyNumber = res.Output.MdtrtCertNo
  8090. //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)
  8091. }
  8092. var balc float64
  8093. for _, item := range rf {
  8094. if item.Insutype == insutype {
  8095. balc = item.Balc
  8096. }
  8097. }
  8098. service.CreateHisPsn(psn)
  8099. c.ServeSuccessJSON(map[string]interface{}{
  8100. "patient": patient,
  8101. "number": res.Output.CardNo,
  8102. "insutype": insutype,
  8103. "blac": balc,
  8104. "desc": idetinfoStr,
  8105. })
  8106. }
  8107. } else {
  8108. c.ServeSuccessJSON(map[string]interface{}{
  8109. "failed_code": -10,
  8110. "msg": res2.ErrMsg,
  8111. })
  8112. }
  8113. } else {
  8114. c.ServeSuccessJSON(map[string]interface{}{
  8115. "failed_code": -10,
  8116. "msg": res.ErrMsg,
  8117. })
  8118. }
  8119. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8120. var api string
  8121. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8122. "&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
  8123. fmt.Println(api)
  8124. resp, requestErr := http.Get(api)
  8125. if requestErr != nil {
  8126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8127. return
  8128. }
  8129. body, ioErr := ioutil.ReadAll(resp.Body)
  8130. if ioErr != nil {
  8131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8133. return
  8134. }
  8135. var respJSON map[string]interface{}
  8136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8139. return
  8140. }
  8141. var status string
  8142. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8143. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8144. //console.log()
  8145. fmt.Println("type===")
  8146. fmt.Println(card_type)
  8147. var token string
  8148. var res ResultTwo //1101结果
  8149. //var res10265 ResultTwoesultTwo10265 //1101结果
  8150. var card_info string //卡信息
  8151. var busi_card_info string
  8152. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8153. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8154. if status == "0" { //读卡成功
  8155. if card_type == "1" {
  8156. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8157. result, _ := json.Marshal(respJSON)
  8158. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8159. utils.ErrorLog("解析失败:%v", err)
  8160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8161. return
  8162. }
  8163. } else {
  8164. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8165. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8166. result, _ := json.Marshal(respJSON)
  8167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8168. utils.ErrorLog("解析失败:%v", err)
  8169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8170. return
  8171. }
  8172. }
  8173. if res.Infcode == 0 {
  8174. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8175. if err == gorm.ErrRecordNotFound {
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8177. return
  8178. } else if err != nil {
  8179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8180. return
  8181. } else {
  8182. if card_type == "1" {
  8183. bas := strings.Split(card_info, "|")
  8184. basNumber := bas[2]
  8185. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8186. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8187. infoStr := string(Iinfos)
  8188. idetinfoStr := string(Idetinfos)
  8189. psn := &models.HisPsn{
  8190. PsnNo: res.Output.Baseinfo.PsnNo,
  8191. PatientId: patient.ID,
  8192. Certno: res.Output.Baseinfo.Certno,
  8193. Gend: res.Output.Baseinfo.Gend,
  8194. Naty: res.Output.Baseinfo.Naty,
  8195. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8196. PsnName: res.Output.Baseinfo.PsnName,
  8197. Idetinfo: idetinfoStr,
  8198. Insuinfo: infoStr,
  8199. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8200. CardInfo: card_info,
  8201. VerifyNumber: busi_card_info,
  8202. }
  8203. service.CreateHisPsn(psn)
  8204. var rf []*ResultFive
  8205. json.Unmarshal([]byte(infoStr), &rf)
  8206. var insutypes []*ResultFive
  8207. var insutype string
  8208. var is390 int = 0
  8209. var is310 int = 0
  8210. for _, item := range rf {
  8211. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8212. insutypes = append(insutypes, item)
  8213. }
  8214. }
  8215. if len(insutypes) == 1 {
  8216. insutype = insutypes[0].Insutype
  8217. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8218. } else {
  8219. for _, i := range insutypes {
  8220. if i.Insutype == "390" {
  8221. is390 = 1
  8222. }
  8223. if i.Insutype == "310" {
  8224. is310 = 1
  8225. }
  8226. }
  8227. }
  8228. if is390 == 1 {
  8229. insutype = "390"
  8230. }
  8231. if is310 == 1 {
  8232. insutype = "310"
  8233. }
  8234. if len(insutypes) == 0 {
  8235. insutype = "310"
  8236. }
  8237. c.ServeSuccessJSON(map[string]interface{}{
  8238. "patient": patient,
  8239. "number": basNumber,
  8240. "insutype": insutype,
  8241. })
  8242. } else {
  8243. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8244. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8245. infoStr := string(Iinfos)
  8246. idetinfoStr := string(Idetinfos)
  8247. psn := &models.HisPsn{
  8248. PsnNo: res.Output.Baseinfo.PsnNo,
  8249. PatientId: patient.ID,
  8250. Certno: res.Output.Baseinfo.Certno,
  8251. Gend: res.Output.Baseinfo.Gend,
  8252. Naty: res.Output.Baseinfo.Naty,
  8253. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8254. PsnName: res.Output.Baseinfo.PsnName,
  8255. Idetinfo: idetinfoStr,
  8256. Insuinfo: infoStr,
  8257. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8258. CardInfo: card_info,
  8259. VerifyNumber: token,
  8260. }
  8261. service.CreateHisPsn(psn)
  8262. c.ServeSuccessJSON(map[string]interface{}{
  8263. "patient": patient,
  8264. "number": token,
  8265. })
  8266. }
  8267. }
  8268. } else {
  8269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8270. return
  8271. }
  8272. } else { //读卡失败
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8274. return
  8275. }
  8276. } else {
  8277. if initFlag == 0 {
  8278. c.TestGetBasBaseInit()
  8279. }
  8280. basStr := c.GetBasBaseInfo()
  8281. if len(basStr) == 0 {
  8282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8283. return
  8284. }
  8285. fmt.Println(basStr)
  8286. bas := strings.Split(basStr, "|")
  8287. basNumber := bas[1]
  8288. fmt.Println(basNumber)
  8289. card_sn := bas[3]
  8290. fmt.Println(card_sn)
  8291. cardNumber := bas[2]
  8292. fmt.Println(cardNumber)
  8293. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8294. var result string
  8295. if bas[0][:2] == "44" {
  8296. 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)
  8297. } else {
  8298. 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)
  8299. }
  8300. var dat map[string]interface{}
  8301. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8302. fmt.Println(dat)
  8303. } else {
  8304. fmt.Println(err)
  8305. }
  8306. userJSONBytes, _ := json.Marshal(dat)
  8307. var res ResultTwo
  8308. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8309. utils.ErrorLog("解析失败:%v", err)
  8310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8311. return
  8312. }
  8313. if res.Infcode == 0 {
  8314. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8315. if err == gorm.ErrRecordNotFound {
  8316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8317. return
  8318. } else if err != nil {
  8319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8320. return
  8321. } else {
  8322. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8323. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8324. infoStr := string(Iinfos)
  8325. idetinfoStr := string(Idetinfos)
  8326. var rf []*ResultFive
  8327. json.Unmarshal([]byte(infoStr), &rf)
  8328. var insutypes []*ResultFive
  8329. var insutype string
  8330. var is390 int = 0
  8331. var is310 int = 0
  8332. var insuplc_admdvs string
  8333. for _, item := range rf {
  8334. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8335. insutypes = append(insutypes, item)
  8336. }
  8337. }
  8338. if len(insutypes) == 1 {
  8339. insutype = insutypes[0].Insutype
  8340. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8341. } else {
  8342. for _, i := range insutypes {
  8343. if i.Insutype == "390" {
  8344. is390 = 1
  8345. }
  8346. if i.Insutype == "310" {
  8347. is310 = 1
  8348. }
  8349. }
  8350. }
  8351. if is390 == 1 {
  8352. insutype = "390"
  8353. }
  8354. if is310 == 1 {
  8355. insutype = "310"
  8356. }
  8357. if len(insutypes) == 0 {
  8358. insutype = "310"
  8359. }
  8360. for _, item := range rf {
  8361. if item.Insutype == insutype {
  8362. insuplc_admdvs = item.InsuplcAdmdvs
  8363. }
  8364. }
  8365. psn := &models.HisPsn{
  8366. PsnNo: res.Output.Baseinfo.PsnNo,
  8367. PatientId: patient.ID,
  8368. Certno: res.Output.Baseinfo.Certno,
  8369. Gend: res.Output.Baseinfo.Gend,
  8370. Naty: res.Output.Baseinfo.Naty,
  8371. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8372. PsnName: res.Output.Baseinfo.PsnName,
  8373. Idetinfo: idetinfoStr,
  8374. Insuinfo: infoStr,
  8375. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8376. CardInfo: basStr,
  8377. VerifyNumber: "",
  8378. InsuplcAdmdvs: insuplc_admdvs,
  8379. }
  8380. service.CreateHisPsn(psn)
  8381. c.ServeSuccessJSON(map[string]interface{}{
  8382. "patient": patient,
  8383. "number": basNumber,
  8384. })
  8385. }
  8386. } else {
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8388. return
  8389. }
  8390. break
  8391. }
  8392. case 2:
  8393. if miConfig.MdtrtareaAdmvs == "430800" {
  8394. if initFlag == 0 {
  8395. c.TestGetHnBasBaseInit()
  8396. }
  8397. SFZStr := c.GetSFZBaseInfo()
  8398. if len(SFZStr) == 0 {
  8399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8400. return
  8401. }
  8402. fmt.Println(SFZStr)
  8403. id_card_str := strings.Split(SFZStr, "^")
  8404. card_no := id_card_str[0]
  8405. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8406. //name := id_card_str[1]
  8407. //name = ConvertToString(name, "gbk", "utf-8")
  8408. 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)
  8409. var dat map[string]interface{}
  8410. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8411. fmt.Println(dat)
  8412. } else {
  8413. fmt.Println(err)
  8414. }
  8415. userJSONBytes, _ := json.Marshal(dat)
  8416. var res ResultTwo
  8417. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8418. utils.ErrorLog("解析失败:%v", err)
  8419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8420. return
  8421. }
  8422. if res.Infcode == 0 {
  8423. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8424. if err == gorm.ErrRecordNotFound {
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8426. return
  8427. } else if err != nil {
  8428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8429. return
  8430. } else {
  8431. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8432. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8433. infoStr := string(Iinfos)
  8434. idetinfoStr := string(Idetinfos)
  8435. var rf []*ResultFive
  8436. json.Unmarshal([]byte(infoStr), &rf)
  8437. var insutypes []*ResultFive
  8438. var insutype string
  8439. var is390 int = 0
  8440. var is310 int = 0
  8441. for _, item := range rf {
  8442. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8443. insutypes = append(insutypes, item)
  8444. }
  8445. }
  8446. if len(insutypes) == 1 {
  8447. insutype = insutypes[0].Insutype
  8448. } else {
  8449. for _, i := range insutypes {
  8450. if i.Insutype == "390" {
  8451. is390 = 1
  8452. }
  8453. if i.Insutype == "310" {
  8454. is310 = 1
  8455. }
  8456. }
  8457. }
  8458. if is390 == 1 {
  8459. insutype = "390"
  8460. }
  8461. if is310 == 1 {
  8462. insutype = "310"
  8463. }
  8464. if len(insutypes) == 0 {
  8465. insutype = "310"
  8466. }
  8467. var InsuplcAdmdvs string
  8468. for _, item := range rf {
  8469. if item.Insutype == insutype {
  8470. InsuplcAdmdvs = item.InsuplcAdmdvs
  8471. }
  8472. }
  8473. psn := &models.HisPsn{
  8474. PsnNo: res.Output.Baseinfo.PsnNo,
  8475. PatientId: patient.ID,
  8476. Certno: res.Output.Baseinfo.Certno,
  8477. Gend: res.Output.Baseinfo.Gend,
  8478. Naty: res.Output.Baseinfo.Naty,
  8479. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8480. PsnName: res.Output.Baseinfo.PsnName,
  8481. Idetinfo: idetinfoStr,
  8482. Insuinfo: infoStr,
  8483. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8484. CardInfo: SFZStr,
  8485. VerifyNumber: "",
  8486. InsuplcAdmdvs: InsuplcAdmdvs,
  8487. }
  8488. service.CreateHisPsn(psn)
  8489. c.ServeSuccessJSON(map[string]interface{}{
  8490. "patient": patient,
  8491. "number": card_no,
  8492. "insutype": insutype,
  8493. })
  8494. }
  8495. } else {
  8496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8497. return
  8498. }
  8499. } else if miConfig.MdtrtareaAdmvs == "420200" {
  8500. var res ResultTwo
  8501. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  8502. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8503. "&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)
  8504. resp, requestErr := http.Get(api)
  8505. if requestErr != nil {
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. body, ioErr := ioutil.ReadAll(resp.Body)
  8510. if ioErr != nil {
  8511. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8513. return
  8514. }
  8515. var respJSON map[string]interface{}
  8516. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8517. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8522. result, _ := json.Marshal(respJSON)
  8523. fmt.Println("log")
  8524. fmt.Println(string(result))
  8525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. if res.Infcode == 0 {
  8531. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8532. if err == gorm.ErrRecordNotFound {
  8533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8534. return
  8535. } else if err != nil {
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8537. return
  8538. } else {
  8539. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8540. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8541. infoStr := string(Iinfos)
  8542. idetinfoStr := string(Idetinfos)
  8543. psn := &models.HisPsn{
  8544. PsnNo: res.Output.Baseinfo.PsnNo,
  8545. PatientId: patient.ID,
  8546. Certno: res.Output.Baseinfo.Certno,
  8547. Gend: res.Output.Baseinfo.Gend,
  8548. Naty: res.Output.Baseinfo.Naty,
  8549. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8550. PsnName: res.Output.Baseinfo.PsnName,
  8551. Idetinfo: idetinfoStr,
  8552. Insuinfo: infoStr,
  8553. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8554. }
  8555. service.CreateHisPsn(psn)
  8556. c.ServeSuccessJSON(map[string]interface{}{
  8557. "patient": patient,
  8558. "number": res.Output.Baseinfo.Certno,
  8559. })
  8560. }
  8561. } else {
  8562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8563. return
  8564. }
  8565. } else if miConfig.MdtrtareaAdmvs == "421182" {
  8566. var res ResultTwo
  8567. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  8568. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8569. "&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)
  8570. resp, requestErr := http.Get(api)
  8571. if requestErr != nil {
  8572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8573. return
  8574. }
  8575. body, ioErr := ioutil.ReadAll(resp.Body)
  8576. if ioErr != nil {
  8577. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8579. return
  8580. }
  8581. var respJSON map[string]interface{}
  8582. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8585. return
  8586. }
  8587. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8588. result, _ := json.Marshal(respJSON)
  8589. fmt.Println("log")
  8590. fmt.Println(string(result))
  8591. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8592. utils.ErrorLog("解析失败:%v", err)
  8593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8594. return
  8595. }
  8596. if res.Infcode == 0 {
  8597. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8598. if err == gorm.ErrRecordNotFound {
  8599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8600. return
  8601. } else if err != nil {
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8603. return
  8604. } else {
  8605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8607. infoStr := string(Iinfos)
  8608. idetinfoStr := string(Idetinfos)
  8609. psn := &models.HisPsn{
  8610. PsnNo: res.Output.Baseinfo.PsnNo,
  8611. PatientId: patient.ID,
  8612. Certno: res.Output.Baseinfo.Certno,
  8613. Gend: res.Output.Baseinfo.Gend,
  8614. Naty: res.Output.Baseinfo.Naty,
  8615. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8616. PsnName: res.Output.Baseinfo.PsnName,
  8617. Idetinfo: idetinfoStr,
  8618. Insuinfo: infoStr,
  8619. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8620. }
  8621. service.CreateHisPsn(psn)
  8622. c.ServeSuccessJSON(map[string]interface{}{
  8623. "patient": patient,
  8624. "number": res.Output.Baseinfo.Certno,
  8625. })
  8626. }
  8627. } else {
  8628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8629. return
  8630. }
  8631. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8632. res := c.GetoleInfo()
  8633. if res.Infcode == 0 {
  8634. var result string
  8635. if res.Output.MdtrtCertType == "01" {
  8636. 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)
  8637. } else if res.Output.MdtrtCertType == "02" {
  8638. 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)
  8639. } else if res.Output.MdtrtCertType == "03" {
  8640. 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)
  8641. }
  8642. var dat map[string]interface{}
  8643. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8644. fmt.Println(dat)
  8645. } else {
  8646. fmt.Println(err)
  8647. }
  8648. userJSONBytes, _ := json.Marshal(dat)
  8649. var res2 ResultTwo
  8650. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8651. utils.ErrorLog("解析失败:%v", err)
  8652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8653. return
  8654. }
  8655. if res2.Infcode == 0 {
  8656. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  8657. if err == gorm.ErrRecordNotFound {
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8659. return
  8660. } else if err != nil {
  8661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8662. return
  8663. } else {
  8664. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  8665. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8666. infoStr := string(Iinfos)
  8667. idetinfoStr := string(Idetinfos)
  8668. var rf []*ResultFive
  8669. json.Unmarshal([]byte(infoStr), &rf)
  8670. var insutypes []*ResultFive
  8671. var insutype string
  8672. var is390 int = 0
  8673. var is310 int = 0
  8674. //var insuplc_admdvs string
  8675. for _, item := range rf {
  8676. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8677. insutypes = append(insutypes, item)
  8678. }
  8679. }
  8680. if len(insutypes) == 1 {
  8681. insutype = insutypes[0].Insutype
  8682. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8683. } else {
  8684. for _, i := range insutypes {
  8685. if i.Insutype == "390" {
  8686. is390 = 1
  8687. }
  8688. if i.Insutype == "310" {
  8689. is310 = 1
  8690. }
  8691. }
  8692. }
  8693. if is390 == 1 {
  8694. insutype = "390"
  8695. }
  8696. if is310 == 1 {
  8697. insutype = "310"
  8698. }
  8699. if len(insutypes) == 0 {
  8700. insutype = "310"
  8701. }
  8702. psn := &models.HisPsn{
  8703. PsnNo: res2.Output.Baseinfo.PsnNo,
  8704. PatientId: patient.ID,
  8705. //Brdy: res2.Output.Baseinfo.Brdy,
  8706. Certno: res2.Output.Baseinfo.Certno,
  8707. Gend: res2.Output.Baseinfo.Gend,
  8708. Naty: res2.Output.Baseinfo.Naty,
  8709. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8710. PsnName: res2.Output.Baseinfo.PsnName,
  8711. Idetinfo: idetinfoStr,
  8712. Insuinfo: infoStr,
  8713. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8714. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8715. VerifyNumber: res.Output.EcToken,
  8716. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8717. }
  8718. service.CreateHisPsn(psn)
  8719. var balc float64
  8720. for _, item := range rf {
  8721. if item.Insutype == insutype {
  8722. balc = item.Balc
  8723. }
  8724. }
  8725. c.ServeSuccessJSON(map[string]interface{}{
  8726. "patient": patient,
  8727. "number": res.Output.CardNo,
  8728. "insutype": insutype,
  8729. "blac": balc,
  8730. "desc": idetinfoStr,
  8731. })
  8732. }
  8733. } else {
  8734. c.ServeSuccessJSON(map[string]interface{}{
  8735. "failed_code": -10,
  8736. "msg": res2.ErrMsg,
  8737. })
  8738. }
  8739. } else {
  8740. c.ServeSuccessJSON(map[string]interface{}{
  8741. "failed_code": -10,
  8742. "msg": res.ErrMsg,
  8743. })
  8744. }
  8745. } else {
  8746. SFZStr := c.GetSFZBaseInfo()
  8747. id_card_str := strings.Split(SFZStr, "^")
  8748. id_card_number := id_card_str[0]
  8749. card_sn := ""
  8750. 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)
  8751. var dat map[string]interface{}
  8752. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8753. fmt.Println(dat)
  8754. } else {
  8755. fmt.Println(err)
  8756. }
  8757. userJSONBytes, _ := json.Marshal(dat)
  8758. var res ResultTwo
  8759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8760. utils.ErrorLog("解析失败:%v", err)
  8761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8762. return
  8763. }
  8764. if res.Infcode == 0 {
  8765. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  8766. if err == gorm.ErrRecordNotFound {
  8767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8768. return
  8769. } else if err != nil {
  8770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8771. return
  8772. } else {
  8773. c.ServeSuccessJSON(map[string]interface{}{
  8774. "patient": patient,
  8775. "number": id_card_number,
  8776. })
  8777. }
  8778. } else {
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8780. return
  8781. }
  8782. }
  8783. break
  8784. case 3:
  8785. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8786. var api string
  8787. if miConfig.MdtrtareaAdmvs == "320921" {
  8788. 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 +
  8789. "&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
  8790. fmt.Println(api)
  8791. } else {
  8792. 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 +
  8793. "&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)
  8794. }
  8795. resp, requestErr := http.Get(api)
  8796. if requestErr != nil {
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. return
  8799. }
  8800. body, ioErr := ioutil.ReadAll(resp.Body)
  8801. if ioErr != nil {
  8802. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8804. return
  8805. }
  8806. var respJSON map[string]interface{}
  8807. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8808. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8810. return
  8811. }
  8812. var status string
  8813. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8814. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8815. var token string
  8816. var res ResultTwo //1101结果
  8817. var res10265 ResultTwo10265 //1101结果
  8818. var card_info string //卡信息
  8819. var busi_card_info string
  8820. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8821. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8822. if status == "0" { //读卡成功
  8823. if card_type == "1" {
  8824. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8825. result, _ := json.Marshal(respJSON)
  8826. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8827. utils.ErrorLog("解析失败:%v", err)
  8828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8829. return
  8830. }
  8831. res.ErrMsg = res10265.ErrMsg
  8832. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8833. res.Infcode = infocode
  8834. res.Output = res10265.Output
  8835. res.InfRefmsgid = res10265.InfRefmsgid
  8836. } else {
  8837. //var card_info string //卡信息
  8838. //var busi_card_info string
  8839. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8840. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8841. //fmt.Println(card_info)
  8842. //fmt.Println(busi_card_info)
  8843. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8844. result, _ := json.Marshal(respJSON)
  8845. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8846. utils.ErrorLog("解析失败:%v", err)
  8847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8848. return
  8849. }
  8850. res.ErrMsg = res10265.ErrMsg
  8851. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8852. res.Infcode = infocode
  8853. res.Output = res10265.Output
  8854. res.InfRefmsgid = res10265.InfRefmsgid
  8855. }
  8856. if res.Infcode == 0 {
  8857. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8858. if err == gorm.ErrRecordNotFound {
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8860. return
  8861. } else if err != nil {
  8862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8863. return
  8864. } else {
  8865. if card_type == "1" {
  8866. bas := strings.Split(card_info, "|")
  8867. basNumber := bas[2]
  8868. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8869. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8870. infoStr := string(Iinfos)
  8871. idetinfoStr := string(Idetinfos)
  8872. psn := &models.HisPsn{
  8873. PsnNo: res.Output.Baseinfo.PsnNo,
  8874. PatientId: patient.ID,
  8875. Certno: res.Output.Baseinfo.Certno,
  8876. //Brdy: res.Output.Baseinfo.Brdy,
  8877. Gend: res.Output.Baseinfo.Gend,
  8878. Naty: res.Output.Baseinfo.Naty,
  8879. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8880. PsnName: res.Output.Baseinfo.PsnName,
  8881. Idetinfo: idetinfoStr,
  8882. Insuinfo: infoStr,
  8883. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8884. CardInfo: card_info,
  8885. VerifyNumber: busi_card_info,
  8886. }
  8887. service.CreateHisPsn(psn)
  8888. c.ServeSuccessJSON(map[string]interface{}{
  8889. "patient": patient,
  8890. "number": basNumber,
  8891. })
  8892. } else {
  8893. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8894. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8895. infoStr := string(Iinfos)
  8896. idetinfoStr := string(Idetinfos)
  8897. psn := &models.HisPsn{
  8898. PsnNo: res.Output.Baseinfo.PsnNo,
  8899. PatientId: patient.ID,
  8900. Certno: res.Output.Baseinfo.Certno,
  8901. Gend: res.Output.Baseinfo.Gend,
  8902. Naty: res.Output.Baseinfo.Naty,
  8903. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8904. PsnName: res.Output.Baseinfo.PsnName,
  8905. Idetinfo: idetinfoStr,
  8906. Insuinfo: infoStr,
  8907. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8908. CardInfo: card_info,
  8909. VerifyNumber: token,
  8910. }
  8911. service.CreateHisPsn(psn)
  8912. var rf []*ResultFive
  8913. json.Unmarshal([]byte(infoStr), &rf)
  8914. var insutypes []*ResultFive
  8915. var insutype string
  8916. var is390 int = 0
  8917. var is310 int = 0
  8918. for _, item := range rf {
  8919. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8920. insutypes = append(insutypes, item)
  8921. }
  8922. }
  8923. if len(insutypes) == 1 {
  8924. insutype = insutypes[0].Insutype
  8925. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8926. } else {
  8927. for _, i := range insutypes {
  8928. if i.Insutype == "390" {
  8929. is390 = 1
  8930. }
  8931. if i.Insutype == "310" {
  8932. is310 = 1
  8933. }
  8934. }
  8935. }
  8936. if is390 == 1 {
  8937. insutype = "390"
  8938. }
  8939. if is310 == 1 {
  8940. insutype = "310"
  8941. }
  8942. if len(insutypes) == 0 {
  8943. insutype = "310"
  8944. }
  8945. c.ServeSuccessJSON(map[string]interface{}{
  8946. "patient": patient,
  8947. "number": token,
  8948. "insutype": insutype,
  8949. })
  8950. }
  8951. }
  8952. } else {
  8953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8954. return
  8955. }
  8956. } else { //读卡失败
  8957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8958. return
  8959. }
  8960. }
  8961. break
  8962. case 4:
  8963. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8964. var api string
  8965. if miConfig.MdtrtareaAdmvs == "320921" {
  8966. 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 +
  8967. "&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
  8968. fmt.Println(api)
  8969. } else {
  8970. 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 +
  8971. "&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)
  8972. }
  8973. resp, requestErr := http.Get(api)
  8974. if requestErr != nil {
  8975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8976. return
  8977. }
  8978. body, ioErr := ioutil.ReadAll(resp.Body)
  8979. if ioErr != nil {
  8980. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8982. return
  8983. }
  8984. var respJSON map[string]interface{}
  8985. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8986. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8988. return
  8989. }
  8990. var status string
  8991. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8992. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8993. var token string
  8994. var res ResultTwo //1101结果
  8995. var res10265 ResultTwo10265 //1101结果
  8996. if status == "0" { //读卡成功
  8997. var card_info string //卡信息
  8998. var busi_card_info string
  8999. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9000. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9001. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9002. fmt.Println(card_info)
  9003. fmt.Println(busi_card_info)
  9004. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9005. result, _ := json.Marshal(respJSON)
  9006. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9007. utils.ErrorLog("解析失败:%v", err)
  9008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9009. return
  9010. }
  9011. res.ErrMsg = res10265.ErrMsg
  9012. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9013. res.Infcode = infocode
  9014. res.Output = res10265.Output
  9015. res.InfRefmsgid = res10265.InfRefmsgid
  9016. if res.Infcode == 0 {
  9017. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9018. if err == gorm.ErrRecordNotFound {
  9019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9020. return
  9021. } else if err != nil {
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9023. return
  9024. } else {
  9025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9027. infoStr := string(Iinfos)
  9028. idetinfoStr := string(Idetinfos)
  9029. b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9030. psn := &models.HisPsn{
  9031. PsnNo: res.Output.Baseinfo.PsnNo,
  9032. PatientId: patient.ID,
  9033. Certno: res.Output.Baseinfo.Certno,
  9034. Brdy: b,
  9035. Age:float64(age),
  9036. //Brdy: res.Output.Baseinfo.Brdy,
  9037. Gend: res.Output.Baseinfo.Gend,
  9038. Naty: res.Output.Baseinfo.Naty,
  9039. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9040. PsnName: res.Output.Baseinfo.PsnName,
  9041. Idetinfo: idetinfoStr,
  9042. Insuinfo: infoStr,
  9043. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9044. CardInfo: card_info,
  9045. VerifyNumber: token,
  9046. }
  9047. var rf []*ResultFive
  9048. json.Unmarshal([]byte(infoStr), &rf)
  9049. var insutypes []*ResultFive
  9050. var insutype string
  9051. var is390 int = 0
  9052. var is310 int = 0
  9053. for _, item := range rf {
  9054. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9055. insutypes = append(insutypes, item)
  9056. }
  9057. }
  9058. if len(insutypes) == 1 {
  9059. insutype = insutypes[0].Insutype
  9060. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9061. } else {
  9062. for _, i := range insutypes {
  9063. if i.Insutype == "390" {
  9064. is390 = 1
  9065. }
  9066. if i.Insutype == "310" {
  9067. is310 = 1
  9068. }
  9069. }
  9070. }
  9071. if is390 == 1 {
  9072. insutype = "390"
  9073. }
  9074. if is310 == 1 {
  9075. insutype = "310"
  9076. }
  9077. if len(insutypes) == 0 {
  9078. insutype = "310"
  9079. }
  9080. service.CreateHisPsn(psn)
  9081. c.ServeSuccessJSON(map[string]interface{}{
  9082. "patient": patient,
  9083. "number": token,
  9084. "insutype": insutype,
  9085. })
  9086. }
  9087. } else {
  9088. c.ServeSuccessJSON(map[string]interface{}{
  9089. "failed_code": -10,
  9090. "msg": res.ErrMsg,
  9091. })
  9092. }
  9093. } else { //读卡失败
  9094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9095. return
  9096. }
  9097. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9098. var api string
  9099. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9100. "&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
  9101. resp, requestErr := http.Get(api)
  9102. if requestErr != nil {
  9103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9104. return
  9105. }
  9106. body, ioErr := ioutil.ReadAll(resp.Body)
  9107. if ioErr != nil {
  9108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9110. return
  9111. }
  9112. var respJSON map[string]interface{}
  9113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9116. return
  9117. }
  9118. var status string
  9119. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9120. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9121. var token string
  9122. var res ResultTwo //1101结果
  9123. if status == "1" { //读卡成功
  9124. var card_info string //卡信息
  9125. var busi_card_info string
  9126. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9127. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9128. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9129. fmt.Println(card_info)
  9130. fmt.Println(busi_card_info)
  9131. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9132. result, _ := json.Marshal(respJSON)
  9133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9134. utils.ErrorLog("解析失败:%v", err)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. if res.Infcode == 0 {
  9139. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9140. if err == gorm.ErrRecordNotFound {
  9141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9142. return
  9143. } else if err != nil {
  9144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9145. return
  9146. } else {
  9147. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9148. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9149. infoStr := string(Iinfos)
  9150. idetinfoStr := string(Idetinfos)
  9151. psn := &models.HisPsn{
  9152. PsnNo: res.Output.Baseinfo.PsnNo,
  9153. PatientId: patient.ID,
  9154. Certno: res.Output.Baseinfo.Certno,
  9155. Gend: res.Output.Baseinfo.Gend,
  9156. Naty: res.Output.Baseinfo.Naty,
  9157. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9158. PsnName: res.Output.Baseinfo.PsnName,
  9159. Idetinfo: idetinfoStr,
  9160. Insuinfo: infoStr,
  9161. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9162. CardInfo: card_info,
  9163. VerifyNumber: token,
  9164. }
  9165. var rf []*ResultFive
  9166. json.Unmarshal([]byte(infoStr), &rf)
  9167. var insutypes []*ResultFive
  9168. var insutype string
  9169. var is390 int = 0
  9170. var is310 int = 0
  9171. for _, item := range rf {
  9172. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9173. insutypes = append(insutypes, item)
  9174. }
  9175. }
  9176. if len(insutypes) == 1 {
  9177. insutype = insutypes[0].Insutype
  9178. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9179. } else {
  9180. for _, i := range insutypes {
  9181. if i.Insutype == "390" {
  9182. is390 = 1
  9183. }
  9184. if i.Insutype == "310" {
  9185. is310 = 1
  9186. }
  9187. }
  9188. }
  9189. if is390 == 1 {
  9190. insutype = "390"
  9191. }
  9192. if is310 == 1 {
  9193. insutype = "310"
  9194. }
  9195. if len(insutypes) == 0 {
  9196. insutype = "310"
  9197. }
  9198. service.CreateHisPsn(psn)
  9199. c.ServeSuccessJSON(map[string]interface{}{
  9200. "patient": patient,
  9201. "number": token,
  9202. "insutype": insutype,
  9203. })
  9204. }
  9205. } else {
  9206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9207. return
  9208. }
  9209. } else { //读卡失败
  9210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9211. return
  9212. }
  9213. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9214. idNo := c.GetString("idNo")
  9215. userName := c.GetString("userName")
  9216. ecToken := c.GetString("ecToken")
  9217. insuOrg := c.GetString("insuOrg")
  9218. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9219. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9220. var res ResultTwo
  9221. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9222. utils.ErrorLog("解析失败:%v", err)
  9223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9224. return
  9225. }
  9226. if res.Infcode == 0 {
  9227. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9228. if err == gorm.ErrRecordNotFound {
  9229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9230. return
  9231. } else if err != nil {
  9232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9233. return
  9234. } else {
  9235. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9236. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9237. infoStr := string(Iinfos)
  9238. idetinfoStr := string(Idetinfos)
  9239. psn := &models.HisPsn{
  9240. PsnNo: res.Output.Baseinfo.PsnNo,
  9241. PatientId: patient.ID,
  9242. Certno: res.Output.Baseinfo.Certno,
  9243. Gend: res.Output.Baseinfo.Gend,
  9244. Naty: res.Output.Baseinfo.Naty,
  9245. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9246. PsnName: res.Output.Baseinfo.PsnName,
  9247. Idetinfo: idetinfoStr,
  9248. Insuinfo: infoStr,
  9249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9250. CardInfo: "",
  9251. Stage: "1",
  9252. VerifyNumber: ecToken,
  9253. InsuplcAdmdvs: insuOrg,
  9254. }
  9255. service.CreateHisPsn(psn)
  9256. var rf []*ResultFive
  9257. json.Unmarshal([]byte(infoStr), &rf)
  9258. var insutypes []*ResultFive
  9259. var insutype string
  9260. var is390 int = 0
  9261. var is310 int = 0
  9262. for _, item := range rf {
  9263. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9264. insutypes = append(insutypes, item)
  9265. }
  9266. }
  9267. if len(insutypes) == 1 {
  9268. insutype = insutypes[0].Insutype
  9269. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9270. } else {
  9271. for _, i := range insutypes {
  9272. if i.Insutype == "390" {
  9273. is390 = 1
  9274. }
  9275. if i.Insutype == "310" {
  9276. is310 = 1
  9277. }
  9278. }
  9279. }
  9280. if is390 == 1 {
  9281. insutype = "390"
  9282. }
  9283. if is310 == 1 {
  9284. insutype = "310"
  9285. }
  9286. if len(insutypes) == 0 {
  9287. insutype = "310"
  9288. }
  9289. c.ServeSuccessJSON(map[string]interface{}{
  9290. "patient": patient,
  9291. "number": ecToken,
  9292. "insutype": insutype,
  9293. })
  9294. }
  9295. } else {
  9296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9297. return
  9298. }
  9299. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9300. //if initFlag == 0 {
  9301. //c.TestGetJiangXiBasBaseInit()
  9302. //}
  9303. //if initEleFlag == 0 {
  9304. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9305. //}
  9306. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9307. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9308. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9309. type ELeData struct {
  9310. Data struct {
  9311. IdNo string `json:"idNo"`
  9312. IdType string `json:"idType"`
  9313. UserName string `json:"userName"`
  9314. EcToken string `json:"ecToken"`
  9315. InsuOrg string `json:"insuOrg"`
  9316. Gender string `json:"gender"`
  9317. Birthday string `json:"birthday"`
  9318. Nationality string `json:"nationality"`
  9319. Email string `json:"email"`
  9320. Extra string `json:"extra"`
  9321. } `json:"data"`
  9322. Code int `json:"code"`
  9323. Message string `json:"message"`
  9324. }
  9325. var ele ELeData
  9326. err := json.Unmarshal([]byte(result), &ele)
  9327. if err != nil {
  9328. utils.ErrorLog("解析失败:%v", err)
  9329. }
  9330. token := ele.Data.EcToken
  9331. token = Remove0000(token)
  9332. 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)
  9333. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9334. var res ResultTwo
  9335. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9336. utils.ErrorLog("解析失败:%v", err)
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. if res.Infcode == 0 {
  9341. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9342. if err == gorm.ErrRecordNotFound {
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9344. return
  9345. } else if err != nil {
  9346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9347. return
  9348. } else {
  9349. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9350. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9351. infoStr := string(Iinfos)
  9352. idetinfoStr := string(Idetinfos)
  9353. psn := &models.HisPsn{
  9354. PsnNo: res.Output.Baseinfo.PsnNo,
  9355. PatientId: patient.ID,
  9356. Certno: res.Output.Baseinfo.Certno,
  9357. Gend: res.Output.Baseinfo.Gend,
  9358. Naty: res.Output.Baseinfo.Naty,
  9359. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9360. PsnName: res.Output.Baseinfo.PsnName,
  9361. Idetinfo: idetinfoStr,
  9362. Insuinfo: infoStr,
  9363. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9364. CardInfo: "",
  9365. VerifyNumber: token,
  9366. }
  9367. service.CreateHisPsn(psn)
  9368. var rf []*ResultFive
  9369. json.Unmarshal([]byte(infoStr), &rf)
  9370. var insutypes []*ResultFive
  9371. var insutype string
  9372. var is390 int = 0
  9373. var is310 int = 0
  9374. for _, item := range rf {
  9375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9376. insutypes = append(insutypes, item)
  9377. }
  9378. }
  9379. if len(insutypes) == 1 {
  9380. insutype = insutypes[0].Insutype
  9381. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9382. } else {
  9383. for _, i := range insutypes {
  9384. if i.Insutype == "390" {
  9385. is390 = 1
  9386. }
  9387. if i.Insutype == "310" {
  9388. is310 = 1
  9389. }
  9390. }
  9391. }
  9392. if is390 == 1 {
  9393. insutype = "390"
  9394. }
  9395. if is310 == 1 {
  9396. insutype = "310"
  9397. }
  9398. if len(insutypes) == 0 {
  9399. insutype = "310"
  9400. }
  9401. c.ServeSuccessJSON(map[string]interface{}{
  9402. "patient": patient,
  9403. "number": token,
  9404. "insutype": insutype,
  9405. })
  9406. }
  9407. } else {
  9408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9409. return
  9410. }
  9411. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9412. //if initFlag == 0 {
  9413. c.TestGetJiangXiBasBaseInit()
  9414. //}
  9415. //if initEleFlag == 0 {
  9416. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9417. //}
  9418. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9419. type ELeData struct {
  9420. Data struct {
  9421. IdNo string `json:"idNo"`
  9422. IdType string `json:"idType"`
  9423. UserName string `json:"userName"`
  9424. EcToken string `json:"ecToken"`
  9425. InsuOrg string `json:"insuOrg"`
  9426. Gender string `json:"gender"`
  9427. Birthday string `json:"birthday"`
  9428. Nationality string `json:"nationality"`
  9429. Email string `json:"email"`
  9430. Extra string `json:"extra"`
  9431. } `json:"data"`
  9432. Code int `json:"code"`
  9433. Message string `json:"message"`
  9434. }
  9435. var ele ELeData
  9436. err := json.Unmarshal([]byte(json_result), &ele)
  9437. if err != nil {
  9438. utils.ErrorLog("解析失败:%v", err)
  9439. }
  9440. token := ele.Data.EcToken
  9441. token = Remove0000(token)
  9442. 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)
  9443. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9444. var res ResultTwo
  9445. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9446. utils.ErrorLog("解析失败:%v", err)
  9447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9448. return
  9449. }
  9450. if res.Infcode == 0 {
  9451. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9452. if err == gorm.ErrRecordNotFound {
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9454. return
  9455. } else if err != nil {
  9456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9457. return
  9458. } else {
  9459. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9460. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9461. infoStr := string(Iinfos)
  9462. idetinfoStr := string(Idetinfos)
  9463. psn := &models.HisPsn{
  9464. PsnNo: res.Output.Baseinfo.PsnNo,
  9465. PatientId: patient.ID,
  9466. Certno: res.Output.Baseinfo.Certno,
  9467. Gend: res.Output.Baseinfo.Gend,
  9468. Naty: res.Output.Baseinfo.Naty,
  9469. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9470. PsnName: res.Output.Baseinfo.PsnName,
  9471. Idetinfo: idetinfoStr,
  9472. Insuinfo: infoStr,
  9473. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9474. CardInfo: "",
  9475. VerifyNumber: token,
  9476. }
  9477. service.CreateHisPsn(psn)
  9478. var rf []*ResultFive
  9479. json.Unmarshal([]byte(infoStr), &rf)
  9480. var insutypes []*ResultFive
  9481. var insutype string
  9482. var is390 int = 0
  9483. var is310 int = 0
  9484. for _, item := range rf {
  9485. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9486. insutypes = append(insutypes, item)
  9487. }
  9488. }
  9489. if len(insutypes) == 1 {
  9490. insutype = insutypes[0].Insutype
  9491. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9492. } else {
  9493. for _, i := range insutypes {
  9494. if i.Insutype == "390" {
  9495. is390 = 1
  9496. }
  9497. if i.Insutype == "310" {
  9498. is310 = 1
  9499. }
  9500. }
  9501. }
  9502. if is390 == 1 {
  9503. insutype = "390"
  9504. }
  9505. if is310 == 1 {
  9506. insutype = "310"
  9507. }
  9508. if len(insutypes) == 0 {
  9509. insutype = "310"
  9510. }
  9511. c.ServeSuccessJSON(map[string]interface{}{
  9512. "patient": patient,
  9513. "number": token,
  9514. "insutype": insutype,
  9515. })
  9516. }
  9517. } else {
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9519. return
  9520. }
  9521. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9522. type ELeData struct {
  9523. Code string `json:"code"`
  9524. Data struct {
  9525. Aac002 string `json:"aac002"`
  9526. Aaz500 string `json:"aaz500"`
  9527. ActCardNo string `json:"actCardNo"`
  9528. Bab520 string `json:"bab520"`
  9529. Bkz543 string `json:"bkz543"`
  9530. BusinessType string `json:"businessType"`
  9531. CertfCodg string `json:"certfCodg"`
  9532. EcIndexNo string `json:"ecIndexNo"`
  9533. EcToken string `json:"ecToken"`
  9534. ID0000 string `json:"id0000"`
  9535. IDNo string `json:"idNo"`
  9536. IDType string `json:"idType"`
  9537. Idcode string `json:"idcode"`
  9538. IdentityToken string `json:"identity_token"`
  9539. InsuOrg string `json:"insuOrg"`
  9540. OfficeID string `json:"officeId"`
  9541. OfficeName string `json:"officeName"`
  9542. OperatorID string `json:"operatorId"`
  9543. OperatorName string `json:"operatorName"`
  9544. OrgID string `json:"orgId"`
  9545. UserName string `json:"userName"`
  9546. } `json:"data"`
  9547. Infno interface{} `json:"infno"`
  9548. Message string `json:"message"`
  9549. OrgID string `json:"orgId"`
  9550. TransType string `json:"transType"`
  9551. }
  9552. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  9553. outPutInfo = Remove0000(outPutInfo)
  9554. if len(outPutInfo) > 0 {
  9555. var ele ELeData
  9556. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9557. if err != nil {
  9558. utils.ErrorLog("解析失败:%v", err)
  9559. }
  9560. token := ele.Data.EcToken
  9561. fmt.Println(inputInfo)
  9562. fmt.Println(outPutInfo)
  9563. 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)
  9564. saveLog(result, requestLog, "1101", "获取人员信息")
  9565. var dat map[string]interface{}
  9566. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9567. fmt.Println(dat)
  9568. } else {
  9569. fmt.Println(err)
  9570. }
  9571. userJSONBytes, _ := json.Marshal(dat)
  9572. var res ResultTwo
  9573. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9574. utils.ErrorLog("解析失败:%v", err)
  9575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9576. return
  9577. }
  9578. res.ErrMsg = errMsgLog
  9579. if res.Infcode == 0 {
  9580. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9581. if err == gorm.ErrRecordNotFound {
  9582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9583. return
  9584. } else if err != nil {
  9585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9586. return
  9587. } else {
  9588. fmt.Println(res)
  9589. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9590. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9591. infoStr := string(Iinfos)
  9592. idetinfoStr := string(Idetinfos)
  9593. psn := &models.HisPsn{
  9594. PsnNo: res.Output.Baseinfo.PsnNo,
  9595. PatientId: patient.ID,
  9596. Certno: res.Output.Baseinfo.Certno,
  9597. Gend: res.Output.Baseinfo.Gend,
  9598. Naty: res.Output.Baseinfo.Naty,
  9599. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9600. PsnName: res.Output.Baseinfo.PsnName,
  9601. Idetinfo: idetinfoStr,
  9602. Insuinfo: infoStr,
  9603. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9604. CardInfo: outPutInfo,
  9605. VerifyNumber: token,
  9606. InsuplcAdmdvs: ele.Data.InsuOrg,
  9607. }
  9608. service.CreateHisPsn(psn)
  9609. var rf []*ResultFive
  9610. json.Unmarshal([]byte(infoStr), &rf)
  9611. var insutypes []*ResultFive
  9612. var insutype string
  9613. var is390 int = 0
  9614. var is310 int = 0
  9615. for _, item := range rf {
  9616. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9617. insutypes = append(insutypes, item)
  9618. }
  9619. }
  9620. if len(insutypes) == 1 {
  9621. insutype = insutypes[0].Insutype
  9622. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9623. } else {
  9624. for _, i := range insutypes {
  9625. if i.Insutype == "390" {
  9626. is390 = 1
  9627. }
  9628. if i.Insutype == "310" {
  9629. is310 = 1
  9630. }
  9631. }
  9632. }
  9633. if is390 == 1 {
  9634. insutype = "390"
  9635. }
  9636. if is310 == 1 {
  9637. insutype = "310"
  9638. }
  9639. if len(insutypes) == 0 {
  9640. insutype = "310"
  9641. }
  9642. c.ServeSuccessJSON(map[string]interface{}{
  9643. "patient": patient,
  9644. "number": token,
  9645. "insutype": insutype,
  9646. })
  9647. }
  9648. } else {
  9649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9650. return
  9651. }
  9652. }
  9653. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9654. var api string
  9655. 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 +
  9656. "&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
  9657. resp, requestErr := http.Get(api)
  9658. if requestErr != nil {
  9659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9660. return
  9661. }
  9662. body, ioErr := ioutil.ReadAll(resp.Body)
  9663. if ioErr != nil {
  9664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. return
  9667. }
  9668. var respJSON map[string]interface{}
  9669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. return
  9673. }
  9674. var status string
  9675. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9676. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9677. var token string
  9678. var res ResultTwo //1101结果
  9679. var res10265 ResultTwo10265 //1101结果
  9680. if status == "0" { //读卡成功
  9681. var card_info string //卡信息
  9682. var busi_card_info string
  9683. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9684. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9685. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9686. fmt.Println(card_info)
  9687. fmt.Println(busi_card_info)
  9688. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9689. result, _ := json.Marshal(respJSON)
  9690. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9691. utils.ErrorLog("解析失败:%v", err)
  9692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9693. return
  9694. }
  9695. res.ErrMsg = res10265.ErrMsg
  9696. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9697. res.Infcode = infocode
  9698. res.Output = res10265.Output
  9699. res.InfRefmsgid = res10265.InfRefmsgid
  9700. if res.Infcode == 0 {
  9701. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9702. if err == gorm.ErrRecordNotFound {
  9703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9704. return
  9705. } else if err != nil {
  9706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9707. return
  9708. } else {
  9709. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9710. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9711. infoStr := string(Iinfos)
  9712. idetinfoStr := string(Idetinfos)
  9713. psn := &models.HisPsn{
  9714. PsnNo: res.Output.Baseinfo.PsnNo,
  9715. PatientId: patient.ID,
  9716. Certno: res.Output.Baseinfo.Certno,
  9717. Gend: res.Output.Baseinfo.Gend,
  9718. Naty: res.Output.Baseinfo.Naty,
  9719. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9720. PsnName: res.Output.Baseinfo.PsnName,
  9721. Idetinfo: idetinfoStr,
  9722. Insuinfo: infoStr,
  9723. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9724. CardInfo: card_info,
  9725. VerifyNumber: token,
  9726. }
  9727. var rf []*ResultFive
  9728. json.Unmarshal([]byte(infoStr), &rf)
  9729. var insutypes []*ResultFive
  9730. var insutype string
  9731. var is390 int = 0
  9732. var is310 int = 0
  9733. for _, item := range rf {
  9734. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9735. insutypes = append(insutypes, item)
  9736. }
  9737. }
  9738. if len(insutypes) == 1 {
  9739. insutype = insutypes[0].Insutype
  9740. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9741. } else {
  9742. for _, i := range insutypes {
  9743. if i.Insutype == "390" {
  9744. is390 = 1
  9745. }
  9746. if i.Insutype == "310" {
  9747. is310 = 1
  9748. }
  9749. }
  9750. }
  9751. if is390 == 1 {
  9752. insutype = "390"
  9753. }
  9754. if is310 == 1 {
  9755. insutype = "310"
  9756. }
  9757. if len(insutypes) == 0 {
  9758. insutype = "310"
  9759. }
  9760. service.CreateHisPsn(psn)
  9761. c.ServeSuccessJSON(map[string]interface{}{
  9762. "patient": patient,
  9763. "number": token,
  9764. "insutype": insutype,
  9765. })
  9766. }
  9767. } else {
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9769. return
  9770. }
  9771. } else { //读卡失败
  9772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9773. return
  9774. }
  9775. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9776. res := c.GetoleInfo()
  9777. if res.Infcode == 0 {
  9778. var result string
  9779. if res.Output.MdtrtCertType == "01" {
  9780. 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)
  9781. } else if res.Output.MdtrtCertType == "02" {
  9782. 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)
  9783. } else if res.Output.MdtrtCertType == "03" {
  9784. 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)
  9785. }
  9786. var dat map[string]interface{}
  9787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9788. fmt.Println(dat)
  9789. } else {
  9790. fmt.Println(err)
  9791. }
  9792. userJSONBytes, _ := json.Marshal(dat)
  9793. var res2 ResultTwo
  9794. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9795. utils.ErrorLog("解析失败:%v", err)
  9796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9797. return
  9798. }
  9799. if res2.Infcode == 0 {
  9800. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9801. if err == gorm.ErrRecordNotFound {
  9802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9803. return
  9804. } else if err != nil {
  9805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9806. return
  9807. } else {
  9808. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9809. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9810. infoStr := string(Iinfos)
  9811. idetinfoStr := string(Idetinfos)
  9812. var rf []*ResultFive
  9813. json.Unmarshal([]byte(infoStr), &rf)
  9814. var insutypes []*ResultFive
  9815. var insutype string
  9816. var is390 int = 0
  9817. var is310 int = 0
  9818. //var insuplc_admdvs string
  9819. for _, item := range rf {
  9820. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9821. insutypes = append(insutypes, item)
  9822. }
  9823. }
  9824. if len(insutypes) == 1 {
  9825. insutype = insutypes[0].Insutype
  9826. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9827. } else {
  9828. for _, i := range insutypes {
  9829. if i.Insutype == "390" {
  9830. is390 = 1
  9831. }
  9832. if i.Insutype == "310" {
  9833. is310 = 1
  9834. }
  9835. }
  9836. }
  9837. if is390 == 1 {
  9838. insutype = "390"
  9839. }
  9840. if is310 == 1 {
  9841. insutype = "310"
  9842. }
  9843. if len(insutypes) == 0 {
  9844. insutype = "310"
  9845. }
  9846. psn := &models.HisPsn{
  9847. PsnNo: res2.Output.Baseinfo.PsnNo,
  9848. PatientId: patient.ID,
  9849. Certno: res2.Output.Baseinfo.Certno,
  9850. Gend: res2.Output.Baseinfo.Gend,
  9851. Naty: res2.Output.Baseinfo.Naty,
  9852. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9853. PsnName: res2.Output.Baseinfo.PsnName,
  9854. Idetinfo: idetinfoStr,
  9855. Insuinfo: infoStr,
  9856. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9857. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9858. VerifyNumber: res.Output.EcToken,
  9859. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9860. }
  9861. if res.Output.MdtrtCertType == "01" {
  9862. psn.VerifyNumber = res.Output.EcToken
  9863. //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)
  9864. } else if res.Output.MdtrtCertType == "02" {
  9865. psn.VerifyNumber = res.Output.CardNo
  9866. //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)
  9867. } else if res.Output.MdtrtCertType == "03" {
  9868. psn.VerifyNumber = res.Output.MdtrtCertNo
  9869. //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)
  9870. }
  9871. service.CreateHisPsn(psn)
  9872. var balc float64
  9873. for _, item := range rf {
  9874. if item.Insutype == insutype {
  9875. balc = item.Balc
  9876. }
  9877. }
  9878. c.ServeSuccessJSON(map[string]interface{}{
  9879. "patient": patient,
  9880. "number": res.Output.CardNo,
  9881. "insutype": insutype,
  9882. "blac": balc,
  9883. "desc": idetinfoStr,
  9884. })
  9885. }
  9886. } else {
  9887. c.ServeSuccessJSON(map[string]interface{}{
  9888. "failed_code": -10,
  9889. "msg": res2.ErrMsg,
  9890. })
  9891. }
  9892. } else {
  9893. c.ServeSuccessJSON(map[string]interface{}{
  9894. "failed_code": -10,
  9895. "msg": res.ErrMsg,
  9896. })
  9897. }
  9898. } else {
  9899. type ELeData struct {
  9900. Code string `json:"code"`
  9901. Data struct {
  9902. Aac002 string `json:"aac002"`
  9903. Aaz500 string `json:"aaz500"`
  9904. ActCardNo string `json:"actCardNo"`
  9905. Bab520 string `json:"bab520"`
  9906. Bkz543 string `json:"bkz543"`
  9907. BusinessType string `json:"businessType"`
  9908. CertfCodg string `json:"certfCodg"`
  9909. EcIndexNo string `json:"ecIndexNo"`
  9910. EcToken string `json:"ecToken"`
  9911. ID0000 string `json:"id0000"`
  9912. IDNo string `json:"idNo"`
  9913. IDType string `json:"idType"`
  9914. Idcode string `json:"idcode"`
  9915. IdentityToken string `json:"identity_token"`
  9916. InsuOrg string `json:"insuOrg"`
  9917. OfficeID string `json:"officeId"`
  9918. OfficeName string `json:"officeName"`
  9919. OperatorID string `json:"operatorId"`
  9920. OperatorName string `json:"operatorName"`
  9921. OrgID string `json:"orgId"`
  9922. UserName string `json:"userName"`
  9923. } `json:"data"`
  9924. Infno interface{} `json:"infno"`
  9925. Message string `json:"message"`
  9926. OrgID string `json:"orgId"`
  9927. TransType string `json:"transType"`
  9928. }
  9929. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  9930. fmt.Println(result)
  9931. outPutInfo := Remove0000(result)
  9932. fmt.Println(outPutInfo)
  9933. if len(outPutInfo) > 0 {
  9934. var ele ELeData
  9935. err := json.Unmarshal([]byte(outPutInfo), &ele)
  9936. if err != nil {
  9937. utils.ErrorLog("解析失败:%v", err)
  9938. }
  9939. token := ele.Data.EcToken
  9940. fmt.Println(outPutInfo)
  9941. 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)
  9942. saveLog(result, requestLog, "1101", "获取人员信息")
  9943. var dat map[string]interface{}
  9944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9945. fmt.Println(dat)
  9946. } else {
  9947. fmt.Println(err)
  9948. }
  9949. userJSONBytes, _ := json.Marshal(dat)
  9950. var res ResultTwo
  9951. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9952. utils.ErrorLog("解析失败:%v", err)
  9953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9954. return
  9955. }
  9956. if res.Infcode == 0 {
  9957. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  9958. if err == gorm.ErrRecordNotFound {
  9959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9960. return
  9961. } else if err != nil {
  9962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9963. return
  9964. } else {
  9965. fmt.Println(res)
  9966. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9967. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9968. infoStr := string(Iinfos)
  9969. idetinfoStr := string(Idetinfos)
  9970. psn := &models.HisPsn{
  9971. PsnNo: res.Output.Baseinfo.PsnNo,
  9972. PatientId: patient.ID,
  9973. Certno: res.Output.Baseinfo.Certno,
  9974. Gend: res.Output.Baseinfo.Gend,
  9975. Naty: res.Output.Baseinfo.Naty,
  9976. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9977. PsnName: res.Output.Baseinfo.PsnName,
  9978. Idetinfo: idetinfoStr,
  9979. Insuinfo: infoStr,
  9980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9981. CardInfo: outPutInfo,
  9982. VerifyNumber: token,
  9983. InsuplcAdmdvs: ele.Data.InsuOrg,
  9984. }
  9985. service.CreateHisPsn(psn)
  9986. var rf []*ResultFive
  9987. json.Unmarshal([]byte(infoStr), &rf)
  9988. var insutypes []*ResultFive
  9989. var insutype string
  9990. var is390 int = 0
  9991. var is310 int = 0
  9992. for _, item := range rf {
  9993. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9994. insutypes = append(insutypes, item)
  9995. }
  9996. }
  9997. if len(insutypes) == 1 {
  9998. insutype = insutypes[0].Insutype
  9999. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10000. } else {
  10001. for _, i := range insutypes {
  10002. if i.Insutype == "390" {
  10003. is390 = 1
  10004. }
  10005. if i.Insutype == "310" {
  10006. is310 = 1
  10007. }
  10008. }
  10009. }
  10010. if is390 == 1 {
  10011. insutype = "390"
  10012. }
  10013. if is310 == 1 {
  10014. insutype = "310"
  10015. }
  10016. if len(insutypes) == 0 {
  10017. insutype = "310"
  10018. }
  10019. c.ServeSuccessJSON(map[string]interface{}{
  10020. "patient": patient,
  10021. "number": token,
  10022. "insutype": insutype,
  10023. })
  10024. }
  10025. } else {
  10026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10027. return
  10028. }
  10029. }
  10030. //fmt.Println(result)
  10031. //
  10032. //if initFlag == 0 {
  10033. // c.TestGetBasBaseInit()
  10034. //}
  10035. //token := c.GetEleBaseInfo()
  10036. //
  10037. //token = Remove0000(token)
  10038. //
  10039. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10040. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10041. ////
  10042. //var res ResultTwo
  10043. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10044. // utils.ErrorLog("解析失败:%v", err)
  10045. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10046. // return
  10047. //}
  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. //
  10058. // } else {
  10059. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10060. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10061. // infoStr := string(Iinfos)
  10062. // idetinfoStr := string(Idetinfos)
  10063. //
  10064. //
  10065. //
  10066. //
  10067. // var rf []*ResultFive
  10068. // json.Unmarshal([]byte(infoStr), &rf)
  10069. //
  10070. // var insutypes []*ResultFive
  10071. // var insutype string
  10072. // var is390 int = 0
  10073. // var is310 int = 0
  10074. // var insuplc_admdvs string
  10075. //
  10076. // for _, item := range rf {
  10077. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10078. // insutypes = append(insutypes, item)
  10079. // }
  10080. // }
  10081. //
  10082. // if len(insutypes) == 1 {
  10083. // insutype = insutypes[0].Insutype
  10084. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10085. // } else {
  10086. // for _, i := range insutypes {
  10087. // if i.Insutype == "390" {
  10088. // is390 = 1
  10089. // }
  10090. //
  10091. // if i.Insutype == "310" {
  10092. // is310 = 1
  10093. // }
  10094. // }
  10095. // }
  10096. // if is390 == 1 {
  10097. // insutype = "390"
  10098. // }
  10099. //
  10100. // if is310 == 1 {
  10101. // insutype = "310"
  10102. // }
  10103. // if len(insutypes) == 0 {
  10104. // insutype = "310"
  10105. // }
  10106. // for _, item := range rf {
  10107. // if item.Insutype == insutype {
  10108. // insuplc_admdvs = item.InsuplcAdmdvs
  10109. // }
  10110. // }
  10111. // psn := &models.HisPsn{
  10112. // PsnNo: res.Output.Baseinfo.PsnNo,
  10113. // Age: res.Output.Baseinfo.Age,
  10114. // PatientId: patient.ID,
  10115. // Certno: res.Output.Baseinfo.Certno,
  10116. // Brdy: res.Output.Baseinfo.Brdy,
  10117. // Gend: res.Output.Baseinfo.Gend,
  10118. // Naty: res.Output.Baseinfo.Naty,
  10119. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10120. // PsnName: res.Output.Baseinfo.PsnName,
  10121. // Idetinfo: idetinfoStr,
  10122. // Insuinfo: infoStr,
  10123. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10124. // CardInfo: "",
  10125. // VerifyNumber: token,
  10126. // InsuplcAdmdvs: insuplc_admdvs,
  10127. // }
  10128. // service.CreateHisPsn(psn)
  10129. //
  10130. // c.ServeSuccessJSON(map[string]interface{}{
  10131. // "patient": patient,
  10132. // "number": token,
  10133. // })
  10134. // }
  10135. //} else {
  10136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10137. // return
  10138. //}
  10139. }
  10140. break
  10141. case 5:
  10142. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10143. var api string
  10144. if miConfig.MdtrtareaAdmvs == "320921" {
  10145. 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 +
  10146. "&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
  10147. fmt.Println(api)
  10148. } else {
  10149. 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 +
  10150. "&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)
  10151. }
  10152. resp, requestErr := http.Get(api)
  10153. if requestErr != nil {
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. return
  10156. }
  10157. body, ioErr := ioutil.ReadAll(resp.Body)
  10158. if ioErr != nil {
  10159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10161. return
  10162. }
  10163. var respJSON map[string]interface{}
  10164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10167. return
  10168. }
  10169. var status string
  10170. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10171. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10172. var token string
  10173. var res ResultTwo //1101结果
  10174. var res10265 ResultTwo10265 //1101结果
  10175. if status == "0" { //读卡成功
  10176. var card_info string //卡信息
  10177. //var busi_card_info string
  10178. var auth_info string
  10179. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10180. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10181. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10182. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10183. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10184. result, _ := json.Marshal(respJSON)
  10185. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10186. utils.ErrorLog("解析失败:%v", err)
  10187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10188. return
  10189. }
  10190. res.ErrMsg = res10265.ErrMsg
  10191. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10192. res.Infcode = infocode
  10193. res.Output = res10265.Output
  10194. res.InfRefmsgid = res10265.InfRefmsgid
  10195. if res.Infcode == 0 {
  10196. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10197. if err == gorm.ErrRecordNotFound {
  10198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10199. return
  10200. } else if err != nil {
  10201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10202. return
  10203. } else {
  10204. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10205. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10206. infoStr := string(Iinfos)
  10207. idetinfoStr := string(Idetinfos)
  10208. b,age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10209. psn := &models.HisPsn{
  10210. PsnNo: res.Output.Baseinfo.PsnNo,
  10211. PatientId: patient.ID,
  10212. Certno: res.Output.Baseinfo.Certno,
  10213. Gend: res.Output.Baseinfo.Gend,
  10214. Brdy: b,
  10215. Age:float64(age),
  10216. Naty: res.Output.Baseinfo.Naty,
  10217. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10218. PsnName: res.Output.Baseinfo.PsnName,
  10219. Idetinfo: idetinfoStr,
  10220. Insuinfo: infoStr,
  10221. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10222. CardInfo: card_info,
  10223. VerifyNumber: token,
  10224. AuthInfo: auth_info,
  10225. }
  10226. var rf []*ResultFive
  10227. json.Unmarshal([]byte(infoStr), &rf)
  10228. var insutypes []*ResultFive
  10229. var insutype string
  10230. var is390 int = 0
  10231. var is310 int = 0
  10232. for _, item := range rf {
  10233. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10234. insutypes = append(insutypes, item)
  10235. }
  10236. }
  10237. if len(insutypes) == 1 {
  10238. insutype = insutypes[0].Insutype
  10239. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10240. } else {
  10241. for _, i := range insutypes {
  10242. if i.Insutype == "390" {
  10243. is390 = 1
  10244. }
  10245. if i.Insutype == "310" {
  10246. is310 = 1
  10247. }
  10248. }
  10249. }
  10250. if is390 == 1 {
  10251. insutype = "390"
  10252. }
  10253. if is310 == 1 {
  10254. insutype = "310"
  10255. }
  10256. if len(insutypes) == 0 {
  10257. insutype = "310"
  10258. }
  10259. service.CreateHisPsn(psn)
  10260. c.ServeSuccessJSON(map[string]interface{}{
  10261. "patient": patient,
  10262. "number": token,
  10263. "insutype": insutype,
  10264. })
  10265. }
  10266. } else {
  10267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10268. return
  10269. }
  10270. } else { //读卡失败
  10271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10272. return
  10273. }
  10274. }
  10275. break
  10276. }
  10277. }
  10278. var initFlag int64 = 0
  10279. var initEleFlag int64 = 0
  10280. func (c *HisApiController) TestGetBasBaseInit() {
  10281. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10282. Iinit := DllDef.MustFindProc("Init")
  10283. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10284. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  10285. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  10286. if ret != 0 {
  10287. fmt.Println("SSCard的报错原因:", err)
  10288. fmt.Println("SSCard的运算结果为:", ret)
  10289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10290. return
  10291. }
  10292. result := int(ret)
  10293. fmt.Println("SSCard的运算结果为1:", result)
  10294. initFlag = 1
  10295. return
  10296. }
  10297. func (c *HisApiController) HandleJiangXiReadCard() {
  10298. fmt.Println("~~~~~~")
  10299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10300. admin_user_id, _ := c.GetInt64("admin_user_id")
  10301. id_card_type, _ := c.GetInt64("id_card_type")
  10302. //certificates, _ := c.GetInt64("certificates")
  10303. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10304. if initFlag == 0 {
  10305. c.TestGetJiangXiBasBaseInit()
  10306. }
  10307. basStr := c.GetBasBaseInfo()
  10308. if len(basStr) == 0 {
  10309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10310. return
  10311. }
  10312. fmt.Println(basStr)
  10313. bas := strings.Split(basStr, "|")
  10314. basNumber := bas[1]
  10315. fmt.Println(basNumber)
  10316. card_sn := bas[3]
  10317. fmt.Println(card_sn)
  10318. 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, "")
  10319. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  10320. var dat map[string]interface{}
  10321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10322. fmt.Println(dat)
  10323. } else {
  10324. fmt.Println(err)
  10325. }
  10326. userJSONBytes, _ := json.Marshal(dat)
  10327. var res ResultTwo
  10328. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. if res.Infcode == 0 {
  10334. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  10335. if err == gorm.ErrRecordNotFound {
  10336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10337. return
  10338. } else if err != nil {
  10339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10340. return
  10341. } else {
  10342. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10343. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10344. infoStr := string(Iinfos)
  10345. idetinfoStr := string(Idetinfos)
  10346. psn := &models.HisPsn{
  10347. PsnNo: res.Output.Baseinfo.PsnNo,
  10348. PatientId: patient.ID,
  10349. Certno: res.Output.Baseinfo.Certno,
  10350. Gend: res.Output.Baseinfo.Gend,
  10351. Naty: res.Output.Baseinfo.Naty,
  10352. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10353. PsnName: res.Output.Baseinfo.PsnName,
  10354. Idetinfo: idetinfoStr,
  10355. Insuinfo: infoStr,
  10356. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10357. CardInfo: basStr,
  10358. VerifyNumber: "",
  10359. }
  10360. service.CreateHisPsn(psn)
  10361. c.ServeSuccessJSON(map[string]interface{}{
  10362. "patient": patient,
  10363. "number": basNumber,
  10364. })
  10365. }
  10366. } else {
  10367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10368. return
  10369. }
  10370. }
  10371. func (c *HisApiController) TestGetHnBasBaseInit() {
  10372. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10373. Iinit := DllDef.MustFindProc("Init")
  10374. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10375. //http://10.77.211.236/CSB/hsa-fsi-1303
  10376. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  10377. if ret != 0 {
  10378. fmt.Println("SSCard的报错原因:", err)
  10379. fmt.Println("SSCard的运算结果为:", ret)
  10380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10381. return
  10382. }
  10383. result := int(ret)
  10384. fmt.Println("SSCard的运算结果为1:", result)
  10385. initFlag = 1
  10386. return
  10387. }
  10388. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  10389. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10390. Iinit := DllDef.MustFindProc("Init")
  10391. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10392. //http://10.77.211.236/CSB/hsa-fsi-1303
  10393. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  10394. if ret != 0 {
  10395. fmt.Println("SSCard的报错原因:", err)
  10396. fmt.Println("SSCard的运算结果为:", ret)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  10398. return
  10399. }
  10400. result := int(ret)
  10401. fmt.Println("SSCard的运算结果为1:", result)
  10402. initFlag = 1
  10403. return
  10404. }
  10405. func (c *HisApiController) GetSFZBaseInfo() string {
  10406. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10407. readCard := DllDef.MustFindProc("ReadSFZ")
  10408. if readCard == nil {
  10409. fmt.Println("readcard is nil")
  10410. readCard = DllDef.MustFindProc("ReadSFZ")
  10411. }
  10412. str := make([]byte, 8096)
  10413. str1 := make([]byte, 8096)
  10414. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  10415. fmt.Println(r)
  10416. return Remove0000(string(str))
  10417. }
  10418. func (c *HisApiController) GetEleBaseInfo() string {
  10419. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10420. readCard := DllDef.MustFindProc("GetQRBase")
  10421. fmt.Println(readCard)
  10422. if readCard == nil {
  10423. fmt.Println("readcard is nil")
  10424. readCard = DllDef.MustFindProc("GetQRBase")
  10425. }
  10426. str := make([]byte, 1024)
  10427. str1 := make([]byte, 1024)
  10428. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10429. fmt.Println(ret2)
  10430. fmt.Println(string(str1))
  10431. fmt.Println(string(str))
  10432. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10433. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10434. if ret2 != 0 {
  10435. return ""
  10436. }
  10437. return string(str)
  10438. }
  10439. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10440. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10441. readCard := DllDef.MustFindProc("NationEcTrans")
  10442. fmt.Println(readCard)
  10443. fmt.Println("!!!!!")
  10444. pBusiCardInfo := make([]byte, 2048)
  10445. input := make(map[string]interface{})
  10446. inputData := make(map[string]interface{})
  10447. inputData["orgId"] = code
  10448. inputData["businessType"] = "01101"
  10449. inputData["operatorId"] = "1"
  10450. inputData["operatorName"] = "admin"
  10451. inputData["officeId"] = "001"
  10452. inputData["officeName"] = "血透室"
  10453. inputData["deviceType"] = ""
  10454. input["data"] = inputData
  10455. input["orgId"] = code
  10456. input["transType"] = "ec.query"
  10457. bytesData, _ := json.Marshal(input)
  10458. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  10459. fmt.Println(ret2)
  10460. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10461. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10462. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  10463. }
  10464. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  10465. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10466. readCard := DllDef.MustFindProc("NationEcTrans")
  10467. fmt.Println(readCard)
  10468. fmt.Println("!!!!!")
  10469. pBusiCardInfo := make([]byte, 2048)
  10470. input := make(map[string]interface{})
  10471. inputData := make(map[string]interface{})
  10472. inputData["orgId"] = code
  10473. inputData["businessType"] = "01101"
  10474. inputData["operatorId"] = "9"
  10475. inputData["operatorName"] = "admin"
  10476. inputData["officeId"] = "001"
  10477. inputData["officeName"] = "血透室"
  10478. inputData["deviceType"] = ""
  10479. input["data"] = inputData
  10480. input["orgId"] = code
  10481. input["transType"] = "ec.query"
  10482. bytesData, _ := json.Marshal(input)
  10483. 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])))
  10484. fmt.Println(ret2)
  10485. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10486. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10487. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10488. }
  10489. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  10490. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  10491. readCard := DllDef.MustFindProc("NationEcTrans")
  10492. fmt.Println(readCard)
  10493. fmt.Println("!!!!!")
  10494. pBusiCardInfo := make([]byte, 2048)
  10495. input := make(map[string]interface{})
  10496. inputData := make(map[string]interface{})
  10497. inputData["orgId"] = code
  10498. inputData["businessType"] = "01301"
  10499. inputData["operatorId"] = "9"
  10500. inputData["operatorName"] = "admin"
  10501. inputData["officeId"] = "001"
  10502. inputData["officeName"] = "血透室"
  10503. inputData["deviceType"] = ""
  10504. input["data"] = inputData
  10505. input["orgId"] = code
  10506. input["transType"] = "ec.query"
  10507. bytesData, _ := json.Marshal(input)
  10508. 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])))
  10509. fmt.Println(ret2)
  10510. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  10511. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  10512. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  10513. }
  10514. func GetJxEleBaseInfo(org_id int64) string {
  10515. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10516. readCard := DllDef.MustFindProc("NationEcTrans")
  10517. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10518. if readCard == nil {
  10519. fmt.Println("readcard is nil")
  10520. readCard = DllDef.MustFindProc("NationEcTrans")
  10521. }
  10522. str1 := make([]byte, 1024)
  10523. data := make(map[string]interface{})
  10524. inputData := make(map[string]interface{})
  10525. inputData["orgId"] = miConfig.Code
  10526. inputData["businessType"] = "01101"
  10527. inputData["operatorId"] = "test001"
  10528. inputData["operatorName"] = "cn"
  10529. inputData["officeId"] = "32760"
  10530. inputData["officeName"] = "waike"
  10531. inputData["deviceType"] = ""
  10532. data["data"] = inputData
  10533. data["transType"] = "ec.query"
  10534. data["extra "] = ""
  10535. data["orgId"] = miConfig.Code
  10536. bytesData, _ := json.Marshal(data)
  10537. //bytesData, _ := json.Marshal(data)
  10538. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10539. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10540. fmt.Println(ret2)
  10541. fmt.Println(string(str1))
  10542. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10543. if ret2 != 0 {
  10544. return ""
  10545. }
  10546. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10547. }
  10548. func GetJxEleBaseInitInfo(org_id int64) string {
  10549. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10550. readCard := DllDef.MustFindProc("NationEcTrans")
  10551. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10552. if readCard == nil {
  10553. fmt.Println("readcard is nil")
  10554. readCard = DllDef.MustFindProc("NationEcTrans")
  10555. }
  10556. str1 := make([]byte, 2048)
  10557. data := make(map[string]interface{})
  10558. inputData := make(map[string]interface{})
  10559. inputData["orgId"] = miConfig.Code
  10560. inputData["businessType"] = "01101"
  10561. inputData["operatorId"] = "1"
  10562. inputData["operatorName"] = "huangchuang"
  10563. inputData["officeId"] = "101"
  10564. inputData["officeName"] = "xuetou"
  10565. inputData["deviceType"] = ""
  10566. data["data"] = inputData
  10567. data["transType"] = "ec.query"
  10568. data["orgId"] = miConfig.Code
  10569. bytesData, _ := json.Marshal(data)
  10570. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  10571. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10572. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  10573. fmt.Println(ret2)
  10574. fmt.Println(string(str1))
  10575. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10576. if ret2 != 0 {
  10577. return ""
  10578. }
  10579. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  10580. initEleFlag = 1
  10581. }
  10582. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  10583. }
  10584. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  10585. // // 构建命令
  10586. // cmd := exec.Command("python", "b.py")
  10587. //
  10588. // // 执行命令并等待完成
  10589. // output, err := cmd.CombinedOutput()
  10590. // if err != nil {
  10591. // fmt.Println("Error executing Python script:", err)
  10592. // return
  10593. // }
  10594. //
  10595. // // 打印Python脚本的输出
  10596. // fmt.Println(string(output))
  10597. //}
  10598. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  10599. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  10600. readCard := DllDef.MustFindProc("gxyb_call")
  10601. if readCard == nil {
  10602. fmt.Println("readcard is nil")
  10603. readCard = DllDef.MustFindProc("gxyb_call")
  10604. }
  10605. str := make([]byte, 1024)
  10606. str1 := make([]byte, 1024)
  10607. //data := make(map[string]interface{})
  10608. currentTime := time.Now()
  10609. // 格式化时间为 "YYYYMMDDHH24MISS"
  10610. formattedTime := currentTime.Format("20060102150405")
  10611. inputData := make(map[string]interface{})
  10612. inputData2 := make(map[string]interface{})
  10613. inputData["transNo"] = "1401"
  10614. inputData["transType"] = "passwordCheck"
  10615. inputData["timestamp"] = formattedTime
  10616. inputData2["fixmedinsCode"] = code
  10617. inputData2["psnNo"] = ""
  10618. inputData["data"] = inputData2
  10619. jsonBytes, err := json.Marshal(inputData)
  10620. if err != nil {
  10621. fmt.Println("Error encoding map to JSON:", err)
  10622. }
  10623. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  10624. fmt.Println(string(str1))
  10625. fmt.Println(string(str))
  10626. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10627. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10628. if ret2 != 0 {
  10629. return ""
  10630. }
  10631. return string(str)
  10632. }
  10633. func (c *HisApiController) GetoleInfo() Response {
  10634. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  10635. defer ole.CoUninitialize()
  10636. // Replace with the ProgID or CLSID of your COM object
  10637. progID := "YinHai.XJ.Actual.Interface.New"
  10638. // Create COM object
  10639. unknown, err := oleutil.CreateObject(progID)
  10640. if err != nil {
  10641. fmt.Println("Unable to create COM object:", err)
  10642. }
  10643. defer unknown.Release()
  10644. // Query for the IDispatch interface
  10645. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  10646. if err != nil {
  10647. fmt.Println("Unable to get IDispatch interface:", err)
  10648. }
  10649. defer dispatch.Release()
  10650. // Prepare parameters
  10651. transNo := "1401"
  10652. transType := "passwordCheck"
  10653. timestamp := time.Now().Unix()
  10654. fixmedinsCode := "H45072101171"
  10655. psnNo := ""
  10656. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  10657. result2 := ""
  10658. // Call COM object's method using the IDispatch interface
  10659. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  10660. fmt.Println(resulr)
  10661. fmt.Println(result2)
  10662. if err != nil {
  10663. fmt.Println("调用COM对象方法失败:", err)
  10664. }
  10665. var response Response
  10666. err2 := json.Unmarshal([]byte(result2), &response)
  10667. if err2 != nil {
  10668. fmt.Println("解析JSON失败:", err)
  10669. }
  10670. return response
  10671. }
  10672. func (c *HisApiController) GetBasBaseInfo() string {
  10673. DllDef := syscall.MustLoadDLL("SSCard.dll")
  10674. readCard := DllDef.MustFindProc("ReadCardBas")
  10675. if readCard == nil {
  10676. fmt.Println("readcard is nil")
  10677. readCard = DllDef.MustFindProc("ReadCardBas")
  10678. }
  10679. str := make([]byte, 1024)
  10680. str1 := make([]byte, 1024)
  10681. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  10682. fmt.Println(string(str1))
  10683. fmt.Println(string(str))
  10684. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10685. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10686. if ret2 != 0 {
  10687. return ""
  10688. }
  10689. return string(str)
  10690. }
  10691. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  10692. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  10693. readCard := DllDef.MustFindProc("read_cardinfo")
  10694. if readCard == nil {
  10695. fmt.Println("readcard is nil")
  10696. readCard = DllDef.MustFindProc("read_cardinfo")
  10697. }
  10698. str := make([]byte, 1024) //卡号
  10699. str1 := make([]byte, 1024) //卡识别码
  10700. str2 := make([]byte, 1024) //身份证号
  10701. str3 := make([]byte, 1024) //姓名
  10702. str4 := make([]byte, 1024) //错误信息
  10703. 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])))
  10704. fmt.Println(string(str1))
  10705. fmt.Println(string(str))
  10706. fmt.Println(string(str2))
  10707. fmt.Println(string(str3))
  10708. fmt.Println(string(str4))
  10709. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  10710. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  10711. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  10712. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  10713. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  10714. if ret2 != 0 {
  10715. return "", "", "", "", ""
  10716. }
  10717. return string(str), string(str1), string(str2), string(str3), string(str4)
  10718. }
  10719. type CustomFundPay struct {
  10720. FundPayType string `json:"fund_pay_type"`
  10721. FundPayamt float64 `json:"fund_payamt"`
  10722. InscpScpAmt float64 `json:"inscp_scp_amt"`
  10723. }
  10724. //func (c *HisApiController) GetBatchSettleList() {
  10725. // start_time_str := c.GetString("start_time")
  10726. // //end_time_str := c.GetString("end_time")
  10727. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10728. //
  10729. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  10730. //
  10731. // for _, item := range orders {
  10732. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  10733. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  10734. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  10735. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  10736. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10737. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  10738. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10739. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  10740. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  10741. //
  10742. // if order.ID == 0 {
  10743. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  10744. // return
  10745. // }
  10746. //
  10747. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  10748. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  10749. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  10750. // //fmt.Println(count)
  10751. // //var zero string
  10752. // //number := count + 1
  10753. // //if number >= 1000 {
  10754. // // zero = "0000" + strconv.FormatInt(number, 10)
  10755. // //} else if number >= 10000 {
  10756. // // zero = "000" + strconv.FormatInt(number, 10)
  10757. // //} else if number >= 100000 {
  10758. // // zero = "00" + strconv.FormatInt(number, 10)
  10759. // //} else if number >= 1000000 {
  10760. // // zero = "0" + strconv.FormatInt(number, 10)
  10761. // //} else {
  10762. // // zero = strconv.FormatInt(number, 10)
  10763. // //}
  10764. // //fmt.Println(zero)
  10765. //
  10766. // struct4101 := service.Struct4101{
  10767. // PsnNo: order.PsnNo,
  10768. // MdtrtId: order.MdtrtId,
  10769. // SetlId: order.SetlId,
  10770. // PsnName: order.PsnName,
  10771. // Gend: order.Gend,
  10772. // Brdy: his.Brdy,
  10773. // Age: his.Age,
  10774. // Naty: order.Naty,
  10775. // PatnCertType: "01",
  10776. // Certno: order.Certno,
  10777. // Prfs: "90",
  10778. // ConerName: roles[0].UserName,
  10779. // PatnRlts: "99",
  10780. // ConerAddr: miConfig.OrgName,
  10781. // ConerTel: admin.Mobile,
  10782. // HiType: order.Insutype,
  10783. // Insuplc: miConfig.InsuplcAdmdvs,
  10784. // MaindiagFlag: "1",
  10785. // BillCode: order.SetlId,
  10786. // BillNo: order.SetlId,
  10787. // BizSn: order.Number,
  10788. // PsnSelfPay: order.PsnPartAmt,
  10789. // PsnOwnPay: order.PsnPartAmt,
  10790. // AcctPay: order.AcctPay,
  10791. // PsnCashpay: order.PsnCashPay,
  10792. // HiPaymtd: "1",
  10793. // Hsorg: miConfig.InsuplcAdmdvs,
  10794. // HsorgOpter: miConfig.InsuplcAdmdvs,
  10795. // MedinsFillPsn: curRoles.UserName,
  10796. // MedinsFillDept: miConfig.OrgName,
  10797. // IptMedType: "2",
  10798. // }
  10799. // struct4101.SetlBegnDate = order.SetlTime
  10800. // struct4101.SetlEndDate = order.SetlTime
  10801. // time_arr := strings.Split(order.SetlTime, " ")
  10802. // struct4101.AdmTime = time_arr[0]
  10803. // struct4101.AdmEndTime = time_arr[0]
  10804. //
  10805. // var rf []CustomFundPay
  10806. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  10807. //
  10808. // var tempFunPays []service.CustomStruct
  10809. // for _, item := range rf {
  10810. // var tempFunPay service.CustomStruct
  10811. // tempFunPay.FundPayamt = item.FundPayamt
  10812. // tempFunPay.FundPayType = item.FundPayType
  10813. // tempFunPays = append(tempFunPays, tempFunPay)
  10814. // }
  10815. // struct4101.CustomStruct = tempFunPays
  10816. //
  10817. // var tempDiaginfos []service.DiaginfoStructTwo
  10818. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  10819. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  10820. //
  10821. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  10822. // var config []*models.HisXtDiagnoseConfig
  10823. // for _, item := range diagnosis_ids {
  10824. // id, _ := strconv.ParseInt(item, 10, 64)
  10825. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  10826. // config = append(config, &diagnosisConfig)
  10827. // }
  10828. //
  10829. // for index, item := range config {
  10830. // if index == 0 {
  10831. // var tempDiaginfo service.DiaginfoStructTwo
  10832. // tempDiaginfo.DiagCode = item.CountryCode
  10833. // tempDiaginfo.DiagName = item.CountryContentName
  10834. // tempDiaginfo.DiagType = "1"
  10835. // tempDiaginfo.MaindiagFlag = "1"
  10836. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10837. // } else {
  10838. // var tempDiaginfo service.DiaginfoStructTwo
  10839. // tempDiaginfo.DiagCode = item.CountryCode
  10840. // tempDiaginfo.DiagName = item.CountryContentName
  10841. // tempDiaginfo.DiagType = "1"
  10842. // tempDiaginfo.MaindiagFlag = "0"
  10843. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  10844. // }
  10845. // }
  10846. // struct4101.Diseinfo = tempDiaginfos
  10847. //
  10848. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  10849. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  10850. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  10851. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  10852. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  10853. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  10854. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  10855. //
  10856. // var iteminfo service.IteminfoStruct
  10857. //
  10858. // var bedCostTotal float64 = 0 //床位总费
  10859. // var bedCostSelfTotal float64 = 0 //床位自费
  10860. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  10861. //
  10862. // var operationCostTotal float64 = 0 //手术费
  10863. // var operationCostSelfTotal float64 = 0 //手术费
  10864. // var operationCostPartSelfTotal float64 = 0 //手术费
  10865. //
  10866. // var otherCostTotal float64 = 0 //其他费用
  10867. // var otherCostSelfTotal float64 = 0 //其他费用
  10868. // var otherCostPartSelfTotal float64 = 0 //其他费用
  10869. //
  10870. // var materialCostTotal float64 = 0 //材料费
  10871. // var materialCostSelfTotal float64 = 0 //材料费
  10872. // var materialCostPartSelfTotal float64 = 0 //材料费
  10873. //
  10874. // var westernMedicineCostTotal float64 = 0 //西药费
  10875. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  10876. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  10877. //
  10878. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  10879. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  10880. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  10881. //
  10882. // var checkCostTotal float64 = 0 //检查费
  10883. // var checkCostSelfTotal float64 = 0 //检查费
  10884. // var checkCostPartSelfTotal float64 = 0 //检查费
  10885. //
  10886. // var laboratoryCostTotal float64 = 0 //化验费
  10887. // var laboratoryCostSelfTotal float64 = 0 //化验费
  10888. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  10889. //
  10890. // var treatCostTotal float64 = 0 //治疗费用
  10891. // var treatCostSelfTotal float64 = 0 //治疗费用
  10892. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  10893. //
  10894. // decimal.DivisionPrecision = 2
  10895. //
  10896. // var bed_fulamt_ownpay_amt float64 = 0
  10897. // var operation_fulamt_ownpay_amt float64 = 0
  10898. // var other_fulamt_ownpay_amt float64 = 0
  10899. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  10900. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  10901. // var check_fulamt_ownpay_amt float64 = 0
  10902. // var material_fulamt_ownpay_amt float64 = 0
  10903. // var laboratory_fulamt_ownpay_amt float64 = 0
  10904. // var treat_fulamt_ownpay_amt float64 = 0
  10905. //
  10906. // var bed_claa_sunmfee float64 = 0
  10907. // var bed_clab_amt float64 = 0
  10908. // var bed_other_amt float64 = 0
  10909. //
  10910. // var operation_claa_sunmfee float64 = 0
  10911. // var operation_clab_amt float64 = 0
  10912. // var operation_other_amt float64 = 0
  10913. //
  10914. // var other_claa_sunmfee float64 = 0
  10915. // var other_clab_amt float64 = 0
  10916. // var other_other_amt float64 = 0
  10917. //
  10918. // var westernMedicine_claa_sunmfee float64 = 0
  10919. // var westernMedicine_clab_amt float64 = 0
  10920. // var westernMedicine_other_amt float64 = 0
  10921. //
  10922. // var chineseTraditional_claa_sunmfee float64 = 0
  10923. // var chineseTraditional_clab_amt float64 = 0
  10924. // var chineseTraditional_other_amt float64 = 0
  10925. //
  10926. // var check_claa_sunmfee float64 = 0
  10927. // var check_clab_amt float64 = 0
  10928. // var check_other_amt float64 = 0
  10929. //
  10930. // var material_claa_sunmfee float64 = 0
  10931. // var material_clab_amt float64 = 0
  10932. // var material_other_amt float64 = 0
  10933. //
  10934. // var laboratory_claa_sunmfee float64 = 0
  10935. // var laboratory_clab_amt float64 = 0
  10936. // var laboratory_other_amt float64 = 0
  10937. //
  10938. // var treat_claa_sunmfee float64 = 0
  10939. // var treat_clab_amt float64 = 0
  10940. // var treat_other_amt float64 = 0
  10941. //
  10942. // for _, item := range order.HisOrderInfo {
  10943. // if item.MedChrgitmType == "01" { //床位费
  10944. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10945. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10946. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10947. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10948. // if item.ChrgitmLv == "1" {
  10949. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10950. // }
  10951. // if item.ChrgitmLv == "2" {
  10952. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10953. //
  10954. // }
  10955. // if item.ChrgitmLv == "3" {
  10956. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10957. // }
  10958. //
  10959. // }
  10960. //
  10961. // if item.MedChrgitmType == "03" { //检查费
  10962. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10963. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10964. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10965. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10966. // if item.ChrgitmLv == "1" {
  10967. //
  10968. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10969. //
  10970. // }
  10971. // if item.ChrgitmLv == "2" {
  10972. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10973. //
  10974. // }
  10975. // if item.ChrgitmLv == "3" {
  10976. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10977. // }
  10978. // }
  10979. //
  10980. // if item.MedChrgitmType == "04" { //化验费
  10981. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10982. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10983. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10984. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  10985. // if item.ChrgitmLv == "1" {
  10986. //
  10987. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  10988. //
  10989. // }
  10990. // if item.ChrgitmLv == "2" {
  10991. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  10992. //
  10993. // }
  10994. // if item.ChrgitmLv == "3" {
  10995. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  10996. // }
  10997. // }
  10998. //
  10999. // if item.MedChrgitmType == "05" { //治疗费
  11000. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11001. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11002. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11003. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11004. // if item.ChrgitmLv == "1" {
  11005. //
  11006. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11007. //
  11008. // }
  11009. // if item.ChrgitmLv == "2" {
  11010. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11011. //
  11012. // }
  11013. // if item.ChrgitmLv == "3" {
  11014. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11015. // }
  11016. // }
  11017. //
  11018. // if item.MedChrgitmType == "06" { //手术费
  11019. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11020. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11021. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11022. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11023. //
  11024. // if item.ChrgitmLv == "1" {
  11025. //
  11026. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11027. //
  11028. // }
  11029. // if item.ChrgitmLv == "2" {
  11030. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11031. //
  11032. // }
  11033. // if item.ChrgitmLv == "3" {
  11034. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11035. // }
  11036. // }
  11037. //
  11038. // if item.MedChrgitmType == "08" { //材料费
  11039. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11040. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11041. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11042. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11043. // if item.ChrgitmLv == "1" {
  11044. //
  11045. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11046. //
  11047. // }
  11048. // if item.ChrgitmLv == "2" {
  11049. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11050. //
  11051. // }
  11052. // if item.ChrgitmLv == "3" {
  11053. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11054. // }
  11055. // }
  11056. //
  11057. // if item.MedChrgitmType == "09" { //西药费
  11058. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11059. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11060. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11061. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11062. // if item.ChrgitmLv == "1" {
  11063. //
  11064. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11065. //
  11066. // }
  11067. // if item.ChrgitmLv == "2" {
  11068. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11069. //
  11070. // }
  11071. // if item.ChrgitmLv == "3" {
  11072. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11073. // }
  11074. // }
  11075. //
  11076. // if item.MedChrgitmType == "11" { //中成费
  11077. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11078. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11079. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11080. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11081. // if item.ChrgitmLv == "1" {
  11082. //
  11083. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11084. //
  11085. // }
  11086. // if item.ChrgitmLv == "2" {
  11087. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11088. //
  11089. // }
  11090. // if item.ChrgitmLv == "3" {
  11091. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11092. // }
  11093. // }
  11094. //
  11095. // if item.MedChrgitmType == "14" { //其他费
  11096. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11097. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11098. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11099. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11100. // if item.ChrgitmLv == "1" {
  11101. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11102. //
  11103. // }
  11104. // if item.ChrgitmLv == "2" {
  11105. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11106. //
  11107. // }
  11108. // if item.ChrgitmLv == "3" {
  11109. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11110. // }
  11111. // }
  11112. //
  11113. // }
  11114. //
  11115. // var iteminfoStructs []service.IteminfoStruct
  11116. //
  11117. // if bedCostTotal != 0 {
  11118. // iteminfo.MedChrgitm = "01"
  11119. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11120. // iteminfo.Amt = bedCostTotal
  11121. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11122. // iteminfo.ClabAmt = bed_clab_amt
  11123. // iteminfo.OthAmt = bed_other_amt
  11124. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11125. // }
  11126. //
  11127. // if checkCostTotal != 0 {
  11128. // iteminfo.MedChrgitm = "03"
  11129. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11130. // iteminfo.Amt = checkCostTotal
  11131. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11132. // iteminfo.ClabAmt = check_clab_amt
  11133. // iteminfo.OthAmt = check_other_amt
  11134. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11135. //
  11136. // }
  11137. //
  11138. // if laboratoryCostTotal != 0 {
  11139. // iteminfo.MedChrgitm = "04"
  11140. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11141. // iteminfo.Amt = laboratoryCostTotal
  11142. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11143. // iteminfo.ClabAmt = laboratory_clab_amt
  11144. // iteminfo.OthAmt = laboratory_other_amt
  11145. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11146. //
  11147. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11148. //
  11149. // }
  11150. //
  11151. // if treatCostTotal != 0 {
  11152. // iteminfo.MedChrgitm = "05"
  11153. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11154. // iteminfo.Amt = treatCostTotal
  11155. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11156. // iteminfo.ClabAmt = treat_clab_amt
  11157. // iteminfo.OthAmt = treat_other_amt
  11158. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11159. // //(struct4101.IteminfoStruct, iteminfo)
  11160. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11161. // }
  11162. //
  11163. // if operationCostTotal != 0 {
  11164. // iteminfo.MedChrgitm = "06"
  11165. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11166. // iteminfo.Amt = operationCostTotal
  11167. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11168. // iteminfo.ClabAmt = operation_clab_amt
  11169. // iteminfo.OthAmt = operation_other_amt
  11170. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11171. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11172. // }
  11173. //
  11174. // if materialCostTotal != 0 {
  11175. // iteminfo.MedChrgitm = "08"
  11176. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11177. // iteminfo.Amt = materialCostTotal
  11178. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11179. // iteminfo.ClabAmt = material_clab_amt
  11180. // iteminfo.OthAmt = material_other_amt
  11181. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11182. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11183. // }
  11184. //
  11185. // if westernMedicineCostTotal != 0 {
  11186. // iteminfo.MedChrgitm = "09"
  11187. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11188. // iteminfo.Amt = westernMedicineCostTotal
  11189. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11190. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11191. // iteminfo.OthAmt = westernMedicine_other_amt
  11192. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11193. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11194. //
  11195. // }
  11196. // if chineseTraditionalMedicineCostTotal != 0 {
  11197. // iteminfo.MedChrgitm = "11"
  11198. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11199. // iteminfo.Amt = westernMedicineCostTotal
  11200. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11201. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11202. // iteminfo.OthAmt = westernMedicine_other_amt
  11203. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11204. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11205. //
  11206. // }
  11207. // if otherCostTotal != 0 {
  11208. // iteminfo.MedChrgitm = "14"
  11209. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11210. // iteminfo.Amt = otherCostTotal
  11211. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11212. // iteminfo.ClabAmt = other_clab_amt
  11213. // iteminfo.OthAmt = other_other_amt
  11214. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11215. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11216. //
  11217. // }
  11218. // struct4101.IteminfoStruct = iteminfoStructs
  11219. // struct4101.Ntly = "中国"
  11220. // struct4101.AdmCaty = "A03.06"
  11221. //
  11222. // struct4101.DoctorName = doctor.UserName
  11223. // struct4101.DoctorCode = doctor.DoctorNumber
  11224. //
  11225. // var res ResultSeventeen
  11226. //
  11227. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11228. // struct4101.BillCode = order.Number
  11229. // struct4101.BillNo = order.SetlId
  11230. // var resOther ResultSeventeenOther
  11231. // var pp models.PublicParams
  11232. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11233. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11234. // pp.FixmedinsName = miConfig.OrgName
  11235. // pp.FixmedinsCode = miConfig.Code
  11236. // pp.RequestUrl = miConfig.Url
  11237. // pp.Cainfo = miConfig.Cainfo
  11238. // pp.SecretKey = miConfig.SecretKey
  11239. // pp.AccessKey = miConfig.AccessKey
  11240. // pp.OpterName = curRoles.UserName
  11241. //
  11242. // client := &http.Client{}
  11243. // var req *http.Request
  11244. // data := make(map[string]interface{})
  11245. // data["struct4101"] = struct4101
  11246. // data["pp"] = pp
  11247. // bytesData, _ := json.Marshal(data)
  11248. // if miConfig.MdtrtareaAdmvs == "320921" {
  11249. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11250. // } else {
  11251. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11252. // }
  11253. // resp, _ := client.Do(req)
  11254. // defer resp.Body.Close()
  11255. // body, ioErr := ioutil.ReadAll(resp.Body)
  11256. // if ioErr != nil {
  11257. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11259. // return
  11260. // }
  11261. // var respJSON map[string]interface{}
  11262. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11263. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11264. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11265. // return
  11266. // }
  11267. //
  11268. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11269. // userJSONBytes, _ := json.Marshal(respJSON)
  11270. // fmt.Println("log")
  11271. // fmt.Println(string(userJSONBytes))
  11272. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11273. // utils.ErrorLog("解析失败:%v", err)
  11274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11275. // return
  11276. // }
  11277. // res.InfRefmsgid = resOther.InfRefmsgid
  11278. // res.Output = resOther.Output
  11279. // res.ErrMsg = resOther.ErrMsg
  11280. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11281. // res.Infcode = infocode
  11282. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  11283. //
  11284. // var pp models.PublicParams
  11285. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11286. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11287. // pp.FixmedinsName = miConfig.OrgName
  11288. // pp.FixmedinsCode = miConfig.Code
  11289. // pp.RequestUrl = miConfig.Url
  11290. // pp.Cainfo = miConfig.Cainfo
  11291. // pp.SecretKey = miConfig.SecretKey
  11292. // pp.AccessKey = miConfig.AccessKey
  11293. // pp.OpterName = curRoles.UserName
  11294. // result, _ := service.Jxyb4101(struct4101, pp)
  11295. // var dat map[string]interface{}
  11296. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11297. // fmt.Println(dat)
  11298. // } else {
  11299. // fmt.Println(err)
  11300. // }
  11301. // userJSONBytes, _ := json.Marshal(dat)
  11302. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11303. // utils.ErrorLog("解析失败:%v", err)
  11304. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11305. // return
  11306. // }
  11307. //
  11308. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  11309. // var pp models.PublicParams
  11310. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11311. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11312. // pp.FixmedinsName = miConfig.OrgName
  11313. // pp.FixmedinsCode = miConfig.Code
  11314. // pp.RequestUrl = miConfig.Url
  11315. // pp.Cainfo = miConfig.Cainfo
  11316. // pp.SecretKey = miConfig.SecretKey
  11317. // pp.AccessKey = miConfig.AccessKey
  11318. // pp.OpterName = curRoles.UserName
  11319. // result, _ := service.Hnyb4101(struct4101, pp)
  11320. // var dat map[string]interface{}
  11321. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11322. // fmt.Println(dat)
  11323. // } else {
  11324. // fmt.Println(err)
  11325. // }
  11326. // userJSONBytes, _ := json.Marshal(dat)
  11327. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11328. // utils.ErrorLog("解析失败:%v", err)
  11329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11330. // return
  11331. // }
  11332. //
  11333. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  11334. // var resOther ResultSeventeenOther
  11335. //
  11336. // var pp models.PublicParams
  11337. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11338. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11339. // pp.FixmedinsName = miConfig.OrgName
  11340. // pp.FixmedinsCode = miConfig.Code
  11341. // pp.RequestUrl = miConfig.Url
  11342. // pp.Cainfo = miConfig.Cainfo
  11343. // pp.SecretKey = miConfig.SecretKey
  11344. // pp.AccessKey = miConfig.AccessKey
  11345. // pp.OpterName = curRoles.UserName
  11346. // client := &http.Client{}
  11347. // var req *http.Request
  11348. // data := make(map[string]interface{})
  11349. // data["struct4101"] = struct4101
  11350. // data["pp"] = pp
  11351. // bytesData, _ := json.Marshal(data)
  11352. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11353. // resp, _ := client.Do(req)
  11354. // defer resp.Body.Close()
  11355. // body, ioErr := ioutil.ReadAll(resp.Body)
  11356. // if ioErr != nil {
  11357. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11359. // return
  11360. // }
  11361. // var respJSON map[string]interface{}
  11362. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11363. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11364. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11365. // return
  11366. // }
  11367. //
  11368. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11369. // userJSONBytes, _ := json.Marshal(respJSON)
  11370. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11371. // utils.ErrorLog("解析失败:%v", err)
  11372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11373. // return
  11374. // }
  11375. // res.InfRefmsgid = resOther.InfRefmsgid
  11376. // res.Output = resOther.Output
  11377. // res.ErrMsg = resOther.ErrMsg
  11378. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11379. // res.Infcode = infocode
  11380. //
  11381. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  11382. // var pp models.PublicParams
  11383. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11384. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11385. // pp.FixmedinsName = miConfig.OrgName
  11386. // pp.FixmedinsCode = miConfig.Code
  11387. // pp.RequestUrl = miConfig.Url
  11388. // pp.Cainfo = miConfig.Cainfo
  11389. // pp.SecretKey = miConfig.SecretKey
  11390. // pp.AccessKey = miConfig.AccessKey
  11391. // pp.OpterName = curRoles.UserName
  11392. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  11393. // fmt.Println(requestLog)
  11394. // fmt.Println(errMsgLog)
  11395. //
  11396. // saveLog(result, requestLog, "4101a", "上传清单")
  11397. //
  11398. // var dat map[string]interface{}
  11399. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11400. // fmt.Println(dat)
  11401. // } else {
  11402. // fmt.Println(err)
  11403. // }
  11404. // userJSONBytes, _ := json.Marshal(dat)
  11405. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11406. // utils.ErrorLog("解析失败:%v", err)
  11407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11408. // return
  11409. // }
  11410. //
  11411. // } else {
  11412. //
  11413. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  11414. // var dat map[string]interface{}
  11415. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11416. // fmt.Println(dat)
  11417. // } else {
  11418. // fmt.Println(err)
  11419. // }
  11420. // userJSONBytes, _ := json.Marshal(dat)
  11421. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11422. // utils.ErrorLog("解析失败:%v", err)
  11423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11424. // return
  11425. // }
  11426. // }
  11427. //
  11428. // if res.Infcode != 0 {
  11429. // adminUser := c.GetAdminUserInfo()
  11430. // errlog := &models.HisOrderError{
  11431. // UserOrgId: adminUser.CurrentOrgId,
  11432. // Ctime: time.Now().Unix(),
  11433. // Mtime: time.Now().Unix(),
  11434. // ErrMsg: res.ErrMsg,
  11435. // Status: 1,
  11436. // PatientId: order.ID,
  11437. // Stage: 10265,
  11438. // }
  11439. // service.CreateErrMsgLog(errlog)
  11440. // continue
  11441. // } else {
  11442. // //order.FaPiaoNumber = zero
  11443. // //order.FaPiaoCode = last_order.FaPiaoCode
  11444. // //service.UpdateOrder(order)
  11445. // hisFundSettleListResult := &models.HisFundSettleListResult{
  11446. // Number: res.Output.SetlListId,
  11447. // Status: 1,
  11448. // Ctime: time.Now().Unix(),
  11449. // Mtime: time.Now().Unix(),
  11450. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11451. // IsUpload: 1,
  11452. // OrderId: order.ID,
  11453. // }
  11454. // service.CreateUploadRecord(hisFundSettleListResult)
  11455. // c.ServeSuccessJSON(map[string]interface{}{
  11456. // "msg": "上传成功",
  11457. // "result": hisFundSettleListResult,
  11458. // })
  11459. // continue
  11460. // }
  11461. // }
  11462. //}
  11463. func (c *HisApiController) GetbatchSettleList() {
  11464. //order_id, _ := c.GetInt64("order_id")
  11465. admin_user_id, _ := c.GetInt64("admin_user_id")
  11466. orders, _ := service.GetAllHisOrderTwo10485()
  11467. for _, item := range orders {
  11468. order, _ := service.GetHisOrderByIDTwo(item.ID)
  11469. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11470. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11471. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11472. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11473. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11474. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11475. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11476. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11477. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11478. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11479. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11480. //fmt.Println(count)
  11481. //var zero string
  11482. //number := count + 1
  11483. //if number >= 1000 {
  11484. // zero = "0000" + strconv.FormatInt(number, 10)
  11485. //} else if number >= 10000 {
  11486. // zero = "000" + strconv.FormatInt(number, 10)
  11487. //} else if number >= 100000 {
  11488. // zero = "00" + strconv.FormatInt(number, 10)
  11489. //} else if number >= 1000000 {
  11490. // zero = "0" + strconv.FormatInt(number, 10)
  11491. //} else {
  11492. // zero = strconv.FormatInt(number, 10)
  11493. //}
  11494. //fmt.Println(zero)
  11495. struct4101 := service.Struct4101{
  11496. PsnNo: order.PsnNo,
  11497. MdtrtId: order.MdtrtId,
  11498. SetlId: order.SetlId,
  11499. PsnName: order.PsnName,
  11500. Gend: order.Gend,
  11501. Brdy: his.Brdy,
  11502. Age: his.Age,
  11503. Naty: order.Naty,
  11504. PatnCertType: "01",
  11505. Certno: order.Certno,
  11506. Prfs: "90",
  11507. ConerName: roles[0].UserName,
  11508. PatnRlts: "99",
  11509. ConerAddr: miConfig.OrgName,
  11510. ConerTel: admin.Mobile,
  11511. HiType: order.Insutype,
  11512. Insuplc: miConfig.InsuplcAdmdvs,
  11513. MaindiagFlag: "1",
  11514. BillCode: order.SetlId,
  11515. BillNo: order.SetlId,
  11516. BizSn: order.Number,
  11517. PsnSelfPay: order.PsnPartAmt,
  11518. PsnOwnPay: order.PsnPartAmt,
  11519. AcctPay: order.AcctPay,
  11520. PsnCashpay: order.PsnCashPay,
  11521. HiPaymtd: "1",
  11522. Hsorg: miConfig.InsuplcAdmdvs,
  11523. HsorgOpter: miConfig.InsuplcAdmdvs,
  11524. MedinsFillPsn: curRoles.UserName,
  11525. MedinsFillDept: miConfig.OrgName,
  11526. IptMedType: "2",
  11527. }
  11528. struct4101.SetlBegnDate = order.SetlTime
  11529. struct4101.SetlEndDate = order.SetlTime
  11530. time_arr := strings.Split(order.SetlTime, " ")
  11531. struct4101.AdmTime = time_arr[0]
  11532. struct4101.AdmEndTime = time_arr[0]
  11533. //var rf []CustomFundPay
  11534. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  11535. //
  11536. //var tempFunPays []service.CustomStruct
  11537. //for _, item := range rf {
  11538. // var tempFunPay service.CustomStruct
  11539. // tempFunPay.FundPayamt = item.FundPayamt
  11540. // tempFunPay.FundPayType = item.FundPayType
  11541. // tempFunPays = append(tempFunPays, tempFunPay)
  11542. //}
  11543. //struct4101.CustomStruct = tempFunPays
  11544. var tempDiaginfos []service.DiaginfoStructTwo
  11545. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11546. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11547. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11548. var config []*models.HisXtDiagnoseConfig
  11549. for _, item := range diagnosis_ids {
  11550. id, _ := strconv.ParseInt(item, 10, 64)
  11551. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11552. config = append(config, &diagnosisConfig)
  11553. }
  11554. for index, item := range config {
  11555. if index == 0 {
  11556. var tempDiaginfo service.DiaginfoStructTwo
  11557. tempDiaginfo.DiagCode = item.CountryCode
  11558. tempDiaginfo.DiagName = item.CountryContentName
  11559. tempDiaginfo.DiagType = "1"
  11560. tempDiaginfo.MaindiagFlag = "1"
  11561. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11562. } else {
  11563. var tempDiaginfo service.DiaginfoStructTwo
  11564. tempDiaginfo.DiagCode = item.CountryCode
  11565. tempDiaginfo.DiagName = item.CountryContentName
  11566. tempDiaginfo.DiagType = "1"
  11567. tempDiaginfo.MaindiagFlag = "0"
  11568. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11569. }
  11570. }
  11571. struct4101.Diseinfo = tempDiaginfos
  11572. sickConfigTwo, _ := service.FindSickById(his.SickType)
  11573. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11574. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11575. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11576. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11577. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11578. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11579. var iteminfo service.IteminfoStruct
  11580. var bedCostTotal float64 = 0 //床位总费
  11581. var bedCostSelfTotal float64 = 0 //床位自费
  11582. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11583. var operationCostTotal float64 = 0 //手术费
  11584. var operationCostSelfTotal float64 = 0 //手术费
  11585. var operationCostPartSelfTotal float64 = 0 //手术费
  11586. var otherCostTotal float64 = 0 //其他费用
  11587. var otherCostSelfTotal float64 = 0 //其他费用
  11588. var otherCostPartSelfTotal float64 = 0 //其他费用
  11589. var materialCostTotal float64 = 0 //材料费
  11590. var materialCostSelfTotal float64 = 0 //材料费
  11591. var materialCostPartSelfTotal float64 = 0 //材料费
  11592. var westernMedicineCostTotal float64 = 0 //西药费
  11593. var westernMedicineCostSelfTotal float64 = 0 //西药费
  11594. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11595. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11596. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11597. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11598. var checkCostTotal float64 = 0 //检查费
  11599. var checkCostSelfTotal float64 = 0 //检查费
  11600. var checkCostPartSelfTotal float64 = 0 //检查费
  11601. var laboratoryCostTotal float64 = 0 //化验费
  11602. var laboratoryCostSelfTotal float64 = 0 //化验费
  11603. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11604. var treatCostTotal float64 = 0 //治疗费用
  11605. var treatCostSelfTotal float64 = 0 //治疗费用
  11606. var treatCostPartSelfTotal float64 = 0 //治疗费用
  11607. decimal.DivisionPrecision = 2
  11608. var bed_fulamt_ownpay_amt float64 = 0
  11609. var operation_fulamt_ownpay_amt float64 = 0
  11610. var other_fulamt_ownpay_amt float64 = 0
  11611. var westernMedicine_fulamt_ownpay_amt float64 = 0
  11612. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11613. var check_fulamt_ownpay_amt float64 = 0
  11614. var material_fulamt_ownpay_amt float64 = 0
  11615. var laboratory_fulamt_ownpay_amt float64 = 0
  11616. var treat_fulamt_ownpay_amt float64 = 0
  11617. var bed_claa_sunmfee float64 = 0
  11618. var bed_clab_amt float64 = 0
  11619. var bed_other_amt float64 = 0
  11620. var operation_claa_sunmfee float64 = 0
  11621. var operation_clab_amt float64 = 0
  11622. var operation_other_amt float64 = 0
  11623. var other_claa_sunmfee float64 = 0
  11624. var other_clab_amt float64 = 0
  11625. var other_other_amt float64 = 0
  11626. var westernMedicine_claa_sunmfee float64 = 0
  11627. var westernMedicine_clab_amt float64 = 0
  11628. var westernMedicine_other_amt float64 = 0
  11629. var chineseTraditional_claa_sunmfee float64 = 0
  11630. var chineseTraditional_clab_amt float64 = 0
  11631. var chineseTraditional_other_amt float64 = 0
  11632. var check_claa_sunmfee float64 = 0
  11633. var check_clab_amt float64 = 0
  11634. var check_other_amt float64 = 0
  11635. var material_claa_sunmfee float64 = 0
  11636. var material_clab_amt float64 = 0
  11637. var material_other_amt float64 = 0
  11638. var laboratory_claa_sunmfee float64 = 0
  11639. var laboratory_clab_amt float64 = 0
  11640. var laboratory_other_amt float64 = 0
  11641. var treat_claa_sunmfee float64 = 0
  11642. var treat_clab_amt float64 = 0
  11643. var treat_other_amt float64 = 0
  11644. for _, item := range order.HisOrderInfo {
  11645. if item.MedChrgitmType == "01" { //床位费
  11646. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11647. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11648. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11649. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11650. if item.ChrgitmLv == "1" {
  11651. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11652. }
  11653. if item.ChrgitmLv == "2" {
  11654. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11655. }
  11656. if item.ChrgitmLv == "3" {
  11657. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11658. }
  11659. }
  11660. if item.MedChrgitmType == "03" { //检查费
  11661. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11662. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11663. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11664. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11665. if item.ChrgitmLv == "1" {
  11666. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11667. }
  11668. if item.ChrgitmLv == "2" {
  11669. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11670. }
  11671. if item.ChrgitmLv == "3" {
  11672. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11673. }
  11674. }
  11675. if item.MedChrgitmType == "04" { //化验费
  11676. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11677. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11678. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11679. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11680. if item.ChrgitmLv == "1" {
  11681. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11682. }
  11683. if item.ChrgitmLv == "2" {
  11684. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11685. }
  11686. if item.ChrgitmLv == "3" {
  11687. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11688. }
  11689. }
  11690. if item.MedChrgitmType == "05" { //治疗费
  11691. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11692. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11693. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11694. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11695. if item.ChrgitmLv == "1" {
  11696. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11697. }
  11698. if item.ChrgitmLv == "2" {
  11699. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11700. }
  11701. if item.ChrgitmLv == "3" {
  11702. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11703. }
  11704. }
  11705. if item.MedChrgitmType == "06" { //手术费
  11706. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11707. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11708. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11709. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11710. if item.ChrgitmLv == "1" {
  11711. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11712. }
  11713. if item.ChrgitmLv == "2" {
  11714. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11715. }
  11716. if item.ChrgitmLv == "3" {
  11717. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11718. }
  11719. }
  11720. if item.MedChrgitmType == "08" { //材料费
  11721. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11722. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11723. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11724. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11725. if item.ChrgitmLv == "1" {
  11726. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11727. }
  11728. if item.ChrgitmLv == "2" {
  11729. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11730. }
  11731. if item.ChrgitmLv == "3" {
  11732. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11733. }
  11734. }
  11735. if item.MedChrgitmType == "09" { //西药费
  11736. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11737. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11738. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11739. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11740. if item.ChrgitmLv == "1" {
  11741. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11742. }
  11743. if item.ChrgitmLv == "2" {
  11744. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11745. }
  11746. if item.ChrgitmLv == "3" {
  11747. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11748. }
  11749. }
  11750. if item.MedChrgitmType == "11" { //中成费
  11751. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11752. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11753. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11754. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11755. if item.ChrgitmLv == "1" {
  11756. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11757. }
  11758. if item.ChrgitmLv == "2" {
  11759. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11760. }
  11761. if item.ChrgitmLv == "3" {
  11762. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11763. }
  11764. }
  11765. if item.MedChrgitmType == "14" { //其他费
  11766. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11767. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11768. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11769. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11770. if item.ChrgitmLv == "1" {
  11771. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11772. }
  11773. if item.ChrgitmLv == "2" {
  11774. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11775. }
  11776. if item.ChrgitmLv == "3" {
  11777. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11778. }
  11779. }
  11780. }
  11781. var iteminfoStructs []service.IteminfoStruct
  11782. if bedCostTotal != 0 {
  11783. iteminfo.MedChrgitm = "01"
  11784. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11785. iteminfo.Amt = bedCostTotal
  11786. iteminfo.ClaaSumfee = bed_claa_sunmfee
  11787. iteminfo.ClabAmt = bed_clab_amt
  11788. iteminfo.OthAmt = bed_other_amt
  11789. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11790. }
  11791. if checkCostTotal != 0 {
  11792. iteminfo.MedChrgitm = "03"
  11793. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11794. iteminfo.Amt = checkCostTotal
  11795. iteminfo.ClaaSumfee = check_claa_sunmfee
  11796. iteminfo.ClabAmt = check_clab_amt
  11797. iteminfo.OthAmt = check_other_amt
  11798. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11799. }
  11800. if laboratoryCostTotal != 0 {
  11801. iteminfo.MedChrgitm = "04"
  11802. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11803. iteminfo.Amt = laboratoryCostTotal
  11804. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11805. iteminfo.ClabAmt = laboratory_clab_amt
  11806. iteminfo.OthAmt = laboratory_other_amt
  11807. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11808. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11809. }
  11810. if treatCostTotal != 0 {
  11811. iteminfo.MedChrgitm = "05"
  11812. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11813. iteminfo.Amt = treatCostTotal
  11814. iteminfo.ClaaSumfee = treat_claa_sunmfee
  11815. iteminfo.ClabAmt = treat_clab_amt
  11816. iteminfo.OthAmt = treat_other_amt
  11817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11818. //(struct4101.IteminfoStruct, iteminfo)
  11819. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11820. }
  11821. if operationCostTotal != 0 {
  11822. iteminfo.MedChrgitm = "06"
  11823. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11824. iteminfo.Amt = operationCostTotal
  11825. iteminfo.ClaaSumfee = operation_claa_sunmfee
  11826. iteminfo.ClabAmt = operation_clab_amt
  11827. iteminfo.OthAmt = operation_other_amt
  11828. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11829. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11830. }
  11831. if materialCostTotal != 0 {
  11832. iteminfo.MedChrgitm = "08"
  11833. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11834. iteminfo.Amt = materialCostTotal
  11835. iteminfo.ClaaSumfee = material_claa_sunmfee
  11836. iteminfo.ClabAmt = material_clab_amt
  11837. iteminfo.OthAmt = material_other_amt
  11838. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11839. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11840. }
  11841. if westernMedicineCostTotal != 0 {
  11842. iteminfo.MedChrgitm = "09"
  11843. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11844. iteminfo.Amt = westernMedicineCostTotal
  11845. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11846. iteminfo.ClabAmt = westernMedicine_clab_amt
  11847. iteminfo.OthAmt = westernMedicine_other_amt
  11848. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11849. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11850. }
  11851. if chineseTraditionalMedicineCostTotal != 0 {
  11852. iteminfo.MedChrgitm = "11"
  11853. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11854. iteminfo.Amt = westernMedicineCostTotal
  11855. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11856. iteminfo.ClabAmt = westernMedicine_clab_amt
  11857. iteminfo.OthAmt = westernMedicine_other_amt
  11858. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11859. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11860. }
  11861. if otherCostTotal != 0 {
  11862. iteminfo.MedChrgitm = "14"
  11863. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11864. iteminfo.Amt = otherCostTotal
  11865. iteminfo.ClaaSumfee = other_claa_sunmfee
  11866. iteminfo.ClabAmt = other_clab_amt
  11867. iteminfo.OthAmt = other_other_amt
  11868. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11869. iteminfoStructs = append(iteminfoStructs, iteminfo)
  11870. }
  11871. struct4101.IteminfoStruct = iteminfoStructs
  11872. struct4101.Ntly = "中国"
  11873. struct4101.AdmCaty = "A03.06"
  11874. struct4101.DoctorName = doctor.UserName
  11875. struct4101.DoctorCode = doctor.DoctorNumber
  11876. var res ResultSeventeen
  11877. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11878. struct4101.BillCode = order.Number
  11879. struct4101.BillNo = order.SetlId
  11880. var resOther ResultSeventeenOther
  11881. var pp models.PublicParams
  11882. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11883. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11884. pp.FixmedinsName = miConfig.OrgName
  11885. pp.FixmedinsCode = miConfig.Code
  11886. pp.RequestUrl = miConfig.Url
  11887. pp.Cainfo = miConfig.Cainfo
  11888. pp.SecretKey = miConfig.SecretKey
  11889. pp.AccessKey = miConfig.AccessKey
  11890. pp.OpterName = curRoles.UserName
  11891. client := &http.Client{}
  11892. var req *http.Request
  11893. data := make(map[string]interface{})
  11894. data["struct4101"] = struct4101
  11895. data["pp"] = pp
  11896. bytesData, _ := json.Marshal(data)
  11897. if miConfig.MdtrtareaAdmvs == "320921" {
  11898. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11899. } else {
  11900. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11901. }
  11902. resp, _ := client.Do(req)
  11903. defer resp.Body.Close()
  11904. body, ioErr := ioutil.ReadAll(resp.Body)
  11905. if ioErr != nil {
  11906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11908. return
  11909. }
  11910. var respJSON map[string]interface{}
  11911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11914. return
  11915. }
  11916. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11917. userJSONBytes, _ := json.Marshal(respJSON)
  11918. fmt.Println("log")
  11919. fmt.Println(string(userJSONBytes))
  11920. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11921. utils.ErrorLog("解析失败:%v", err)
  11922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11923. return
  11924. }
  11925. res.InfRefmsgid = resOther.InfRefmsgid
  11926. res.Output = resOther.Output
  11927. res.ErrMsg = resOther.ErrMsg
  11928. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  11929. res.Infcode = infocode
  11930. } else if miConfig.MdtrtareaAdmvs == "360302" {
  11931. var pp models.PublicParams
  11932. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11933. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11934. pp.FixmedinsName = miConfig.OrgName
  11935. pp.FixmedinsCode = miConfig.Code
  11936. pp.RequestUrl = miConfig.Url
  11937. pp.Cainfo = miConfig.Cainfo
  11938. pp.SecretKey = miConfig.SecretKey
  11939. pp.AccessKey = miConfig.AccessKey
  11940. pp.OpterName = curRoles.UserName
  11941. result, _ := service.Jxyb4101(struct4101, pp)
  11942. var dat map[string]interface{}
  11943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11944. fmt.Println(dat)
  11945. } else {
  11946. fmt.Println(err)
  11947. }
  11948. userJSONBytes, _ := json.Marshal(dat)
  11949. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11950. utils.ErrorLog("解析失败:%v", err)
  11951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11952. return
  11953. }
  11954. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11955. var pp models.PublicParams
  11956. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11957. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11958. pp.FixmedinsName = miConfig.OrgName
  11959. pp.FixmedinsCode = miConfig.Code
  11960. pp.RequestUrl = miConfig.Url
  11961. pp.Cainfo = miConfig.Cainfo
  11962. pp.SecretKey = miConfig.SecretKey
  11963. pp.AccessKey = miConfig.AccessKey
  11964. pp.OpterName = curRoles.UserName
  11965. result, _ := service.Hnyb4101(struct4101, pp)
  11966. var dat map[string]interface{}
  11967. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11968. fmt.Println(dat)
  11969. } else {
  11970. fmt.Println(err)
  11971. }
  11972. userJSONBytes, _ := json.Marshal(dat)
  11973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11974. utils.ErrorLog("解析失败:%v", err)
  11975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11976. return
  11977. }
  11978. } else if miConfig.MdtrtareaAdmvs == "150499" {
  11979. var resOther ResultSeventeenOther
  11980. var pp models.PublicParams
  11981. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11982. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11983. pp.FixmedinsName = miConfig.OrgName
  11984. pp.FixmedinsCode = miConfig.Code
  11985. pp.RequestUrl = miConfig.Url
  11986. pp.Cainfo = miConfig.Cainfo
  11987. pp.SecretKey = miConfig.SecretKey
  11988. pp.AccessKey = miConfig.AccessKey
  11989. pp.OpterName = curRoles.UserName
  11990. client := &http.Client{}
  11991. var req *http.Request
  11992. data := make(map[string]interface{})
  11993. data["struct4101"] = struct4101
  11994. data["pp"] = pp
  11995. bytesData, _ := json.Marshal(data)
  11996. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  11997. resp, _ := client.Do(req)
  11998. defer resp.Body.Close()
  11999. body, ioErr := ioutil.ReadAll(resp.Body)
  12000. if ioErr != nil {
  12001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12003. return
  12004. }
  12005. var respJSON map[string]interface{}
  12006. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12009. return
  12010. }
  12011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12012. userJSONBytes, _ := json.Marshal(respJSON)
  12013. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12014. utils.ErrorLog("解析失败:%v", err)
  12015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12016. return
  12017. }
  12018. res.InfRefmsgid = resOther.InfRefmsgid
  12019. res.Output = resOther.Output
  12020. res.ErrMsg = resOther.ErrMsg
  12021. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12022. res.Infcode = infocode
  12023. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12024. var pp models.PublicParams
  12025. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12026. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12027. pp.FixmedinsName = miConfig.OrgName
  12028. pp.FixmedinsCode = miConfig.Code
  12029. pp.RequestUrl = miConfig.Url
  12030. pp.Cainfo = miConfig.Cainfo
  12031. pp.SecretKey = miConfig.SecretKey
  12032. pp.AccessKey = miConfig.AccessKey
  12033. pp.OpterName = curRoles.UserName
  12034. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12035. fmt.Println(requestLog)
  12036. fmt.Println(errMsgLog)
  12037. saveLog(result, requestLog, "4101a", "上传清单")
  12038. var dat map[string]interface{}
  12039. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12040. fmt.Println(dat)
  12041. } else {
  12042. fmt.Println(err)
  12043. }
  12044. userJSONBytes, _ := json.Marshal(dat)
  12045. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12046. utils.ErrorLog("解析失败:%v", err)
  12047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12048. return
  12049. }
  12050. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12051. var pp models.PublicParams
  12052. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12053. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12054. pp.FixmedinsName = miConfig.OrgName
  12055. pp.FixmedinsCode = miConfig.Code
  12056. pp.RequestUrl = miConfig.Url
  12057. pp.Cainfo = miConfig.Cainfo
  12058. pp.SecretKey = miConfig.SecretKey
  12059. pp.AccessKey = miConfig.AccessKey
  12060. pp.OpterName = curRoles.UserName
  12061. client := &http.Client{}
  12062. var req *http.Request
  12063. data := make(map[string]interface{})
  12064. data["struct4101"] = struct4101
  12065. data["pp"] = pp
  12066. bytesData, _ := json.Marshal(data)
  12067. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  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. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12083. userJSONBytes, _ := json.Marshal(respJSON)
  12084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12085. utils.ErrorLog("解析失败:%v", err)
  12086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12087. return
  12088. }
  12089. } else {
  12090. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12091. var dat map[string]interface{}
  12092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12093. fmt.Println(dat)
  12094. } else {
  12095. fmt.Println(err)
  12096. }
  12097. userJSONBytes, _ := json.Marshal(dat)
  12098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12099. utils.ErrorLog("解析失败:%v", err)
  12100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12101. return
  12102. }
  12103. }
  12104. if res.Infcode != 0 {
  12105. errlog := &models.HisOrderError{
  12106. UserOrgId: order.UserOrgId,
  12107. Ctime: time.Now().Unix(),
  12108. Mtime: time.Now().Unix(),
  12109. ErrMsg: res.ErrMsg + "解析失败",
  12110. Status: 1,
  12111. PatientId: order.ID,
  12112. Stage: 10485,
  12113. }
  12114. service.CreateErrMsgLog(errlog)
  12115. continue
  12116. //c.ServeSuccessJSON(map[string]interface{}{
  12117. // "failed_code": -10,
  12118. // "msg": res.ErrMsg,
  12119. //})
  12120. } else {
  12121. //order.FaPiaoNumber = zero
  12122. //order.FaPiaoCode = last_order.FaPiaoCode
  12123. //service.UpdateOrder(order)
  12124. hisFundSettleListResult := &models.HisFundSettleListResult{
  12125. Number: res.Output.SetlListId,
  12126. Status: 1,
  12127. Ctime: time.Now().Unix(),
  12128. Mtime: time.Now().Unix(),
  12129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12130. IsUpload: 1,
  12131. OrderId: order.ID,
  12132. }
  12133. service.CreateUploadRecord(hisFundSettleListResult)
  12134. continue
  12135. }
  12136. }
  12137. }
  12138. func (c *HisApiController) GetSettleList() {
  12139. order_id, _ := c.GetInt64("order_id")
  12140. admin_user_id, _ := c.GetInt64("admin_user_id")
  12141. order, _ := service.GetHisOrderByIDTwo(order_id)
  12142. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12143. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12144. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12145. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12146. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12147. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12148. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12149. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12150. if order.ID == 0 {
  12151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12152. return
  12153. }
  12154. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12155. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12156. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12157. //fmt.Println(count)
  12158. //var zero string
  12159. //number := count + 1
  12160. //if number >= 1000 {
  12161. // zero = "0000" + strconv.FormatInt(number, 10)
  12162. //} else if number >= 10000 {
  12163. // zero = "000" + strconv.FormatInt(number, 10)
  12164. //} else if number >= 100000 {
  12165. // zero = "00" + strconv.FormatInt(number, 10)
  12166. //} else if number >= 1000000 {
  12167. // zero = "0" + strconv.FormatInt(number, 10)
  12168. //} else {
  12169. // zero = strconv.FormatInt(number, 10)
  12170. //}
  12171. //fmt.Println(zero)
  12172. struct4101 := service.Struct4101{
  12173. PsnNo: order.PsnNo,
  12174. MdtrtId: order.MdtrtId,
  12175. SetlId: order.SetlId,
  12176. PsnName: order.PsnName,
  12177. Gend: order.Gend,
  12178. Brdy: his.Brdy,
  12179. Age: his.Age,
  12180. Naty: order.Naty,
  12181. PatnCertType: "01",
  12182. Certno: order.Certno,
  12183. Prfs: "90",
  12184. ConerName: roles[0].UserName,
  12185. PatnRlts: "99",
  12186. ConerAddr: miConfig.OrgName,
  12187. ConerTel: admin.Mobile,
  12188. HiType: order.Insutype,
  12189. Insuplc: miConfig.InsuplcAdmdvs,
  12190. MaindiagFlag: "1",
  12191. BillCode: order.SetlId,
  12192. BillNo: order.SetlId,
  12193. BizSn: order.Number,
  12194. PsnSelfPay: order.PsnPartAmt,
  12195. PsnOwnPay: order.PsnPartAmt,
  12196. AcctPay: order.AcctPay,
  12197. PsnCashpay: order.PsnCashPay,
  12198. HiPaymtd: "1",
  12199. Hsorg: miConfig.InsuplcAdmdvs,
  12200. HsorgOpter: miConfig.InsuplcAdmdvs,
  12201. MedinsFillPsn: curRoles.UserName,
  12202. MedinsFillDept: miConfig.OrgName,
  12203. IptMedType: "2",
  12204. }
  12205. struct4101.SetlBegnDate = order.SetlTime
  12206. struct4101.SetlEndDate = order.SetlTime
  12207. time_arr := strings.Split(order.SetlTime, " ")
  12208. struct4101.AdmTime = time_arr[0]
  12209. struct4101.AdmEndTime = time_arr[0]
  12210. //
  12211. //var rf []CustomFundPay
  12212. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12213. //
  12214. //var tempFunPays []service.CustomStruct
  12215. //for _, item := range rf {
  12216. // var tempFunPay service.CustomStruct
  12217. // tempFunPay.FundPayamt = item.FundPayamt
  12218. // tempFunPay.FundPayType = item.FundPayType
  12219. // tempFunPays = append(tempFunPays, tempFunPay)
  12220. //}
  12221. //struct4101.CustomStruct = tempFunPays
  12222. var tempDiaginfos []service.DiaginfoStructTwo
  12223. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12224. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12225. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12226. var config []*models.HisXtDiagnoseConfig
  12227. for _, item := range diagnosis_ids {
  12228. id, _ := strconv.ParseInt(item, 10, 64)
  12229. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12230. config = append(config, &diagnosisConfig)
  12231. }
  12232. if miConfig.Code == "H15049901371" {
  12233. //for _, item := range config {
  12234. // if item.ID == 138 {
  12235. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12236. var tempDiaginfo service.DiaginfoStructTwo
  12237. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12238. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12239. tempDiaginfo.DiagType = "1"
  12240. tempDiaginfo.MaindiagFlag = "1"
  12241. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12242. //}
  12243. //}
  12244. for _, item := range config {
  12245. if item.ID != 138 {
  12246. var tempDiaginfo service.DiaginfoStructTwo
  12247. tempDiaginfo.DiagCode = item.CountryCode
  12248. tempDiaginfo.DiagName = item.CountryContentName
  12249. tempDiaginfo.DiagType = "1"
  12250. tempDiaginfo.MaindiagFlag = "0"
  12251. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12252. }
  12253. }
  12254. } else {
  12255. for index, item := range config {
  12256. if index == 0 {
  12257. var tempDiaginfo service.DiaginfoStructTwo
  12258. tempDiaginfo.DiagCode = item.CountryCode
  12259. tempDiaginfo.DiagName = item.CountryContentName
  12260. tempDiaginfo.DiagType = "1"
  12261. tempDiaginfo.MaindiagFlag = "1"
  12262. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12263. } else {
  12264. var tempDiaginfo service.DiaginfoStructTwo
  12265. tempDiaginfo.DiagCode = item.CountryCode
  12266. tempDiaginfo.DiagName = item.CountryContentName
  12267. tempDiaginfo.DiagType = "1"
  12268. tempDiaginfo.MaindiagFlag = "0"
  12269. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12270. }
  12271. }
  12272. }
  12273. struct4101.Diseinfo = tempDiaginfos
  12274. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12275. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12276. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12277. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12278. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12279. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12280. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12281. var iteminfo service.IteminfoStruct
  12282. var bedCostTotal float64 = 0 //床位总费
  12283. var bedCostSelfTotal float64 = 0 //床位自费
  12284. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12285. var operationCostTotal float64 = 0 //手术费
  12286. var operationCostSelfTotal float64 = 0 //手术费
  12287. var operationCostPartSelfTotal float64 = 0 //手术费
  12288. var otherCostTotal float64 = 0 //其他费用
  12289. var otherCostSelfTotal float64 = 0 //其他费用
  12290. var otherCostPartSelfTotal float64 = 0 //其他费用
  12291. var materialCostTotal float64 = 0 //材料费
  12292. var materialCostSelfTotal float64 = 0 //材料费
  12293. var materialCostPartSelfTotal float64 = 0 //材料费
  12294. var westernMedicineCostTotal float64 = 0 //西药费
  12295. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12296. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12297. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12298. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12299. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12300. var checkCostTotal float64 = 0 //检查费
  12301. var checkCostSelfTotal float64 = 0 //检查费
  12302. var checkCostPartSelfTotal float64 = 0 //检查费
  12303. var laboratoryCostTotal float64 = 0 //化验费
  12304. var laboratoryCostSelfTotal float64 = 0 //化验费
  12305. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12306. var treatCostTotal float64 = 0 //治疗费用
  12307. var treatCostSelfTotal float64 = 0 //治疗费用
  12308. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12309. decimal.DivisionPrecision = 2
  12310. var bed_fulamt_ownpay_amt float64 = 0
  12311. var operation_fulamt_ownpay_amt float64 = 0
  12312. var other_fulamt_ownpay_amt float64 = 0
  12313. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12314. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12315. var check_fulamt_ownpay_amt float64 = 0
  12316. var material_fulamt_ownpay_amt float64 = 0
  12317. var laboratory_fulamt_ownpay_amt float64 = 0
  12318. var treat_fulamt_ownpay_amt float64 = 0
  12319. var bed_claa_sunmfee float64 = 0
  12320. var bed_clab_amt float64 = 0
  12321. var bed_other_amt float64 = 0
  12322. var operation_claa_sunmfee float64 = 0
  12323. var operation_clab_amt float64 = 0
  12324. var operation_other_amt float64 = 0
  12325. var other_claa_sunmfee float64 = 0
  12326. var other_clab_amt float64 = 0
  12327. var other_other_amt float64 = 0
  12328. var westernMedicine_claa_sunmfee float64 = 0
  12329. var westernMedicine_clab_amt float64 = 0
  12330. var westernMedicine_other_amt float64 = 0
  12331. var chineseTraditional_claa_sunmfee float64 = 0
  12332. var chineseTraditional_clab_amt float64 = 0
  12333. var chineseTraditional_other_amt float64 = 0
  12334. var check_claa_sunmfee float64 = 0
  12335. var check_clab_amt float64 = 0
  12336. var check_other_amt float64 = 0
  12337. var material_claa_sunmfee float64 = 0
  12338. var material_clab_amt float64 = 0
  12339. var material_other_amt float64 = 0
  12340. var laboratory_claa_sunmfee float64 = 0
  12341. var laboratory_clab_amt float64 = 0
  12342. var laboratory_other_amt float64 = 0
  12343. var treat_claa_sunmfee float64 = 0
  12344. var treat_clab_amt float64 = 0
  12345. var treat_other_amt float64 = 0
  12346. for _, item := range order.HisOrderInfo {
  12347. if item.MedChrgitmType == "01" { //床位费
  12348. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12349. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12350. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12351. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12352. if item.ChrgitmLv == "1" {
  12353. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12354. }
  12355. if item.ChrgitmLv == "2" {
  12356. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12357. }
  12358. if item.ChrgitmLv == "3" {
  12359. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12360. }
  12361. }
  12362. if item.MedChrgitmType == "03" { //检查费
  12363. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12364. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12365. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12366. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12367. if item.ChrgitmLv == "1" {
  12368. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12369. }
  12370. if item.ChrgitmLv == "2" {
  12371. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12372. }
  12373. if item.ChrgitmLv == "3" {
  12374. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12375. }
  12376. }
  12377. if item.MedChrgitmType == "04" { //化验费
  12378. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12379. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12380. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12381. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12382. if item.ChrgitmLv == "1" {
  12383. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12384. }
  12385. if item.ChrgitmLv == "2" {
  12386. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12387. }
  12388. if item.ChrgitmLv == "3" {
  12389. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12390. }
  12391. }
  12392. if item.MedChrgitmType == "05" { //治疗费
  12393. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12394. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12395. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12396. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12397. if item.ChrgitmLv == "1" {
  12398. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12399. }
  12400. if item.ChrgitmLv == "2" {
  12401. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12402. }
  12403. if item.ChrgitmLv == "3" {
  12404. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12405. }
  12406. }
  12407. if item.MedChrgitmType == "06" { //手术费
  12408. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12409. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12410. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12411. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12412. if item.ChrgitmLv == "1" {
  12413. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12414. }
  12415. if item.ChrgitmLv == "2" {
  12416. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12417. }
  12418. if item.ChrgitmLv == "3" {
  12419. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12420. }
  12421. }
  12422. if item.MedChrgitmType == "08" { //材料费
  12423. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12424. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12425. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12426. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12427. if item.ChrgitmLv == "1" {
  12428. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12429. }
  12430. if item.ChrgitmLv == "2" {
  12431. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12432. }
  12433. if item.ChrgitmLv == "3" {
  12434. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12435. }
  12436. }
  12437. if item.MedChrgitmType == "09" { //西药费
  12438. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12439. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12440. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12441. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12442. if item.ChrgitmLv == "1" {
  12443. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12444. }
  12445. if item.ChrgitmLv == "2" {
  12446. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12447. }
  12448. if item.ChrgitmLv == "3" {
  12449. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12450. }
  12451. }
  12452. if item.MedChrgitmType == "11" { //中成费
  12453. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12454. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12455. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12456. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12457. if item.ChrgitmLv == "1" {
  12458. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12459. }
  12460. if item.ChrgitmLv == "2" {
  12461. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12462. }
  12463. if item.ChrgitmLv == "3" {
  12464. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12465. }
  12466. }
  12467. if item.MedChrgitmType == "14" { //其他费
  12468. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12469. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12470. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12471. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12472. if item.ChrgitmLv == "1" {
  12473. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12474. }
  12475. if item.ChrgitmLv == "2" {
  12476. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12477. }
  12478. if item.ChrgitmLv == "3" {
  12479. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12480. }
  12481. }
  12482. }
  12483. var iteminfoStructs []service.IteminfoStruct
  12484. if bedCostTotal != 0 {
  12485. iteminfo.MedChrgitm = "01"
  12486. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12487. iteminfo.Amt = bedCostTotal
  12488. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12489. iteminfo.ClabAmt = bed_clab_amt
  12490. iteminfo.OthAmt = bed_other_amt
  12491. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12492. }
  12493. if checkCostTotal != 0 {
  12494. iteminfo.MedChrgitm = "03"
  12495. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12496. iteminfo.Amt = checkCostTotal
  12497. iteminfo.ClaaSumfee = check_claa_sunmfee
  12498. iteminfo.ClabAmt = check_clab_amt
  12499. iteminfo.OthAmt = check_other_amt
  12500. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12501. }
  12502. if laboratoryCostTotal != 0 {
  12503. iteminfo.MedChrgitm = "04"
  12504. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12505. iteminfo.Amt = laboratoryCostTotal
  12506. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12507. iteminfo.ClabAmt = laboratory_clab_amt
  12508. iteminfo.OthAmt = laboratory_other_amt
  12509. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12510. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12511. }
  12512. if treatCostTotal != 0 {
  12513. iteminfo.MedChrgitm = "05"
  12514. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12515. iteminfo.Amt = treatCostTotal
  12516. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12517. iteminfo.ClabAmt = treat_clab_amt
  12518. iteminfo.OthAmt = treat_other_amt
  12519. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12520. //(struct4101.IteminfoStruct, iteminfo)
  12521. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12522. }
  12523. if operationCostTotal != 0 {
  12524. iteminfo.MedChrgitm = "06"
  12525. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12526. iteminfo.Amt = operationCostTotal
  12527. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12528. iteminfo.ClabAmt = operation_clab_amt
  12529. iteminfo.OthAmt = operation_other_amt
  12530. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12531. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12532. }
  12533. if materialCostTotal != 0 {
  12534. iteminfo.MedChrgitm = "08"
  12535. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12536. iteminfo.Amt = materialCostTotal
  12537. iteminfo.ClaaSumfee = material_claa_sunmfee
  12538. iteminfo.ClabAmt = material_clab_amt
  12539. iteminfo.OthAmt = material_other_amt
  12540. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12541. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12542. }
  12543. if westernMedicineCostTotal != 0 {
  12544. iteminfo.MedChrgitm = "09"
  12545. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12546. iteminfo.Amt = westernMedicineCostTotal
  12547. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12548. iteminfo.ClabAmt = westernMedicine_clab_amt
  12549. iteminfo.OthAmt = westernMedicine_other_amt
  12550. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12552. }
  12553. if chineseTraditionalMedicineCostTotal != 0 {
  12554. iteminfo.MedChrgitm = "11"
  12555. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12556. iteminfo.Amt = westernMedicineCostTotal
  12557. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12558. iteminfo.ClabAmt = westernMedicine_clab_amt
  12559. iteminfo.OthAmt = westernMedicine_other_amt
  12560. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12562. }
  12563. if otherCostTotal != 0 {
  12564. iteminfo.MedChrgitm = "14"
  12565. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12566. iteminfo.Amt = otherCostTotal
  12567. iteminfo.ClaaSumfee = other_claa_sunmfee
  12568. iteminfo.ClabAmt = other_clab_amt
  12569. iteminfo.OthAmt = other_other_amt
  12570. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12571. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12572. }
  12573. struct4101.IteminfoStruct = iteminfoStructs
  12574. struct4101.Ntly = "中国"
  12575. struct4101.AdmCaty = "A03.06"
  12576. struct4101.DoctorName = doctor.UserName
  12577. struct4101.DoctorCode = doctor.DoctorNumber
  12578. var res ResultSeventeen
  12579. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12580. struct4101.BillCode = order.Number
  12581. struct4101.BillNo = order.SetlId
  12582. var resOther ResultSeventeenOther
  12583. var pp models.PublicParams
  12584. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12585. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12586. pp.FixmedinsName = miConfig.OrgName
  12587. pp.FixmedinsCode = miConfig.Code
  12588. pp.RequestUrl = miConfig.Url
  12589. pp.Cainfo = miConfig.Cainfo
  12590. pp.SecretKey = miConfig.SecretKey
  12591. pp.AccessKey = miConfig.AccessKey
  12592. pp.OpterName = curRoles.UserName
  12593. client := &http.Client{}
  12594. var req *http.Request
  12595. data := make(map[string]interface{})
  12596. data["struct4101"] = struct4101
  12597. data["pp"] = pp
  12598. bytesData, _ := json.Marshal(data)
  12599. if miConfig.MdtrtareaAdmvs == "320921" {
  12600. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12601. } else {
  12602. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12603. }
  12604. resp, _ := client.Do(req)
  12605. defer resp.Body.Close()
  12606. body, ioErr := ioutil.ReadAll(resp.Body)
  12607. if ioErr != nil {
  12608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12610. return
  12611. }
  12612. var respJSON map[string]interface{}
  12613. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12616. return
  12617. }
  12618. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12619. userJSONBytes, _ := json.Marshal(respJSON)
  12620. fmt.Println("log")
  12621. fmt.Println(string(userJSONBytes))
  12622. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12623. utils.ErrorLog("解析失败:%v", err)
  12624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12625. return
  12626. }
  12627. res.InfRefmsgid = resOther.InfRefmsgid
  12628. res.Output = resOther.Output
  12629. res.ErrMsg = resOther.ErrMsg
  12630. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12631. res.Infcode = infocode
  12632. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12633. var pp models.PublicParams
  12634. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12635. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12636. pp.FixmedinsName = miConfig.OrgName
  12637. pp.FixmedinsCode = miConfig.Code
  12638. pp.RequestUrl = miConfig.Url
  12639. pp.Cainfo = miConfig.Cainfo
  12640. pp.SecretKey = miConfig.SecretKey
  12641. pp.AccessKey = miConfig.AccessKey
  12642. pp.OpterName = curRoles.UserName
  12643. result, _ := service.Jxyb4101(struct4101, pp)
  12644. var dat map[string]interface{}
  12645. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12646. fmt.Println(dat)
  12647. } else {
  12648. fmt.Println(err)
  12649. }
  12650. userJSONBytes, _ := json.Marshal(dat)
  12651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12652. utils.ErrorLog("解析失败:%v", err)
  12653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12654. return
  12655. }
  12656. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12657. var pp models.PublicParams
  12658. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12659. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12660. pp.FixmedinsName = miConfig.OrgName
  12661. pp.FixmedinsCode = miConfig.Code
  12662. pp.RequestUrl = miConfig.Url
  12663. pp.Cainfo = miConfig.Cainfo
  12664. pp.SecretKey = miConfig.SecretKey
  12665. pp.AccessKey = miConfig.AccessKey
  12666. pp.OpterName = curRoles.UserName
  12667. result, _ := service.Hnyb4101(struct4101, pp)
  12668. var dat map[string]interface{}
  12669. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12670. fmt.Println(dat)
  12671. } else {
  12672. fmt.Println(err)
  12673. }
  12674. userJSONBytes, _ := json.Marshal(dat)
  12675. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12676. utils.ErrorLog("解析失败:%v", err)
  12677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12678. return
  12679. }
  12680. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12681. var resOther ResultSeventeenOther
  12682. var pp models.PublicParams
  12683. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12684. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12685. pp.FixmedinsName = miConfig.OrgName
  12686. pp.FixmedinsCode = miConfig.Code
  12687. pp.RequestUrl = miConfig.Url
  12688. pp.Cainfo = miConfig.Cainfo
  12689. pp.SecretKey = miConfig.SecretKey
  12690. pp.AccessKey = miConfig.AccessKey
  12691. pp.OpterName = curRoles.UserName
  12692. client := &http.Client{}
  12693. var req *http.Request
  12694. data := make(map[string]interface{})
  12695. data["struct4101"] = struct4101
  12696. data["pp"] = pp
  12697. bytesData, _ := json.Marshal(data)
  12698. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12699. resp, _ := client.Do(req)
  12700. defer resp.Body.Close()
  12701. body, ioErr := ioutil.ReadAll(resp.Body)
  12702. if ioErr != nil {
  12703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12705. return
  12706. }
  12707. var respJSON map[string]interface{}
  12708. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12711. return
  12712. }
  12713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12714. userJSONBytes, _ := json.Marshal(respJSON)
  12715. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12716. utils.ErrorLog("解析失败:%v", err)
  12717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12718. return
  12719. }
  12720. res.InfRefmsgid = resOther.InfRefmsgid
  12721. res.Output = resOther.Output
  12722. res.ErrMsg = resOther.ErrMsg
  12723. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12724. res.Infcode = infocode
  12725. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12726. var pp models.PublicParams
  12727. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12728. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12729. pp.FixmedinsName = miConfig.OrgName
  12730. pp.FixmedinsCode = miConfig.Code
  12731. pp.RequestUrl = miConfig.Url
  12732. pp.Cainfo = miConfig.Cainfo
  12733. pp.SecretKey = miConfig.SecretKey
  12734. pp.AccessKey = miConfig.AccessKey
  12735. pp.OpterName = curRoles.UserName
  12736. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12737. fmt.Println(requestLog)
  12738. fmt.Println(errMsgLog)
  12739. saveLog(result, requestLog, "4101a", "上传清单")
  12740. var dat map[string]interface{}
  12741. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12742. fmt.Println(dat)
  12743. } else {
  12744. fmt.Println(err)
  12745. }
  12746. userJSONBytes, _ := json.Marshal(dat)
  12747. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12748. utils.ErrorLog("解析失败:%v", err)
  12749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12750. return
  12751. }
  12752. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12753. var pp models.PublicParams
  12754. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12755. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12756. pp.FixmedinsName = miConfig.OrgName
  12757. pp.FixmedinsCode = miConfig.Code
  12758. pp.RequestUrl = miConfig.Url
  12759. pp.Cainfo = miConfig.Cainfo
  12760. pp.SecretKey = miConfig.SecretKey
  12761. pp.AccessKey = miConfig.AccessKey
  12762. pp.OpterName = curRoles.UserName
  12763. client := &http.Client{}
  12764. var req *http.Request
  12765. data := make(map[string]interface{})
  12766. data["struct4101"] = struct4101
  12767. data["pp"] = pp
  12768. bytesData, _ := json.Marshal(data)
  12769. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12770. resp, _ := client.Do(req)
  12771. defer resp.Body.Close()
  12772. body, ioErr := ioutil.ReadAll(resp.Body)
  12773. if ioErr != nil {
  12774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12776. return
  12777. }
  12778. var respJSON map[string]interface{}
  12779. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12782. return
  12783. }
  12784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12785. userJSONBytes, _ := json.Marshal(respJSON)
  12786. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12787. utils.ErrorLog("解析失败:%v", err)
  12788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12789. return
  12790. }
  12791. } else {
  12792. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12793. var dat map[string]interface{}
  12794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12795. fmt.Println(dat)
  12796. } else {
  12797. fmt.Println(err)
  12798. }
  12799. userJSONBytes, _ := json.Marshal(dat)
  12800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12801. utils.ErrorLog("解析失败:%v", err)
  12802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12803. return
  12804. }
  12805. }
  12806. if res.Infcode != 0 {
  12807. c.ServeSuccessJSON(map[string]interface{}{
  12808. "failed_code": -10,
  12809. "msg": res.ErrMsg,
  12810. })
  12811. return
  12812. } else {
  12813. //order.FaPiaoNumber = zero
  12814. //order.FaPiaoCode = last_order.FaPiaoCode
  12815. //service.UpdateOrder(order)
  12816. hisFundSettleListResult := &models.HisFundSettleListResult{
  12817. Number: res.Output.SetlListId,
  12818. Status: 1,
  12819. Ctime: time.Now().Unix(),
  12820. Mtime: time.Now().Unix(),
  12821. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12822. IsUpload: 1,
  12823. OrderId: order_id,
  12824. }
  12825. service.CreateUploadRecord(hisFundSettleListResult)
  12826. c.ServeSuccessJSON(map[string]interface{}{
  12827. "msg": "上传成功",
  12828. "result": hisFundSettleListResult,
  12829. })
  12830. return
  12831. }
  12832. }
  12833. func (c *HisApiController) GetSettleListHospital() {
  12834. order_id, _ := c.GetInt64("order_id")
  12835. admin_user_id, _ := c.GetInt64("admin_user_id")
  12836. order, _ := service.GetHisOrderByIDTwo(order_id)
  12837. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12838. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  12839. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12840. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12841. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12843. if order.ID == 0 {
  12844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12845. return
  12846. }
  12847. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12848. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12849. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12850. fmt.Println(count)
  12851. var zero string
  12852. number := count + 1
  12853. if number >= 1000 {
  12854. zero = "0000" + strconv.FormatInt(number, 10)
  12855. } else if number >= 10000 {
  12856. zero = "000" + strconv.FormatInt(number, 10)
  12857. } else if number >= 100000 {
  12858. zero = "00" + strconv.FormatInt(number, 10)
  12859. } else if number >= 1000000 {
  12860. zero = "0" + strconv.FormatInt(number, 10)
  12861. } else {
  12862. zero = strconv.FormatInt(number, 10)
  12863. }
  12864. fmt.Println(zero)
  12865. struct4101 := service.Struct4101{
  12866. PsnNo: order.PsnNo,
  12867. MdtrtId: order.MdtrtId,
  12868. SetlId: order.SetlId,
  12869. PsnName: order.PsnName,
  12870. Gend: order.Gend,
  12871. Brdy: his.Brdy,
  12872. Age: int64(order.Age),
  12873. Naty: order.Naty,
  12874. PatnCertType: "01",
  12875. Certno: order.Certno,
  12876. Prfs: "90",
  12877. ConerName: roles[0].UserName,
  12878. PatnRlts: "99",
  12879. ConerAddr: miConfig.OrgName,
  12880. ConerTel: admin.Mobile,
  12881. HiType: order.Insutype,
  12882. Insuplc: miConfig.InsuplcAdmdvs,
  12883. MaindiagFlag: "1",
  12884. BillCode: order.SetlId,
  12885. BillNo: order.SetlId,
  12886. BizSn: order.Number,
  12887. PsnSelfPay: order.PsnPartAmt,
  12888. PsnOwnPay: order.PsnPartAmt,
  12889. AcctPay: order.AcctPay,
  12890. PsnCashpay: order.PsnCashPay,
  12891. HiPaymtd: "1",
  12892. Hsorg: miConfig.InsuplcAdmdvs,
  12893. HsorgOpter: miConfig.InsuplcAdmdvs,
  12894. MedinsFillPsn: curRoles.UserName,
  12895. MedinsFillDept: depart.Name,
  12896. IptMedType: "2",
  12897. AdmTime: his.InHosptialTime,
  12898. AdmEndTime: his.OutHosptialTime,
  12899. }
  12900. struct4101.SetlBegnDate = order.SetlTime
  12901. struct4101.SetlEndDate = order.SetlTime
  12902. //var rf []CustomFundPay
  12903. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12904. //
  12905. //var tempFunPays []service.CustomStruct
  12906. //for _, item := range rf {
  12907. // var tempFunPay service.CustomStruct
  12908. // tempFunPay.FundPayamt = item.FundPayamt
  12909. // tempFunPay.FundPayType = item.FundPayType
  12910. // tempFunPays = append(tempFunPays, tempFunPay)
  12911. //}
  12912. //struct4101.CustomStruct = tempFunPays
  12913. var tempDiaginfos []service.DiaginfoStructTwo
  12914. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12915. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12916. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  12917. //for _, item := range infos {
  12918. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  12919. //}
  12920. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  12921. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  12922. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12923. fmt.Println(diagnosis_ids_arr)
  12924. if order.UserOrgId == 10210 {
  12925. var diagnosis_ids_arr_two []int64
  12926. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  12927. var config []*models.HisXtDiagnoseConfig
  12928. for _, id := range diagnosis_ids_arr_two {
  12929. //id, _ := strconv.ParseInt(item, 10, 64)
  12930. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12931. if diagnosisConfig.ID > 0 {
  12932. config = append(config, &diagnosisConfig)
  12933. }
  12934. }
  12935. for index, item := range config {
  12936. if item.ID > 0 {
  12937. if index == 0 {
  12938. var tempDiaginfo service.DiaginfoStructTwo
  12939. tempDiaginfo.DiagCode = item.CountryCode
  12940. tempDiaginfo.DiagName = item.CountryContentName
  12941. tempDiaginfo.DiagType = "1"
  12942. tempDiaginfo.MaindiagFlag = "1"
  12943. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12944. } else {
  12945. var tempDiaginfo service.DiaginfoStructTwo
  12946. tempDiaginfo.DiagCode = item.CountryCode
  12947. tempDiaginfo.DiagName = item.CountryContentName
  12948. tempDiaginfo.DiagType = "1"
  12949. tempDiaginfo.MaindiagFlag = "0"
  12950. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12951. }
  12952. }
  12953. }
  12954. struct4101.Diseinfo = tempDiaginfos
  12955. } else {
  12956. var config []*models.HisXtDiagnoseConfig
  12957. for _, item := range diagnosis_ids_arr {
  12958. id, _ := strconv.ParseInt(item, 10, 64)
  12959. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12960. if diagnosisConfig.ID > 0 {
  12961. config = append(config, &diagnosisConfig)
  12962. }
  12963. }
  12964. for index, item := range config {
  12965. if item.ID > 0 {
  12966. if index == 0 {
  12967. var tempDiaginfo service.DiaginfoStructTwo
  12968. tempDiaginfo.DiagCode = item.CountryCode
  12969. tempDiaginfo.DiagName = item.CountryContentName
  12970. tempDiaginfo.DiagType = "1"
  12971. tempDiaginfo.MaindiagFlag = "1"
  12972. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12973. } else {
  12974. var tempDiaginfo service.DiaginfoStructTwo
  12975. tempDiaginfo.DiagCode = item.CountryCode
  12976. tempDiaginfo.DiagName = item.CountryContentName
  12977. tempDiaginfo.DiagType = "1"
  12978. tempDiaginfo.MaindiagFlag = "0"
  12979. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12980. }
  12981. }
  12982. }
  12983. struct4101.Diseinfo = tempDiaginfos
  12984. }
  12985. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12986. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12987. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12988. tempOpspdiseinfo2.OprnOprtCode = ""
  12989. tempOpspdiseinfo2.OprnOprtName = ""
  12990. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12991. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12992. var iteminfo service.IteminfoStruct
  12993. var bedCostTotal float64 = 0 //床位总费
  12994. var bedCostSelfTotal float64 = 0 //床位自费
  12995. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12996. var operationCostTotal float64 = 0 //手术费
  12997. var operationCostSelfTotal float64 = 0 //手术费
  12998. var operationCostPartSelfTotal float64 = 0 //手术费
  12999. var otherCostTotal float64 = 0 //其他费用
  13000. var otherCostSelfTotal float64 = 0 //其他费用
  13001. var otherCostPartSelfTotal float64 = 0 //其他费用
  13002. var materialCostTotal float64 = 0 //材料费
  13003. var materialCostSelfTotal float64 = 0 //材料费
  13004. var materialCostPartSelfTotal float64 = 0 //材料费
  13005. var westernMedicineCostTotal float64 = 0 //西药费
  13006. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13007. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13008. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13009. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13010. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13011. var checkCostTotal float64 = 0 //检查费
  13012. var checkCostSelfTotal float64 = 0 //检查费
  13013. var checkCostPartSelfTotal float64 = 0 //检查费
  13014. var laboratoryCostTotal float64 = 0 //化验费
  13015. var laboratoryCostSelfTotal float64 = 0 //化验费
  13016. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13017. var treatCostTotal float64 = 0 //治疗费用
  13018. var treatCostSelfTotal float64 = 0 //治疗费用
  13019. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13020. decimal.DivisionPrecision = 2
  13021. var bed_fulamt_ownpay_amt float64 = 0
  13022. var operation_fulamt_ownpay_amt float64 = 0
  13023. var other_fulamt_ownpay_amt float64 = 0
  13024. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13025. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13026. var check_fulamt_ownpay_amt float64 = 0
  13027. var material_fulamt_ownpay_amt float64 = 0
  13028. var laboratory_fulamt_ownpay_amt float64 = 0
  13029. var treat_fulamt_ownpay_amt float64 = 0
  13030. var bed_claa_sunmfee float64 = 0
  13031. var bed_clab_amt float64 = 0
  13032. var bed_other_amt float64 = 0
  13033. var operation_claa_sunmfee float64 = 0
  13034. var operation_clab_amt float64 = 0
  13035. var operation_other_amt float64 = 0
  13036. var other_claa_sunmfee float64 = 0
  13037. var other_clab_amt float64 = 0
  13038. var other_other_amt float64 = 0
  13039. var westernMedicine_claa_sunmfee float64 = 0
  13040. var westernMedicine_clab_amt float64 = 0
  13041. var westernMedicine_other_amt float64 = 0
  13042. var chineseTraditional_claa_sunmfee float64 = 0
  13043. var chineseTraditional_clab_amt float64 = 0
  13044. var chineseTraditional_other_amt float64 = 0
  13045. var check_claa_sunmfee float64 = 0
  13046. var check_clab_amt float64 = 0
  13047. var check_other_amt float64 = 0
  13048. var material_claa_sunmfee float64 = 0
  13049. var material_clab_amt float64 = 0
  13050. var material_other_amt float64 = 0
  13051. var laboratory_claa_sunmfee float64 = 0
  13052. var laboratory_clab_amt float64 = 0
  13053. var laboratory_other_amt float64 = 0
  13054. var treat_claa_sunmfee float64 = 0
  13055. var treat_clab_amt float64 = 0
  13056. var treat_other_amt float64 = 0
  13057. for _, item := range order.HisOrderInfo {
  13058. if item.MedChrgitmType == "01" { //床位费
  13059. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13060. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13061. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13062. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13063. if item.ChrgitmLv == "1" {
  13064. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13065. }
  13066. if item.ChrgitmLv == "2" {
  13067. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13068. }
  13069. if item.ChrgitmLv == "3" {
  13070. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13071. }
  13072. }
  13073. if item.MedChrgitmType == "03" { //检查费
  13074. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13075. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13076. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13077. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13078. if item.ChrgitmLv == "1" {
  13079. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13080. }
  13081. if item.ChrgitmLv == "2" {
  13082. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13083. }
  13084. if item.ChrgitmLv == "3" {
  13085. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13086. }
  13087. }
  13088. if item.MedChrgitmType == "04" { //化验费
  13089. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13090. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13091. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13092. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13093. if item.ChrgitmLv == "1" {
  13094. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13095. }
  13096. if item.ChrgitmLv == "2" {
  13097. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13098. }
  13099. if item.ChrgitmLv == "3" {
  13100. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13101. }
  13102. }
  13103. if item.MedChrgitmType == "05" { //治疗费
  13104. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13105. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13106. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13107. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13108. if item.ChrgitmLv == "1" {
  13109. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13110. }
  13111. if item.ChrgitmLv == "2" {
  13112. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13113. }
  13114. if item.ChrgitmLv == "3" {
  13115. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13116. }
  13117. }
  13118. if item.MedChrgitmType == "06" { //手术费
  13119. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13120. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13121. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13122. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13123. if item.ChrgitmLv == "1" {
  13124. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13125. }
  13126. if item.ChrgitmLv == "2" {
  13127. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13128. }
  13129. if item.ChrgitmLv == "3" {
  13130. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13131. }
  13132. }
  13133. if item.MedChrgitmType == "08" { //材料费
  13134. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13135. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13136. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13137. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13138. if item.ChrgitmLv == "1" {
  13139. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13140. }
  13141. if item.ChrgitmLv == "2" {
  13142. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13143. }
  13144. if item.ChrgitmLv == "3" {
  13145. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13146. }
  13147. }
  13148. if item.MedChrgitmType == "09" { //西药费
  13149. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13150. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13151. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13152. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13153. if item.ChrgitmLv == "1" {
  13154. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13155. }
  13156. if item.ChrgitmLv == "2" {
  13157. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13158. }
  13159. if item.ChrgitmLv == "3" {
  13160. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13161. }
  13162. }
  13163. if item.MedChrgitmType == "11" { //中成费
  13164. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13165. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13166. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13167. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13168. if item.ChrgitmLv == "1" {
  13169. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13170. }
  13171. if item.ChrgitmLv == "2" {
  13172. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13173. }
  13174. if item.ChrgitmLv == "3" {
  13175. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13176. }
  13177. }
  13178. if item.MedChrgitmType == "14" { //其他费
  13179. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13180. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13181. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13182. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13183. if item.ChrgitmLv == "1" {
  13184. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13185. }
  13186. if item.ChrgitmLv == "2" {
  13187. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13188. }
  13189. if item.ChrgitmLv == "3" {
  13190. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13191. }
  13192. }
  13193. }
  13194. var iteminfoStructs []service.IteminfoStruct
  13195. if bedCostTotal != 0 {
  13196. iteminfo.MedChrgitm = "01"
  13197. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13198. iteminfo.Amt = bedCostTotal
  13199. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13200. iteminfo.ClabAmt = bed_clab_amt
  13201. iteminfo.OthAmt = bed_other_amt
  13202. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13203. }
  13204. if checkCostTotal != 0 {
  13205. iteminfo.MedChrgitm = "03"
  13206. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13207. iteminfo.Amt = checkCostTotal
  13208. iteminfo.ClaaSumfee = check_claa_sunmfee
  13209. iteminfo.ClabAmt = check_clab_amt
  13210. iteminfo.OthAmt = check_other_amt
  13211. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13212. }
  13213. if laboratoryCostTotal != 0 {
  13214. iteminfo.MedChrgitm = "04"
  13215. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13216. iteminfo.Amt = laboratoryCostTotal
  13217. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13218. iteminfo.ClabAmt = laboratory_clab_amt
  13219. iteminfo.OthAmt = laboratory_other_amt
  13220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13221. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13222. }
  13223. if treatCostTotal != 0 {
  13224. iteminfo.MedChrgitm = "05"
  13225. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13226. iteminfo.Amt = treatCostTotal
  13227. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13228. iteminfo.ClabAmt = treat_clab_amt
  13229. iteminfo.OthAmt = treat_other_amt
  13230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13231. //(struct4101.IteminfoStruct, iteminfo)
  13232. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13233. }
  13234. if operationCostTotal != 0 {
  13235. iteminfo.MedChrgitm = "06"
  13236. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13237. iteminfo.Amt = operationCostTotal
  13238. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13239. iteminfo.ClabAmt = operation_clab_amt
  13240. iteminfo.OthAmt = operation_other_amt
  13241. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13242. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13243. }
  13244. if materialCostTotal != 0 {
  13245. iteminfo.MedChrgitm = "08"
  13246. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13247. iteminfo.Amt = materialCostTotal
  13248. iteminfo.ClaaSumfee = material_claa_sunmfee
  13249. iteminfo.ClabAmt = material_clab_amt
  13250. iteminfo.OthAmt = material_other_amt
  13251. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13253. }
  13254. if westernMedicineCostTotal != 0 {
  13255. iteminfo.MedChrgitm = "09"
  13256. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13257. iteminfo.Amt = westernMedicineCostTotal
  13258. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13259. iteminfo.ClabAmt = westernMedicine_clab_amt
  13260. iteminfo.OthAmt = westernMedicine_other_amt
  13261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13263. }
  13264. if chineseTraditionalMedicineCostTotal != 0 {
  13265. iteminfo.MedChrgitm = "11"
  13266. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13267. iteminfo.Amt = westernMedicineCostTotal
  13268. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13269. iteminfo.ClabAmt = westernMedicine_clab_amt
  13270. iteminfo.OthAmt = westernMedicine_other_amt
  13271. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13272. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13273. }
  13274. if otherCostTotal != 0 {
  13275. iteminfo.MedChrgitm = "14"
  13276. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13277. iteminfo.Amt = otherCostTotal
  13278. iteminfo.ClaaSumfee = other_claa_sunmfee
  13279. iteminfo.ClabAmt = other_clab_amt
  13280. iteminfo.OthAmt = other_other_amt
  13281. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13283. }
  13284. struct4101.IteminfoStruct = iteminfoStructs
  13285. struct4101.Ntly = "中国"
  13286. struct4101.AdmCaty = "A03.06"
  13287. var resOther ResultSeventeenOther
  13288. var res ResultSeventeen
  13289. if miConfig.MdtrtareaAdmvs == "150499" {
  13290. var pp models.PublicParams
  13291. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13292. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13293. pp.FixmedinsName = miConfig.OrgName
  13294. pp.FixmedinsCode = miConfig.Code
  13295. pp.RequestUrl = miConfig.Url
  13296. pp.Cainfo = miConfig.Cainfo
  13297. pp.SecretKey = miConfig.SecretKey
  13298. pp.AccessKey = miConfig.AccessKey
  13299. pp.OpterName = curRoles.UserName
  13300. client := &http.Client{}
  13301. var req *http.Request
  13302. data := make(map[string]interface{})
  13303. data["struct4101"] = struct4101
  13304. data["pp"] = pp
  13305. bytesData, _ := json.Marshal(data)
  13306. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13307. resp, _ := client.Do(req)
  13308. defer resp.Body.Close()
  13309. body, ioErr := ioutil.ReadAll(resp.Body)
  13310. if ioErr != nil {
  13311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13313. return
  13314. }
  13315. var respJSON map[string]interface{}
  13316. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13319. return
  13320. }
  13321. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13322. userJSONBytes, _ := json.Marshal(respJSON)
  13323. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13324. utils.ErrorLog("解析失败:%v", err)
  13325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13326. return
  13327. }
  13328. res.InfRefmsgid = resOther.InfRefmsgid
  13329. res.Output = resOther.Output
  13330. res.ErrMsg = resOther.ErrMsg
  13331. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13332. res.Infcode = infocode
  13333. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13334. var pp models.PublicParams
  13335. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13336. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13337. pp.FixmedinsName = miConfig.OrgName
  13338. pp.FixmedinsCode = miConfig.Code
  13339. pp.RequestUrl = miConfig.Url
  13340. pp.Cainfo = miConfig.Cainfo
  13341. pp.SecretKey = miConfig.SecretKey
  13342. pp.AccessKey = miConfig.AccessKey
  13343. pp.OpterName = curRoles.UserName
  13344. result, _ := service.Jxyb4101(struct4101, pp)
  13345. var dat map[string]interface{}
  13346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13347. fmt.Println(dat)
  13348. } else {
  13349. fmt.Println(err)
  13350. }
  13351. userJSONBytes, _ := json.Marshal(dat)
  13352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13353. utils.ErrorLog("解析失败:%v", err)
  13354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13355. return
  13356. }
  13357. } else {
  13358. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13359. var dat map[string]interface{}
  13360. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13361. fmt.Println(dat)
  13362. } else {
  13363. fmt.Println(err)
  13364. }
  13365. userJSONBytes, _ := json.Marshal(dat)
  13366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13367. utils.ErrorLog("解析失败:%v", err)
  13368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13369. return
  13370. }
  13371. }
  13372. if res.Infcode != 0 {
  13373. c.ServeSuccessJSON(map[string]interface{}{
  13374. "failed_code": -10,
  13375. "msg": res.ErrMsg,
  13376. })
  13377. return
  13378. } else {
  13379. if miConfig.MdtrtareaAdmvs != "150499" {
  13380. order.FaPiaoNumber = zero
  13381. order.FaPiaoCode = last_order.FaPiaoCode
  13382. service.UpdateOrder(order)
  13383. }
  13384. hisFundSettleListResult := &models.HisFundSettleListResult{
  13385. Number: res.Output.SetlListId,
  13386. Status: 1,
  13387. Ctime: time.Now().Unix(),
  13388. Mtime: time.Now().Unix(),
  13389. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13390. IsUpload: 1,
  13391. OrderId: order_id,
  13392. }
  13393. service.CreateUploadRecord(hisFundSettleListResult)
  13394. c.ServeSuccessJSON(map[string]interface{}{
  13395. "msg": "上传成功",
  13396. "result": hisFundSettleListResult,
  13397. })
  13398. return
  13399. }
  13400. }
  13401. //func (c *HisApiController) GetBatchSettleList() {
  13402. // orders, _ := service.GetAllHisOrder(10106)
  13403. // for _, item := range orders {
  13404. // order_id := item.ID
  13405. // order, _ := service.GetHisOrderByIDTwo(order_id)
  13406. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13407. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13408. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13409. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  13410. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13411. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13412. //
  13413. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  13414. //
  13415. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  13416. //
  13417. // if order.ID == 0 {
  13418. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13419. // return
  13420. // }
  13421. // if his.BalanceAccountsType == 2 {
  13422. // continue
  13423. // }
  13424. // struct4101 := service.Struct4101{
  13425. // PsnNo: order.PsnNo,
  13426. // MdtrtId: order.MdtrtId,
  13427. // SetlId: order.SetlId,
  13428. // PsnName: order.PsnName,
  13429. // Gend: order.Gend,
  13430. // Brdy: his.Brdy,
  13431. // Age: his.Age,
  13432. // Naty: order.Naty,
  13433. // PatnCertType: "01",
  13434. // Certno: order.Certno,
  13435. // Prfs: "90",
  13436. // ConerName: roles[0].UserName,
  13437. // PatnRlts: "99",
  13438. // ConerAddr: miConfig.OrgName,
  13439. // ConerTel: admin.Mobile,
  13440. // HiType: order.Insutype,
  13441. // Insuplc: his.InsuplcAdmdvs,
  13442. // MaindiagFlag: "1",
  13443. // BillCode: order.SetlId,
  13444. // BillNo: order.SetlId,
  13445. // BizSn: order.Number,
  13446. // PsnSelfPay: order.PsnPartAmt,
  13447. // PsnOwnPay: order.PsnPartAmt,
  13448. // AcctPay: order.AcctPay,
  13449. // PsnCashpay: order.PsnCashPay,
  13450. // HiPaymtd: "1",
  13451. // Hsorg: his.InsuplcAdmdvs,
  13452. // HsorgOpter: his.InsuplcAdmdvs,
  13453. // MedinsFillPsn: curRoles.UserName,
  13454. // MedinsFillDept: depart.Name,
  13455. // IptMedType: "2",
  13456. // }
  13457. // struct4101.SetlBegnDate = order.SetlTime
  13458. // struct4101.SetlEndDate = order.SetlTime
  13459. // //if order.SettleType == 1 {
  13460. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  13461. // // dateStr := t.Format("2006-01-02")
  13462. // // struct4101.SetlBegnDate = dateStr
  13463. // // struct4101.SetlEndDate = dateStr
  13464. // //} else {
  13465. // // t := time.Unix(int64(order.SettleStartTime), 0)
  13466. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  13467. // // dateStartStr := t.Format("2006-01-02")
  13468. // // dateEndStr := t2.Format("2006-01-02")
  13469. // // struct4101.SetlBegnDate = dateStartStr
  13470. // // struct4101.SetlEndDate = dateEndStr
  13471. // //}
  13472. //
  13473. // var rf []CustomFundPay
  13474. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  13475. //
  13476. // var tempFunPays []service.CustomStruct
  13477. // var tempFunPay610100 service.CustomStruct
  13478. //
  13479. // for _, item := range rf {
  13480. // if item.FundPayType == "610100" {
  13481. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  13482. // tempFunPay610100.FundPayType = item.FundPayType
  13483. // } else {
  13484. // var tempFunPay service.CustomStruct
  13485. // tempFunPay.FundPayamt = item.FundPayamt
  13486. // tempFunPay.FundPayType = item.FundPayType
  13487. // tempFunPays = append(tempFunPays, tempFunPay)
  13488. // }
  13489. // }
  13490. // tempFunPays = append(tempFunPays, tempFunPay610100)
  13491. // struct4101.CustomStruct = tempFunPays
  13492. //
  13493. // var tempDiaginfos []service.DiaginfoStructTwo
  13494. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13495. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13496. //
  13497. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13498. // var config []*models.HisXtDiagnoseConfig
  13499. // for _, item := range diagnosis_ids {
  13500. // id, _ := strconv.ParseInt(item, 10, 64)
  13501. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  13502. // config = append(config, &diagnosisConfig)
  13503. // }
  13504. //
  13505. // for index, item := range config {
  13506. // if index == 0 {
  13507. // var tempDiaginfo service.DiaginfoStructTwo
  13508. // tempDiaginfo.DiagCode = item.CountryCode
  13509. // tempDiaginfo.DiagName = item.CountryContentName
  13510. // tempDiaginfo.DiagType = "1"
  13511. // tempDiaginfo.MaindiagFlag = "1"
  13512. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13513. // } else {
  13514. //
  13515. // var tempDiaginfo service.DiaginfoStructTwo
  13516. // tempDiaginfo.DiagCode = item.CountryCode
  13517. // tempDiaginfo.DiagName = item.CountryContentName
  13518. // tempDiaginfo.DiagType = "2"
  13519. // tempDiaginfo.MaindiagFlag = "0"
  13520. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13521. // }
  13522. // }
  13523. // struct4101.Diseinfo = tempDiaginfos
  13524. //
  13525. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  13526. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13527. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13528. // tempOpspdiseinfo2.OprnOprtCode = ""
  13529. // tempOpspdiseinfo2.OprnOprtName = ""
  13530. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13531. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13532. //
  13533. // var iteminfo service.IteminfoStruct
  13534. //
  13535. // var bedCostTotal float64 = 0 //床位总费
  13536. // var bedCostSelfTotal float64 = 0 //床位自费
  13537. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13538. //
  13539. // var examineCostTotal float64 = 0 //诊查总费
  13540. // var examineCostSelfTotal float64 = 0 //诊查自费
  13541. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  13542. //
  13543. // var nursingCostTotal float64 = 0 //护理总费
  13544. // var nursingCostSelfTotal float64 = 0 //护理自费
  13545. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  13546. //
  13547. // var chineseMedicineCostTotal float64 = 0 //中成药
  13548. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  13549. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  13550. //
  13551. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  13552. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  13553. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  13554. //
  13555. // var registerCostTotal float64 = 0 //一般诊疗费
  13556. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  13557. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  13558. //
  13559. // var operationCostTotal float64 = 0 //手术费
  13560. // var operationCostSelfTotal float64 = 0 //手术费
  13561. // var operationCostPartSelfTotal float64 = 0 //手术费
  13562. //
  13563. // var otherCostTotal float64 = 0 //其他费用
  13564. // var otherCostSelfTotal float64 = 0 //其他费用
  13565. // var otherCostPartSelfTotal float64 = 0 //其他费用
  13566. //
  13567. // var materialCostTotal float64 = 0 //材料费
  13568. // var materialCostSelfTotal float64 = 0 //材料费
  13569. // var materialCostPartSelfTotal float64 = 0 //材料费
  13570. //
  13571. // var westernMedicineCostTotal float64 = 0 //西药费
  13572. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  13573. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13574. //
  13575. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13576. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13577. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13578. //
  13579. // var checkCostTotal float64 = 0 //检查费
  13580. // var checkCostSelfTotal float64 = 0 //检查费
  13581. // var checkCostPartSelfTotal float64 = 0 //检查费
  13582. //
  13583. // var laboratoryCostTotal float64 = 0 //化验费
  13584. // var laboratoryCostSelfTotal float64 = 0 //化验费
  13585. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13586. //
  13587. // var treatCostTotal float64 = 0 //治疗费用
  13588. // var treatCostSelfTotal float64 = 0 //治疗费用
  13589. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  13590. //
  13591. // decimal.DivisionPrecision = 2
  13592. //
  13593. // var bed_fulamt_ownpay_amt float64 = 0
  13594. //
  13595. // var examine_fulamt_ownpay_amt float64 = 0
  13596. //
  13597. // var nursing_fulamt_ownpay_amt float64 = 0
  13598. //
  13599. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  13600. //
  13601. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  13602. //
  13603. // var register_fulamt_ownpay_amt float64 = 0
  13604. //
  13605. // var operation_fulamt_ownpay_amt float64 = 0
  13606. // var other_fulamt_ownpay_amt float64 = 0
  13607. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  13608. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13609. // var check_fulamt_ownpay_amt float64 = 0
  13610. // var material_fulamt_ownpay_amt float64 = 0
  13611. // var laboratory_fulamt_ownpay_amt float64 = 0
  13612. // var treat_fulamt_ownpay_amt float64 = 0
  13613. //
  13614. // var bed_claa_sunmfee float64 = 0
  13615. // var bed_clab_amt float64 = 0
  13616. // var bed_other_amt float64 = 0
  13617. //
  13618. // var examine_claa_sunmfee float64 = 0
  13619. // var examine_clab_amt float64 = 0
  13620. // var examine_other_amt float64 = 0
  13621. //
  13622. // var nursing_claa_sunmfee float64 = 0
  13623. // var nursing_clab_amt float64 = 0
  13624. // var nursing_other_amt float64 = 0
  13625. //
  13626. // var chinese_medicine_claa_sunmfee float64 = 0
  13627. // var chinese_medicine_clab_amt float64 = 0
  13628. // var chinese_medicine_other_amt float64 = 0
  13629. //
  13630. // var commonly_treatment_claa_sunmfee float64 = 0
  13631. // var commonly_treatment_clab_amt float64 = 0
  13632. // var commonly_treatment_other_amt float64 = 0
  13633. //
  13634. // var operation_claa_sunmfee float64 = 0
  13635. // var operation_clab_amt float64 = 0
  13636. // var operation_other_amt float64 = 0
  13637. //
  13638. // var other_claa_sunmfee float64 = 0
  13639. // var other_clab_amt float64 = 0
  13640. // var other_other_amt float64 = 0
  13641. //
  13642. // var westernMedicine_claa_sunmfee float64 = 0
  13643. // var westernMedicine_clab_amt float64 = 0
  13644. // var westernMedicine_other_amt float64 = 0
  13645. //
  13646. // var chineseTraditional_claa_sunmfee float64 = 0
  13647. // var chineseTraditional_clab_amt float64 = 0
  13648. // var chineseTraditional_other_amt float64 = 0
  13649. //
  13650. // var check_claa_sunmfee float64 = 0
  13651. // var check_clab_amt float64 = 0
  13652. // var check_other_amt float64 = 0
  13653. //
  13654. // var material_claa_sunmfee float64 = 0
  13655. // var material_clab_amt float64 = 0
  13656. // var material_other_amt float64 = 0
  13657. //
  13658. // var laboratory_claa_sunmfee float64 = 0
  13659. // var laboratory_clab_amt float64 = 0
  13660. // var laboratory_other_amt float64 = 0
  13661. //
  13662. // var treat_claa_sunmfee float64 = 0
  13663. // var treat_clab_amt float64 = 0
  13664. // var treat_other_amt float64 = 0
  13665. //
  13666. // var register_claa_sunmfee float64 = 0
  13667. // var register_clab_amt float64 = 0
  13668. // var register_other_amt float64 = 0
  13669. //
  13670. // for _, item := range order.HisOrderInfo {
  13671. // if item.MedChrgitmType == "01" { //床位费
  13672. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13673. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13674. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13675. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13676. // if item.ChrgitmLv == "1" {
  13677. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13678. // }
  13679. // if item.ChrgitmLv == "2" {
  13680. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13681. //
  13682. // }
  13683. // if item.ChrgitmLv == "3" {
  13684. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13685. // }
  13686. //
  13687. // }
  13688. //
  13689. // if item.MedChrgitmType == "02" { //诊查
  13690. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13691. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13692. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13693. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13694. // if item.ChrgitmLv == "1" {
  13695. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13696. // }
  13697. // if item.ChrgitmLv == "2" {
  13698. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13699. //
  13700. // }
  13701. // if item.ChrgitmLv == "3" {
  13702. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13703. // }
  13704. //
  13705. // }
  13706. //
  13707. // if item.MedChrgitmType == "03" { //检查费
  13708. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13709. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13710. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13711. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13712. // if item.ChrgitmLv == "1" {
  13713. //
  13714. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13715. //
  13716. // }
  13717. // if item.ChrgitmLv == "2" {
  13718. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13719. //
  13720. // }
  13721. // if item.ChrgitmLv == "3" {
  13722. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13723. // }
  13724. // }
  13725. //
  13726. // if item.MedChrgitmType == "04" { //化验费
  13727. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13728. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13729. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13730. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13731. // if item.ChrgitmLv == "1" {
  13732. //
  13733. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13734. //
  13735. // }
  13736. // if item.ChrgitmLv == "2" {
  13737. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13738. //
  13739. // }
  13740. // if item.ChrgitmLv == "3" {
  13741. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13742. // }
  13743. // }
  13744. //
  13745. // if item.MedChrgitmType == "05" { //治疗费
  13746. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13747. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13748. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13749. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13750. // if item.ChrgitmLv == "1" {
  13751. //
  13752. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13753. //
  13754. // }
  13755. // if item.ChrgitmLv == "2" {
  13756. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13757. //
  13758. // }
  13759. // if item.ChrgitmLv == "3" {
  13760. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13761. // }
  13762. // }
  13763. //
  13764. // if item.MedChrgitmType == "06" { //手术费
  13765. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13766. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13767. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13768. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13769. //
  13770. // if item.ChrgitmLv == "1" {
  13771. //
  13772. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13773. //
  13774. // }
  13775. // if item.ChrgitmLv == "2" {
  13776. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13777. //
  13778. // }
  13779. // if item.ChrgitmLv == "3" {
  13780. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13781. // }
  13782. // }
  13783. //
  13784. // if item.MedChrgitmType == "07" { //手术费
  13785. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13786. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13787. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13788. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13789. //
  13790. // if item.ChrgitmLv == "1" {
  13791. //
  13792. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13793. //
  13794. // }
  13795. // if item.ChrgitmLv == "2" {
  13796. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13797. //
  13798. // }
  13799. // if item.ChrgitmLv == "3" {
  13800. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13801. // }
  13802. // }
  13803. //
  13804. // if item.MedChrgitmType == "08" { //材料费
  13805. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13806. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13807. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13808. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13809. // if item.ChrgitmLv == "1" {
  13810. //
  13811. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13812. //
  13813. // }
  13814. // if item.ChrgitmLv == "2" {
  13815. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13816. //
  13817. // }
  13818. // if item.ChrgitmLv == "3" {
  13819. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13820. // }
  13821. // }
  13822. // if item.MedChrgitmType == "09" { //西药费
  13823. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13824. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13825. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13826. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13827. // if item.ChrgitmLv == "1" {
  13828. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13829. // }
  13830. // if item.ChrgitmLv == "2" {
  13831. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13832. // }
  13833. // if item.ChrgitmLv == "3" {
  13834. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13835. // }
  13836. // }
  13837. // if item.MedChrgitmType == "10" { //中药饮片
  13838. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13839. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13840. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13841. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13842. // if item.ChrgitmLv == "1" {
  13843. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13844. // }
  13845. // if item.ChrgitmLv == "2" {
  13846. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13847. // }
  13848. // if item.ChrgitmLv == "3" {
  13849. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13850. // }
  13851. // }
  13852. //
  13853. // if item.MedChrgitmType == "11" { //中成费
  13854. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13855. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13856. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13857. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13858. // if item.ChrgitmLv == "1" {
  13859. //
  13860. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13861. //
  13862. // }
  13863. // if item.ChrgitmLv == "2" {
  13864. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13865. //
  13866. // }
  13867. // if item.ChrgitmLv == "3" {
  13868. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13869. // }
  13870. // }
  13871. //
  13872. // if item.MedChrgitmType == "12" { //中成费
  13873. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13874. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13875. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13876. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13877. // if item.ChrgitmLv == "1" {
  13878. //
  13879. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13880. //
  13881. // }
  13882. // if item.ChrgitmLv == "2" {
  13883. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13884. //
  13885. // }
  13886. // if item.ChrgitmLv == "3" {
  13887. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13888. // }
  13889. // }
  13890. //
  13891. // if item.MedChrgitmType == "13" { //中成费
  13892. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13893. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13894. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13895. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13896. // if item.ChrgitmLv == "1" {
  13897. //
  13898. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13899. //
  13900. // }
  13901. // if item.ChrgitmLv == "2" {
  13902. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13903. //
  13904. // }
  13905. // if item.ChrgitmLv == "3" {
  13906. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13907. // }
  13908. // }
  13909. //
  13910. // if item.MedChrgitmType == "14" { //其他费
  13911. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13912. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13913. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13914. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13915. // if item.ChrgitmLv == "1" {
  13916. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13917. //
  13918. // }
  13919. // if item.ChrgitmLv == "2" {
  13920. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13921. //
  13922. // }
  13923. // if item.ChrgitmLv == "3" {
  13924. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13925. // }
  13926. // }
  13927. //
  13928. // }
  13929. //
  13930. // var iteminfoStructs []service.IteminfoStruct
  13931. //
  13932. // if bedCostTotal != 0 {
  13933. // iteminfo.MedChrgitm = "01"
  13934. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13935. // iteminfo.Amt = bedCostTotal
  13936. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  13937. // iteminfo.ClabAmt = bed_clab_amt
  13938. // iteminfo.OthAmt = bed_other_amt
  13939. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13940. // }
  13941. //
  13942. // if examineCostTotal != 0 {
  13943. // iteminfo.MedChrgitm = "02"
  13944. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  13945. // iteminfo.Amt = examineCostTotal
  13946. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  13947. // iteminfo.ClabAmt = examine_clab_amt
  13948. // iteminfo.OthAmt = examine_other_amt
  13949. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13950. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13951. // }
  13952. //
  13953. // if checkCostTotal != 0 {
  13954. // iteminfo.MedChrgitm = "03"
  13955. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13956. // iteminfo.Amt = checkCostTotal
  13957. // iteminfo.ClaaSumfee = check_claa_sunmfee
  13958. // iteminfo.ClabAmt = check_clab_amt
  13959. // iteminfo.OthAmt = check_other_amt
  13960. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13961. //
  13962. // }
  13963. //
  13964. // if laboratoryCostTotal != 0 {
  13965. // iteminfo.MedChrgitm = "04"
  13966. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13967. // iteminfo.Amt = laboratoryCostTotal
  13968. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13969. // iteminfo.ClabAmt = laboratory_clab_amt
  13970. // iteminfo.OthAmt = laboratory_other_amt
  13971. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13972. //
  13973. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13974. //
  13975. // }
  13976. //
  13977. // if treatCostTotal != 0 {
  13978. // iteminfo.MedChrgitm = "05"
  13979. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13980. // iteminfo.Amt = treatCostTotal
  13981. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  13982. // iteminfo.ClabAmt = treat_clab_amt
  13983. // iteminfo.OthAmt = treat_other_amt
  13984. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13985. // //(struct4101.IteminfoStruct, iteminfo)
  13986. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13987. // }
  13988. //
  13989. // if operationCostTotal != 0 {
  13990. // iteminfo.MedChrgitm = "06"
  13991. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13992. // iteminfo.Amt = operationCostTotal
  13993. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  13994. // iteminfo.ClabAmt = operation_clab_amt
  13995. // iteminfo.OthAmt = operation_other_amt
  13996. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13997. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  13998. // }
  13999. //
  14000. // if nursingCostTotal != 0 {
  14001. // iteminfo.MedChrgitm = "07"
  14002. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14003. // iteminfo.Amt = nursingCostTotal
  14004. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14005. // iteminfo.ClabAmt = nursing_clab_amt
  14006. // iteminfo.OthAmt = nursing_other_amt
  14007. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14008. // }
  14009. //
  14010. // if materialCostTotal != 0 {
  14011. // iteminfo.MedChrgitm = "08"
  14012. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14013. // iteminfo.Amt = materialCostTotal
  14014. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14015. // iteminfo.ClabAmt = material_clab_amt
  14016. // iteminfo.OthAmt = material_other_amt
  14017. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14018. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14019. // }
  14020. //
  14021. // if westernMedicineCostTotal != 0 {
  14022. // iteminfo.MedChrgitm = "09"
  14023. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14024. // iteminfo.Amt = westernMedicineCostTotal
  14025. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14026. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14027. // iteminfo.OthAmt = westernMedicine_other_amt
  14028. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14029. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14030. //
  14031. // }
  14032. //
  14033. // if chineseMedicineCostTotal != 0 {
  14034. // iteminfo.MedChrgitm = "10"
  14035. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14036. // iteminfo.Amt = chineseMedicineCostTotal
  14037. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14038. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14039. // iteminfo.OthAmt = chinese_medicine_other_amt
  14040. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14041. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14042. //
  14043. // }
  14044. //
  14045. // if chineseTraditionalMedicineCostTotal != 0 {
  14046. // iteminfo.MedChrgitm = "11"
  14047. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14048. // iteminfo.Amt = westernMedicineCostTotal
  14049. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14050. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14051. // iteminfo.OthAmt = westernMedicine_other_amt
  14052. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14053. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14054. //
  14055. // }
  14056. //
  14057. // if commonlyTreatmentCostTotal != 0 {
  14058. // iteminfo.MedChrgitm = "12"
  14059. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14060. // iteminfo.Amt = commonlyTreatmentCostTotal
  14061. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14062. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14063. // iteminfo.OthAmt = commonly_treatment_other_amt
  14064. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14065. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14066. //
  14067. // }
  14068. //
  14069. // if registerCostTotal != 0 {
  14070. // iteminfo.MedChrgitm = "13"
  14071. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14072. // iteminfo.Amt = registerCostTotal
  14073. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14074. // iteminfo.ClabAmt = register_clab_amt
  14075. // iteminfo.OthAmt = register_other_amt
  14076. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14077. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14078. //
  14079. // }
  14080. //
  14081. // if otherCostTotal != 0 {
  14082. // iteminfo.MedChrgitm = "14"
  14083. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14084. // iteminfo.Amt = otherCostTotal
  14085. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14086. // iteminfo.ClabAmt = other_clab_amt
  14087. // iteminfo.OthAmt = other_other_amt
  14088. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14089. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14090. //
  14091. // }
  14092. // struct4101.IteminfoStruct = iteminfoStructs
  14093. // time_arr := strings.Split(order.SetlTime, " ")
  14094. // struct4101.AdmTime = time_arr[0]
  14095. // struct4101.AdmEndTime = time_arr[0]
  14096. //
  14097. // struct4101.DoctorName = doctor.UserName
  14098. // struct4101.DoctorCode = doctor.DoctorNumber
  14099. //
  14100. // struct4101.Ntly = "中国"
  14101. // struct4101.AdmCaty = "A03.06"
  14102. // var res ResultSeventeen
  14103. // if miConfig.MdtrtareaAdmvs == "421300" {
  14104. // data := make(map[string]interface{})
  14105. // data["struct4101"] = struct4101
  14106. // data["secret_key"] = miConfig.SecretKey
  14107. // data["org_name"] = miConfig.OrgName
  14108. // data["opera"] = curRoles.UserName
  14109. // data["code"] = miConfig.Code
  14110. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14111. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14112. //
  14113. // client := &http.Client{}
  14114. // bytesData, _ := json.Marshal(data)
  14115. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14116. // resp, _ := client.Do(req)
  14117. // defer resp.Body.Close()
  14118. // body, ioErr := ioutil.ReadAll(resp.Body)
  14119. // if ioErr != nil {
  14120. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14122. // return
  14123. // }
  14124. // var respJSON map[string]interface{}
  14125. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14126. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14128. // return
  14129. // }
  14130. //
  14131. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14132. // userJSONBytes, _ := json.Marshal(respJSON)
  14133. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14134. // utils.ErrorLog("解析失败:%v", err)
  14135. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14136. // adminUser := c.GetAdminUserInfo()
  14137. // errlog := &models.HisOrderError{
  14138. // UserOrgId: adminUser.CurrentOrgId,
  14139. // Ctime: time.Now().Unix(),
  14140. // Mtime: time.Now().Unix(),
  14141. // ErrMsg: res.ErrMsg + "解析失败",
  14142. // Status: 1,
  14143. // PatientId: order_id,
  14144. // Stage: 10088,
  14145. // }
  14146. // service.CreateErrMsgLog(errlog)
  14147. // continue
  14148. // }
  14149. //
  14150. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14151. // data := make(map[string]interface{})
  14152. // data["struct4101"] = struct4101
  14153. // data["secret_key"] = miConfig.SecretKey
  14154. // data["org_name"] = miConfig.OrgName
  14155. // data["opera"] = curRoles.UserName
  14156. // data["code"] = miConfig.Code
  14157. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14158. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14159. //
  14160. // client := &http.Client{}
  14161. // bytesData, _ := json.Marshal(data)
  14162. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14163. // resp, _ := client.Do(req)
  14164. // defer resp.Body.Close()
  14165. // body, ioErr := ioutil.ReadAll(resp.Body)
  14166. // if ioErr != nil {
  14167. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14168. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14169. // return
  14170. // }
  14171. // var respJSON map[string]interface{}
  14172. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14173. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14174. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14175. // return
  14176. // }
  14177. //
  14178. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14179. // userJSONBytes, _ := json.Marshal(respJSON)
  14180. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14181. // utils.ErrorLog("解析失败:%v", err)
  14182. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14183. // adminUser := c.GetAdminUserInfo()
  14184. // errlog := &models.HisOrderError{
  14185. // UserOrgId: adminUser.CurrentOrgId,
  14186. // Ctime: time.Now().Unix(),
  14187. // Mtime: time.Now().Unix(),
  14188. // ErrMsg: res.ErrMsg + "解析失败",
  14189. // Status: 1,
  14190. // PatientId: order_id,
  14191. // Stage: 10088,
  14192. // }
  14193. // service.CreateErrMsgLog(errlog)
  14194. // continue
  14195. // }
  14196. //
  14197. // } else {
  14198. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14199. // fmt.Println(result)
  14200. //
  14201. // var dat map[string]interface{}
  14202. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14203. // fmt.Println(dat)
  14204. // } else {
  14205. // fmt.Println(err)
  14206. // }
  14207. // userJSONBytes, _ := json.Marshal(dat)
  14208. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14209. // utils.ErrorLog("解析失败:%v", err)
  14210. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14211. // adminUser := c.GetAdminUserInfo()
  14212. // errlog := &models.HisOrderError{
  14213. // UserOrgId: adminUser.CurrentOrgId,
  14214. // Ctime: time.Now().Unix(),
  14215. // Mtime: time.Now().Unix(),
  14216. // ErrMsg: res.ErrMsg + "解析失败",
  14217. // Status: 1,
  14218. // PatientId: order_id,
  14219. // Stage: 10106,
  14220. // }
  14221. // service.CreateErrMsgLog(errlog)
  14222. // continue
  14223. // }
  14224. // }
  14225. //
  14226. // if res.Infcode != 0 {
  14227. // adminUser := c.GetAdminUserInfo()
  14228. // errlog := &models.HisOrderError{
  14229. // UserOrgId: adminUser.CurrentOrgId,
  14230. // Ctime: time.Now().Unix(),
  14231. // Mtime: time.Now().Unix(),
  14232. // ErrMsg: res.ErrMsg,
  14233. // Status: 1,
  14234. // PatientId: order_id,
  14235. // Stage: 10106,
  14236. // }
  14237. // service.CreateErrMsgLog(errlog)
  14238. // continue
  14239. // } else {
  14240. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14241. // Number: res.Output.SetlListId,
  14242. // Status: 1,
  14243. // Ctime: time.Now().Unix(),
  14244. // Mtime: time.Now().Unix(),
  14245. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14246. // IsUpload: 1,
  14247. // OrderId: order_id,
  14248. // }
  14249. // service.CreateUploadRecord(hisFundSettleListResult)
  14250. // continue
  14251. // }
  14252. // }
  14253. //}
  14254. func (c *HisApiController) GetOrgInfo() {
  14255. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14256. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14257. }
  14258. func (c *HisApiController) GetHisPatientInfo() {
  14259. medical_insurance_card := c.GetString("medical_insurance_card")
  14260. id_card_type, _ := c.GetInt64("id_card_type")
  14261. id_card := c.GetString("id_card")
  14262. adminInfo := c.GetAdminUserInfo()
  14263. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14264. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14265. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14266. IdCardNo := ""
  14267. if id_card_type == 1 {
  14268. IdCardNo = medical_insurance_card
  14269. } else if id_card_type == 2 {
  14270. IdCardNo = id_card
  14271. }
  14272. if config.IsOpen == 1 {
  14273. 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
  14274. resp, requestErr := http.Get(api)
  14275. if requestErr != nil {
  14276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14277. return
  14278. }
  14279. defer resp.Body.Close()
  14280. body, ioErr := ioutil.ReadAll(resp.Body)
  14281. if ioErr != nil {
  14282. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14284. return
  14285. }
  14286. var respJSON map[string]interface{}
  14287. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14288. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14290. return
  14291. }
  14292. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14293. userJSONBytes, _ := json.Marshal(userJSON)
  14294. var res ResultTwo
  14295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14296. utils.ErrorLog("解析失败:%v", err)
  14297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14298. return
  14299. }
  14300. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14301. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14302. infoStr := string(Iinfos)
  14303. idetinfoStr := string(Idetinfos)
  14304. if res.Infcode == 0 {
  14305. his := models.VMHisPatient{
  14306. Status: 1,
  14307. Ctime: time.Now().Unix(),
  14308. Mtime: time.Now().Unix(),
  14309. PsnNo: res.Output.Baseinfo.PsnNo,
  14310. PsnCertType: res.Output.Baseinfo.PsnCertType,
  14311. Certno: res.Output.Baseinfo.Certno,
  14312. PsnName: res.Output.Baseinfo.PsnName,
  14313. Gend: res.Output.Baseinfo.Gend,
  14314. Naty: res.Output.Baseinfo.Naty,
  14315. Iinfo: infoStr,
  14316. Idetinfo: idetinfoStr,
  14317. UserOrgId: adminInfo.CurrentOrgId,
  14318. IsReturn: 1,
  14319. IdCardType: id_card_type,
  14320. }
  14321. c.ServeSuccessJSON(map[string]interface{}{
  14322. "info": his,
  14323. })
  14324. } else {
  14325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14326. return
  14327. }
  14328. }
  14329. }
  14330. //func GetBasBaseInfo() (jsonStr string, err error) {
  14331. //
  14332. // handle := syscall.NewLazyDLL("SSCard.dll")
  14333. // add := handle.NewProc("ReadCardBas")
  14334. // str := make([]byte, 1024)
  14335. // str1 := make([]byte, 1024)
  14336. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14337. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  14338. //
  14339. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  14340. //
  14341. // fmt.Println("> Add(4,5)的结果为:", ret)
  14342. // handle.Release()
  14343. //
  14344. // return "", nil
  14345. //
  14346. //}
  14347. //func GetQRBaseInfo() (jsonStr string, err error) {
  14348. // handle := syscall.LoadDLL("SSCard.dll")
  14349. // ReadCardBas := handle.FindProc("GetQRBase")
  14350. //
  14351. // str := make([]byte, 256)
  14352. // str1 := make([]byte, 256)
  14353. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  14354. //
  14355. // fmt.Println(string(str))
  14356. // fmt.Println(r)
  14357. // return string(str), nil
  14358. //}
  14359. //func CardInit() int {
  14360. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  14361. // add := DllTestDef.MustFindProc("Init")
  14362. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14363. // if err != nil {
  14364. // fmt.Println("SSCard的运算结果为:", ret)
  14365. // }
  14366. // result := int(ret)
  14367. // return result
  14368. //}
  14369. //func CardInit() int {
  14370. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  14371. // if err != nil {
  14372. // fmt.Println("SSCard的运算结果为:", ret)
  14373. // }
  14374. // fmt.Println(err)
  14375. // result := int(ret)
  14376. // return result
  14377. //}
  14378. func IntPtr(n int) uintptr {
  14379. return uintptr(n)
  14380. }
  14381. func StrPtr(s string) uintptr {
  14382. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  14383. }
  14384. type Result2001 struct {
  14385. Cainfo interface{} `json:"cainfo"`
  14386. ErrMsg string `json:"err_msg"`
  14387. InfRefmsgid string `json:"inf_refmsgid"`
  14388. Infcode int64 `json:"infcode"`
  14389. Output struct {
  14390. Trtinfo struct {
  14391. PsnNo string `json:"psn_no"`
  14392. TrtChkType string `json:"trt_chk_type"`
  14393. FundPayType string `json:"fund_pay_type"`
  14394. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14395. Begndate string `json:"begndate"`
  14396. Enddate string `json:"enddate"`
  14397. TrtChkRslt string `json:"trt_chk_rslt"`
  14398. } `json:"trtinfo"`
  14399. } `json:"output"`
  14400. RefmsgTime string `json:"refmsg_time"`
  14401. RespondTime string `json:"respond_time"`
  14402. Signtype interface{} `json:"signtype"`
  14403. WarnMsg interface{} `json:"warn_msg"`
  14404. }
  14405. type Result2001Org10265 struct {
  14406. Cainfo interface{} `json:"cainfo"`
  14407. ErrMsg string `json:"err_msg"`
  14408. InfRefmsgid string `json:"inf_refmsgid"`
  14409. Infcode string `json:"infcode"`
  14410. Output struct {
  14411. Trtinfo struct {
  14412. PsnNo string `json:"psn_no"`
  14413. TrtChkType string `json:"trt_chk_type"`
  14414. FundPayType string `json:"fund_pay_type"`
  14415. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  14416. Begndate string `json:"begndate"`
  14417. Enddate string `json:"enddate"`
  14418. TrtChkRslt string `json:"trt_chk_rslt"`
  14419. } `json:"trtinfo"`
  14420. } `json:"output"`
  14421. RefmsgTime string `json:"refmsg_time"`
  14422. RespondTime string `json:"respond_time"`
  14423. Signtype interface{} `json:"signtype"`
  14424. WarnMsg interface{} `json:"warn_msg"`
  14425. }
  14426. type ResultTwo struct {
  14427. ErrMsg string `json:"err_msg"`
  14428. InfRefmsgid string `json:"inf_refmsgid"`
  14429. Infcode int64 `json:"infcode"`
  14430. Output struct {
  14431. Baseinfo struct {
  14432. //Brdy string `json:"brdy"`
  14433. Certno string `json:"certno"`
  14434. Gend string `json:"gend"`
  14435. Naty string `json:"naty"`
  14436. PsnCertType string `json:"psn_cert_type"`
  14437. PsnName string `json:"psn_name"`
  14438. PsnNo string `json:"psn_no"`
  14439. } `json:"baseinfo"`
  14440. Idetinfo []interface{} `json:"idetinfo"`
  14441. Iinfo []struct {
  14442. Balc float64 `json:"balc"`
  14443. CvlservFlag string `json:"cvlserv_flag"`
  14444. EmpName string `json:"emp_name"`
  14445. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14446. Insutype string `json:"insutype"`
  14447. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14448. //PausInsuDate string `json:"paus_insu_date"`
  14449. //PsnInsuDate string `json:"psn_insu_date"`
  14450. PsnInsuStas string `json:"psn_insu_stas"`
  14451. PsnType string `json:"psn_type"`
  14452. } `json:"insuinfo"`
  14453. } `json:"output"`
  14454. RefmsgTime string `json:"refmsg_time"`
  14455. RespondTime string `json:"respond_time"`
  14456. Signtype interface{} `json:"signtype"`
  14457. WarnInfo interface{} `json:"warn_info"`
  14458. }
  14459. type ResultTwo10265 struct {
  14460. ErrMsg string `json:"err_msg"`
  14461. InfRefmsgid string `json:"inf_refmsgid"`
  14462. Infcode string `json:"infcode"`
  14463. Output struct {
  14464. Baseinfo struct {
  14465. //Brdy string `json:"brdy"`
  14466. Certno string `json:"certno"`
  14467. Gend string `json:"gend"`
  14468. Naty string `json:"naty"`
  14469. PsnCertType string `json:"psn_cert_type"`
  14470. PsnName string `json:"psn_name"`
  14471. PsnNo string `json:"psn_no"`
  14472. } `json:"baseinfo"`
  14473. Idetinfo []interface{} `json:"idetinfo"`
  14474. Iinfo []struct {
  14475. Balc float64 `json:"balc"`
  14476. CvlservFlag string `json:"cvlserv_flag"`
  14477. EmpName string `json:"emp_name"`
  14478. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14479. Insutype string `json:"insutype"`
  14480. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14481. PsnInsuStas string `json:"psn_insu_stas"`
  14482. PsnType string `json:"psn_type"`
  14483. } `json:"insuinfo"`
  14484. } `json:"output"`
  14485. RefmsgTime string `json:"refmsg_time"`
  14486. RespondTime string `json:"respond_time"`
  14487. Signtype interface{} `json:"signtype"`
  14488. WarnInfo interface{} `json:"warn_info"`
  14489. }
  14490. type ResultThree struct {
  14491. Cainfo interface{} `json:"cainfo"`
  14492. ErrMsg string `json:"err_msg"`
  14493. InfRefmsgid string `json:"inf_refmsgid"`
  14494. Infcode int64 `json:"infcode"`
  14495. Output struct {
  14496. Data struct {
  14497. IptOtpNo string `json:"ipt_otp_no"`
  14498. MdtrtID string `json:"mdtrt_id"`
  14499. PsnNo string `json:"psn_no"`
  14500. } `json:"data"`
  14501. } `json:"output"`
  14502. RefmsgTime string `json:"refmsg_time"`
  14503. RespondTime string `json:"respond_time"`
  14504. Signtype interface{} `json:"signtype"`
  14505. WarnMsg interface{} `json:"warn_msg"`
  14506. }
  14507. type ResultThree10265 struct {
  14508. Cainfo interface{} `json:"cainfo"`
  14509. ErrMsg string `json:"err_msg"`
  14510. InfRefmsgid string `json:"inf_refmsgid"`
  14511. Infcode string `json:"infcode"`
  14512. Output struct {
  14513. Data struct {
  14514. IptOtpNo string `json:"ipt_otp_no"`
  14515. MdtrtID string `json:"mdtrt_id"`
  14516. PsnNo string `json:"psn_no"`
  14517. } `json:"data"`
  14518. } `json:"output"`
  14519. RefmsgTime string `json:"refmsg_time"`
  14520. RespondTime string `json:"respond_time"`
  14521. Signtype interface{} `json:"signtype"`
  14522. WarnMsg interface{} `json:"warn_msg"`
  14523. }
  14524. type ResultFour struct {
  14525. Cainfo string `json:"cainfo"`
  14526. ErrMsg string `json:"err_msg"`
  14527. InfRefmsgid string `json:"inf_refmsgid"`
  14528. Infcode int64 `json:"infcode"`
  14529. Output struct {
  14530. Result []struct {
  14531. BasMednFlag string `json:"bas_medn_flag"`
  14532. ChldMedcFlag string `json:"chld_medc_flag"`
  14533. ChrgitmLv string `json:"chrgitm_lv"`
  14534. Cnt float64 `json:"cnt"`
  14535. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14536. DrtReimFlag string `json:"drt_reim_flag"`
  14537. FeedetlSn string `json:"feedetl_sn"`
  14538. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14539. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14540. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14541. ListSpItemFlag string `json:"list_sp_item_flag"`
  14542. LmtUsedFlag string `json:"lmt_used_flag"`
  14543. MedChrgitmType string `json:"med_chrgitm_type"`
  14544. Memo string `json:"memo"`
  14545. OverlmtAmt float64 `json:"overlmt_amt"`
  14546. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14547. Pric float64 `json:"pric"`
  14548. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14549. SelfpayProp float64 `json:"selfpay_prop"`
  14550. } `json:"result"`
  14551. } `json:"output"`
  14552. RefmsgTime string `json:"refmsg_time"`
  14553. RespondTime string `json:"respond_time"`
  14554. Signtype string `json:"signtype"`
  14555. WarnMsg string `json:"warn_msg"`
  14556. }
  14557. type ResultFour10265 struct {
  14558. Cainfo string `json:"cainfo"`
  14559. ErrMsg string `json:"err_msg"`
  14560. InfRefmsgid string `json:"inf_refmsgid"`
  14561. Infcode string `json:"infcode"`
  14562. Output struct {
  14563. Result []struct {
  14564. BasMednFlag string `json:"bas_medn_flag"`
  14565. ChldMedcFlag string `json:"chld_medc_flag"`
  14566. ChrgitmLv string `json:"chrgitm_lv"`
  14567. Cnt float64 `json:"cnt"`
  14568. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  14569. DrtReimFlag string `json:"drt_reim_flag"`
  14570. FeedetlSn string `json:"feedetl_sn"`
  14571. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14572. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  14573. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14574. ListSpItemFlag string `json:"list_sp_item_flag"`
  14575. LmtUsedFlag string `json:"lmt_used_flag"`
  14576. MedChrgitmType string `json:"med_chrgitm_type"`
  14577. Memo string `json:"memo"`
  14578. OverlmtAmt float64 `json:"overlmt_amt"`
  14579. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14580. Pric float64 `json:"pric"`
  14581. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  14582. SelfpayProp float64 `json:"selfpay_prop"`
  14583. } `json:"result"`
  14584. } `json:"output"`
  14585. RefmsgTime string `json:"refmsg_time"`
  14586. RespondTime string `json:"respond_time"`
  14587. Signtype string `json:"signtype"`
  14588. WarnMsg string `json:"warn_msg"`
  14589. }
  14590. type ResultMemo struct {
  14591. InsuAdmdvs string `json:"insuAdmdvs"`
  14592. }
  14593. // [{"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}]
  14594. type ResultIDInfo struct {
  14595. Begntime string `json:"begntime"`
  14596. Endtime string `json:"endtime"`
  14597. Memo string `json:"memo"`
  14598. }
  14599. type ResultFive struct {
  14600. Balc float64 `json:"balc"`
  14601. CvlservFlag string `json:"cvlserv_flag"`
  14602. EmpName string `json:"emp_name"`
  14603. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  14604. Insutype string `json:"insutype"`
  14605. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  14606. PausInsuDate string `json:"paus_insu_date"`
  14607. PsnInsuDate string `json:"psn_insu_date"`
  14608. PsnInsuStas string `json:"psn_insu_stas"`
  14609. PsnType string `json:"psn_type"`
  14610. }
  14611. type ResultSix struct {
  14612. Cainfo interface{} `json:"cainfo"`
  14613. ErrMsg string `json:"err_msg"`
  14614. InfRefmsgid string `json:"inf_refmsgid"`
  14615. Infcode int64 `json:"infcode"`
  14616. Output struct {
  14617. } `json:"output"`
  14618. RefmsgTime string `json:"refmsg_time"`
  14619. RespondTime string `json:"respond_time"`
  14620. Signtype interface{} `json:"signtype"`
  14621. WarnMsg interface{} `json:"warn_msg"`
  14622. }
  14623. type Result2406 struct {
  14624. Cainfo interface{} `json:"cainfo"`
  14625. ErrMsg string `json:"err_msg"`
  14626. InfRefmsgid string `json:"inf_refmsgid"`
  14627. Infcode int64 `json:"infcode"`
  14628. Output struct {
  14629. Result struct {
  14630. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  14631. } `json:"result"`
  14632. } `json:"output"`
  14633. RefmsgTime string `json:"refmsg_time"`
  14634. RespondTime string `json:"respond_time"`
  14635. Signtype interface{} `json:"signtype"`
  14636. WarnMsg interface{} `json:"warn_msg"`
  14637. }
  14638. type GZResultSix struct {
  14639. Cainfo interface{} `json:"cainfo"`
  14640. ErrMsg string `json:"err_msg"`
  14641. InfRefmsgid string `json:"inf_refmsgid"`
  14642. Infcode int64 `json:"infcode"`
  14643. Output string `json:"output"`
  14644. RefmsgTime string `json:"refmsg_time"`
  14645. RespondTime string `json:"respond_time"`
  14646. Signtype interface{} `json:"signtype"`
  14647. WarnMsg interface{} `json:"warn_msg"`
  14648. }
  14649. type ResultSix10265 struct {
  14650. Cainfo interface{} `json:"cainfo"`
  14651. ErrMsg string `json:"err_msg"`
  14652. InfRefmsgid string `json:"inf_refmsgid"`
  14653. Infcode string `json:"infcode"`
  14654. Output struct {
  14655. } `json:"output"`
  14656. RefmsgTime string `json:"refmsg_time"`
  14657. RespondTime string `json:"respond_time"`
  14658. Signtype interface{} `json:"signtype"`
  14659. WarnMsg interface{} `json:"warn_msg"`
  14660. }
  14661. type ResultSeven struct {
  14662. Cainfo string `json:"cainfo"`
  14663. ErrMsg string `json:"err_msg"`
  14664. InfRefmsgid string `json:"inf_refmsgid"`
  14665. Infcode int64 `json:"infcode"`
  14666. Output struct {
  14667. Setlinfo struct {
  14668. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14669. AcctPay float64 `json:"acct_pay"`
  14670. ActPayDedc float64 `json:"act_pay_dedc"`
  14671. Age float64 `json:"age"`
  14672. Balc float64 `json:"balc"`
  14673. Certno string `json:"certno"`
  14674. ClrOptins string `json:"clr_optins"`
  14675. ClrType string `json:"clr_type"`
  14676. ClrWay string `json:"clr_way"`
  14677. CvlservFlag string `json:"cvlserv_flag"`
  14678. CvlservPay float64 `json:"cvlserv_pay"`
  14679. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14680. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14681. Gend string `json:"gend"`
  14682. HifesPay float64 `json:"hifes_pay"`
  14683. HifmiPay float64 `json:"hifmi_pay"`
  14684. HifpPay float64 `json:"hifp_pay"`
  14685. HospPartAmt float64 `json:"hosp_part_amt"`
  14686. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14687. Insutype string `json:"insutype"`
  14688. MafPay float64 `json:"maf_pay"`
  14689. MdtrtCertType string `json:"mdtrt_cert_type"`
  14690. HifobPay float64 `json:"hifob_pay"`
  14691. MdtrtID string `json:"mdtrt_id"`
  14692. MedType string `json:"med_type"`
  14693. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14694. MedinsSetlID string `json:"medins_setl_id"`
  14695. Naty string `json:"naty"`
  14696. OthPay float64 `json:"oth_pay"`
  14697. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14698. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14699. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14700. PsnCashPay float64 `json:"psn_cash_pay"`
  14701. PsnCertType string `json:"psn_cert_type"`
  14702. PsnName string `json:"psn_name"`
  14703. PsnNo string `json:"psn_no"`
  14704. PsnPartAmt float64 `json:"psn_part_amt"`
  14705. PsnType string `json:"psn_type"`
  14706. SetlID string `json:"setl_id"`
  14707. SetlTime string `json:"setl_time"`
  14708. } `json:"setlinfo"`
  14709. Setldetail interface{} `json:"setldetail"`
  14710. } `json:"output"`
  14711. RefmsgTime string `json:"refmsg_time"`
  14712. RespondTime string `json:"respond_time"`
  14713. Signtype interface{} `json:"signtype"`
  14714. WarnMsg interface{} `json:"warn_msg"`
  14715. }
  14716. type ResultSevenAH struct {
  14717. Cainfo string `json:"cainfo"`
  14718. ErrMsg string `json:"err_msg"`
  14719. InfRefmsgid string `json:"inf_refmsgid"`
  14720. Infcode int64 `json:"infcode"`
  14721. Output struct {
  14722. Setlinfo struct {
  14723. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14724. AcctPay float64 `json:"acct_pay"`
  14725. ActPayDedc float64 `json:"act_pay_dedc"`
  14726. Age float64 `json:"age"`
  14727. Balc float64 `json:"balc"`
  14728. Certno string `json:"certno"`
  14729. ClrOptins string `json:"clr_optins"`
  14730. ClrType string `json:"clr_type"`
  14731. ClrWay string `json:"clr_way"`
  14732. CvlservFlag string `json:"cvlserv_flag"`
  14733. CvlservPay float64 `json:"cvlserv_pay"`
  14734. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14735. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14736. Gend string `json:"gend"`
  14737. HifesPay float64 `json:"hifes_pay"`
  14738. HifmiPay float64 `json:"hifmi_pay"`
  14739. HifpPay float64 `json:"hifp_pay"`
  14740. HospPartAmt float64 `json:"hosp_part_amt"`
  14741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14742. Insutype string `json:"insutype"`
  14743. MafPay float64 `json:"maf_pay"`
  14744. MdtrtCertType string `json:"mdtrt_cert_type"`
  14745. HifobPay float64 `json:"hifob_pay"`
  14746. MdtrtID string `json:"mdtrt_id"`
  14747. MedType string `json:"med_type"`
  14748. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14749. MedinsSetlID string `json:"medins_setl_id"`
  14750. Naty string `json:"naty"`
  14751. OthPay float64 `json:"oth_pay"`
  14752. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14753. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14754. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14755. PsnCashPay float64 `json:"psn_cash_pay"`
  14756. PsnCertType string `json:"psn_cert_type"`
  14757. PsnName string `json:"psn_name"`
  14758. PsnNo string `json:"psn_no"`
  14759. PsnPartAmt float64 `json:"psn_part_amt"`
  14760. PsnType string `json:"psn_type"`
  14761. SetlID string `json:"setl_id"`
  14762. SetlTime int64 `json:"setl_time"`
  14763. } `json:"setlinfo"`
  14764. Setldetail interface{} `json:"setldetail"`
  14765. } `json:"output"`
  14766. RefmsgTime string `json:"refmsg_time"`
  14767. RespondTime string `json:"respond_time"`
  14768. Signtype interface{} `json:"signtype"`
  14769. WarnMsg interface{} `json:"warn_msg"`
  14770. }
  14771. type ResultSeven10265 struct {
  14772. Cainfo string `json:"cainfo"`
  14773. ErrMsg string `json:"err_msg"`
  14774. InfRefmsgid string `json:"inf_refmsgid"`
  14775. Infcode string `json:"infcode"`
  14776. Output struct {
  14777. Setlinfo struct {
  14778. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14779. AcctPay float64 `json:"acct_pay"`
  14780. ActPayDedc float64 `json:"act_pay_dedc"`
  14781. Age float64 `json:"age"`
  14782. Balc float64 `json:"balc"`
  14783. Certno string `json:"certno"`
  14784. ClrOptins string `json:"clr_optins"`
  14785. ClrType string `json:"clr_type"`
  14786. ClrWay string `json:"clr_way"`
  14787. CvlservFlag string `json:"cvlserv_flag"`
  14788. CvlservPay float64 `json:"cvlserv_pay"`
  14789. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14790. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14791. Gend string `json:"gend"`
  14792. HifesPay float64 `json:"hifes_pay"`
  14793. HifmiPay float64 `json:"hifmi_pay"`
  14794. HifpPay float64 `json:"hifp_pay"`
  14795. HospPartAmt float64 `json:"hosp_part_amt"`
  14796. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14797. Insutype string `json:"insutype"`
  14798. MafPay float64 `json:"maf_pay"`
  14799. MdtrtCertType string `json:"mdtrt_cert_type"`
  14800. HifobPay float64 `json:"hifob_pay"`
  14801. MdtrtID string `json:"mdtrt_id"`
  14802. MedType string `json:"med_type"`
  14803. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14804. MedinsSetlID string `json:"medins_setl_id"`
  14805. Naty string `json:"naty"`
  14806. OthPay float64 `json:"oth_pay"`
  14807. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14808. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  14809. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14810. PsnCashPay float64 `json:"psn_cash_pay"`
  14811. PsnCertType string `json:"psn_cert_type"`
  14812. PsnName string `json:"psn_name"`
  14813. PsnNo string `json:"psn_no"`
  14814. PsnPartAmt float64 `json:"psn_part_amt"`
  14815. PsnType string `json:"psn_type"`
  14816. SetlID string `json:"setl_id"`
  14817. SetlTime string `json:"setl_time"`
  14818. } `json:"setlinfo"`
  14819. Setldetail interface{} `json:"setldetail"`
  14820. } `json:"output"`
  14821. RefmsgTime string `json:"refmsg_time"`
  14822. RespondTime string `json:"respond_time"`
  14823. Signtype interface{} `json:"signtype"`
  14824. WarnMsg interface{} `json:"warn_msg"`
  14825. }
  14826. type ResultSeven10265Two struct {
  14827. Cainfo string `json:"cainfo"`
  14828. ErrMsg string `json:"err_msg"`
  14829. InfRefmsgid string `json:"inf_refmsgid"`
  14830. Infcode string `json:"infcode"`
  14831. Output struct {
  14832. Setlinfo struct {
  14833. AcctMulaidPay string `json:"acct_mulaid_pay"`
  14834. AcctPay float64 `json:"acct_pay"`
  14835. ActPayDedc float64 `json:"act_pay_dedc"`
  14836. Age float64 `json:"age"`
  14837. Balc float64 `json:"balc"`
  14838. Certno string `json:"certno"`
  14839. ClrOptins string `json:"clr_optins"`
  14840. ClrType string `json:"clr_type"`
  14841. ClrWay string `json:"clr_way"`
  14842. CvlservFlag string `json:"cvlserv_flag"`
  14843. CvlservPay float64 `json:"cvlserv_pay"`
  14844. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14845. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14846. Gend string `json:"gend"`
  14847. HifesPay float64 `json:"hifes_pay"`
  14848. HifmiPay float64 `json:"hifmi_pay"`
  14849. HifpPay float64 `json:"hifp_pay"`
  14850. HospPartAmt string `json:"hosp_part_amt"`
  14851. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14852. Insutype string `json:"insutype"`
  14853. MafPay float64 `json:"maf_pay"`
  14854. MdtrtCertType string `json:"mdtrt_cert_type"`
  14855. HifobPay float64 `json:"hifob_pay"`
  14856. MdtrtID string `json:"mdtrt_id"`
  14857. MedType string `json:"med_type"`
  14858. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14859. MedinsSetlID string `json:"medins_setl_id"`
  14860. Naty string `json:"naty"`
  14861. OthPay float64 `json:"oth_pay"`
  14862. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14863. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14864. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14865. PsnCashPay float64 `json:"psn_cash_pay"`
  14866. PsnCertType string `json:"psn_cert_type"`
  14867. PsnName string `json:"psn_name"`
  14868. PsnNo string `json:"psn_no"`
  14869. PsnPartAmt float64 `json:"psn_part_amt"`
  14870. PsnType string `json:"psn_type"`
  14871. SetlID string `json:"setl_id"`
  14872. SetlTime string `json:"setl_time"`
  14873. } `json:"setlinfo"`
  14874. Setldetail interface{} `json:"setldetail"`
  14875. } `json:"output"`
  14876. RefmsgTime string `json:"refmsg_time"`
  14877. RespondTime string `json:"respond_time"`
  14878. Signtype interface{} `json:"signtype"`
  14879. WarnMsg interface{} `json:"warn_msg"`
  14880. }
  14881. type GZResultSeven10265Two struct {
  14882. Cainfo string `json:"cainfo"`
  14883. ErrMsg string `json:"err_msg"`
  14884. InfRefmsgid string `json:"inf_refmsgid"`
  14885. Infcode int64 `json:"infcode"`
  14886. Output struct {
  14887. Setlinfo struct {
  14888. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  14889. AcctPay float64 `json:"acct_pay"`
  14890. ActPayDedc float64 `json:"act_pay_dedc"`
  14891. Age float64 `json:"age"`
  14892. Balc float64 `json:"balc"`
  14893. Certno string `json:"certno"`
  14894. ClrOptins string `json:"clr_optins"`
  14895. ClrType string `json:"clr_type"`
  14896. ClrWay string `json:"clr_way"`
  14897. CvlservFlag string `json:"cvlserv_flag"`
  14898. CvlservPay float64 `json:"cvlserv_pay"`
  14899. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  14900. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  14901. Gend string `json:"gend"`
  14902. HifesPay float64 `json:"hifes_pay"`
  14903. HifmiPay float64 `json:"hifmi_pay"`
  14904. HifpPay float64 `json:"hifp_pay"`
  14905. HospPartAmt float64 `json:"hosp_part_amt"`
  14906. InscpScpAmt float64 `json:"inscp_scp_amt"`
  14907. Insutype string `json:"insutype"`
  14908. MafPay float64 `json:"maf_pay"`
  14909. MdtrtCertType string `json:"mdtrt_cert_type"`
  14910. HifobPay float64 `json:"hifob_pay"`
  14911. MdtrtID string `json:"mdtrt_id"`
  14912. MedType string `json:"med_type"`
  14913. MedfeeSumamt float64 `json:"medfee_sumamt"`
  14914. MedinsSetlID string `json:"medins_setl_id"`
  14915. Naty string `json:"naty"`
  14916. OthPay float64 `json:"oth_pay"`
  14917. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  14918. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  14919. PreselfpayAmt float64 `json:"preselfpay_amt"`
  14920. PsnCashPay float64 `json:"psn_cash_pay"`
  14921. PsnCertType string `json:"psn_cert_type"`
  14922. PsnName string `json:"psn_name"`
  14923. PsnNo string `json:"psn_no"`
  14924. PsnPartAmt float64 `json:"psn_part_amt"`
  14925. PsnType string `json:"psn_type"`
  14926. SetlID string `json:"setl_id"`
  14927. SetlTime string `json:"setl_time"`
  14928. } `json:"setlinfo"`
  14929. Setldetail interface{} `json:"setldetail"`
  14930. } `json:"output"`
  14931. RefmsgTime string `json:"refmsg_time"`
  14932. RespondTime string `json:"respond_time"`
  14933. Signtype interface{} `json:"signtype"`
  14934. WarnMsg interface{} `json:"warn_msg"`
  14935. }
  14936. type ResultEight struct {
  14937. Cainfo string `json:"cainfo"`
  14938. ErrMsg string `json:"err_msg"`
  14939. InfRefmsgid string `json:"inf_refmsgid"`
  14940. Infcode int64 `json:"infcode"`
  14941. Output struct {
  14942. Stmtinfo struct {
  14943. SetlOptins string `json:"setl_optins"`
  14944. StmtRslt string `json:"stmt_rslt"`
  14945. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14946. } `json:"stmtinfo"`
  14947. } `json:"output"`
  14948. RefmsgTime string `json:"refmsg_time"`
  14949. RespondTime string `json:"respond_time"`
  14950. Signtype interface{} `json:"signtype"`
  14951. WarnMsg interface{} `json:"warn_msg"`
  14952. }
  14953. type ResultEightFor10188 struct {
  14954. Cainfo string `json:"cainfo"`
  14955. ErrMsg string `json:"err_msg"`
  14956. InfRefmsgid string `json:"inf_refmsgid"`
  14957. Infcode string `json:"infcode"`
  14958. Output struct {
  14959. Stmtinfo struct {
  14960. SetlOptins string `json:"setl_optins"`
  14961. StmtRslt string `json:"stmt_rslt"`
  14962. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  14963. } `json:"stmtinfo"`
  14964. } `json:"output"`
  14965. RefmsgTime string `json:"refmsg_time"`
  14966. RespondTime string `json:"respond_time"`
  14967. Signtype interface{} `json:"signtype"`
  14968. WarnMsg interface{} `json:"warn_msg"`
  14969. }
  14970. type ResultNine struct {
  14971. Cainfo string `json:"cainfo"`
  14972. ErrMsg string `json:"err_msg"`
  14973. InfRefmsgid string `json:"inf_refmsgid"`
  14974. Infcode int64 `json:"infcode"`
  14975. Output struct {
  14976. FileQuryNo string `json:"file_qury_no"`
  14977. } `json:"output"`
  14978. RefmsgTime string `json:"refmsg_time"`
  14979. RespondTime string `json:"respond_time"`
  14980. Signtype interface{} `json:"signtype"`
  14981. WarnMsg interface{} `json:"warn_msg"`
  14982. }
  14983. type ResultTen struct {
  14984. Cainfo string `json:"cainfo"`
  14985. ErrMsg string `json:"err_msg"`
  14986. InfRefmsgid string `json:"inf_refmsgid"`
  14987. Infcode int64 `json:"infcode"`
  14988. Output struct {
  14989. Fileinfo struct {
  14990. DldEndtime string `json:"dld_endtime"`
  14991. FileQuryNo string `json:"file_qury_no"`
  14992. Filename string `json:"filename"`
  14993. } `json:"fileinfo"`
  14994. } `json:"output"`
  14995. RefmsgTime string `json:"refmsg_time"`
  14996. RespondTime string `json:"respond_time"`
  14997. Signtype interface{} `json:"signtype"`
  14998. WarnMsg interface{} `json:"warn_msg"`
  14999. }
  15000. type Result5262 struct {
  15001. ErrMsg string `json:"err_msg"`
  15002. InfRefmsgid string `json:"inf_refmsgid"`
  15003. Infcode int64 `json:"infcode"`
  15004. Output struct {
  15005. PageInfo struct {
  15006. Size int `json:"size"`
  15007. RecordCounts int `json:"record_counts"`
  15008. } `json:"page_info"`
  15009. Idetinfo []interface{} `json:"idetinfo"`
  15010. Result []struct {
  15011. SetlID string `json:"setl_id"`
  15012. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15013. MdtrtID string `json:"mdtrt_id"`
  15014. InitSetlID string `json:"init_setl_id,omitempty"`
  15015. PsnNo string `json:"psn_no"`
  15016. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15017. PsnName string `json:"psn_name"`
  15018. PsnCertType string `json:"psn_cert_type"`
  15019. Certno string `json:"certno"`
  15020. Gend string `json:"gend,omitempty"`
  15021. Naty string `json:"naty,omitempty"`
  15022. Brdy string `json:"brdy,omitempty"`
  15023. Age float64 `json:"age,omitempty"`
  15024. Insutype string `json:"insutype,omitempty"`
  15025. PsnType string `json:"psn_type"`
  15026. CvlservFlag string `json:"cvlserv_flag"`
  15027. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15028. SpPsnType string `json:"sp_psn_type,omitempty"`
  15029. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15030. ClctGrde string `json:"clct_grde,omitempty"`
  15031. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15032. NwbFlag string `json:"nwb_flag,omitempty"`
  15033. InsuAdmdvs string `json:"insu_admdvs"`
  15034. EmpNo string `json:"emp_no,omitempty"`
  15035. EmpName string `json:"emp_name,omitempty"`
  15036. EmpType string `json:"emp_type,omitempty"`
  15037. EconType string `json:"econ_type,omitempty"`
  15038. AfilIndu string `json:"afil_indu,omitempty"`
  15039. AfilRlts string `json:"afil_rlts,omitempty"`
  15040. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15041. PayLoc string `json:"pay_loc,omitempty"`
  15042. FixmedinsCode string `json:"fixmedins_code"`
  15043. FixmedinsName string `json:"fixmedins_name"`
  15044. HospLv string `json:"hosp_lv,omitempty"`
  15045. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15046. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15047. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15048. Begndate string `json:"begndate"`
  15049. Enddate string `json:"enddate"`
  15050. SetlTime string `json:"setl_time"`
  15051. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15052. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15053. MedType string `json:"med_type"`
  15054. SetlType string `json:"setl_type,omitempty"`
  15055. ClrType string `json:"clr_type,omitempty"`
  15056. ClrWay string `json:"clr_way,omitempty"`
  15057. PsnSetlway string `json:"psn_setlway,omitempty"`
  15058. ClrOptins string `json:"clr_optins,omitempty"`
  15059. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15060. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15061. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15062. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15063. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15064. DedcStd float64 `json:"dedc_std,omitempty"`
  15065. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15066. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15067. HifpPay float64 `json:"hifp_pay,omitempty"`
  15068. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15069. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15070. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15071. HifesPay float64 `json:"hifes_pay,omitempty"`
  15072. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15073. HifobPay float64 `json:"hifob_pay,omitempty"`
  15074. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15075. MafPay float64 `json:"maf_pay,omitempty"`
  15076. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15077. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15078. PsnPay float64 `json:"psn_pay,omitempty"`
  15079. AcctPay float64 `json:"acct_pay,omitempty"`
  15080. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15081. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15082. Balc float64 `json:"balc,omitempty"`
  15083. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15084. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15085. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15086. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15087. Year string `json:"year,omitempty"`
  15088. DiseNo string `json:"dise_no,omitempty"`
  15089. DiseName string `json:"dise_name,omitempty"`
  15090. Invono string `json:"invono,omitempty"`
  15091. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15092. ValiFlag string `json:"vali_flag,omitempty"`
  15093. Memo string `json:"memo,omitempty"`
  15094. Rid string `json:"rid"`
  15095. UpdtTime string `json:"updt_time,omitempty"`
  15096. CrterID string `json:"crter_id,omitempty"`
  15097. CrterName string `json:"crter_name,omitempty"`
  15098. CrteTime string `json:"crte_time,omitempty"`
  15099. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15100. OpterID string `json:"opter_id,omitempty"`
  15101. OpterName string `json:"opter_name,omitempty"`
  15102. OptTime string `json:"opt_time,omitempty"`
  15103. OptinsNo string `json:"optins_no,omitempty"`
  15104. PoolareaNo string `json:"poolarea_no,omitempty"`
  15105. } `json:"result"`
  15106. } `json:"output"`
  15107. RefmsgTime string `json:"refmsg_time"`
  15108. RespondTime string `json:"respond_time"`
  15109. Signtype interface{} `json:"signtype"`
  15110. WarnInfo interface{} `json:"warn_info"`
  15111. }
  15112. type Result5267 struct {
  15113. ErrMsg string `json:"err_msg"`
  15114. InfRefmsgid string `json:"inf_refmsgid"`
  15115. Infcode int64 `json:"infcode"`
  15116. Output struct {
  15117. PageInfo struct {
  15118. Size int `json:"size"`
  15119. RecordCounts int `json:"record_counts"`
  15120. } `json:"pageinfo"`
  15121. Result []struct {
  15122. SetlID string `json:"setl_id"`
  15123. ClrOptins string `json:"clr_optins"`
  15124. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15125. MdtrtID string `json:"mdtrt_id"`
  15126. InitSetlID string `json:"init_setl_id,omitempty"`
  15127. PsnNo string `json:"psn_no"`
  15128. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15129. PsnName string `json:"psn_name"`
  15130. PsnCertType string `json:"psn_cert_type"`
  15131. Certno string `json:"certno"`
  15132. Gend string `json:"gend,omitempty"`
  15133. Naty string `json:"naty,omitempty"`
  15134. Brdy string `json:"brdy,omitempty"`
  15135. Age float64 `json:"age,omitempty"`
  15136. Insutype string `json:"insutype,omitempty"`
  15137. PsnType string `json:"psn_type"`
  15138. CvlservFlag string `json:"cvlserv_flag"`
  15139. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15140. SpPsnType string `json:"sp_psn_type,omitempty"`
  15141. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15142. ClctGrde string `json:"clct_grde,omitempty"`
  15143. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15144. NwbFlag string `json:"nwb_flag,omitempty"`
  15145. InsuAdmdvs string `json:"insu_admdvs"`
  15146. EmpNo string `json:"emp_no,omitempty"`
  15147. EmpName string `json:"emp_name,omitempty"`
  15148. EmpType string `json:"emp_type,omitempty"`
  15149. EconType string `json:"econ_type,omitempty"`
  15150. AfilIndu string `json:"afil_indu,omitempty"`
  15151. AfilRlts string `json:"afil_rlts,omitempty"`
  15152. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15153. PayLoc string `json:"pay_loc,omitempty"`
  15154. FixmedinsCode string `json:"fixmedins_code"`
  15155. FixmedinsName string `json:"fixmedins_name"`
  15156. HospLv string `json:"hosp_lv,omitempty"`
  15157. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15158. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15159. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15160. Begndate string `json:"begndate,omitempty"`
  15161. Enddate string `json:"enddate,omitempty"`
  15162. SetlTime string `json:"setl_time,omitempty"`
  15163. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15164. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15165. MedType string `json:"med_type"`
  15166. SetlType string `json:"setl_type,omitempty"`
  15167. ClrType string `json:"clr_type,omitempty"`
  15168. ClrWay string `json:"clr_way,omitempty"`
  15169. PsnSetlway string `json:"psn_setlway,omitempty"`
  15170. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15171. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15172. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15173. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15174. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15175. DedcStd float64 `json:"dedc_std,omitempty"`
  15176. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15177. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15178. HifpPay float64 `json:"hifp_pay,omitempty"`
  15179. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15180. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15181. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15182. HifesPay float64 `json:"hifes_pay,omitempty"`
  15183. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15184. HifobPay float64 `json:"hifob_pay,omitempty"`
  15185. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15186. MafPay float64 `json:"maf_pay,omitempty"`
  15187. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15188. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15189. PsnPay float64 `json:"psn_pay,omitempty"`
  15190. AcctPay float64 `json:"acct_pay,omitempty"`
  15191. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15192. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15193. Balc float64 `json:"balc,omitempty"`
  15194. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15195. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15196. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15197. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15198. Year string `json:"year,omitempty"`
  15199. DiseNo string `json:"dise_no,omitempty"`
  15200. DiseName string `json:"dise_name,omitempty"`
  15201. Invono string `json:"invono,omitempty"`
  15202. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15203. Memo string `json:"memo,omitempty"`
  15204. UpdtTime string `json:"updt_time,omitempty"`
  15205. OpterID string `json:"opter_id,omitempty"`
  15206. OpterName string `json:"opter_name,omitempty"`
  15207. OptTime string `json:"opt_time,omitempty"`
  15208. OptinsNo string `json:"optins_no,omitempty"`
  15209. PoolareaNo string `json:"poolarea_no,omitempty"`
  15210. } `json:"result"`
  15211. } `json:"output"`
  15212. RefmsgTime string `json:"refmsg_time"`
  15213. RespondTime string `json:"respond_time"`
  15214. Signtype interface{} `json:"signtype"`
  15215. WarnInfo interface{} `json:"warn_info"`
  15216. }
  15217. // type Autogenerated struct {
  15218. // Output struct {
  15219. // Setlinfo struct {
  15220. // SetlTime string `json:"setl_time"`
  15221. // CvlservPay float64 `json:"cvlserv_pay"`
  15222. // Year string `json:"year"`
  15223. // MedType string `json:"med_type"`
  15224. // PsnPay float64 `json:"psn_pay"`
  15225. // OpterID string `json:"opter_id"`
  15226. // Begndate string `json:"begndate"`
  15227. // FlxempeFlag string `json:"flxempe_flag"`
  15228. // HifmiPay float64 `json:"hifmi_pay"`
  15229. // PsnNo string `json:"psn_no"`
  15230. // ActPayDedc float64 `json:"act_pay_dedc"`
  15231. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15232. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15233. // ClrWay string `json:"clr_way"`
  15234. // OthPay float64 `json:"oth_pay"`
  15235. // Gend string `json:"gend"`
  15236. // MdtrtID string `json:"mdtrt_id"`
  15237. // AcctPay float64 `json:"acct_pay"`
  15238. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15239. // Insutype string `json:"insutype"`
  15240. // Invono interface{} `json:"invono"`
  15241. // Enddate string `json:"enddate"`
  15242. // CashPayamt float64 `json:"cash_payamt"`
  15243. // PsnType string `json:"psn_type"`
  15244. // FixmedinsName string `json:"fixmedins_name"`
  15245. // HifpPay float64 `json:"hifp_pay"`
  15246. // NewFlag interface{} `json:"new_flag"`
  15247. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15248. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15249. // PayLoc string `json:"pay_loc"`
  15250. // ClrType string `json:"clr_type"`
  15251. // RefdSetlFlag string `json:"refd_setl_flag"`
  15252. // CvlservFlag string `json:"cvlserv_flag"`
  15253. // EmpName string `json:"emp_name"`
  15254. // Brdy string `json:"brdy"`
  15255. // Naty string `json:"naty"`
  15256. // Certno string `json:"certno"`
  15257. // DiseCode string `json:"dise_code"`
  15258. // FixmedinsCode string `json:"fixmedins_code"`
  15259. // DedcHospLv string `json:"dedc_hosp_lv"`
  15260. // OpterName string `json:"opter_name"`
  15261. // Balc float64 `json:"balc"`
  15262. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15263. // PsnCertType string `json:"psn_cert_type"`
  15264. // HifobPay float64 `json:"hifob_pay"`
  15265. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15266. // HifesPay float64 `json:"hifes_pay"`
  15267. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15268. // OptTime string `json:"opt_time"`
  15269. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15270. // SetlID string `json:"setl_id"`
  15271. // MafPay float64 `json:"maf_pay"`
  15272. // PsnName string `json:"psn_name"`
  15273. // InsuOptins interface{} `json:"insu_optins"`
  15274. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15275. // ClrOptins string `json:"clr_optins"`
  15276. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15277. // DiseName string `json:"dise_name"`
  15278. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15279. // Age float64 `json:"age"`
  15280. // DtrtCertType string `json:"dtrt_cert_type"`
  15281. // HospLv string `json:"hosp_lv"`
  15282. // } `json:"setlinfo"`
  15283. // Setldetail []struct {
  15284. // FundPayType string `json:"fund_pay_type"`
  15285. // FundPayamt float64 `json:"fund_payamt"`
  15286. // SetlProcInfo interface{} `json:"setl_proc_info"`
  15287. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  15288. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  15289. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  15290. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15291. // } `json:"setldetail"`
  15292. // } `json:"output"`
  15293. // Infcode int `json:"infcode"`
  15294. // WarnMsg interface{} `json:"warn_msg"`
  15295. // Cainfo interface{} `json:"cainfo"`
  15296. // ErrMsg interface{} `json:"err_msg"`
  15297. // RefmsgTime string `json:"refmsg_time"`
  15298. // Signtype interface{} `json:"signtype"`
  15299. // RespondTime string `json:"respond_time"`
  15300. // InfRefmsgid string `json:"inf_refmsgid"`
  15301. // }
  15302. type Result002 struct {
  15303. Cainfo interface{} `json:"cainfo"`
  15304. ErrMsg string `json:"err_msg"`
  15305. InfRefmsgid string `json:"inf_refmsgid"`
  15306. Infcode int64 `json:"infcode"`
  15307. Output struct {
  15308. RxFile string `json:"rx_file"`
  15309. SignDigest string `json:"sign_digest"`
  15310. SignCertSn string `json:"sign_cert_sn"`
  15311. SignCertDn string `json:"sign_cert_dn"`
  15312. } `json:"output"`
  15313. RefmsgTime string `json:"refmsg_time"`
  15314. RespondTime string `json:"respond_time"`
  15315. Signtype interface{} `json:"signtype"`
  15316. WarnMsg interface{} `json:"warn_msg"`
  15317. }
  15318. type Result003 struct {
  15319. Cainfo interface{} `json:"cainfo"`
  15320. ErrMsg string `json:"err_msg"`
  15321. InfRefmsgid string `json:"inf_refmsgid"`
  15322. Infcode int64 `json:"infcode"`
  15323. Output struct {
  15324. HiRxno string `json:"hi_rxno"`
  15325. RxStasCodg string `json:"rx_stas_codg"`
  15326. RxStasName string `json:"rx_stas_name"`
  15327. } `json:"output"`
  15328. RefmsgTime string `json:"refmsg_time"`
  15329. RespondTime string `json:"respond_time"`
  15330. Signtype interface{} `json:"signtype"`
  15331. WarnMsg interface{} `json:"warn_msg"`
  15332. }
  15333. type ResultEleven struct {
  15334. Cainfo string `json:"cainfo"`
  15335. ErrMsg string `json:"err_msg"`
  15336. InfRefmsgid string `json:"inf_refmsgid"`
  15337. Infcode int64 `json:"infcode"`
  15338. Output struct {
  15339. Setlinfo struct {
  15340. SetlTime string `json:"setl_time"`
  15341. CvlservPay float64 `json:"cvlserv_pay"`
  15342. Year string `json:"year"`
  15343. MedType string `json:"med_type"`
  15344. PsnPay float64 `json:"psn_pay"`
  15345. OpterID string `json:"opter_id"`
  15346. Begndate string `json:"begndate"`
  15347. FlxempeFlag string `json:"flxempe_flag"`
  15348. HifmiPay float64 `json:"hifmi_pay"`
  15349. PsnNo string `json:"psn_no"`
  15350. ActPayDedc float64 `json:"act_pay_dedc"`
  15351. MedinsSetlID interface{} `json:"medins_setl_id"`
  15352. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15353. ClrWay string `json:"clr_way"`
  15354. OthPay float64 `json:"oth_pay"`
  15355. Gend string `json:"gend"`
  15356. MdtrtID string `json:"mdtrt_id"`
  15357. AcctPay float64 `json:"acct_pay"`
  15358. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15359. Insutype string `json:"insutype"`
  15360. Invono interface{} `json:"invono"`
  15361. Enddate string `json:"enddate"`
  15362. CashPayamt float64 `json:"cash_payamt"`
  15363. PsnType string `json:"psn_type"`
  15364. FixmedinsName string `json:"fixmedins_name"`
  15365. HifpPay float64 `json:"hifp_pay"`
  15366. NewFlag interface{} `json:"new_flag"`
  15367. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15368. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15369. PayLoc string `json:"pay_loc"`
  15370. ClrType string `json:"clr_type"`
  15371. RefdSetlFlag string `json:"refd_setl_flag"`
  15372. CvlservFlag string `json:"cvlserv_flag"`
  15373. EmpName string `json:"emp_name"`
  15374. Brdy string `json:"brdy"`
  15375. Naty string `json:"naty"`
  15376. Certno string `json:"certno"`
  15377. DiseCode string `json:"dise_code"`
  15378. FixmedinsCode string `json:"fixmedins_code"`
  15379. DedcHospLv string `json:"dedc_hosp_lv"`
  15380. OpterName string `json:"opter_name"`
  15381. Balc float64 `json:"balc"`
  15382. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15383. PsnCertType string `json:"psn_cert_type"`
  15384. HifobPay float64 `json:"hifob_pay"`
  15385. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15386. HifesPay float64 `json:"hifes_pay"`
  15387. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15388. OptTime string `json:"opt_time"`
  15389. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15390. SetlID string `json:"setl_id"`
  15391. MafPay float64 `json:"maf_pay"`
  15392. PsnName string `json:"psn_name"`
  15393. InsuOptins interface{} `json:"insu_optins"`
  15394. PrefFundPay interface{} `json:"pref_fund_pay"`
  15395. ClrOptins string `json:"clr_optins"`
  15396. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15397. DiseName string `json:"dise_name"`
  15398. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15399. Age float64 `json:"age"`
  15400. DtrtCertType string `json:"dtrt_cert_type"`
  15401. HospLv string `json:"hosp_lv"`
  15402. PsnCashPay float64 `json:"psn_cash_pay"`
  15403. } `json:"setlinfo"`
  15404. } `json:"output"`
  15405. RefmsgTime string `json:"refmsg_time"`
  15406. RespondTime string `json:"respond_time"`
  15407. Signtype interface{} `json:"signtype"`
  15408. WarnMsg interface{} `json:"warn_msg"`
  15409. }
  15410. type ResultElevenah struct {
  15411. Cainfo string `json:"cainfo"`
  15412. ErrMsg string `json:"err_msg"`
  15413. InfRefmsgid string `json:"inf_refmsgid"`
  15414. Infcode int64 `json:"infcode"`
  15415. Output struct {
  15416. Setlinfo struct {
  15417. SetlTime int64 `json:"setl_time"`
  15418. CvlservPay float64 `json:"cvlserv_pay"`
  15419. Year string `json:"year"`
  15420. MedType string `json:"med_type"`
  15421. PsnPay float64 `json:"psn_pay"`
  15422. OpterID string `json:"opter_id"`
  15423. Begndate int64 `json:"begndate"`
  15424. FlxempeFlag string `json:"flxempe_flag"`
  15425. HifmiPay float64 `json:"hifmi_pay"`
  15426. PsnNo string `json:"psn_no"`
  15427. ActPayDedc float64 `json:"act_pay_dedc"`
  15428. MedinsSetlID interface{} `json:"medins_setl_id"`
  15429. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15430. ClrWay string `json:"clr_way"`
  15431. OthPay float64 `json:"oth_pay"`
  15432. Gend string `json:"gend"`
  15433. MdtrtID string `json:"mdtrt_id"`
  15434. AcctPay float64 `json:"acct_pay"`
  15435. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15436. Insutype string `json:"insutype"`
  15437. Invono interface{} `json:"invono"`
  15438. Enddate int64 `json:"enddate"`
  15439. CashPayamt float64 `json:"cash_payamt"`
  15440. PsnType string `json:"psn_type"`
  15441. FixmedinsName string `json:"fixmedins_name"`
  15442. HifpPay float64 `json:"hifp_pay"`
  15443. NewFlag interface{} `json:"new_flag"`
  15444. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15445. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15446. PayLoc string `json:"pay_loc"`
  15447. ClrType string `json:"clr_type"`
  15448. RefdSetlFlag string `json:"refd_setl_flag"`
  15449. CvlservFlag string `json:"cvlserv_flag"`
  15450. EmpName string `json:"emp_name"`
  15451. Brdy int64 `json:"brdy"`
  15452. Naty string `json:"naty"`
  15453. Certno string `json:"certno"`
  15454. DiseCode string `json:"dise_code"`
  15455. FixmedinsCode string `json:"fixmedins_code"`
  15456. DedcHospLv string `json:"dedc_hosp_lv"`
  15457. OpterName string `json:"opter_name"`
  15458. Balc float64 `json:"balc"`
  15459. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15460. PsnCertType string `json:"psn_cert_type"`
  15461. HifobPay float64 `json:"hifob_pay"`
  15462. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15463. HifesPay float64 `json:"hifes_pay"`
  15464. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15465. OptTime int64 `json:"opt_time"`
  15466. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15467. SetlID string `json:"setl_id"`
  15468. MafPay float64 `json:"maf_pay"`
  15469. PsnName string `json:"psn_name"`
  15470. InsuOptins interface{} `json:"insu_optins"`
  15471. PrefFundPay interface{} `json:"pref_fund_pay"`
  15472. ClrOptins string `json:"clr_optins"`
  15473. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15474. DiseName string `json:"dise_name"`
  15475. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15476. Age float64 `json:"age"`
  15477. DtrtCertType string `json:"dtrt_cert_type"`
  15478. HospLv string `json:"hosp_lv"`
  15479. PsnCashPay float64 `json:"psn_cash_pay"`
  15480. } `json:"setlinfo"`
  15481. } `json:"output"`
  15482. RefmsgTime string `json:"refmsg_time"`
  15483. RespondTime string `json:"respond_time"`
  15484. Signtype interface{} `json:"signtype"`
  15485. WarnMsg interface{} `json:"warn_msg"`
  15486. }
  15487. type ResultEleven10265 struct {
  15488. Cainfo string `json:"cainfo"`
  15489. ErrMsg string `json:"err_msg"`
  15490. InfRefmsgid string `json:"inf_refmsgid"`
  15491. Infcode string `json:"infcode"`
  15492. Output struct {
  15493. Setlinfo struct {
  15494. SetlTime string `json:"setl_time"`
  15495. CvlservPay float64 `json:"cvlserv_pay"`
  15496. Year string `json:"year"`
  15497. MedType string `json:"med_type"`
  15498. PsnPay float64 `json:"psn_pay"`
  15499. OpterID string `json:"opter_id"`
  15500. Begndate string `json:"begndate"`
  15501. FlxempeFlag string `json:"flxempe_flag"`
  15502. HifmiPay float64 `json:"hifmi_pay"`
  15503. PsnNo string `json:"psn_no"`
  15504. ActPayDedc float64 `json:"act_pay_dedc"`
  15505. MedinsSetlID interface{} `json:"medins_setl_id"`
  15506. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15507. ClrWay string `json:"clr_way"`
  15508. OthPay float64 `json:"oth_pay"`
  15509. Gend string `json:"gend"`
  15510. MdtrtID string `json:"mdtrt_id"`
  15511. AcctPay float64 `json:"acct_pay"`
  15512. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15513. Insutype string `json:"insutype"`
  15514. Invono interface{} `json:"invono"`
  15515. Enddate string `json:"enddate"`
  15516. CashPayamt float64 `json:"cash_payamt"`
  15517. PsnType string `json:"psn_type"`
  15518. FixmedinsName string `json:"fixmedins_name"`
  15519. HifpPay float64 `json:"hifp_pay"`
  15520. NewFlag interface{} `json:"new_flag"`
  15521. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15522. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15523. PayLoc string `json:"pay_loc"`
  15524. ClrType string `json:"clr_type"`
  15525. RefdSetlFlag string `json:"refd_setl_flag"`
  15526. CvlservFlag string `json:"cvlserv_flag"`
  15527. EmpName string `json:"emp_name"`
  15528. Brdy string `json:"brdy"`
  15529. Naty string `json:"naty"`
  15530. Certno string `json:"certno"`
  15531. DiseCode string `json:"dise_code"`
  15532. FixmedinsCode string `json:"fixmedins_code"`
  15533. DedcHospLv string `json:"dedc_hosp_lv"`
  15534. OpterName string `json:"opter_name"`
  15535. Balc float64 `json:"balc"`
  15536. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15537. PsnCertType string `json:"psn_cert_type"`
  15538. HifobPay float64 `json:"hifob_pay"`
  15539. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15540. HifesPay float64 `json:"hifes_pay"`
  15541. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15542. OptTime string `json:"opt_time"`
  15543. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15544. SetlID string `json:"setl_id"`
  15545. MafPay float64 `json:"maf_pay"`
  15546. PsnName string `json:"psn_name"`
  15547. InsuOptins interface{} `json:"insu_optins"`
  15548. PrefFundPay interface{} `json:"pref_fund_pay"`
  15549. ClrOptins string `json:"clr_optins"`
  15550. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15551. DiseName string `json:"dise_name"`
  15552. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  15553. Age float64 `json:"age"`
  15554. DtrtCertType string `json:"dtrt_cert_type"`
  15555. HospLv string `json:"hosp_lv"`
  15556. PsnCashPay float64 `json:"psn_cash_pay"`
  15557. } `json:"setlinfo"`
  15558. } `json:"output"`
  15559. RefmsgTime string `json:"refmsg_time"`
  15560. RespondTime string `json:"respond_time"`
  15561. Signtype interface{} `json:"signtype"`
  15562. WarnMsg interface{} `json:"warn_msg"`
  15563. }
  15564. type ResultTwelve struct {
  15565. Cainfo string `json:"cainfo"`
  15566. ErrMsg string `json:"err_msg"`
  15567. InfRefmsgid string `json:"inf_refmsgid"`
  15568. Infcode int64 `json:"infcode"`
  15569. Output struct {
  15570. MdtrtId string `json:"mdtrt_id"`
  15571. ChrgBchno string `json:"chrg_bchno"`
  15572. PsnNo string `json:"psn_no"`
  15573. } `json:"output"`
  15574. RefmsgTime string `json:"refmsg_time"`
  15575. RespondTime string `json:"respond_time"`
  15576. Signtype interface{} `json:"signtype"`
  15577. WarnMsg interface{} `json:"warn_msg"`
  15578. }
  15579. type ResultThirteen struct {
  15580. ErrMsg string `json:"err_msg"`
  15581. InfRefmsgid string `json:"inf_refmsgid"`
  15582. Infcode int64 `json:"infcode"`
  15583. Output struct {
  15584. Result struct {
  15585. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15586. } `json:"result"`
  15587. } `json:"output"`
  15588. RefmsgTime string `json:"refmsg_time"`
  15589. RespondTime string `json:"respond_time"`
  15590. Signtype interface{} `json:"signtype"`
  15591. WarnInfo interface{} `json:"warn_info"`
  15592. }
  15593. type ResultThirteen10265 struct {
  15594. ErrMsg string `json:"err_msg"`
  15595. InfRefmsgid string `json:"inf_refmsgid"`
  15596. Infcode string `json:"infcode"`
  15597. Output struct {
  15598. Result struct {
  15599. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  15600. } `json:"result"`
  15601. } `json:"output"`
  15602. RefmsgTime string `json:"refmsg_time"`
  15603. RespondTime string `json:"respond_time"`
  15604. Signtype interface{} `json:"signtype"`
  15605. WarnInfo interface{} `json:"warn_info"`
  15606. }
  15607. type ResultFourteen struct {
  15608. ErrMsg string `json:"err_msg"`
  15609. InfRefmsgid string `json:"inf_refmsgid"`
  15610. Infcode int64 `json:"infcode"`
  15611. Output struct {
  15612. } `json:"output"`
  15613. RefmsgTime string `json:"refmsg_time"`
  15614. RespondTime string `json:"respond_time"`
  15615. Signtype interface{} `json:"signtype"`
  15616. WarnInfo interface{} `json:"warn_info"`
  15617. }
  15618. type ResultCFYLJG001 struct {
  15619. ErrMsg string `json:"err_msg"`
  15620. InfRefmsgid string `json:"inf_refmsgid"`
  15621. Infcode int64 `json:"infcode"`
  15622. Output struct {
  15623. RxTraceCode string `json:"rx_trace_code"`
  15624. HiRxno string `json:"hi_rxno"`
  15625. } `json:"output"`
  15626. RefmsgTime string `json:"refmsg_time"`
  15627. RespondTime string `json:"respond_time"`
  15628. Signtype interface{} `json:"signtype"`
  15629. WarnInfo interface{} `json:"warn_info"`
  15630. }
  15631. type ResultCFYLJG007 struct {
  15632. ErrMsg string `json:"err_msg"`
  15633. InfRefmsgid string `json:"inf_refmsgid"`
  15634. Infcode int64 `json:"infcode"`
  15635. Output struct {
  15636. HiRxno string `json:"hi_rxno"`
  15637. RxStasName string `json:"rx_stas_name"`
  15638. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  15639. Seltdelts []interface{} `json:"seltdelts"`
  15640. RxUsedStasName string `json:"rx_used_stas_name"`
  15641. RxStasCodg string `json:"rx_stas_codg"`
  15642. } `json:"output"`
  15643. RefmsgTime string `json:"refmsg_time"`
  15644. RespondTime string `json:"respond_time"`
  15645. Signtype interface{} `json:"signtype"`
  15646. WarnInfo interface{} `json:"warn_info"`
  15647. }
  15648. type ResultCFYLJG002 struct {
  15649. ErrMsg string `json:"err_msg"`
  15650. InfRefmsgid string `json:"inf_refmsgid"`
  15651. Infcode int64 `json:"infcode"`
  15652. Output struct {
  15653. RxFile string `json:"rx_file"`
  15654. SignDigest string `json:"sign_digest"`
  15655. SignCertSn string `json:"sign_cert_sn"`
  15656. SignCertDn string `json:"sign_cert_dn"`
  15657. } `json:"output"`
  15658. RefmsgTime string `json:"refmsg_time"`
  15659. RespondTime string `json:"respond_time"`
  15660. Signtype interface{} `json:"signtype"`
  15661. WarnInfo interface{} `json:"warn_info"`
  15662. }
  15663. type ResultCFYLJG003 struct {
  15664. ErrMsg string `json:"err_msg"`
  15665. InfRefmsgid string `json:"inf_refmsgid"`
  15666. Infcode int64 `json:"infcode"`
  15667. Output struct {
  15668. HiRxno string `json:"hi_rxno"`
  15669. RxStasCodg string `json:"rx_stas_codg"`
  15670. RxStasName string `json:"rx_stas_name"`
  15671. } `json:"output"`
  15672. RefmsgTime string `json:"refmsg_time"`
  15673. RespondTime string `json:"respond_time"`
  15674. Signtype interface{} `json:"signtype"`
  15675. WarnInfo interface{} `json:"warn_info"`
  15676. }
  15677. type ResultCFYLJG004 struct {
  15678. ErrMsg string `json:"err_msg"`
  15679. InfRefmsgid string `json:"inf_refmsgid"`
  15680. Infcode int64 `json:"infcode"`
  15681. Output struct {
  15682. HiRxno string `json:"hi_rxno"`
  15683. RxStasCodg string `json:"rx_stas_codg"`
  15684. RxStasName string `json:"rx_stas_name"`
  15685. } `json:"output"`
  15686. RefmsgTime string `json:"refmsg_time"`
  15687. RespondTime string `json:"respond_time"`
  15688. Signtype interface{} `json:"signtype"`
  15689. WarnInfo interface{} `json:"warn_info"`
  15690. }
  15691. type ResultCFYLJG008 struct {
  15692. ErrMsg string `json:"err_msg"`
  15693. InfRefmsgid string `json:"inf_refmsgid"`
  15694. Infcode int64 `json:"infcode"`
  15695. Output struct {
  15696. PoolareaNo string `json:"poolareaNo"`
  15697. AdmdvsName string `json:"admdvsName"`
  15698. Count string `json:"count"`
  15699. } `json:"output"`
  15700. RefmsgTime string `json:"refmsg_time"`
  15701. RespondTime string `json:"respond_time"`
  15702. Signtype interface{} `json:"signtype"`
  15703. WarnInfo interface{} `json:"warn_info"`
  15704. }
  15705. type ResultCFYLJG005 struct {
  15706. ErrMsg string `json:"err_msg"`
  15707. InfRefmsgid string `json:"inf_refmsgid"`
  15708. Infcode int64 `json:"infcode"`
  15709. Output struct {
  15710. HiRxNo string `json:"hi_rxno"`
  15711. FixMedinsCode string `json:"fixmedins_code"`
  15712. FixMedinsName string `json:"fixmedins_name"`
  15713. RxStasCodg string `json:"rx_stas_codg"`
  15714. RxStasName string `json:"rx_stas_name"`
  15715. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  15716. RxUserdStasName string `json:"rx_userd_stas_name"`
  15717. PrscTime string `json:"prsc_time"`
  15718. RxDrugCnt float64 `json:"rx_drug_cnt"`
  15719. RxUsedWayCodg string `json:"rx_used_way_codg"`
  15720. RxUsedWayName string `json:"rx_used_way_name"`
  15721. RxFrquCodg string `json:"rx_frqu_codg"`
  15722. RxFrquName string `json:"rx_frqu_name"`
  15723. RxDosunt string `json:"rx_dosunt"`
  15724. RxDoscnt float64 `json:"rx_doscnt"`
  15725. RxDrordDscr string `json:"rx_drord_dscr"`
  15726. ValiDays int64 `json:"vali_days"`
  15727. ValiEndTime string `json:"vali_end_time"`
  15728. ReptFlag string `json:"rept_flag"`
  15729. MaxReptCnt int64 `json:"max_rept_cnt"`
  15730. ReptdCnt int64 `json:"reptd_cnt"`
  15731. MinInrvDays int64 `json:"min_inrv_days"`
  15732. RxTypeCode string `json:"rx_type_code"`
  15733. RxTypeName string `json:"rx_type_name"`
  15734. LongRxFlag string `json:"long_rx_flag"`
  15735. RxDetlList []struct {
  15736. MedListCodg string `json:"med_list_codg"`
  15737. MedinsListCodg string `json:"medins_list_codg"`
  15738. HospPrepFlag string `json:"hosp_prep_flag"`
  15739. RxItemTypeCode string `json:"rx_item_type_code"`
  15740. RxItemTypeName string `json:"rx_item_type_name"`
  15741. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  15742. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  15743. TcmHerbFoote string `json:"tcmherb_foote"`
  15744. MednTypeCode string `json:"medn_type_code"`
  15745. MednTypeName string `json:"medn_type_name"`
  15746. MainMedcFlag string `json:"main_medc_flag"`
  15747. UrgtFlag string `json:"urgt_flag"`
  15748. BasMednFlag string `json:"bas_medn_flag"`
  15749. ImpDrugFlag string `json:"imp_drug_flag"`
  15750. ProdBarc string `json:"prod_barc"`
  15751. DrugProdname string `json:"drug_prodname"`
  15752. GennameCodg string `json:"genname_codg"`
  15753. DrugGenname string `json:"drug_genname"`
  15754. DrugDosform string `json:"drug_dosform"`
  15755. DrugSpec string `json:"drug_spec"`
  15756. PrdrName string `json:"prdr_name"`
  15757. MedcWayCodg string `json:"medc_way_codg"`
  15758. MedcWayDscr string `json:"medc_way_dscr"`
  15759. MedcBegntime string `json:"medc_begntime"`
  15760. MedcEndtime string `json:"medc_endtime"`
  15761. MedcDays float64 `json:"medc_days"`
  15762. DrugPric float64 `json:"drug_pric"`
  15763. DrugSumamt float64 `json:"drug_sumamt"`
  15764. DrugCnt float64 `json:"drug_cnt"`
  15765. DrugDosunt string `json:"drug_dosunt"`
  15766. SinDoscnt float64 `json:"sin_doscnt"`
  15767. SinDosunt string `json:"sin_dosunt"`
  15768. UsedFrquCodg string `json:"used_frqu_codg"`
  15769. UsedFrquName string `json:"used_frqu_name"`
  15770. DrugTotlcnt string `json:"drug_totlcnt"`
  15771. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  15772. DiseCodg string `json:"dise_codg"`
  15773. HospApprFlag string `json:"hosp_appr_flag"`
  15774. } `json:"rx_detl_list"`
  15775. RxOtpinfo struct {
  15776. MedType string `json:"med_type"`
  15777. IptOtpNo string `json:"ipt_otp_no"`
  15778. OtpIptFlag string `json:"otp_ipt_flag"`
  15779. PatnName string `json:"patn_name"`
  15780. PatnAge float64 `json:"patn_age"`
  15781. PatnHgt float64 `json:"patn_hgt"`
  15782. PatnWt float64 `json:"patn_wt"`
  15783. Gend string `json:"gend"`
  15784. GesoVal float64 `json:"geso_val"`
  15785. NwbFlag string `json:"nwb_flag"`
  15786. NwbAge string `json:"nwb_age"`
  15787. SuckPrdFlag string `json:"suck_prd_flag"`
  15788. AlgsHis string `json:"algs_his"`
  15789. Insutype string `json:"insutype"`
  15790. PrscDeptName string `json:"prsc_dept_name"`
  15791. PrscDrName string `json:"prsc_dr_name"`
  15792. PharName string `json:"phar_name"`
  15793. PharChkTime string `json:"phar_chk_time"`
  15794. MdtrtTime string `json:"mdtrt_time"`
  15795. DiseCodg string `json:"dise_codg"`
  15796. DiseName string `json:"dise_name"`
  15797. SpDiseFlag string `json:"sp_dise_flag"`
  15798. MaindiagCode string `json:"maindiag_code"`
  15799. MaindiagName string `json:"maindiag_name"`
  15800. DiseCondDscr string `json:"dise_cond_dscr"`
  15801. FstdiagFlag string `json:"fstdiag_flag"`
  15802. } `json:"rx_otpinfo"`
  15803. RxDiseList []struct {
  15804. DiagType string `json:"diag_type"`
  15805. MaindiagFlag string `json:"maindiag_flag"`
  15806. DiagSrtNo string `json:"diag_srt_no"`
  15807. DiagCode string `json:"diag_code"`
  15808. DiagName string `json:"diag_name"`
  15809. DiagDept string `json:"diag_dept"`
  15810. DiagDrNo string `json:"diag_dr_no"`
  15811. DiagDrName string `json:"diag_dr_name"`
  15812. DiagTime string `json:"diag_time"`
  15813. TcmDiseCode string `json:"tcm_dise_code"`
  15814. TcmDiseName string `json:"tcm_dise_name"`
  15815. TcmSympCode string `json:"tcmsymp_code"`
  15816. TcmSymp string `json:"tcmsymp"`
  15817. } `json:"rx_dise_list"`
  15818. } `json:"output"`
  15819. RefmsgTime string `json:"refmsg_time"`
  15820. RespondTime string `json:"respond_time"`
  15821. Signtype interface{} `json:"signtype"`
  15822. WarnInfo interface{} `json:"warn_info"`
  15823. }
  15824. type ResultCFYLJG006 struct {
  15825. ErrMsg string `json:"err_msg"`
  15826. InfRefmsgid string `json:"inf_refmsgid"`
  15827. Infcode int64 `json:"infcode"`
  15828. Output struct {
  15829. HiRxNo string `json:"hi_rxno"`
  15830. PharCode string `json:"phar_code"`
  15831. PharName string `json:"phar_name"`
  15832. RxChkOpnn string `json:"rx_chk_opnn"`
  15833. RxChkTime string `json:"rx_chk_time"`
  15834. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  15835. RxChkStasName string `json:"rx_chk_stas_name"`
  15836. RxStasCodg string `json:"rx_stas_codg"`
  15837. RxStasName string `json:"rx_stas_name"`
  15838. } `json:"output"`
  15839. RefmsgTime string `json:"refmsg_time"`
  15840. RespondTime string `json:"respond_time"`
  15841. Signtype interface{} `json:"signtype"`
  15842. WarnInfo interface{} `json:"warn_info"`
  15843. }
  15844. type ResultFourteen10265 struct {
  15845. ErrMsg string `json:"err_msg"`
  15846. InfRefmsgid string `json:"inf_refmsgid"`
  15847. Infcode string `json:"infcode"`
  15848. Output struct {
  15849. } `json:"output"`
  15850. RefmsgTime string `json:"refmsg_time"`
  15851. RespondTime string `json:"respond_time"`
  15852. Signtype interface{} `json:"signtype"`
  15853. WarnInfo interface{} `json:"warn_info"`
  15854. }
  15855. type ResultSixteen struct {
  15856. Cainfo string `json:"cainfo"`
  15857. ErrMsg string `json:"err_msg"`
  15858. InfRefmsgid string `json:"inf_refmsgid"`
  15859. Infcode int64 `json:"infcode"`
  15860. Output struct {
  15861. Setlinfo struct {
  15862. MdtrtID string `json:"mdtrt_id"`
  15863. SetlID string `json:"setl_id"`
  15864. ClrOptins string `json:"clr_optins"`
  15865. SetlTime string `json:"setl_time"`
  15866. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15867. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15868. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15869. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15870. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15871. ActPayDedc float64 `json:"act_pay_dedc"`
  15872. HifpPay float64 `json:"hifp_pay"`
  15873. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15874. Lfpay float64 `json:"selfpay"`
  15875. CvlservPay float64 `json:"cvlserv_pay"`
  15876. HifesPay float64 `json:"hifes_pay"`
  15877. HifmiPay float64 `json:"hifmi_pay"`
  15878. HifobPay float64 `json:"hifob_pay"`
  15879. MafPay float64 `json:"maf_pay"`
  15880. OthPay float64 `json:"oth_pay"`
  15881. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15882. PsnPartAmt float64 `json:"psn_part_amt"`
  15883. AcctPay float64 `json:"acct_pay"`
  15884. Balc float64 `json:"balc"`
  15885. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15886. HospPartAmt float64 `json:"hosp_part_amt"`
  15887. MedinsSetlID string `json:"medins_setl_id"`
  15888. PdnCashPay string `json:"pdn_cash_pay"`
  15889. } `json:"setlinfo"`
  15890. } `json:"output"`
  15891. RefmsgTime string `json:"refmsg_time"`
  15892. RespondTime string `json:"respond_time"`
  15893. Signtype interface{} `json:"signtype"`
  15894. WarnMsg interface{} `json:"warn_msg"`
  15895. }
  15896. type ResultSixteen10265 struct {
  15897. Cainfo string `json:"cainfo"`
  15898. ErrMsg string `json:"err_msg"`
  15899. InfRefmsgid string `json:"inf_refmsgid"`
  15900. Infcode string `json:"infcode"`
  15901. Output struct {
  15902. Setlinfo struct {
  15903. MdtrtID string `json:"mdtrt_id"`
  15904. SetlID string `json:"setl_id"`
  15905. ClrOptins string `json:"clr_optins"`
  15906. SetlTime string `json:"setl_time"`
  15907. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15908. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15909. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15910. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15911. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15912. ActPayDedc float64 `json:"act_pay_dedc"`
  15913. HifpPay float64 `json:"hifp_pay"`
  15914. PoolPropSe float64 `json:"pool_prop_selfpay"`
  15915. Lfpay float64 `json:"selfpay"`
  15916. CvlservPay float64 `json:"cvlserv_pay"`
  15917. HifesPay float64 `json:"hifes_pay"`
  15918. HifmiPay float64 `json:"hifmi_pay"`
  15919. HifobPay float64 `json:"hifob_pay"`
  15920. MafPay float64 `json:"maf_pay"`
  15921. OthPay float64 `json:"oth_pay"`
  15922. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15923. PsnPartAmt float64 `json:"psn_part_amt"`
  15924. AcctPay float64 `json:"acct_pay"`
  15925. Balc float64 `json:"balc"`
  15926. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15927. HospPartAmt float64 `json:"hosp_part_amt"`
  15928. MedinsSetlID string `json:"medins_setl_id"`
  15929. PdnCashPay string `json:"pdn_cash_pay"`
  15930. } `json:"setlinfo"`
  15931. } `json:"output"`
  15932. RefmsgTime string `json:"refmsg_time"`
  15933. RespondTime string `json:"respond_time"`
  15934. Signtype interface{} `json:"signtype"`
  15935. WarnMsg interface{} `json:"warn_msg"`
  15936. }
  15937. type ResultSixteen10265Two struct {
  15938. Cainfo string `json:"cainfo"`
  15939. ErrMsg string `json:"err_msg"`
  15940. InfRefmsgid string `json:"inf_refmsgid"`
  15941. Infcode string `json:"infcode"`
  15942. Output struct {
  15943. Setlinfo interface{} `json:"setlinfo"`
  15944. } `json:"output"`
  15945. RefmsgTime string `json:"refmsg_time"`
  15946. RespondTime string `json:"respond_time"`
  15947. Signtype interface{} `json:"signtype"`
  15948. WarnMsg interface{} `json:"warn_msg"`
  15949. }
  15950. type ResultgzSixteen10265Two struct {
  15951. Cainfo string `json:"cainfo"`
  15952. ErrMsg string `json:"err_msg"`
  15953. InfRefmsgid string `json:"inf_refmsgid"`
  15954. Infcode int64 `json:"infcode"`
  15955. Output struct {
  15956. Setlinfo interface{} `json:"setlinfo"`
  15957. } `json:"output"`
  15958. RefmsgTime string `json:"refmsg_time"`
  15959. RespondTime string `json:"respond_time"`
  15960. Signtype interface{} `json:"signtype"`
  15961. WarnMsg interface{} `json:"warn_msg"`
  15962. }
  15963. type ResultSeventeen struct {
  15964. ErrMsg string `json:"err_msg"`
  15965. InfRefmsgid string `json:"inf_refmsgid"`
  15966. Infcode int64 `json:"infcode"`
  15967. Output struct {
  15968. SetlListId string `json:"setl_list_id"`
  15969. } `json:"output"`
  15970. RefmsgTime string `json:"refmsg_time"`
  15971. RespondTime string `json:"respond_time"`
  15972. Signtype string `json:"signtype"`
  15973. WarnInfo string `json:"warn_info"`
  15974. }
  15975. type ResultSeventeenOther struct {
  15976. ErrMsg string `json:"err_msg"`
  15977. InfRefmsgid string `json:"inf_refmsgid"`
  15978. Infcode string `json:"infcode"`
  15979. Output struct {
  15980. SetlListId string `json:"setl_list_id"`
  15981. } `json:"output"`
  15982. RefmsgTime string `json:"refmsg_time"`
  15983. RespondTime string `json:"respond_time"`
  15984. Signtype string `json:"signtype"`
  15985. WarnInfo string `json:"warn_info"`
  15986. }
  15987. type Result90991 struct {
  15988. ErrMsg string `json:"err_msg"`
  15989. InfRefmsgid string `json:"inf_refmsgid"`
  15990. Infcode int64 `json:"infcode"`
  15991. Output struct {
  15992. Result struct {
  15993. PsnNo string `json:"psn_no"`
  15994. CardStat string `json:"card_stat"`
  15995. Certno string `json:"certno"`
  15996. PsnName string `json:"psn_name"`
  15997. CheckStat string `json:"check_stat"`
  15998. SscnoCheckStat string `json:"sscno_check_stat"`
  15999. } `json:"result"`
  16000. } `json:"output"`
  16001. RefmsgTime string `json:"refmsg_time"`
  16002. RespondTime string `json:"respond_time"`
  16003. Signtype interface{} `json:"signtype"`
  16004. WarnInfo interface{} `json:"warn_info"`
  16005. }
  16006. type Result90100 struct {
  16007. ErrMsg string `json:"err_msg"`
  16008. InfRefmsgid string `json:"inf_refmsgid"`
  16009. Infcode int64 `json:"infcode"`
  16010. Output struct {
  16011. PoolareaNo string `json:"poolarea_no"`
  16012. PoolareaNoName string `json:"poolarea_no_name"`
  16013. Insutype string `json:"insutype"`
  16014. InsutypeName string `json:"insutype_name"`
  16015. ClctType string `json:"clct_type"`
  16016. ClctTypeName string `json:"clct_type_name"`
  16017. ClctFlag string `json:"clct_flag"`
  16018. ClctFlagName string `json:"clct_flag_name"`
  16019. AccrymBegn string `json:"accrym_begn"`
  16020. AccrymEnd string `json:"accrym_end"`
  16021. ClctTime string `json:"clct_time"`
  16022. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16023. } `json:"output"`
  16024. RefmsgTime string `json:"refmsg_time"`
  16025. RespondTime string `json:"respond_time"`
  16026. Signtype interface{} `json:"signtype"`
  16027. WarnInfo interface{} `json:"warn_info"`
  16028. }
  16029. type Custom struct {
  16030. DetItemFeeSumamt string
  16031. Cut string
  16032. FeedetlSn string
  16033. Price string
  16034. MedListCodg string
  16035. Type int64
  16036. AdviceId int64
  16037. ProjectId int64
  16038. ItemId int64
  16039. }
  16040. type Result5301 struct {
  16041. ErrMsg string `json:"err_msg"`
  16042. InfRefmsgid string `json:"inf_refmsgid"`
  16043. Infcode int64 `json:"infcode"`
  16044. Output struct {
  16045. Result []struct {
  16046. OpspDiseCode string `json:"opsp_dise_code"`
  16047. OpspDiseName string `json:"opsp_dise_name"`
  16048. Begndate string `json:"begndate"`
  16049. Enddate string `json:"enddate"`
  16050. } `json:"feedetail"`
  16051. } `json:"output"`
  16052. RefmsgTime string `json:"refmsg_time"`
  16053. RespondTime string `json:"respond_time"`
  16054. Signtype interface{} `json:"signtype"`
  16055. WarnInfo interface{} `json:"warn_info"`
  16056. }
  16057. type Result5301For10265 struct {
  16058. ErrMsg string `json:"err_msg"`
  16059. InfRefmsgid string `json:"inf_refmsgid"`
  16060. Infcode string `json:"infcode"`
  16061. Output struct {
  16062. Result []struct {
  16063. OpspDiseCode string `json:"opsp_dise_code"`
  16064. OpspDiseName string `json:"opsp_dise_name"`
  16065. Begndate string `json:"begndate"`
  16066. Enddate string `json:"enddate"`
  16067. } `json:"feedetail"`
  16068. } `json:"output"`
  16069. RefmsgTime string `json:"refmsg_time"`
  16070. RespondTime string `json:"respond_time"`
  16071. Signtype interface{} `json:"signtype"`
  16072. WarnInfo interface{} `json:"warn_info"`
  16073. }
  16074. //获取个人信息----挂号-----上传就诊信息
  16075. func (c *HisApiController) GetRegisterInfo() {
  16076. id, _ := c.GetInt64("id")
  16077. record_time := c.GetString("record_time")
  16078. settlementValue, _ := c.GetInt64("settlement_value")
  16079. medical_insurance_card := c.GetString("medical_insurance_card")
  16080. name := c.GetString("name")
  16081. id_card_type, _ := c.GetInt64("id_card_type")
  16082. certificates, _ := c.GetInt64("certificates")
  16083. medical_care, _ := c.GetInt64("medical_care")
  16084. birthday := c.GetString("birthday")
  16085. id_card := c.GetString("id_card")
  16086. register_type, _ := c.GetInt64("register")
  16087. doctor, _ := c.GetInt64("doctor")
  16088. department, _ := c.GetInt64("department")
  16089. gender, _ := c.GetInt64("sex")
  16090. registration_fee, _ := c.GetFloat("registration_fee")
  16091. medical_expenses, _ := c.GetFloat("medical_expenses")
  16092. social_type, _ := c.GetInt64("social_type")
  16093. admin_user_id, _ := c.GetInt64("admin_user_id")
  16094. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16095. mdtrt_type := c.GetString("mdtrt_type")
  16096. if id_card_type == 5 {
  16097. id_card_type = 4
  16098. }
  16099. timeLayout := "2006-01-02"
  16100. loc, _ := time.LoadLocation("Local")
  16101. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16102. birthUnix := birthdays.Unix()
  16103. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16104. if err != nil {
  16105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16106. return
  16107. }
  16108. recordDateTime := theTime.Unix()
  16109. adminInfo := c.GetAdminUserInfo()
  16110. var patient service.Patients
  16111. if id == 0 {
  16112. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16113. } else {
  16114. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16115. }
  16116. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16117. if patientPrescription.ID == 0 {
  16118. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16119. }
  16120. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16121. if patient.ID == 0 {
  16122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16123. return
  16124. }
  16125. if len(patient.IdCardNo) == 0 {
  16126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16127. return
  16128. }
  16129. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16130. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16131. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16132. //就诊结算未完成,不能进行二次挂号
  16133. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16134. //if len(his) >= 1 {
  16135. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16136. // if len(his) >= 1 && order.ID == 0 {
  16137. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16138. // return
  16139. // }
  16140. //}
  16141. //var register_log string
  16142. if config.IsOpen == 1 {
  16143. var res ResultTwo
  16144. var res10265 ResultTwo10265
  16145. var PsnNo string
  16146. var PsnCertType string
  16147. var Certno string
  16148. var PsnName string
  16149. var Gend string
  16150. var Naty string
  16151. var Brdy string
  16152. var Age float64
  16153. var infoStr string
  16154. var idetinfoStr string
  16155. var infocode int64
  16156. var verify_number string
  16157. fmt.Println(verify_number)
  16158. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" {
  16159. psn_info, _ := service.GetPsnByPatientId(id)
  16160. PsnNo = psn_info.PsnNo
  16161. PsnCertType = psn_info.PsnCertType
  16162. Certno = psn_info.Certno
  16163. PsnName = psn_info.PsnName
  16164. Gend = psn_info.Gend
  16165. Naty = psn_info.Naty
  16166. Brdy = psn_info.Brdy
  16167. Age = psn_info.Age
  16168. infoStr = psn_info.Insuinfo
  16169. idetinfoStr = psn_info.Idetinfo
  16170. infocode = 0
  16171. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16172. psn_info, _ := service.GetPsnByPatientId(id)
  16173. PsnNo = psn_info.PsnNo
  16174. PsnCertType = psn_info.PsnCertType
  16175. Certno = psn_info.Certno
  16176. PsnName = psn_info.PsnName
  16177. Gend = psn_info.Gend
  16178. Naty = psn_info.Naty
  16179. Brdy = psn_info.Brdy
  16180. Age = psn_info.Age
  16181. infoStr = psn_info.Insuinfo
  16182. idetinfoStr = psn_info.Idetinfo
  16183. infocode = 0
  16184. verify_number = psn_info.VerifyNumber
  16185. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16186. if id_card_type == 2 {
  16187. //请求内网数据
  16188. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16189. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16190. "&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
  16191. resp, requestErr := http.Get(api)
  16192. if requestErr != nil {
  16193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16194. return
  16195. }
  16196. body, ioErr := ioutil.ReadAll(resp.Body)
  16197. if ioErr != nil {
  16198. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16200. return
  16201. }
  16202. var respJSON map[string]interface{}
  16203. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16204. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16206. return
  16207. }
  16208. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16209. result_byte, _ := json.Marshal(respJSON)
  16210. result := string(result_byte)
  16211. var dat map[string]interface{}
  16212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16213. fmt.Println(dat)
  16214. } else {
  16215. fmt.Println(err)
  16216. }
  16217. userJSONBytes, _ := json.Marshal(dat)
  16218. var res ResultTwo
  16219. var resTwo10265 ResultTwo10265
  16220. if miConfig.Code == "H15049901371" {
  16221. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16222. utils.ErrorLog("解析失败:%v", err)
  16223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16224. return
  16225. }
  16226. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16227. res.Infcode = Infcode
  16228. res.ErrMsg = resTwo10265.ErrMsg
  16229. res.Output = resTwo10265.Output
  16230. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16231. res.RespondTime = resTwo10265.RespondTime
  16232. res.WarnInfo = resTwo10265.WarnInfo
  16233. } else {
  16234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16235. utils.ErrorLog("解析失败:%v", err)
  16236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16237. return
  16238. }
  16239. }
  16240. //var insutypes []string
  16241. //var insutype string
  16242. //var is390 int = 0
  16243. //var is310 int = 0
  16244. //for _, item := range res.Output.Iinfo {
  16245. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16246. // insutypes = append(insutypes, item.Insutype)
  16247. // }
  16248. //}
  16249. //if len(insutypes) == 1 {
  16250. // insutype = insutypes[0]
  16251. //} else {
  16252. // for _, i := range insutypes {
  16253. // if i == "390" {
  16254. // is390 = 1
  16255. // }
  16256. //
  16257. // if i == "310" {
  16258. // is310 = 1
  16259. // }
  16260. // }
  16261. //}
  16262. //if is390 == 1 {
  16263. // insutype = "390"
  16264. //}
  16265. //if is310 == 1 {
  16266. // insutype = "310"
  16267. //}
  16268. //if len(insutypes) == 0 {
  16269. // insutype = "310"
  16270. //}
  16271. PsnNo = res.Output.Baseinfo.PsnNo
  16272. PsnCertType = res.Output.Baseinfo.PsnCertType
  16273. Certno = res.Output.Baseinfo.Certno
  16274. PsnName = res.Output.Baseinfo.PsnName
  16275. Gend = res.Output.Baseinfo.Gend
  16276. Naty = res.Output.Baseinfo.Naty
  16277. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16278. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16279. infoStr = string(Iinfos)
  16280. idetinfoStr = string(Idetinfos)
  16281. infocode = res.Infcode
  16282. //infocode = 0
  16283. //verify_number = psn_info.VerifyNumber
  16284. } else {
  16285. psn_info, _ := service.GetPsnByPatientId(id)
  16286. PsnNo = psn_info.PsnNo
  16287. PsnCertType = psn_info.PsnCertType
  16288. Certno = psn_info.Certno
  16289. PsnName = psn_info.PsnName
  16290. Gend = psn_info.Gend
  16291. Naty = psn_info.Naty
  16292. Brdy = psn_info.Brdy
  16293. Age = psn_info.Age
  16294. infoStr = psn_info.Insuinfo
  16295. idetinfoStr = psn_info.Idetinfo
  16296. infocode = 0
  16297. verify_number = psn_info.VerifyNumber
  16298. }
  16299. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16300. if id_card_type == 1 {
  16301. psn_info, _ := service.GetPsnByPatientId(id)
  16302. PsnNo = psn_info.PsnNo
  16303. PsnCertType = psn_info.PsnCertType
  16304. Certno = psn_info.Certno
  16305. PsnName = psn_info.PsnName
  16306. Gend = psn_info.Gend
  16307. Naty = psn_info.Naty
  16308. Brdy = psn_info.Brdy
  16309. Age = psn_info.Age
  16310. infoStr = psn_info.Insuinfo
  16311. idetinfoStr = psn_info.Idetinfo
  16312. infocode = 0
  16313. verify_number = psn_info.VerifyNumber
  16314. } else if id_card_type == 2 {
  16315. 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)
  16316. fmt.Println(errMsgLog)
  16317. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16318. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16319. utils.ErrorLog("解析失败:%v", err)
  16320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16321. return
  16322. }
  16323. PsnNo = res.Output.Baseinfo.PsnNo
  16324. PsnCertType = res.Output.Baseinfo.PsnCertType
  16325. Certno = res.Output.Baseinfo.Certno
  16326. PsnName = res.Output.Baseinfo.PsnName
  16327. Gend = res.Output.Baseinfo.Gend
  16328. Naty = res.Output.Baseinfo.Naty
  16329. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16330. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16331. infoStr = string(Iinfos)
  16332. idetinfoStr = string(Idetinfos)
  16333. infocode = res.Infcode
  16334. }
  16335. } else if miConfig.MdtrtareaAdmvs == "360302" {
  16336. if id_card_type == 1 {
  16337. psn_info, _ := service.GetPsnByPatientId(id)
  16338. PsnNo = psn_info.PsnNo
  16339. PsnCertType = psn_info.PsnCertType
  16340. Certno = psn_info.Certno
  16341. PsnName = psn_info.PsnName
  16342. Gend = psn_info.Gend
  16343. Naty = psn_info.Naty
  16344. Brdy = psn_info.Brdy
  16345. Age = psn_info.Age
  16346. infoStr = psn_info.Insuinfo
  16347. idetinfoStr = psn_info.Idetinfo
  16348. infocode = 0
  16349. verify_number = psn_info.VerifyNumber
  16350. } else if id_card_type == 2 {
  16351. 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, "")
  16352. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16353. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16354. utils.ErrorLog("解析失败:%v", err)
  16355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16356. return
  16357. }
  16358. PsnNo = res.Output.Baseinfo.PsnNo
  16359. PsnCertType = res.Output.Baseinfo.PsnCertType
  16360. Certno = res.Output.Baseinfo.Certno
  16361. PsnName = res.Output.Baseinfo.PsnName
  16362. Gend = res.Output.Baseinfo.Gend
  16363. Naty = res.Output.Baseinfo.Naty
  16364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16366. infoStr = string(Iinfos)
  16367. idetinfoStr = string(Idetinfos)
  16368. infocode = res.Infcode
  16369. } else {
  16370. psn_info, _ := service.GetPsnByPatientId(id)
  16371. PsnNo = psn_info.PsnNo
  16372. PsnCertType = psn_info.PsnCertType
  16373. Certno = psn_info.Certno
  16374. PsnName = psn_info.PsnName
  16375. Gend = psn_info.Gend
  16376. Naty = psn_info.Naty
  16377. Brdy = psn_info.Brdy
  16378. Age = psn_info.Age
  16379. infoStr = psn_info.Insuinfo
  16380. idetinfoStr = psn_info.Idetinfo
  16381. infocode = 0
  16382. verify_number = psn_info.VerifyNumber
  16383. }
  16384. } else if miConfig.MdtrtareaAdmvs == "341203" {
  16385. psn_info, _ := service.GetPsnByPatientId(id)
  16386. PsnNo = psn_info.PsnNo
  16387. PsnCertType = psn_info.PsnCertType
  16388. Certno = psn_info.Certno
  16389. PsnName = psn_info.PsnName
  16390. Gend = psn_info.Gend
  16391. Naty = psn_info.Naty
  16392. Brdy = psn_info.Brdy
  16393. Age = psn_info.Age
  16394. infoStr = psn_info.Insuinfo
  16395. idetinfoStr = psn_info.Idetinfo
  16396. infocode = 0
  16397. verify_number = psn_info.VerifyNumber
  16398. } else if miConfig.MdtrtareaAdmvs == "430800" {
  16399. if id_card_type == 1 {
  16400. psn_info, _ := service.GetPsnByPatientId(id)
  16401. PsnNo = psn_info.PsnNo
  16402. PsnCertType = psn_info.PsnCertType
  16403. Certno = psn_info.Certno
  16404. PsnName = psn_info.PsnName
  16405. Gend = psn_info.Gend
  16406. Naty = psn_info.Naty
  16407. Brdy = psn_info.Brdy
  16408. Age = psn_info.Age
  16409. infoStr = psn_info.Insuinfo
  16410. idetinfoStr = psn_info.Idetinfo
  16411. infocode = 0
  16412. verify_number = psn_info.VerifyNumber
  16413. } else if id_card_type == 2 {
  16414. 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)
  16415. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16417. utils.ErrorLog("解析失败:%v", err)
  16418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16419. return
  16420. }
  16421. PsnNo = res.Output.Baseinfo.PsnNo
  16422. PsnCertType = res.Output.Baseinfo.PsnCertType
  16423. Certno = res.Output.Baseinfo.Certno
  16424. PsnName = res.Output.Baseinfo.PsnName
  16425. Gend = res.Output.Baseinfo.Gend
  16426. Naty = res.Output.Baseinfo.Naty
  16427. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16428. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16429. infoStr = string(Iinfos)
  16430. idetinfoStr = string(Idetinfos)
  16431. infocode = res.Infcode
  16432. } else if id_card_type == 4 {
  16433. psn_info, _ := service.GetPsnByPatientId(id)
  16434. PsnNo = psn_info.PsnNo
  16435. PsnCertType = psn_info.PsnCertType
  16436. Certno = psn_info.Certno
  16437. PsnName = psn_info.PsnName
  16438. Gend = psn_info.Gend
  16439. Naty = psn_info.Naty
  16440. Brdy = psn_info.Brdy
  16441. Age = psn_info.Age
  16442. infoStr = psn_info.Insuinfo
  16443. idetinfoStr = psn_info.Idetinfo
  16444. infocode = 0
  16445. verify_number = psn_info.VerifyNumber
  16446. }
  16447. } else if miConfig.MdtrtareaAdmvs == "131023" {
  16448. var result string
  16449. var requestLog string
  16450. 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), "")
  16451. if id_card_type == 4 {
  16452. psn_info, _ := service.GetPsnByPatientId(id)
  16453. PsnNo = psn_info.PsnNo
  16454. PsnCertType = psn_info.PsnCertType
  16455. Certno = psn_info.Certno
  16456. PsnName = psn_info.PsnName
  16457. Gend = psn_info.Gend
  16458. Naty = psn_info.Naty
  16459. Brdy = psn_info.Brdy
  16460. Age = psn_info.Age
  16461. infoStr = psn_info.Insuinfo
  16462. idetinfoStr = psn_info.Idetinfo
  16463. infocode = 0
  16464. verify_number = psn_info.VerifyNumber
  16465. } else {
  16466. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16467. if miConfig.Code == "H15049901371" {
  16468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16469. utils.ErrorLog("解析失败:%v", err)
  16470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16471. return
  16472. }
  16473. res.ErrMsg = res10265.ErrMsg
  16474. res.Output = res10265.Output
  16475. res.InfRefmsgid = res10265.InfRefmsgid
  16476. } else {
  16477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16478. utils.ErrorLog("解析失败:%v", err)
  16479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16480. return
  16481. }
  16482. }
  16483. PsnNo = res.Output.Baseinfo.PsnNo
  16484. PsnCertType = res.Output.Baseinfo.PsnCertType
  16485. Certno = res.Output.Baseinfo.Certno
  16486. PsnName = res.Output.Baseinfo.PsnName
  16487. Gend = res.Output.Baseinfo.Gend
  16488. Naty = res.Output.Baseinfo.Naty
  16489. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16490. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16491. infoStr = string(Iinfos)
  16492. idetinfoStr = string(Idetinfos)
  16493. if miConfig.Code == "H15049901371" {
  16494. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16495. } else {
  16496. infocode = res.Infcode
  16497. }
  16498. }
  16499. } else if miConfig.MdtrtareaAdmvs == "441799" {
  16500. psn_info, _ := service.GetPsnByPatientId(id)
  16501. PsnNo = psn_info.PsnNo
  16502. PsnCertType = psn_info.PsnCertType
  16503. Certno = psn_info.Certno
  16504. PsnName = psn_info.PsnName
  16505. Gend = psn_info.Gend
  16506. Naty = psn_info.Naty
  16507. Brdy = psn_info.Brdy
  16508. Age = psn_info.Age
  16509. infoStr = psn_info.Insuinfo
  16510. idetinfoStr = psn_info.Idetinfo
  16511. infocode = 0
  16512. verify_number = psn_info.VerifyNumber
  16513. } else if miConfig.MdtrtareaAdmvs == "450721" {
  16514. psn_info, _ := service.GetPsnByPatientId(id)
  16515. PsnNo = psn_info.PsnNo
  16516. PsnCertType = psn_info.PsnCertType
  16517. Certno = psn_info.Certno
  16518. PsnName = psn_info.PsnName
  16519. Gend = psn_info.Gend
  16520. Naty = psn_info.Naty
  16521. Brdy = psn_info.Brdy
  16522. Age = psn_info.Age
  16523. infoStr = psn_info.Insuinfo
  16524. idetinfoStr = psn_info.Idetinfo
  16525. infocode = 0
  16526. verify_number = psn_info.VerifyNumber
  16527. } else {
  16528. var result string
  16529. var requestLog string
  16530. //if miConfig.UserOrgId == 10138 {
  16531. if id_card_type != 4 || id_card_type != 1 {
  16532. var insa string
  16533. if len(patient.InsuplcAdmdvs) > 0 {
  16534. insa = patient.InsuplcAdmdvs
  16535. } else {
  16536. insa = miConfig.InsuplcAdmdvs
  16537. }
  16538. //psn_info, _ := service.GetPsnByPatientId(id)
  16539. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  16540. 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)
  16541. }
  16542. //}
  16543. //else {
  16544. // var insa string
  16545. // if len(patient.InsuplcAdmdvs) > 0 {
  16546. // insa = patient.InsuplcAdmdvs
  16547. // } else {
  16548. // insa = miConfig.InsuplcAdmdvs
  16549. // }
  16550. // 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)
  16551. //}
  16552. if id_card_type == 4 || id_card_type == 1 {
  16553. psn_info, _ := service.GetPsnByPatientId(id)
  16554. PsnNo = psn_info.PsnNo
  16555. PsnCertType = psn_info.PsnCertType
  16556. Certno = psn_info.Certno
  16557. PsnName = psn_info.PsnName
  16558. Gend = psn_info.Gend
  16559. Naty = psn_info.Naty
  16560. Brdy = psn_info.Brdy
  16561. Age = psn_info.Age
  16562. infoStr = psn_info.Insuinfo
  16563. idetinfoStr = psn_info.Idetinfo
  16564. infocode = 0
  16565. verify_number = psn_info.VerifyNumber
  16566. } else {
  16567. saveLog(result, requestLog, "1101", "人员基本信息获取")
  16568. if miConfig.Code == "H15049901371" {
  16569. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16570. utils.ErrorLog("解析失败:%v", err)
  16571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16572. return
  16573. }
  16574. res.ErrMsg = res10265.ErrMsg
  16575. res.Output = res10265.Output
  16576. res.InfRefmsgid = res10265.InfRefmsgid
  16577. } else {
  16578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  16579. utils.ErrorLog("解析失败:%v", err)
  16580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16581. return
  16582. }
  16583. }
  16584. PsnNo = res.Output.Baseinfo.PsnNo
  16585. PsnCertType = res.Output.Baseinfo.PsnCertType
  16586. Certno = res.Output.Baseinfo.Certno
  16587. PsnName = res.Output.Baseinfo.PsnName
  16588. Gend = res.Output.Baseinfo.Gend
  16589. Naty = res.Output.Baseinfo.Naty
  16590. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16591. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16592. infoStr = string(Iinfos)
  16593. idetinfoStr = string(Idetinfos)
  16594. if miConfig.Code == "H15049901371" {
  16595. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  16596. } else {
  16597. infocode = res.Infcode
  16598. }
  16599. }
  16600. }
  16601. if infocode == 0 {
  16602. his := models.VMHisPatient{
  16603. Name: name,
  16604. Gender: gender,
  16605. Birthday: birthUnix,
  16606. MedicalTreatmentType: medical_care,
  16607. IdType: certificates,
  16608. IdCardNo: id_card,
  16609. BalanceAccountsType: settlementValue,
  16610. SocialType: social_type,
  16611. MedicalInsuranceNumber: medical_insurance_card,
  16612. RegisterType: register_type,
  16613. RegisterCost: registration_fee,
  16614. TreatmentCost: medical_expenses,
  16615. Status: 1,
  16616. Ctime: time.Now().Unix(),
  16617. Mtime: time.Now().Unix(),
  16618. PsnNo: PsnNo,
  16619. PsnCertType: PsnCertType,
  16620. Certno: Certno,
  16621. PsnName: PsnName,
  16622. Gend: Gend,
  16623. Naty: Naty,
  16624. Brdy: Brdy,
  16625. Age: Age,
  16626. Iinfo: infoStr,
  16627. Idetinfo: idetinfoStr,
  16628. PatientId: patient.ID,
  16629. RecordDate: theTime.Unix(),
  16630. UserOrgId: adminInfo.CurrentOrgId,
  16631. AdminUserId: admin_user_id,
  16632. IsReturn: 1,
  16633. IdCardType: id_card_type,
  16634. Doctor: doctor,
  16635. Departments: department,
  16636. MdtrtGrpType: mdtrt_type,
  16637. }
  16638. timestamp := time.Now().Unix()
  16639. tempTime := time.Unix(timestamp, 0)
  16640. timeFormat := tempTime.Format("20060102150405")
  16641. chrgBchno := rand.Intn(100000) + 10000
  16642. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  16643. his.Number = ipt_otp_no
  16644. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  16645. department, _ := service.GetDepartMentDetail(department)
  16646. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  16647. IdCardNo := ""
  16648. if id_card_type == 1 {
  16649. // IdCardNo = medical_insurance_card
  16650. IdCardNo = patient.IdCardNo
  16651. } else {
  16652. IdCardNo = patient.IdCardNo
  16653. }
  16654. var rf []*ResultFive
  16655. json.Unmarshal([]byte(his.Iinfo), &rf)
  16656. var insutypes []*ResultFive
  16657. var insutype string
  16658. var insuplc_admdvs_temp string
  16659. var is390 int = 0
  16660. var is310 int = 0
  16661. for _, item := range rf {
  16662. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16663. insutypes = append(insutypes, item)
  16664. }
  16665. }
  16666. if len(insutypes) == 1 {
  16667. insutype = insutypes[0].Insutype
  16668. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  16669. if insutype == "390" {
  16670. is390 = 1
  16671. }
  16672. if insutype == "310" {
  16673. is310 = 1
  16674. }
  16675. } else {
  16676. for _, i := range insutypes {
  16677. if i.Insutype == "390" {
  16678. is390 = 1
  16679. }
  16680. if i.Insutype == "310" {
  16681. is310 = 1
  16682. }
  16683. }
  16684. }
  16685. if is390 == 1 {
  16686. insutype = "390"
  16687. }
  16688. if is310 == 1 {
  16689. insutype = "310"
  16690. }
  16691. fmt.Println(social_type)
  16692. if social_type > 0 {
  16693. insutype = strconv.FormatInt(social_type, 10)
  16694. }
  16695. var infocode int64
  16696. var resThree ResultThree
  16697. var resThree10265 ResultThree10265
  16698. if len(insuplc_admdvs) == 0 {
  16699. psn_info, _ := service.GetPsnByPatientId(id)
  16700. //if len(psn_info.InsuplcAdmdvs) > 0 {
  16701. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16702. //}
  16703. } else {
  16704. insuplc_admdvs_temp = insuplc_admdvs
  16705. }
  16706. if miConfig.MdtrtareaAdmvs == "421300" {
  16707. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16708. psn_info, _ := service.GetPsnByPatientId(id)
  16709. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16710. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16711. "&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
  16712. resp, requestErr := http.Get(api)
  16713. if requestErr != nil {
  16714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16715. return
  16716. }
  16717. body, ioErr := ioutil.ReadAll(resp.Body)
  16718. if ioErr != nil {
  16719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16721. return
  16722. }
  16723. var respJSON map[string]interface{}
  16724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16727. return
  16728. }
  16729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16730. result, _ := json.Marshal(respJSON)
  16731. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16732. utils.ErrorLog("解析失败:%v", err)
  16733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16734. return
  16735. }
  16736. infocode = resThree.Infcode
  16737. } else if miConfig.MdtrtareaAdmvs == "420200" {
  16738. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16739. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16740. // insuplc_admdvs_temp =
  16741. //}
  16742. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16743. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16744. //}
  16745. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16746. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16747. "&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
  16748. resp, requestErr := http.Get(api)
  16749. if requestErr != nil {
  16750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16751. return
  16752. }
  16753. body, ioErr := ioutil.ReadAll(resp.Body)
  16754. if ioErr != nil {
  16755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16757. return
  16758. }
  16759. var respJSON map[string]interface{}
  16760. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16763. return
  16764. }
  16765. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16766. result, _ := json.Marshal(respJSON)
  16767. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16768. utils.ErrorLog("解析失败:%v", err)
  16769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16770. return
  16771. }
  16772. infocode = resThree.Infcode
  16773. } else if miConfig.MdtrtareaAdmvs == "421182" {
  16774. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16775. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  16776. // insuplc_admdvs_temp =
  16777. //}
  16778. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  16779. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  16780. //}
  16781. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16782. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16783. "&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
  16784. resp, requestErr := http.Get(api)
  16785. if requestErr != nil {
  16786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16787. return
  16788. }
  16789. body, ioErr := ioutil.ReadAll(resp.Body)
  16790. if ioErr != nil {
  16791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16793. return
  16794. }
  16795. var respJSON map[string]interface{}
  16796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16799. return
  16800. }
  16801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16802. result, _ := json.Marshal(respJSON)
  16803. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16804. utils.ErrorLog("解析失败:%v", err)
  16805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16806. return
  16807. }
  16808. infocode = resThree.Infcode
  16809. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16810. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  16811. psn_info, _ := service.GetPsnByPatientId(id)
  16812. var verify_number string
  16813. if id_card_type == 4 {
  16814. verify_number = psn_info.VerifyNumber
  16815. } else if id_card_type == 1 {
  16816. bas := strings.Split(psn_info.CardInfo, "|")
  16817. cardNumber := bas[2]
  16818. verify_number = cardNumber
  16819. }
  16820. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  16821. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16822. "&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
  16823. resp, requestErr := http.Get(api)
  16824. if requestErr != nil {
  16825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16826. return
  16827. }
  16828. body, ioErr := ioutil.ReadAll(resp.Body)
  16829. if ioErr != nil {
  16830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16832. return
  16833. }
  16834. var respJSON map[string]interface{}
  16835. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16838. return
  16839. }
  16840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16841. result, _ := json.Marshal(respJSON)
  16842. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16843. // utils.ErrorLog("解析失败:%v", err)
  16844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16845. // return
  16846. //}
  16847. //infocode = resThree.Infcode
  16848. //result, _ := json.Marshal(respJSON)
  16849. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16850. utils.ErrorLog("解析失败:%v", err)
  16851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16852. return
  16853. }
  16854. resThree.ErrMsg = resThree10265.ErrMsg
  16855. resThree.Output = resThree10265.Output
  16856. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16857. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16858. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16859. psn_info, _ := service.GetPsnByPatientId(id)
  16860. his.PsnNo = psn_info.PsnNo
  16861. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  16862. var cert_no string
  16863. if id_card_type == 3 {
  16864. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  16865. cert_no = IdCardNo
  16866. } else if id_card_type == 4 {
  16867. cert_no = IdCardNo
  16868. psn_info.VerifyNumber = psn_info.VerifyNumber
  16869. } else {
  16870. bas := strings.Split(psn_info.CardInfo, "|")
  16871. cert_no = bas[2]
  16872. }
  16873. var hisPrescription []*models.HisPrescription
  16874. for _, item := range rf {
  16875. if item.Insutype == insutype {
  16876. //insuplc_admdvs = item.InsuplcAdmdvs
  16877. his.InsuplcAdmdvs = insuplc_admdvs
  16878. }
  16879. }
  16880. his.Insutype = insutype
  16881. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  16882. fmt.Println(res3101)
  16883. fmt.Println(res3101.Infcode)
  16884. if res3101.Infcode == "0" {
  16885. fmt.Println("33333333")
  16886. if len(res3101.Output.Result) > 0 {
  16887. fmt.Println("222222")
  16888. for _, item := range res3101.Output.Result {
  16889. if len(res3101.ErrMsg) == 0 {
  16890. res3101.ErrMsg = item.VolaCont
  16891. } else {
  16892. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  16893. }
  16894. }
  16895. c.ServeSuccessJSON(map[string]interface{}{
  16896. "failed_code": -10,
  16897. "msg": res3101.ErrMsg,
  16898. })
  16899. return
  16900. } else {
  16901. fmt.Println("11111")
  16902. var api string
  16903. if miConfig.MdtrtareaAdmvs == "320921" {
  16904. ipt_otp_no = timeFormat
  16905. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16906. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16907. "&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
  16908. } else {
  16909. ipt_otp_no = timeFormat
  16910. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  16911. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  16912. "&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
  16913. }
  16914. resp, requestErr := http.Get(api)
  16915. if requestErr != nil {
  16916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16917. return
  16918. }
  16919. body, ioErr := ioutil.ReadAll(resp.Body)
  16920. if ioErr != nil {
  16921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16923. return
  16924. }
  16925. var respJSON map[string]interface{}
  16926. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16929. return
  16930. }
  16931. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16932. result, _ := json.Marshal(respJSON)
  16933. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16934. utils.ErrorLog("解析失败:%v", err)
  16935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16936. return
  16937. }
  16938. resThree.ErrMsg = resThree10265.ErrMsg
  16939. resThree.Output = resThree10265.Output
  16940. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16941. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16942. }
  16943. } else if res3101.Infcode != "0" {
  16944. c.ServeSuccessJSON(map[string]interface{}{
  16945. "failed_code": -10,
  16946. "msg": res3101.ErrMsg,
  16947. })
  16948. return
  16949. }
  16950. } else if miConfig.MdtrtareaAdmvs == "350500" {
  16951. psn_info, _ := service.GetPsnByPatientId(id)
  16952. var cert_no string
  16953. if id_card_type == 1 {
  16954. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  16955. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16956. } else if id_card_type == 4 {
  16957. cert_no = psn_info.VerifyNumber
  16958. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16959. } else {
  16960. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  16961. cert_no = psn_info.VerifyNumber
  16962. }
  16963. 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)
  16964. saveLog(result, requestLog, "2201", "挂号")
  16965. if miConfig.Code == "H15049901371" {
  16966. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  16967. utils.ErrorLog("解析失败:%v", err)
  16968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16969. return
  16970. }
  16971. resThree.ErrMsg = resThree10265.ErrMsg
  16972. resThree.Output = resThree10265.Output
  16973. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  16974. } else {
  16975. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  16976. utils.ErrorLog("解析失败:%v", err)
  16977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16978. return
  16979. }
  16980. }
  16981. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  16982. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  16983. psn_info, _ := service.GetPsnByPatientId(id)
  16984. var result string
  16985. var requestLog string
  16986. if id_card_type == 1 {
  16987. bas := strings.Split(psn_info.CardInfo, "|")
  16988. basNumber := bas[2]
  16989. card_sn := bas[3]
  16990. 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)
  16991. saveLog(result, requestLog, "2201A", "挂号")
  16992. } else if id_card_type == 2 {
  16993. 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, "", "", "", "", "", "")
  16994. saveLog(result, requestLog, "2201A", "挂号")
  16995. } else {
  16996. 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)
  16997. saveLog(result, requestLog, "2201A", "挂号")
  16998. }
  16999. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17000. utils.ErrorLog("解析失败:%v", err)
  17001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17002. return
  17003. }
  17004. infocode = resThree.Infcode
  17005. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17006. psn_info, _ := service.GetPsnByPatientId(id)
  17007. his.PsnNo = psn_info.PsnNo
  17008. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17009. var cert_no string
  17010. if id_card_type == 1 {
  17011. bas := strings.Split(psn_info.CardInfo, "|")
  17012. cert_no = bas[2]
  17013. } else if id_card_type == 4 {
  17014. cert_no = IdCardNo
  17015. psn_info.VerifyNumber = psn_info.VerifyNumber
  17016. } else {
  17017. cert_no = IdCardNo
  17018. psn_info.VerifyNumber = cert_no
  17019. }
  17020. for _, item := range rf {
  17021. if item.Insutype == insutype {
  17022. his.InsuplcAdmdvs = insuplc_admdvs
  17023. }
  17024. }
  17025. his.Insutype = insutype
  17026. var api string
  17027. ipt_otp_no = timeFormat
  17028. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17029. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17030. "&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
  17031. resp, requestErr := http.Get(api)
  17032. if requestErr != nil {
  17033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17034. return
  17035. }
  17036. body, ioErr := ioutil.ReadAll(resp.Body)
  17037. if ioErr != nil {
  17038. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17040. return
  17041. }
  17042. var respJSON map[string]interface{}
  17043. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17044. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17046. return
  17047. }
  17048. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17049. if status == "0" {
  17050. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17051. c.ServeSuccessJSON(map[string]interface{}{
  17052. "failed_code": -10,
  17053. "msg": err_msg,
  17054. })
  17055. return
  17056. }
  17057. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17058. result, _ := json.Marshal(respJSON)
  17059. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17060. utils.ErrorLog("解析失败:%v", err)
  17061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17062. return
  17063. }
  17064. infocode = resThree.Infcode
  17065. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17066. psn_info, _ := service.GetPsnByPatientId(id)
  17067. var result string
  17068. var requestLog string
  17069. if id_card_type == 1 {
  17070. bas := strings.Split(psn_info.CardInfo, "|")
  17071. basNumber := bas[2]
  17072. card_sn := bas[3]
  17073. 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)
  17074. saveLog(result, requestLog, "2201A", "挂号")
  17075. } else if id_card_type == 2 {
  17076. 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, "", "")
  17077. saveLog(result, requestLog, "2201A", "挂号")
  17078. } else {
  17079. 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, "", "")
  17080. saveLog(result, requestLog, "2201A", "挂号")
  17081. }
  17082. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17083. utils.ErrorLog("解析失败:%v", err)
  17084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17085. return
  17086. }
  17087. infocode = resThree.Infcode
  17088. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17089. psn_info, _ := service.GetPsnByPatientId(id)
  17090. 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)
  17091. saveLog(result, requestLog, "2201A", "挂号")
  17092. if miConfig.Code == "H15049901371" {
  17093. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17094. utils.ErrorLog("解析失败:%v", err)
  17095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17096. return
  17097. }
  17098. resThree.ErrMsg = resThree10265.ErrMsg
  17099. resThree.Output = resThree10265.Output
  17100. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17101. } else {
  17102. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17103. utils.ErrorLog("解析失败:%v", err)
  17104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17105. return
  17106. }
  17107. }
  17108. if miConfig.Code == "H15049901371" {
  17109. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17110. } else {
  17111. infocode = resThree.Infcode
  17112. }
  17113. } else {
  17114. psn_info, _ := service.GetPsnByPatientId(id)
  17115. if id_card_type == 4 || id_card_type == 1 {
  17116. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17117. }
  17118. var rf []*ResultFive
  17119. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17120. var insutypes []*ResultFive
  17121. var insutype string
  17122. var is390 int = 0
  17123. var is310 int = 0
  17124. for _, item := range rf {
  17125. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17126. insutypes = append(insutypes, item)
  17127. }
  17128. }
  17129. if len(insutypes) == 1 {
  17130. insutype = insutypes[0].Insutype
  17131. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17132. } else {
  17133. for _, i := range insutypes {
  17134. if i.Insutype == "390" {
  17135. is390 = 1
  17136. }
  17137. if i.Insutype == "310" {
  17138. is310 = 1
  17139. }
  17140. }
  17141. }
  17142. if is390 == 1 {
  17143. insutype = "390"
  17144. }
  17145. if is310 == 1 {
  17146. insutype = "310"
  17147. }
  17148. fmt.Println(len(insutypes))
  17149. if len(insutypes) == 0 {
  17150. for index, item := range rf {
  17151. if index == 0 {
  17152. insutype = item.Insutype
  17153. insuplc_admdvs = item.InsuplcAdmdvs
  17154. }
  17155. }
  17156. fmt.Println(insutype)
  17157. fmt.Println(insuplc_admdvs)
  17158. }
  17159. if social_type > 0 {
  17160. insutype = strconv.FormatInt(social_type, 10)
  17161. }
  17162. fmt.Println("--------")
  17163. fmt.Println(psn_info)
  17164. fmt.Println(psn_info.PsnNo)
  17165. if miConfig.MdtrtareaAdmvs == "441202" {
  17166. var hisPrescription []*models.HisPrescription
  17167. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17168. if res3101.Infcode == 0 {
  17169. fmt.Println("33333333")
  17170. if len(res3101.Output.Result) > 0 {
  17171. fmt.Println("222222")
  17172. for _, item := range res3101.Output.Result {
  17173. if len(res3101.ErrMsg) == 0 {
  17174. res3101.ErrMsg = item.VolaCont
  17175. } else {
  17176. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17177. }
  17178. }
  17179. c.ServeSuccessJSON(map[string]interface{}{
  17180. "failed_code": -10,
  17181. "msg": res3101.ErrMsg,
  17182. })
  17183. return
  17184. } else {
  17185. hour := time.Now().Format("15")
  17186. min := time.Now().Format("04")
  17187. sec := time.Now().Format("05")
  17188. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17189. fmt.Println(record_time_two)
  17190. 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)
  17191. saveLog(result, requestLog, "2201A", "挂号")
  17192. if miConfig.Code == "H15049901371" {
  17193. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17194. utils.ErrorLog("解析失败:%v", err)
  17195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17196. return
  17197. }
  17198. resThree.ErrMsg = resThree10265.ErrMsg
  17199. resThree.Output = resThree10265.Output
  17200. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17201. } else {
  17202. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17203. utils.ErrorLog("解析失败:%v", err)
  17204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17205. return
  17206. }
  17207. }
  17208. if miConfig.Code == "H15049901371" {
  17209. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17210. } else {
  17211. infocode = resThree.Infcode
  17212. }
  17213. }
  17214. } else if res3101.Infcode != 0 {
  17215. c.ServeSuccessJSON(map[string]interface{}{
  17216. "failed_code": -10,
  17217. "msg": res3101.ErrMsg,
  17218. })
  17219. return
  17220. }
  17221. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17222. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17223. psn_info, _ := service.GetPsnByPatientId(id)
  17224. var verify_number string
  17225. if id_card_type == 4 {
  17226. verify_number = psn_info.VerifyNumber
  17227. } else if id_card_type == 1 {
  17228. bas := strings.Split(psn_info.CardInfo, "|")
  17229. cardNumber := bas[2]
  17230. verify_number = cardNumber
  17231. } else {
  17232. verify_number = psn_info.Certno
  17233. }
  17234. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17235. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17236. "&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
  17237. resp, requestErr := http.Get(api)
  17238. if requestErr != nil {
  17239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17240. return
  17241. }
  17242. body, ioErr := ioutil.ReadAll(resp.Body)
  17243. if ioErr != nil {
  17244. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17246. return
  17247. }
  17248. var respJSON map[string]interface{}
  17249. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17250. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17252. return
  17253. }
  17254. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17255. result, _ := json.Marshal(respJSON)
  17256. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17257. utils.ErrorLog("解析失败:%v", err)
  17258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17259. return
  17260. }
  17261. infocode = resThree.Infcode
  17262. } else {
  17263. hour := time.Now().Format("15")
  17264. min := time.Now().Format("04")
  17265. sec := time.Now().Format("05")
  17266. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17267. if id_card_type == 1 {
  17268. for _, item := range rf {
  17269. if item.Insutype == strconv.FormatInt(social_type, 10) {
  17270. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  17271. insuplc_admdvs_temp = item.InsuplcAdmdvs
  17272. } else if strconv.FormatInt(social_type, 10) == "390" {
  17273. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17274. } else {
  17275. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17276. }
  17277. }
  17278. }
  17279. }
  17280. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  17281. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17282. }
  17283. if id_card_type == 1 {
  17284. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  17285. bas := strings.Split(psn_info.CardInfo, "|")
  17286. basNumber := bas[1]
  17287. IdCardNo = basNumber
  17288. }
  17289. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  17290. IdCardNo = psn_info.VerifyNumber
  17291. }
  17292. 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)
  17293. saveLog(result, requestLog, "2201A", "挂号")
  17294. if miConfig.Code == "H15049901371" {
  17295. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17296. utils.ErrorLog("解析失败:%v", err)
  17297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17298. return
  17299. }
  17300. resThree.ErrMsg = resThree10265.ErrMsg
  17301. resThree.Output = resThree10265.Output
  17302. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17303. } else {
  17304. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17305. utils.ErrorLog("解析失败:%v", err)
  17306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17307. return
  17308. }
  17309. }
  17310. if miConfig.Code == "H15049901371" {
  17311. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17312. } else {
  17313. infocode = resThree.Infcode
  17314. }
  17315. }
  17316. }
  17317. if infocode != 0 {
  17318. adminUser := c.GetAdminUserInfo()
  17319. errlog := &models.HisOrderError{
  17320. UserOrgId: adminUser.CurrentOrgId,
  17321. Ctime: time.Now().Unix(),
  17322. Mtime: time.Now().Unix(),
  17323. ErrMsg: resThree.ErrMsg,
  17324. Status: 1,
  17325. PatientId: id,
  17326. RecordTime: recordDateTime,
  17327. Stage: 2,
  17328. }
  17329. service.CreateErrMsgLog(errlog)
  17330. c.ServeSuccessJSON(map[string]interface{}{
  17331. "failed_code": -10,
  17332. "msg": resThree.ErrMsg,
  17333. })
  17334. return
  17335. }
  17336. his.Number = resThree.Output.Data.MdtrtID
  17337. his.PsnNo = resThree.Output.Data.PsnNo
  17338. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  17339. his.IdCardNo = patient.IdCardNo
  17340. his.PhoneNumber = patient.Phone
  17341. his.UserOrgId = adminInfo.CurrentOrgId
  17342. his.Insutype = insutype
  17343. his.Ctime = time.Now().Unix()
  17344. his.Mtime = time.Now().Unix()
  17345. his.InsuplcAdmdvs = insuplc_admdvs_temp
  17346. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  17347. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17348. }
  17349. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  17350. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17351. }
  17352. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  17353. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  17354. }
  17355. his.Status = 1
  17356. his.MdtrtGrpType = mdtrt_type
  17357. service.UpdateHisPatientStatus(&his)
  17358. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  17359. c.ServeSuccessJSON(map[string]interface{}{
  17360. "his_info": his,
  17361. })
  17362. } else {
  17363. adminUser := c.GetAdminUserInfo()
  17364. errlog := &models.HisOrderError{
  17365. UserOrgId: adminUser.CurrentOrgId,
  17366. Ctime: time.Now().Unix(),
  17367. Mtime: time.Now().Unix(),
  17368. ErrMsg: res.ErrMsg,
  17369. Status: 1,
  17370. PatientId: id,
  17371. RecordTime: recordDateTime,
  17372. Stage: 1,
  17373. }
  17374. service.CreateErrMsgLog(errlog)
  17375. c.ServeSuccessJSON(map[string]interface{}{
  17376. "failed_code": -10,
  17377. "msg": res.ErrMsg,
  17378. })
  17379. return
  17380. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  17381. }
  17382. }
  17383. }
  17384. func (c *HisApiController) GetUploadInfo() {
  17385. id, _ := c.GetInt64("id")
  17386. record_time := c.GetString("record_time")
  17387. his_patient_id, _ := c.GetInt64("his_patient_id")
  17388. order_id, _ := c.GetInt64("order_id")
  17389. pay_way, _ := c.GetInt64("pay_way")
  17390. pay_ways := c.GetString("pay_ways")
  17391. oth_desc := c.GetString("oth_desc")
  17392. pay_price, _ := c.GetFloat("pay_price")
  17393. pay_card_no := c.GetString("pay_card_no")
  17394. discount_price, _ := c.GetFloat("discount_price")
  17395. preferential_price, _ := c.GetFloat("preferential_price")
  17396. reality_price, _ := c.GetFloat("reality_price")
  17397. found_price, _ := c.GetFloat("found_price")
  17398. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  17399. private_price, _ := c.GetFloat("private_price")
  17400. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  17401. admin_user_id, _ := c.GetInt64("admin_user_id")
  17402. fapiao_code := c.GetString("fapiao_code")
  17403. fapiao_number := c.GetString("fapiao_number")
  17404. diagnosis_id := c.GetString("diagnosis")
  17405. sick_type, _ := c.GetInt64("sick_type")
  17406. reg_type, _ := c.GetInt64("p_type")
  17407. begin_time := c.GetString("begin_time")
  17408. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  17409. cash_pay := c.GetString("cash_pay")
  17410. band_card_pay := c.GetString("band_card_pay")
  17411. wechat_pay := c.GetString("wechat_pay")
  17412. ali_pay := c.GetString("ali_pay")
  17413. jifen_pay := c.GetString("jifen_pay")
  17414. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  17415. fmt.Println(acct_used_flag)
  17416. id_str := c.GetString("ids")
  17417. ids_arr := strings.Split(id_str, ",")
  17418. timeLayout := "2006-01-02"
  17419. loc, _ := time.LoadLocation("Local")
  17420. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  17421. if err != nil {
  17422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17423. return
  17424. }
  17425. recordDateTime := theTime.Unix()
  17426. adminUser := c.GetAdminUserInfo()
  17427. var tempOrder models.HisOrder
  17428. tempOrder, _ = service.GetHisOrderByID(order_id)
  17429. var prescriptions []*models.HisPrescription
  17430. var start_time int64
  17431. var end_time int64
  17432. //押金模块
  17433. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  17434. tmp_decimal := c.GetString("tmp_decimal")
  17435. var decimal float64 //本次使用的押金
  17436. var errmsg error
  17437. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  17438. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  17439. return
  17440. }
  17441. if len(tmp_decimal) > 0 {
  17442. if tmp_decimal[0] == 45 {
  17443. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  17444. return
  17445. }
  17446. }
  17447. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  17448. fmt.Println(errs)
  17449. decimal = tt
  17450. //if adminUser.CurrentOrgId == 10106{
  17451. // if len(fapiao_code) == 0{
  17452. // fapiao_code = "144072080589"
  17453. // }
  17454. // if len(fapiao_number) == 0{
  17455. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  17456. // if order.ID == 0{
  17457. // fapiao_number = "00001520"
  17458. // }else{
  17459. // //fapiao_code = "00001520"
  17460. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  17461. // var zero string
  17462. // if fpNumber >= 1000{
  17463. // zero = "0000" + strconv.Itoa(fpNumber)
  17464. // }else if fpNumber >= 10000{
  17465. // zero = "000" + strconv.Itoa(fpNumber)
  17466. // } else if fpNumber >= 100000{
  17467. // zero = "00" + strconv.Itoa(fpNumber)
  17468. // } else if fpNumber >= 1000000{
  17469. // zero = "0" + strconv.Itoa(fpNumber)
  17470. // }else {
  17471. // zero = strconv.Itoa(fpNumber)
  17472. // }
  17473. // fapiao_number = zero
  17474. // }
  17475. // }
  17476. //}
  17477. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  17478. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17479. var patientPrescription models.HisPrescriptionInfo
  17480. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  17481. if patientPrescription.ID == 0 {
  17482. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  17483. }
  17484. //if patientPrescription.Do
  17485. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  17486. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  17487. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  17488. diagnosis_ids := strings.Split(diagnosis_id, ",")
  17489. var config []*models.HisXtDiagnoseConfig
  17490. for _, item := range diagnosis_ids {
  17491. id, _ := strconv.ParseInt(item, 10, 64)
  17492. diagnosisConfig, _ := service.FindDiagnoseById(id)
  17493. config = append(config, &diagnosisConfig)
  17494. }
  17495. sickConfig, _ := service.FindSickById(sick_type)
  17496. //if tempOrder.ID == 0 {
  17497. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  17498. //}
  17499. if tempOrder.ID == 0 {
  17500. var result string
  17501. var requestLog string
  17502. var res2 ResultSix
  17503. var res3 GZResultSix
  17504. var ressix10265 ResultSix10265
  17505. if miConfig.MdtrtareaAdmvs == "421300" {
  17506. data := make(map[string]interface{})
  17507. client := &http.Client{}
  17508. data["psn_no"] = his.PsnNo
  17509. data["mdtrt_id"] = his.Number
  17510. data["opter"] = roles.UserName
  17511. data["org_name"] = miConfig.OrgName
  17512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17513. data["doctor_id"] = doctor_info.DoctorNumber
  17514. data["doctor_name"] = doctor_info.UserName
  17515. data["department"] = department.Name
  17516. data["fixmedins_code"] = miConfig.Code
  17517. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17518. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17519. data["secret_key"] = miConfig.SecretKey
  17520. data["sick_code"] = sickConfig.CountryCode
  17521. data["sick_name"] = sickConfig.ClassName
  17522. data["dept"] = strconv.FormatInt(department.ID, 10)
  17523. data["config"] = config
  17524. data["begin_time"] = begin_time
  17525. bytesData, _ := json.Marshal(data)
  17526. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17527. resp, _ := client.Do(req)
  17528. defer resp.Body.Close()
  17529. body, ioErr := ioutil.ReadAll(resp.Body)
  17530. if ioErr != nil {
  17531. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. var respJSON map[string]interface{}
  17536. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17537. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17539. return
  17540. }
  17541. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17542. userJSONBytes, _ := json.Marshal(respJSON)
  17543. fmt.Println("log")
  17544. fmt.Println(string(userJSONBytes))
  17545. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17546. utils.ErrorLog("解析失败:%v", err)
  17547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17548. return
  17549. }
  17550. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17551. data := make(map[string]interface{})
  17552. client := &http.Client{}
  17553. data["psn_no"] = his.PsnNo
  17554. data["mdtrt_id"] = his.Number
  17555. data["opter"] = roles.UserName
  17556. data["org_name"] = miConfig.OrgName
  17557. if reg_type == 11 && his.Insutype == "390" {
  17558. data["med_type"] = "110104"
  17559. } else {
  17560. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17561. }
  17562. data["doctor_id"] = doctor_info.DoctorNumber
  17563. data["doctor_name"] = doctor_info.UserName
  17564. data["department"] = department.Name
  17565. data["fixmedins_code"] = miConfig.Code
  17566. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17567. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17568. data["secret_key"] = miConfig.SecretKey
  17569. data["sick_code"] = sickConfig.CountryCode
  17570. data["sick_name"] = sickConfig.ClassName
  17571. data["dept"] = strconv.FormatInt(department.ID, 10)
  17572. data["config"] = config
  17573. data["begin_time"] = begin_time
  17574. bytesData, _ := json.Marshal(data)
  17575. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  17576. resp, _ := client.Do(req)
  17577. defer resp.Body.Close()
  17578. body, ioErr := ioutil.ReadAll(resp.Body)
  17579. if ioErr != nil {
  17580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17582. return
  17583. }
  17584. var respJSON map[string]interface{}
  17585. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17586. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17588. return
  17589. }
  17590. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17591. userJSONBytes, _ := json.Marshal(respJSON)
  17592. fmt.Println("log")
  17593. fmt.Println(string(userJSONBytes))
  17594. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17595. utils.ErrorLog("解析失败:%v", err)
  17596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17597. return
  17598. }
  17599. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17600. data := make(map[string]interface{})
  17601. client := &http.Client{}
  17602. data["psn_no"] = his.PsnNo
  17603. data["mdtrt_id"] = his.Number
  17604. data["opter"] = roles.UserName
  17605. data["org_name"] = miConfig.OrgName
  17606. if reg_type == 11 && his.Insutype == "390" {
  17607. data["med_type"] = "110104"
  17608. } else {
  17609. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17610. }
  17611. data["doctor_id"] = doctor_info.DoctorNumber
  17612. data["doctor_name"] = doctor_info.UserName
  17613. data["department"] = department.Name
  17614. data["fixmedins_code"] = miConfig.Code
  17615. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17617. data["secret_key"] = miConfig.SecretKey
  17618. data["sick_code"] = sickConfig.CountryCode
  17619. data["sick_name"] = sickConfig.ClassName
  17620. data["dept"] = strconv.FormatInt(department.ID, 10)
  17621. data["config"] = config
  17622. data["begin_time"] = begin_time
  17623. bytesData, _ := json.Marshal(data)
  17624. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  17625. resp, _ := client.Do(req)
  17626. defer resp.Body.Close()
  17627. body, ioErr := ioutil.ReadAll(resp.Body)
  17628. if ioErr != nil {
  17629. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17631. return
  17632. }
  17633. var respJSON map[string]interface{}
  17634. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17635. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17637. return
  17638. }
  17639. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17640. userJSONBytes, _ := json.Marshal(respJSON)
  17641. fmt.Println("log")
  17642. fmt.Println(string(userJSONBytes))
  17643. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17644. utils.ErrorLog("解析失败:%v", err)
  17645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17646. return
  17647. }
  17648. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17649. data := make(map[string]interface{})
  17650. client := &http.Client{}
  17651. data["psn_no"] = his.PsnNo
  17652. data["mdtrt_id"] = his.Number
  17653. data["doctor"] = roles.UserName
  17654. data["department"] = department.Name
  17655. data["org_name"] = miConfig.OrgName
  17656. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17657. data["doctor_id"] = doctor_info.DoctorNumber
  17658. data["new_doctor_name"] = doctor_info.UserName
  17659. data["fixmedins_code"] = miConfig.Code
  17660. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17661. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17662. data["secret_key"] = miConfig.SecretKey
  17663. data["sick_code"] = sickConfig.CountryCode
  17664. data["sick_name"] = sickConfig.ClassName
  17665. data["url"] = miConfig.Url
  17666. data["ak"] = miConfig.AccessKey
  17667. data["begin_time"] = begin_time
  17668. data["cainfo"] = miConfig.Cainfo
  17669. data["dept"] = strconv.FormatInt(department.ID, 10)
  17670. data["config"] = config
  17671. bytesData, _ := json.Marshal(data)
  17672. var req *http.Request
  17673. if miConfig.MdtrtareaAdmvs == "320921" {
  17674. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17675. //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 +
  17676. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  17677. } else {
  17678. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  17679. }
  17680. resp, _ := client.Do(req)
  17681. defer resp.Body.Close()
  17682. body, ioErr := ioutil.ReadAll(resp.Body)
  17683. if ioErr != nil {
  17684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17686. return
  17687. }
  17688. var respJSON map[string]interface{}
  17689. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17692. return
  17693. }
  17694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17695. userJSONBytes, _ := json.Marshal(respJSON)
  17696. fmt.Println("log")
  17697. fmt.Println(string(userJSONBytes))
  17698. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17699. utils.ErrorLog("解析失败:%v", err)
  17700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17701. return
  17702. }
  17703. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17704. res2.Output = ressix10265.Output
  17705. res2.ErrMsg = ressix10265.ErrMsg
  17706. res2.Cainfo = ressix10265.Cainfo
  17707. res2.WarnMsg = ressix10265.WarnMsg
  17708. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17709. res2.Infcode = infocode
  17710. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17711. data := make(map[string]interface{})
  17712. client := &http.Client{}
  17713. data["psn_no"] = his.PsnNo
  17714. data["mdtrt_id"] = his.Number
  17715. data["doctor"] = roles.UserName
  17716. data["department"] = department.Name
  17717. data["org_name"] = miConfig.OrgName
  17718. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17719. data["doctor_id"] = doctor_info.DoctorNumber
  17720. data["new_doctor_name"] = doctor_info.UserName
  17721. data["fixmedins_code"] = miConfig.Code
  17722. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17723. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17724. data["secret_key"] = miConfig.SecretKey
  17725. data["sick_code"] = sickConfig.CountryCode
  17726. data["sick_name"] = sickConfig.ClassName
  17727. data["url"] = miConfig.Url
  17728. data["ak"] = miConfig.AccessKey
  17729. data["begin_time"] = begin_time
  17730. data["cainfo"] = miConfig.Cainfo
  17731. data["dept"] = strconv.FormatInt(department.ID, 10)
  17732. data["config"] = config
  17733. bytesData, _ := json.Marshal(data)
  17734. var req *http.Request
  17735. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  17736. resp, _ := client.Do(req)
  17737. defer resp.Body.Close()
  17738. body, ioErr := ioutil.ReadAll(resp.Body)
  17739. if ioErr != nil {
  17740. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17742. return
  17743. }
  17744. var respJSON map[string]interface{}
  17745. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17746. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17748. return
  17749. }
  17750. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17751. userJSONBytes, _ := json.Marshal(respJSON)
  17752. fmt.Println("log")
  17753. fmt.Println(string(userJSONBytes))
  17754. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  17755. utils.ErrorLog("解析失败:%v", err)
  17756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17757. return
  17758. }
  17759. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17760. res2.Output = ressix10265.Output
  17761. res2.ErrMsg = ressix10265.ErrMsg
  17762. res2.Cainfo = ressix10265.Cainfo
  17763. res2.WarnMsg = ressix10265.WarnMsg
  17764. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17765. res2.Infcode = infocode
  17766. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17767. 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)
  17768. saveLog(result, requestLog, "2203", "上传就诊信息")
  17769. var respJSON2 map[string]interface{}
  17770. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17773. return
  17774. }
  17775. userJSONBytes2, _ := json.Marshal(respJSON2)
  17776. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17777. utils.ErrorLog("解析失败:%v", err)
  17778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17779. return
  17780. }
  17781. 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)
  17782. fmt.Println(result2)
  17783. fmt.Println(src_request)
  17784. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17785. data := make(map[string]interface{})
  17786. client := &http.Client{}
  17787. data["psn_no"] = his.PsnNo
  17788. data["mdtrt_id"] = his.Number
  17789. data["doctor"] = roles.UserName
  17790. data["department"] = department.Name
  17791. data["org_name"] = miConfig.OrgName
  17792. data["med_type"] = strconv.FormatInt(reg_type, 10)
  17793. data["doctor_id"] = doctor_info.DoctorNumber
  17794. data["new_doctor_name"] = doctor_info.UserName
  17795. data["fixmedins_code"] = miConfig.Code
  17796. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17797. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17798. data["secret_key"] = miConfig.SecretKey
  17799. data["sick_code"] = sickConfig.CountryCode
  17800. data["sick_name"] = sickConfig.ClassName
  17801. data["url"] = miConfig.Url
  17802. data["ak"] = miConfig.AccessKey
  17803. data["begin_time"] = begin_time
  17804. data["cainfo"] = miConfig.Cainfo
  17805. data["dept"] = strconv.FormatInt(department.ID, 10)
  17806. data["config"] = config
  17807. bytesData, _ := json.Marshal(data)
  17808. var req *http.Request
  17809. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  17810. resp, _ := client.Do(req)
  17811. defer resp.Body.Close()
  17812. body, ioErr := ioutil.ReadAll(resp.Body)
  17813. if ioErr != nil {
  17814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17816. return
  17817. }
  17818. var respJSON map[string]interface{}
  17819. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17822. return
  17823. }
  17824. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17825. userJSONBytes, _ := json.Marshal(respJSON)
  17826. fmt.Println("log")
  17827. fmt.Println(string(userJSONBytes))
  17828. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  17829. utils.ErrorLog("解析失败:%v", err)
  17830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17831. return
  17832. }
  17833. } else {
  17834. if miConfig.MdtrtareaAdmvs == "440781" { //
  17835. 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)
  17836. } else {
  17837. if miConfig.Code == "H15049901371" {
  17838. //赤峰地区国家医保医疗类别
  17839. //职工透析:医疗类别选特殊情况门诊990502
  17840. //居民定额血透门慢: 医疗类别选门诊慢病140104
  17841. var med_type string
  17842. if his.Insutype == "390" {
  17843. if reg_type == 14 {
  17844. med_type = "9933"
  17845. } else if reg_type == 11 {
  17846. med_type = "11"
  17847. }
  17848. } else if his.Insutype == "310" {
  17849. if reg_type == 14 {
  17850. med_type = "990502"
  17851. } else if reg_type == 11 {
  17852. med_type = "11"
  17853. }
  17854. }
  17855. 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)
  17856. } else {
  17857. 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)
  17858. }
  17859. }
  17860. saveLog(result, requestLog, "2203", "上传就诊信息")
  17861. var respJSON2 map[string]interface{}
  17862. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  17863. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17865. return
  17866. }
  17867. userJSONBytes2, _ := json.Marshal(respJSON2)
  17868. if miConfig.Code == "H15049901371" {
  17869. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  17870. utils.ErrorLog("解析失败:%v", err)
  17871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17872. return
  17873. }
  17874. res2.InfRefmsgid = ressix10265.InfRefmsgid
  17875. res2.Output = ressix10265.Output
  17876. res2.ErrMsg = ressix10265.ErrMsg
  17877. res2.Cainfo = ressix10265.Cainfo
  17878. res2.WarnMsg = ressix10265.WarnMsg
  17879. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  17880. res2.Infcode = infocode
  17881. } else {
  17882. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  17883. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  17884. utils.ErrorLog("解析失败:%v", err)
  17885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17886. return
  17887. }
  17888. res2.Infcode = res3.Infcode
  17889. } else {
  17890. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  17891. utils.ErrorLog("解析失败:%v", err)
  17892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17893. return
  17894. }
  17895. }
  17896. }
  17897. }
  17898. if res2.Infcode != 0 {
  17899. adminUser := c.GetAdminUserInfo()
  17900. errlog := &models.HisOrderError{
  17901. UserOrgId: adminUser.CurrentOrgId,
  17902. Ctime: time.Now().Unix(),
  17903. Mtime: time.Now().Unix(),
  17904. ErrMsg: res2.ErrMsg,
  17905. Status: 1,
  17906. PatientId: id,
  17907. RecordTime: recordDateTime,
  17908. Stage: 3,
  17909. }
  17910. service.CreateErrMsgLog(errlog)
  17911. c.ServeSuccessJSON(map[string]interface{}{
  17912. "failed_code": -10,
  17913. "msg": res2.ErrMsg,
  17914. })
  17915. return
  17916. } else {
  17917. his.Diagnosis = diagnosis_id
  17918. his.SickType = sickConfig.ID
  17919. //var p_type int64
  17920. //if reg_type == 1111 || reg_type == 1112 {
  17921. // p_type = 11
  17922. //
  17923. //}
  17924. his.PType = fmt.Sprintf("%d", reg_type)
  17925. service.UpdateHisPatientThree(&his)
  17926. data := make(map[string]interface{})
  17927. if settle_accounts_type == 1 { //日结
  17928. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  17929. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  17930. } else {
  17931. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  17932. }
  17933. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  17934. data["pre"] = prescriptions
  17935. } else { //月结
  17936. start_time_str := c.GetString("start_time")
  17937. end_time_str := c.GetString("end_time")
  17938. timeLayout := "2006-01-02"
  17939. loc, _ := time.LoadLocation("Local")
  17940. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  17941. if err != nil {
  17942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17943. return
  17944. }
  17945. recordStartTime := theStartTime.Unix()
  17946. start_time = recordStartTime
  17947. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  17948. if err != nil {
  17949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  17950. return
  17951. }
  17952. recordEndTime := theEndTime.Unix()
  17953. end_time = recordEndTime
  17954. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  17955. data["pre"] = prescriptions
  17956. }
  17957. timestamp := time.Now().Unix()
  17958. tempTime := time.Unix(timestamp, 0)
  17959. timeFormat := tempTime.Format("20060102150405")
  17960. chrgBchno := rand.Intn(100000) + 10000
  17961. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17962. strconv.FormatInt(his.PatientId, 10)
  17963. client := &http.Client{}
  17964. data["psn_no"] = his.PsnNo
  17965. data["mdtrt_id"] = his.Number
  17966. data["chrg_bchno"] = chrg_bchno
  17967. data["org_name"] = miConfig.OrgName
  17968. data["doctor"] = doctor_info.UserName
  17969. data["doctor_id"] = doctor_info.DoctorNumber
  17970. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  17971. data["fixmedins_code"] = miConfig.Code
  17972. data["dept_code"] = department.Number
  17973. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  17974. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  17975. data["secret_key"] = miConfig.SecretKey
  17976. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  17977. data["url"] = miConfig.Url
  17978. data["ak"] = miConfig.AccessKey
  17979. data["new_doctor_name"] = patientPrescription.Doctor
  17980. data["diag_code"] = sickConfig.CountryCode
  17981. data["cainfo"] = miConfig.Cainfo
  17982. data["opter"] = roles.UserName
  17983. var ids []int64
  17984. for _, item := range prescriptions {
  17985. ids = append(ids, item.ID)
  17986. }
  17987. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  17988. if config.IsOpen == 1 { //对接了医保,走医保流程
  17989. var res ResultFour
  17990. var resFour10265 ResultFour10265
  17991. if miConfig.MdtrtareaAdmvs == "421300" {
  17992. bytesData, _ := json.Marshal(data)
  17993. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  17994. resp, _ := client.Do(req)
  17995. defer resp.Body.Close()
  17996. body, ioErr := ioutil.ReadAll(resp.Body)
  17997. if ioErr != nil {
  17998. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18000. return
  18001. }
  18002. var respJSON map[string]interface{}
  18003. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18004. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18006. return
  18007. }
  18008. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18009. userJSONBytes, _ := json.Marshal(respJSON)
  18010. fmt.Println("log")
  18011. fmt.Println(string(userJSONBytes))
  18012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18013. utils.ErrorLog("解析失败:%v", err)
  18014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18015. return
  18016. }
  18017. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18018. bytesData, _ := json.Marshal(data)
  18019. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18020. resp, _ := client.Do(req)
  18021. defer resp.Body.Close()
  18022. body, ioErr := ioutil.ReadAll(resp.Body)
  18023. if ioErr != nil {
  18024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18026. return
  18027. }
  18028. var respJSON map[string]interface{}
  18029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18032. return
  18033. }
  18034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18035. userJSONBytes, _ := json.Marshal(respJSON)
  18036. fmt.Println("log")
  18037. fmt.Println(string(userJSONBytes))
  18038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18039. utils.ErrorLog("解析失败:%v", err)
  18040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18041. return
  18042. }
  18043. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18044. bytesData, _ := json.Marshal(data)
  18045. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18046. resp, _ := client.Do(req)
  18047. defer resp.Body.Close()
  18048. body, ioErr := ioutil.ReadAll(resp.Body)
  18049. if ioErr != nil {
  18050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18052. return
  18053. }
  18054. var respJSON map[string]interface{}
  18055. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18058. return
  18059. }
  18060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18061. userJSONBytes, _ := json.Marshal(respJSON)
  18062. fmt.Println("log")
  18063. fmt.Println(string(userJSONBytes))
  18064. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18065. utils.ErrorLog("解析失败:%v", err)
  18066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18067. return
  18068. }
  18069. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18070. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18071. if result3101.Infcode == "0" {
  18072. if len(result3101.Output.Result) > 0 {
  18073. var errMsgs []string
  18074. for _, item := range result3101.Output.Result {
  18075. errMsgs = append(errMsgs, item.VolaCont)
  18076. }
  18077. c.ServeSuccessJSON(map[string]interface{}{
  18078. "failed_code": -10,
  18079. "msg": errMsgs,
  18080. })
  18081. return
  18082. }
  18083. }
  18084. bytesData, _ := json.Marshal(data)
  18085. var req *http.Request
  18086. if miConfig.MdtrtareaAdmvs == "320921" {
  18087. data["diag_code"] = sickConfig.CountryCode
  18088. fmt.Println(data)
  18089. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18090. } else {
  18091. data["diag_code"] = sickConfig.CountryCode
  18092. fmt.Println(data)
  18093. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18094. }
  18095. resp, _ := client.Do(req)
  18096. defer resp.Body.Close()
  18097. body, ioErr := ioutil.ReadAll(resp.Body)
  18098. if ioErr != nil {
  18099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18101. return
  18102. }
  18103. var respJSON map[string]interface{}
  18104. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18107. return
  18108. }
  18109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18110. userJSONBytes, _ := json.Marshal(respJSON)
  18111. fmt.Println("log")
  18112. fmt.Println(string(userJSONBytes))
  18113. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18114. utils.ErrorLog("解析失败:%v", err)
  18115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18116. return
  18117. }
  18118. res.InfRefmsgid = resFour10265.InfRefmsgid
  18119. res.Output = resFour10265.Output
  18120. res.ErrMsg = resFour10265.ErrMsg
  18121. res.Cainfo = resFour10265.Cainfo
  18122. res.WarnMsg = resFour10265.WarnMsg
  18123. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18124. res.Infcode = infocode
  18125. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18126. var pagesize int = 2
  18127. var start int = 1
  18128. var stop int
  18129. var pagecount int
  18130. var curpage int
  18131. var isSuccess bool = true
  18132. data["doctor_id"] = doctor_info.DoctorNumber
  18133. //总页数,向上取整,注意除之前要先转换类型为float64
  18134. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18135. for curpage = 1; curpage <= pagecount; curpage++ {
  18136. if curpage == 1 {
  18137. start = 1
  18138. } else {
  18139. start = (curpage-1)*pagesize + 1
  18140. }
  18141. stop = curpage * pagesize
  18142. if stop > len(prescriptions) {
  18143. stop = len(prescriptions)
  18144. }
  18145. //var requestLog string
  18146. data["pre"] = prescriptions[start-1 : stop]
  18147. fmt.Println(data["pre"])
  18148. bytesData, _ := json.Marshal(data)
  18149. var req *http.Request
  18150. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18151. resp, _ := client.Do(req)
  18152. defer resp.Body.Close()
  18153. body, ioErr := ioutil.ReadAll(resp.Body)
  18154. if ioErr != nil {
  18155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18157. return
  18158. }
  18159. var respJSON map[string]interface{}
  18160. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18163. return
  18164. }
  18165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18166. userJSONBytes, _ := json.Marshal(respJSON)
  18167. fmt.Println("log")
  18168. fmt.Println(string(userJSONBytes))
  18169. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18170. utils.ErrorLog("解析失败:%v", err)
  18171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18172. return
  18173. }
  18174. res.InfRefmsgid = resFour10265.InfRefmsgid
  18175. res.Output = resFour10265.Output
  18176. res.ErrMsg = resFour10265.ErrMsg
  18177. res.Cainfo = resFour10265.Cainfo
  18178. res.WarnMsg = resFour10265.WarnMsg
  18179. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18180. res.Infcode = infocode
  18181. if infocode == 0 {
  18182. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  18183. } else {
  18184. isSuccess = false
  18185. errlog := &models.HisOrderError{
  18186. UserOrgId: adminUser.CurrentOrgId,
  18187. Ctime: time.Now().Unix(),
  18188. Mtime: time.Now().Unix(),
  18189. Number: chrg_bchno,
  18190. ErrMsg: "",
  18191. Status: 1,
  18192. PatientId: id,
  18193. RecordTime: recordDateTime,
  18194. Stage: 4,
  18195. }
  18196. service.CreateErrMsgLog(errlog)
  18197. c.ServeSuccessJSON(map[string]interface{}{
  18198. "failed_code": -10,
  18199. "msg": res.ErrMsg,
  18200. })
  18201. return
  18202. }
  18203. }
  18204. if isSuccess {
  18205. res.Infcode = 0
  18206. }
  18207. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18208. 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)
  18209. var dat map[string]interface{}
  18210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18211. fmt.Println(dat)
  18212. } else {
  18213. fmt.Println(err)
  18214. }
  18215. saveLog(result, request_log, "2204", "上传费用明细")
  18216. userJSONBytes, _ := json.Marshal(dat)
  18217. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18218. utils.ErrorLog("解析失败:%v", err)
  18219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18220. return
  18221. }
  18222. res.InfRefmsgid = resFour10265.InfRefmsgid
  18223. res.Output = resFour10265.Output
  18224. res.ErrMsg = resFour10265.ErrMsg
  18225. res.Cainfo = resFour10265.Cainfo
  18226. res.WarnMsg = resFour10265.WarnMsg
  18227. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18228. res.Infcode = infocode
  18229. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18230. bytesData, _ := json.Marshal(data)
  18231. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  18232. resp, _ := client.Do(req)
  18233. defer resp.Body.Close()
  18234. body, ioErr := ioutil.ReadAll(resp.Body)
  18235. if ioErr != nil {
  18236. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18238. return
  18239. }
  18240. var respJSON map[string]interface{}
  18241. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18242. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18244. return
  18245. }
  18246. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18247. userJSONBytes, _ := json.Marshal(respJSON)
  18248. fmt.Println("log")
  18249. fmt.Println(string(userJSONBytes))
  18250. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18251. utils.ErrorLog("解析失败:%v", err)
  18252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18253. return
  18254. }
  18255. } else {
  18256. if miConfig.Code == "H15049901371" {
  18257. 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)
  18258. var dat map[string]interface{}
  18259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18260. fmt.Println(dat)
  18261. } else {
  18262. fmt.Println(err)
  18263. }
  18264. saveLog(result, request_log, "2204", "上传费用明细")
  18265. userJSONBytes, _ := json.Marshal(dat)
  18266. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18267. utils.ErrorLog("解析失败:%v", err)
  18268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18269. return
  18270. }
  18271. res.InfRefmsgid = resFour10265.InfRefmsgid
  18272. res.Output = resFour10265.Output
  18273. res.ErrMsg = resFour10265.ErrMsg
  18274. res.Cainfo = resFour10265.Cainfo
  18275. res.WarnMsg = resFour10265.WarnMsg
  18276. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18277. res.Infcode = infocode
  18278. } else {
  18279. 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)
  18280. var dat map[string]interface{}
  18281. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18282. fmt.Println(dat)
  18283. } else {
  18284. fmt.Println(err)
  18285. }
  18286. saveLog(result, request_log, "2204", "上传费用明细")
  18287. userJSONBytes, _ := json.Marshal(dat)
  18288. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18289. utils.ErrorLog("解析失败:%v", err)
  18290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18291. return
  18292. }
  18293. }
  18294. }
  18295. if res.Infcode == 0 {
  18296. order := &models.HisOrder{
  18297. UserOrgId: adminUser.CurrentOrgId,
  18298. HisPatientId: his.ID,
  18299. PatientId: his.PatientId,
  18300. SettleAccountsDate: recordDateTime,
  18301. MdtrtId: his.Number,
  18302. PsnNo: his.PsnNo,
  18303. MedType: strconv.FormatInt(reg_type, 10),
  18304. Ctime: time.Now().Unix(),
  18305. Mtime: time.Now().Unix(),
  18306. Status: 1,
  18307. Number: chrg_bchno,
  18308. Infcode: res.Infcode,
  18309. WarnMsg: res.WarnMsg,
  18310. Cainfo: res.Cainfo,
  18311. ErrMsg: res.ErrMsg,
  18312. RespondTime: res.RefmsgTime,
  18313. InfRefmsgid: res.InfRefmsgid,
  18314. OrderStatus: 1,
  18315. PayWay: pay_way,
  18316. PayWays: pay_ways,
  18317. OthDesc: oth_desc,
  18318. PayPrice: pay_price,
  18319. PayCardNo: pay_card_no,
  18320. DiscountPrice: discount_price,
  18321. PreferentialPrice: preferential_price,
  18322. RealityPrice: reality_price,
  18323. FoundPrice: found_price,
  18324. MedicalInsurancePrice: medical_insurance_price,
  18325. PrivatePrice: private_price,
  18326. IsMedicineInsurance: 1,
  18327. SettleType: settle_accounts_type,
  18328. SettleStartTime: start_time,
  18329. SettleEndTime: end_time,
  18330. Creator: roles.AdminUserId,
  18331. Modify: roles.AdminUserId,
  18332. FaPiaoNumber: fapiao_number,
  18333. FaPiaoCode: fapiao_code,
  18334. PType: 2,
  18335. Diagnosis: diagnosis_id,
  18336. CashPay: cash_pay,
  18337. WechatPay: wechat_pay,
  18338. AliPay: ali_pay,
  18339. JifenPay: jifen_pay,
  18340. BandCardPay: band_card_pay,
  18341. }
  18342. err = service.CreateOrder(order)
  18343. if err != nil {
  18344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  18345. return
  18346. }
  18347. for _, item := range res.Output.Result {
  18348. temp := strings.Split(item.FeedetlSn, "-")
  18349. var advice_id int64 = 0
  18350. var project_id int64 = 0
  18351. var types int64 = 0
  18352. id, _ := strconv.ParseInt(temp[2], 10, 64)
  18353. types, _ = strconv.ParseInt(temp[1], 10, 64)
  18354. if temp[1] == "1" {
  18355. advice_id = id
  18356. project_id = 0
  18357. } else if temp[1] == "2" {
  18358. advice_id = 0
  18359. project_id = id
  18360. }
  18361. if item.MedChrgitmType == "9" {
  18362. item.MedChrgitmType = "09"
  18363. }
  18364. info := &models.HisOrderInfo{
  18365. OrderNumber: order.Number,
  18366. FeedetlSn: item.FeedetlSn,
  18367. UploadDate: time.Now().Unix(),
  18368. AdviceId: advice_id,
  18369. DetItemFeeSumamt: item.DetItemFeeSumamt,
  18370. Cnt: item.Cnt,
  18371. Pric: float64(item.Pric),
  18372. PatientId: his.PatientId,
  18373. PricUplmtAmt: item.PricUplmtAmt,
  18374. SelfpayProp: item.SelfpayProp,
  18375. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  18376. OverlmtAmt: item.OverlmtAmt,
  18377. PreselfpayAmt: item.PreselfpayAmt,
  18378. BasMednFlag: item.BasMednFlag,
  18379. MedChrgitmType: item.MedChrgitmType,
  18380. HiNegoDrugFlag: item.HiNegoDrugFlag,
  18381. Status: 1,
  18382. Memo: item.Memo,
  18383. Mtime: time.Now().Unix(),
  18384. InscpScpAmt: item.InscpScpAmt,
  18385. DrtReimFlag: item.DrtReimFlag,
  18386. Ctime: time.Now().Unix(),
  18387. ListSpItemFlag: item.ListSpItemFlag,
  18388. ChldMedcFlag: item.ChldMedcFlag,
  18389. LmtUsedFlag: item.LmtUsedFlag,
  18390. ChrgitmLv: item.ChrgitmLv,
  18391. UserOrgId: adminUser.CurrentOrgId,
  18392. HisPatientId: his.ID,
  18393. OrderId: order.ID,
  18394. ProjectId: project_id,
  18395. Type: types,
  18396. }
  18397. service.CreateOrderInfo(info)
  18398. }
  18399. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  18400. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  18401. var total float64
  18402. for _, item := range prescriptions {
  18403. if item.Type == 1 { //药品
  18404. for _, subItem := range item.HisDoctorAdviceInfo {
  18405. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18406. total_one := price * subItem.PrescribingNumber
  18407. total = total + total_one
  18408. }
  18409. }
  18410. if item.Type == 2 { //项目
  18411. for _, subItem := range item.HisPrescriptionProject {
  18412. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  18413. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  18414. total_one := price * cnt
  18415. total = total + total_one
  18416. }
  18417. }
  18418. }
  18419. allTotal := fmt.Sprintf("%.2f", total)
  18420. //if adminUser.CurrentOrgId == 9919 {
  18421. //
  18422. // allTotal = fmt.Sprintf("%.2f", total)
  18423. //
  18424. //} else {
  18425. //
  18426. // allTotal = fmt.Sprintf("%.2f", total)
  18427. //
  18428. //}
  18429. if res.Infcode == 0 {
  18430. var rf []*ResultFive
  18431. json.Unmarshal([]byte(his.Iinfo), &rf)
  18432. chrg_bchno := chrg_bchno
  18433. cert_no := his.Certno
  18434. var insutypes []string
  18435. var insutype string
  18436. var is390 int = 0
  18437. var is310 int = 0
  18438. for _, item := range rf {
  18439. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18440. insutypes = append(insutypes, item.Insutype)
  18441. }
  18442. }
  18443. if len(insutypes) == 1 {
  18444. insutype = insutypes[0]
  18445. } else {
  18446. for _, i := range insutypes {
  18447. if i == "390" {
  18448. is390 = 1
  18449. }
  18450. if i == "310" {
  18451. is310 = 1
  18452. }
  18453. }
  18454. }
  18455. if is390 == 1 {
  18456. insutype = "390"
  18457. }
  18458. if is310 == 1 {
  18459. insutype = "310"
  18460. }
  18461. if len(insutypes) == 0 {
  18462. insutype = "310"
  18463. }
  18464. if len(insutypes) == 2 {
  18465. insutype = strconv.FormatInt(his.SocialType, 10)
  18466. }
  18467. insutype = strconv.FormatInt(his.SocialType, 10)
  18468. //insutype = "390"
  18469. if his.IdCardType == 1 {
  18470. // cert_no = his.MedicalInsuranceNumber
  18471. cert_no = his.Certno
  18472. } else {
  18473. cert_no = his.Certno
  18474. }
  18475. var res ResultSeven
  18476. var resSeven10265 ResultSeven10265
  18477. var gzresSeven10265Two GZResultSeven10265Two
  18478. var src_resquest string
  18479. var result2 string
  18480. if miConfig.MdtrtareaAdmvs == "421300" {
  18481. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18482. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18483. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18485. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18486. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18487. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18488. resp, requestErr := http.Get(api)
  18489. if requestErr != nil {
  18490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18491. return
  18492. }
  18493. body, ioErr := ioutil.ReadAll(resp.Body)
  18494. if ioErr != nil {
  18495. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18497. return
  18498. }
  18499. var respJSON map[string]interface{}
  18500. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18501. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18503. return
  18504. }
  18505. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18506. result, _ := json.Marshal(respJSON)
  18507. if miConfig.Code == "H15049901371" {
  18508. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18509. utils.ErrorLog("解析失败:%v", err)
  18510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18511. return
  18512. }
  18513. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18514. res.Output = resSeven10265.Output
  18515. res.ErrMsg = resSeven10265.ErrMsg
  18516. res.Cainfo = resSeven10265.Cainfo
  18517. res.WarnMsg = resSeven10265.WarnMsg
  18518. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18519. res.Infcode = infocode
  18520. } else {
  18521. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18522. utils.ErrorLog("解析失败:%v", err)
  18523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18524. return
  18525. }
  18526. }
  18527. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18528. if reg_type == 11 && his.Insutype == "390" {
  18529. reg_type = 110104
  18530. }
  18531. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18532. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18533. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18534. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18535. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18536. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18537. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18538. resp, requestErr := http.Get(api)
  18539. if requestErr != nil {
  18540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18541. return
  18542. }
  18543. body, ioErr := ioutil.ReadAll(resp.Body)
  18544. if ioErr != nil {
  18545. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18547. return
  18548. }
  18549. var respJSON map[string]interface{}
  18550. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18551. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18553. return
  18554. }
  18555. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18556. result, _ := json.Marshal(respJSON)
  18557. if miConfig.Code == "H15049901371" {
  18558. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18559. utils.ErrorLog("解析失败:%v", err)
  18560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18561. return
  18562. }
  18563. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18564. res.Output = resSeven10265.Output
  18565. res.ErrMsg = resSeven10265.ErrMsg
  18566. res.Cainfo = resSeven10265.Cainfo
  18567. res.WarnMsg = resSeven10265.WarnMsg
  18568. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18569. res.Infcode = infocode
  18570. } else {
  18571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18572. utils.ErrorLog("解析失败:%v", err)
  18573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18574. return
  18575. }
  18576. }
  18577. } else if miConfig.MdtrtareaAdmvs == "421182" {
  18578. if reg_type == 11 && his.Insutype == "390" {
  18579. reg_type = 110104
  18580. }
  18581. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18582. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18583. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18584. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18585. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18586. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18587. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  18588. resp, requestErr := http.Get(api)
  18589. if requestErr != nil {
  18590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18591. return
  18592. }
  18593. body, ioErr := ioutil.ReadAll(resp.Body)
  18594. if ioErr != nil {
  18595. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18597. return
  18598. }
  18599. var respJSON map[string]interface{}
  18600. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18601. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18603. return
  18604. }
  18605. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18606. result, _ := json.Marshal(respJSON)
  18607. if miConfig.Code == "H15049901371" {
  18608. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18609. utils.ErrorLog("解析失败:%v", err)
  18610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18611. return
  18612. }
  18613. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18614. res.Output = resSeven10265.Output
  18615. res.ErrMsg = resSeven10265.ErrMsg
  18616. res.Cainfo = resSeven10265.Cainfo
  18617. res.WarnMsg = resSeven10265.WarnMsg
  18618. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18619. res.Infcode = infocode
  18620. } else {
  18621. if err := json.Unmarshal([]byte(result), &res); err != nil {
  18622. utils.ErrorLog("解析失败:%v", err)
  18623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18624. return
  18625. }
  18626. }
  18627. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18628. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  18629. if result3101.Infcode == "0" {
  18630. if len(result3101.Output.Result) > 0 {
  18631. var errMsgs []string
  18632. for _, item := range result3101.Output.Result {
  18633. errMsgs = append(errMsgs, item.VolaCont)
  18634. }
  18635. c.ServeSuccessJSON(map[string]interface{}{
  18636. "failed_code": -10,
  18637. "msg": errMsgs,
  18638. })
  18639. return
  18640. } else {
  18641. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18642. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  18643. bas := strings.Split(psn_info.CardInfo, "|")
  18644. if his.IdCardType == 1 {
  18645. cert_no = bas[2]
  18646. } else if his.IdCardType == 3 {
  18647. cert_no = his.Certno
  18648. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  18649. } else if his.IdCardType == 4 {
  18650. cert_no = his.Certno
  18651. psn_info.VerifyNumber = psn_info.VerifyNumber
  18652. }
  18653. var api string
  18654. if miConfig.MdtrtareaAdmvs == "320921" {
  18655. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18656. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18657. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18658. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18659. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18660. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18661. "&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
  18662. } else {
  18663. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18664. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18665. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18666. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18667. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18668. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18669. "&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
  18670. }
  18671. resp, requestErr := http.Get(api)
  18672. if requestErr != nil {
  18673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18674. return
  18675. }
  18676. body, ioErr := ioutil.ReadAll(resp.Body)
  18677. if ioErr != nil {
  18678. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18680. return
  18681. }
  18682. var respJSON map[string]interface{}
  18683. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18684. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18686. return
  18687. }
  18688. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18689. result, _ := json.Marshal(respJSON)
  18690. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18691. utils.ErrorLog("解析失败:%v", err)
  18692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18693. return
  18694. }
  18695. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18696. res.Output = resSeven10265.Output
  18697. res.ErrMsg = resSeven10265.ErrMsg
  18698. res.Cainfo = resSeven10265.Cainfo
  18699. res.WarnMsg = resSeven10265.WarnMsg
  18700. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18701. res.Infcode = infocode
  18702. }
  18703. }
  18704. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18705. psn_info, _ := service.GetPsnByPatientId(id)
  18706. var verify_number string
  18707. if psn_info.IdCardType == 4 {
  18708. verify_number = psn_info.VerifyNumber
  18709. } else if psn_info.IdCardType == 1 {
  18710. bas := strings.Split(psn_info.CardInfo, "|")
  18711. cardNumber := bas[2]
  18712. verify_number = cardNumber
  18713. } else {
  18714. psn_info.IdCardType = 2
  18715. verify_number = psn_info.Certno
  18716. }
  18717. var api string
  18718. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  18719. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  18720. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  18721. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  18722. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  18723. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  18724. "&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
  18725. resp, requestErr := http.Get(api)
  18726. if requestErr != nil {
  18727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18728. return
  18729. }
  18730. body, ioErr := ioutil.ReadAll(resp.Body)
  18731. if ioErr != nil {
  18732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18734. return
  18735. }
  18736. var respJSON map[string]interface{}
  18737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18740. return
  18741. }
  18742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18743. result, _ := json.Marshal(respJSON)
  18744. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  18745. utils.ErrorLog("解析失败:%v", err)
  18746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18747. return
  18748. }
  18749. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18750. res.Output = resSeven10265.Output
  18751. res.ErrMsg = resSeven10265.ErrMsg
  18752. res.Cainfo = resSeven10265.Cainfo
  18753. res.WarnMsg = resSeven10265.WarnMsg
  18754. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18755. res.Infcode = infocode
  18756. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18757. var cert_no string
  18758. if his.IdCardType == 4 {
  18759. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18760. cert_no = psn_info.VerifyNumber
  18761. 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)
  18762. } else if his.IdCardType == 1 {
  18763. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18764. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  18765. 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)
  18766. }
  18767. //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)
  18768. var dat map[string]interface{}
  18769. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18770. fmt.Println(dat)
  18771. } else {
  18772. fmt.Println(err)
  18773. }
  18774. saveLog(result2, src_resquest, "2207", "结算")
  18775. userJSONBytes, _ := json.Marshal(dat)
  18776. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18777. utils.ErrorLog("解析失败:%v", err)
  18778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18779. return
  18780. }
  18781. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18782. res.Output = resSeven10265.Output
  18783. res.ErrMsg = resSeven10265.ErrMsg
  18784. res.Cainfo = resSeven10265.Cainfo
  18785. res.WarnMsg = resSeven10265.WarnMsg
  18786. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18787. res.Infcode = infocode
  18788. } else if miConfig.MdtrtareaAdmvs == "450721" {
  18789. res2 := c.GetoleInfo()
  18790. if res2.Infcode == 0 {
  18791. var result string
  18792. var request_log string
  18793. var result_log string
  18794. if res2.Output.MdtrtCertType == "02" {
  18795. 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)
  18796. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18797. } else if res2.Output.MdtrtCertType == "01" {
  18798. 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)
  18799. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18800. } else {
  18801. 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)
  18802. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  18803. }
  18804. var dat map[string]interface{}
  18805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  18806. fmt.Println(dat)
  18807. } else {
  18808. fmt.Println(err)
  18809. }
  18810. userJSONBytes, _ := json.Marshal(dat)
  18811. var res5 ResultTwo
  18812. //var resTwo10265 ResultTwo10265
  18813. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  18814. utils.ErrorLog("解析失败:%v", err)
  18815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18816. return
  18817. }
  18818. if res5.Infcode == -1 {
  18819. c.ServeSuccessJSON(map[string]interface{}{
  18820. "failed_code": -10,
  18821. "msg": res5.ErrMsg,
  18822. })
  18823. return
  18824. }
  18825. var insutypes []string
  18826. var insutype string
  18827. var is390 int = 0
  18828. var is310 int = 0
  18829. for _, item := range res5.Output.Iinfo {
  18830. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  18831. insutypes = append(insutypes, item.Insutype)
  18832. }
  18833. }
  18834. if len(insutypes) == 1 {
  18835. insutype = insutypes[0]
  18836. } else {
  18837. for _, i := range insutypes {
  18838. if i == "390" {
  18839. is390 = 1
  18840. }
  18841. if i == "310" {
  18842. is310 = 1
  18843. }
  18844. }
  18845. }
  18846. if is390 == 1 {
  18847. insutype = "390"
  18848. }
  18849. if is310 == 1 {
  18850. insutype = "310"
  18851. }
  18852. if len(insutypes) == 0 {
  18853. insutype = "310"
  18854. }
  18855. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  18856. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  18857. infoStr := string(Iinfos)
  18858. idetinfoStr := string(Idetinfos)
  18859. psn := &models.HisPsn{
  18860. PsnNo: res5.Output.Baseinfo.PsnNo,
  18861. PatientId: id,
  18862. Certno: res5.Output.Baseinfo.Certno,
  18863. Gend: res5.Output.Baseinfo.Gend,
  18864. Naty: res5.Output.Baseinfo.Naty,
  18865. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  18866. PsnName: res5.Output.Baseinfo.PsnName,
  18867. Idetinfo: idetinfoStr,
  18868. Insuinfo: infoStr,
  18869. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  18870. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  18871. VerifyNumber: res2.Output.EcToken,
  18872. }
  18873. if res2.Output.MdtrtCertType == "01" {
  18874. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18875. psn.VerifyNumber = res2.Output.EcToken
  18876. } else if res2.Output.MdtrtCertType == "02" {
  18877. psn.VerifyNumber = res2.Output.CardNo
  18878. } else {
  18879. psn.VerifyNumber = res2.Output.MdtrtCertNo
  18880. }
  18881. service.CreateHisPsn(psn)
  18882. if res2.Output.MdtrtCertType == "01" {
  18883. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18884. token := res2.Output.EcToken
  18885. 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)
  18886. } else if res2.Output.MdtrtCertType == "02" {
  18887. 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)
  18888. } else {
  18889. 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)
  18890. }
  18891. var dat2 map[string]interface{}
  18892. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  18893. fmt.Println(dat2)
  18894. } else {
  18895. fmt.Println(err)
  18896. }
  18897. userJSONBytes3, _ := json.Marshal(dat2)
  18898. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  18899. utils.ErrorLog("解析失败:%v", err)
  18900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18901. return
  18902. }
  18903. saveLog(result2, src_resquest, "2207", "结算")
  18904. } else {
  18905. c.ServeSuccessJSON(map[string]interface{}{
  18906. "failed_code": -10,
  18907. "msg": res2.ErrMsg,
  18908. })
  18909. return
  18910. }
  18911. } else {
  18912. if miConfig.Code == "H15049901371" {
  18913. //赤峰地区国家医保医疗类别
  18914. //职工透析:医疗类别选特殊情况门诊990502
  18915. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18916. var med_type string
  18917. if his.Insutype == "390" {
  18918. if reg_type == 14 {
  18919. med_type = "9933"
  18920. } else if reg_type == 11 {
  18921. med_type = "11"
  18922. }
  18923. } else if his.Insutype == "310" {
  18924. if reg_type == 14 {
  18925. med_type = "990502"
  18926. } else if reg_type == 11 {
  18927. med_type = "11"
  18928. }
  18929. }
  18930. 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)
  18931. } else {
  18932. if his.IdCardType == 4 {
  18933. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18934. var token string
  18935. token = psn_info.VerifyNumber
  18936. 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)
  18937. } else {
  18938. if his.IdCardType == 1 {
  18939. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  18940. bas := strings.Split(psn_info.CardInfo, "|")
  18941. basNumber := bas[2]
  18942. cert_no = basNumber
  18943. }
  18944. 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)
  18945. }
  18946. }
  18947. //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)
  18948. var dat map[string]interface{}
  18949. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  18950. fmt.Println(dat)
  18951. } else {
  18952. fmt.Println(err)
  18953. }
  18954. saveLog(result2, src_resquest, "2207", "结算")
  18955. userJSONBytes, _ := json.Marshal(dat)
  18956. if miConfig.Code == "H15049901371" {
  18957. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  18958. utils.ErrorLog("解析失败:%v", err)
  18959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18960. return
  18961. }
  18962. res.InfRefmsgid = resSeven10265.InfRefmsgid
  18963. res.Output = resSeven10265.Output
  18964. res.ErrMsg = resSeven10265.ErrMsg
  18965. res.Cainfo = resSeven10265.Cainfo
  18966. res.WarnMsg = resSeven10265.WarnMsg
  18967. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  18968. res.Infcode = infocode
  18969. } else {
  18970. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18971. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  18972. utils.ErrorLog("解析失败:%v", err)
  18973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18974. return
  18975. }
  18976. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  18977. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  18978. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  18979. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18980. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  18981. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  18982. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  18983. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  18984. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  18985. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18986. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18987. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18988. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  18989. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  18990. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  18991. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  18992. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  18993. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  18994. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  18995. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  18996. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  18997. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  18998. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  18999. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19000. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19001. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19002. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19003. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19004. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19005. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19006. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19007. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19008. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19009. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19010. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19011. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19012. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19013. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19014. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19015. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19016. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19017. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19018. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19019. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19020. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19021. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19022. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19023. res.Cainfo = gzresSeven10265Two.Cainfo
  19024. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19025. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19026. //res.Infcode = infocode
  19027. } else {
  19028. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19029. utils.ErrorLog("解析失败:%v", err)
  19030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19031. return
  19032. }
  19033. }
  19034. }
  19035. }
  19036. if res.Infcode == -1 {
  19037. errlog := &models.HisOrderError{
  19038. UserOrgId: adminUser.CurrentOrgId,
  19039. Ctime: time.Now().Unix(),
  19040. Mtime: time.Now().Unix(),
  19041. Number: chrg_bchno,
  19042. ErrMsg: res.ErrMsg,
  19043. Status: 1,
  19044. PatientId: id,
  19045. RecordTime: recordDateTime,
  19046. Stage: 6,
  19047. }
  19048. service.CreateErrMsgLog(errlog)
  19049. c.ServeSuccessJSON(map[string]interface{}{
  19050. "failed_code": -10,
  19051. "msg": res.ErrMsg,
  19052. })
  19053. return
  19054. } else {
  19055. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19056. order.OrderStatus = 2
  19057. order.Status = 1
  19058. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19059. order.SetlId = res.Output.Setlinfo.SetlID
  19060. order.PsnNo = res.Output.Setlinfo.PsnNo
  19061. order.PsnName = res.Output.Setlinfo.PsnName
  19062. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19063. order.Certno = res.Output.Setlinfo.Certno
  19064. order.Gend = res.Output.Setlinfo.Gend
  19065. order.Naty = res.Output.Setlinfo.Naty
  19066. order.Age = res.Output.Setlinfo.Age
  19067. order.Insutype = res.Output.Setlinfo.Insutype
  19068. order.PsnType = res.Output.Setlinfo.PsnType
  19069. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19070. order.SetlTime = res.Output.Setlinfo.SetlTime
  19071. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19072. if res.Output.Setlinfo.MedType == "140101" {
  19073. order.MedType = "14"
  19074. } else {
  19075. if res.Output.Setlinfo.MedType == "110104" {
  19076. order.MedType = "11"
  19077. } else {
  19078. order.MedType = res.Output.Setlinfo.MedType
  19079. }
  19080. }
  19081. if reg_type == 1112 {
  19082. order.MedType = "1112"
  19083. }
  19084. if reg_type == 1111 {
  19085. order.MedType = "1111"
  19086. }
  19087. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19088. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19089. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19090. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19091. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19092. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19093. order.HifpPay = res.Output.Setlinfo.HifpPay
  19094. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19095. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19096. order.HifesPay = res.Output.Setlinfo.HifesPay
  19097. order.HifobPay = res.Output.Setlinfo.HifobPay
  19098. order.MafPay = res.Output.Setlinfo.MafPay
  19099. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19100. order.OthPay = res.Output.Setlinfo.OthPay
  19101. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19102. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19103. order.AcctPay = res.Output.Setlinfo.AcctPay
  19104. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  19105. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  19106. order.Balc = res.Output.Setlinfo.Balc
  19107. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  19108. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  19109. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  19110. order.ClrType = res.Output.Setlinfo.ClrType
  19111. order.ClrWay = res.Output.Setlinfo.ClrWay
  19112. order.Creator = order.Creator
  19113. order.Modify = roles.AdminUserId
  19114. order.RequestLog = src_resquest
  19115. order.FaPiaoNumber = fapiao_number
  19116. order.FaPiaoCode = fapiao_code
  19117. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  19118. //detailStr := string(setlDetail)
  19119. //order.SetlDetail = detailStr
  19120. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  19121. err = service.UpDateOrder(order)
  19122. if err == nil {
  19123. //判断是否使用了押金
  19124. if dec_way == "true" {
  19125. tmpstring := strconv.FormatInt(order.ID, 10)
  19126. order.Decimal = decimal
  19127. service.UpDateOrder(order)
  19128. //扣押金
  19129. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  19130. if errmsg != nil {
  19131. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  19132. return
  19133. }
  19134. }
  19135. c.ServeSuccessJSON(map[string]interface{}{
  19136. "msg": "结算成功",
  19137. })
  19138. } else {
  19139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  19140. return
  19141. }
  19142. }
  19143. } else {
  19144. adminUser := c.GetAdminUserInfo()
  19145. errlog := &models.HisOrderError{
  19146. UserOrgId: adminUser.CurrentOrgId,
  19147. Ctime: time.Now().Unix(),
  19148. Mtime: time.Now().Unix(),
  19149. ErrMsg: res.ErrMsg,
  19150. Status: 1,
  19151. PatientId: id,
  19152. RecordTime: recordDateTime,
  19153. Stage: 4,
  19154. }
  19155. service.CreateErrMsgLog(errlog)
  19156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  19157. return
  19158. }
  19159. } else {
  19160. adminUser := c.GetAdminUserInfo()
  19161. errlog := &models.HisOrderError{
  19162. UserOrgId: adminUser.CurrentOrgId,
  19163. Ctime: time.Now().Unix(),
  19164. Mtime: time.Now().Unix(),
  19165. ErrMsg: res.ErrMsg,
  19166. Status: 1,
  19167. PatientId: id,
  19168. RecordTime: recordDateTime,
  19169. Stage: 4,
  19170. }
  19171. service.CreateErrMsgLog(errlog)
  19172. c.ServeSuccessJSON(map[string]interface{}{
  19173. "failed_code": -10,
  19174. "msg": res.ErrMsg,
  19175. })
  19176. return
  19177. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  19178. //return
  19179. }
  19180. }
  19181. }
  19182. } else if tempOrder.ID > 0 {
  19183. if tempOrder.IsPre == 1 {
  19184. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  19185. var rf []*ResultFive
  19186. json.Unmarshal([]byte(his.Iinfo), &rf)
  19187. chrg_bchno := tempOrder.Number
  19188. cert_no := his.Certno
  19189. var insutypes []string
  19190. var insutype string
  19191. var is390 int = 0
  19192. var is310 int = 0
  19193. for _, item := range rf {
  19194. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19195. insutypes = append(insutypes, item.Insutype)
  19196. }
  19197. }
  19198. if len(insutypes) == 1 {
  19199. insutype = insutypes[0]
  19200. } else {
  19201. for _, i := range insutypes {
  19202. if i == "390" {
  19203. is390 = 1
  19204. }
  19205. if i == "310" {
  19206. is310 = 1
  19207. }
  19208. }
  19209. }
  19210. if is390 == 1 {
  19211. insutype = "390"
  19212. }
  19213. if is310 == 1 {
  19214. insutype = "310"
  19215. }
  19216. if len(insutypes) == 0 {
  19217. insutype = "310"
  19218. }
  19219. if len(insutypes) == 2 {
  19220. insutype = strconv.FormatInt(his.SocialType, 10)
  19221. }
  19222. //insutype = "390"
  19223. if his.IdCardType == 1 {
  19224. // cert_no = his.MedicalInsuranceNumber
  19225. cert_no = his.Certno
  19226. } else {
  19227. cert_no = his.Certno
  19228. }
  19229. var res ResultSeven
  19230. var ahres ResultSevenAH
  19231. var resSeven10265 ResultSeven10265
  19232. var gzresSeven10265Two GZResultSeven10265Two
  19233. var src_resquest string
  19234. var result2 string
  19235. if miConfig.MdtrtareaAdmvs == "450721" {
  19236. res2 := c.GetoleInfo()
  19237. if res2.Infcode == 0 {
  19238. var result string
  19239. var request_log string
  19240. var result_log string
  19241. if res2.Output.MdtrtCertType == "02" {
  19242. 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)
  19243. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19244. } else if res2.Output.MdtrtCertType == "01" {
  19245. 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)
  19246. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19247. } else {
  19248. 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)
  19249. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19250. }
  19251. var dat map[string]interface{}
  19252. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19253. fmt.Println(dat)
  19254. } else {
  19255. fmt.Println(err)
  19256. }
  19257. userJSONBytes, _ := json.Marshal(dat)
  19258. var res5 ResultTwo
  19259. //var resTwo10265 ResultTwo10265
  19260. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19261. utils.ErrorLog("解析失败:%v", err)
  19262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19263. return
  19264. }
  19265. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  19266. if res5.Infcode == -1 {
  19267. c.ServeSuccessJSON(map[string]interface{}{
  19268. "failed_code": -10,
  19269. "msg": res5.ErrMsg,
  19270. })
  19271. return
  19272. }
  19273. var insutypes []string
  19274. var insutype string
  19275. var is390 int = 0
  19276. var is310 int = 0
  19277. for _, item := range res5.Output.Iinfo {
  19278. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19279. insutypes = append(insutypes, item.Insutype)
  19280. }
  19281. }
  19282. if len(insutypes) == 1 {
  19283. insutype = insutypes[0]
  19284. } else {
  19285. for _, i := range insutypes {
  19286. if i == "390" {
  19287. is390 = 1
  19288. }
  19289. if i == "310" {
  19290. is310 = 1
  19291. }
  19292. }
  19293. }
  19294. if is390 == 1 {
  19295. insutype = "390"
  19296. }
  19297. if is310 == 1 {
  19298. insutype = "310"
  19299. }
  19300. if len(insutypes) == 0 {
  19301. insutype = "310"
  19302. }
  19303. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19304. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19305. infoStr := string(Iinfos)
  19306. idetinfoStr := string(Idetinfos)
  19307. psn := &models.HisPsn{
  19308. PsnNo: res5.Output.Baseinfo.PsnNo,
  19309. PatientId: id,
  19310. Certno: res5.Output.Baseinfo.Certno,
  19311. Gend: res5.Output.Baseinfo.Gend,
  19312. Naty: res5.Output.Baseinfo.Naty,
  19313. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19314. PsnName: res5.Output.Baseinfo.PsnName,
  19315. Idetinfo: idetinfoStr,
  19316. Insuinfo: infoStr,
  19317. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19318. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19319. VerifyNumber: res2.Output.EcToken,
  19320. }
  19321. service.CreateHisPsn(psn)
  19322. if res2.Output.MdtrtCertType == "01" {
  19323. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19324. token := res2.Output.EcToken
  19325. 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)
  19326. } else if res2.Output.MdtrtCertType == "02" {
  19327. 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)
  19328. } else {
  19329. 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)
  19330. }
  19331. var dat2 map[string]interface{}
  19332. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19333. fmt.Println(dat2)
  19334. } else {
  19335. fmt.Println(err)
  19336. }
  19337. userJSONBytes3, _ := json.Marshal(dat2)
  19338. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19339. utils.ErrorLog("解析失败:%v", err)
  19340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19341. return
  19342. }
  19343. saveLog(result2, src_resquest, "2207", "结算")
  19344. } else {
  19345. c.ServeSuccessJSON(map[string]interface{}{
  19346. "failed_code": -10,
  19347. "msg": res2.ErrMsg,
  19348. })
  19349. return
  19350. }
  19351. } else if miConfig.MdtrtareaAdmvs == "421300" {
  19352. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19353. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19354. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19355. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19356. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19357. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19358. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19359. resp, requestErr := http.Get(api)
  19360. if requestErr != nil {
  19361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19362. return
  19363. }
  19364. body, ioErr := ioutil.ReadAll(resp.Body)
  19365. if ioErr != nil {
  19366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19368. return
  19369. }
  19370. var respJSON map[string]interface{}
  19371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19374. return
  19375. }
  19376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19377. result, _ := json.Marshal(respJSON)
  19378. fmt.Println("log")
  19379. fmt.Println(string(result))
  19380. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19381. utils.ErrorLog("解析失败:%v", err)
  19382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19383. return
  19384. }
  19385. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19386. if reg_type == 11 && his.Insutype == "390" {
  19387. reg_type = 110104
  19388. }
  19389. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19390. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19391. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19392. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19393. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19394. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19395. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19396. resp, requestErr := http.Get(api)
  19397. if requestErr != nil {
  19398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19399. return
  19400. }
  19401. body, ioErr := ioutil.ReadAll(resp.Body)
  19402. if ioErr != nil {
  19403. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19405. return
  19406. }
  19407. var respJSON map[string]interface{}
  19408. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19409. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19411. return
  19412. }
  19413. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19414. result, _ := json.Marshal(respJSON)
  19415. fmt.Println("log")
  19416. fmt.Println(string(result))
  19417. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19418. utils.ErrorLog("解析失败:%v", err)
  19419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19420. return
  19421. }
  19422. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19423. if reg_type == 11 && his.Insutype == "390" {
  19424. reg_type = 110104
  19425. }
  19426. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19427. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19428. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19429. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19430. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19431. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19432. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19433. resp, requestErr := http.Get(api)
  19434. if requestErr != nil {
  19435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19436. return
  19437. }
  19438. body, ioErr := ioutil.ReadAll(resp.Body)
  19439. if ioErr != nil {
  19440. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19442. return
  19443. }
  19444. var respJSON map[string]interface{}
  19445. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19446. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19448. return
  19449. }
  19450. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19451. result, _ := json.Marshal(respJSON)
  19452. fmt.Println("log")
  19453. fmt.Println(string(result))
  19454. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19455. utils.ErrorLog("解析失败:%v", err)
  19456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19457. return
  19458. }
  19459. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19460. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  19461. if result3101.Infcode == "0" {
  19462. if len(result3101.Output.Result) > 0 {
  19463. var errMsgs []string
  19464. for _, item := range result3101.Output.Result {
  19465. errMsgs = append(errMsgs, item.VolaCont)
  19466. }
  19467. c.ServeSuccessJSON(map[string]interface{}{
  19468. "failed_code": -10,
  19469. "msg": errMsgs,
  19470. })
  19471. return
  19472. } else {
  19473. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19474. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19475. bas := strings.Split(psn_info.CardInfo, "|")
  19476. if his.IdCardType == 1 {
  19477. cert_no = bas[2]
  19478. } else if his.IdCardType == 3 {
  19479. cert_no = his.Certno
  19480. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19481. } else if his.IdCardType == 4 {
  19482. cert_no = his.Certno
  19483. psn_info.VerifyNumber = psn_info.VerifyNumber
  19484. }
  19485. //江苏地区国家医保医疗类别
  19486. //职工透析:医疗类别选特殊情况门诊9933
  19487. //居民血透门慢: 医疗类别选门诊慢病1402
  19488. //var med_type string
  19489. //if his.Insutype == "310" {
  19490. // if reg_type == 14 {
  19491. // med_type = "9933"
  19492. // } else if reg_type == 11 {
  19493. // med_type = "11"
  19494. //
  19495. // }
  19496. //} else if his.Insutype == "390" {
  19497. // if reg_type == 14 {
  19498. // med_type = "1402"
  19499. // } else if reg_type == 11 {
  19500. // med_type = "11"
  19501. // }
  19502. //}
  19503. var api string
  19504. if miConfig.MdtrtareaAdmvs == "320921" {
  19505. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19506. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19507. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19509. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19510. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19511. "&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
  19512. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19513. } else {
  19514. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  19515. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19516. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19517. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19518. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19519. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19520. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19521. "&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
  19522. }
  19523. resp, requestErr := http.Get(api)
  19524. if requestErr != nil {
  19525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19526. return
  19527. }
  19528. body, ioErr := ioutil.ReadAll(resp.Body)
  19529. if ioErr != nil {
  19530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19532. return
  19533. }
  19534. var respJSON map[string]interface{}
  19535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19538. return
  19539. }
  19540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19541. result, _ := json.Marshal(respJSON)
  19542. fmt.Println("log")
  19543. fmt.Println(string(result))
  19544. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19545. utils.ErrorLog("解析失败:%v", err)
  19546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19547. return
  19548. }
  19549. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19550. res.Output = resSeven10265.Output
  19551. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19552. res.ErrMsg = resSeven10265.ErrMsg
  19553. res.Cainfo = resSeven10265.Cainfo
  19554. res.WarnMsg = resSeven10265.WarnMsg
  19555. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19556. res.Infcode = infocode
  19557. }
  19558. }
  19559. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19560. psn_info, _ := service.GetPsnByPatientId(id)
  19561. var verify_number string
  19562. if psn_info.IdCardType == 4 {
  19563. verify_number = psn_info.VerifyNumber
  19564. } else if psn_info.IdCardType == 1 {
  19565. bas := strings.Split(psn_info.CardInfo, "|")
  19566. cardNumber := bas[2]
  19567. verify_number = cardNumber
  19568. } else {
  19569. verify_number = psn_info.Certno
  19570. psn_info.IdCardType = 2
  19571. }
  19572. var api string
  19573. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19574. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19575. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19576. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19577. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19578. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19579. "&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
  19580. resp, requestErr := http.Get(api)
  19581. if requestErr != nil {
  19582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19583. return
  19584. }
  19585. body, ioErr := ioutil.ReadAll(resp.Body)
  19586. if ioErr != nil {
  19587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19589. return
  19590. }
  19591. var respJSON map[string]interface{}
  19592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19595. return
  19596. }
  19597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19598. result, _ := json.Marshal(respJSON)
  19599. fmt.Println("log")
  19600. fmt.Println(string(result))
  19601. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19602. utils.ErrorLog("解析失败:%v", err)
  19603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19604. return
  19605. }
  19606. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19607. res.Output = resSeven10265.Output
  19608. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19609. res.ErrMsg = resSeven10265.ErrMsg
  19610. res.Cainfo = resSeven10265.Cainfo
  19611. res.WarnMsg = resSeven10265.WarnMsg
  19612. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19613. res.Infcode = infocode
  19614. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19615. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19616. var cert_no string
  19617. if his.IdCardType == 1 {
  19618. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19619. } else {
  19620. cert_no = psn_info.VerifyNumber
  19621. }
  19622. 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)
  19623. var dat map[string]interface{}
  19624. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19625. fmt.Println(dat)
  19626. } else {
  19627. fmt.Println(err)
  19628. }
  19629. saveLog(result2, src_resquest, "2207", "结算")
  19630. userJSONBytes, _ := json.Marshal(dat)
  19631. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19632. utils.ErrorLog("解析失败:%v", err)
  19633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19634. return
  19635. }
  19636. } else if miConfig.MdtrtareaAdmvs == "360302" {
  19637. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19638. var cert_no string
  19639. var card_sn string
  19640. if his.IdCardType == 1 {
  19641. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19642. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19643. bas := strings.Split(psn_info.CardInfo, "|")
  19644. card_sn = bas[3]
  19645. } else if his.IdCardType == 2 {
  19646. cert_no = his.IdCardNo
  19647. } else {
  19648. cert_no = psn_info.VerifyNumber
  19649. }
  19650. var rf []*ResultFive
  19651. json.Unmarshal([]byte(his.Iinfo), &rf)
  19652. var psn_type string
  19653. for _, item := range rf {
  19654. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  19655. psn_type = item.PsnType
  19656. }
  19657. }
  19658. 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)
  19659. var dat map[string]interface{}
  19660. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19661. fmt.Println(dat)
  19662. } else {
  19663. fmt.Println(err)
  19664. }
  19665. saveLog(result2, src_resquest, "2207", "结算")
  19666. userJSONBytes, _ := json.Marshal(dat)
  19667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19668. utils.ErrorLog("解析失败:%v", err)
  19669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19670. return
  19671. }
  19672. } else if miConfig.MdtrtareaAdmvs == "341203" {
  19673. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19674. if his.IdCardType == 1 {
  19675. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19676. bas := strings.Split(psn_info.CardInfo, "|")
  19677. cert_no = bas[2]
  19678. } else if his.IdCardType == 3 {
  19679. cert_no = his.Certno
  19680. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19681. } else if his.IdCardType == 4 {
  19682. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19683. cert_no = his.Certno
  19684. psn_info.VerifyNumber = psn_info.VerifyNumber
  19685. } else {
  19686. cert_no = his.Certno
  19687. psn_info.VerifyNumber = his.Certno
  19688. }
  19689. var api string
  19690. var med_type string
  19691. if his.Insutype == "390" {
  19692. if reg_type == 992102 {
  19693. med_type = "992102"
  19694. }
  19695. if reg_type == 140104 {
  19696. med_type = "140104"
  19697. }
  19698. if reg_type == 14 {
  19699. med_type = "14"
  19700. }
  19701. } else if his.Insutype == "310" {
  19702. if reg_type == 992102 {
  19703. med_type = "992102"
  19704. }
  19705. if reg_type == 14 {
  19706. med_type = "14"
  19707. }
  19708. }
  19709. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19710. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19711. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19712. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19713. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19714. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19715. "&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
  19716. resp, requestErr := http.Get(api)
  19717. if requestErr != nil {
  19718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19719. return
  19720. }
  19721. body, ioErr := ioutil.ReadAll(resp.Body)
  19722. if ioErr != nil {
  19723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19725. return
  19726. }
  19727. var respJSON map[string]interface{}
  19728. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19731. return
  19732. }
  19733. status := respJSON["data"].(map[string]interface{})["status"].(string)
  19734. if status == "0" {
  19735. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  19736. c.ServeSuccessJSON(map[string]interface{}{
  19737. "failed_code": -10,
  19738. "msg": err_msg,
  19739. })
  19740. return
  19741. }
  19742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19743. result, _ := json.Marshal(respJSON)
  19744. fmt.Println("log")
  19745. fmt.Println(string(result))
  19746. if err := json.Unmarshal(result, &ahres); err != nil {
  19747. utils.ErrorLog("解析失败:%v", err)
  19748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19749. return
  19750. }
  19751. res.InfRefmsgid = ahres.InfRefmsgid
  19752. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  19753. // 创建对应的Time类型
  19754. t := time.UnixMilli(timestamp)
  19755. // 格式化成指定的日期字符串
  19756. str := t.Format("2006-01-02 15:04:05")
  19757. res.Output.Setlinfo.SetlTime = str
  19758. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  19759. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  19760. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19761. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  19762. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  19763. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  19764. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19765. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  19766. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  19767. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  19768. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  19769. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  19770. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  19771. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  19772. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  19773. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  19774. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  19775. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  19776. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  19777. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19778. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  19779. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  19780. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  19781. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  19782. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  19783. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  19784. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  19785. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  19786. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  19787. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  19788. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  19789. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  19790. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  19791. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  19792. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  19793. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  19794. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  19795. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  19796. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  19797. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  19798. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  19799. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  19800. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  19801. res.Output.Setldetail = ahres.Output.Setldetail
  19802. res.ErrMsg = ahres.ErrMsg
  19803. res.Cainfo = ahres.Cainfo
  19804. res.WarnMsg = ahres.WarnMsg
  19805. res.Infcode = ahres.Infcode
  19806. } else if miConfig.MdtrtareaAdmvs == "430800" {
  19807. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19808. var cert_no string
  19809. if his.IdCardType == 1 {
  19810. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19811. } else if his.IdCardType == 2 {
  19812. cert_no = his.IdCardNo
  19813. } else {
  19814. cert_no = psn_info.VerifyNumber
  19815. }
  19816. 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, "")
  19817. var dat map[string]interface{}
  19818. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19819. fmt.Println(dat)
  19820. } else {
  19821. fmt.Println(err)
  19822. }
  19823. saveLog(result2, src_resquest, "2207", "结算")
  19824. userJSONBytes, _ := json.Marshal(dat)
  19825. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19826. utils.ErrorLog("解析失败:%v", err)
  19827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19828. return
  19829. }
  19830. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19831. psn_info, _ := service.GetPsnByPatientId(id)
  19832. var verify_number string
  19833. if psn_info.IdCardType == 4 {
  19834. verify_number = psn_info.VerifyNumber
  19835. } else if psn_info.IdCardType == 1 {
  19836. bas := strings.Split(psn_info.CardInfo, "|")
  19837. cardNumber := bas[2]
  19838. verify_number = cardNumber
  19839. } else {
  19840. verify_number = psn_info.Certno
  19841. psn_info.IdCardType = 2
  19842. }
  19843. var api string
  19844. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19845. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19846. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19847. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19848. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  19849. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19850. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  19851. resp, requestErr := http.Get(api)
  19852. if requestErr != nil {
  19853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19854. return
  19855. }
  19856. body, ioErr := ioutil.ReadAll(resp.Body)
  19857. if ioErr != nil {
  19858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19860. return
  19861. }
  19862. var respJSON map[string]interface{}
  19863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19866. return
  19867. }
  19868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19869. result, _ := json.Marshal(respJSON)
  19870. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19871. utils.ErrorLog("解析失败:%v", err)
  19872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19873. return
  19874. }
  19875. } else {
  19876. var src_resquest string
  19877. if miConfig.Code == "H15049901371" {
  19878. //赤峰地区国家医保医疗类别
  19879. //职工透析:医疗类别选特殊情况门诊990502
  19880. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19881. var med_type string
  19882. if his.Insutype == "390" {
  19883. if reg_type == 14 {
  19884. med_type = "9933"
  19885. } else if reg_type == 11 {
  19886. med_type = "11"
  19887. }
  19888. } else if his.Insutype == "310" {
  19889. if reg_type == 14 {
  19890. med_type = "990502"
  19891. } else if reg_type == 11 {
  19892. med_type = "11"
  19893. }
  19894. }
  19895. 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)
  19896. } else {
  19897. if his.IdCardType == 4 {
  19898. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19899. token := psn_info.VerifyNumber
  19900. 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)
  19901. } else {
  19902. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, "", admin_user_id)
  19903. }
  19904. }
  19905. var dat map[string]interface{}
  19906. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19907. fmt.Println(dat)
  19908. } else {
  19909. fmt.Println(err)
  19910. }
  19911. saveLog(result2, src_resquest, "2207", "结算")
  19912. userJSONBytes, _ := json.Marshal(dat)
  19913. if miConfig.Code == "H15049901371" {
  19914. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19915. utils.ErrorLog("解析失败:%v", err)
  19916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19917. return
  19918. }
  19919. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19920. res.Output = resSeven10265.Output
  19921. res.ErrMsg = resSeven10265.ErrMsg
  19922. res.Cainfo = resSeven10265.Cainfo
  19923. res.WarnMsg = resSeven10265.WarnMsg
  19924. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19925. res.Infcode = infocode
  19926. } else {
  19927. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19928. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19929. utils.ErrorLog("解析失败:%v", err)
  19930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19931. return
  19932. }
  19933. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19934. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19935. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19936. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19937. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19938. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19939. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19940. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19941. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19942. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19943. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19944. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19945. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19946. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19947. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19948. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19949. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19950. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19951. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19952. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19953. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19954. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19955. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19956. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19957. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19958. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19959. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19960. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19961. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19962. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19963. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19964. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19965. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19966. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19967. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19968. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19969. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19970. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19971. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19972. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19973. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19974. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19975. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19976. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19977. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19978. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19979. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19980. res.Cainfo = gzresSeven10265Two.Cainfo
  19981. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19982. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19983. //res.Infcode = infocode
  19984. } else {
  19985. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19986. utils.ErrorLog("解析失败:%v", err)
  19987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19988. return
  19989. }
  19990. }
  19991. }
  19992. }
  19993. if res.Infcode != 0 {
  19994. errlog := &models.HisOrderError{
  19995. UserOrgId: adminUser.CurrentOrgId,
  19996. Ctime: time.Now().Unix(),
  19997. Mtime: time.Now().Unix(),
  19998. Number: chrg_bchno,
  19999. ErrMsg: res.ErrMsg,
  20000. Status: 1,
  20001. PatientId: id,
  20002. RecordTime: recordDateTime,
  20003. Stage: 6,
  20004. }
  20005. service.CreateErrMsgLog(errlog)
  20006. c.ServeSuccessJSON(map[string]interface{}{
  20007. "failed_code": -10,
  20008. "msg": res.ErrMsg,
  20009. })
  20010. return
  20011. } else {
  20012. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20013. order.OrderStatus = 2
  20014. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20015. order.SetlId = res.Output.Setlinfo.SetlID
  20016. order.PsnNo = res.Output.Setlinfo.PsnNo
  20017. order.PsnName = res.Output.Setlinfo.PsnName
  20018. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20019. order.Certno = res.Output.Setlinfo.Certno
  20020. order.Gend = res.Output.Setlinfo.Gend
  20021. order.Naty = res.Output.Setlinfo.Naty
  20022. order.Age = res.Output.Setlinfo.Age
  20023. order.Insutype = res.Output.Setlinfo.Insutype
  20024. order.PsnType = res.Output.Setlinfo.PsnType
  20025. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20026. order.SetlTime = res.Output.Setlinfo.SetlTime
  20027. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20028. order.PayWays = pay_ways
  20029. order.AcctUsedFlag = acct_used_flag
  20030. order.WechatPay = wechat_pay
  20031. order.AliPay = ali_pay
  20032. order.JifenPay = jifen_pay
  20033. order.BandCardPay = band_card_pay
  20034. order.CashPay = cash_pay
  20035. order.OthDesc = oth_desc
  20036. //order.MedType = res.Output.Setlinfo.MedType
  20037. if reg_type == 1112 {
  20038. order.MedType = "1112"
  20039. }
  20040. if reg_type == 1111 {
  20041. order.MedType = "1111"
  20042. }
  20043. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20044. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20045. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20046. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20047. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20048. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20049. order.HifpPay = res.Output.Setlinfo.HifpPay
  20050. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20051. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20052. order.HifesPay = res.Output.Setlinfo.HifesPay
  20053. order.HifobPay = res.Output.Setlinfo.HifobPay
  20054. order.MafPay = res.Output.Setlinfo.MafPay
  20055. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20056. order.OthPay = res.Output.Setlinfo.OthPay
  20057. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20058. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20059. order.AcctPay = res.Output.Setlinfo.AcctPay
  20060. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20061. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20062. order.Balc = res.Output.Setlinfo.Balc
  20063. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20064. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20065. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20066. order.ClrWay = res.Output.Setlinfo.ClrWay
  20067. order.Creator = order.Creator
  20068. order.ClrType = res.Output.Setlinfo.ClrType
  20069. order.Modify = roles.AdminUserId
  20070. order.RequestLog = src_resquest
  20071. order.Diagnosis = diagnosis_id
  20072. order.FaPiaoNumber = fapiao_number
  20073. order.FaPiaoCode = fapiao_code
  20074. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20075. detailStr := string(setlDetail)
  20076. order.SetlDetail = detailStr
  20077. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20078. err = service.UpDateOrder(order)
  20079. if err == nil {
  20080. //判断是否使用了押金
  20081. if dec_way == "true" {
  20082. tmpstring := strconv.FormatInt(order.ID, 10)
  20083. //扣押金
  20084. order.Decimal = decimal
  20085. service.UpDateOrder(order)
  20086. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20087. if errmsg != nil {
  20088. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20089. return
  20090. }
  20091. }
  20092. c.ServeSuccessJSON(map[string]interface{}{
  20093. "msg": "结算成功",
  20094. })
  20095. } else {
  20096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20097. return
  20098. }
  20099. }
  20100. }
  20101. }
  20102. }
  20103. // 上传明细-预结算-
  20104. func (c *HisApiController) GetPreUploadInfo() {
  20105. id, _ := c.GetInt64("id")
  20106. record_time := c.GetString("record_time")
  20107. his_patient_id, _ := c.GetInt64("his_patient_id")
  20108. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  20109. admin_user_id, _ := c.GetInt64("admin_user_id")
  20110. diagnosis_id := c.GetString("diagnosis")
  20111. sick_type, _ := c.GetInt64("sick_type")
  20112. reg_type, _ := c.GetInt64("p_type")
  20113. begin_time := c.GetString("begin_time")
  20114. acct_used_flag := c.GetString("acct_used_flag")
  20115. id_str := c.GetString("ids")
  20116. ids_arr := strings.Split(id_str, ",")
  20117. timeLayout := "2006-01-02"
  20118. loc, _ := time.LoadLocation("Local")
  20119. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  20120. if err != nil {
  20121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20122. return
  20123. }
  20124. recordDateTime := theTime.Unix()
  20125. adminUser := c.GetAdminUserInfo()
  20126. diagnosis_ids := strings.Split(diagnosis_id, ",")
  20127. var config []*models.HisXtDiagnoseConfig
  20128. for _, item := range diagnosis_ids {
  20129. id, _ := strconv.ParseInt(item, 10, 64)
  20130. diagnosisConfig, _ := service.FindDiagnoseById(id)
  20131. config = append(config, &diagnosisConfig)
  20132. }
  20133. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  20134. sickConfig, _ := service.FindSickById(sick_type)
  20135. var prescriptions []*models.HisPrescription
  20136. var start_time int64
  20137. var end_time int64
  20138. var isSuccess bool = true
  20139. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  20140. fmt.Println(his_patient_id)
  20141. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20142. timestamp := time.Now().Unix()
  20143. tempTime := time.Unix(timestamp, 0)
  20144. timeFormat := tempTime.Format("20060102150405")
  20145. chrgBchno := rand.Intn(100000) + 10000
  20146. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  20147. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20148. var patientPrescription models.HisPrescriptionInfo
  20149. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  20150. if patientPrescription.ID == 0 {
  20151. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  20152. }
  20153. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  20154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  20155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  20156. strconv.FormatInt(his.PatientId, 10)
  20157. var res2406 Result2406
  20158. //安徽单病种处理
  20159. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  20160. data := make(map[string]interface{})
  20161. client := &http.Client{}
  20162. data["psn_no"] = his.PsnNo
  20163. data["mdtrt_id"] = his.Number
  20164. data["operator"] = roles.UserName
  20165. data["cert_no"] = his.IdCardNo
  20166. data["org_name"] = miConfig.OrgName
  20167. data["psn_name"] = his.Name
  20168. data["ipt_otp_no"] = his.IptOtpNo
  20169. data["ipt_psn_sp_flag_type"] = "0901"
  20170. data["ipt_psn_sp_flag"] = "1"
  20171. data["fixmedins_code"] = miConfig.Code
  20172. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20173. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20174. data["url"] = miConfig.Url
  20175. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  20176. bytesData, _ := json.Marshal(data)
  20177. var req *http.Request
  20178. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  20179. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  20180. resp, _ := client.Do(req)
  20181. defer resp.Body.Close()
  20182. body, ioErr := ioutil.ReadAll(resp.Body)
  20183. if ioErr != nil {
  20184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20186. return
  20187. }
  20188. var respJSON map[string]interface{}
  20189. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20192. return
  20193. }
  20194. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20195. if status == "0" {
  20196. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20197. c.ServeSuccessJSON(map[string]interface{}{
  20198. "failed_code": -10,
  20199. "msg": err_msg,
  20200. })
  20201. return
  20202. }
  20203. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20204. userJSONBytes, _ := json.Marshal(respJSON)
  20205. fmt.Println("log")
  20206. fmt.Println(string(userJSONBytes))
  20207. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  20208. utils.ErrorLog("解析失败:%v", err)
  20209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20210. return
  20211. }
  20212. }
  20213. if res2406.Infcode != 0 {
  20214. adminUser := c.GetAdminUserInfo()
  20215. errlog := &models.HisOrderError{
  20216. UserOrgId: adminUser.CurrentOrgId,
  20217. Ctime: time.Now().Unix(),
  20218. Mtime: time.Now().Unix(),
  20219. ErrMsg: res2406.ErrMsg,
  20220. Status: 1,
  20221. PatientId: id,
  20222. RecordTime: recordDateTime,
  20223. Stage: 3,
  20224. }
  20225. service.CreateErrMsgLog(errlog)
  20226. c.ServeSuccessJSON(map[string]interface{}{
  20227. "failed_code": -10,
  20228. "msg": res2406.ErrMsg,
  20229. })
  20230. return
  20231. }
  20232. var res2 ResultSix
  20233. var res3 GZResultSix
  20234. var resSix10265 ResultSix10265
  20235. //var time_stamp string
  20236. if miConfig.MdtrtareaAdmvs == "421300" {
  20237. data := make(map[string]interface{})
  20238. client := &http.Client{}
  20239. data["psn_no"] = his.PsnNo
  20240. data["mdtrt_id"] = his.Number
  20241. data["department"] = department.Name
  20242. data["org_name"] = miConfig.OrgName
  20243. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20244. data["doctor_id"] = doctor_info.DoctorNumber
  20245. data["doctor_name"] = roles.UserName
  20246. data["fixmedins_code"] = miConfig.Code
  20247. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20248. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20249. data["secret_key"] = miConfig.SecretKey
  20250. data["sick_code"] = sickConfig.CountryCode
  20251. data["sick_name"] = sickConfig.ClassName
  20252. data["begin_time"] = begin_time
  20253. data["dept"] = strconv.FormatInt(department.ID, 10)
  20254. data["config"] = config
  20255. data["opter"] = roles.UserName
  20256. fmt.Println(data)
  20257. bytesData, _ := json.Marshal(data)
  20258. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20259. resp, _ := client.Do(req)
  20260. defer resp.Body.Close()
  20261. body, ioErr := ioutil.ReadAll(resp.Body)
  20262. if ioErr != nil {
  20263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20265. return
  20266. }
  20267. var respJSON map[string]interface{}
  20268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20271. return
  20272. }
  20273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20274. userJSONBytes, _ := json.Marshal(respJSON)
  20275. fmt.Println("log")
  20276. fmt.Println(string(userJSONBytes))
  20277. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20278. utils.ErrorLog("解析失败:%v", err)
  20279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20280. return
  20281. }
  20282. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20283. data := make(map[string]interface{})
  20284. client := &http.Client{}
  20285. data["psn_no"] = his.PsnNo
  20286. data["mdtrt_id"] = his.Number
  20287. data["department"] = department.Name
  20288. data["org_name"] = miConfig.OrgName
  20289. if reg_type == 11 && his.Insutype == "390" {
  20290. data["med_type"] = "110104"
  20291. } else {
  20292. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20293. }
  20294. data["doctor_id"] = doctor_info.DoctorNumber
  20295. data["doctor_name"] = roles.UserName
  20296. data["fixmedins_code"] = miConfig.Code
  20297. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20298. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20299. data["secret_key"] = miConfig.SecretKey
  20300. data["sick_code"] = sickConfig.CountryCode
  20301. data["sick_name"] = sickConfig.ClassName
  20302. data["begin_time"] = begin_time
  20303. data["dept"] = strconv.FormatInt(department.ID, 10)
  20304. data["config"] = config
  20305. data["opter"] = roles.UserName
  20306. fmt.Println(data)
  20307. bytesData, _ := json.Marshal(data)
  20308. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  20309. resp, _ := client.Do(req)
  20310. defer resp.Body.Close()
  20311. body, ioErr := ioutil.ReadAll(resp.Body)
  20312. if ioErr != nil {
  20313. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20315. return
  20316. }
  20317. var respJSON map[string]interface{}
  20318. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20319. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20321. return
  20322. }
  20323. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20324. userJSONBytes, _ := json.Marshal(respJSON)
  20325. fmt.Println("log")
  20326. fmt.Println(string(userJSONBytes))
  20327. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20328. utils.ErrorLog("解析失败:%v", err)
  20329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20330. return
  20331. }
  20332. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20333. data := make(map[string]interface{})
  20334. client := &http.Client{}
  20335. data["psn_no"] = his.PsnNo
  20336. data["mdtrt_id"] = his.Number
  20337. data["department"] = department.Name
  20338. data["org_name"] = miConfig.OrgName
  20339. if reg_type == 11 && his.Insutype == "390" {
  20340. data["med_type"] = "110104"
  20341. } else {
  20342. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20343. }
  20344. data["doctor_id"] = doctor_info.DoctorNumber
  20345. data["doctor_name"] = roles.UserName
  20346. data["fixmedins_code"] = miConfig.Code
  20347. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20348. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20349. data["secret_key"] = miConfig.SecretKey
  20350. data["sick_code"] = sickConfig.CountryCode
  20351. data["sick_name"] = sickConfig.ClassName
  20352. data["begin_time"] = begin_time
  20353. data["dept"] = strconv.FormatInt(department.ID, 10)
  20354. data["config"] = config
  20355. data["opter"] = roles.UserName
  20356. fmt.Println(data)
  20357. bytesData, _ := json.Marshal(data)
  20358. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  20359. resp, _ := client.Do(req)
  20360. defer resp.Body.Close()
  20361. body, ioErr := ioutil.ReadAll(resp.Body)
  20362. if ioErr != nil {
  20363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20365. return
  20366. }
  20367. var respJSON map[string]interface{}
  20368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20371. return
  20372. }
  20373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20374. userJSONBytes, _ := json.Marshal(respJSON)
  20375. fmt.Println("log")
  20376. fmt.Println(string(userJSONBytes))
  20377. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20378. utils.ErrorLog("解析失败:%v", err)
  20379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20380. return
  20381. }
  20382. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20383. data := make(map[string]interface{})
  20384. client := &http.Client{}
  20385. data["psn_no"] = his.PsnNo
  20386. data["mdtrt_id"] = his.Number
  20387. data["doctor"] = roles.UserName
  20388. data["department"] = department.Name
  20389. data["org_name"] = miConfig.OrgName
  20390. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20391. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20392. data["fixmedins_code"] = miConfig.Code
  20393. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20394. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20395. data["secret_key"] = miConfig.SecretKey
  20396. data["sick_code"] = sickConfig.CountryCode
  20397. data["sick_name"] = sickConfig.ClassName
  20398. data["begin_time"] = begin_time
  20399. data["dept"] = strconv.FormatInt(department.ID, 10)
  20400. data["config"] = config
  20401. data["url"] = miConfig.Url
  20402. data["ak"] = miConfig.AccessKey
  20403. data["cainfo"] = miConfig.Cainfo
  20404. bytesData, _ := json.Marshal(data)
  20405. var req *http.Request
  20406. if miConfig.MdtrtareaAdmvs == "320921" {
  20407. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20408. } else {
  20409. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  20410. }
  20411. resp, _ := client.Do(req)
  20412. defer resp.Body.Close()
  20413. body, ioErr := ioutil.ReadAll(resp.Body)
  20414. if ioErr != nil {
  20415. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20417. return
  20418. }
  20419. var respJSON map[string]interface{}
  20420. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20421. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20423. return
  20424. }
  20425. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20426. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20427. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20428. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20429. userJSONBytes, _ := json.Marshal(respJSON)
  20430. fmt.Println("log")
  20431. fmt.Println(string(userJSONBytes))
  20432. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20433. utils.ErrorLog("解析失败:%v", err)
  20434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20435. return
  20436. }
  20437. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20438. res2.Output = resSix10265.Output
  20439. res2.ErrMsg = resSix10265.ErrMsg
  20440. res2.Cainfo = resSix10265.Cainfo
  20441. res2.WarnMsg = resSix10265.WarnMsg
  20442. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20443. res2.Infcode = infocode
  20444. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20445. data := make(map[string]interface{})
  20446. client := &http.Client{}
  20447. data["psn_no"] = his.PsnNo
  20448. data["mdtrt_id"] = his.Number
  20449. data["doctor"] = roles.UserName
  20450. data["department"] = department.Name
  20451. data["org_name"] = miConfig.OrgName
  20452. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20453. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  20454. data["fixmedins_code"] = miConfig.Code
  20455. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20456. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20457. data["secret_key"] = miConfig.SecretKey
  20458. data["sick_code"] = sickConfig.CountryCode
  20459. data["sick_name"] = sickConfig.ClassName
  20460. data["begin_time"] = begin_time
  20461. data["dept"] = strconv.FormatInt(department.ID, 10)
  20462. data["config"] = config
  20463. //data["url"] = miConfig.Url
  20464. //data["ak"] = miConfig.AccessKey
  20465. data["cainfo"] = miConfig.Cainfo
  20466. fmt.Println(data)
  20467. bytesData, _ := json.Marshal(data)
  20468. var req *http.Request
  20469. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  20470. resp, _ := client.Do(req)
  20471. defer resp.Body.Close()
  20472. body, ioErr := ioutil.ReadAll(resp.Body)
  20473. if ioErr != nil {
  20474. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20476. return
  20477. }
  20478. var respJSON map[string]interface{}
  20479. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20480. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20482. return
  20483. }
  20484. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  20485. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  20486. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  20487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20488. userJSONBytes, _ := json.Marshal(respJSON)
  20489. fmt.Println("log")
  20490. fmt.Println(string(userJSONBytes))
  20491. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  20492. utils.ErrorLog("解析失败:%v", err)
  20493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20494. return
  20495. }
  20496. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20497. res2.Output = resSix10265.Output
  20498. res2.ErrMsg = resSix10265.ErrMsg
  20499. res2.Cainfo = resSix10265.Cainfo
  20500. res2.WarnMsg = resSix10265.WarnMsg
  20501. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20502. res2.Infcode = infocode
  20503. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20504. 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)
  20505. saveLog(result, requestLog, "2203", "上传就诊信息")
  20506. var respJSON2 map[string]interface{}
  20507. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20510. return
  20511. }
  20512. userJSONBytes2, _ := json.Marshal(respJSON2)
  20513. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20514. utils.ErrorLog("解析失败:%v", err)
  20515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20516. return
  20517. }
  20518. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20519. var result string
  20520. var requestLog string
  20521. 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, "")
  20522. saveLog(result, requestLog, "2203", "上传就诊信息")
  20523. var respJSON2 map[string]interface{}
  20524. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20527. return
  20528. }
  20529. userJSONBytes2, _ := json.Marshal(respJSON2)
  20530. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20531. utils.ErrorLog("解析失败:%v", err)
  20532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20533. return
  20534. }
  20535. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20536. data := make(map[string]interface{})
  20537. client := &http.Client{}
  20538. data["psn_no"] = his.PsnNo
  20539. data["mdtrt_id"] = his.Number
  20540. data["operator"] = roles.UserName
  20541. data["department"] = department.Name
  20542. data["org_name"] = miConfig.OrgName
  20543. var med_type string
  20544. if his.Insutype == "390" {
  20545. if reg_type == 992102 {
  20546. med_type = "992102"
  20547. data["sick_code"] = "ZDZ940"
  20548. data["sick_name"] = "慢性肾衰竭"
  20549. }
  20550. if reg_type == 140104 {
  20551. med_type = "140104"
  20552. data["sick_code"] = sickConfig.CountryCode
  20553. data["sick_name"] = sickConfig.ClassName
  20554. }
  20555. if reg_type == 14 {
  20556. med_type = "140104"
  20557. data["sick_code"] = sickConfig.CountryCode
  20558. data["sick_name"] = sickConfig.ClassName
  20559. }
  20560. } else if his.Insutype == "310" {
  20561. if reg_type == 992102 {
  20562. med_type = "992102"
  20563. data["sick_code"] = "ZDZ940"
  20564. data["sick_name"] = "慢性肾衰竭"
  20565. }
  20566. if reg_type == 140104 {
  20567. med_type = "140104"
  20568. data["sick_code"] = sickConfig.CountryCode
  20569. data["sick_name"] = sickConfig.ClassName
  20570. }
  20571. if reg_type == 14 {
  20572. med_type = "14"
  20573. data["sick_code"] = sickConfig.CountryCode
  20574. data["sick_name"] = sickConfig.ClassName
  20575. }
  20576. }
  20577. data["med_type"] = med_type
  20578. data["doctor_number"] = doctor_info.DoctorNumber
  20579. data["doctor_name"] = doctor_info.UserName
  20580. data["fixmedins_code"] = miConfig.Code
  20581. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20582. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20583. data["secret_key"] = miConfig.SecretKey
  20584. data["begin_time"] = begin_time
  20585. data["dept"] = strconv.FormatInt(department.ID, 10)
  20586. data["config"] = config
  20587. data["url"] = miConfig.Url
  20588. data["ak"] = miConfig.AccessKey
  20589. data["cainfo"] = miConfig.Cainfo
  20590. bytesData, _ := json.Marshal(data)
  20591. var req *http.Request
  20592. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  20593. resp, _ := client.Do(req)
  20594. defer resp.Body.Close()
  20595. body, ioErr := ioutil.ReadAll(resp.Body)
  20596. if ioErr != nil {
  20597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20599. return
  20600. }
  20601. var respJSON map[string]interface{}
  20602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20605. return
  20606. }
  20607. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20608. if status == "0" {
  20609. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20610. c.ServeSuccessJSON(map[string]interface{}{
  20611. "failed_code": -10,
  20612. "msg": err_msg,
  20613. })
  20614. return
  20615. }
  20616. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20617. userJSONBytes, _ := json.Marshal(respJSON)
  20618. fmt.Println("log")
  20619. fmt.Println(string(userJSONBytes))
  20620. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20621. utils.ErrorLog("解析失败:%v", err)
  20622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20623. return
  20624. }
  20625. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20626. var result string
  20627. var requestLog string
  20628. 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, "")
  20629. saveLog(result, requestLog, "2203", "上传就诊信息")
  20630. var respJSON2 map[string]interface{}
  20631. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20634. return
  20635. }
  20636. userJSONBytes2, _ := json.Marshal(respJSON2)
  20637. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20638. utils.ErrorLog("解析失败:%v", err)
  20639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20640. return
  20641. }
  20642. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20643. data := make(map[string]interface{})
  20644. client := &http.Client{}
  20645. data["psn_no"] = his.PsnNo
  20646. data["mdtrt_id"] = his.Number
  20647. data["doctor"] = roles.UserName
  20648. data["department"] = department.Name
  20649. data["org_name"] = miConfig.OrgName
  20650. data["med_type"] = strconv.FormatInt(reg_type, 10)
  20651. data["doctor_id"] = doctor_info.DoctorNumber
  20652. data["fixmedins_code"] = miConfig.Code
  20653. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20654. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20655. data["secret_key"] = miConfig.SecretKey
  20656. data["sick_code"] = sickConfig.CountryCode
  20657. data["sick_name"] = sickConfig.ClassName
  20658. data["begin_time"] = begin_time
  20659. data["new_doctor_name"] = doctor_info.UserName
  20660. data["dept"] = strconv.FormatInt(department.ID, 10)
  20661. data["config"] = config
  20662. bytesData, _ := json.Marshal(data)
  20663. var req *http.Request
  20664. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  20665. resp, _ := client.Do(req)
  20666. defer resp.Body.Close()
  20667. body, ioErr := ioutil.ReadAll(resp.Body)
  20668. if ioErr != nil {
  20669. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20671. return
  20672. }
  20673. var respJSON map[string]interface{}
  20674. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20675. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20677. return
  20678. }
  20679. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20680. userJSONBytes, _ := json.Marshal(respJSON)
  20681. fmt.Println("log")
  20682. fmt.Println(string(userJSONBytes))
  20683. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  20684. utils.ErrorLog("解析失败:%v", err)
  20685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20686. return
  20687. }
  20688. } else {
  20689. var result string
  20690. var requestLog string
  20691. if miConfig.MdtrtareaAdmvs == "440781" { //
  20692. 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)
  20693. } else {
  20694. if miConfig.Code == "H15049901371" {
  20695. //赤峰地区国家医保医疗类别
  20696. //职工透析:医疗类别选特殊情况门诊990502
  20697. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20698. var med_type string
  20699. if his.Insutype == "390" {
  20700. if reg_type == 14 {
  20701. med_type = "9933"
  20702. } else if reg_type == 11 {
  20703. med_type = "11"
  20704. }
  20705. } else if his.Insutype == "310" {
  20706. if reg_type == 14 {
  20707. med_type = "990502"
  20708. } else if reg_type == 11 {
  20709. med_type = "11"
  20710. }
  20711. }
  20712. 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)
  20713. } else {
  20714. 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)
  20715. }
  20716. saveLog(result, requestLog, "2203", "上传就诊信息")
  20717. var respJSON2 map[string]interface{}
  20718. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  20719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20721. return
  20722. }
  20723. userJSONBytes2, _ := json.Marshal(respJSON2)
  20724. if miConfig.Code == "H15049901371" {
  20725. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  20726. utils.ErrorLog("解析失败:%v", err)
  20727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20728. return
  20729. }
  20730. res2.InfRefmsgid = resSix10265.InfRefmsgid
  20731. res2.Output = resSix10265.Output
  20732. res2.ErrMsg = resSix10265.ErrMsg
  20733. res2.Cainfo = resSix10265.Cainfo
  20734. res2.WarnMsg = resSix10265.WarnMsg
  20735. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  20736. res2.Infcode = infocode
  20737. } else {
  20738. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20739. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  20740. utils.ErrorLog("解析失败:%v", err)
  20741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20742. return
  20743. }
  20744. res2.Infcode = res3.Infcode
  20745. } else {
  20746. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  20747. utils.ErrorLog("解析失败:%v", err)
  20748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20749. return
  20750. }
  20751. }
  20752. }
  20753. }
  20754. }
  20755. if res2.Infcode == -1 {
  20756. adminUser := c.GetAdminUserInfo()
  20757. errlog := &models.HisOrderError{
  20758. UserOrgId: adminUser.CurrentOrgId,
  20759. Ctime: time.Now().Unix(),
  20760. Mtime: time.Now().Unix(),
  20761. ErrMsg: res2.ErrMsg,
  20762. Status: 1,
  20763. PatientId: id,
  20764. RecordTime: recordDateTime,
  20765. Stage: 3,
  20766. }
  20767. service.CreateErrMsgLog(errlog)
  20768. c.ServeSuccessJSON(map[string]interface{}{
  20769. "failed_code": -10,
  20770. "msg": res2.ErrMsg,
  20771. })
  20772. return
  20773. }
  20774. if res2.Infcode != 0 {
  20775. adminUser := c.GetAdminUserInfo()
  20776. errlog := &models.HisOrderError{
  20777. UserOrgId: adminUser.CurrentOrgId,
  20778. Ctime: time.Now().Unix(),
  20779. Mtime: time.Now().Unix(),
  20780. ErrMsg: res2.ErrMsg,
  20781. Status: 1,
  20782. PatientId: id,
  20783. RecordTime: recordDateTime,
  20784. Stage: 3,
  20785. }
  20786. service.CreateErrMsgLog(errlog)
  20787. c.ServeSuccessJSON(map[string]interface{}{
  20788. "failed_code": -10,
  20789. "msg": res2.ErrMsg,
  20790. })
  20791. return
  20792. } else {
  20793. his.Diagnosis = diagnosis_id
  20794. his.SickType = sickConfig.ID
  20795. his.PType = fmt.Sprintf("%d", reg_type)
  20796. service.UpdateHisPatientThree(&his)
  20797. data := make(map[string]interface{})
  20798. if settle_accounts_type == 1 { //日结
  20799. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  20800. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  20801. } else {
  20802. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  20803. }
  20804. data["pre"] = prescriptions
  20805. } else { //月结
  20806. start_time_str := c.GetString("start_time")
  20807. end_time_str := c.GetString("end_time")
  20808. timeLayout := "2006-01-02"
  20809. loc, _ := time.LoadLocation("Local")
  20810. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  20811. if err != nil {
  20812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20813. return
  20814. }
  20815. recordStartTime := theStartTime.Unix()
  20816. start_time = recordStartTime
  20817. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  20818. if err != nil {
  20819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  20820. return
  20821. }
  20822. recordEndTime := theEndTime.Unix()
  20823. end_time = recordEndTime
  20824. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  20825. data["pre"] = prescriptions
  20826. }
  20827. client := &http.Client{}
  20828. data["psn_no"] = his.PsnNo
  20829. data["mdtrt_id"] = his.Number
  20830. data["chrg_bchno"] = chrg_bchno
  20831. data["org_name"] = miConfig.OrgName
  20832. data["doctor"] = doctor_info.UserName
  20833. data["doctor_id"] = doctor_info.DoctorNumber
  20834. data["dept"] = department.Name
  20835. data["fixmedins_code"] = miConfig.Code
  20836. data["opter"] = roles.UserName
  20837. data["dept_code"] = department.Number
  20838. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  20839. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  20840. data["secret_key"] = miConfig.SecretKey
  20841. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  20842. data["url"] = miConfig.Url
  20843. data["ak"] = miConfig.AccessKey
  20844. data["new_doctor_name"] = patientPrescription.Doctor
  20845. if his.Insutype == "390" {
  20846. if reg_type == 992102 {
  20847. data["diag_code"] = "ZDZ940"
  20848. }
  20849. if reg_type == 140104 {
  20850. data["diag_code"] = sickConfig.CountryCode
  20851. }
  20852. if reg_type == 14 {
  20853. data["diag_code"] = sickConfig.CountryCode
  20854. }
  20855. } else if his.Insutype == "310" {
  20856. if reg_type == 992102 {
  20857. data["diag_code"] = "ZDZ940"
  20858. }
  20859. if reg_type == 14 {
  20860. data["diag_code"] = sickConfig.CountryCode
  20861. }
  20862. }
  20863. data["cainfo"] = miConfig.Cainfo
  20864. data["opter"] = roles.UserName
  20865. var ids []int64
  20866. for _, item := range prescriptions {
  20867. ids = append(ids, item.ID)
  20868. }
  20869. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  20870. if config.IsOpen == 1 { //对接了医保,走医保流程
  20871. var res ResultFour
  20872. var resFour10265 ResultFour10265
  20873. if miConfig.MdtrtareaAdmvs == "421300" {
  20874. bytesData, _ := json.Marshal(data)
  20875. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20876. resp, _ := client.Do(req)
  20877. defer resp.Body.Close()
  20878. body, ioErr := ioutil.ReadAll(resp.Body)
  20879. if ioErr != nil {
  20880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20882. return
  20883. }
  20884. var respJSON map[string]interface{}
  20885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20888. return
  20889. }
  20890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20891. userJSONBytes, _ := json.Marshal(respJSON)
  20892. fmt.Println("log")
  20893. fmt.Println(string(userJSONBytes))
  20894. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20895. utils.ErrorLog("解析失败:%v", err)
  20896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20897. return
  20898. }
  20899. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20900. bytesData, _ := json.Marshal(data)
  20901. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  20902. resp, _ := client.Do(req)
  20903. defer resp.Body.Close()
  20904. body, ioErr := ioutil.ReadAll(resp.Body)
  20905. if ioErr != nil {
  20906. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20908. return
  20909. }
  20910. var respJSON map[string]interface{}
  20911. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20912. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20914. return
  20915. }
  20916. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20917. userJSONBytes, _ := json.Marshal(respJSON)
  20918. fmt.Println("log")
  20919. fmt.Println(string(userJSONBytes))
  20920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20921. utils.ErrorLog("解析失败:%v", err)
  20922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20923. return
  20924. }
  20925. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20926. bytesData, _ := json.Marshal(data)
  20927. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  20928. resp, _ := client.Do(req)
  20929. defer resp.Body.Close()
  20930. body, ioErr := ioutil.ReadAll(resp.Body)
  20931. if ioErr != nil {
  20932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20934. return
  20935. }
  20936. var respJSON map[string]interface{}
  20937. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20940. return
  20941. }
  20942. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20943. userJSONBytes, _ := json.Marshal(respJSON)
  20944. fmt.Println("log")
  20945. fmt.Println(string(userJSONBytes))
  20946. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20947. utils.ErrorLog("解析失败:%v", err)
  20948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20949. return
  20950. }
  20951. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20952. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  20953. if result3101.Infcode == "0" {
  20954. if len(result3101.Output.Result) > 0 {
  20955. var errMsgs []string
  20956. for _, item := range result3101.Output.Result {
  20957. errMsgs = append(errMsgs, item.VolaCont)
  20958. }
  20959. c.ServeSuccessJSON(map[string]interface{}{
  20960. "failed_code": -10,
  20961. "msg": errMsgs,
  20962. })
  20963. return
  20964. } else {
  20965. if miConfig.MdtrtareaAdmvs == "320921" {
  20966. data["doctor_id"] = "D320923012139"
  20967. } else {
  20968. data["doctor_id"] = "D371621008686"
  20969. }
  20970. bytesData, _ := json.Marshal(data)
  20971. var req *http.Request
  20972. if miConfig.MdtrtareaAdmvs == "320921" {
  20973. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20974. } else {
  20975. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20976. }
  20977. resp, _ := client.Do(req)
  20978. defer resp.Body.Close()
  20979. body, ioErr := ioutil.ReadAll(resp.Body)
  20980. if ioErr != nil {
  20981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20983. return
  20984. }
  20985. var respJSON map[string]interface{}
  20986. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  20987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20989. return
  20990. }
  20991. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20992. userJSONBytes, _ := json.Marshal(respJSON)
  20993. fmt.Println("log")
  20994. fmt.Println(string(userJSONBytes))
  20995. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  20996. utils.ErrorLog("解析失败:%v", err)
  20997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20998. return
  20999. }
  21000. res.InfRefmsgid = resFour10265.InfRefmsgid
  21001. res.Output = resFour10265.Output
  21002. res.ErrMsg = resFour10265.ErrMsg
  21003. res.Cainfo = resFour10265.Cainfo
  21004. res.WarnMsg = resFour10265.WarnMsg
  21005. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21006. res.Infcode = infocode
  21007. }
  21008. }
  21009. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21010. var pagesize int = 5
  21011. var start int = 1
  21012. var stop int
  21013. var pagecount int
  21014. var curpage int
  21015. data["doctor_id"] = doctor_info.DoctorNumber
  21016. var res2 ResultFour
  21017. //var result res.
  21018. //总页数,向上取整,注意除之前要先转换类型为float64
  21019. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  21020. for curpage = 1; curpage <= pagecount; curpage++ {
  21021. if curpage == 1 {
  21022. start = 1
  21023. } else {
  21024. start = (curpage-1)*pagesize + 1
  21025. }
  21026. stop = curpage * pagesize
  21027. if stop > len(prescriptions) {
  21028. stop = len(prescriptions)
  21029. }
  21030. //var requestLog string
  21031. data["pre"] = prescriptions[start-1 : stop]
  21032. fmt.Println(data["pre"])
  21033. bytesData, _ := json.Marshal(data)
  21034. var req *http.Request
  21035. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  21036. resp, _ := client.Do(req)
  21037. defer resp.Body.Close()
  21038. body, ioErr := ioutil.ReadAll(resp.Body)
  21039. if ioErr != nil {
  21040. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21042. return
  21043. }
  21044. var respJSON map[string]interface{}
  21045. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21048. return
  21049. }
  21050. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21051. userJSONBytes, _ := json.Marshal(respJSON)
  21052. fmt.Println("log")
  21053. fmt.Println(string(userJSONBytes))
  21054. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21055. utils.ErrorLog("解析失败:%v", err)
  21056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21057. return
  21058. }
  21059. res.InfRefmsgid = resFour10265.InfRefmsgid
  21060. res.Output = resFour10265.Output
  21061. res.ErrMsg = resFour10265.ErrMsg
  21062. res.Cainfo = resFour10265.Cainfo
  21063. res.WarnMsg = resFour10265.WarnMsg
  21064. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21065. res.Infcode = infocode
  21066. if infocode == 0 {
  21067. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  21068. } else {
  21069. isSuccess = false
  21070. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  21071. res.Infcode = -1
  21072. res.ErrMsg = resFour10265.ErrMsg
  21073. errlog := &models.HisOrderError{
  21074. UserOrgId: adminUser.CurrentOrgId,
  21075. Ctime: time.Now().Unix(),
  21076. Mtime: time.Now().Unix(),
  21077. Number: chrg_bchno,
  21078. ErrMsg: "",
  21079. Status: 1,
  21080. PatientId: id,
  21081. RecordTime: recordDateTime,
  21082. Stage: 4,
  21083. }
  21084. service.CreateErrMsgLog(errlog)
  21085. }
  21086. }
  21087. if isSuccess {
  21088. res.Infcode = 0
  21089. res.Output.Result = res2.Output.Result
  21090. } else {
  21091. order := &models.HisOrder{
  21092. UserOrgId: adminUser.CurrentOrgId,
  21093. HisPatientId: his.ID,
  21094. PatientId: his.PatientId,
  21095. SettleAccountsDate: recordDateTime,
  21096. Ctime: time.Now().Unix(),
  21097. Mtime: time.Now().Unix(),
  21098. MdtrtId: his.Number,
  21099. PsnNo: his.PsnNo,
  21100. MedType: strconv.FormatInt(reg_type, 10),
  21101. Status: 1,
  21102. Number: chrg_bchno,
  21103. Infcode: res.Infcode,
  21104. WarnMsg: res.WarnMsg,
  21105. Cainfo: res.Cainfo,
  21106. ErrMsg: res.ErrMsg,
  21107. RespondTime: res.RefmsgTime,
  21108. InfRefmsgid: res.InfRefmsgid,
  21109. OrderStatus: 1,
  21110. IsMedicineInsurance: 1,
  21111. SettleType: settle_accounts_type,
  21112. SettleStartTime: start_time,
  21113. SettleEndTime: end_time,
  21114. Creator: roles.AdminUserId,
  21115. Modify: roles.AdminUserId,
  21116. PType: 2,
  21117. Diagnosis: diagnosis_id,
  21118. }
  21119. err = service.CreateOrder(order)
  21120. if err != nil {
  21121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21122. return
  21123. }
  21124. c.ServeSuccessJSON(map[string]interface{}{
  21125. "failed_code": -10,
  21126. "msg": res2.ErrMsg,
  21127. })
  21128. return
  21129. }
  21130. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21131. 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)
  21132. var dat map[string]interface{}
  21133. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21134. fmt.Println(dat)
  21135. } else {
  21136. fmt.Println(err)
  21137. }
  21138. saveLog(result, request_log, "2204", "上传费用明细")
  21139. userJSONBytes, _ := json.Marshal(dat)
  21140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21141. utils.ErrorLog("解析失败:%v", err)
  21142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21143. return
  21144. }
  21145. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21146. 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, "", "")
  21147. var dat map[string]interface{}
  21148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21149. fmt.Println(dat)
  21150. } else {
  21151. fmt.Println(err)
  21152. }
  21153. saveLog(result, request_log, "2204", "上传费用明细")
  21154. userJSONBytes, _ := json.Marshal(dat)
  21155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21156. utils.ErrorLog("解析失败:%v", err)
  21157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21158. return
  21159. }
  21160. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21161. bytesData, _ := json.Marshal(data)
  21162. var req *http.Request
  21163. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  21164. resp, _ := client.Do(req)
  21165. defer resp.Body.Close()
  21166. body, ioErr := ioutil.ReadAll(resp.Body)
  21167. if ioErr != nil {
  21168. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21170. return
  21171. }
  21172. var respJSON map[string]interface{}
  21173. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21174. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21176. return
  21177. }
  21178. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21179. if status == "0" {
  21180. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21181. c.ServeSuccessJSON(map[string]interface{}{
  21182. "failed_code": -10,
  21183. "msg": err_msg,
  21184. })
  21185. return
  21186. }
  21187. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21188. userJSONBytes, _ := json.Marshal(respJSON)
  21189. fmt.Println("log")
  21190. fmt.Println(string(userJSONBytes))
  21191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21192. utils.ErrorLog("解析失败:%v", err)
  21193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21194. return
  21195. }
  21196. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21197. 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, "", "")
  21198. var dat map[string]interface{}
  21199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21200. fmt.Println(dat)
  21201. } else {
  21202. fmt.Println(err)
  21203. }
  21204. saveLog(result, request_log, "2204", "上传费用明细")
  21205. userJSONBytes, _ := json.Marshal(dat)
  21206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21207. utils.ErrorLog("解析失败:%v", err)
  21208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21209. return
  21210. }
  21211. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21212. bytesData, _ := json.Marshal(data)
  21213. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  21214. resp, _ := client.Do(req)
  21215. defer resp.Body.Close()
  21216. body, ioErr := ioutil.ReadAll(resp.Body)
  21217. if ioErr != nil {
  21218. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21220. return
  21221. }
  21222. var respJSON map[string]interface{}
  21223. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21224. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  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, &res); err != nil {
  21233. utils.ErrorLog("解析失败:%v", err)
  21234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21235. return
  21236. }
  21237. } else {
  21238. if miConfig.MdtrtareaAdmvs == "441202" {
  21239. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21240. if result3101.Infcode == 0 {
  21241. if len(result3101.Output.Result) > 0 {
  21242. var errMsgs []string
  21243. for _, item := range result3101.Output.Result {
  21244. errMsgs = append(errMsgs, item.VolaCont)
  21245. }
  21246. c.ServeSuccessJSON(map[string]interface{}{
  21247. "failed_code": -10,
  21248. "msg": errMsgs,
  21249. })
  21250. return
  21251. } else {
  21252. 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)
  21253. var dat map[string]interface{}
  21254. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21255. fmt.Println(dat)
  21256. } else {
  21257. fmt.Println(err)
  21258. }
  21259. saveLog(result, request_log, "2204", "上传费用明细")
  21260. userJSONBytes, _ := json.Marshal(dat)
  21261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21262. utils.ErrorLog("解析失败:%v", err)
  21263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21264. return
  21265. }
  21266. }
  21267. } else {
  21268. c.ServeSuccessJSON(map[string]interface{}{
  21269. "failed_code": -10,
  21270. "msg": result3101.ErrMsg,
  21271. })
  21272. return
  21273. }
  21274. } else {
  21275. if miConfig.Code == "H15049901371" {
  21276. 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)
  21277. var dat map[string]interface{}
  21278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21279. fmt.Println(dat)
  21280. } else {
  21281. fmt.Println(err)
  21282. }
  21283. saveLog(result, request_log, "2204", "上传费用明细")
  21284. userJSONBytes, _ := json.Marshal(dat)
  21285. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  21286. utils.ErrorLog("解析失败:%v", err)
  21287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21288. return
  21289. }
  21290. res.InfRefmsgid = resFour10265.InfRefmsgid
  21291. res.Output = resFour10265.Output
  21292. res.ErrMsg = resFour10265.ErrMsg
  21293. res.Cainfo = resFour10265.Cainfo
  21294. res.WarnMsg = resFour10265.WarnMsg
  21295. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  21296. res.Infcode = infocode
  21297. } else {
  21298. 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)
  21299. var dat map[string]interface{}
  21300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21301. fmt.Println(dat)
  21302. } else {
  21303. fmt.Println(err)
  21304. }
  21305. saveLog(result, request_log, "2204", "上传费用明细")
  21306. userJSONBytes, _ := json.Marshal(dat)
  21307. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21308. utils.ErrorLog("解析失败:%v", err)
  21309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21310. return
  21311. }
  21312. }
  21313. }
  21314. }
  21315. var total_two float64
  21316. if res.Infcode == 0 {
  21317. order := &models.HisOrder{
  21318. UserOrgId: adminUser.CurrentOrgId,
  21319. HisPatientId: his.ID,
  21320. PatientId: his.PatientId,
  21321. SettleAccountsDate: recordDateTime,
  21322. Ctime: time.Now().Unix(),
  21323. Mtime: time.Now().Unix(),
  21324. MdtrtId: his.Number,
  21325. PsnNo: his.PsnNo,
  21326. MedType: strconv.FormatInt(reg_type, 10),
  21327. Status: 1,
  21328. Number: chrg_bchno,
  21329. Infcode: res.Infcode,
  21330. WarnMsg: res.WarnMsg,
  21331. Cainfo: res.Cainfo,
  21332. ErrMsg: res.ErrMsg,
  21333. RespondTime: res.RefmsgTime,
  21334. InfRefmsgid: res.InfRefmsgid,
  21335. OrderStatus: 1,
  21336. IsMedicineInsurance: 1,
  21337. SettleType: settle_accounts_type,
  21338. SettleStartTime: start_time,
  21339. SettleEndTime: end_time,
  21340. Creator: roles.AdminUserId,
  21341. Modify: roles.AdminUserId,
  21342. PType: 2,
  21343. Diagnosis: diagnosis_id,
  21344. }
  21345. err = service.CreateOrder(order)
  21346. if err != nil {
  21347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  21348. return
  21349. }
  21350. for _, item := range res.Output.Result {
  21351. temp := strings.Split(item.FeedetlSn, "-")
  21352. var advice_id int64 = 0
  21353. var project_id int64 = 0
  21354. var types int64 = 0
  21355. id, _ := strconv.ParseInt(temp[2], 10, 64)
  21356. types, _ = strconv.ParseInt(temp[1], 10, 64)
  21357. if temp[1] == "1" {
  21358. advice_id = id
  21359. project_id = 0
  21360. } else if temp[1] == "2" {
  21361. advice_id = 0
  21362. project_id = id
  21363. }
  21364. total_two = total_two + item.DetItemFeeSumamt
  21365. info := &models.HisOrderInfo{
  21366. OrderNumber: order.Number,
  21367. FeedetlSn: item.FeedetlSn,
  21368. UploadDate: time.Now().Unix(),
  21369. AdviceId: advice_id,
  21370. DetItemFeeSumamt: item.DetItemFeeSumamt,
  21371. Cnt: item.Cnt,
  21372. Pric: float64(item.Pric),
  21373. PatientId: his.PatientId,
  21374. PricUplmtAmt: item.PricUplmtAmt,
  21375. SelfpayProp: item.SelfpayProp,
  21376. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  21377. OverlmtAmt: item.OverlmtAmt,
  21378. PreselfpayAmt: item.PreselfpayAmt,
  21379. BasMednFlag: item.BasMednFlag,
  21380. MedChrgitmType: item.MedChrgitmType,
  21381. HiNegoDrugFlag: item.HiNegoDrugFlag,
  21382. Status: 1,
  21383. Memo: item.Memo,
  21384. Mtime: time.Now().Unix(),
  21385. InscpScpAmt: item.InscpScpAmt,
  21386. DrtReimFlag: item.DrtReimFlag,
  21387. Ctime: time.Now().Unix(),
  21388. ListSpItemFlag: item.ListSpItemFlag,
  21389. ChldMedcFlag: item.ChldMedcFlag,
  21390. LmtUsedFlag: item.LmtUsedFlag,
  21391. ChrgitmLv: item.ChrgitmLv,
  21392. UserOrgId: adminUser.CurrentOrgId,
  21393. HisPatientId: his.ID,
  21394. OrderId: order.ID,
  21395. ProjectId: project_id,
  21396. Type: types,
  21397. }
  21398. service.CreateOrderInfo(info)
  21399. }
  21400. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  21401. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  21402. var total float64
  21403. for _, item := range prescriptions {
  21404. if item.Type == 1 { //药品
  21405. for _, subItem := range item.HisDoctorAdviceInfo {
  21406. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21407. total_one := price * subItem.PrescribingNumber
  21408. fmt.Println("subItem")
  21409. fmt.Println(subItem.Price)
  21410. fmt.Println("price")
  21411. fmt.Println(price)
  21412. fmt.Println("total_one")
  21413. fmt.Println(total_one)
  21414. total = total + total_one
  21415. fmt.Println(total)
  21416. }
  21417. }
  21418. if item.Type == 2 { //项目
  21419. for _, subItem := range item.HisPrescriptionProject {
  21420. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  21421. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  21422. total_one := price * cnt
  21423. total = total + total_one
  21424. }
  21425. }
  21426. }
  21427. allTotal := fmt.Sprintf("%.2f", total)
  21428. if res.Infcode == 0 {
  21429. var rf []*ResultFive
  21430. json.Unmarshal([]byte(his.Iinfo), &rf)
  21431. chrg_bchno := chrg_bchno
  21432. cert_no := his.Certno
  21433. var insutypes []string
  21434. var insutype string
  21435. var is390 int = 0
  21436. var is310 int = 0
  21437. for _, item := range rf {
  21438. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  21439. insutypes = append(insutypes, item.Insutype)
  21440. }
  21441. }
  21442. if len(insutypes) == 1 {
  21443. insutype = insutypes[0]
  21444. } else {
  21445. for _, i := range insutypes {
  21446. if i == "390" {
  21447. is390 = 1
  21448. }
  21449. if i == "310" {
  21450. is310 = 1
  21451. }
  21452. }
  21453. }
  21454. if is390 == 1 {
  21455. insutype = "390"
  21456. }
  21457. if is310 == 1 {
  21458. insutype = "310"
  21459. }
  21460. if len(insutypes) == 0 {
  21461. insutype = "390"
  21462. }
  21463. if len(insutypes) == 2 {
  21464. insutype = strconv.FormatInt(his.SocialType, 10)
  21465. }
  21466. //insutype = "390"
  21467. if his.IdCardType == 1 {
  21468. cert_no = his.MedicalInsuranceNumber
  21469. } else {
  21470. cert_no = his.Certno
  21471. }
  21472. var res ResultSeven
  21473. var ahres ResultSevenAH
  21474. var resSeven10265 ResultSeven10265
  21475. var resSeven10265Two ResultSeven10265Two
  21476. var gzresSeven10265Two GZResultSeven10265Two
  21477. if miConfig.MdtrtareaAdmvs == "421300" {
  21478. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  21479. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21480. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21481. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21482. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21483. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21484. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21485. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21486. resp, requestErr := http.Get(api)
  21487. if requestErr != nil {
  21488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21489. return
  21490. }
  21491. body, ioErr := ioutil.ReadAll(resp.Body)
  21492. if ioErr != nil {
  21493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21495. return
  21496. }
  21497. var respJSON map[string]interface{}
  21498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21501. return
  21502. }
  21503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21504. result, _ := json.Marshal(respJSON)
  21505. fmt.Println("log")
  21506. fmt.Println(string(result))
  21507. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21508. utils.ErrorLog("解析失败:%v", err)
  21509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21510. return
  21511. }
  21512. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21513. if reg_type == 11 && his.Insutype == "390" {
  21514. reg_type = 110104
  21515. }
  21516. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21517. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21518. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21519. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21520. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21521. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21522. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21523. resp, requestErr := http.Get(api)
  21524. if requestErr != nil {
  21525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21526. return
  21527. }
  21528. body, ioErr := ioutil.ReadAll(resp.Body)
  21529. if ioErr != nil {
  21530. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21532. return
  21533. }
  21534. var respJSON map[string]interface{}
  21535. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21536. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21538. return
  21539. }
  21540. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21541. result, _ := json.Marshal(respJSON)
  21542. fmt.Println("log")
  21543. fmt.Println(string(result))
  21544. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21545. utils.ErrorLog("解析失败:%v", err)
  21546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21547. return
  21548. }
  21549. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21550. if reg_type == 11 && his.Insutype == "390" {
  21551. reg_type = 110104
  21552. }
  21553. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21554. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21555. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21556. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21557. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21558. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21559. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  21560. resp, requestErr := http.Get(api)
  21561. if requestErr != nil {
  21562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21563. return
  21564. }
  21565. body, ioErr := ioutil.ReadAll(resp.Body)
  21566. if ioErr != nil {
  21567. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21569. return
  21570. }
  21571. var respJSON map[string]interface{}
  21572. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21573. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21575. return
  21576. }
  21577. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21578. result, _ := json.Marshal(respJSON)
  21579. fmt.Println("log")
  21580. fmt.Println(string(result))
  21581. if err := json.Unmarshal([]byte(result), &res); err != nil {
  21582. utils.ErrorLog("解析失败:%v", err)
  21583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21584. return
  21585. }
  21586. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21587. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  21588. if result3101.Infcode == "0" {
  21589. if len(result3101.Output.Result) > 0 {
  21590. var errMsgs []string
  21591. for _, item := range result3101.Output.Result {
  21592. errMsgs = append(errMsgs, item.VolaCont)
  21593. }
  21594. c.ServeSuccessJSON(map[string]interface{}{
  21595. "failed_code": -10,
  21596. "msg": errMsgs,
  21597. })
  21598. return
  21599. } else {
  21600. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21601. if his.IdCardType != 4 {
  21602. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21603. bas := strings.Split(psn_info.CardInfo, "|")
  21604. if his.IdCardType == 1 {
  21605. cert_no = bas[2]
  21606. } else {
  21607. cert_no = bas[1]
  21608. }
  21609. } else {
  21610. cert_no = his.Certno
  21611. }
  21612. //江苏地区国家医保医疗类别
  21613. //职工透析:医疗类别选特殊情况门诊9933
  21614. //居民血透门慢: 医疗类别选门诊慢病1402
  21615. //var med_type string
  21616. //if his.Insutype == "310" {
  21617. // if reg_type == 14 {
  21618. // med_type = "9933"
  21619. // } else if reg_type == 11 {
  21620. // med_type = "11"
  21621. //
  21622. // }
  21623. //} else if his.Insutype == "390" {
  21624. // if reg_type == 14 {
  21625. // med_type = "1402"
  21626. // } else if reg_type == 11 {
  21627. // med_type = "11"
  21628. // }
  21629. //}
  21630. var api string
  21631. if miConfig.MdtrtareaAdmvs == "320921" {
  21632. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21633. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21634. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21636. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21637. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21638. "&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
  21639. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21640. } else {
  21641. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21642. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21643. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21644. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21645. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21646. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21647. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21648. "&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
  21649. }
  21650. resp, requestErr := http.Get(api)
  21651. if requestErr != nil {
  21652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21653. return
  21654. }
  21655. body, ioErr := ioutil.ReadAll(resp.Body)
  21656. if ioErr != nil {
  21657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21659. return
  21660. }
  21661. var respJSON map[string]interface{}
  21662. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21665. return
  21666. }
  21667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21668. result, _ := json.Marshal(respJSON)
  21669. fmt.Println("log")
  21670. fmt.Println(string(result))
  21671. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  21672. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21673. utils.ErrorLog("解析失败:%v", err)
  21674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21675. return
  21676. }
  21677. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21678. res.Output = resSeven10265.Output
  21679. res.ErrMsg = resSeven10265.ErrMsg
  21680. res.Cainfo = resSeven10265.Cainfo
  21681. res.WarnMsg = resSeven10265.WarnMsg
  21682. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21683. res.Infcode = infocode
  21684. } else {
  21685. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  21686. utils.ErrorLog("解析失败:%v", err)
  21687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21688. return
  21689. }
  21690. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  21691. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  21692. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  21693. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  21694. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21695. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  21696. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  21697. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  21698. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  21699. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  21700. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  21701. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21702. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  21703. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  21704. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  21705. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  21706. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  21707. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  21708. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  21709. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  21710. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  21711. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21712. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  21713. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  21714. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  21715. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  21716. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  21717. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  21718. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  21719. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  21720. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  21721. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  21722. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  21723. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  21724. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  21725. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21726. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  21727. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  21728. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  21729. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  21730. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  21731. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  21732. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  21733. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  21734. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  21735. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  21736. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  21737. res.ErrMsg = resSeven10265Two.ErrMsg
  21738. res.Cainfo = resSeven10265Two.Cainfo
  21739. res.WarnMsg = resSeven10265Two.WarnMsg
  21740. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  21741. res.Infcode = infocode
  21742. }
  21743. }
  21744. }
  21745. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21746. psn_info, _ := service.GetPsnByPatientId(id)
  21747. var verify_number string
  21748. if psn_info.IdCardType == 4 {
  21749. verify_number = psn_info.VerifyNumber
  21750. } else if psn_info.IdCardType == 1 {
  21751. bas := strings.Split(psn_info.CardInfo, "|")
  21752. cardNumber := bas[2]
  21753. verify_number = cardNumber
  21754. } else {
  21755. psn_info.IdCardType = 2
  21756. verify_number = psn_info.Certno
  21757. }
  21758. var api string
  21759. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21760. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21761. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21762. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21763. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  21764. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21765. "&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
  21766. resp, requestErr := http.Get(api)
  21767. if requestErr != nil {
  21768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21769. return
  21770. }
  21771. body, ioErr := ioutil.ReadAll(resp.Body)
  21772. if ioErr != nil {
  21773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21775. return
  21776. }
  21777. var respJSON map[string]interface{}
  21778. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21781. return
  21782. }
  21783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21784. result, _ := json.Marshal(respJSON)
  21785. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  21786. utils.ErrorLog("解析失败:%v", err)
  21787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21788. return
  21789. }
  21790. res.InfRefmsgid = resSeven10265.InfRefmsgid
  21791. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  21792. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  21793. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21794. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  21795. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  21796. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  21797. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  21798. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  21799. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  21800. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  21801. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  21802. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  21803. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  21804. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  21805. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  21806. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  21807. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  21808. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  21809. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  21810. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  21811. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  21812. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  21813. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  21814. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  21815. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  21816. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  21817. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  21818. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  21819. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  21820. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  21821. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  21822. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  21823. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  21824. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  21825. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  21826. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  21827. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  21828. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  21829. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  21830. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  21831. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  21832. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  21833. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  21834. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  21835. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  21836. res.ErrMsg = resSeven10265.ErrMsg
  21837. res.Cainfo = resSeven10265.Cainfo
  21838. res.WarnMsg = resSeven10265.WarnMsg
  21839. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  21840. res.Infcode = infocode
  21841. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21842. acct_used_flag := "1"
  21843. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  21844. var result string
  21845. var request_log string
  21846. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  21847. 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)
  21848. } else {
  21849. 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)
  21850. }
  21851. var dat map[string]interface{}
  21852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21853. fmt.Println(dat)
  21854. } else {
  21855. fmt.Println(err)
  21856. }
  21857. saveLog(result, request_log, "2206", "预结算")
  21858. userJSONBytes, _ := json.Marshal(dat)
  21859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21860. utils.ErrorLog("解析失败:%v", err)
  21861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21862. return
  21863. }
  21864. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21865. var result string
  21866. var request_log string
  21867. if his.IdCardType == 2 {
  21868. 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, "")
  21869. } else if his.IdCardType == 1 {
  21870. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21871. bas := strings.Split(psn_info.CardInfo, "|")
  21872. basNumber := bas[2]
  21873. card_sn := bas[3]
  21874. var rf []*ResultFive
  21875. json.Unmarshal([]byte(his.Iinfo), &rf)
  21876. var psn_type string
  21877. for _, item := range rf {
  21878. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  21879. psn_type = item.PsnType
  21880. }
  21881. }
  21882. 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)
  21883. } else {
  21884. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21885. 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, "")
  21886. }
  21887. var dat map[string]interface{}
  21888. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  21889. fmt.Println(dat)
  21890. } else {
  21891. fmt.Println(err)
  21892. }
  21893. saveLog(result, request_log, "2206", "预结算")
  21894. userJSONBytes, _ := json.Marshal(dat)
  21895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21896. utils.ErrorLog("解析失败:%v", err)
  21897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21898. return
  21899. }
  21900. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21901. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  21902. if his.IdCardType == 4 {
  21903. psn_info.VerifyNumber = psn_info.VerifyNumber
  21904. cert_no = psn_info.Certno
  21905. } else if his.IdCardType == 2 {
  21906. cert_no = psn_info.Certno
  21907. psn_info.VerifyNumber = psn_info.Certno
  21908. } else {
  21909. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  21910. bas := strings.Split(psn_info.CardInfo, "|")
  21911. if his.IdCardType == 1 {
  21912. cert_no = bas[2]
  21913. } else {
  21914. cert_no = bas[1]
  21915. }
  21916. }
  21917. var api string
  21918. var med_type string
  21919. if his.Insutype == "390" {
  21920. if reg_type == 992102 {
  21921. med_type = "992102"
  21922. }
  21923. if reg_type == 140104 {
  21924. med_type = "140104"
  21925. }
  21926. if reg_type == 14 {
  21927. med_type = "140104"
  21928. }
  21929. } else if his.Insutype == "310" {
  21930. if reg_type == 992102 {
  21931. med_type = "992102"
  21932. }
  21933. if reg_type == 14 {
  21934. med_type = "14"
  21935. }
  21936. }
  21937. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  21938. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  21939. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  21940. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  21941. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  21942. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  21943. "&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
  21944. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21945. resp, requestErr := http.Get(api)
  21946. if requestErr != nil {
  21947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21948. return
  21949. }
  21950. body, ioErr := ioutil.ReadAll(resp.Body)
  21951. if ioErr != nil {
  21952. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21954. return
  21955. }
  21956. var respJSON map[string]interface{}
  21957. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  21958. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21960. return
  21961. }
  21962. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21963. if status == "0" {
  21964. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21965. c.ServeSuccessJSON(map[string]interface{}{
  21966. "failed_code": -10,
  21967. "msg": err_msg,
  21968. })
  21969. return
  21970. }
  21971. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21972. result, _ := json.Marshal(respJSON)
  21973. fmt.Println("log")
  21974. fmt.Println(string(result))
  21975. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  21976. utils.ErrorLog("解析失败:%v", err)
  21977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21978. return
  21979. }
  21980. res.InfRefmsgid = ahres.InfRefmsgid
  21981. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  21982. // 创建对应的Time类型
  21983. t := time.UnixMilli(timestamp)
  21984. // 格式化成指定的日期字符串
  21985. str := t.Format("2006-01-02 15:04:05")
  21986. res.Output.Setlinfo.SetlTime = str
  21987. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  21988. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  21989. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  21990. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  21991. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  21992. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  21993. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  21994. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  21995. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  21996. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  21997. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  21998. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  21999. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22000. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22001. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22002. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22003. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22004. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22005. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22006. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22007. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22008. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22009. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22010. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22011. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22012. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22013. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22014. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22015. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22016. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22017. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22018. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22019. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22020. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  22021. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22022. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  22023. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  22024. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  22025. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  22026. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22027. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  22028. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22029. //res.Output.Setldetail = ahres.Output.Setldetail
  22030. res.ErrMsg = ahres.ErrMsg
  22031. res.Cainfo = ahres.Cainfo
  22032. res.WarnMsg = ahres.WarnMsg
  22033. res.Infcode = ahres.Infcode
  22034. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22035. var result string
  22036. var request_log string
  22037. if his.IdCardType == 2 {
  22038. 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")
  22039. } else if his.IdCardType == 1 {
  22040. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22041. bas := strings.Split(psn_info.CardInfo, "|")
  22042. basNumber := bas[2]
  22043. card_sn := bas[3]
  22044. 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")
  22045. } else {
  22046. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22047. 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")
  22048. }
  22049. var dat map[string]interface{}
  22050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22051. fmt.Println(dat)
  22052. } else {
  22053. fmt.Println(err)
  22054. }
  22055. saveLog(result, request_log, "2206", "预结算")
  22056. userJSONBytes, _ := json.Marshal(dat)
  22057. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22058. utils.ErrorLog("解析失败:%v", err)
  22059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22060. return
  22061. }
  22062. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22063. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22064. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22065. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22066. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22067. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22068. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22069. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22070. resp, requestErr := http.Get(api)
  22071. if requestErr != nil {
  22072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22073. return
  22074. }
  22075. body, ioErr := ioutil.ReadAll(resp.Body)
  22076. if ioErr != nil {
  22077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22079. return
  22080. }
  22081. var respJSON map[string]interface{}
  22082. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22085. return
  22086. }
  22087. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22088. result, _ := json.Marshal(respJSON)
  22089. fmt.Println("log")
  22090. fmt.Println(string(result))
  22091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22092. utils.ErrorLog("解析失败:%v", err)
  22093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22094. return
  22095. }
  22096. } else {
  22097. if miConfig.MdtrtareaAdmvs == "441202" {
  22098. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22099. if result3101.Infcode == 0 {
  22100. if len(result3101.Output.Result) > 0 {
  22101. var errMsgs []string
  22102. for _, item := range result3101.Output.Result {
  22103. errMsgs = append(errMsgs, item.VolaCont)
  22104. }
  22105. c.ServeSuccessJSON(map[string]interface{}{
  22106. "failed_code": -10,
  22107. "msg": errMsgs,
  22108. })
  22109. return
  22110. } else {
  22111. var result string
  22112. var request_log string
  22113. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22114. allTotal = fmt.Sprintf("%.2f", total_two)
  22115. if his.IdCardType == 4 {
  22116. 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)
  22117. } else {
  22118. 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)
  22119. }
  22120. var dat map[string]interface{}
  22121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22122. fmt.Println(dat)
  22123. } else {
  22124. fmt.Println(err)
  22125. }
  22126. saveLog(result, request_log, "2206", "预结算")
  22127. //userJSONBytes, _ := json.Marshal(dat)
  22128. //
  22129. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22130. // utils.ErrorLog("解析失败:%v", err)
  22131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22132. // return
  22133. //}
  22134. userJSONBytes, _ := json.Marshal(dat)
  22135. if miConfig.Code == "H15049901371" {
  22136. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22137. utils.ErrorLog("解析失败:%v", err)
  22138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22139. return
  22140. }
  22141. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22142. res.Output = resSeven10265.Output
  22143. res.ErrMsg = resSeven10265.ErrMsg
  22144. res.Cainfo = resSeven10265.Cainfo
  22145. res.WarnMsg = resSeven10265.WarnMsg
  22146. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22147. res.Infcode = infocode
  22148. } else {
  22149. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22150. utils.ErrorLog("解析失败:%v", err)
  22151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22152. return
  22153. }
  22154. }
  22155. }
  22156. } else {
  22157. c.ServeSuccessJSON(map[string]interface{}{
  22158. "failed_code": -10,
  22159. "msg": result3101.ErrMsg,
  22160. })
  22161. return
  22162. }
  22163. } else {
  22164. var result string
  22165. var request_log string
  22166. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22167. allTotal = fmt.Sprintf("%.2f", total_two)
  22168. if his.IdCardType == 4 {
  22169. 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)
  22170. } else {
  22171. 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)
  22172. }
  22173. var dat map[string]interface{}
  22174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22175. fmt.Println(dat)
  22176. } else {
  22177. fmt.Println(err)
  22178. }
  22179. saveLog(result, request_log, "2206", "预结算")
  22180. //userJSONBytes, _ := json.Marshal(dat)
  22181. //
  22182. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22183. // utils.ErrorLog("解析失败:%v", err)
  22184. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22185. // return
  22186. //}
  22187. userJSONBytes, _ := json.Marshal(dat)
  22188. if miConfig.Code == "H15049901371" {
  22189. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  22190. utils.ErrorLog("解析失败:%v", err)
  22191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22192. return
  22193. }
  22194. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22195. res.Output = resSeven10265.Output
  22196. res.ErrMsg = resSeven10265.ErrMsg
  22197. res.Cainfo = resSeven10265.Cainfo
  22198. res.WarnMsg = resSeven10265.WarnMsg
  22199. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22200. res.Infcode = infocode
  22201. } else {
  22202. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22203. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  22204. utils.ErrorLog("解析失败:%v", err)
  22205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22206. return
  22207. }
  22208. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  22209. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  22210. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  22211. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22212. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  22213. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  22214. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  22215. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22216. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  22217. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22218. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22219. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22220. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22221. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  22222. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22223. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  22224. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  22225. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  22226. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  22227. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  22228. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22229. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  22230. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  22231. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  22232. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  22233. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  22234. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  22235. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  22236. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  22237. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22238. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  22239. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  22240. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  22241. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22242. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22243. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22244. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22245. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  22246. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  22247. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  22248. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  22249. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  22250. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  22251. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  22252. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  22253. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  22254. res.ErrMsg = gzresSeven10265Two.ErrMsg
  22255. res.Cainfo = gzresSeven10265Two.Cainfo
  22256. res.WarnMsg = gzresSeven10265Two.WarnMsg
  22257. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22258. //res.Infcode = infocode
  22259. } else {
  22260. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22261. utils.ErrorLog("解析失败:%v", err)
  22262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22263. return
  22264. }
  22265. }
  22266. }
  22267. }
  22268. }
  22269. utils.ErrorLog("解析失败:%v", res.Infcode)
  22270. if res.Infcode == -1 {
  22271. errlog := &models.HisOrderError{
  22272. UserOrgId: adminUser.CurrentOrgId,
  22273. Ctime: time.Now().Unix(),
  22274. Mtime: time.Now().Unix(),
  22275. Number: chrg_bchno,
  22276. ErrMsg: res.ErrMsg,
  22277. Status: 1,
  22278. PatientId: id,
  22279. RecordTime: recordDateTime,
  22280. Stage: 20,
  22281. }
  22282. service.CreateErrMsgLog(errlog)
  22283. c.ServeSuccessJSON(map[string]interface{}{
  22284. "failed_code": -10,
  22285. "msg": res.ErrMsg,
  22286. })
  22287. return
  22288. }
  22289. if res.Infcode != 0 {
  22290. errlog := &models.HisOrderError{
  22291. UserOrgId: adminUser.CurrentOrgId,
  22292. Ctime: time.Now().Unix(),
  22293. Mtime: time.Now().Unix(),
  22294. Number: chrg_bchno,
  22295. ErrMsg: res.ErrMsg,
  22296. Status: 1,
  22297. PatientId: id,
  22298. RecordTime: recordDateTime,
  22299. Stage: 20,
  22300. }
  22301. service.CreateErrMsgLog(errlog)
  22302. c.ServeSuccessJSON(map[string]interface{}{
  22303. "failed_code": -10,
  22304. "msg": res.ErrMsg,
  22305. })
  22306. return
  22307. } else {
  22308. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  22309. order.OrderStatus = 1
  22310. order.IsPre = 1
  22311. order.Status = 1
  22312. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  22313. order.SetlId = res.Output.Setlinfo.SetlID
  22314. order.PsnNo = res.Output.Setlinfo.PsnNo
  22315. order.PsnName = res.Output.Setlinfo.PsnName
  22316. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  22317. order.Certno = res.Output.Setlinfo.Certno
  22318. order.Gend = res.Output.Setlinfo.Gend
  22319. order.Naty = res.Output.Setlinfo.Naty
  22320. order.Age = res.Output.Setlinfo.Age
  22321. order.Insutype = res.Output.Setlinfo.Insutype
  22322. order.PsnType = res.Output.Setlinfo.PsnType
  22323. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  22324. order.SetlTime = res.Output.Setlinfo.SetlTime
  22325. order.AcctUsedFlag = acct_used_flag
  22326. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  22327. if res.Output.Setlinfo.MedType == "140101" {
  22328. order.MedType = "14"
  22329. } else {
  22330. if res.Output.Setlinfo.MedType == "110104" {
  22331. order.MedType = "11"
  22332. } else {
  22333. order.MedType = res.Output.Setlinfo.MedType
  22334. }
  22335. }
  22336. if res.Output.Setlinfo.MedType == "992102" {
  22337. order.MedType = "992102"
  22338. }
  22339. if res.Output.Setlinfo.MedType == "140104" {
  22340. order.MedType = "140104"
  22341. }
  22342. if res.Output.Setlinfo.MedType == "14" {
  22343. order.MedType = "14"
  22344. }
  22345. if reg_type == 1112 {
  22346. order.MedType = "1112"
  22347. }
  22348. if reg_type == 1111 {
  22349. order.MedType = "1111"
  22350. }
  22351. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  22352. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  22353. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  22354. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  22355. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  22356. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  22357. order.HifpPay = res.Output.Setlinfo.HifpPay
  22358. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  22359. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  22360. order.HifesPay = res.Output.Setlinfo.HifesPay
  22361. order.HifobPay = res.Output.Setlinfo.HifobPay
  22362. order.MafPay = res.Output.Setlinfo.MafPay
  22363. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  22364. order.OthPay = res.Output.Setlinfo.OthPay
  22365. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  22366. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  22367. order.AcctPay = res.Output.Setlinfo.AcctPay
  22368. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  22369. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  22370. order.Balc = res.Output.Setlinfo.Balc
  22371. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  22372. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  22373. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  22374. order.ClrWay = res.Output.Setlinfo.ClrWay
  22375. order.Creator = order.Creator
  22376. order.Modify = roles.AdminUserId
  22377. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  22378. //detailStr := string(setlDetail)
  22379. //order.SetlDetail = detailStr
  22380. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  22381. err = service.UpDateOrder(order)
  22382. if err == nil {
  22383. c.ServeSuccessJSON(map[string]interface{}{
  22384. "msg": "预结算成功",
  22385. })
  22386. } else {
  22387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  22388. return
  22389. }
  22390. }
  22391. } else {
  22392. adminUser := c.GetAdminUserInfo()
  22393. errlog := &models.HisOrderError{
  22394. UserOrgId: adminUser.CurrentOrgId,
  22395. Ctime: time.Now().Unix(),
  22396. Mtime: time.Now().Unix(),
  22397. ErrMsg: res.ErrMsg,
  22398. Status: 1,
  22399. PatientId: id,
  22400. RecordTime: recordDateTime,
  22401. Stage: 4,
  22402. }
  22403. service.CreateErrMsgLog(errlog)
  22404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  22405. return
  22406. }
  22407. } else {
  22408. if miConfig.MdtrtareaAdmvs == "150499" {
  22409. order := &models.HisOrder{
  22410. UserOrgId: adminUser.CurrentOrgId,
  22411. HisPatientId: his.ID,
  22412. PatientId: his.PatientId,
  22413. SettleAccountsDate: recordDateTime,
  22414. Ctime: time.Now().Unix(),
  22415. Mtime: time.Now().Unix(),
  22416. MdtrtId: his.Number,
  22417. PsnNo: his.PsnNo,
  22418. MedType: strconv.FormatInt(reg_type, 10),
  22419. Status: 1,
  22420. Number: chrg_bchno,
  22421. Infcode: res.Infcode,
  22422. WarnMsg: res.WarnMsg,
  22423. Cainfo: res.Cainfo,
  22424. ErrMsg: res.ErrMsg,
  22425. RespondTime: res.RefmsgTime,
  22426. InfRefmsgid: res.InfRefmsgid,
  22427. OrderStatus: 1,
  22428. IsMedicineInsurance: 1,
  22429. SettleType: settle_accounts_type,
  22430. SettleStartTime: start_time,
  22431. SettleEndTime: end_time,
  22432. Creator: roles.AdminUserId,
  22433. Modify: roles.AdminUserId,
  22434. PType: 2,
  22435. Diagnosis: diagnosis_id,
  22436. }
  22437. err = service.CreateOrder(order)
  22438. if err != nil {
  22439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22440. return
  22441. }
  22442. }
  22443. adminUser := c.GetAdminUserInfo()
  22444. errlog := &models.HisOrderError{
  22445. UserOrgId: adminUser.CurrentOrgId,
  22446. Ctime: time.Now().Unix(),
  22447. Mtime: time.Now().Unix(),
  22448. ErrMsg: res.ErrMsg,
  22449. Status: 1,
  22450. PatientId: id,
  22451. RecordTime: recordDateTime,
  22452. Stage: 4,
  22453. }
  22454. service.CreateErrMsgLog(errlog)
  22455. c.ServeSuccessJSON(map[string]interface{}{
  22456. "failed_code": -10,
  22457. "msg": res.ErrMsg,
  22458. })
  22459. return
  22460. }
  22461. }
  22462. }
  22463. }
  22464. // 退款
  22465. func (c *HisApiController) Refund() {
  22466. order_id, _ := c.GetInt64("order_id")
  22467. admin_user_id, _ := c.GetInt64("admin_user_id")
  22468. adminUser := c.GetAdminUserInfo()
  22469. var order models.HisOrder
  22470. order, _ = service.GetHisOrderByID(order_id)
  22471. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  22472. if order.ID == 0 {
  22473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  22474. return
  22475. }
  22476. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  22477. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  22478. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  22479. if config.IsOpen == 1 { //对接了医保,走医保流程
  22480. var res ResultSixteen
  22481. var ahres ResultSevenAH
  22482. var resSixteen10265 ResultSixteen10265
  22483. var resSixteen10265Two ResultSixteen10265Two
  22484. var gz ResultgzSixteen10265Two
  22485. var src_resquest string
  22486. var result string
  22487. if miConfig.MdtrtareaAdmvs == "421300" {
  22488. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22489. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22490. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22491. resp3, requestErr3 := http.Get(api3)
  22492. if requestErr3 != nil {
  22493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22494. return
  22495. }
  22496. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22497. if ioErr3 != nil {
  22498. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22500. return
  22501. }
  22502. var respJSON3 map[string]interface{}
  22503. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22504. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22506. return
  22507. }
  22508. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22509. userJSONBytes3, _ := json.Marshal(respJSON3)
  22510. fmt.Println("log")
  22511. fmt.Println(string(userJSONBytes3))
  22512. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22513. utils.ErrorLog("解析失败:%v", err)
  22514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22515. return
  22516. }
  22517. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22518. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  22519. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22520. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22521. resp3, requestErr3 := http.Get(api3)
  22522. if requestErr3 != nil {
  22523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22524. return
  22525. }
  22526. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22527. if ioErr3 != nil {
  22528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22530. return
  22531. }
  22532. var respJSON3 map[string]interface{}
  22533. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22536. return
  22537. }
  22538. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22539. userJSONBytes3, _ := json.Marshal(respJSON3)
  22540. fmt.Println("log")
  22541. fmt.Println(string(userJSONBytes3))
  22542. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22543. utils.ErrorLog("解析失败:%v", err)
  22544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22545. return
  22546. }
  22547. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22548. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  22549. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22550. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22551. resp3, requestErr3 := http.Get(api3)
  22552. if requestErr3 != nil {
  22553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22554. return
  22555. }
  22556. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22557. if ioErr3 != nil {
  22558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22560. return
  22561. }
  22562. var respJSON3 map[string]interface{}
  22563. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22566. return
  22567. }
  22568. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22569. userJSONBytes3, _ := json.Marshal(respJSON3)
  22570. fmt.Println("log")
  22571. fmt.Println(string(userJSONBytes3))
  22572. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22573. utils.ErrorLog("解析失败:%v", err)
  22574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22575. return
  22576. }
  22577. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22578. var api3 string
  22579. if miConfig.MdtrtareaAdmvs == "320921" {
  22580. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22581. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22582. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22583. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22584. } else {
  22585. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22586. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  22587. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22588. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22589. }
  22590. resp3, requestErr3 := http.Get(api3)
  22591. if requestErr3 != nil {
  22592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22593. return
  22594. }
  22595. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22596. if ioErr3 != nil {
  22597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22599. return
  22600. }
  22601. var respJSON3 map[string]interface{}
  22602. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22605. return
  22606. }
  22607. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22608. userJSONBytes3, _ := json.Marshal(respJSON3)
  22609. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22610. utils.ErrorLog("解析失败:%v", err)
  22611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22612. return
  22613. }
  22614. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22615. res.Output = resSixteen10265.Output
  22616. res.ErrMsg = resSixteen10265.ErrMsg
  22617. res.Cainfo = resSixteen10265.Cainfo
  22618. res.WarnMsg = resSixteen10265.WarnMsg
  22619. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22620. res.Infcode = infocode
  22621. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22622. var api3 string
  22623. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  22624. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22625. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22626. resp3, requestErr3 := http.Get(api3)
  22627. if requestErr3 != nil {
  22628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22629. return
  22630. }
  22631. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22632. if ioErr3 != nil {
  22633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22635. return
  22636. }
  22637. var respJSON3 map[string]interface{}
  22638. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22641. return
  22642. }
  22643. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22644. userJSONBytes3, _ := json.Marshal(respJSON3)
  22645. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  22646. utils.ErrorLog("解析失败:%v", err)
  22647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22648. return
  22649. }
  22650. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22651. res.Output = resSixteen10265.Output
  22652. res.ErrMsg = resSixteen10265.ErrMsg
  22653. res.Cainfo = resSixteen10265.Cainfo
  22654. res.WarnMsg = resSixteen10265.WarnMsg
  22655. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22656. res.Infcode = infocode
  22657. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22658. 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)
  22659. var dat map[string]interface{}
  22660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22661. fmt.Println(dat)
  22662. } else {
  22663. fmt.Println(err)
  22664. }
  22665. saveLog(result, src_resquest, "2208", "退费")
  22666. userJSONBytes, _ := json.Marshal(dat)
  22667. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22668. utils.ErrorLog("解析失败:%v", err)
  22669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22670. return
  22671. }
  22672. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22673. 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, "")
  22674. var dat map[string]interface{}
  22675. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22676. fmt.Println(dat)
  22677. } else {
  22678. fmt.Println(err)
  22679. }
  22680. saveLog(result, src_resquest, "2208", "退费")
  22681. userJSONBytes, _ := json.Marshal(dat)
  22682. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22683. utils.ErrorLog("解析失败:%v", err)
  22684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22685. return
  22686. }
  22687. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22688. var api3 string
  22689. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  22690. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22691. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22692. resp3, requestErr3 := http.Get(api3)
  22693. if requestErr3 != nil {
  22694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22695. return
  22696. }
  22697. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22698. if ioErr3 != nil {
  22699. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22701. return
  22702. }
  22703. var respJSON3 map[string]interface{}
  22704. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22705. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22707. return
  22708. }
  22709. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  22710. if status == "0" {
  22711. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  22712. c.ServeSuccessJSON(map[string]interface{}{
  22713. "failed_code": -10,
  22714. "msg": err_msg,
  22715. })
  22716. return
  22717. }
  22718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22719. userJSONBytes3, _ := json.Marshal(respJSON3)
  22720. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22721. // utils.ErrorLog("解析失败:%v", err)
  22722. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22723. // return
  22724. //}
  22725. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  22726. utils.ErrorLog("解析失败:%v", err)
  22727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22728. return
  22729. }
  22730. res.InfRefmsgid = ahres.InfRefmsgid
  22731. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  22732. // 创建对应的Time类型
  22733. t := time.UnixMilli(timestamp)
  22734. // 格式化成指定的日期字符串
  22735. str := t.Format("2006-01-02 15:04:05")
  22736. res.Output.Setlinfo.SetlTime = str
  22737. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  22738. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  22739. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22740. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  22741. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  22742. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  22743. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  22744. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  22745. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  22746. //
  22747. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  22748. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  22749. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  22750. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  22751. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  22752. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  22753. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  22754. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  22755. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  22756. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  22757. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22758. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  22759. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  22760. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  22761. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  22762. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  22763. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  22764. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  22765. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  22766. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  22767. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  22768. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  22769. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  22770. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  22771. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  22772. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  22773. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  22774. //res.Output.Setldetail = ahres.Output.Setldetail
  22775. res.ErrMsg = ahres.ErrMsg
  22776. res.Cainfo = ahres.Cainfo
  22777. res.WarnMsg = ahres.WarnMsg
  22778. res.Infcode = ahres.Infcode
  22779. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22780. 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, "")
  22781. var dat map[string]interface{}
  22782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22783. fmt.Println(dat)
  22784. } else {
  22785. fmt.Println(err)
  22786. }
  22787. saveLog(result, src_resquest, "2208", "退费")
  22788. userJSONBytes, _ := json.Marshal(dat)
  22789. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22790. utils.ErrorLog("解析失败:%v", err)
  22791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22792. return
  22793. }
  22794. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22795. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  22796. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22797. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22798. resp3, requestErr3 := http.Get(api3)
  22799. if requestErr3 != nil {
  22800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22801. return
  22802. }
  22803. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22804. if ioErr3 != nil {
  22805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22807. return
  22808. }
  22809. var respJSON3 map[string]interface{}
  22810. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22813. return
  22814. }
  22815. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22816. userJSONBytes3, _ := json.Marshal(respJSON3)
  22817. fmt.Println("log")
  22818. fmt.Println(string(userJSONBytes3))
  22819. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  22820. utils.ErrorLog("解析失败:%v", err)
  22821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22822. return
  22823. }
  22824. } else {
  22825. if miConfig.Code == "H15049901371" {
  22826. 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)
  22827. var dat map[string]interface{}
  22828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22829. fmt.Println(dat)
  22830. } else {
  22831. fmt.Println(err)
  22832. }
  22833. saveLog(result, src_resquest, "2208", "退费")
  22834. userJSONBytes, _ := json.Marshal(dat)
  22835. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  22836. utils.ErrorLog("解析失败:%v", err)
  22837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22838. return
  22839. }
  22840. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  22841. res.Output = resSixteen10265.Output
  22842. res.ErrMsg = resSixteen10265.ErrMsg
  22843. res.Cainfo = resSixteen10265.Cainfo
  22844. res.WarnMsg = resSixteen10265.WarnMsg
  22845. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  22846. res.Infcode = infocode
  22847. } else {
  22848. 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)
  22849. var dat map[string]interface{}
  22850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22851. fmt.Println(dat)
  22852. } else {
  22853. fmt.Println(err)
  22854. }
  22855. saveLog(result, src_resquest, "2208", "退费")
  22856. userJSONBytes, _ := json.Marshal(dat)
  22857. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  22858. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  22859. utils.ErrorLog("解析失败:%v", err)
  22860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22861. return
  22862. }
  22863. res.Infcode = gz.Infcode
  22864. } else {
  22865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22866. utils.ErrorLog("解析失败:%v", err)
  22867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22868. return
  22869. }
  22870. }
  22871. }
  22872. }
  22873. if res.Infcode == 0 {
  22874. var res2 ResultSix
  22875. var resSix10265 ResultSix10265
  22876. if miConfig.MdtrtareaAdmvs == "421300" {
  22877. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22878. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22879. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22880. resp3, requestErr3 := http.Get(api3)
  22881. if requestErr3 != nil {
  22882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22883. return
  22884. }
  22885. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22886. if ioErr3 != nil {
  22887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22889. return
  22890. }
  22891. var respJSON3 map[string]interface{}
  22892. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22895. return
  22896. }
  22897. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22898. userJSONBytes3, _ := json.Marshal(respJSON3)
  22899. fmt.Println("log")
  22900. fmt.Println(string(userJSONBytes3))
  22901. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22902. utils.ErrorLog("解析失败:%v", err)
  22903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22904. return
  22905. }
  22906. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22907. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  22908. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22909. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22910. resp3, requestErr3 := http.Get(api3)
  22911. if requestErr3 != nil {
  22912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22913. return
  22914. }
  22915. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22916. if ioErr3 != nil {
  22917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22919. return
  22920. }
  22921. var respJSON3 map[string]interface{}
  22922. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22925. return
  22926. }
  22927. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22928. userJSONBytes3, _ := json.Marshal(respJSON3)
  22929. fmt.Println("log")
  22930. fmt.Println(string(userJSONBytes3))
  22931. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22932. utils.ErrorLog("解析失败:%v", err)
  22933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22934. return
  22935. }
  22936. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22937. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  22938. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22939. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  22940. resp3, requestErr3 := http.Get(api3)
  22941. if requestErr3 != nil {
  22942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22943. return
  22944. }
  22945. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22946. if ioErr3 != nil {
  22947. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22949. return
  22950. }
  22951. var respJSON3 map[string]interface{}
  22952. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22953. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22955. return
  22956. }
  22957. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22958. userJSONBytes3, _ := json.Marshal(respJSON3)
  22959. fmt.Println("log")
  22960. fmt.Println(string(userJSONBytes3))
  22961. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  22962. utils.ErrorLog("解析失败:%v", err)
  22963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22964. return
  22965. }
  22966. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22967. var api3 string
  22968. if miConfig.MdtrtareaAdmvs == "320921" {
  22969. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22970. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22971. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22972. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22973. } else {
  22974. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22975. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  22976. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  22977. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  22978. }
  22979. resp3, requestErr3 := http.Get(api3)
  22980. if requestErr3 != nil {
  22981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22982. return
  22983. }
  22984. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  22985. if ioErr3 != nil {
  22986. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  22987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22988. return
  22989. }
  22990. var respJSON3 map[string]interface{}
  22991. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  22992. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22994. return
  22995. }
  22996. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22997. userJSONBytes3, _ := json.Marshal(respJSON3)
  22998. fmt.Println("log")
  22999. fmt.Println(string(userJSONBytes3))
  23000. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23001. utils.ErrorLog("解析失败:%v", err)
  23002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23003. return
  23004. }
  23005. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23006. res2.Output = resSix10265.Output
  23007. res2.ErrMsg = resSix10265.ErrMsg
  23008. res2.Cainfo = resSix10265.Cainfo
  23009. res2.WarnMsg = resSix10265.WarnMsg
  23010. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23011. res2.Infcode = infocode
  23012. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23013. var api3 string
  23014. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23015. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23016. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23017. resp3, requestErr3 := http.Get(api3)
  23018. if requestErr3 != nil {
  23019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23020. return
  23021. }
  23022. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23023. if ioErr3 != nil {
  23024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23026. return
  23027. }
  23028. var respJSON3 map[string]interface{}
  23029. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23032. return
  23033. }
  23034. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23035. userJSONBytes3, _ := json.Marshal(respJSON3)
  23036. fmt.Println("log")
  23037. fmt.Println(string(userJSONBytes3))
  23038. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23039. utils.ErrorLog("解析失败:%v", err)
  23040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23041. return
  23042. }
  23043. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23044. res2.Output = resSix10265.Output
  23045. res2.ErrMsg = resSix10265.ErrMsg
  23046. res2.Cainfo = resSix10265.Cainfo
  23047. res2.WarnMsg = resSix10265.WarnMsg
  23048. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23049. res2.Infcode = infocode
  23050. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23051. 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)
  23052. var dat map[string]interface{}
  23053. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23054. fmt.Println(dat)
  23055. } else {
  23056. fmt.Println(err)
  23057. }
  23058. saveLog(result2, src_request, "2205", "撤销明细")
  23059. userJSONBytes, _ := json.Marshal(dat)
  23060. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23061. utils.ErrorLog("解析失败:%v", err)
  23062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23063. return
  23064. }
  23065. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23066. 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, "")
  23067. var dat map[string]interface{}
  23068. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23069. fmt.Println(dat)
  23070. } else {
  23071. fmt.Println(err)
  23072. }
  23073. saveLog(result2, src_request, "2205", "撤销明细")
  23074. userJSONBytes, _ := json.Marshal(dat)
  23075. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23076. utils.ErrorLog("解析失败:%v", err)
  23077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23078. return
  23079. }
  23080. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23081. var api3 string
  23082. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23083. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23084. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23085. resp3, requestErr3 := http.Get(api3)
  23086. if requestErr3 != nil {
  23087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23088. return
  23089. }
  23090. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23091. if ioErr3 != nil {
  23092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23094. return
  23095. }
  23096. var respJSON3 map[string]interface{}
  23097. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23100. return
  23101. }
  23102. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23103. if status == "0" {
  23104. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23105. c.ServeSuccessJSON(map[string]interface{}{
  23106. "failed_code": -10,
  23107. "msg": err_msg,
  23108. })
  23109. return
  23110. }
  23111. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23112. userJSONBytes3, _ := json.Marshal(respJSON3)
  23113. fmt.Println("log")
  23114. fmt.Println(string(userJSONBytes3))
  23115. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23116. utils.ErrorLog("解析失败:%v", err)
  23117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23118. return
  23119. }
  23120. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23121. 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, "")
  23122. var dat map[string]interface{}
  23123. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23124. fmt.Println(dat)
  23125. } else {
  23126. fmt.Println(err)
  23127. }
  23128. saveLog(result2, src_request, "2205", "撤销明细")
  23129. userJSONBytes, _ := json.Marshal(dat)
  23130. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23131. utils.ErrorLog("解析失败:%v", err)
  23132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23133. return
  23134. }
  23135. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23136. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  23137. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23139. resp3, requestErr3 := http.Get(api3)
  23140. if requestErr3 != nil {
  23141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23142. return
  23143. }
  23144. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23145. if ioErr3 != nil {
  23146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23148. return
  23149. }
  23150. var respJSON3 map[string]interface{}
  23151. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23154. return
  23155. }
  23156. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23157. userJSONBytes3, _ := json.Marshal(respJSON3)
  23158. fmt.Println("log")
  23159. fmt.Println(string(userJSONBytes3))
  23160. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23161. utils.ErrorLog("解析失败:%v", err)
  23162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23163. return
  23164. }
  23165. } else {
  23166. if miConfig.Code == "H15049901371" {
  23167. 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)
  23168. var dat map[string]interface{}
  23169. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23170. fmt.Println(dat)
  23171. } else {
  23172. fmt.Println(err)
  23173. }
  23174. saveLog(result2, src_request, "2205", "撤销明细")
  23175. userJSONBytes, _ := json.Marshal(dat)
  23176. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  23177. utils.ErrorLog("解析失败:%v", err)
  23178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23179. return
  23180. }
  23181. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23182. res2.Output = resSix10265.Output
  23183. res2.ErrMsg = resSix10265.ErrMsg
  23184. res2.Cainfo = resSix10265.Cainfo
  23185. res2.WarnMsg = resSix10265.WarnMsg
  23186. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23187. res2.Infcode = infocode
  23188. } else {
  23189. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23190. res2.Infcode = 0
  23191. } else {
  23192. 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)
  23193. var dat map[string]interface{}
  23194. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23195. fmt.Println(dat)
  23196. } else {
  23197. fmt.Println(err)
  23198. }
  23199. saveLog(result2, src_request, "2205", "撤销明细")
  23200. userJSONBytes, _ := json.Marshal(dat)
  23201. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23202. utils.ErrorLog("解析失败:%v", err)
  23203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23204. return
  23205. }
  23206. }
  23207. }
  23208. }
  23209. if res2.Infcode == -1 {
  23210. c.ServeSuccessJSON(map[string]interface{}{
  23211. "failed_code": -10,
  23212. "msg": res2.ErrMsg,
  23213. })
  23214. return
  23215. }
  23216. if res2.Infcode == 0 {
  23217. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  23218. if err == nil {
  23219. //当押金不为零时产生退费记录
  23220. if order.Decimal != 0 {
  23221. tmp := strconv.FormatInt(order.ID, 10)
  23222. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  23223. if err != nil {
  23224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23225. return
  23226. }
  23227. }
  23228. c.ServeSuccessJSON(map[string]interface{}{
  23229. "msg": "退费成功",
  23230. })
  23231. } else {
  23232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23233. return
  23234. }
  23235. } else {
  23236. c.ServeSuccessJSON(map[string]interface{}{
  23237. "failed_code": -10,
  23238. "msg": res2.ErrMsg,
  23239. })
  23240. }
  23241. } else {
  23242. c.ServeSuccessJSON(map[string]interface{}{
  23243. "failed_code": -10,
  23244. "msg": res.ErrMsg,
  23245. })
  23246. }
  23247. }
  23248. }
  23249. func (c *HisApiController) RefundNumber() {
  23250. record_time := c.GetString("record_time")
  23251. //patient_id, _ := c.GetInt64("patient_id")
  23252. admin_user_id, _ := c.GetInt64("admin_user_id")
  23253. his_patient_id, _ := c.GetInt64("id")
  23254. timeLayout := "2006-01-02"
  23255. loc, _ := time.LoadLocation("Local")
  23256. adminUser := c.GetAdminUserInfo()
  23257. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23258. fmt.Println(err)
  23259. if err != nil {
  23260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23261. return
  23262. }
  23263. recordDateTime := theTime.Unix()
  23264. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23265. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  23266. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23267. //order, _ := service.GetHisOrderByID(order_id)
  23268. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23269. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23270. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23271. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  23272. if count > 0 {
  23273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  23274. return
  23275. }
  23276. if config.IsOpen == 1 { //对接了医保,走医保流程
  23277. var res2 ResultSix
  23278. var res3 GZResultSix
  23279. var resSix10265 ResultSix10265
  23280. if miConfig.MdtrtareaAdmvs == "421300" {
  23281. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23282. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23283. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23284. resp3, requestErr3 := http.Get(api3)
  23285. if requestErr3 != nil {
  23286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23287. return
  23288. }
  23289. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23290. if ioErr3 != nil {
  23291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23293. return
  23294. }
  23295. var respJSON3 map[string]interface{}
  23296. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23299. return
  23300. }
  23301. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23302. userJSONBytes3, _ := json.Marshal(respJSON3)
  23303. fmt.Println("log")
  23304. fmt.Println(string(userJSONBytes3))
  23305. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23306. utils.ErrorLog("解析失败:%v", err)
  23307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23308. return
  23309. }
  23310. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23311. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  23312. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23313. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23314. resp3, requestErr3 := http.Get(api3)
  23315. if requestErr3 != nil {
  23316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23317. return
  23318. }
  23319. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23320. if ioErr3 != nil {
  23321. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23323. return
  23324. }
  23325. var respJSON3 map[string]interface{}
  23326. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23327. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23329. return
  23330. }
  23331. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23332. userJSONBytes3, _ := json.Marshal(respJSON3)
  23333. fmt.Println("log")
  23334. fmt.Println(string(userJSONBytes3))
  23335. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23336. utils.ErrorLog("解析失败:%v", err)
  23337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23338. return
  23339. }
  23340. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23341. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  23342. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23343. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23344. resp3, requestErr3 := http.Get(api3)
  23345. if requestErr3 != nil {
  23346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23347. return
  23348. }
  23349. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23350. if ioErr3 != nil {
  23351. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23353. return
  23354. }
  23355. var respJSON3 map[string]interface{}
  23356. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23357. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23359. return
  23360. }
  23361. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23362. userJSONBytes3, _ := json.Marshal(respJSON3)
  23363. fmt.Println("log")
  23364. fmt.Println(string(userJSONBytes3))
  23365. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23366. utils.ErrorLog("解析失败:%v", err)
  23367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23368. return
  23369. }
  23370. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23371. var api3 string
  23372. if miConfig.MdtrtareaAdmvs == "320921" {
  23373. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23374. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23376. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23377. } else {
  23378. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23379. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  23380. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23381. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23382. }
  23383. resp3, requestErr3 := http.Get(api3)
  23384. if requestErr3 != nil {
  23385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23386. return
  23387. }
  23388. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23389. if ioErr3 != nil {
  23390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23392. return
  23393. }
  23394. var respJSON3 map[string]interface{}
  23395. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23398. return
  23399. }
  23400. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23401. userJSONBytes3, _ := json.Marshal(respJSON3)
  23402. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23403. utils.ErrorLog("解析失败:%v", err)
  23404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23405. return
  23406. }
  23407. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23408. res2.Output = resSix10265.Output
  23409. res2.ErrMsg = resSix10265.ErrMsg
  23410. res2.Cainfo = resSix10265.Cainfo
  23411. res2.WarnMsg = resSix10265.WarnMsg
  23412. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23413. res2.Infcode = infocode
  23414. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23415. var api3 string
  23416. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  23417. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23419. resp3, requestErr3 := http.Get(api3)
  23420. if requestErr3 != nil {
  23421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23422. return
  23423. }
  23424. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23425. if ioErr3 != nil {
  23426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23428. return
  23429. }
  23430. var respJSON3 map[string]interface{}
  23431. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23434. return
  23435. }
  23436. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23437. userJSONBytes3, _ := json.Marshal(respJSON3)
  23438. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23439. utils.ErrorLog("解析失败:%v", err)
  23440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23441. return
  23442. }
  23443. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23444. res2.Output = resSix10265.Output
  23445. res2.ErrMsg = resSix10265.ErrMsg
  23446. res2.Cainfo = resSix10265.Cainfo
  23447. res2.WarnMsg = resSix10265.WarnMsg
  23448. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23449. res2.Infcode = infocode
  23450. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23451. 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)
  23452. var dat map[string]interface{}
  23453. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23454. fmt.Println(dat)
  23455. } else {
  23456. fmt.Println(err)
  23457. }
  23458. saveLog(result, request, "2202", "退号")
  23459. userJSONBytes, _ := json.Marshal(dat)
  23460. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23461. utils.ErrorLog("解析失败:%v", err)
  23462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23463. return
  23464. }
  23465. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23466. 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, "")
  23467. var dat map[string]interface{}
  23468. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23469. fmt.Println(dat)
  23470. } else {
  23471. fmt.Println(err)
  23472. }
  23473. saveLog(result, request, "2202", "退号")
  23474. userJSONBytes, _ := json.Marshal(dat)
  23475. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23476. utils.ErrorLog("解析失败:%v", err)
  23477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23478. return
  23479. }
  23480. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23481. var api3 string
  23482. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  23483. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23484. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23485. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23486. resp3, requestErr3 := http.Get(api3)
  23487. if requestErr3 != nil {
  23488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23489. return
  23490. }
  23491. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23492. if ioErr3 != nil {
  23493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23495. return
  23496. }
  23497. var respJSON3 map[string]interface{}
  23498. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23501. return
  23502. }
  23503. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23504. if status == "0" {
  23505. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23506. c.ServeSuccessJSON(map[string]interface{}{
  23507. "failed_code": -10,
  23508. "msg": err_msg,
  23509. })
  23510. return
  23511. }
  23512. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23513. userJSONBytes3, _ := json.Marshal(respJSON3)
  23514. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23515. utils.ErrorLog("解析失败:%v", err)
  23516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23517. return
  23518. }
  23519. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  23520. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23521. 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, "")
  23522. var dat map[string]interface{}
  23523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23524. fmt.Println(dat)
  23525. } else {
  23526. fmt.Println(err)
  23527. }
  23528. saveLog(result, request, "2202", "退号")
  23529. userJSONBytes, _ := json.Marshal(dat)
  23530. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23531. utils.ErrorLog("解析失败:%v", err)
  23532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23533. return
  23534. }
  23535. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23536. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  23537. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23538. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23539. resp3, requestErr3 := http.Get(api3)
  23540. if requestErr3 != nil {
  23541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23542. return
  23543. }
  23544. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23545. if ioErr3 != nil {
  23546. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23548. return
  23549. }
  23550. var respJSON3 map[string]interface{}
  23551. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23552. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23554. return
  23555. }
  23556. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23557. userJSONBytes3, _ := json.Marshal(respJSON3)
  23558. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23559. utils.ErrorLog("解析失败:%v", err)
  23560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23561. return
  23562. }
  23563. } else {
  23564. var api3 string
  23565. if miConfig.Code == "H15049901371" {
  23566. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  23567. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23569. } else {
  23570. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  23571. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23572. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  23573. }
  23574. resp3, requestErr3 := http.Get(api3)
  23575. if requestErr3 != nil {
  23576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23577. return
  23578. }
  23579. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23580. if ioErr3 != nil {
  23581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23583. return
  23584. }
  23585. var respJSON3 map[string]interface{}
  23586. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23589. return
  23590. }
  23591. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23592. userJSONBytes3, _ := json.Marshal(respJSON3)
  23593. if miConfig.Code == "H15049901371" {
  23594. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23595. utils.ErrorLog("解析失败:%v", err)
  23596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23597. return
  23598. }
  23599. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23600. res2.Output = resSix10265.Output
  23601. res2.ErrMsg = resSix10265.ErrMsg
  23602. res2.Cainfo = resSix10265.Cainfo
  23603. res2.WarnMsg = resSix10265.WarnMsg
  23604. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23605. res2.Infcode = infocode
  23606. } else {
  23607. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23608. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  23609. utils.ErrorLog("解析失败:%v", err)
  23610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23611. return
  23612. }
  23613. res2.Infcode = res3.Infcode
  23614. } else {
  23615. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23616. utils.ErrorLog("解析失败:%v", err)
  23617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23618. return
  23619. }
  23620. }
  23621. }
  23622. }
  23623. if res2.Infcode == -1 {
  23624. utils.ErrorLog("解析失败:%v", res2.Infcode)
  23625. c.ServeSuccessJSON(map[string]interface{}{
  23626. "failed_code": -10,
  23627. "msg": res2.ErrMsg,
  23628. })
  23629. return
  23630. }
  23631. if res2.Infcode == 0 {
  23632. if err == nil {
  23633. c.ServeSuccessJSON(map[string]interface{}{
  23634. "msg": "退号成功",
  23635. })
  23636. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  23637. } else {
  23638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23639. return
  23640. }
  23641. }
  23642. } else {
  23643. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  23644. //if err == nil {
  23645. // c.ServeSuccessJSON(map[string]interface{}{
  23646. // "msg": "退费成功",
  23647. // })
  23648. //} else {
  23649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23650. // return
  23651. //}
  23652. }
  23653. }
  23654. func (c *HisApiController) RefundDetail() {
  23655. order_id, _ := c.GetInt64("order_id")
  23656. admin_user_id, _ := c.GetInt64("admin_user_id")
  23657. //his_patient_id, _ := c.GetInt64("his_patient_id")
  23658. number := c.GetString("number")
  23659. record_time := c.GetString("record_time")
  23660. patient_id, _ := c.GetInt64("patient_id")
  23661. //med_type, _ := c.GetInt64("med_type")
  23662. timeLayout := "2006-01-02"
  23663. loc, _ := time.LoadLocation("Local")
  23664. adminUser := c.GetAdminUserInfo()
  23665. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23666. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  23667. fmt.Println(err)
  23668. if err != nil {
  23669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23670. return
  23671. }
  23672. recordDateTime := theTime.Unix()
  23673. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  23674. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  23675. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23676. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23677. var order models.HisOrder
  23678. order, _ = service.GetHisOrderByID(order_id)
  23679. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23680. if config.IsOpen == 1 { //对接了医保,走医保流程
  23681. var res2 ResultSix
  23682. if miConfig.MdtrtareaAdmvs == "421300" {
  23683. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23684. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23685. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23686. resp3, requestErr3 := http.Get(api3)
  23687. if requestErr3 != nil {
  23688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23689. return
  23690. }
  23691. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23692. if ioErr3 != nil {
  23693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23695. return
  23696. }
  23697. var respJSON3 map[string]interface{}
  23698. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23701. return
  23702. }
  23703. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23704. userJSONBytes3, _ := json.Marshal(respJSON3)
  23705. fmt.Println("log")
  23706. fmt.Println(string(userJSONBytes3))
  23707. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23708. utils.ErrorLog("解析失败:%v", err)
  23709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23710. return
  23711. }
  23712. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23713. if err == nil {
  23714. c.ServeSuccessJSON(map[string]interface{}{
  23715. "msg": "撤销明细成功",
  23716. })
  23717. return
  23718. } else {
  23719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23720. return
  23721. }
  23722. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23723. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23724. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23725. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23726. resp3, requestErr3 := http.Get(api3)
  23727. if requestErr3 != nil {
  23728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23729. return
  23730. }
  23731. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23732. if ioErr3 != nil {
  23733. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23735. return
  23736. }
  23737. var respJSON3 map[string]interface{}
  23738. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23739. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23741. return
  23742. }
  23743. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23744. userJSONBytes3, _ := json.Marshal(respJSON3)
  23745. fmt.Println("log")
  23746. fmt.Println(string(userJSONBytes3))
  23747. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23748. utils.ErrorLog("解析失败:%v", err)
  23749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23750. return
  23751. }
  23752. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23753. if err == nil {
  23754. c.ServeSuccessJSON(map[string]interface{}{
  23755. "msg": "撤销明细成功",
  23756. })
  23757. return
  23758. } else {
  23759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23760. return
  23761. }
  23762. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23763. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  23764. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23765. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23766. resp3, requestErr3 := http.Get(api3)
  23767. if requestErr3 != nil {
  23768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23769. return
  23770. }
  23771. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23772. if ioErr3 != nil {
  23773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23775. return
  23776. }
  23777. var respJSON3 map[string]interface{}
  23778. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23781. return
  23782. }
  23783. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23784. userJSONBytes3, _ := json.Marshal(respJSON3)
  23785. fmt.Println("log")
  23786. fmt.Println(string(userJSONBytes3))
  23787. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23788. utils.ErrorLog("解析失败:%v", err)
  23789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23790. return
  23791. }
  23792. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23793. if err == nil {
  23794. c.ServeSuccessJSON(map[string]interface{}{
  23795. "msg": "撤销明细成功",
  23796. })
  23797. return
  23798. } else {
  23799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23800. return
  23801. }
  23802. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23803. var resSix10265 ResultSix10265
  23804. var api3 string
  23805. if miConfig.MdtrtareaAdmvs == "320921" {
  23806. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23807. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23809. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23810. } else {
  23811. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23812. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  23813. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23814. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23815. }
  23816. resp3, requestErr3 := http.Get(api3)
  23817. utils.ErrorLog("接口: %v", requestErr3)
  23818. if requestErr3 != nil {
  23819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23820. return
  23821. }
  23822. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23823. if ioErr3 != nil {
  23824. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23826. return
  23827. }
  23828. var respJSON3 map[string]interface{}
  23829. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23830. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23832. return
  23833. }
  23834. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23835. userJSONBytes3, _ := json.Marshal(respJSON3)
  23836. fmt.Println("log")
  23837. fmt.Println(string(userJSONBytes3))
  23838. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23839. utils.ErrorLog("解析失败:%v", err)
  23840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23841. return
  23842. }
  23843. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23844. res2.Output = resSix10265.Output
  23845. res2.ErrMsg = resSix10265.ErrMsg
  23846. res2.Cainfo = resSix10265.Cainfo
  23847. res2.WarnMsg = resSix10265.WarnMsg
  23848. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23849. res2.Infcode = infocode
  23850. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23851. if err == nil {
  23852. c.ServeSuccessJSON(map[string]interface{}{
  23853. "msg": "撤销明细成功",
  23854. })
  23855. return
  23856. } else {
  23857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23858. return
  23859. }
  23860. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23861. var api3 string
  23862. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  23863. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23864. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23865. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23866. resp3, requestErr3 := http.Get(api3)
  23867. utils.ErrorLog("接口: %v", requestErr3)
  23868. if requestErr3 != nil {
  23869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23870. return
  23871. }
  23872. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23873. if ioErr3 != nil {
  23874. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23876. return
  23877. }
  23878. var respJSON3 map[string]interface{}
  23879. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23880. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. return
  23883. }
  23884. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23885. if status == "0" {
  23886. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23887. c.ServeSuccessJSON(map[string]interface{}{
  23888. "failed_code": -10,
  23889. "msg": err_msg,
  23890. })
  23891. return
  23892. }
  23893. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23894. userJSONBytes3, _ := json.Marshal(respJSON3)
  23895. fmt.Println("log")
  23896. fmt.Println(string(userJSONBytes3))
  23897. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23898. utils.ErrorLog("解析失败:%v", err)
  23899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23900. return
  23901. }
  23902. fmt.Println(res2.Infcode)
  23903. if res2.Infcode == -1 {
  23904. c.ServeSuccessJSON(map[string]interface{}{
  23905. "failed_code": -10,
  23906. "msg": res2.ErrMsg,
  23907. })
  23908. return
  23909. }
  23910. if res2.Infcode == 0 {
  23911. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23912. if err == nil {
  23913. c.ServeSuccessJSON(map[string]interface{}{
  23914. "msg": "撤销明细成功",
  23915. })
  23916. return
  23917. } else {
  23918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23919. return
  23920. }
  23921. } else {
  23922. c.ServeSuccessJSON(map[string]interface{}{
  23923. "failed_code": -10,
  23924. "msg": res2.ErrMsg,
  23925. })
  23926. }
  23927. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23928. if err == nil {
  23929. c.ServeSuccessJSON(map[string]interface{}{
  23930. "msg": "撤销明细成功",
  23931. })
  23932. return
  23933. } else {
  23934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23935. return
  23936. }
  23937. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23938. var resSix10265 ResultSix10265
  23939. var api3 string
  23940. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  23941. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23942. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23943. resp3, requestErr3 := http.Get(api3)
  23944. if requestErr3 != nil {
  23945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23946. return
  23947. }
  23948. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23949. if ioErr3 != nil {
  23950. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23952. return
  23953. }
  23954. var respJSON3 map[string]interface{}
  23955. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23958. return
  23959. }
  23960. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23961. userJSONBytes3, _ := json.Marshal(respJSON3)
  23962. fmt.Println("log")
  23963. fmt.Println(string(userJSONBytes3))
  23964. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  23965. utils.ErrorLog("解析失败:%v", err)
  23966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23967. return
  23968. }
  23969. res2.InfRefmsgid = resSix10265.InfRefmsgid
  23970. res2.Output = resSix10265.Output
  23971. res2.ErrMsg = resSix10265.ErrMsg
  23972. res2.Cainfo = resSix10265.Cainfo
  23973. res2.WarnMsg = resSix10265.WarnMsg
  23974. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  23975. res2.Infcode = infocode
  23976. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  23977. if err == nil {
  23978. c.ServeSuccessJSON(map[string]interface{}{
  23979. "msg": "撤销明细成功",
  23980. })
  23981. return
  23982. } else {
  23983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23984. return
  23985. }
  23986. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23987. 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)
  23988. var dat map[string]interface{}
  23989. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  23990. fmt.Println(dat)
  23991. } else {
  23992. fmt.Println(err)
  23993. }
  23994. saveLog(result2, src_request, "2205", "撤销明细")
  23995. userJSONBytes, _ := json.Marshal(dat)
  23996. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  23997. utils.ErrorLog("解析失败:%v", err)
  23998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23999. return
  24000. }
  24001. if res2.Infcode == 0 {
  24002. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24003. if err == nil {
  24004. c.ServeSuccessJSON(map[string]interface{}{
  24005. "msg": "撤销明细成功",
  24006. })
  24007. return
  24008. } else {
  24009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24010. return
  24011. }
  24012. } else {
  24013. c.ServeSuccessJSON(map[string]interface{}{
  24014. "failed_code": -10,
  24015. "msg": res2.ErrMsg,
  24016. })
  24017. }
  24018. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24019. 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, "")
  24020. var dat map[string]interface{}
  24021. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24022. fmt.Println(dat)
  24023. } else {
  24024. fmt.Println(err)
  24025. }
  24026. saveLog(result2, src_request, "2205", "撤销明细")
  24027. userJSONBytes, _ := json.Marshal(dat)
  24028. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24029. utils.ErrorLog("解析失败:%v", err)
  24030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24031. return
  24032. }
  24033. if res2.Infcode == 0 {
  24034. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24035. if err == nil {
  24036. c.ServeSuccessJSON(map[string]interface{}{
  24037. "msg": "撤销明细成功",
  24038. })
  24039. return
  24040. } else {
  24041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24042. return
  24043. }
  24044. } else {
  24045. c.ServeSuccessJSON(map[string]interface{}{
  24046. "failed_code": -10,
  24047. "msg": res2.ErrMsg,
  24048. })
  24049. }
  24050. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24051. 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, "")
  24052. var dat map[string]interface{}
  24053. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24054. fmt.Println(dat)
  24055. } else {
  24056. fmt.Println(err)
  24057. }
  24058. saveLog(result2, src_request, "2205", "撤销明细")
  24059. userJSONBytes, _ := json.Marshal(dat)
  24060. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24061. utils.ErrorLog("解析失败:%v", err)
  24062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24063. return
  24064. }
  24065. if res2.Infcode == 0 {
  24066. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24067. if err == nil {
  24068. c.ServeSuccessJSON(map[string]interface{}{
  24069. "msg": "撤销明细成功",
  24070. })
  24071. return
  24072. } else {
  24073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24074. return
  24075. }
  24076. } else {
  24077. c.ServeSuccessJSON(map[string]interface{}{
  24078. "failed_code": -10,
  24079. "msg": res2.ErrMsg,
  24080. })
  24081. }
  24082. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24083. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  24084. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24085. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24086. resp2, requestErr2 := http.Get(api2)
  24087. if requestErr2 != nil {
  24088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24089. return
  24090. }
  24091. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24092. if ioErr2 != nil {
  24093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24095. return
  24096. }
  24097. var respJSON2 map[string]interface{}
  24098. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24101. return
  24102. }
  24103. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24104. userJSONBytes3, _ := json.Marshal(respJSON2)
  24105. fmt.Println("log")
  24106. fmt.Println(string(userJSONBytes3))
  24107. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24108. utils.ErrorLog("解析失败:%v", err)
  24109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24110. return
  24111. }
  24112. if res2.Infcode == 0 {
  24113. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24114. if err == nil {
  24115. c.ServeSuccessJSON(map[string]interface{}{
  24116. "msg": "撤销明细成功",
  24117. })
  24118. return
  24119. } else {
  24120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24121. return
  24122. }
  24123. } else {
  24124. c.ServeSuccessJSON(map[string]interface{}{
  24125. "failed_code": -10,
  24126. "msg": res2.ErrMsg,
  24127. })
  24128. }
  24129. } else {
  24130. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  24131. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24132. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24133. resp2, requestErr2 := http.Get(api2)
  24134. if requestErr2 != nil {
  24135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24136. return
  24137. }
  24138. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  24139. if ioErr2 != nil {
  24140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  24141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24142. return
  24143. }
  24144. var respJSON2 map[string]interface{}
  24145. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  24146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24148. return
  24149. }
  24150. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24151. if err == nil {
  24152. c.ServeSuccessJSON(map[string]interface{}{
  24153. "msg": "撤销明细成功",
  24154. })
  24155. return
  24156. } else {
  24157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24158. return
  24159. }
  24160. }
  24161. } else {
  24162. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24163. if err == nil {
  24164. c.ServeSuccessJSON(map[string]interface{}{
  24165. "msg": "退费成功",
  24166. })
  24167. } else {
  24168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24169. return
  24170. }
  24171. }
  24172. }
  24173. // 对账
  24174. func (c *HisApiController) GetCheckAccount() {
  24175. start_time := c.GetString("start_time")
  24176. end_time := c.GetString("end_time")
  24177. insutype := c.GetString("insutype")
  24178. clr_type := c.GetString("clr_type")
  24179. clr_org := c.GetString("clr_optins")
  24180. admin_user_id, _ := c.GetInt64("admin_user_id")
  24181. adminUser := c.GetAdminUserInfo()
  24182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24184. if len(clr_org) == 0 {
  24185. clr_org = miConfig.InsuplcAdmdvs
  24186. }
  24187. timeLayout := "2006-01-02"
  24188. loc, _ := time.LoadLocation("Local")
  24189. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24190. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24191. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24192. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  24193. fixmedins_setl_cnt := int64(len(orders))
  24194. var medfee_sumamt float64
  24195. var acct_pay float64
  24196. var fund_pay_sumamt float64
  24197. for _, item := range orders {
  24198. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24199. acct_pay = acct_pay + item.AcctPay
  24200. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24201. }
  24202. var user_name string
  24203. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24204. if role.ID == 0 {
  24205. user_name = "xxx"
  24206. } else {
  24207. user_name = role.UserName
  24208. }
  24209. var res ResultEight
  24210. var res10188 ResultEightFor10188
  24211. if config.IsOpen == 1 {
  24212. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24213. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  24214. "insutype=" + insutype +
  24215. "&clr_type=" + clr_type +
  24216. "&setl_optins=" + clr_org +
  24217. "&stmt_begndate=" + start_time +
  24218. "&stm_enddate=" + end_time +
  24219. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24220. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24221. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24222. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24223. "&fixmedins_code=" + miConfig.Code +
  24224. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24225. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24226. "&secret_key=" + miConfig.SecretKey +
  24227. "&org_name=" + miConfig.OrgName +
  24228. "&doctor=" + user_name +
  24229. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24230. fmt.Println(api)
  24231. resp, requestErr := http.Get(api)
  24232. if requestErr != nil {
  24233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24234. return
  24235. }
  24236. body, ioErr := ioutil.ReadAll(resp.Body)
  24237. fmt.Println(body)
  24238. if ioErr != nil {
  24239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24241. return
  24242. }
  24243. var respJSON map[string]interface{}
  24244. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24247. return
  24248. }
  24249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24250. userJSONBytes, _ := json.Marshal(respJSON)
  24251. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24252. utils.ErrorLog("解析失败:%v", err)
  24253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24254. return
  24255. }
  24256. res.InfRefmsgid = res10188.InfRefmsgid
  24257. res.Output = res10188.Output
  24258. res.ErrMsg = res10188.ErrMsg
  24259. res.Cainfo = res10188.Cainfo
  24260. res.WarnMsg = res10188.WarnMsg
  24261. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24262. res.Infcode = infocode
  24263. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24264. if clr_type != "9903" {
  24265. clr_type = "99" // 就诊 ID(来自2201接口返回)
  24266. }
  24267. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  24268. "insutype=" + insutype +
  24269. "&clr_type=" + clr_type +
  24270. "&setl_optins=" + clr_org +
  24271. "&stmt_begndate=" + start_time +
  24272. "&stm_enddate=" + end_time +
  24273. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24274. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24275. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24276. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24277. "&fixmedins_code=" + miConfig.Code +
  24278. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24279. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24280. "&secret_key=" + miConfig.SecretKey +
  24281. "&org_name=" + miConfig.OrgName +
  24282. "&doctor=" + user_name
  24283. resp, requestErr := http.Get(api)
  24284. if requestErr != nil {
  24285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24286. return
  24287. }
  24288. body, ioErr := ioutil.ReadAll(resp.Body)
  24289. if ioErr != nil {
  24290. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24292. return
  24293. }
  24294. var respJSON map[string]interface{}
  24295. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24296. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24298. return
  24299. }
  24300. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24301. result, _ := json.Marshal(respJSON)
  24302. fmt.Println("log")
  24303. fmt.Println(string(result))
  24304. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  24305. utils.ErrorLog("解析失败:%v", err)
  24306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24307. return
  24308. }
  24309. res.InfRefmsgid = res10188.InfRefmsgid
  24310. res.Output = res10188.Output
  24311. res.ErrMsg = res10188.ErrMsg
  24312. res.Cainfo = res10188.Cainfo
  24313. res.WarnMsg = res10188.WarnMsg
  24314. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  24315. res.Infcode = infocode
  24316. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24317. var baseParams models.BaseParams
  24318. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24319. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24320. baseParams.SecretKey = miConfig.SecretKey
  24321. baseParams.OrgName = miConfig.OrgName
  24322. baseParams.FixmedinsCode = miConfig.Code
  24323. baseParams.EncKey = miConfig.EncKey
  24324. baseParams.AppSecret = miConfig.AppSecret
  24325. baseParams.SignKey = miConfig.SignKey
  24326. baseParams.AppID = miConfig.Code
  24327. baseParams.Doctor = role.UserName
  24328. baseParams.RequestUrl = miConfig.Url
  24329. businessParams := models.BusinessParams{
  24330. Insutype: insutype,
  24331. ClrType: clr_type,
  24332. SetlOptins: clr_org,
  24333. StmtBegndate: start_time,
  24334. StmtEnddate: end_time,
  24335. MedfeeSumamt: medfee_sumamt,
  24336. FundPaySumamt: fund_pay_sumamt,
  24337. AcctPay: acct_pay,
  24338. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24339. }
  24340. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24341. fmt.Println(requestLog)
  24342. fmt.Println(result)
  24343. fmt.Println(err_msg)
  24344. var dat map[string]interface{}
  24345. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24346. fmt.Println(dat)
  24347. } else {
  24348. fmt.Println(err)
  24349. }
  24350. userJSONBytes, _ := json.Marshal(dat)
  24351. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24352. utils.ErrorLog("解析失败:%v", err)
  24353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24354. return
  24355. }
  24356. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24357. var baseParams models.BaseParams
  24358. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24359. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24360. baseParams.SecretKey = miConfig.SecretKey
  24361. baseParams.OrgName = miConfig.OrgName
  24362. baseParams.FixmedinsCode = miConfig.Code
  24363. baseParams.EncKey = miConfig.EncKey
  24364. baseParams.AppSecret = miConfig.AppSecret
  24365. baseParams.SignKey = miConfig.SignKey
  24366. baseParams.AppID = miConfig.Code
  24367. baseParams.Doctor = role.UserName
  24368. baseParams.RequestUrl = miConfig.Url
  24369. baseParams.AccessKey = miConfig.AccessKey
  24370. businessParams := models.BusinessParams{
  24371. Insutype: insutype,
  24372. ClrType: clr_type,
  24373. SetlOptins: "430822",
  24374. StmtBegndate: start_time,
  24375. StmtEnddate: end_time,
  24376. MedfeeSumamt: medfee_sumamt,
  24377. FundPaySumamt: fund_pay_sumamt,
  24378. AcctPay: acct_pay,
  24379. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24380. }
  24381. 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)
  24382. fmt.Println(requestLog)
  24383. fmt.Println(result)
  24384. var dat map[string]interface{}
  24385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24386. fmt.Println(dat)
  24387. } else {
  24388. fmt.Println(err)
  24389. }
  24390. userJSONBytes, _ := json.Marshal(dat)
  24391. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24392. utils.ErrorLog("解析失败:%v", err)
  24393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24394. return
  24395. }
  24396. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24397. var baseParams models.BaseParams
  24398. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24399. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24400. baseParams.SecretKey = miConfig.SecretKey
  24401. baseParams.OrgName = miConfig.OrgName
  24402. baseParams.FixmedinsCode = miConfig.Code
  24403. baseParams.EncKey = miConfig.EncKey
  24404. baseParams.AppSecret = miConfig.AppSecret
  24405. baseParams.SignKey = miConfig.SignKey
  24406. baseParams.AppID = miConfig.Code
  24407. baseParams.Doctor = role.UserName
  24408. baseParams.RequestUrl = miConfig.Url
  24409. businessParams := models.BusinessParams{
  24410. Insutype: insutype,
  24411. ClrType: clr_type,
  24412. SetlOptins: clr_org,
  24413. StmtBegndate: start_time,
  24414. StmtEnddate: end_time,
  24415. MedfeeSumamt: medfee_sumamt,
  24416. FundPaySumamt: fund_pay_sumamt,
  24417. AcctPay: acct_pay,
  24418. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24419. }
  24420. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  24421. fmt.Println(requestLog)
  24422. fmt.Println(result)
  24423. fmt.Println(err_msg)
  24424. var dat map[string]interface{}
  24425. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24426. fmt.Println(dat)
  24427. } else {
  24428. fmt.Println(err)
  24429. }
  24430. userJSONBytes, _ := json.Marshal(dat)
  24431. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24432. utils.ErrorLog("解析失败:%v", err)
  24433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24434. return
  24435. }
  24436. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24437. if len(clr_type) == 0 {
  24438. clr_type = "11"
  24439. }
  24440. api := miConfig.Url + "gdyb/ten?" +
  24441. "insutype=" + insutype +
  24442. "&clr_type=" + clr_type +
  24443. "&setl_optins=" + clr_org +
  24444. "&stmt_begndate=" + start_time +
  24445. "&stm_enddate=" + end_time +
  24446. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24447. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24448. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24449. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24450. "&fixmedins_code=" + miConfig.Code +
  24451. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24452. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24453. "&secret_key=" + miConfig.SecretKey +
  24454. "&org_name=" + miConfig.OrgName +
  24455. "&doctor=" + user_name
  24456. fmt.Println(api)
  24457. resp, requestErr := http.Get(api)
  24458. if requestErr != nil {
  24459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24460. return
  24461. }
  24462. body, ioErr := ioutil.ReadAll(resp.Body)
  24463. fmt.Println(body)
  24464. if ioErr != nil {
  24465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24467. return
  24468. }
  24469. var respJSON map[string]interface{}
  24470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24473. return
  24474. }
  24475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24476. userJSONBytes, _ := json.Marshal(respJSON)
  24477. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24478. utils.ErrorLog("解析失败:%v", err)
  24479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24480. return
  24481. }
  24482. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24483. var baseParams models.BaseParams
  24484. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  24485. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  24486. baseParams.SecretKey = miConfig.SecretKey
  24487. baseParams.OrgName = miConfig.OrgName
  24488. baseParams.FixmedinsCode = miConfig.Code
  24489. baseParams.EncKey = miConfig.EncKey
  24490. baseParams.AppSecret = miConfig.AppSecret
  24491. baseParams.SignKey = miConfig.SignKey
  24492. baseParams.AppID = miConfig.Code
  24493. baseParams.Doctor = role.UserName
  24494. baseParams.RequestUrl = miConfig.Url
  24495. if clr_type == "9903" {
  24496. clr_type = "9901"
  24497. }
  24498. businessParams := models.BusinessParams{
  24499. Insutype: insutype,
  24500. ClrType: clr_type,
  24501. SetlOptins: "360302",
  24502. StmtBegndate: start_time,
  24503. StmtEnddate: end_time,
  24504. MedfeeSumamt: 0,
  24505. FundPaySumamt: 0,
  24506. AcctPay: 0,
  24507. FixmedinsSetlCnt: fixmedins_setl_cnt,
  24508. }
  24509. 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))
  24510. fmt.Println(requestLog)
  24511. fmt.Println(result)
  24512. var dat map[string]interface{}
  24513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24514. fmt.Println(dat)
  24515. } else {
  24516. fmt.Println(err)
  24517. }
  24518. userJSONBytes, _ := json.Marshal(dat)
  24519. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24520. utils.ErrorLog("解析失败:%v", err)
  24521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24522. return
  24523. }
  24524. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24525. var api string
  24526. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  24527. "&clr_type=" + clr_type +
  24528. "&setl_optins=" + clr_org +
  24529. "&stmt_begndate=" + start_time +
  24530. "&stm_enddate=" + end_time +
  24531. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24532. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24533. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24534. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  24535. "&fixmedins_code=" + miConfig.Code +
  24536. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24537. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24538. "&secret_key=" + miConfig.SecretKey +
  24539. "&org_name=" + miConfig.OrgName +
  24540. "&doctor=" + user_name + "&url=" + miConfig.Url
  24541. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24542. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24543. resp, requestErr := http.Get(api)
  24544. if requestErr != nil {
  24545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24546. return
  24547. }
  24548. body, ioErr := ioutil.ReadAll(resp.Body)
  24549. if ioErr != nil {
  24550. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24552. return
  24553. }
  24554. var respJSON map[string]interface{}
  24555. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24556. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24558. return
  24559. }
  24560. status := respJSON["data"].(map[string]interface{})["status"].(string)
  24561. if status == "0" {
  24562. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  24563. c.ServeSuccessJSON(map[string]interface{}{
  24564. "failed_code": -10,
  24565. "msg": err_msg,
  24566. })
  24567. return
  24568. }
  24569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24570. userJSONBytes, _ := json.Marshal(respJSON)
  24571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24572. utils.ErrorLog("解析失败:%v", err)
  24573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24574. return
  24575. }
  24576. } else {
  24577. if len(clr_type) == 0 {
  24578. clr_type = "11"
  24579. }
  24580. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24581. "insutype=" + insutype +
  24582. "&clr_type=" + clr_type +
  24583. "&setl_optins=" + clr_org +
  24584. "&stmt_begndate=" + start_time +
  24585. "&stm_enddate=" + end_time +
  24586. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24587. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24588. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  24589. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24590. "&fixmedins_code=" + miConfig.Code +
  24591. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24592. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24593. "&secret_key=" + miConfig.SecretKey +
  24594. "&org_name=" + miConfig.OrgName +
  24595. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24596. fmt.Println(api)
  24597. resp, requestErr := http.Get(api)
  24598. if requestErr != nil {
  24599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24600. return
  24601. }
  24602. body, ioErr := ioutil.ReadAll(resp.Body)
  24603. fmt.Println(body)
  24604. if ioErr != nil {
  24605. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24607. return
  24608. }
  24609. var respJSON map[string]interface{}
  24610. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24611. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24613. return
  24614. }
  24615. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24616. userJSONBytes, _ := json.Marshal(respJSON)
  24617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24618. utils.ErrorLog("解析失败:%v", err)
  24619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24620. return
  24621. }
  24622. }
  24623. if res.Infcode == 0 {
  24624. if res.Output.Stmtinfo.StmtRslt == "0" {
  24625. micc := &models.MedicalInsuranceCostCompare{
  24626. StartTime: startime.Unix(),
  24627. EndTime: endtime.Unix(),
  24628. Insutype: insutype,
  24629. CheckType: 1,
  24630. Num: fixmedins_setl_cnt,
  24631. Mtime: time.Now().Unix(),
  24632. Status: 1,
  24633. UserOrgId: adminUser.CurrentOrgId,
  24634. CostTotal: medfee_sumamt,
  24635. FuncTotal: fund_pay_sumamt,
  24636. PsnPay: acct_pay,
  24637. Creator: admin_user_id,
  24638. Ctime: time.Now().Unix(),
  24639. ClrType: clr_type,
  24640. }
  24641. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  24642. if err == nil {
  24643. c.ServeSuccessJSON(map[string]interface{}{
  24644. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24645. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24646. })
  24647. } else {
  24648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24649. }
  24650. } else {
  24651. c.ServeSuccessJSON(map[string]interface{}{
  24652. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  24653. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  24654. })
  24655. }
  24656. } else {
  24657. c.ServeSuccessJSON(map[string]interface{}{
  24658. "failed_code": -10,
  24659. "msg": res.ErrMsg,
  24660. })
  24661. }
  24662. }
  24663. }
  24664. func (c *HisApiController) Check310() {
  24665. adminUser := c.GetAdminUserInfo()
  24666. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24667. var user_name string
  24668. user_name = "高慧裕"
  24669. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24670. "insutype=" + "310" +
  24671. "&clr_type=" + "" +
  24672. "&setl_optins=" + "441202" +
  24673. "&stmt_begndate=" + "2022-03-01" +
  24674. "&stm_enddate=" + "2022-03-31" +
  24675. "&medfee_sumamt=" + "194930.12" +
  24676. "&fund_pay_sumamt=" + "188741.46" +
  24677. "&acct_pay=" + "0" +
  24678. "&fixmedins_setl_cnt=" + "452" +
  24679. "&fixmedins_code=" + miConfig.Code +
  24680. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24681. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24682. "&secret_key=" + miConfig.SecretKey +
  24683. "&org_name=" + miConfig.OrgName +
  24684. "&doctor=" + user_name
  24685. fmt.Println(api)
  24686. resp, requestErr := http.Get(api)
  24687. if requestErr != nil {
  24688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24689. return
  24690. }
  24691. body, ioErr := ioutil.ReadAll(resp.Body)
  24692. fmt.Println(body)
  24693. if ioErr != nil {
  24694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24696. return
  24697. }
  24698. var respJSON map[string]interface{}
  24699. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24702. return
  24703. }
  24704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24705. userJSONBytes, _ := json.Marshal(respJSON)
  24706. var res ResultEight
  24707. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24708. utils.ErrorLog("解析失败:%v", err)
  24709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24710. return
  24711. }
  24712. }
  24713. func (c *HisApiController) Check390() {
  24714. adminUser := c.GetAdminUserInfo()
  24715. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24716. var user_name string
  24717. user_name = "高慧裕"
  24718. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  24719. "insutype=" + "390" +
  24720. "&clr_type=" + "" +
  24721. "&setl_optins=" + "441202" +
  24722. "&stmt_begndate=" + "2022-03-01" +
  24723. "&stm_enddate=" + "2022-03-31" +
  24724. "&medfee_sumamt=" + "1068448.89" +
  24725. "&fund_pay_sumamt=" + "1014677.62" +
  24726. "&acct_pay=" + "0" +
  24727. "&fixmedins_setl_cnt=" + "1950" +
  24728. "&fixmedins_code=" + miConfig.Code +
  24729. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24730. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24731. "&secret_key=" + miConfig.SecretKey +
  24732. "&org_name=" + miConfig.OrgName +
  24733. "&doctor=" + user_name
  24734. fmt.Println(api)
  24735. resp, requestErr := http.Get(api)
  24736. if requestErr != nil {
  24737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24738. return
  24739. }
  24740. body, ioErr := ioutil.ReadAll(resp.Body)
  24741. fmt.Println(body)
  24742. if ioErr != nil {
  24743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24745. return
  24746. }
  24747. var respJSON map[string]interface{}
  24748. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24751. return
  24752. }
  24753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24754. userJSONBytes, _ := json.Marshal(respJSON)
  24755. var res ResultEight
  24756. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24757. utils.ErrorLog("解析失败:%v", err)
  24758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24759. return
  24760. }
  24761. }
  24762. // 对账明细
  24763. func (c *HisApiController) GetCheckDetailAccount() {
  24764. start_time := c.GetString("start_time")
  24765. end_time := c.GetString("end_time")
  24766. admin_user_id, _ := c.GetInt64("admin_user_id")
  24767. adminUser := c.GetAdminUserInfo()
  24768. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24769. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24770. timeLayout := "2006-01-02"
  24771. loc, _ := time.LoadLocation("Local")
  24772. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  24773. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  24774. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  24775. rand.Seed(time.Now().UnixNano())
  24776. num := rand.Intn(30000)
  24777. Mkdir(miConfig.OrgName)
  24778. file := strconv.FormatInt(int64(num), 10)
  24779. file_name := file + ".txt"
  24780. zip_name := file + ".zip"
  24781. zip_path := miConfig.OrgName + "/" + zip_name
  24782. file_path := miConfig.OrgName + "/" + file_name
  24783. decimal.DivisionPrecision = 2
  24784. var medfee_sumamt float64
  24785. var psn_cash_pay float64
  24786. var fund_pay_sumamt float64
  24787. fixmedins_setl_cnt := int64(len(orders))
  24788. for _, item := range orders {
  24789. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  24790. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  24791. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  24792. }
  24793. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  24794. defer f.Close()
  24795. if err != nil {
  24796. fmt.Println(err.Error())
  24797. } else {
  24798. for _, item := range orders {
  24799. var refd_setl_flag string
  24800. if item.OrderStatus == 2 {
  24801. refd_setl_flag = "0"
  24802. var str string
  24803. str = item.SetlId + " " +
  24804. item.MdtrtId + " " +
  24805. item.PsnNo + " " +
  24806. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24807. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24808. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  24809. _, err = f.Write([]byte(str))
  24810. }
  24811. if item.OrderStatus == 3 {
  24812. var str string
  24813. str = item.SetlId + " " +
  24814. item.MdtrtId + " " +
  24815. item.PsnNo + " " +
  24816. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  24817. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  24818. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  24819. _, err = f.Write([]byte(str))
  24820. var str2 string
  24821. str2 = item.SetlId + " " +
  24822. item.MdtrtId + " " +
  24823. item.PsnNo + " " +
  24824. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  24825. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  24826. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  24827. _, err = f.Write([]byte(str2))
  24828. }
  24829. }
  24830. }
  24831. Zip(file_path, zip_path)
  24832. fmt.Println(ReadFile(zip_path))
  24833. fmt.Println(string(ReadFile(zip_path)))
  24834. if config.IsOpen == 1 {
  24835. var user_name string
  24836. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24837. if role.ID == 0 {
  24838. user_name = "管理员"
  24839. } else {
  24840. user_name = role.UserName
  24841. }
  24842. baseParams := models.BaseParams{
  24843. SecretKey: miConfig.SecretKey,
  24844. FixmedinsCode: miConfig.Code,
  24845. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  24846. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  24847. OrgName: miConfig.OrgName,
  24848. Doctor: user_name,
  24849. }
  24850. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  24851. var dat map[string]interface{}
  24852. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24853. fmt.Println(dat)
  24854. } else {
  24855. fmt.Println(err)
  24856. }
  24857. userJSONBytes, _ := json.Marshal(dat)
  24858. var res ResultNine
  24859. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24860. utils.ErrorLog("解析失败:%v", err)
  24861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24862. return
  24863. }
  24864. if res.Infcode == 0 {
  24865. fileNo := res.Output.FileQuryNo
  24866. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  24867. "file_qury_no=" + fileNo +
  24868. "&setl_optins=" + "定点医保中心" +
  24869. "&stmt_begndate=" + start_time +
  24870. "&stm_enddate=" + end_time +
  24871. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  24872. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  24873. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  24874. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  24875. "&fixmedins_code=" + miConfig.Code +
  24876. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  24877. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  24878. "&secret_key=" + miConfig.SecretKey +
  24879. "&org_name=" + miConfig.OrgName +
  24880. "&doctor=" + user_name
  24881. resp, requestErr := http.Get(api)
  24882. if requestErr != nil {
  24883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24884. return
  24885. }
  24886. body, ioErr := ioutil.ReadAll(resp.Body)
  24887. if ioErr != nil {
  24888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  24889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24890. return
  24891. }
  24892. var respJSON map[string]interface{}
  24893. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  24894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24896. return
  24897. }
  24898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24899. userJSONBytes, _ := json.Marshal(respJSON)
  24900. var res ResultTen
  24901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  24902. utils.ErrorLog("解析失败:%v", err)
  24903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24904. return
  24905. }
  24906. if res.Infcode == 0 {
  24907. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  24908. micc := &models.MedicalInsuranceCostCompare{
  24909. StartTime: startime.Unix(),
  24910. EndTime: endtime.Unix(),
  24911. Insutype: "0",
  24912. CheckType: 2,
  24913. Num: fixmedins_setl_cnt,
  24914. Mtime: time.Now().Unix(),
  24915. Status: 1,
  24916. UserOrgId: adminUser.CurrentOrgId,
  24917. CostTotal: medfee_sumamt,
  24918. FuncTotal: fund_pay_sumamt,
  24919. PsnPay: psn_cash_pay,
  24920. Creator: admin_user_id,
  24921. Ctime: time.Now().Unix(),
  24922. }
  24923. service.CreateMedicalInsuranceCostCompareRecord(micc)
  24924. c.ServeSuccessJSON(map[string]interface{}{
  24925. "msg": "明细对账成功",
  24926. })
  24927. }
  24928. } else {
  24929. }
  24930. }
  24931. }
  24932. type CustomOrderInfo struct {
  24933. Name string
  24934. Spec string
  24935. Unit string
  24936. Count float64
  24937. Price float64
  24938. Total float64
  24939. }
  24940. func (c *HisApiController) GetBatchSettleAccounts() {
  24941. admin_user_id, _ := c.GetInt64("admin_user_id")
  24942. order_ids := c.GetString("order_ids")
  24943. order_ids_arr := strings.Split(order_ids, ",")
  24944. data3 := []map[string]interface{}{}
  24945. for _, item := range order_ids_arr {
  24946. id, _ := strconv.ParseInt(item, 10, 64)
  24947. order_id := id
  24948. adminUser := c.GetAdminUserInfo()
  24949. order, _ := service.GetHisOrderByID(order_id)
  24950. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24951. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  24952. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  24953. orderInfos = append(orderInfos, orderInfos_two...)
  24954. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  24955. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  24956. var diagnosis_ids []string
  24957. if his.ID > 0 {
  24958. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  24959. } else {
  24960. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  24961. }
  24962. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  24963. var dia_config []*models.HisXtDiagnoseConfig
  24964. var name string
  24965. for _, item := range diagnosis_ids {
  24966. id, _ := strconv.ParseInt(item, 10, 64)
  24967. diagnosisConfig, _ := service.FindDiagnoseById(id)
  24968. dia_config = append(dia_config, &diagnosisConfig)
  24969. if len(name) == 0 {
  24970. name = diagnosisConfig.ClassName
  24971. }
  24972. //} else {
  24973. // name = name + "," + diagnosisConfig.ClassName
  24974. //}
  24975. }
  24976. var bedCostTotal float64 = 0 //床位总费
  24977. var bedCostSelfTotal float64 = 0 //床位自费
  24978. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  24979. var bedSelfTotal float64 = 0 //床位部分项目自费
  24980. var bedInscpTotal float64 = 0 //床位部分项目自费
  24981. var operationCostTotal float64 = 0 //手术费
  24982. var operationCostSelfTotal float64 = 0 //手术费
  24983. var operationCostPartSelfTotal float64 = 0 //手术费
  24984. var operationSelfTotal float64 = 0 //床位部分项目自费
  24985. var operationInscpTotal float64 = 0 //床位部分项目自费
  24986. var otherCostTotal float64 = 0 //其他费用
  24987. var otherCostSelfTotal float64 = 0 //其他费用
  24988. var otherCostPartSelfTotal float64 = 0 //其他费用
  24989. var otherSelfTotal float64 = 0 //床位部分项目自费
  24990. var otherInscpTotal float64 = 0 //床位部分项目自费
  24991. var materialCostTotal float64 = 0 //材料费
  24992. var materialCostSelfTotal float64 = 0 //材料费
  24993. var materialCostPartSelfTotal float64 = 0 //材料费
  24994. var materialSelfTotal float64 = 0 //床位部分项目自费
  24995. var materialInscpTotal float64 = 0 //床位部分项目自费
  24996. var westernMedicineCostTotal float64 = 0 //西药费
  24997. var westernMedicineCostSelfTotal float64 = 0 //西药费
  24998. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  24999. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25000. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25001. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25002. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25003. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25004. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25005. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25006. var checkCostTotal float64 = 0 //检查费
  25007. var checkCostSelfTotal float64 = 0 //检查费
  25008. var checkCostPartSelfTotal float64 = 0 //检查费
  25009. var checkSelfTotal float64 = 0 //床位部分项目自费
  25010. var checkInscpTotal float64 = 0 //床位部分项目自费
  25011. var laboratoryCostTotal float64 = 0 //化验费
  25012. var laboratoryCostSelfTotal float64 = 0 //化验费
  25013. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25014. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25015. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25016. var treatCostTotal float64 = 0 //治疗费用
  25017. var treatCostSelfTotal float64 = 0 //治疗费用
  25018. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25019. var treatSelfTotal float64 = 0 //床位部分项目自费
  25020. var treatInscpTotal float64 = 0 //床位部分项目自费
  25021. decimal.DivisionPrecision = 2
  25022. for _, item := range orderInfos {
  25023. if item.MedChrgitmType == "01" { //床位费
  25024. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25025. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25026. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25027. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25028. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25029. }
  25030. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25031. if item.MedChrgitmType == "03" { //检查费
  25032. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25033. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25034. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25035. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25036. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25037. }
  25038. } else {
  25039. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25040. fmt.Println("------------")
  25041. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25042. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25043. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25044. }
  25045. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25046. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25047. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25048. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25049. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25050. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25051. }
  25052. }
  25053. if item.MedChrgitmType == "04" { //化验费
  25054. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25055. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25056. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25057. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25058. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25059. }
  25060. if item.MedChrgitmType == "05" { //治疗费
  25061. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25062. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25063. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25064. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25065. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25066. }
  25067. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25068. fmt.Println("------------")
  25069. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25070. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25071. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25072. }
  25073. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25074. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25075. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25076. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25077. }
  25078. //if item.MedChrgitmType == "06" { //手术费
  25079. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25080. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25081. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25082. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25083. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25084. //
  25085. //}
  25086. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25087. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25088. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25089. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25090. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25091. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25092. }
  25093. if item.MedChrgitmType == "09" { //西药费
  25094. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25095. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25096. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25097. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25098. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25099. }
  25100. if item.MedChrgitmType == "11" { //中成费
  25101. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25102. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25103. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25104. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25105. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25106. }
  25107. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25108. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25109. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25110. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25111. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25112. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25113. }
  25114. }
  25115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25116. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25117. var user_name string
  25118. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25119. if role.ID == 0 {
  25120. user_name = "管理员"
  25121. } else {
  25122. user_name = role.UserName
  25123. }
  25124. baseParams := models.BaseParams{
  25125. SecretKey: miConfig.SecretKey,
  25126. FixmedinsCode: miConfig.Code,
  25127. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25128. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25129. OrgName: miConfig.OrgName,
  25130. Doctor: user_name,
  25131. RequestUrl: miConfig.Url,
  25132. AccessKey: miConfig.AccessKey,
  25133. }
  25134. businessParams := models.BusinessParams{
  25135. PsnNo: order.PsnNo,
  25136. MdtrtId: order.MdtrtId,
  25137. SetlId: order.SetlId,
  25138. }
  25139. var res ResultEleven
  25140. var resEleven10265 ResultEleven10265
  25141. if config.IsOpen == 1 {
  25142. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25143. result := service.Gdyb5203(baseParams, businessParams)
  25144. service.Gdyb5204(baseParams, businessParams)
  25145. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25146. var dat map[string]interface{}
  25147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25148. fmt.Println(dat)
  25149. } else {
  25150. fmt.Println(err)
  25151. }
  25152. userJSONBytes, _ := json.Marshal(dat)
  25153. if miConfig.Code == "H15049901371" {
  25154. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25155. utils.ErrorLog("解析失败:%v", err)
  25156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25157. return
  25158. }
  25159. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25160. res.Output = resEleven10265.Output
  25161. res.ErrMsg = resEleven10265.ErrMsg
  25162. res.Cainfo = resEleven10265.Cainfo
  25163. res.WarnMsg = resEleven10265.WarnMsg
  25164. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25165. res.Infcode = infocode
  25166. } else {
  25167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25168. utils.ErrorLog("解析失败:%v", err)
  25169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25170. return
  25171. }
  25172. }
  25173. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25174. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25175. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25176. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25177. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25178. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25179. var doctor_name string
  25180. if roles.ID == 0 {
  25181. doctor_name = "管理员"
  25182. } else {
  25183. doctor_name = roles.UserName
  25184. }
  25185. yiliao_leibie := ""
  25186. switch order.MedType {
  25187. case "11":
  25188. yiliao_leibie = "普通门诊"
  25189. break
  25190. case "12":
  25191. yiliao_leibie = "门诊挂号"
  25192. break
  25193. case "13":
  25194. yiliao_leibie = "急诊"
  25195. break
  25196. case "14":
  25197. yiliao_leibie = "门诊特殊病"
  25198. break
  25199. case "15":
  25200. yiliao_leibie = "门诊统筹"
  25201. break
  25202. case "16":
  25203. yiliao_leibie = "门诊慢性病"
  25204. break
  25205. case "21":
  25206. yiliao_leibie = "普通住院"
  25207. break
  25208. }
  25209. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25210. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  25211. if res.Infcode == 0 {
  25212. data2 := map[string]interface{}{
  25213. "diagnosis": name,
  25214. "order_infos": orderInfos,
  25215. "number": order.MdtrtId,
  25216. "date": order.SettleAccountsDate,
  25217. "charge_admin": charge_admin,
  25218. "printor_admin": printor_admin,
  25219. "info": res.Output.Setlinfo,
  25220. "order": order,
  25221. "bedCostTotal": bedCostTotal,
  25222. "bedCostSelfTotal": bedCostSelfTotal,
  25223. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25224. "bedSelfTotal": bedSelfTotal,
  25225. "bedInscpTotal": bedInscpTotal,
  25226. "operationCostTotal": operationCostTotal,
  25227. "operationCostSelfTotal": operationCostSelfTotal,
  25228. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25229. "operationSelfTotal": operationSelfTotal,
  25230. "operationInscpTotal": operationInscpTotal,
  25231. "otherCostTotal": otherCostTotal,
  25232. "otherCostSelfTotal": otherCostSelfTotal,
  25233. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25234. "otherSelfTotal": otherSelfTotal,
  25235. "otherInscpTotal": otherInscpTotal,
  25236. "materialCostTotal": materialCostTotal,
  25237. "materialCostSelfTotal": materialCostSelfTotal,
  25238. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25239. "materialSelfTotal": materialSelfTotal,
  25240. "materialInscpTotal": materialInscpTotal,
  25241. "westernMedicineCostTotal": westernMedicineCostTotal,
  25242. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25243. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25244. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25245. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25246. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25247. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25248. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25249. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25250. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25251. "checkCostTotal": checkCostTotal,
  25252. "checkCostSelfTotal": checkCostSelfTotal,
  25253. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25254. "checkSelfTotal": checkSelfTotal,
  25255. "checkInscpTotal": checkInscpTotal,
  25256. "laboratoryCostTotal": laboratoryCostTotal,
  25257. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25258. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  25259. "laboratorySelfTotal": laboratorySelfTotal,
  25260. "laboratoryInscpTotal": laboratoryInscpTotal,
  25261. "treatCostTotal": treatCostTotal,
  25262. "treatCostSelfTotal": treatCostSelfTotal,
  25263. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  25264. "treatSelfTotal": treatSelfTotal,
  25265. "treatInscpTotal": treatInscpTotal,
  25266. "doctor_info": doctor_info,
  25267. "doctor_code": adminRole_two.DoctorCode,
  25268. "doctor_name": doctor_name,
  25269. "health_card_no": order.PsnNo,
  25270. "department": departments.Name,
  25271. "yiliao_leibie": yiliao_leibie,
  25272. "after_money": order.AccountPrice,
  25273. "patient": patient,
  25274. "org_name": miConfig.OrgName,
  25275. "org_code": miConfig.Code,
  25276. "order_number": order.Number,
  25277. "his_hospital": his_hospital,
  25278. "his": his,
  25279. "dia_config": dia_config,
  25280. "psn_cash_pay": order.PsnCashPay,
  25281. //"check_order_info": cus_slice,
  25282. }
  25283. data3 = append(data3, data2)
  25284. }
  25285. }
  25286. }
  25287. c.ServeSuccessJSON(map[string]interface{}{
  25288. "infos": data3,
  25289. })
  25290. }
  25291. func (c *HisApiController) GetSettleAccounts() {
  25292. //id, _ := c.GetInt64("id")
  25293. //record_time := c.GetString("record_time")
  25294. order_id, _ := c.GetInt64("order_id")
  25295. admin_user_id, _ := c.GetInt64("admin_user_id")
  25296. //timeLayout := "2006-01-02"
  25297. //loc, _ := time.LoadLocation("Local")
  25298. //
  25299. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  25300. //if err != nil {
  25301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  25302. // return
  25303. //}Hbyb5203
  25304. //recordDateTime := theTime.Unix()
  25305. adminUser := c.GetAdminUserInfo()
  25306. order, _ := service.GetHisOrderByID(order_id)
  25307. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25308. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  25309. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  25310. orderInfos = append(orderInfos, orderInfos_two...)
  25311. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  25312. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  25313. var diagnosis_ids []string
  25314. if his.ID > 0 {
  25315. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  25316. } else {
  25317. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  25318. }
  25319. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  25320. var dia_config []*models.HisXtDiagnoseConfig
  25321. var name string
  25322. for _, item := range diagnosis_ids {
  25323. id, _ := strconv.ParseInt(item, 10, 64)
  25324. diagnosisConfig, _ := service.FindDiagnoseById(id)
  25325. dia_config = append(dia_config, &diagnosisConfig)
  25326. if len(name) == 0 {
  25327. name = diagnosisConfig.ClassName
  25328. } else {
  25329. name = name + "," + diagnosisConfig.ClassName
  25330. }
  25331. }
  25332. if patient.UserOrgId == 10215 {
  25333. name = "慢性肾功能不全(血透治疗)"
  25334. }
  25335. var bedCostTotal float64 = 0 //床位总费
  25336. var bedCostSelfTotal float64 = 0 //床位自费
  25337. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  25338. var bedSelfTotal float64 = 0 //床位部分项目自费
  25339. var bedInscpTotal float64 = 0 //床位部分项目自费
  25340. var operationCostTotal float64 = 0 //手术费
  25341. var operationCostSelfTotal float64 = 0 //手术费
  25342. var operationCostPartSelfTotal float64 = 0 //手术费
  25343. var operationSelfTotal float64 = 0 //床位部分项目自费
  25344. var operationInscpTotal float64 = 0 //床位部分项目自费
  25345. var otherCostTotal float64 = 0 //其他费用
  25346. var otherCostSelfTotal float64 = 0 //其他费用
  25347. var otherCostPartSelfTotal float64 = 0 //其他费用
  25348. var otherSelfTotal float64 = 0 //床位部分项目自费
  25349. var otherInscpTotal float64 = 0 //床位部分项目自费
  25350. var materialCostTotal float64 = 0 //材料费
  25351. var materialCostSelfTotal float64 = 0 //材料费
  25352. var materialCostPartSelfTotal float64 = 0 //材料费
  25353. var materialSelfTotal float64 = 0 //床位部分项目自费
  25354. var materialInscpTotal float64 = 0 //床位部分项目自费
  25355. var westernMedicineCostTotal float64 = 0 //西药费
  25356. var westernMedicineCostSelfTotal float64 = 0 //西药费
  25357. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  25358. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  25359. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  25360. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  25361. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  25362. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  25363. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  25364. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  25365. var checkCostTotal float64 = 0 //检查费
  25366. var checkCostSelfTotal float64 = 0 //检查费
  25367. var checkCostPartSelfTotal float64 = 0 //检查费
  25368. var checkSelfTotal float64 = 0 //床位部分项目自费
  25369. var checkInscpTotal float64 = 0 //床位部分项目自费
  25370. var laboratoryCostTotal float64 = 0 //化验费
  25371. var laboratoryCostSelfTotal float64 = 0 //化验费
  25372. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  25373. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  25374. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  25375. var treatCostTotal float64 = 0 //治疗费用
  25376. var treatCostSelfTotal float64 = 0 //治疗费用
  25377. var treatCostPartSelfTotal float64 = 0 //治疗费用
  25378. var treatSelfTotal float64 = 0 //床位部分项目自费
  25379. var treatInscpTotal float64 = 0 //床位部分项目自费
  25380. decimal.DivisionPrecision = 2
  25381. for _, item := range orderInfos {
  25382. if item.MedChrgitmType == "01" { //床位费
  25383. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25384. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25385. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25386. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25387. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25388. }
  25389. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  25390. if item.MedChrgitmType == "03" { //检查费
  25391. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25392. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25393. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25394. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25395. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25396. }
  25397. } else {
  25398. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  25399. fmt.Println("------------")
  25400. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25401. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25402. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25403. }
  25404. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  25405. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25406. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25407. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25408. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25409. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25410. }
  25411. }
  25412. if item.MedChrgitmType == "04" { //化验费
  25413. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25414. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25415. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25416. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25417. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25418. }
  25419. if item.MedChrgitmType == "05" { //治疗费
  25420. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25421. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25422. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25423. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25424. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25425. }
  25426. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  25427. fmt.Println("------------")
  25428. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25429. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25430. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25431. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25432. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25433. }
  25434. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  25435. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25436. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25437. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25438. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25439. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25440. }
  25441. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  25442. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25443. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25444. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25445. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25446. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25447. }
  25448. if item.MedChrgitmType == "09" { //西药费
  25449. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25450. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25451. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25452. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25453. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25454. }
  25455. if item.MedChrgitmType == "11" { //中成费
  25456. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25457. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25458. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25459. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25460. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25461. }
  25462. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  25463. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  25464. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  25465. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  25466. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  25467. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  25468. }
  25469. }
  25470. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25471. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25472. var user_name string
  25473. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25474. if role.ID == 0 {
  25475. user_name = "管理员"
  25476. } else {
  25477. user_name = role.UserName
  25478. }
  25479. baseParams := models.BaseParams{
  25480. SecretKey: miConfig.SecretKey,
  25481. FixmedinsCode: miConfig.Code,
  25482. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  25483. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  25484. OrgName: miConfig.OrgName,
  25485. Doctor: user_name,
  25486. RequestUrl: miConfig.Url,
  25487. AccessKey: miConfig.AccessKey,
  25488. }
  25489. businessParams := models.BusinessParams{
  25490. PsnNo: order.PsnNo,
  25491. MdtrtId: order.MdtrtId,
  25492. SetlId: order.SetlId,
  25493. }
  25494. var res ResultEleven
  25495. var resah ResultElevenah
  25496. var resEleven10265 ResultEleven10265
  25497. if config.IsOpen == 1 {
  25498. if miConfig.MdtrtareaAdmvs == "421300" {
  25499. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25500. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25501. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25502. resp, requestErr := http.Get(api)
  25503. if requestErr != nil {
  25504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25505. return
  25506. }
  25507. body, ioErr := ioutil.ReadAll(resp.Body)
  25508. if ioErr != nil {
  25509. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25511. return
  25512. }
  25513. var respJSON map[string]interface{}
  25514. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25515. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25517. return
  25518. }
  25519. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25520. result, _ := json.Marshal(respJSON)
  25521. fmt.Println("log")
  25522. fmt.Println(string(result))
  25523. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25524. utils.ErrorLog("解析失败:%v", err)
  25525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25526. return
  25527. }
  25528. } else if miConfig.MdtrtareaAdmvs == "420200" {
  25529. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25530. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25531. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25532. resp, requestErr := http.Get(api)
  25533. if requestErr != nil {
  25534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25535. return
  25536. }
  25537. body, ioErr := ioutil.ReadAll(resp.Body)
  25538. if ioErr != nil {
  25539. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25541. return
  25542. }
  25543. var respJSON map[string]interface{}
  25544. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25545. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25547. return
  25548. }
  25549. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25550. result, _ := json.Marshal(respJSON)
  25551. fmt.Println("log")
  25552. fmt.Println(string(result))
  25553. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25554. utils.ErrorLog("解析失败:%v", err)
  25555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25556. return
  25557. }
  25558. } else if miConfig.MdtrtareaAdmvs == "421182" {
  25559. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25560. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25561. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  25562. resp, requestErr := http.Get(api)
  25563. if requestErr != nil {
  25564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25565. return
  25566. }
  25567. body, ioErr := ioutil.ReadAll(resp.Body)
  25568. if ioErr != nil {
  25569. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25571. return
  25572. }
  25573. var respJSON map[string]interface{}
  25574. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25575. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25577. return
  25578. }
  25579. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25580. result, _ := json.Marshal(respJSON)
  25581. fmt.Println("log")
  25582. fmt.Println(string(result))
  25583. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25584. utils.ErrorLog("解析失败:%v", err)
  25585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25586. return
  25587. }
  25588. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25589. var api string
  25590. if miConfig.MdtrtareaAdmvs == "320921" {
  25591. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25592. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25593. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25594. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25595. } else {
  25596. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25597. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25598. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25599. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25600. }
  25601. resp, requestErr := http.Get(api)
  25602. if requestErr != nil {
  25603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25604. return
  25605. }
  25606. body, ioErr := ioutil.ReadAll(resp.Body)
  25607. if ioErr != nil {
  25608. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25610. return
  25611. }
  25612. var respJSON map[string]interface{}
  25613. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25616. return
  25617. }
  25618. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25619. result, _ := json.Marshal(respJSON)
  25620. fmt.Println("log")
  25621. fmt.Println(string(result))
  25622. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25623. utils.ErrorLog("解析失败:%v", err)
  25624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25625. return
  25626. }
  25627. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25628. res.Output = resEleven10265.Output
  25629. res.ErrMsg = resEleven10265.ErrMsg
  25630. res.Cainfo = resEleven10265.Cainfo
  25631. res.WarnMsg = resEleven10265.WarnMsg
  25632. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25633. res.Infcode = infocode
  25634. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25635. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  25636. saveLog(result, requestLog, "5203", "结算单")
  25637. var dat map[string]interface{}
  25638. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25639. fmt.Println(dat)
  25640. } else {
  25641. fmt.Println(err)
  25642. }
  25643. userJSONBytes, _ := json.Marshal(dat)
  25644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25645. utils.ErrorLog("解析失败:%v", err)
  25646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25647. return
  25648. }
  25649. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25650. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  25651. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  25652. fmt.Println(result3)
  25653. fmt.Println(requestLog3)
  25654. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  25655. fmt.Println(result2)
  25656. fmt.Println(requestLog2)
  25657. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  25658. saveLog(result, requestLog, "5203", "结算单")
  25659. var dat map[string]interface{}
  25660. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25661. fmt.Println(dat)
  25662. } else {
  25663. fmt.Println(err)
  25664. }
  25665. userJSONBytes, _ := json.Marshal(dat)
  25666. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25667. utils.ErrorLog("解析失败:%v", err)
  25668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25669. return
  25670. }
  25671. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25672. var api string
  25673. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25674. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25675. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25676. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25677. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25678. resp, requestErr := http.Get(api)
  25679. if requestErr != nil {
  25680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25681. return
  25682. }
  25683. body, ioErr := ioutil.ReadAll(resp.Body)
  25684. if ioErr != nil {
  25685. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25687. return
  25688. }
  25689. var respJSON map[string]interface{}
  25690. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25691. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25693. return
  25694. }
  25695. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25696. if status == "0" {
  25697. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25698. c.ServeSuccessJSON(map[string]interface{}{
  25699. "failed_code": -10,
  25700. "msg": err_msg,
  25701. })
  25702. return
  25703. }
  25704. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25705. result, _ := json.Marshal(respJSON)
  25706. fmt.Println("log")
  25707. fmt.Println(string(result))
  25708. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  25709. utils.ErrorLog("解析失败:%v", err)
  25710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25711. return
  25712. }
  25713. res.InfRefmsgid = resah.InfRefmsgid
  25714. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25715. // 创建对应的Time类型
  25716. t := time.UnixMilli(timestamp)
  25717. // 格式化成指定的日期字符串
  25718. str := t.Format("2006-01-02 15:04:05")
  25719. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  25720. // 创建对应的Time类型
  25721. t3 := time.UnixMilli(timestamp2)
  25722. // 格式化成指定的日期字符串
  25723. str2 := t3.Format("2006-01-02 15:04:05")
  25724. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  25725. // 创建对应的Time类型
  25726. t4 := time.UnixMilli(timestamp3)
  25727. // 格式化成指定的日期字符串
  25728. str3 := t4.Format("2006-01-02 15:04:05")
  25729. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  25730. // 创建对应的Time类型
  25731. t5 := time.UnixMilli(timestamp4)
  25732. // 格式化成指定的日期字符串
  25733. str5 := t5.Format("2006-01-02 15:04:05")
  25734. res.Output.Setlinfo.Brdy = str2
  25735. res.Output.Setlinfo.SetlTime = str
  25736. res.Output.Setlinfo.Begndate = str3
  25737. res.Output.Setlinfo.Enddate = str5
  25738. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  25739. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  25740. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  25741. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  25742. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25743. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25744. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  25745. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  25746. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25747. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  25748. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  25749. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  25750. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  25751. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  25752. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  25753. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  25754. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  25755. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  25756. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  25757. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  25758. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  25759. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  25760. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  25761. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  25762. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  25763. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  25764. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  25765. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  25766. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  25767. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  25768. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  25769. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  25770. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  25771. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  25772. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  25773. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  25774. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  25775. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  25776. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  25777. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  25778. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  25779. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  25780. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  25781. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  25782. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  25783. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  25784. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  25785. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  25786. //res.Output.Setldetail = resah.Output.Setldetail
  25787. res.ErrMsg = resah.ErrMsg
  25788. res.Cainfo = resah.Cainfo
  25789. res.WarnMsg = resah.WarnMsg
  25790. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25791. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  25792. saveLog(result, requestLog, "5203", "结算单")
  25793. var dat map[string]interface{}
  25794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25795. fmt.Println(dat)
  25796. } else {
  25797. fmt.Println(err)
  25798. }
  25799. userJSONBytes, _ := json.Marshal(dat)
  25800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25801. utils.ErrorLog("解析失败:%v", err)
  25802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25803. return
  25804. }
  25805. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25806. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25807. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25808. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25809. resp, requestErr := http.Get(api)
  25810. if requestErr != nil {
  25811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25812. return
  25813. }
  25814. body, ioErr := ioutil.ReadAll(resp.Body)
  25815. if ioErr != nil {
  25816. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25818. return
  25819. }
  25820. var respJSON map[string]interface{}
  25821. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25822. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25824. return
  25825. }
  25826. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25827. result, _ := json.Marshal(respJSON)
  25828. fmt.Println("log")
  25829. fmt.Println(string(result))
  25830. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  25831. utils.ErrorLog("解析失败:%v", err)
  25832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25833. return
  25834. }
  25835. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25836. res.Output = resEleven10265.Output
  25837. res.ErrMsg = resEleven10265.ErrMsg
  25838. res.Cainfo = resEleven10265.Cainfo
  25839. res.WarnMsg = resEleven10265.WarnMsg
  25840. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25841. res.Infcode = infocode
  25842. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25843. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  25844. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  25845. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25846. resp, requestErr := http.Get(api)
  25847. if requestErr != nil {
  25848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25849. return
  25850. }
  25851. body, ioErr := ioutil.ReadAll(resp.Body)
  25852. if ioErr != nil {
  25853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25855. return
  25856. }
  25857. var respJSON map[string]interface{}
  25858. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25861. return
  25862. }
  25863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25864. result, _ := json.Marshal(respJSON)
  25865. if err := json.Unmarshal([]byte(result), &res); err != nil {
  25866. utils.ErrorLog("解析失败:%v", err)
  25867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25868. return
  25869. }
  25870. } else if miConfig.MdtrtareaAdmvs == "450721" {
  25871. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  25872. //return
  25873. } else {
  25874. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  25875. if len(his.InsuplcAdmdvs) == 0 {
  25876. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25877. } else {
  25878. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  25879. }
  25880. result := service.Gdyb5203(baseParams, businessParams)
  25881. //service.Gdyb5204(baseParams, businessParams)
  25882. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  25883. var dat map[string]interface{}
  25884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25885. fmt.Println(dat)
  25886. } else {
  25887. fmt.Println(err)
  25888. }
  25889. userJSONBytes, _ := json.Marshal(dat)
  25890. if miConfig.Code == "H15049901371" {
  25891. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  25892. utils.ErrorLog("解析失败:%v", err)
  25893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25894. return
  25895. }
  25896. res.InfRefmsgid = resEleven10265.InfRefmsgid
  25897. res.Output = resEleven10265.Output
  25898. res.ErrMsg = resEleven10265.ErrMsg
  25899. res.Cainfo = resEleven10265.Cainfo
  25900. res.WarnMsg = resEleven10265.WarnMsg
  25901. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  25902. res.Infcode = infocode
  25903. } else {
  25904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25905. utils.ErrorLog("解析失败:%v", err)
  25906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25907. return
  25908. }
  25909. }
  25910. }
  25911. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25912. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  25913. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  25914. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  25915. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  25916. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25917. var doctor_name string
  25918. if roles.ID == 0 {
  25919. doctor_name = "管理员"
  25920. } else {
  25921. doctor_name = roles.UserName
  25922. }
  25923. yiliao_leibie := ""
  25924. switch order.MedType {
  25925. case "11":
  25926. yiliao_leibie = "普通门诊"
  25927. break
  25928. case "12":
  25929. yiliao_leibie = "门诊挂号"
  25930. break
  25931. case "13":
  25932. yiliao_leibie = "急诊"
  25933. break
  25934. case "14":
  25935. yiliao_leibie = "门诊特殊病"
  25936. break
  25937. case "15":
  25938. yiliao_leibie = "门诊统筹"
  25939. break
  25940. case "16":
  25941. yiliao_leibie = "门诊慢性病"
  25942. break
  25943. case "21":
  25944. yiliao_leibie = "普通住院"
  25945. break
  25946. }
  25947. //var rf []CustomFundPay
  25948. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  25949. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  25950. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  25951. if res.Infcode == 0 {
  25952. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  25953. c.ServeSuccessJSON(map[string]interface{}{
  25954. "diagnosis": name,
  25955. "order_infos": orderInfos,
  25956. "number": order.MdtrtId,
  25957. "date": order.SettleAccountsDate,
  25958. "charge_admin": charge_admin,
  25959. "printor_admin": printor_admin,
  25960. "info": res.Output.Setlinfo,
  25961. "order": order,
  25962. "bedCostTotal": bedCostTotal,
  25963. "bedCostSelfTotal": bedCostSelfTotal,
  25964. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  25965. "bedSelfTotal": bedSelfTotal,
  25966. "bedInscpTotal": bedInscpTotal,
  25967. "operationCostTotal": operationCostTotal,
  25968. "operationCostSelfTotal": operationCostSelfTotal,
  25969. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  25970. "operationSelfTotal": operationSelfTotal,
  25971. "operationInscpTotal": operationInscpTotal,
  25972. "otherCostTotal": otherCostTotal,
  25973. "otherCostSelfTotal": otherCostSelfTotal,
  25974. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  25975. "otherSelfTotal": otherSelfTotal,
  25976. "otherInscpTotal": otherInscpTotal,
  25977. "materialCostTotal": materialCostTotal,
  25978. "materialCostSelfTotal": materialCostSelfTotal,
  25979. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  25980. "materialSelfTotal": materialSelfTotal,
  25981. "materialInscpTotal": materialInscpTotal,
  25982. "westernMedicineCostTotal": westernMedicineCostTotal,
  25983. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  25984. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  25985. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  25986. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  25987. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  25988. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  25989. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  25990. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  25991. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  25992. "checkCostTotal": checkCostTotal,
  25993. "checkCostSelfTotal": checkCostSelfTotal,
  25994. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  25995. "checkSelfTotal": checkSelfTotal,
  25996. "checkInscpTotal": checkInscpTotal,
  25997. "laboratoryCostTotal": laboratoryCostTotal,
  25998. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  25999. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26000. "laboratorySelfTotal": laboratorySelfTotal,
  26001. "laboratoryInscpTotal": laboratoryInscpTotal,
  26002. "treatCostTotal": treatCostTotal,
  26003. "treatCostSelfTotal": treatCostSelfTotal,
  26004. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26005. "treatSelfTotal": treatSelfTotal,
  26006. "treatInscpTotal": treatInscpTotal,
  26007. "doctor_info": doctor_info,
  26008. "doctor_code": adminRole_two.DoctorCode,
  26009. "doctor_name": doctor_name,
  26010. "health_card_no": order.PsnNo,
  26011. "department": departments.Name,
  26012. "yiliao_leibie": yiliao_leibie,
  26013. "after_money": order.AccountPrice,
  26014. "patient": patient,
  26015. "org_name": miConfig.OrgName,
  26016. "org_code": miConfig.Code,
  26017. "order_number": order.Number,
  26018. "his_hospital": his_hospital,
  26019. "his": his,
  26020. "dia_config": dia_config,
  26021. "psn_cash_pay": order.PsnCashPay,
  26022. //"funds": rf,
  26023. //"check_order_info": cus_slice,
  26024. })
  26025. } else {
  26026. c.ServeSuccessJSON(map[string]interface{}{
  26027. "diagnosis": name,
  26028. "order_infos": orderInfos,
  26029. "number": order.MdtrtId,
  26030. "date": order.SettleAccountsDate,
  26031. "charge_admin": charge_admin,
  26032. "printor_admin": printor_admin,
  26033. "info": order,
  26034. "order": order,
  26035. "bedCostTotal": bedCostTotal,
  26036. "bedCostSelfTotal": bedCostSelfTotal,
  26037. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26038. "bedSelfTotal": bedSelfTotal,
  26039. "bedInscpTotal": bedInscpTotal,
  26040. "operationCostTotal": operationCostTotal,
  26041. "operationCostSelfTotal": operationCostSelfTotal,
  26042. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26043. "operationSelfTotal": operationSelfTotal,
  26044. "operationInscpTotal": operationInscpTotal,
  26045. "otherCostTotal": otherCostTotal,
  26046. "otherCostSelfTotal": otherCostSelfTotal,
  26047. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26048. "otherSelfTotal": otherSelfTotal,
  26049. "otherInscpTotal": otherInscpTotal,
  26050. "materialCostTotal": materialCostTotal,
  26051. "materialCostSelfTotal": materialCostSelfTotal,
  26052. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26053. "materialSelfTotal": materialSelfTotal,
  26054. "materialInscpTotal": materialInscpTotal,
  26055. "westernMedicineCostTotal": westernMedicineCostTotal,
  26056. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26057. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26058. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26059. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26060. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26061. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26062. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26063. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26064. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26065. "checkCostTotal": checkCostTotal,
  26066. "checkCostSelfTotal": checkCostSelfTotal,
  26067. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26068. "checkSelfTotal": checkSelfTotal,
  26069. "checkInscpTotal": checkInscpTotal,
  26070. "laboratoryCostTotal": laboratoryCostTotal,
  26071. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26072. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26073. "laboratorySelfTotal": laboratorySelfTotal,
  26074. "laboratoryInscpTotal": laboratoryInscpTotal,
  26075. "treatCostTotal": treatCostTotal,
  26076. "treatCostSelfTotal": treatCostSelfTotal,
  26077. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26078. "treatSelfTotal": treatSelfTotal,
  26079. "treatInscpTotal": treatInscpTotal,
  26080. "doctor_info": doctor_info,
  26081. "doctor_code": adminRole_two.DoctorCode,
  26082. "doctor_name": doctor_name,
  26083. "health_card_no": order.PsnNo,
  26084. "department": departments.Name,
  26085. "yiliao_leibie": yiliao_leibie,
  26086. "after_money": order.AccountPrice,
  26087. "patient": patient,
  26088. "org_name": miConfig.OrgName,
  26089. "org_code": miConfig.Code,
  26090. "order_number": order.Number,
  26091. "his_hospital": his_hospital,
  26092. "his": his,
  26093. "dia_config": dia_config,
  26094. "psn_cash_pay": order.PsnCashPay,
  26095. //"funds": rf,
  26096. //"check_order_info": cus_slice,
  26097. })
  26098. }
  26099. }
  26100. }
  26101. }
  26102. //func (c *HisApiController) CheckTreatment() {
  26103. // patient_id, _ := c.GetInt64("patient_id")
  26104. // id_card_no := c.GetString("id_card_no")
  26105. // insutype := c.GetString("insutype")
  26106. // med_type := c.GetString("med_type")
  26107. // admin_user_id, _ := c.GetInt64("admin_user_id")
  26108. //
  26109. // adminUser := c.GetAdminUserInfo()
  26110. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26111. //
  26112. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26113. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26114. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26115. //
  26116. // if miConfig.MdtrtareaAdmvs == "421300" {
  26117. // var res ResultTwo
  26118. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  26119. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26120. // "&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)
  26121. // resp, requestErr := http.Get(api)
  26122. // if requestErr != nil {
  26123. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26124. // return
  26125. // }
  26126. //
  26127. // body, ioErr := ioutil.ReadAll(resp.Body)
  26128. // if ioErr != nil {
  26129. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26131. // return
  26132. // }
  26133. // var respJSON map[string]interface{}
  26134. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26135. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26136. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26137. // return
  26138. // }
  26139. //
  26140. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26141. // result, _ := json.Marshal(respJSON)
  26142. //
  26143. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26144. // utils.ErrorLog("解析失败:%v", err)
  26145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26146. // return
  26147. // }
  26148. //
  26149. // if res.Infcode == 0 {
  26150. //
  26151. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  26152. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  26153. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  26154. // resp, requestErr := http.Get(api)
  26155. // if requestErr != nil {
  26156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26157. // return
  26158. // }
  26159. //
  26160. // body, ioErr := ioutil.ReadAll(resp.Body)
  26161. // if ioErr != nil {
  26162. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26163. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26164. // return
  26165. // }
  26166. // var respJSON map[string]interface{}
  26167. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26168. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26169. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26170. // return
  26171. // }
  26172. // var res Result2001
  26173. //
  26174. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26175. // result2, _ := json.Marshal(respJSON)
  26176. //
  26177. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  26178. // utils.ErrorLog("解析失败:%v", err)
  26179. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26180. // return
  26181. // }
  26182. //
  26183. // if res.Infcode == 0 {
  26184. // c.ServeSuccessJSON(map[string]interface{}{
  26185. // "msg": res.Output.Trtinfo,
  26186. // })
  26187. // }
  26188. //
  26189. // } else {
  26190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  26191. // return
  26192. // }
  26193. //
  26194. // } else {
  26195. //
  26196. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26197. // var dat map[string]interface{}
  26198. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26199. // fmt.Println(dat)
  26200. // } else {
  26201. // fmt.Println(err)
  26202. // }
  26203. // userJSONBytes, _ := json.Marshal(dat)
  26204. // var res ResultTwo
  26205. // var res10265 ResultTwo10265
  26206. // if miConfig.Code == "H15049901371" {
  26207. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26208. // utils.ErrorLog("解析失败:%v", err)
  26209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26210. // return
  26211. // }
  26212. // res.ErrMsg = res10265.ErrMsg
  26213. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26214. // res.Infcode = infocode
  26215. // res.Output = res10265.Output
  26216. // res.InfRefmsgid = res10265.InfRefmsgid
  26217. // } else {
  26218. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26219. // utils.ErrorLog("解析失败:%v", err)
  26220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26221. // return
  26222. // }
  26223. // }
  26224. //
  26225. // var user_name string
  26226. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  26227. // if role.ID == 0 {
  26228. // user_name = "xxx"
  26229. // } else {
  26230. // user_name = role.UserName
  26231. // }
  26232. //
  26233. // baseParams := models.BaseParams{
  26234. // SecretKey: miConfig.SecretKey,
  26235. // FixmedinsCode: miConfig.Code,
  26236. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26237. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26238. // OrgName: miConfig.OrgName,
  26239. // Doctor: user_name,
  26240. // }
  26241. //
  26242. // if config.IsOpen == 1 {
  26243. // if miConfig.Code == "H15049901371" {
  26244. // if med_type == "14" {
  26245. // if insutype == "390" {
  26246. // med_type = "9933"
  26247. // } else if insutype == "310" {
  26248. // med_type = "990502"
  26249. // }
  26250. // } else if med_type == "11" {
  26251. // med_type = "11"
  26252. // }
  26253. // }
  26254. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  26255. // var dat map[string]interface{}
  26256. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26257. // fmt.Println(dat)
  26258. // } else {
  26259. // fmt.Println(err)
  26260. // }
  26261. // var res Result2001
  26262. // var res10265 Result2001Org10265
  26263. // if miConfig.Code == "H15049901371" {
  26264. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  26265. // utils.ErrorLog("解析失败:%v", err)
  26266. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26267. // return
  26268. // }
  26269. // res.ErrMsg = res10265.ErrMsg
  26270. // res.Output = res10265.Output
  26271. // res.InfRefmsgid = res10265.InfRefmsgid
  26272. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26273. // res.Infcode = infocode
  26274. // } else {
  26275. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  26276. // utils.ErrorLog("解析失败:%v", err)
  26277. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26278. // return
  26279. // }
  26280. // }
  26281. // if res.Infcode == 0 {
  26282. // c.ServeSuccessJSON(map[string]interface{}{
  26283. // "msg": res.Output.Trtinfo,
  26284. // })
  26285. // }
  26286. // }
  26287. // }
  26288. //}
  26289. //func (c *HisApiController) PutRecord() {
  26290. // id, _ := c.GetInt64("id")
  26291. // record_time := c.GetString("record_time")
  26292. // timeLayout := "2006-01-02"
  26293. // loc, _ := time.LoadLocation("Local")
  26294. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26295. // if err != nil {
  26296. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26297. // return
  26298. // }
  26299. // recordDateTime := theTime.Unix()
  26300. //
  26301. // adminInfo := c.GetAdminUserInfo()
  26302. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  26303. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26304. //
  26305. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26306. //
  26307. // fmt.Println(miConfig.SecretKey)
  26308. //
  26309. // if patient == nil {
  26310. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26311. // return
  26312. // }
  26313. // if len(patient.IdCardNo) == 0 {
  26314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  26315. // return
  26316. // }
  26317. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  26318. // if config.IsOpen == 1 {
  26319. // 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
  26320. // resp, requestErr := http.Get(api)
  26321. // if requestErr != nil {
  26322. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26323. // return
  26324. // }
  26325. // defer resp.Body.Close()
  26326. // body, ioErr := ioutil.ReadAll(resp.Body)
  26327. // if ioErr != nil {
  26328. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26330. // return
  26331. // }
  26332. // var respJSON map[string]interface{}
  26333. //
  26334. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26335. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26336. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26337. // return
  26338. // }
  26339. //
  26340. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26341. // userJSONBytes, _ := json.Marshal(userJSON)
  26342. // var res ResultTwo
  26343. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26344. // utils.ErrorLog("解析失败:%v", err)
  26345. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26346. // return
  26347. // }
  26348. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  26349. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  26350. // infoStr := string(Iinfos)
  26351. // idetinfoStr := string(Idetinfos)
  26352. //
  26353. // if res.Infcode == 0 {
  26354. // his := models.VMHisPatient{
  26355. // Status: 1,
  26356. // Ctime: time.Now().Unix(),
  26357. // Mtime: time.Now().Unix(),
  26358. // PsnNo: res.Output.Baseinfo.PsnNo,
  26359. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  26360. // Certno: res.Output.Baseinfo.Certno,
  26361. // PsnName: res.Output.Baseinfo.PsnName,
  26362. // Gend: res.Output.Baseinfo.Gend,
  26363. // Naty: res.Output.Baseinfo.Naty,
  26364. // Brdy: res.Output.Baseinfo.Brdy,
  26365. // Age: res.Output.Baseinfo.Age,
  26366. // Iinfo: infoStr,
  26367. // Idetinfo: idetinfoStr,
  26368. // PatientId: patient.ID,
  26369. // RecordDate: theTime.Unix(),
  26370. // UserOrgId: adminInfo.CurrentOrgId,
  26371. // AdminUserId: adminInfo.AdminUser.Id,
  26372. // IsReturn: 1,
  26373. // }
  26374. //
  26375. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  26376. // //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")
  26377. // //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")
  26378. //
  26379. // //var dat map[string]interface{}
  26380. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26381. // // fmt.Println(dat)
  26382. // //} else {
  26383. // // fmt.Println(err)
  26384. // //}
  26385. //
  26386. // var dat2 map[string]interface{}
  26387. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  26388. // fmt.Println(dat2)
  26389. // } else {
  26390. // fmt.Println(err)
  26391. // }
  26392. //
  26393. // } else {
  26394. // adminUser := c.GetAdminUserInfo()
  26395. // errlog := &models.HisOrderError{
  26396. // UserOrgId: adminUser.CurrentOrgId,
  26397. // Ctime: time.Now().Unix(),
  26398. // Mtime: time.Now().Unix(),
  26399. // ErrMsg: res.ErrMsg,
  26400. // Status: 1,
  26401. // PatientId: id,
  26402. // RecordTime: recordDateTime,
  26403. // Stage: 1,
  26404. // }
  26405. // service.CreateErrMsgLog(errlog)
  26406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  26407. // return
  26408. // }
  26409. // }
  26410. //
  26411. //}
  26412. //func (c *HisApiController) GetUploadDiag() {
  26413. // id, _ := c.GetInt64("id")
  26414. // record_time := c.GetString("record_time")
  26415. //
  26416. // diagnosis_id, _ := c.GetInt64("diagnosis")
  26417. // sick_type, _ := c.GetInt64("sick_type")
  26418. // reg_type, _ := c.GetInt64("reg_type")
  26419. //
  26420. // timeLayout := "2006-01-02"
  26421. // loc, _ := time.LoadLocation("Local")
  26422. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26423. // if err != nil {
  26424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26425. // return
  26426. // }
  26427. //
  26428. // var patientPrescription models.HisPrescriptionInfo
  26429. // recordDateTime := theTime.Unix()
  26430. // adminInfo := c.GetAdminUserInfo()
  26431. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26432. //
  26433. // if patientPrescription.ID == 0 {
  26434. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26435. // }
  26436. //
  26437. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  26438. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  26439. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  26440. // sickConfig, _ := service.FindSickById(sick_type)
  26441. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26442. //
  26443. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  26444. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  26445. // "&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 +
  26446. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  26447. // resp2, requestErr2 := http.Get(api2)
  26448. // if requestErr2 != nil {
  26449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26450. // return
  26451. // }
  26452. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  26453. // if ioErr2 != nil {
  26454. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  26455. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26456. // return
  26457. // }
  26458. // var respJSON2 map[string]interface{}
  26459. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  26460. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26461. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26462. // return
  26463. // }
  26464. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26465. // userJSONBytes2, _ := json.Marshal(respJSON2)
  26466. //
  26467. // var res2 ResultSix
  26468. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  26469. // utils.ErrorLog("解析失败:%v", err)
  26470. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26471. // return
  26472. // }
  26473. // if res2.Infcode != 0 {
  26474. // adminUser := c.GetAdminUserInfo()
  26475. // errlog := &models.HisOrderError{
  26476. // UserOrgId: adminUser.CurrentOrgId,
  26477. // Ctime: time.Now().Unix(),
  26478. // Mtime: time.Now().Unix(),
  26479. // ErrMsg: res2.ErrMsg,
  26480. // Status: 1,
  26481. // PatientId: id,
  26482. // RecordTime: recordDateTime,
  26483. // Stage: 3,
  26484. // }
  26485. // service.CreateErrMsgLog(errlog)
  26486. //
  26487. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  26488. // return
  26489. // }
  26490. //
  26491. // c.ServeSuccessJSON(map[string]interface{}{
  26492. // "msg": "上传成功",
  26493. // })
  26494. //
  26495. //}
  26496. type QueryResult struct {
  26497. ID int64
  26498. Name string
  26499. Code string
  26500. List_type_code string
  26501. }
  26502. func (c *HisApiController) GetCheckCode() {
  26503. ids_str := c.GetString("ids")
  26504. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26505. ids_arr := strings.Split(ids_str, ",")
  26506. var queryResult []QueryResult
  26507. ids := make([]int64, 0)
  26508. for _, item := range ids_arr {
  26509. id, _ := strconv.ParseInt(item, 10, 64)
  26510. ids = append(ids, id)
  26511. }
  26512. if record_type == 1 {
  26513. drugs, _ := service.GetBatchDrugList(ids)
  26514. for _, item := range drugs {
  26515. result := QueryResult{
  26516. ID: item.ID,
  26517. Name: item.DrugName,
  26518. Code: item.MedicalInsuranceNumber,
  26519. List_type_code: "101",
  26520. }
  26521. queryResult = append(queryResult, result)
  26522. }
  26523. } else if record_type == 2 {
  26524. goods, _ := service.GetBatchGoodInformationList(ids)
  26525. fmt.Println(goods)
  26526. for _, item := range goods {
  26527. result := QueryResult{
  26528. ID: item.ID,
  26529. Name: item.GoodName,
  26530. Code: item.SocialSecurityDirectoryCode,
  26531. List_type_code: "301",
  26532. }
  26533. queryResult = append(queryResult, result)
  26534. }
  26535. } else if record_type == 3 {
  26536. projects, _ := service.GetBathchMyPorjecgList(ids)
  26537. for _, item := range projects {
  26538. result := QueryResult{
  26539. ID: item.ID,
  26540. Name: item.ProjectName,
  26541. Code: item.MedicalCode,
  26542. List_type_code: "201",
  26543. }
  26544. queryResult = append(queryResult, result)
  26545. }
  26546. }
  26547. admin_user_id, _ := c.GetInt64("admin_user_id")
  26548. adminUser := c.GetAdminUserInfo()
  26549. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26550. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26551. var user_name string
  26552. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26553. if role.ID == 0 {
  26554. user_name = "管理员"
  26555. } else {
  26556. user_name = role.UserName
  26557. }
  26558. baseParams := models.BaseParams{
  26559. SecretKey: miConfig.SecretKey,
  26560. FixmedinsCode: miConfig.Code,
  26561. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26562. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26563. OrgName: miConfig.OrgName,
  26564. Doctor: user_name,
  26565. }
  26566. var result string
  26567. if miConfig.MdtrtareaAdmvs == "430800" {
  26568. for _, item := range queryResult {
  26569. if record_type == 1 {
  26570. 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)
  26571. } else if record_type == 2 {
  26572. fmt.Println(item.Code)
  26573. 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)
  26574. } else if record_type == 3 {
  26575. 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)
  26576. }
  26577. var dat map[string]interface{}
  26578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26579. fmt.Println(dat)
  26580. } else {
  26581. fmt.Println(err)
  26582. }
  26583. userJSONBytes, _ := json.Marshal(dat)
  26584. var res ResultSix
  26585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26586. utils.ErrorLog("解析失败:%v", err)
  26587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26588. return
  26589. }
  26590. if res.Infcode == 0 {
  26591. if record_type == 1 {
  26592. service.UpdateBaseDrugById(item.ID)
  26593. } else if record_type == 2 {
  26594. service.UpdateGoodInformaitonByDetail(item.ID)
  26595. } else if record_type == 3 {
  26596. service.UpdateProjectById(item.ID)
  26597. }
  26598. c.ServeSuccessJSON(map[string]interface{}{
  26599. "failed_code": 0,
  26600. "msg": "目录对照成功",
  26601. })
  26602. } else {
  26603. c.ServeSuccessJSON(map[string]interface{}{
  26604. "failed_code": -10,
  26605. "msg": res.ErrMsg,
  26606. })
  26607. }
  26608. }
  26609. } else {
  26610. for _, item := range queryResult {
  26611. var result string
  26612. if record_type == 1 {
  26613. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26614. } else if record_type == 2 {
  26615. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26616. } else if record_type == 3 {
  26617. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  26618. }
  26619. var dat map[string]interface{}
  26620. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26621. fmt.Println(dat)
  26622. } else {
  26623. fmt.Println(err)
  26624. }
  26625. userJSONBytes, _ := json.Marshal(dat)
  26626. var res ResultSix
  26627. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26628. utils.ErrorLog("解析失败:%v", err)
  26629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26630. return
  26631. }
  26632. if res.Infcode == 0 {
  26633. if record_type == 1 {
  26634. service.UpdateBaseDrugById(item.ID)
  26635. } else if record_type == 2 {
  26636. service.UpdateGoodInformaitonByDetail(item.ID)
  26637. } else if record_type == 3 {
  26638. service.UpdateProjectById(item.ID)
  26639. }
  26640. c.ServeSuccessJSON(map[string]interface{}{
  26641. "failed_code": 0,
  26642. "msg": "目录对照成功",
  26643. })
  26644. } else {
  26645. c.ServeSuccessJSON(map[string]interface{}{
  26646. "failed_code": -10,
  26647. "msg": res.ErrMsg,
  26648. })
  26649. }
  26650. }
  26651. }
  26652. }
  26653. func (c *HisApiController) UnCheckCode() {
  26654. ids_str := c.GetString("ids")
  26655. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  26656. admin_user_id, _ := c.GetInt64("admin_user_id")
  26657. ids_arr := strings.Split(ids_str, ",")
  26658. var queryResult []QueryResult
  26659. ids := make([]int64, 0)
  26660. for _, item := range ids_arr {
  26661. id, _ := strconv.ParseInt(item, 10, 64)
  26662. ids = append(ids, id)
  26663. }
  26664. if record_type == 1 {
  26665. drugs, _ := service.GetBatchDrugList(ids)
  26666. for _, item := range drugs {
  26667. result := QueryResult{
  26668. ID: item.ID,
  26669. Name: item.DrugName,
  26670. Code: item.MedicalInsuranceNumber,
  26671. List_type_code: "101",
  26672. }
  26673. queryResult = append(queryResult, result)
  26674. }
  26675. } else if record_type == 2 {
  26676. goods, _ := service.GetBatchGoodInformationList(ids)
  26677. for _, item := range goods {
  26678. result := QueryResult{
  26679. ID: item.ID,
  26680. Name: item.GoodName,
  26681. Code: item.SocialSecurityDirectoryCode,
  26682. List_type_code: "301",
  26683. }
  26684. queryResult = append(queryResult, result)
  26685. }
  26686. } else if record_type == 3 {
  26687. projects, _ := service.GetBathchMyPorjecgList(ids)
  26688. for _, item := range projects {
  26689. result := QueryResult{
  26690. ID: item.ID,
  26691. Name: item.ProjectName,
  26692. Code: item.MedicalCode,
  26693. List_type_code: "201",
  26694. }
  26695. queryResult = append(queryResult, result)
  26696. }
  26697. }
  26698. adminUser := c.GetAdminUserInfo()
  26699. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26700. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26701. var user_name string
  26702. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26703. if role.ID == 0 {
  26704. user_name = "xxx"
  26705. } else {
  26706. user_name = role.UserName
  26707. }
  26708. baseParams := &models.BaseParams{
  26709. SecretKey: miConfig.SecretKey,
  26710. FixmedinsCode: miConfig.Code,
  26711. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26712. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26713. OrgName: miConfig.OrgName,
  26714. Doctor: user_name,
  26715. }
  26716. if config.IsOpen == 1 {
  26717. if miConfig.MdtrtareaAdmvs == "430800" {
  26718. for _, item := range queryResult {
  26719. var result string
  26720. if record_type == 1 {
  26721. 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)
  26722. } else if record_type == 2 {
  26723. fmt.Println(item.Code)
  26724. 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)
  26725. } else if record_type == 3 {
  26726. 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)
  26727. }
  26728. var dat map[string]interface{}
  26729. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26730. fmt.Println(dat)
  26731. } else {
  26732. fmt.Println(err)
  26733. }
  26734. userJSONBytes, _ := json.Marshal(dat)
  26735. var res ResultSix
  26736. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26737. utils.ErrorLog("解析失败:%v", err)
  26738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26739. return
  26740. }
  26741. if res.Infcode == 0 {
  26742. if record_type == 1 {
  26743. service.UpdateBaseDrugById(item.ID)
  26744. } else if record_type == 2 {
  26745. service.UpdateGoodInformaitonByDetail(item.ID)
  26746. } else if record_type == 3 {
  26747. service.UpdateProjectById(item.ID)
  26748. }
  26749. c.ServeSuccessJSON(map[string]interface{}{
  26750. "failed_code": 0,
  26751. "msg": "目录对照成功",
  26752. })
  26753. } else {
  26754. c.ServeSuccessJSON(map[string]interface{}{
  26755. "failed_code": -10,
  26756. "msg": res.ErrMsg,
  26757. })
  26758. }
  26759. }
  26760. } else {
  26761. for _, item := range queryResult {
  26762. var result string
  26763. if record_type == 1 {
  26764. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26765. } else if record_type == 2 {
  26766. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26767. } else if record_type == 3 {
  26768. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  26769. }
  26770. var dat2 map[string]interface{}
  26771. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  26772. fmt.Println(dat2)
  26773. } else {
  26774. fmt.Println(err)
  26775. }
  26776. userJSONBytes, _ := json.Marshal(dat2)
  26777. var res ResultSix
  26778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26779. utils.ErrorLog("解析失败:%v", err)
  26780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26781. return
  26782. }
  26783. if res.Infcode == 0 {
  26784. if record_type == 1 {
  26785. service.UpdateDrugByIdDetail(item.ID)
  26786. } else if record_type == 2 {
  26787. service.UpdateGoodInfoById(item.ID)
  26788. } else if record_type == 3 {
  26789. service.UpdateMyProjectById(item.ID)
  26790. }
  26791. c.ServeSuccessJSON(map[string]interface{}{
  26792. "failed_code": 0,
  26793. "msg": "撤销目录对照成功",
  26794. })
  26795. } else {
  26796. c.ServeSuccessJSON(map[string]interface{}{
  26797. "failed_code": -10,
  26798. "msg": res.ErrMsg,
  26799. })
  26800. }
  26801. }
  26802. }
  26803. }
  26804. }
  26805. func (c *HisApiController) GetPatientInfo() {
  26806. id_card_no := c.GetString("id_card_no")
  26807. admin_user_id, _ := c.GetInt64("admin_user_id")
  26808. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  26809. if patient.ID == 0 {
  26810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  26811. return
  26812. }
  26813. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  26814. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  26815. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  26816. var res ResultTwo
  26817. var res10265 ResultTwo10265
  26818. if config.IsOpen == 1 {
  26819. if miConfig.MdtrtareaAdmvs == "150499" {
  26820. //请求内网数据
  26821. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  26822. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  26823. "&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
  26824. resp, requestErr := http.Get(api)
  26825. if requestErr != nil {
  26826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26827. return
  26828. }
  26829. body, ioErr := ioutil.ReadAll(resp.Body)
  26830. if ioErr != nil {
  26831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26833. return
  26834. }
  26835. var respJSON map[string]interface{}
  26836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26839. return
  26840. }
  26841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26842. result_byte, _ := json.Marshal(respJSON)
  26843. result := string(result_byte)
  26844. var dat map[string]interface{}
  26845. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26846. fmt.Println(dat)
  26847. } else {
  26848. fmt.Println(err)
  26849. }
  26850. userJSONBytes, _ := json.Marshal(dat)
  26851. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  26852. utils.ErrorLog("解析失败:%v", err)
  26853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26854. return
  26855. }
  26856. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  26857. res.Infcode = Infcode
  26858. res.ErrMsg = res10265.ErrMsg
  26859. res.Output = res10265.Output
  26860. res.InfRefmsgid = res10265.InfRefmsgid
  26861. res.RespondTime = res10265.RespondTime
  26862. res.WarnInfo = res10265.WarnInfo
  26863. } else {
  26864. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  26865. var dat map[string]interface{}
  26866. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26867. fmt.Println(dat)
  26868. } else {
  26869. fmt.Println(err)
  26870. }
  26871. userJSONBytes, _ := json.Marshal(dat)
  26872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26873. utils.ErrorLog("解析失败:%v", err)
  26874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26875. return
  26876. }
  26877. }
  26878. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26879. // utils.ErrorLog("解析失败:%v", err)
  26880. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26881. // return
  26882. //}
  26883. for index, item := range res.Output.Iinfo {
  26884. if item.PsnInsuStas == "2" {
  26885. fmt.Println("--------")
  26886. res.Output.Iinfo[index].Insutype = "300"
  26887. res.Output.Iinfo[index].PsnInsuStas = "1"
  26888. }
  26889. }
  26890. fmt.Println(res.Output.Iinfo)
  26891. if res.Infcode != 0 {
  26892. c.ServeSuccessJSON(map[string]interface{}{
  26893. "failed_code": -10,
  26894. "msg": res.ErrMsg,
  26895. })
  26896. } else {
  26897. c.ServeSuccessJSON(map[string]interface{}{
  26898. "failed_code": 0,
  26899. "info": res,
  26900. })
  26901. }
  26902. }
  26903. }
  26904. func (c *HisApiController) PsnPutOnRecord() {
  26905. record_type, _ := c.GetInt64("type")
  26906. patient_id, _ := c.GetInt64("patient_id")
  26907. admin_user_id, _ := c.GetInt64("admin_user_id")
  26908. start_time := c.GetString("start_time")
  26909. end_time := c.GetString("end_time")
  26910. adminUser := c.GetAdminUserInfo()
  26911. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26912. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26913. var patients []*models.Patients
  26914. if record_type == 1 { //全部备案
  26915. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  26916. patients = append(patients, patient...)
  26917. } else { //单个备案
  26918. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  26919. patients = append(patients, patient)
  26920. }
  26921. var user_name string
  26922. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26923. if role.ID == 0 {
  26924. user_name = "xxx"
  26925. } else {
  26926. user_name = role.UserName
  26927. }
  26928. if config.IsOpen == 1 {
  26929. for _, item := range patients {
  26930. 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
  26931. resp, requestErr := http.Get(api)
  26932. if requestErr != nil {
  26933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26934. return
  26935. }
  26936. defer resp.Body.Close()
  26937. body, ioErr := ioutil.ReadAll(resp.Body)
  26938. if ioErr != nil {
  26939. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26941. return
  26942. }
  26943. var respJSON map[string]interface{}
  26944. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26947. return
  26948. }
  26949. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26950. userJSONBytes, _ := json.Marshal(userJSON)
  26951. var res ResultTwo
  26952. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26953. utils.ErrorLog("解析失败:%v", err)
  26954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26955. return
  26956. }
  26957. if res.Infcode == 0 {
  26958. 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)
  26959. var dat map[string]interface{}
  26960. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26961. fmt.Println(dat)
  26962. } else {
  26963. fmt.Println(err)
  26964. }
  26965. userJSONBytes, _ := json.Marshal(dat)
  26966. var res2 ResultThirteen
  26967. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  26968. utils.ErrorLog("解析失败:%v", err)
  26969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26970. return
  26971. }
  26972. if res2.Infcode == 0 {
  26973. psnResult := &models.GdybPsnRecord{
  26974. UserOrgId: adminUser.CurrentOrgId,
  26975. PatientId: item.ID,
  26976. PsnNo: res.Output.Baseinfo.PsnNo,
  26977. Ctime: time.Now().Unix(),
  26978. Mtime: time.Now().Unix(),
  26979. Status: 1,
  26980. IsCancel: 1,
  26981. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  26982. }
  26983. service.CreatePsnRecord(psnResult)
  26984. } else {
  26985. c.ServeSuccessJSON(map[string]interface{}{
  26986. "failed_code": -10,
  26987. "msg": res2.ErrMsg,
  26988. })
  26989. return
  26990. }
  26991. }
  26992. }
  26993. }
  26994. }
  26995. func (c *HisApiController) PsnUnPutOnRecord() {
  26996. id, _ := c.GetInt64("id")
  26997. //record_type, _ := c.GetInt64("type")
  26998. admin_user_id, _ := c.GetInt64("admin_user_id")
  26999. adminUser := c.GetAdminUserInfo()
  27000. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27001. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27002. var user_name string
  27003. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27004. if role.ID == 0 {
  27005. user_name = "xxx"
  27006. } else {
  27007. user_name = role.UserName
  27008. }
  27009. psn_record, _ := service.GetPsnRecordById(id)
  27010. if psn_record.ID == 0 {
  27011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27012. return
  27013. }
  27014. if config.IsOpen == 1 {
  27015. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27016. var dat map[string]interface{}
  27017. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27018. fmt.Println(dat)
  27019. } else {
  27020. fmt.Println(err)
  27021. }
  27022. userJSONBytes, _ := json.Marshal(dat)
  27023. var res ResultFourteen
  27024. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27025. utils.ErrorLog("解析失败:%v", err)
  27026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27027. return
  27028. }
  27029. if res.Infcode == 0 {
  27030. psn_record.IsCancel = 2
  27031. service.CreatePsnRecord(&psn_record)
  27032. } else {
  27033. c.ServeSuccessJSON(map[string]interface{}{
  27034. "failed_code": -10,
  27035. "msg": res.ErrMsg,
  27036. })
  27037. return
  27038. }
  27039. }
  27040. }
  27041. func (c *HisApiController) PsnPutNCDSOnRecord() {
  27042. patient_id, _ := c.GetInt64("patient_id")
  27043. insutype_two := c.GetString("insutype")
  27044. psn_no := c.GetString("psn_no")
  27045. doctor_id, _ := c.GetInt64("doctor_id")
  27046. sick_id, _ := c.GetInt64("sick_id")
  27047. department_id, _ := c.GetInt64("department_id")
  27048. start_time := c.GetString("start_time")
  27049. end_time := c.GetString("end_time")
  27050. check_time := c.GetString("check_time")
  27051. hospital_code := c.GetString("hospital_code")
  27052. hospital_name := c.GetString("hospital_name")
  27053. adminUser := c.GetAdminUserInfo()
  27054. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27056. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27057. sick, _ := service.FindSickById(sick_id)
  27058. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27059. if len(hospital_code) == 0 {
  27060. hospital_code = miConfig.Code
  27061. }
  27062. if len(hospital_name) == 0 {
  27063. hospital_name = miConfig.OrgName
  27064. }
  27065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  27066. var res ResultTwo
  27067. var res10265 ResultTwo10265
  27068. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27069. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  27070. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  27071. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27072. "&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
  27073. resp, requestErr := http.Get(api)
  27074. if requestErr != nil {
  27075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27076. return
  27077. }
  27078. body, ioErr := ioutil.ReadAll(resp.Body)
  27079. if ioErr != nil {
  27080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27082. return
  27083. }
  27084. var respJSON map[string]interface{}
  27085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27088. return
  27089. }
  27090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27091. result, _ := json.Marshal(respJSON)
  27092. fmt.Println("log")
  27093. fmt.Println(string(result))
  27094. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27095. utils.ErrorLog("解析失败:%v", err)
  27096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27097. return
  27098. }
  27099. res.ErrMsg = res10265.ErrMsg
  27100. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27101. res.Infcode = infocode
  27102. res.Output = res10265.Output
  27103. res.InfRefmsgid = res10265.InfRefmsgid
  27104. } else {
  27105. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27106. if miConfig.Code == "H15049901371" {
  27107. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27108. utils.ErrorLog("解析失败:%v", err)
  27109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27110. return
  27111. }
  27112. res.ErrMsg = res10265.ErrMsg
  27113. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27114. res.Infcode = infocode
  27115. res.Output = res10265.Output
  27116. res.InfRefmsgid = res10265.InfRefmsgid
  27117. } else {
  27118. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27119. utils.ErrorLog("解析失败:%v", err)
  27120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27121. return
  27122. }
  27123. }
  27124. }
  27125. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27126. infoStr := string(Iinfos)
  27127. var rf []*ResultFive
  27128. json.Unmarshal([]byte(infoStr), &rf)
  27129. var insuplc_admdvs string
  27130. var insutype string
  27131. var is390 int = 0
  27132. var is310 int = 0
  27133. var insutypes []*ResultFive
  27134. for _, item := range rf {
  27135. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27136. insutypes = append(insutypes, item)
  27137. }
  27138. }
  27139. if len(insutypes) == 1 {
  27140. insutype = insutypes[0].Insutype
  27141. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27142. } else {
  27143. for _, i := range insutypes {
  27144. if i.Insutype == "390" {
  27145. is390 = 1
  27146. }
  27147. if i.Insutype == "310" {
  27148. is310 = 1
  27149. }
  27150. }
  27151. }
  27152. if is390 == 1 {
  27153. insutype = "390"
  27154. }
  27155. if is310 == 1 {
  27156. insutype = "310"
  27157. }
  27158. if len(insutypes) == 2 {
  27159. insutype = insutype_two
  27160. }
  27161. if len(insutypes) == 0 {
  27162. insutype = "310"
  27163. }
  27164. insutype = insutype_two
  27165. fmt.Println(insutype)
  27166. for _, item := range rf {
  27167. fmt.Println(item.Insutype)
  27168. fmt.Println(insutype)
  27169. if item.Insutype == insutype {
  27170. fmt.Println(item.Insutype)
  27171. fmt.Println(insutype)
  27172. insuplc_admdvs = item.InsuplcAdmdvs
  27173. }
  27174. }
  27175. fmt.Println(insuplc_admdvs)
  27176. var res2 ResultThirteen
  27177. var res10265_2 ResultThirteen10265
  27178. if config.IsOpen == 1 {
  27179. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  27180. } else {
  27181. if miConfig.MdtrtareaAdmvs == "150499" {
  27182. //
  27183. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  27184. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  27185. // "&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
  27186. //resp, requestErr := http.Get(api)
  27187. //if requestErr != nil {
  27188. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27189. // return
  27190. //}
  27191. //
  27192. //body, ioErr := ioutil.ReadAll(resp.Body)
  27193. //if ioErr != nil {
  27194. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27196. // return
  27197. //}
  27198. //var respJSON map[string]interface{}
  27199. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27200. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27201. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27202. // return
  27203. //}
  27204. //
  27205. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27206. //result, _ := json.Marshal(respJSON)
  27207. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  27208. // utils.ErrorLog("解析失败:%v", err)
  27209. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27210. // return
  27211. //}
  27212. //infocode = resThree.Infcode
  27213. //result, _ := json.Marshal(respJSON)
  27214. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  27215. // utils.ErrorLog("解析失败:%v", err)
  27216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27217. // return
  27218. //}
  27219. //
  27220. //resThree.ErrMsg = resThree10265.ErrMsg
  27221. //
  27222. //resThree.Output = resThree10265.Output
  27223. //
  27224. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  27225. //
  27226. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  27227. //
  27228. } else {
  27229. 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)
  27230. var dat map[string]interface{}
  27231. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27232. fmt.Println(dat)
  27233. } else {
  27234. fmt.Println(err)
  27235. }
  27236. userJSONBytes, _ := json.Marshal(dat)
  27237. if miConfig.Code == "H15049901371" {
  27238. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  27239. utils.ErrorLog("解析失败:%v", err)
  27240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27241. return
  27242. }
  27243. res2.ErrMsg = res10265_2.ErrMsg
  27244. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  27245. res2.Infcode = infocode
  27246. res2.Output = res10265_2.Output
  27247. res2.InfRefmsgid = res10265_2.InfRefmsgid
  27248. } else {
  27249. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  27250. utils.ErrorLog("解析失败:%v", err)
  27251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27252. return
  27253. }
  27254. }
  27255. }
  27256. }
  27257. if res2.Infcode == 0 {
  27258. psnResult := &models.GdybPsnNcdsRecord{
  27259. UserOrgId: adminUser.CurrentOrgId,
  27260. PatientId: patient.ID,
  27261. PsnNo: psn_no,
  27262. DoctorId: doctor.AdminUserId,
  27263. DepartmentId: department_id,
  27264. SickType: sick_id,
  27265. Insutype: insutype,
  27266. Ctime: time.Now().Unix(),
  27267. Mtime: time.Now().Unix(),
  27268. Status: 1,
  27269. IsCancel: 1,
  27270. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  27271. }
  27272. service.CreatePsnNCDSRecord(psnResult)
  27273. c.ServeSuccessJSON(map[string]interface{}{
  27274. "failed_code": 0,
  27275. "msg": "备案成功",
  27276. "result": psnResult,
  27277. })
  27278. } else {
  27279. c.ServeSuccessJSON(map[string]interface{}{
  27280. "failed_code": -10,
  27281. "msg": res2.ErrMsg,
  27282. })
  27283. return
  27284. }
  27285. }
  27286. }
  27287. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  27288. id, _ := c.GetInt64("id")
  27289. admin_user_id, _ := c.GetInt64("admin_user_id")
  27290. adminUser := c.GetAdminUserInfo()
  27291. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27292. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27293. //config, _ := service.Ge(adminUser.CurrentOrgId)
  27294. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  27295. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27296. //var user_name string
  27297. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27298. //if role.ID == 0 {
  27299. // user_name = "xxx"
  27300. //} else {
  27301. // user_name = role.UserName
  27302. //}
  27303. psn_record, _ := service.GetPsnNCDSRecordById(id)
  27304. if psn_record.ID == 0 {
  27305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  27306. return
  27307. }
  27308. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  27309. var res ResultTwo
  27310. var res10265 ResultTwo10265
  27311. if miConfig.Code == "H15049901371" {
  27312. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27313. utils.ErrorLog("解析失败:%v", err)
  27314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27315. return
  27316. }
  27317. res.ErrMsg = res10265.ErrMsg
  27318. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27319. res.Infcode = infocode
  27320. res.Output = res10265.Output
  27321. res.InfRefmsgid = res10265.InfRefmsgid
  27322. } else {
  27323. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27324. utils.ErrorLog("解析失败:%v", err)
  27325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27326. return
  27327. }
  27328. }
  27329. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27330. infoStr := string(Iinfos)
  27331. var rf []*ResultFive
  27332. json.Unmarshal([]byte(infoStr), &rf)
  27333. var insuplc_admdvs string
  27334. var insutype string
  27335. var is390 int = 0
  27336. var is310 int = 0
  27337. var insutypes []*ResultFive
  27338. for _, item := range rf {
  27339. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  27340. insutypes = append(insutypes, item)
  27341. }
  27342. }
  27343. if len(insutypes) == 1 {
  27344. insutype = insutypes[0].Insutype
  27345. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  27346. } else {
  27347. for _, i := range insutypes {
  27348. if i.Insutype == "390" {
  27349. is390 = 1
  27350. }
  27351. if i.Insutype == "310" {
  27352. is310 = 1
  27353. }
  27354. }
  27355. }
  27356. if is390 == 1 {
  27357. insutype = "390"
  27358. }
  27359. if is310 == 1 {
  27360. insutype = "310"
  27361. }
  27362. if len(insutypes) == 0 {
  27363. insutype = "310"
  27364. }
  27365. insutype = psn_record.Insutype
  27366. for _, item := range rf {
  27367. if item.Insutype == insutype {
  27368. insuplc_admdvs = item.InsuplcAdmdvs
  27369. }
  27370. }
  27371. if config.IsOpen == 1 {
  27372. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  27373. var dat map[string]interface{}
  27374. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27375. fmt.Println(dat)
  27376. } else {
  27377. fmt.Println(err)
  27378. }
  27379. userJSONBytes, _ := json.Marshal(dat)
  27380. var res ResultFourteen
  27381. var res10265 ResultFourteen10265
  27382. if miConfig.Code == "H15049901371" {
  27383. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27384. utils.ErrorLog("解析失败:%v", err)
  27385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27386. return
  27387. }
  27388. res.ErrMsg = res10265.ErrMsg
  27389. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27390. res.Infcode = infocode
  27391. res.Output = res10265.Output
  27392. res.InfRefmsgid = res10265.InfRefmsgid
  27393. } else {
  27394. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27395. utils.ErrorLog("解析失败:%v", err)
  27396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27397. return
  27398. }
  27399. }
  27400. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27401. // utils.ErrorLog("解析失败:%v", err)
  27402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27403. // return
  27404. //}
  27405. if res.Infcode == 0 {
  27406. psn_record.IsCancel = 2
  27407. service.CreatePsnNCDSRecord(&psn_record)
  27408. c.ServeSuccessJSON(map[string]interface{}{
  27409. "failed_code": 0,
  27410. "msg": "撤销备案成功",
  27411. })
  27412. } else {
  27413. c.ServeSuccessJSON(map[string]interface{}{
  27414. "failed_code": -10,
  27415. "msg": res.ErrMsg,
  27416. })
  27417. return
  27418. }
  27419. }
  27420. }
  27421. func (c *HisApiController) TestTest() {
  27422. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  27423. fmt.Println(patient.Iinfo)
  27424. }
  27425. type CustomData struct {
  27426. MsgId string
  27427. PsnNo string
  27428. Info string
  27429. }
  27430. func (c *HisApiController) ReversalData() {
  27431. var customData []*CustomData
  27432. custom := &CustomData{
  27433. MsgId: "H44022900158202103301714472004",
  27434. PsnNo: "44020000001101329945",
  27435. Info: "2207",
  27436. }
  27437. customData = append(customData, custom)
  27438. custom1 := &CustomData{
  27439. MsgId: "H4402290015820210330172057803",
  27440. PsnNo: "44020000001101161813",
  27441. Info: "2207",
  27442. }
  27443. customData = append(customData, custom1)
  27444. custom2 := &CustomData{
  27445. MsgId: "H44022900158202103301705198813",
  27446. PsnNo: "44190000133097375417",
  27447. Info: "2207",
  27448. }
  27449. customData = append(customData, custom2)
  27450. custom3 := &CustomData{
  27451. MsgId: "H44022900158202103301715524756",
  27452. PsnNo: "44020000001100187221",
  27453. Info: "2207",
  27454. }
  27455. customData = append(customData, custom3)
  27456. custom4 := &CustomData{
  27457. MsgId: "H44022900158202103301730376224",
  27458. PsnNo: "44020000001101959155",
  27459. Info: "2207",
  27460. }
  27461. customData = append(customData, custom4)
  27462. custom5 := &CustomData{
  27463. MsgId: "H44022900158202103301748008725",
  27464. PsnNo: "44020000001104246641",
  27465. Info: "2207",
  27466. }
  27467. customData = append(customData, custom5)
  27468. custom6 := &CustomData{
  27469. MsgId: "H44022900158202103301718096755",
  27470. PsnNo: "44020000001102211860",
  27471. Info: "2207",
  27472. }
  27473. customData = append(customData, custom6)
  27474. custom7 := &CustomData{
  27475. MsgId: "H44022900158202103301736551640",
  27476. PsnNo: "44020000001102687718",
  27477. Info: "2207",
  27478. }
  27479. customData = append(customData, custom7)
  27480. custom8 := &CustomData{
  27481. MsgId: "H44022900158202103301743097676",
  27482. PsnNo: "44020000001102127785",
  27483. Info: "2207",
  27484. }
  27485. customData = append(customData, custom8)
  27486. custom9 := &CustomData{
  27487. MsgId: "H44022900158202103301712304203",
  27488. PsnNo: "44020000001101518097",
  27489. Info: "2207",
  27490. }
  27491. customData = append(customData, custom9)
  27492. custom10 := &CustomData{
  27493. MsgId: "H44022900158202103301738448785",
  27494. PsnNo: "44020000001100500813",
  27495. Info: "2207",
  27496. }
  27497. customData = append(customData, custom10)
  27498. custom11 := &CustomData{
  27499. MsgId: "H44022900158202103301732455843",
  27500. PsnNo: "44020000001102690557",
  27501. Info: "2207",
  27502. }
  27503. customData = append(customData, custom11)
  27504. custom12 := &CustomData{
  27505. MsgId: "H44022900158202103301745421708",
  27506. PsnNo: "44020000001102211928",
  27507. Info: "2207",
  27508. }
  27509. customData = append(customData, custom12)
  27510. custom1212 := &CustomData{
  27511. MsgId: "H440229001582021033017351627",
  27512. PsnNo: "44020000001102481733",
  27513. Info: "2207",
  27514. }
  27515. customData = append(customData, custom1212)
  27516. custom13 := &CustomData{
  27517. MsgId: "H44022900158202103301740327951",
  27518. PsnNo: "44020000001103174866",
  27519. Info: "2207",
  27520. }
  27521. customData = append(customData, custom13)
  27522. custom14 := &CustomData{
  27523. MsgId: "H4402290015820210330174922668",
  27524. PsnNo: "44020000001102927272",
  27525. Info: "2207",
  27526. }
  27527. customData = append(customData, custom14)
  27528. custom15 := &CustomData{
  27529. MsgId: "H44022900158202103301752362273",
  27530. PsnNo: "44020000001102942890",
  27531. Info: "2207",
  27532. }
  27533. customData = append(customData, custom15)
  27534. custom16 := &CustomData{
  27535. MsgId: "H44022900158202103301751082917",
  27536. PsnNo: "44020000001101662162",
  27537. Info: "2207",
  27538. }
  27539. customData = append(customData, custom16)
  27540. custom17 := &CustomData{
  27541. MsgId: "H44022900158202103301754147728",
  27542. PsnNo: "44020000000229014511",
  27543. Info: "2207",
  27544. }
  27545. customData = append(customData, custom17)
  27546. adminUser := c.GetAdminUserInfo()
  27547. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27548. for _, item := range customData {
  27549. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27550. fmt.Println(result)
  27551. }
  27552. }
  27553. func (c *HisApiController) GetAllopatry() {
  27554. year := c.GetString("year")
  27555. month := c.GetString("month")
  27556. admin_user_id, _ := c.GetInt64("admin_user_id")
  27557. adminUser := c.GetAdminUserInfo()
  27558. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27559. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27560. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27561. var dat map[string]interface{}
  27562. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27563. fmt.Println(dat)
  27564. } else {
  27565. fmt.Println(err)
  27566. }
  27567. userJSONBytes, _ := json.Marshal(dat)
  27568. var res models.Result9001
  27569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27570. utils.ErrorLog("解析失败:%v", err)
  27571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27572. return
  27573. }
  27574. fmt.Println(res.Output.Signinoutb)
  27575. fmt.Println(res.Output.Signinoutb.SignNo)
  27576. fmt.Println(string(userJSONBytes))
  27577. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27578. var dat3 map[string]interface{}
  27579. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  27580. fmt.Println(dat3)
  27581. } else {
  27582. fmt.Println(err)
  27583. }
  27584. userJSONBytes3, _ := json.Marshal(dat3)
  27585. var res3 models.Result3260
  27586. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  27587. utils.ErrorLog("解析失败:%v", err)
  27588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27589. return
  27590. }
  27591. var curpage int
  27592. var pagesize int = 100
  27593. var start int = 1
  27594. //var stop int
  27595. //pagecount := 10
  27596. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  27597. var res22 []models.Result3260
  27598. for curpage = 1; curpage <= pagecount; curpage++ {
  27599. if curpage == 1 {
  27600. start = 0
  27601. } else {
  27602. start = (curpage-1)*pagesize + 1
  27603. }
  27604. fmt.Println(start)
  27605. //stop = curpage * pagesize
  27606. //if stop > int(res3.Output.Totalrow) {
  27607. // stop =int(res3.Output.Totalrow)
  27608. //}
  27609. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  27610. var dat2 map[string]interface{}
  27611. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27612. fmt.Println(dat)
  27613. } else {
  27614. fmt.Println(err)
  27615. }
  27616. userJSONBytes2, _ := json.Marshal(dat2)
  27617. var res2 models.Result3260
  27618. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27619. utils.ErrorLog("解析失败:%v", err)
  27620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27621. return
  27622. }
  27623. if res2.Infcode == 0 {
  27624. res22 = append(res22, res2)
  27625. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27626. //var dat2 map[string]interface{}
  27627. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27628. // fmt.Println(dat)
  27629. //} else {
  27630. // fmt.Println(err)
  27631. //}
  27632. //c.ServeSuccessJSON(map[string]interface{}{
  27633. // "list": res2.Output.Data,
  27634. //})
  27635. //continue
  27636. }
  27637. }
  27638. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27639. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  27640. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  27641. //var dat2 map[string]interface{}
  27642. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27643. // fmt.Println(dat)
  27644. //} else {
  27645. // fmt.Println(err)
  27646. //}
  27647. //userJSONBytes2, _ := json.Marshal(dat2)
  27648. //var res2 models.Result3260
  27649. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27650. // utils.ErrorLog("解析失败:%v", err)
  27651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27652. // return
  27653. //}
  27654. //if res2.Infcode == 0 {
  27655. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27656. // var dat2 map[string]interface{}
  27657. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  27658. // fmt.Println(dat)
  27659. // } else {
  27660. // fmt.Println(err)
  27661. // }
  27662. // c.ServeSuccessJSON(map[string]interface{}{
  27663. // "list": res2.Output.Data,
  27664. // })
  27665. //}
  27666. }
  27667. func (c *HisApiController) ComfirmAllopatry() {
  27668. year := c.GetString("year")
  27669. month := c.GetString("month")
  27670. admin_user_id, _ := c.GetInt64("admin_user_id")
  27671. adminUser := c.GetAdminUserInfo()
  27672. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27673. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27674. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27675. var dat map[string]interface{}
  27676. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27677. fmt.Println(dat)
  27678. } else {
  27679. fmt.Println(err)
  27680. }
  27681. userJSONBytes, _ := json.Marshal(dat)
  27682. var res models.Result9001
  27683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27684. utils.ErrorLog("解析失败:%v", err)
  27685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27686. return
  27687. }
  27688. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  27689. var dat2 map[string]interface{}
  27690. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27691. fmt.Println(dat)
  27692. } else {
  27693. fmt.Println(err)
  27694. }
  27695. userJSONBytes2, _ := json.Marshal(dat2)
  27696. var res2 models.Result3260
  27697. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27698. utils.ErrorLog("解析失败:%v", err)
  27699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27700. return
  27701. }
  27702. //if res2.Infcode == 0 {
  27703. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  27704. // var dat map[string]interface{}
  27705. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27706. // fmt.Println(dat)
  27707. // } else {
  27708. // fmt.Println(err)
  27709. // }
  27710. // userJSONBytes, _ := json.Marshal(dat)
  27711. // var res3 models.Result3261
  27712. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  27713. // utils.ErrorLog("解析失败:%v", err)
  27714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27715. // return
  27716. // }
  27717. //
  27718. // if res3.Infcode == 0 {
  27719. // record := &models.HisYidiClearRecord{
  27720. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  27721. // Ctime: time.Now().Unix(),
  27722. // Mtime: time.Now().Unix(),
  27723. // Status: 1,
  27724. // MsgId: msgId,
  27725. // }
  27726. // service.SaveClearRecord(record)
  27727. // c.ServeSuccessJSON(map[string]interface{}{
  27728. // "msg": "提取成功",
  27729. // })
  27730. // }
  27731. //}
  27732. }
  27733. func (c *HisApiController) RefundAllopatry() {
  27734. year := c.GetString("year")
  27735. month := c.GetString("month")
  27736. //id, _ := c.GetInt64("id")
  27737. admin_user_id, _ := c.GetInt64("admin_user_id")
  27738. adminUser := c.GetAdminUserInfo()
  27739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27740. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27741. //record, _ := service.GetClearRecordById(id)
  27742. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  27743. var dat map[string]interface{}
  27744. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  27745. fmt.Println(dat)
  27746. } else {
  27747. fmt.Println(err)
  27748. }
  27749. userJSONBytes, _ := json.Marshal(dat)
  27750. var res models.Result9001
  27751. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27752. utils.ErrorLog("解析失败:%v", err)
  27753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27754. return
  27755. }
  27756. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  27757. var dat2 map[string]interface{}
  27758. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27759. fmt.Println(dat)
  27760. } else {
  27761. fmt.Println(err)
  27762. }
  27763. userJSONBytes2, _ := json.Marshal(dat2)
  27764. var empty ResultFourteen
  27765. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  27766. utils.ErrorLog("解析失败:%v", err)
  27767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27768. return
  27769. }
  27770. if empty.Infcode == 0 {
  27771. c.ServeSuccessJSON(map[string]interface{}{
  27772. "msg": "撤销成功",
  27773. })
  27774. return
  27775. }
  27776. }
  27777. func (c *HisApiController) ReversalOtherData() {
  27778. var customData []*CustomData
  27779. custom := &CustomData{
  27780. MsgId: "H44022900158202103301714472004",
  27781. PsnNo: "44020000001101329945",
  27782. Info: "2208",
  27783. }
  27784. customData = append(customData, custom)
  27785. custom1 := &CustomData{
  27786. MsgId: "H4402290015820210330172057803",
  27787. PsnNo: "44020000001101161813",
  27788. Info: "2208",
  27789. }
  27790. customData = append(customData, custom1)
  27791. custom2 := &CustomData{
  27792. MsgId: "H44022900158202103301705198813",
  27793. PsnNo: "44190000133097375417",
  27794. Info: "2208",
  27795. }
  27796. customData = append(customData, custom2)
  27797. custom3 := &CustomData{
  27798. MsgId: "H44022900158202103301715524756",
  27799. PsnNo: "44020000001100187221",
  27800. Info: "2208",
  27801. }
  27802. customData = append(customData, custom3)
  27803. custom4 := &CustomData{
  27804. MsgId: "H44022900158202103301730376224",
  27805. PsnNo: "44020000001101959155",
  27806. Info: "2208",
  27807. }
  27808. customData = append(customData, custom4)
  27809. custom5 := &CustomData{
  27810. MsgId: "H44022900158202103301748008725",
  27811. PsnNo: "44020000001104246641",
  27812. Info: "2208",
  27813. }
  27814. customData = append(customData, custom5)
  27815. custom6 := &CustomData{
  27816. MsgId: "H44022900158202103301718096755",
  27817. PsnNo: "44020000001102211860",
  27818. Info: "2208",
  27819. }
  27820. customData = append(customData, custom6)
  27821. custom7 := &CustomData{
  27822. MsgId: "H44022900158202103301736551640",
  27823. PsnNo: "44020000001102687718",
  27824. Info: "2208",
  27825. }
  27826. customData = append(customData, custom7)
  27827. custom8 := &CustomData{
  27828. MsgId: "H44022900158202103301743097676",
  27829. PsnNo: "44020000001102127785",
  27830. Info: "2208",
  27831. }
  27832. customData = append(customData, custom8)
  27833. custom9 := &CustomData{
  27834. MsgId: "H44022900158202103301712304203",
  27835. PsnNo: "44020000001101518097",
  27836. Info: "2208",
  27837. }
  27838. customData = append(customData, custom9)
  27839. custom10 := &CustomData{
  27840. MsgId: "H44022900158202103301738448785",
  27841. PsnNo: "44020000001100500813",
  27842. Info: "2208",
  27843. }
  27844. customData = append(customData, custom10)
  27845. custom11 := &CustomData{
  27846. MsgId: "H44022900158202103301732455843",
  27847. PsnNo: "44020000001102690557",
  27848. Info: "2208",
  27849. }
  27850. customData = append(customData, custom11)
  27851. custom12 := &CustomData{
  27852. MsgId: "H44022900158202103301745421708",
  27853. PsnNo: "44020000001102211928",
  27854. Info: "2208",
  27855. }
  27856. customData = append(customData, custom12)
  27857. custom1212 := &CustomData{
  27858. MsgId: "H440229001582021033017351627",
  27859. PsnNo: "44020000001102481733",
  27860. Info: "2208",
  27861. }
  27862. customData = append(customData, custom1212)
  27863. custom13 := &CustomData{
  27864. MsgId: "H44022900158202103301740327951",
  27865. PsnNo: "44020000001103174866",
  27866. Info: "2208",
  27867. }
  27868. customData = append(customData, custom13)
  27869. custom14 := &CustomData{
  27870. MsgId: "H4402290015820210330174922668",
  27871. PsnNo: "44020000001102927272",
  27872. Info: "2208",
  27873. }
  27874. customData = append(customData, custom14)
  27875. custom15 := &CustomData{
  27876. MsgId: "H44022900158202103301752362273",
  27877. PsnNo: "44020000001102942890",
  27878. Info: "2208",
  27879. }
  27880. customData = append(customData, custom15)
  27881. custom16 := &CustomData{
  27882. MsgId: "H44022900158202103301751082917",
  27883. PsnNo: "44020000001101662162",
  27884. Info: "2208",
  27885. }
  27886. customData = append(customData, custom16)
  27887. custom17 := &CustomData{
  27888. MsgId: "H44022900158202103301754147728",
  27889. PsnNo: "44020000000229014511",
  27890. Info: "2208",
  27891. }
  27892. customData = append(customData, custom17)
  27893. adminUser := c.GetAdminUserInfo()
  27894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27895. for _, item := range customData {
  27896. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  27897. fmt.Println(result)
  27898. }
  27899. }
  27900. func PathExists(path string) (bool, error) {
  27901. _, err := os.Stat(path)
  27902. if err == nil {
  27903. return true, nil
  27904. }
  27905. if os.IsNotExist(err) {
  27906. return false, nil
  27907. }
  27908. return false, err
  27909. }
  27910. // 创建文件夹
  27911. func Mkdir(dir string) {
  27912. // 创建文件夹
  27913. exist, err := PathExists(dir)
  27914. if err != nil {
  27915. fmt.Println(err.Error())
  27916. } else {
  27917. if exist {
  27918. fmt.Println(dir + "文件夹已存在!")
  27919. } else {
  27920. // 文件夹名称,权限
  27921. err := os.Mkdir(dir, os.ModePerm)
  27922. if err != nil {
  27923. fmt.Println(dir+"文件夹创建失败:", err.Error())
  27924. } else {
  27925. fmt.Println(dir + "文件夹创建成功!")
  27926. }
  27927. }
  27928. }
  27929. }
  27930. // 压缩文件
  27931. func Zip(srcFile string, destZip string) error {
  27932. zipfile, err := os.Create(destZip)
  27933. if err != nil {
  27934. return err
  27935. }
  27936. defer zipfile.Close()
  27937. archive := zip.NewWriter(zipfile)
  27938. defer archive.Close()
  27939. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  27940. if err != nil {
  27941. return err
  27942. }
  27943. header, err := zip.FileInfoHeader(info)
  27944. if err != nil {
  27945. return err
  27946. }
  27947. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  27948. // header.Name = path
  27949. if info.IsDir() {
  27950. header.Name += "/"
  27951. } else {
  27952. header.Method = zip.Deflate
  27953. }
  27954. writer, err := archive.CreateHeader(header)
  27955. if err != nil {
  27956. return err
  27957. }
  27958. if !info.IsDir() {
  27959. file, err := os.Open(path)
  27960. if err != nil {
  27961. return err
  27962. }
  27963. defer file.Close()
  27964. _, err = io.Copy(writer, file)
  27965. }
  27966. return err
  27967. })
  27968. return err
  27969. }
  27970. func ReadFile(filePath string) []byte {
  27971. f, err := os.Open(filePath)
  27972. if err != nil {
  27973. fmt.Println("read file fail", err)
  27974. return nil
  27975. }
  27976. defer f.Close()
  27977. fd, err := ioutil.ReadAll(f)
  27978. if err != nil {
  27979. fmt.Println("read to fd fail", err)
  27980. return nil
  27981. }
  27982. return fd
  27983. }
  27984. func saveLogq(result string, request string, infno string, desc string) {
  27985. dir := "日志"
  27986. utils.Mkdir(dir)
  27987. month := time.Unix(1557042972, 0).Format("1")
  27988. year := time.Now().Format("2006")
  27989. month = time.Now().Format("01")
  27990. day := time.Now().Format("02")
  27991. hour := time.Now().Format("15")
  27992. min := time.Now().Format("04")
  27993. sec := time.Now().Format("05")
  27994. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  27995. file := year + month + day + "_log"
  27996. file_name := file + ".txt"
  27997. file_path := "日志" + "/" + file_name
  27998. exist, _ := utils.PathExists(file_path)
  27999. if exist { //存在
  28000. fmt.Println("存在")
  28001. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28002. if err != nil {
  28003. fmt.Println("read fail")
  28004. }
  28005. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28006. n, _ := f.Seek(0, 2)
  28007. _, err = f.WriteAt([]byte(content), n)
  28008. } else { //不存在
  28009. fmt.Println("文件不存在,创建文件")
  28010. f, err := os.Create("日志" + "/" + file_name)
  28011. defer f.Close()
  28012. if err != nil {
  28013. } else {
  28014. _, err = f.Write([]byte("记录日志"))
  28015. }
  28016. }
  28017. }
  28018. func saveLog(result string, request string, infno string, desc string) {
  28019. org_id, _ := beego.AppConfig.Int64("org_id")
  28020. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28021. dir := miConfig.OrgName + "日志"
  28022. utils.Mkdir(dir)
  28023. month := time.Unix(1557042972, 0).Format("1")
  28024. year := time.Now().Format("2006")
  28025. month = time.Now().Format("01")
  28026. day := time.Now().Format("02")
  28027. hour := time.Now().Format("15")
  28028. min := time.Now().Format("04")
  28029. sec := time.Now().Format("05")
  28030. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  28031. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  28032. file_name := file + ".txt"
  28033. file_path := miConfig.OrgName + "日志" + "/" + file_name
  28034. exist, _ := utils.PathExists(file_path)
  28035. if exist { //存在
  28036. fmt.Println("存在")
  28037. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  28038. if err != nil {
  28039. fmt.Println("read fail")
  28040. }
  28041. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  28042. n, _ := f.Seek(0, 2)
  28043. _, err = f.WriteAt([]byte(content), n)
  28044. } else { //不存在
  28045. fmt.Println("文件不存在,创建文件")
  28046. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  28047. defer f.Close()
  28048. if err != nil {
  28049. } else {
  28050. _, err = f.Write([]byte("记录日志"))
  28051. }
  28052. }
  28053. }
  28054. type Charset string
  28055. const (
  28056. UTF8 = Charset("UTF-8")
  28057. GB18030 = Charset("GB18030")
  28058. )
  28059. func ConvertToString(src string, srcCode string, tagCode string) string {
  28060. srcCoder := mahonia.NewDecoder(srcCode)
  28061. srcResult := srcCoder.ConvertString(src)
  28062. tagCoder := mahonia.NewDecoder(tagCode)
  28063. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  28064. result := string(cdata)
  28065. return result
  28066. }
  28067. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  28068. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28069. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28070. var token string
  28071. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28072. var api string
  28073. if miConfig.MdtrtareaAdmvs == "320921" {
  28074. 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 +
  28075. "&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
  28076. fmt.Println(api)
  28077. } else {
  28078. 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 +
  28079. "&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
  28080. }
  28081. resp, requestErr := http.Get(api)
  28082. if requestErr != nil {
  28083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28084. return ""
  28085. }
  28086. body, ioErr := ioutil.ReadAll(resp.Body)
  28087. if ioErr != nil {
  28088. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28090. return ""
  28091. }
  28092. var respJSON map[string]interface{}
  28093. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28094. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28096. return ""
  28097. }
  28098. var status string
  28099. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28100. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28101. var res ResultTwo //1101结果
  28102. var res10265 ResultTwo10265 //1101结果
  28103. if status == "0" { //读卡成功
  28104. var card_info string //卡信息
  28105. var busi_card_info string
  28106. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28107. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28108. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28109. fmt.Println(card_info)
  28110. fmt.Println(busi_card_info)
  28111. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28112. result, _ := json.Marshal(respJSON)
  28113. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28114. utils.ErrorLog("解析失败:%v", err)
  28115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28116. return ""
  28117. }
  28118. res.ErrMsg = res10265.ErrMsg
  28119. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28120. res.Infcode = infocode
  28121. res.Output = res10265.Output
  28122. res.InfRefmsgid = res10265.InfRefmsgid
  28123. if res.Infcode == 0 {
  28124. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28125. if err == gorm.ErrRecordNotFound {
  28126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28127. return ""
  28128. } else if err != nil {
  28129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28130. return ""
  28131. } else {
  28132. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28133. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28134. infoStr := string(Iinfos)
  28135. idetinfoStr := string(Idetinfos)
  28136. psn := &models.HisPsn{
  28137. PsnNo: res.Output.Baseinfo.PsnNo,
  28138. PatientId: patient.ID,
  28139. Certno: res.Output.Baseinfo.Certno,
  28140. Gend: res.Output.Baseinfo.Gend,
  28141. Naty: res.Output.Baseinfo.Naty,
  28142. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28143. PsnName: res.Output.Baseinfo.PsnName,
  28144. Idetinfo: idetinfoStr,
  28145. Insuinfo: infoStr,
  28146. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28147. CardInfo: card_info,
  28148. VerifyNumber: token,
  28149. }
  28150. service.CreateHisPsn(psn)
  28151. return token
  28152. }
  28153. }
  28154. } else {
  28155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28156. return ""
  28157. }
  28158. } else { //读卡失败
  28159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28160. return ""
  28161. }
  28162. return token
  28163. }
  28164. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  28165. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28166. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28167. var token string
  28168. var api string
  28169. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  28170. "&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
  28171. fmt.Println(api)
  28172. resp, requestErr := http.Get(api)
  28173. if requestErr != nil {
  28174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28175. return ""
  28176. }
  28177. body, ioErr := ioutil.ReadAll(resp.Body)
  28178. if ioErr != nil {
  28179. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28181. return ""
  28182. }
  28183. var respJSON map[string]interface{}
  28184. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28185. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28187. return ""
  28188. }
  28189. var status string
  28190. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28191. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28192. var res ResultTwo //1101结果
  28193. if status == "1" { //读卡成功
  28194. var card_info string //卡信息
  28195. var busi_card_info string
  28196. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28197. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28198. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28199. fmt.Println(card_info)
  28200. fmt.Println(busi_card_info)
  28201. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28202. result, _ := json.Marshal(respJSON)
  28203. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28204. utils.ErrorLog("解析失败:%v", err)
  28205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28206. return ""
  28207. }
  28208. if res.Infcode == 0 {
  28209. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28210. if err == gorm.ErrRecordNotFound {
  28211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28212. return ""
  28213. } else if err != nil {
  28214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28215. return ""
  28216. } else {
  28217. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28218. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28219. infoStr := string(Iinfos)
  28220. idetinfoStr := string(Idetinfos)
  28221. psn := &models.HisPsn{
  28222. PsnNo: res.Output.Baseinfo.PsnNo,
  28223. PatientId: patient.ID,
  28224. Certno: res.Output.Baseinfo.Certno,
  28225. Gend: res.Output.Baseinfo.Gend,
  28226. Naty: res.Output.Baseinfo.Naty,
  28227. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28228. PsnName: res.Output.Baseinfo.PsnName,
  28229. Idetinfo: idetinfoStr,
  28230. Insuinfo: infoStr,
  28231. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28232. CardInfo: card_info,
  28233. VerifyNumber: token,
  28234. }
  28235. service.CreateHisPsn(psn)
  28236. return token
  28237. }
  28238. }
  28239. } else {
  28240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28241. return ""
  28242. }
  28243. return token
  28244. }
  28245. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  28246. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  28247. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  28248. var token string
  28249. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28250. var api string
  28251. if miConfig.MdtrtareaAdmvs == "320921" {
  28252. 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 +
  28253. "&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
  28254. fmt.Println(api)
  28255. } else {
  28256. 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 +
  28257. "&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
  28258. }
  28259. resp, requestErr := http.Get(api)
  28260. if requestErr != nil {
  28261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28262. return ""
  28263. }
  28264. body, ioErr := ioutil.ReadAll(resp.Body)
  28265. if ioErr != nil {
  28266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28268. return ""
  28269. }
  28270. var respJSON map[string]interface{}
  28271. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28274. return ""
  28275. }
  28276. var status string
  28277. status = respJSON["data"].(map[string]interface{})["status"].(string)
  28278. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  28279. var res ResultTwo //1101结果
  28280. var res10265 ResultTwo10265 //1101结果
  28281. if status == "0" { //读卡成功
  28282. var card_info string //卡信息
  28283. var busi_card_info string
  28284. token = respJSON["data"].(map[string]interface{})["token"].(string)
  28285. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  28286. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  28287. fmt.Println(card_info)
  28288. fmt.Println(busi_card_info)
  28289. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  28290. result, _ := json.Marshal(respJSON)
  28291. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28292. utils.ErrorLog("解析失败:%v", err)
  28293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28294. return ""
  28295. }
  28296. res.ErrMsg = res10265.ErrMsg
  28297. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28298. res.Infcode = infocode
  28299. res.Output = res10265.Output
  28300. res.InfRefmsgid = res10265.InfRefmsgid
  28301. if res.Infcode == 0 {
  28302. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  28303. if err == gorm.ErrRecordNotFound {
  28304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  28305. return ""
  28306. } else if err != nil {
  28307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  28308. return ""
  28309. } else {
  28310. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28311. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  28312. infoStr := string(Iinfos)
  28313. idetinfoStr := string(Idetinfos)
  28314. psn := &models.HisPsn{
  28315. PsnNo: res.Output.Baseinfo.PsnNo,
  28316. PatientId: patient.ID,
  28317. Certno: res.Output.Baseinfo.Certno,
  28318. Gend: res.Output.Baseinfo.Gend,
  28319. Naty: res.Output.Baseinfo.Naty,
  28320. PsnCertType: res.Output.Baseinfo.PsnCertType,
  28321. PsnName: res.Output.Baseinfo.PsnName,
  28322. Idetinfo: idetinfoStr,
  28323. Insuinfo: infoStr,
  28324. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28325. CardInfo: card_info,
  28326. VerifyNumber: token,
  28327. }
  28328. service.CreateHisPsn(psn)
  28329. return token
  28330. }
  28331. }
  28332. } else {
  28333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28334. return ""
  28335. }
  28336. } else { //读卡失败
  28337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  28338. return ""
  28339. }
  28340. return token
  28341. }
  28342. func DeleteExtraSpaceTwo(s string) string {
  28343. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28344. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28345. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28346. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28347. s2 := make([]byte, len(s1)) //定义字符数组切片
  28348. copy(s2, s1) //将字符串复制到切片
  28349. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28350. for len(spc_index) > 0 { //找到适配项
  28351. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28352. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28353. }
  28354. return string(s2)
  28355. }
  28356. func Remove0000(s string) string {
  28357. str := make([]rune, 0, len(s))
  28358. for _, v := range []rune(s) {
  28359. if v == 0 {
  28360. continue
  28361. }
  28362. str = append(str, v)
  28363. }
  28364. return string(str)
  28365. }
  28366. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  28367. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  28368. readCard := DllDef.MustFindProc("EcQuery")
  28369. pCardInfo := make([]byte, 8192)
  28370. pBusiCardInfo := make([]byte, 8192)
  28371. data := make(map[string]interface{})
  28372. //pData := make(map[string]interface{})
  28373. inputData := make(map[string]interface{})
  28374. inputData["orgId"] = code
  28375. inputData["businessType"] = "01101"
  28376. inputData["operatorId"] = operator_id
  28377. inputData["operatorName"] = operator_name
  28378. inputData["officeId"] = "001"
  28379. inputData["officeName"] = "血透室"
  28380. //
  28381. data["data"] = inputData
  28382. data["transType"] = "ec.query"
  28383. data["orgId"] = code
  28384. bytesData, _ := json.Marshal(data)
  28385. pCardInfo = bytesData
  28386. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  28387. fmt.Println(ret2)
  28388. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  28389. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  28390. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  28391. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  28392. if ret2 != 0 {
  28393. return "", ""
  28394. }
  28395. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  28396. }
  28397. func DeleteExtraSpace(s string) string {
  28398. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  28399. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  28400. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  28401. reg, _ := regexp.Compile(regstr) //编译正则表达式
  28402. s2 := make([]byte, len(s1)) //定义字符数组切片
  28403. copy(s2, s1) //将字符串复制到切片
  28404. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  28405. for len(spc_index) > 0 { //找到适配项
  28406. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  28407. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  28408. }
  28409. return string(s2)
  28410. }
  28411. // 对账
  28412. func (c *HisApiController) Post3202() {
  28413. start_time := c.GetString("start_time")
  28414. end_time := c.GetString("end_time")
  28415. //insutype := c.GetString("insutype")
  28416. clr_type := c.GetString("clr_type")
  28417. clr_org := c.GetString("clr_optins")
  28418. admin_user_id, _ := c.GetInt64("admin_user_id")
  28419. adminUser := c.GetAdminUserInfo()
  28420. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28421. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28422. if len(clr_org) == 0 {
  28423. clr_org = miConfig.MdtrtareaAdmvs
  28424. }
  28425. timeLayout := "2006-01-02"
  28426. loc, _ := time.LoadLocation("Local")
  28427. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28428. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28429. var orders []*models.HisOrder
  28430. if clr_org == "421300" {
  28431. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28432. } else {
  28433. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28434. }
  28435. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28436. //fixmedins_setl_cnt := int64(len(orders))
  28437. var medfee_sumamt float64
  28438. var acct_pay float64
  28439. var fund_pay_sumamt float64
  28440. for _, item := range orders {
  28441. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28442. acct_pay = acct_pay + item.AcctPay
  28443. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28444. }
  28445. //var medfee_sumamt_two float64
  28446. //var acct_pay_two float64
  28447. //var fund_pay_sumamt_two float64
  28448. //for _, item := range orders_two {
  28449. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28450. // acct_pay_two = acct_pay_two + item.AcctPay
  28451. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28452. //}
  28453. //var user_name string
  28454. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28455. //if role.ID == 0 {
  28456. // user_name = "xxx"
  28457. //} else {
  28458. // user_name = role.UserName
  28459. //}
  28460. var res ResultSix
  28461. if config.IsOpen == 1 {
  28462. var bps []*models.BusinessParamsTwo
  28463. var bp models.BusinessParamsTwo
  28464. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28465. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28466. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28467. bp.MedfeeSumamt = medfee_sumamt_str
  28468. bp.AcctPay = acct_pay_str
  28469. bp.FundPaySumamt = fund_pay_sumamt_str
  28470. bp.Insutype = ""
  28471. bp.StmtBegndate = start_time
  28472. bp.ClrType = clr_type
  28473. bp.SetlOptins = clr_org
  28474. bp.StmtEnddate = end_time
  28475. bps = append(bps, &bp)
  28476. data := make(map[string]interface{})
  28477. data["bps"] = bps
  28478. data["org_name"] = miConfig.OrgName
  28479. data["doctor"] = role.UserName
  28480. data["fixmedins_code"] = miConfig.Code
  28481. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28482. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28483. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28484. if miConfig.MdtrtareaAdmvs == "421300" {
  28485. client := &http.Client{}
  28486. bytesData, _ := json.Marshal(data)
  28487. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28488. resp, _ := client.Do(req)
  28489. defer resp.Body.Close()
  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(body), &respJSON); err != nil {
  28498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28500. return
  28501. }
  28502. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28503. userJSONBytes, _ := json.Marshal(respJSON)
  28504. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28505. utils.ErrorLog("解析失败:%v", err)
  28506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28507. return
  28508. }
  28509. }
  28510. if miConfig.MdtrtareaAdmvs == "420200" {
  28511. client := &http.Client{}
  28512. bytesData, _ := json.Marshal(data)
  28513. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  28514. resp, _ := client.Do(req)
  28515. defer resp.Body.Close()
  28516. body, ioErr := ioutil.ReadAll(resp.Body)
  28517. if ioErr != nil {
  28518. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28520. return
  28521. }
  28522. var respJSON map[string]interface{}
  28523. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28524. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28526. return
  28527. }
  28528. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28529. userJSONBytes, _ := json.Marshal(respJSON)
  28530. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28531. utils.ErrorLog("解析失败:%v", err)
  28532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28533. return
  28534. }
  28535. }
  28536. if miConfig.MdtrtareaAdmvs == "421182" {
  28537. client := &http.Client{}
  28538. bytesData, _ := json.Marshal(data)
  28539. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  28540. resp, _ := client.Do(req)
  28541. defer resp.Body.Close()
  28542. body, ioErr := ioutil.ReadAll(resp.Body)
  28543. if ioErr != nil {
  28544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28546. return
  28547. }
  28548. var respJSON map[string]interface{}
  28549. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28552. return
  28553. }
  28554. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28555. userJSONBytes, _ := json.Marshal(respJSON)
  28556. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28557. utils.ErrorLog("解析失败:%v", err)
  28558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28559. return
  28560. }
  28561. }
  28562. if res.Infcode == 0 {
  28563. c.ServeSuccessJSON(map[string]interface{}{
  28564. "msg": "发起成功",
  28565. })
  28566. } else {
  28567. c.ServeSuccessJSON(map[string]interface{}{
  28568. "failed_code": -10,
  28569. "msg": res.ErrMsg,
  28570. })
  28571. }
  28572. }
  28573. }
  28574. func (c *HisApiController) Post3202b() {
  28575. start_time := c.GetString("start_time")
  28576. end_time := c.GetString("end_time")
  28577. //insutype := c.GetString("insutype")
  28578. clr_type := c.GetString("clr_type")
  28579. clr_org := c.GetString("clr_optins")
  28580. admin_user_id, _ := c.GetInt64("admin_user_id")
  28581. adminUser := c.GetAdminUserInfo()
  28582. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28583. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28584. if len(clr_org) == 0 {
  28585. clr_org = miConfig.MdtrtareaAdmvs
  28586. }
  28587. timeLayout := "2006-01-02"
  28588. loc, _ := time.LoadLocation("Local")
  28589. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28590. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28591. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28592. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28593. //fixmedins_setl_cnt := int64(len(orders))
  28594. var medfee_sumamt float64
  28595. var acct_pay float64
  28596. var fund_pay_sumamt float64
  28597. for _, item := range orders {
  28598. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28599. acct_pay = acct_pay + item.AcctPay
  28600. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  28601. }
  28602. //var medfee_sumamt_two float64
  28603. //var acct_pay_two float64
  28604. //var fund_pay_sumamt_two float64
  28605. //for _, item := range orders_two {
  28606. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  28607. // acct_pay_two = acct_pay_two + item.AcctPay
  28608. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  28609. //}
  28610. //var user_name string
  28611. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28612. //if role.ID == 0 {
  28613. // user_name = "xxx"
  28614. //} else {
  28615. // user_name = role.UserName
  28616. //}
  28617. var res ResultSix
  28618. if config.IsOpen == 1 {
  28619. var bps []*models.BusinessParamsTwo
  28620. var bp models.BusinessParamsTwo
  28621. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28622. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  28623. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  28624. bp.MedfeeSumamt = medfee_sumamt_str
  28625. bp.AcctPay = acct_pay_str
  28626. bp.FundPaySumamt = fund_pay_sumamt_str
  28627. bp.Insutype = "390"
  28628. bp.StmtBegndate = start_time
  28629. bp.ClrType = clr_type
  28630. bp.SetlOptins = clr_org
  28631. bp.StmtEnddate = end_time
  28632. bps = append(bps, &bp)
  28633. data := make(map[string]interface{})
  28634. data["bps"] = bps
  28635. data["org_name"] = miConfig.OrgName
  28636. data["doctor"] = role.UserName
  28637. data["fixmedins_code"] = miConfig.Code
  28638. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28639. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28640. if miConfig.MdtrtareaAdmvs == "421300" {
  28641. client := &http.Client{}
  28642. bytesData, _ := json.Marshal(data)
  28643. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28644. resp, _ := client.Do(req)
  28645. defer resp.Body.Close()
  28646. body, ioErr := ioutil.ReadAll(resp.Body)
  28647. if ioErr != nil {
  28648. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28650. return
  28651. }
  28652. var respJSON map[string]interface{}
  28653. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28654. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28656. return
  28657. }
  28658. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28659. userJSONBytes, _ := json.Marshal(respJSON)
  28660. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28661. utils.ErrorLog("解析失败:%v", err)
  28662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28663. return
  28664. }
  28665. }
  28666. if miConfig.MdtrtareaAdmvs == "420200" {
  28667. client := &http.Client{}
  28668. bytesData, _ := json.Marshal(data)
  28669. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  28670. resp, _ := client.Do(req)
  28671. defer resp.Body.Close()
  28672. body, ioErr := ioutil.ReadAll(resp.Body)
  28673. if ioErr != nil {
  28674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28676. return
  28677. }
  28678. var respJSON map[string]interface{}
  28679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28682. return
  28683. }
  28684. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28685. userJSONBytes, _ := json.Marshal(respJSON)
  28686. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28687. utils.ErrorLog("解析失败:%v", err)
  28688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28689. return
  28690. }
  28691. }
  28692. if miConfig.MdtrtareaAdmvs == "421182" {
  28693. client := &http.Client{}
  28694. bytesData, _ := json.Marshal(data)
  28695. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  28696. resp, _ := client.Do(req)
  28697. defer resp.Body.Close()
  28698. body, ioErr := ioutil.ReadAll(resp.Body)
  28699. if ioErr != nil {
  28700. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28702. return
  28703. }
  28704. var respJSON map[string]interface{}
  28705. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28706. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28708. return
  28709. }
  28710. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28711. userJSONBytes, _ := json.Marshal(respJSON)
  28712. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28713. utils.ErrorLog("解析失败:%v", err)
  28714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28715. return
  28716. }
  28717. }
  28718. if res.Infcode == 0 {
  28719. c.ServeSuccessJSON(map[string]interface{}{
  28720. "msg": "发起成功",
  28721. })
  28722. } else {
  28723. c.ServeSuccessJSON(map[string]interface{}{
  28724. "failed_code": -10,
  28725. "msg": res.ErrMsg,
  28726. })
  28727. }
  28728. }
  28729. }
  28730. func (c *HisApiController) Post1608() {
  28731. start_time := c.GetString("start_time")
  28732. end_time := c.GetString("end_time")
  28733. admin_user_id, _ := c.GetInt64("admin_user_id")
  28734. adminUser := c.GetAdminUserInfo()
  28735. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28736. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28737. timeLayout := "2006-01-02"
  28738. loc, _ := time.LoadLocation("Local")
  28739. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  28740. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  28741. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  28742. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  28743. fixmedins_setl_cnt := int64(len(orders))
  28744. var medfee_sumamt float64
  28745. var func_smamt float64
  28746. for _, item := range orders {
  28747. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  28748. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  28749. }
  28750. times := strings.Split(start_time, "-")
  28751. time_tows := strings.Split(end_time, "-")
  28752. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28753. var res ResultSix
  28754. if config.IsOpen == 1 {
  28755. //var bps []*models.BusinessParamsTwo
  28756. //var bp models.BusinessParamsTwo
  28757. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  28758. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  28759. data := make(map[string]interface{})
  28760. data["org_name"] = miConfig.OrgName
  28761. data["doctor"] = role.UserName
  28762. data["func_smamt"] = func_smamt_str
  28763. data["fixmedins_code"] = miConfig.Code
  28764. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28765. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28766. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  28767. data["medfee_sumamt"] = medfee_sumamt_str
  28768. data["start_time"] = times[0] + times[1] + times[2]
  28769. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  28770. if miConfig.MdtrtareaAdmvs == "421300" {
  28771. client := &http.Client{}
  28772. bytesData, _ := json.Marshal(data)
  28773. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28774. resp, _ := client.Do(req)
  28775. defer resp.Body.Close()
  28776. body, ioErr := ioutil.ReadAll(resp.Body)
  28777. if ioErr != nil {
  28778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28780. return
  28781. }
  28782. var respJSON map[string]interface{}
  28783. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28786. return
  28787. }
  28788. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28789. userJSONBytes, _ := json.Marshal(respJSON)
  28790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28791. utils.ErrorLog("解析失败:%v", err)
  28792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28793. return
  28794. }
  28795. }
  28796. if miConfig.MdtrtareaAdmvs == "420200" {
  28797. client := &http.Client{}
  28798. bytesData, _ := json.Marshal(data)
  28799. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  28800. resp, _ := client.Do(req)
  28801. defer resp.Body.Close()
  28802. body, ioErr := ioutil.ReadAll(resp.Body)
  28803. if ioErr != nil {
  28804. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28805. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28806. return
  28807. }
  28808. var respJSON map[string]interface{}
  28809. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28810. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28812. return
  28813. }
  28814. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28815. userJSONBytes, _ := json.Marshal(respJSON)
  28816. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28817. utils.ErrorLog("解析失败:%v", err)
  28818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28819. return
  28820. }
  28821. }
  28822. if miConfig.MdtrtareaAdmvs == "421182" {
  28823. client := &http.Client{}
  28824. bytesData, _ := json.Marshal(data)
  28825. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  28826. resp, _ := client.Do(req)
  28827. defer resp.Body.Close()
  28828. body, ioErr := ioutil.ReadAll(resp.Body)
  28829. if ioErr != nil {
  28830. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28832. return
  28833. }
  28834. var respJSON map[string]interface{}
  28835. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28836. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28838. return
  28839. }
  28840. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28841. userJSONBytes, _ := json.Marshal(respJSON)
  28842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28843. utils.ErrorLog("解析失败:%v", err)
  28844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28845. return
  28846. }
  28847. }
  28848. if res.Infcode == 0 {
  28849. c.ServeSuccessJSON(map[string]interface{}{
  28850. "msg": "发起成功",
  28851. })
  28852. } else {
  28853. c.ServeSuccessJSON(map[string]interface{}{
  28854. "failed_code": -10,
  28855. "msg": res.ErrMsg,
  28856. })
  28857. }
  28858. }
  28859. }
  28860. // 5.11.1.1【5262】结算信息按时间段查询
  28861. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28862. admin_user_id, _ := c.GetInt64("admin_user_id")
  28863. adminUser := c.GetAdminUserInfo()
  28864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28865. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28866. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28867. var res Result5262
  28868. if config.IsOpen == 1 {
  28869. if miConfig.MdtrtareaAdmvs == "421300" {
  28870. data := make(map[string]interface{})
  28871. data["bps"] = bp
  28872. data["org_name"] = miConfig.OrgName
  28873. data["doctor"] = role.UserName
  28874. data["fixmedins_code"] = miConfig.Code
  28875. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28876. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28877. data["page"] = strconv.FormatInt(page, 10)
  28878. data["limit"] = strconv.FormatInt(limit, 10)
  28879. fmt.Println(data)
  28880. client := &http.Client{}
  28881. bytesData, _ := json.Marshal(data)
  28882. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28883. resp, _ := client.Do(req)
  28884. defer resp.Body.Close()
  28885. body, ioErr := ioutil.ReadAll(resp.Body)
  28886. if ioErr != nil {
  28887. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28889. return
  28890. }
  28891. var respJSON map[string]interface{}
  28892. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28893. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28895. return
  28896. }
  28897. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28898. userJSONBytes, _ := json.Marshal(respJSON)
  28899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28900. utils.ErrorLog("解析失败:%v", err)
  28901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28902. return
  28903. }
  28904. }
  28905. if miConfig.MdtrtareaAdmvs == "420200" {
  28906. data := make(map[string]interface{})
  28907. data["bps"] = bp
  28908. data["org_name"] = miConfig.OrgName
  28909. data["doctor"] = role.UserName
  28910. data["fixmedins_code"] = miConfig.Code
  28911. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28912. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28913. data["page"] = strconv.FormatInt(page, 10)
  28914. data["limit"] = strconv.FormatInt(limit, 10)
  28915. fmt.Println(data)
  28916. client := &http.Client{}
  28917. bytesData, _ := json.Marshal(data)
  28918. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  28919. resp, _ := client.Do(req)
  28920. defer resp.Body.Close()
  28921. body, ioErr := ioutil.ReadAll(resp.Body)
  28922. if ioErr != nil {
  28923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28925. return
  28926. }
  28927. var respJSON map[string]interface{}
  28928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28931. return
  28932. }
  28933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28934. userJSONBytes, _ := json.Marshal(respJSON)
  28935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28936. utils.ErrorLog("解析失败:%v", err)
  28937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28938. return
  28939. }
  28940. }
  28941. if miConfig.MdtrtareaAdmvs == "421182" {
  28942. data := make(map[string]interface{})
  28943. data["bps"] = bp
  28944. data["org_name"] = miConfig.OrgName
  28945. data["doctor"] = role.UserName
  28946. data["fixmedins_code"] = miConfig.Code
  28947. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  28948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  28949. data["page"] = strconv.FormatInt(page, 10)
  28950. data["limit"] = strconv.FormatInt(limit, 10)
  28951. fmt.Println(data)
  28952. client := &http.Client{}
  28953. bytesData, _ := json.Marshal(data)
  28954. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  28955. resp, _ := client.Do(req)
  28956. defer resp.Body.Close()
  28957. body, ioErr := ioutil.ReadAll(resp.Body)
  28958. if ioErr != nil {
  28959. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28961. return
  28962. }
  28963. var respJSON map[string]interface{}
  28964. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  28965. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28967. return
  28968. }
  28969. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28970. userJSONBytes, _ := json.Marshal(respJSON)
  28971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28972. utils.ErrorLog("解析失败:%v", err)
  28973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28974. return
  28975. }
  28976. }
  28977. if res.Infcode == 0 {
  28978. c.ServeSuccessJSON(map[string]interface{}{
  28979. "order": res.Output.Result,
  28980. "total": res.Output.PageInfo.RecordCounts,
  28981. })
  28982. } else {
  28983. c.ServeSuccessJSON(map[string]interface{}{
  28984. "failed_code": -10,
  28985. "msg": res.ErrMsg,
  28986. })
  28987. }
  28988. }
  28989. }
  28990. // 5.11.1.2【5267】异地结算信息时间段查询
  28991. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  28992. admin_user_id, _ := c.GetInt64("admin_user_id")
  28993. adminUser := c.GetAdminUserInfo()
  28994. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28995. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28996. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28997. var res Result5267
  28998. if config.IsOpen == 1 {
  28999. if miConfig.MdtrtareaAdmvs == "421300" {
  29000. data := make(map[string]interface{})
  29001. data["bps"] = bp
  29002. data["org_name"] = miConfig.OrgName
  29003. data["doctor"] = role.UserName
  29004. data["fixmedins_code"] = miConfig.Code
  29005. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29006. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29007. data["page"] = page
  29008. data["limit"] = limit
  29009. fmt.Println(data)
  29010. client := &http.Client{}
  29011. bytesData, _ := json.Marshal(data)
  29012. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29013. resp, _ := client.Do(req)
  29014. defer resp.Body.Close()
  29015. body, ioErr := ioutil.ReadAll(resp.Body)
  29016. if ioErr != nil {
  29017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29019. return
  29020. }
  29021. var respJSON map[string]interface{}
  29022. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29025. return
  29026. }
  29027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29028. userJSONBytes, _ := json.Marshal(respJSON)
  29029. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29030. utils.ErrorLog("解析失败:%v", err)
  29031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29032. return
  29033. }
  29034. }
  29035. if miConfig.MdtrtareaAdmvs == "420200" {
  29036. data := make(map[string]interface{})
  29037. data["bps"] = bp
  29038. data["org_name"] = miConfig.OrgName
  29039. data["doctor"] = role.UserName
  29040. data["fixmedins_code"] = miConfig.Code
  29041. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29042. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29043. data["page"] = page
  29044. data["limit"] = limit
  29045. fmt.Println(data)
  29046. client := &http.Client{}
  29047. bytesData, _ := json.Marshal(data)
  29048. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  29049. resp, _ := client.Do(req)
  29050. defer resp.Body.Close()
  29051. body, ioErr := ioutil.ReadAll(resp.Body)
  29052. if ioErr != nil {
  29053. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29055. return
  29056. }
  29057. var respJSON map[string]interface{}
  29058. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29059. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29061. return
  29062. }
  29063. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29064. userJSONBytes, _ := json.Marshal(respJSON)
  29065. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29066. utils.ErrorLog("解析失败:%v", err)
  29067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29068. return
  29069. }
  29070. }
  29071. if miConfig.MdtrtareaAdmvs == "421182" {
  29072. data := make(map[string]interface{})
  29073. data["bps"] = bp
  29074. data["org_name"] = miConfig.OrgName
  29075. data["doctor"] = role.UserName
  29076. data["fixmedins_code"] = miConfig.Code
  29077. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29078. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29079. data["page"] = page
  29080. data["limit"] = limit
  29081. fmt.Println(data)
  29082. client := &http.Client{}
  29083. bytesData, _ := json.Marshal(data)
  29084. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  29085. resp, _ := client.Do(req)
  29086. defer resp.Body.Close()
  29087. body, ioErr := ioutil.ReadAll(resp.Body)
  29088. if ioErr != nil {
  29089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29091. return
  29092. }
  29093. var respJSON map[string]interface{}
  29094. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29097. return
  29098. }
  29099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29100. userJSONBytes, _ := json.Marshal(respJSON)
  29101. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29102. utils.ErrorLog("解析失败:%v", err)
  29103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29104. return
  29105. }
  29106. }
  29107. if res.Infcode == 0 {
  29108. c.ServeSuccessJSON(map[string]interface{}{
  29109. "order": res.Output.Result,
  29110. "total": res.Output.PageInfo.RecordCounts,
  29111. })
  29112. } else {
  29113. c.ServeSuccessJSON(map[string]interface{}{
  29114. "failed_code": -10,
  29115. "msg": res.ErrMsg,
  29116. })
  29117. }
  29118. }
  29119. }
  29120. func (c *HisApiController) Post3501() {
  29121. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29122. data := make(map[string]interface{})
  29123. var struct3501s []models.Struct3501
  29124. var struct3501 models.Struct3501
  29125. struct3501.OrgName = miConfig.OrgName
  29126. struct3501.AccessKey = miConfig.AccessKey
  29127. struct3501.RequestUrl = miConfig.Url
  29128. struct3501.SecretKey = miConfig.SecretKey
  29129. struct3501.ManuDate = "2022-08-17"
  29130. struct3501.FixmedinsBchno = ""
  29131. struct3501.ManuLotnum = ""
  29132. struct3501.RxFlag = "0"
  29133. struct3501.ExpyEnd = "2022-08-17"
  29134. struct3501.Invdate = "2022-08-17"
  29135. struct3501.InvCnt = "20.25"
  29136. struct3501.Memo = ""
  29137. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29138. struct3501.FixmedinsHilistId = miConfig.Code
  29139. struct3501.FixmedinsHilistName = miConfig.OrgName
  29140. struct3501s = append(struct3501s, struct3501)
  29141. data["struct_3501s"] = struct3501s
  29142. client := &http.Client{}
  29143. bytesData, _ := json.Marshal(data)
  29144. var req *http.Request
  29145. if miConfig.MdtrtareaAdmvs == "320921" {
  29146. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29147. } else {
  29148. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29149. }
  29150. resp, _ := client.Do(req)
  29151. defer resp.Body.Close()
  29152. body, ioErr := ioutil.ReadAll(resp.Body)
  29153. if ioErr != nil {
  29154. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29156. return
  29157. }
  29158. var respJSON map[string]interface{}
  29159. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29160. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29162. return
  29163. }
  29164. var res ResultSix
  29165. var resSix10265 ResultSix10265 //1101结果
  29166. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29167. result, _ := json.Marshal(respJSON)
  29168. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29169. utils.ErrorLog("解析失败:%v", err)
  29170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29171. return
  29172. }
  29173. res.InfRefmsgid = resSix10265.InfRefmsgid
  29174. res.Output = resSix10265.Output
  29175. res.ErrMsg = resSix10265.ErrMsg
  29176. res.Cainfo = resSix10265.Cainfo
  29177. res.WarnMsg = resSix10265.WarnMsg
  29178. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29179. res.Infcode = infocode
  29180. if infocode == 0 {
  29181. c.ServeSuccessJSON(map[string]interface{}{
  29182. "msg": "上传成功",
  29183. })
  29184. return
  29185. } else {
  29186. c.ServeSuccessJSON(map[string]interface{}{
  29187. "failed_code": -10,
  29188. "msg": res.ErrMsg,
  29189. })
  29190. return
  29191. }
  29192. }
  29193. func (c *HisApiController) Post3502() {
  29194. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29195. data := make(map[string]interface{})
  29196. var struct3502s []models.Struct3502
  29197. var struct3502 models.Struct3502
  29198. struct3502.OrgName = miConfig.OrgName
  29199. struct3502.AccessKey = miConfig.AccessKey
  29200. struct3502.RequestUrl = miConfig.Url
  29201. struct3502.SecretKey = miConfig.SecretKey
  29202. struct3502.ManuDate = "2022-08-15"
  29203. struct3502.FixmedinsBchno = ""
  29204. struct3502.ManuLotnum = ""
  29205. struct3502.RxFlag = "0"
  29206. struct3502.ExpyEnd = "2022-08-15"
  29207. struct3502.Invdate = "2022-08-15"
  29208. struct3502.InvCnt = "20.25"
  29209. struct3502.Memo = ""
  29210. struct3502.MedListCodg = "XB01ABD056B002020200517"
  29211. struct3502.FixmedinsHilistId = miConfig.Code
  29212. struct3502.FixmedinsHilistName = miConfig.OrgName
  29213. struct3502s = append(struct3502s, struct3502)
  29214. data["struct_3502s"] = struct3502s
  29215. client := &http.Client{}
  29216. bytesData, _ := json.Marshal(data)
  29217. var req *http.Request
  29218. if miConfig.MdtrtareaAdmvs == "320921" {
  29219. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29220. } else {
  29221. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29222. }
  29223. resp, _ := client.Do(req)
  29224. defer resp.Body.Close()
  29225. body, ioErr := ioutil.ReadAll(resp.Body)
  29226. if ioErr != nil {
  29227. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29229. return
  29230. }
  29231. var respJSON map[string]interface{}
  29232. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29233. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29235. return
  29236. }
  29237. var res ResultSix
  29238. var resSix10265 ResultSix10265 //1101结果
  29239. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29240. result, _ := json.Marshal(respJSON)
  29241. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29242. utils.ErrorLog("解析失败:%v", err)
  29243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29244. return
  29245. }
  29246. res.InfRefmsgid = resSix10265.InfRefmsgid
  29247. res.Output = resSix10265.Output
  29248. res.ErrMsg = resSix10265.ErrMsg
  29249. res.Cainfo = resSix10265.Cainfo
  29250. res.WarnMsg = resSix10265.WarnMsg
  29251. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29252. res.Infcode = infocode
  29253. if infocode == 0 {
  29254. c.ServeSuccessJSON(map[string]interface{}{
  29255. "msg": "上传成功",
  29256. })
  29257. return
  29258. } else {
  29259. c.ServeSuccessJSON(map[string]interface{}{
  29260. "failed_code": -10,
  29261. "msg": res.ErrMsg,
  29262. })
  29263. return
  29264. }
  29265. }
  29266. func (c *HisApiController) Post3503() {
  29267. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29268. data := make(map[string]interface{})
  29269. var struct3501s []models.Struct3501
  29270. var struct3501 models.Struct3501
  29271. struct3501.OrgName = miConfig.OrgName
  29272. struct3501.AccessKey = miConfig.AccessKey
  29273. struct3501.RequestUrl = miConfig.Url
  29274. struct3501.SecretKey = miConfig.SecretKey
  29275. struct3501.ManuDate = "2022-08-15"
  29276. struct3501.FixmedinsBchno = ""
  29277. struct3501.ManuLotnum = ""
  29278. struct3501.RxFlag = "0"
  29279. struct3501.ExpyEnd = "2022-08-15"
  29280. struct3501.Invdate = "2022-08-15"
  29281. struct3501.InvCnt = "20.25"
  29282. struct3501.Memo = ""
  29283. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29284. struct3501.FixmedinsHilistId = miConfig.Code
  29285. struct3501.FixmedinsHilistName = miConfig.OrgName
  29286. struct3501s = append(struct3501s, struct3501)
  29287. data["struct_3501s"] = struct3501s
  29288. client := &http.Client{}
  29289. bytesData, _ := json.Marshal(data)
  29290. var req *http.Request
  29291. if miConfig.MdtrtareaAdmvs == "320921" {
  29292. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29293. } else {
  29294. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29295. }
  29296. resp, _ := client.Do(req)
  29297. defer resp.Body.Close()
  29298. body, ioErr := ioutil.ReadAll(resp.Body)
  29299. if ioErr != nil {
  29300. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29302. return
  29303. }
  29304. var respJSON map[string]interface{}
  29305. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29306. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29308. return
  29309. }
  29310. var res ResultSix
  29311. var resSix10265 ResultSix10265 //1101结果
  29312. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29313. result, _ := json.Marshal(respJSON)
  29314. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29315. utils.ErrorLog("解析失败:%v", err)
  29316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29317. return
  29318. }
  29319. res.InfRefmsgid = resSix10265.InfRefmsgid
  29320. res.Output = resSix10265.Output
  29321. res.ErrMsg = resSix10265.ErrMsg
  29322. res.Cainfo = resSix10265.Cainfo
  29323. res.WarnMsg = resSix10265.WarnMsg
  29324. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29325. res.Infcode = infocode
  29326. if infocode == 0 {
  29327. c.ServeSuccessJSON(map[string]interface{}{
  29328. "msg": "上传成功",
  29329. })
  29330. return
  29331. } else {
  29332. c.ServeSuccessJSON(map[string]interface{}{
  29333. "failed_code": -10,
  29334. "msg": res.ErrMsg,
  29335. })
  29336. return
  29337. }
  29338. }
  29339. func (c *HisApiController) Post3504() {
  29340. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29341. data := make(map[string]interface{})
  29342. var struct3501s []models.Struct3501
  29343. var struct3501 models.Struct3501
  29344. struct3501.OrgName = miConfig.OrgName
  29345. struct3501.AccessKey = miConfig.AccessKey
  29346. struct3501.RequestUrl = miConfig.Url
  29347. struct3501.SecretKey = miConfig.SecretKey
  29348. struct3501.ManuDate = "2022-08-15"
  29349. struct3501.FixmedinsBchno = ""
  29350. struct3501.ManuLotnum = ""
  29351. struct3501.RxFlag = "0"
  29352. struct3501.ExpyEnd = "2022-08-15"
  29353. struct3501.Invdate = "2022-08-15"
  29354. struct3501.InvCnt = "20.25"
  29355. struct3501.Memo = ""
  29356. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29357. struct3501.FixmedinsHilistId = miConfig.Code
  29358. struct3501.FixmedinsHilistName = miConfig.OrgName
  29359. struct3501s = append(struct3501s, struct3501)
  29360. data["struct_3501s"] = struct3501s
  29361. client := &http.Client{}
  29362. bytesData, _ := json.Marshal(data)
  29363. var req *http.Request
  29364. if miConfig.MdtrtareaAdmvs == "320921" {
  29365. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29366. } else {
  29367. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29368. }
  29369. resp, _ := client.Do(req)
  29370. defer resp.Body.Close()
  29371. body, ioErr := ioutil.ReadAll(resp.Body)
  29372. if ioErr != nil {
  29373. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29375. return
  29376. }
  29377. var respJSON map[string]interface{}
  29378. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29379. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29381. return
  29382. }
  29383. var res ResultSix
  29384. var resSix10265 ResultSix10265 //1101结果
  29385. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29386. result, _ := json.Marshal(respJSON)
  29387. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29388. utils.ErrorLog("解析失败:%v", err)
  29389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29390. return
  29391. }
  29392. res.InfRefmsgid = resSix10265.InfRefmsgid
  29393. res.Output = resSix10265.Output
  29394. res.ErrMsg = resSix10265.ErrMsg
  29395. res.Cainfo = resSix10265.Cainfo
  29396. res.WarnMsg = resSix10265.WarnMsg
  29397. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29398. res.Infcode = infocode
  29399. if infocode == 0 {
  29400. c.ServeSuccessJSON(map[string]interface{}{
  29401. "msg": "上传成功",
  29402. })
  29403. return
  29404. } else {
  29405. c.ServeSuccessJSON(map[string]interface{}{
  29406. "failed_code": -10,
  29407. "msg": res.ErrMsg,
  29408. })
  29409. return
  29410. }
  29411. }
  29412. func (c *HisApiController) Post3505() {
  29413. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29414. data := make(map[string]interface{})
  29415. var struct3501s []models.Struct3501
  29416. var struct3501 models.Struct3501
  29417. struct3501.OrgName = miConfig.OrgName
  29418. struct3501.AccessKey = miConfig.AccessKey
  29419. struct3501.RequestUrl = miConfig.Url
  29420. struct3501.SecretKey = miConfig.SecretKey
  29421. struct3501.ManuDate = "2022-08-15"
  29422. struct3501.FixmedinsBchno = ""
  29423. struct3501.ManuLotnum = ""
  29424. struct3501.RxFlag = "0"
  29425. struct3501.ExpyEnd = "2022-08-15"
  29426. struct3501.Invdate = "2022-08-15"
  29427. struct3501.InvCnt = "20.25"
  29428. struct3501.Memo = ""
  29429. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29430. struct3501.FixmedinsHilistId = miConfig.Code
  29431. struct3501.FixmedinsHilistName = miConfig.OrgName
  29432. struct3501s = append(struct3501s, struct3501)
  29433. data["struct_3501s"] = struct3501s
  29434. client := &http.Client{}
  29435. bytesData, _ := json.Marshal(data)
  29436. var req *http.Request
  29437. if miConfig.MdtrtareaAdmvs == "320921" {
  29438. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29439. } else {
  29440. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29441. }
  29442. resp, _ := client.Do(req)
  29443. defer resp.Body.Close()
  29444. body, ioErr := ioutil.ReadAll(resp.Body)
  29445. if ioErr != nil {
  29446. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29448. return
  29449. }
  29450. var respJSON map[string]interface{}
  29451. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29452. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29454. return
  29455. }
  29456. var res ResultSix
  29457. var resSix10265 ResultSix10265 //1101结果
  29458. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29459. result, _ := json.Marshal(respJSON)
  29460. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29461. utils.ErrorLog("解析失败:%v", err)
  29462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29463. return
  29464. }
  29465. res.InfRefmsgid = resSix10265.InfRefmsgid
  29466. res.Output = resSix10265.Output
  29467. res.ErrMsg = resSix10265.ErrMsg
  29468. res.Cainfo = resSix10265.Cainfo
  29469. res.WarnMsg = resSix10265.WarnMsg
  29470. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29471. res.Infcode = infocode
  29472. if infocode == 0 {
  29473. c.ServeSuccessJSON(map[string]interface{}{
  29474. "msg": "上传成功",
  29475. })
  29476. return
  29477. } else {
  29478. c.ServeSuccessJSON(map[string]interface{}{
  29479. "failed_code": -10,
  29480. "msg": res.ErrMsg,
  29481. })
  29482. return
  29483. }
  29484. }
  29485. func (c *HisApiController) Post3506() {
  29486. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29487. data := make(map[string]interface{})
  29488. var struct3501s []models.Struct3501
  29489. var struct3501 models.Struct3501
  29490. struct3501.OrgName = miConfig.OrgName
  29491. struct3501.AccessKey = miConfig.AccessKey
  29492. struct3501.RequestUrl = miConfig.Url
  29493. struct3501.SecretKey = miConfig.SecretKey
  29494. struct3501.ManuDate = "2022-08-15"
  29495. struct3501.FixmedinsBchno = ""
  29496. struct3501.ManuLotnum = ""
  29497. struct3501.RxFlag = "0"
  29498. struct3501.ExpyEnd = "2022-08-15"
  29499. struct3501.Invdate = "2022-08-15"
  29500. struct3501.InvCnt = "20.25"
  29501. struct3501.Memo = ""
  29502. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29503. struct3501.FixmedinsHilistId = miConfig.Code
  29504. struct3501.FixmedinsHilistName = miConfig.OrgName
  29505. struct3501s = append(struct3501s, struct3501)
  29506. data["struct_3501s"] = struct3501s
  29507. client := &http.Client{}
  29508. bytesData, _ := json.Marshal(data)
  29509. var req *http.Request
  29510. if miConfig.MdtrtareaAdmvs == "320921" {
  29511. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29512. } else {
  29513. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29514. }
  29515. resp, _ := client.Do(req)
  29516. defer resp.Body.Close()
  29517. body, ioErr := ioutil.ReadAll(resp.Body)
  29518. if ioErr != nil {
  29519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29521. return
  29522. }
  29523. var respJSON map[string]interface{}
  29524. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29527. return
  29528. }
  29529. var res ResultSix
  29530. var resSix10265 ResultSix10265 //1101结果
  29531. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29532. result, _ := json.Marshal(respJSON)
  29533. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29534. utils.ErrorLog("解析失败:%v", err)
  29535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29536. return
  29537. }
  29538. res.InfRefmsgid = resSix10265.InfRefmsgid
  29539. res.Output = resSix10265.Output
  29540. res.ErrMsg = resSix10265.ErrMsg
  29541. res.Cainfo = resSix10265.Cainfo
  29542. res.WarnMsg = resSix10265.WarnMsg
  29543. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29544. res.Infcode = infocode
  29545. if infocode == 0 {
  29546. c.ServeSuccessJSON(map[string]interface{}{
  29547. "msg": "上传成功",
  29548. })
  29549. return
  29550. } else {
  29551. c.ServeSuccessJSON(map[string]interface{}{
  29552. "failed_code": -10,
  29553. "msg": res.ErrMsg,
  29554. })
  29555. return
  29556. }
  29557. }
  29558. func (c *HisApiController) Post3507() {
  29559. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  29560. data := make(map[string]interface{})
  29561. var struct3501s []models.Struct3501
  29562. var struct3501 models.Struct3501
  29563. struct3501.OrgName = miConfig.OrgName
  29564. struct3501.AccessKey = miConfig.AccessKey
  29565. struct3501.RequestUrl = miConfig.Url
  29566. struct3501.SecretKey = miConfig.SecretKey
  29567. struct3501.ManuDate = "2022-08-15"
  29568. struct3501.FixmedinsBchno = ""
  29569. struct3501.ManuLotnum = ""
  29570. struct3501.RxFlag = "0"
  29571. struct3501.ExpyEnd = "2022-08-15"
  29572. struct3501.Invdate = "2022-08-15"
  29573. struct3501.InvCnt = "20.25"
  29574. struct3501.Memo = ""
  29575. struct3501.MedListCodg = "XB01ABD056B002020200517"
  29576. struct3501.FixmedinsHilistId = miConfig.Code
  29577. struct3501.FixmedinsHilistName = miConfig.OrgName
  29578. struct3501s = append(struct3501s, struct3501)
  29579. data["struct_3501s"] = struct3501s
  29580. client := &http.Client{}
  29581. bytesData, _ := json.Marshal(data)
  29582. var req *http.Request
  29583. if miConfig.MdtrtareaAdmvs == "320921" {
  29584. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29585. } else {
  29586. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  29587. }
  29588. resp, _ := client.Do(req)
  29589. defer resp.Body.Close()
  29590. body, ioErr := ioutil.ReadAll(resp.Body)
  29591. if ioErr != nil {
  29592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29594. return
  29595. }
  29596. var respJSON map[string]interface{}
  29597. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29600. return
  29601. }
  29602. var res ResultSix
  29603. var resSix10265 ResultSix10265 //1101结果
  29604. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  29605. result, _ := json.Marshal(respJSON)
  29606. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  29607. utils.ErrorLog("解析失败:%v", err)
  29608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29609. return
  29610. }
  29611. res.InfRefmsgid = resSix10265.InfRefmsgid
  29612. res.Output = resSix10265.Output
  29613. res.ErrMsg = resSix10265.ErrMsg
  29614. res.Cainfo = resSix10265.Cainfo
  29615. res.WarnMsg = resSix10265.WarnMsg
  29616. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  29617. res.Infcode = infocode
  29618. if infocode == 0 {
  29619. c.ServeSuccessJSON(map[string]interface{}{
  29620. "msg": "上传成功",
  29621. })
  29622. return
  29623. } else {
  29624. c.ServeSuccessJSON(map[string]interface{}{
  29625. "failed_code": -10,
  29626. "msg": res.ErrMsg,
  29627. })
  29628. return
  29629. }
  29630. }
  29631. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29632. // WebSocket服务器地址
  29633. serverURL := "ws://127.0.0.1:8899"
  29634. // 解析WebSocket服务器地址
  29635. u, err := url.Parse(serverURL)
  29636. if err != nil {
  29637. }
  29638. // 建立WebSocket连接
  29639. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29640. if err != nil {
  29641. }
  29642. defer conn.Close()
  29643. input2 := make(map[string]interface{})
  29644. input := make(map[string]interface{})
  29645. inputData := make(map[string]interface{})
  29646. inputData["orgId"] = code
  29647. inputData["businessType"] = "01101"
  29648. inputData["operatorId"] = operator_id
  29649. inputData["operatorName"] = operator_name
  29650. inputData["officeId"] = "001"
  29651. inputData["officeName"] = "血透室"
  29652. inputData["deviceType"] = ""
  29653. input["data"] = inputData
  29654. input["orgId"] = code
  29655. input["transType"] = "ec.query"
  29656. //if md == ""
  29657. if md[:4] == "4403" {
  29658. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29659. } else if md[:4] == "4401" {
  29660. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29661. } else {
  29662. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29663. }
  29664. input2["indata"] = input
  29665. fmt.Println(input2)
  29666. bytesData, _ := json.Marshal(input2)
  29667. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29668. if err != nil {
  29669. fmt.Println(err)
  29670. }
  29671. // 接收消息
  29672. _, receivedMessage, err := conn.ReadMessage()
  29673. if err != nil {
  29674. fmt.Println(err)
  29675. }
  29676. return "", string(receivedMessage)
  29677. }
  29678. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  29679. // WebSocket服务器地址
  29680. serverURL := "ws://127.0.0.1:8899"
  29681. // 解析WebSocket服务器地址
  29682. u, err := url.Parse(serverURL)
  29683. if err != nil {
  29684. }
  29685. // 建立WebSocket连接
  29686. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29687. if err != nil {
  29688. }
  29689. defer conn.Close()
  29690. input2 := make(map[string]interface{})
  29691. input := make(map[string]interface{})
  29692. inputData := make(map[string]interface{})
  29693. inputData["orgId"] = code
  29694. inputData["businessType"] = "01103"
  29695. inputData["operatorId"] = operator_id
  29696. inputData["operatorName"] = operator_name
  29697. inputData["officeId"] = "001"
  29698. inputData["officeName"] = "血透室"
  29699. inputData["deviceType"] = ""
  29700. input["data"] = inputData
  29701. input["orgId"] = code
  29702. input["transType"] = "ec.query"
  29703. //if md ==
  29704. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  29705. input2["indata"] = input
  29706. fmt.Println(input2)
  29707. bytesData, _ := json.Marshal(input2)
  29708. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29709. if err != nil {
  29710. fmt.Println(err)
  29711. }
  29712. // 接收消息
  29713. _, receivedMessage, err := conn.ReadMessage()
  29714. if err != nil {
  29715. fmt.Println(err)
  29716. }
  29717. return "", string(receivedMessage)
  29718. }
  29719. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  29720. // WebSocket服务器地址
  29721. serverURL := "ws://127.0.0.1:8899"
  29722. // 解析WebSocket服务器地址
  29723. u, err := url.Parse(serverURL)
  29724. if err != nil {
  29725. }
  29726. // 建立WebSocket连接
  29727. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29728. if err != nil {
  29729. }
  29730. defer conn.Close()
  29731. input2 := make(map[string]interface{})
  29732. input := make(map[string]interface{})
  29733. inputData := make(map[string]interface{})
  29734. inputData["orgId"] = code
  29735. inputData["businessType"] = "01101"
  29736. inputData["operatorId"] = operator_id
  29737. inputData["operatorName"] = operator_name
  29738. inputData["officeId"] = "001"
  29739. inputData["officeName"] = "血透室"
  29740. inputData["deviceType"] = ""
  29741. input["data"] = inputData
  29742. input["orgId"] = code
  29743. input["transType"] = "ec.query"
  29744. //if md == ""
  29745. if md[:4] == "4403" {
  29746. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29747. } else if md[:4] == "4401" {
  29748. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29749. } else {
  29750. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29751. }
  29752. input2["indata"] = input
  29753. fmt.Println(input2)
  29754. bytesData, _ := json.Marshal(input2)
  29755. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29756. if err != nil {
  29757. fmt.Println(err)
  29758. }
  29759. // 接收消息
  29760. _, receivedMessage, err := conn.ReadMessage()
  29761. if err != nil {
  29762. fmt.Println(err)
  29763. }
  29764. return "", string(receivedMessage)
  29765. }
  29766. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  29767. // WebSocket服务器地址
  29768. serverURL := "ws://127.0.0.1:8899"
  29769. // 解析WebSocket服务器地址
  29770. u, err := url.Parse(serverURL)
  29771. if err != nil {
  29772. }
  29773. // 建立WebSocket连接
  29774. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  29775. if err != nil {
  29776. }
  29777. defer conn.Close()
  29778. input2 := make(map[string]interface{})
  29779. input := make(map[string]interface{})
  29780. inputData := make(map[string]interface{})
  29781. inputData["orgId"] = code
  29782. inputData["businessType"] = "01301"
  29783. inputData["operatorId"] = operator_id
  29784. inputData["operatorName"] = operator_name
  29785. inputData["officeId"] = "001"
  29786. inputData["officeName"] = "血透室"
  29787. inputData["deviceType"] = ""
  29788. input["data"] = inputData
  29789. input["orgId"] = code
  29790. input["transType"] = "ec.query"
  29791. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  29792. input2["indata"] = input
  29793. bytesData, _ := json.Marshal(input2)
  29794. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  29795. if err != nil {
  29796. fmt.Println(err)
  29797. }
  29798. // 接收消息
  29799. _, receivedMessage, err := conn.ReadMessage()
  29800. if err != nil {
  29801. fmt.Println(err)
  29802. }
  29803. return "", string(receivedMessage)
  29804. }
  29805. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  29806. newArr = make([]string, 0)
  29807. for i := 0; i < len(arr); i++ {
  29808. repeat := false
  29809. for j := i + 1; j < len(arr); j++ {
  29810. if arr[i] == arr[j] {
  29811. repeat = true
  29812. break
  29813. }
  29814. }
  29815. if !repeat {
  29816. newArr = append(newArr, arr[i])
  29817. }
  29818. }
  29819. return
  29820. }
  29821. func getBirthdateAndAge(idNumber string) (string, int, error) {
  29822. if len(idNumber) != 18 {
  29823. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  29824. }
  29825. // 提取出生日期
  29826. year, err := strconv.Atoi(idNumber[6:10])
  29827. if err != nil {
  29828. return "", 0, err
  29829. }
  29830. month, err := strconv.Atoi(idNumber[10:12])
  29831. if err != nil {
  29832. return "", 0, err
  29833. }
  29834. day, err := strconv.Atoi(idNumber[12:14])
  29835. if err != nil {
  29836. return "", 0, err
  29837. }
  29838. // 格式化生日字符串
  29839. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  29840. birthdateFormatted := birthdate.Format("2006-01-02")
  29841. // 计算年龄
  29842. today := time.Now()
  29843. age := today.Year() - birthdate.Year()
  29844. if today.YearDay() < birthdate.YearDay() {
  29845. age--
  29846. }
  29847. return birthdateFormatted, age, nil
  29848. }