his_api_controller.go 1.2MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/base64"
  6. //"github.com/jung-kurt/gofpdf"
  7. //"github.com/tjfoc/gmsm/sm3"
  8. "math"
  9. //"crypto/x509/pkix"
  10. "encoding/json"
  11. "fmt"
  12. "gdyb/controllers"
  13. "gdyb/enums"
  14. "gdyb/models"
  15. "gdyb/service"
  16. "gdyb/utils"
  17. "github.com/astaxie/beego"
  18. "github.com/axgle/mahonia"
  19. "github.com/gorilla/websocket"
  20. "github.com/jinzhu/gorm"
  21. "github.com/shopspring/decimal"
  22. "io"
  23. "io/ioutil"
  24. //"math"
  25. "math/rand"
  26. "net/http"
  27. "net/url"
  28. "os"
  29. "path/filepath"
  30. "regexp"
  31. "strconv"
  32. "strings"
  33. "syscall"
  34. "time"
  35. "unsafe"
  36. "github.com/go-ole/go-ole/oleutil"
  37. )
  38. type HisApiController struct {
  39. controllers.BaseAuthAPIController
  40. }
  41. func HisManagerApiRegistRouters() {
  42. //挂号
  43. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  44. //上传就诊信息-上传明细-结算
  45. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  46. //查询
  47. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  48. //对总账
  49. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  50. //对明细
  51. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  52. //退费,退明细
  53. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  54. //退号
  55. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  56. //退明细
  57. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  58. //上传就诊信息-上传明细-预结算
  59. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  60. //beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  61. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  62. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  63. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  64. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  65. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  66. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  67. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  68. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  69. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  70. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  71. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  72. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  73. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  74. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  75. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  76. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  77. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  78. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  79. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  80. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  81. beego.Router("/api/check", &HisApiController{}, "get:Check")
  82. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  83. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  84. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  85. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  86. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  87. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  88. beego.Router("/api/3202b", &HisApiController{}, "get:Post3202b")
  89. beego.Router("/api/1608", &HisApiController{}, "get:Post1608")
  90. beego.Router("/api/5302", &HisApiController{}, "get:Post5302")
  91. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  92. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  93. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  94. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  95. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  96. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  97. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  98. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  99. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  100. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  101. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  102. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  103. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  104. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  105. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  106. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  107. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  108. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  109. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  110. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  111. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  112. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  113. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  114. beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  115. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  116. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  117. beego.Router("/api/3260", &HisApiController{}, "get:Get3260")
  118. beego.Router("/api/3261", &HisApiController{}, "get:Get3261")
  119. beego.Router("/api/3262", &HisApiController{}, "get:Get3262")
  120. beego.Router("/api/3263", &HisApiController{}, "get:Get3263")
  121. beego.Router("/api/3264", &HisApiController{}, "get:Get3264")
  122. beego.Router("/api/3265", &HisApiController{}, "get:Get3265")
  123. beego.Router("/api/3266", &HisApiController{}, "get:Get3266")
  124. beego.Router("/api/3267", &HisApiController{}, "get:Get3267")
  125. beego.Router("/api/3268", &HisApiController{}, "get:Get3268")
  126. beego.Router("/api/3269", &HisApiController{}, "get:Get3269")
  127. beego.Router("/api/3270", &HisApiController{}, "get:Get3270")
  128. beego.Router("/api/3271", &HisApiController{}, "get:Get3271")
  129. beego.Router("/api/3272", &HisApiController{}, "get:Get3272")
  130. beego.Router("/api/3273", &HisApiController{}, "get:Get3273")
  131. beego.Router("/api/3274", &HisApiController{}, "get:Get3274")
  132. beego.Router("/api/3275", &HisApiController{}, "get:Get3275")
  133. beego.Router("/api/3276", &HisApiController{}, "get:Get3276")
  134. beego.Router("/api/3277", &HisApiController{}, "get:Get3277")
  135. beego.Router("/api/comfirm/upload", &HisApiController{}, "get:Get4102")
  136. beego.Router("/api/batch/check_drug", &HisApiController{}, "get:Drugscheck")
  137. beego.Router("/api/batch/check_good", &HisApiController{}, "get:Goodcheck")
  138. beego.Router("/api/batch/check_project", &HisApiController{}, "get:Projectcheck")
  139. beego.Router("/api/querydata", &HisApiController{}, "get:Getquerydata")
  140. //beego.Router("/api/5267", &HisApiController{}, "get:Get5267")
  141. //beego.Router("/api/1312a", &HisApiController{}, "get:Get1312a")
  142. //beego.Router("/api/cancledia/get", &HisApiController{}, "get:CancleDia")
  143. beego.Router("/api/4105", &HisApiController{}, "get:Get4105")
  144. beego.Router("/api/4104", &HisApiController{}, "get:Get4104")
  145. beego.Router("/api/2406", &HisApiController{}, "get:Get2406")
  146. beego.Router("/api/2503", &HisApiController{}, "get:Get2503")
  147. beego.Router("/api/1318", &HisApiController{}, "get:Get1318")
  148. beego.Router("/api/readelebyface", &HisApiController{}, "get:ReadEleFace")
  149. beego.Router("/api/settlelist/get/batch", &HisApiController{}, "get:GetbatchSettleList")
  150. //库盘和变更
  151. beego.Router("/api/pc_bg", &HisApiController{}, "get:FJ3501AND3502")
  152. //删除库盘和变更
  153. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeletePCandBG")
  154. beego.Router("/api/delete_pc_bg", &HisApiController{}, "get:DeleteXSandBG")
  155. //药品变更
  156. beego.Router("/api/changedrug", &HisApiController{}, "get:ChangeDrug")
  157. }
  158. func (c *HisApiController) FJ3501AND3502() {
  159. ids := c.getString("ids")
  160. id_arr := strings.Split(ids, ",")
  161. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  162. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  163. //库盘
  164. for _, drug := range drugs {
  165. if drug.IsPc == 0 && drug.IsBg == 0 {
  166. var struct3501 models.Struct3501
  167. struct3501.OrgName = miConfig.OrgName
  168. struct3501.AccessKey = miConfig.AccessKey
  169. struct3501.RequestUrl = miConfig.Url
  170. struct3501.SecretKey = miConfig.SecretKey
  171. struct3501.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  172. struct3501.FixmedinsHilistId = miConfig.Code
  173. struct3501.FixmedinsHilistName = miConfig.OrgName
  174. struct3501.RxFlag = "0"
  175. struct3501.Invdate = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  176. struct3501.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  177. struct3501.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  178. struct3501.InvCnt = strconv.FormatInt(drug.StockMaxNumber, 10)
  179. struct3501.ExpyEnd = time.Unix(drug.ExpiryDate, 0).Format("2006-01-02 15:04:05")
  180. //todo 批次号规则需要在咨询下保健
  181. struct3501.FixmedinsBchno = ""
  182. struct3501.Memo = ""
  183. result1, result2, result3 := service.FJyb3501(struct3501)
  184. fmt.Println(result1)
  185. fmt.Println(result2)
  186. fmt.Println(result3)
  187. var struct3502 models.Struct3502
  188. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  189. struct3502.FixmedinsHilistId = miConfig.Code
  190. struct3502.FixmedinsHilistName = miConfig.OrgName
  191. struct3502.FixmedinsCode = miConfig.Code
  192. struct3502.RxFlag = "0"
  193. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  194. struct3502.OrgName = miConfig.OrgName
  195. struct3502.AccessKey = miConfig.AccessKey
  196. struct3502.RequestUrl = miConfig.Url
  197. struct3502.SecretKey = miConfig.SecretKey
  198. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  199. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  200. struct3502.InvChgType = "102"
  201. struct3502.FixmedinsBchno = ""
  202. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  203. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  204. result11, result22, result33 := service.FJyb3502(struct3502)
  205. fmt.Println(result11)
  206. fmt.Println(result22)
  207. fmt.Println(result33)
  208. }
  209. //变更
  210. if drug.IsPc == 1 && drug.IsBg == 0 {
  211. var struct3502 models.Struct3502
  212. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  213. struct3502.FixmedinsHilistId = miConfig.Code
  214. struct3502.FixmedinsHilistName = miConfig.OrgName
  215. struct3502.FixmedinsCode = miConfig.Code
  216. struct3502.RxFlag = "0"
  217. struct3502.InvChgTime = time.Unix(drug.Ctime, 0).Format("2006-01-02 15:04:05")
  218. struct3502.OrgName = miConfig.OrgName
  219. struct3502.AccessKey = miConfig.AccessKey
  220. struct3502.RequestUrl = miConfig.Url
  221. struct3502.SecretKey = miConfig.SecretKey
  222. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  223. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  224. struct3502.InvChgType = "102"
  225. struct3502.FixmedinsBchno = ""
  226. struct3502.Cnt = strconv.FormatInt(drug.WarehousingCount, 10)
  227. struct3502.Pric = fmt.Sprintf("%.2f", drug.BaseDrugLib.RetailPrice)
  228. result1, result2, result3 := service.FJyb3502(struct3502)
  229. fmt.Println(result1)
  230. fmt.Println(result2)
  231. fmt.Println(result3)
  232. }
  233. }
  234. }
  235. func (c *HisApiController) DeletePCandBG() {
  236. ids := c.getString("ids")
  237. id_arr := strings.Split(ids, ",")
  238. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  239. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  240. for _, item := range drugs {
  241. if item.IsPc == 1 && item.IsBg == 1 {
  242. var struct3507 models.Struct3507
  243. struct3507.FixmedinsBchno = ""
  244. struct3507.InvDataType = "1"
  245. struct3507.OrgName = miConfig.OrgName
  246. struct3507.AccessKey = miConfig.AccessKey
  247. struct3507.RequestUrl = miConfig.Url
  248. struct3507.SecretKey = miConfig.SecretKey
  249. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  250. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  251. service.FJyb3507(struct3507)
  252. var struct3507_2 models.Struct3507
  253. struct3507_2.OrgName = miConfig.OrgName
  254. struct3507_2.AccessKey = miConfig.AccessKey
  255. struct3507_2.RequestUrl = miConfig.Url
  256. struct3507_2.SecretKey = miConfig.SecretKey
  257. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  258. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  259. struct3507_2.FixmedinsBchno = ""
  260. struct3507_2.InvDataType = "2"
  261. service.FJyb3507(struct3507_2)
  262. }
  263. if item.IsPc == 1 && item.IsBg == 0 {
  264. var struct3507 models.Struct3507
  265. struct3507.OrgName = miConfig.OrgName
  266. struct3507.AccessKey = miConfig.AccessKey
  267. struct3507.RequestUrl = miConfig.Url
  268. struct3507.SecretKey = miConfig.SecretKey
  269. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  270. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  271. struct3507.FixmedinsBchno = ""
  272. struct3507.InvDataType = "1"
  273. service.FJyb3507(struct3507)
  274. }
  275. }
  276. }
  277. func (c *HisApiController) DeleteXSandBG() {
  278. ids := c.getString("ids")
  279. id_arr := strings.Split(ids, ",")
  280. drugs, _ := service.GetNewDrugWarehouseInfo(id_arr)
  281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  282. for _, item := range drugs {
  283. if item.is == 1 && item.IsBg == 1 {
  284. var struct3507 models.Struct3507
  285. struct3507.FixmedinsBchno = ""
  286. struct3507.InvDataType = "1"
  287. struct3507.OrgName = miConfig.OrgName
  288. struct3507.AccessKey = miConfig.AccessKey
  289. struct3507.RequestUrl = miConfig.Url
  290. struct3507.SecretKey = miConfig.SecretKey
  291. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  292. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  293. service.FJyb3507(struct3507)
  294. var struct3507_2 models.Struct3507
  295. struct3507_2.OrgName = miConfig.OrgName
  296. struct3507_2.AccessKey = miConfig.AccessKey
  297. struct3507_2.RequestUrl = miConfig.Url
  298. struct3507_2.SecretKey = miConfig.SecretKey
  299. struct3507_2.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  300. struct3507_2.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  301. struct3507_2.FixmedinsBchno = ""
  302. struct3507_2.InvDataType = "2"
  303. service.FJyb3507(struct3507_2)
  304. }
  305. if item.IsPc == 1 && item.IsBg == 0 {
  306. var struct3507 models.Struct3507
  307. struct3507.OrgName = miConfig.OrgName
  308. struct3507.AccessKey = miConfig.AccessKey
  309. struct3507.RequestUrl = miConfig.Url
  310. struct3507.SecretKey = miConfig.SecretKey
  311. struct3507.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  312. struct3507.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  313. struct3507.FixmedinsBchno = ""
  314. struct3507.InvDataType = "1"
  315. service.FJyb3507(struct3507)
  316. }
  317. }
  318. }
  319. func (c *HisApiController) ChangeDrug() {
  320. ids := c.getString("ids")
  321. id_arr := strings.Split(ids, ",")
  322. flows, _ := service.GetNewDrugFlowInfo(id_arr)
  323. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  324. for _, item := range flows {
  325. if item.ConsumableType == 3 { //3为自动出库 7为自动退库
  326. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  327. if prescription.OrderStatus == 2 { //已经结算
  328. //判断是否已经销售
  329. if item.IsSale == 1 { //是否已经销售,1是 0否
  330. //是否已经变更 1是 0否
  331. if item.IsChange == 0 { //没变更,进行变更操作
  332. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  333. }
  334. } else { //没销售,
  335. //进行商品销售接口
  336. SaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  337. if item.IsChange == 0 { //没变更,进行变更操作
  338. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  339. }
  340. }
  341. } else { //还没结算
  342. if item.IsChange == 0 { //没变更,进行变更操作
  343. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  344. }
  345. }
  346. } else if item.ConsumableType == 7 {
  347. prescription := service.GetHisPrescriptionByID(item.HisDoctorAdviceInfo.PrescriptionId)
  348. order := service.GetHisOrderByNumber(prescription.BatchNumber)
  349. if order.OrderStatus == 2 || order.OrderStatus == 1 { //已经结算
  350. //判断是否已经销售
  351. if item.IsSale == 1 { //是否已经销售,1是 0否
  352. //是否已经变更 1是 0否
  353. if item.IsChange == 0 { //没变更,进行变更操作
  354. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  355. }
  356. } else { //没销售,
  357. //进行商品销售退货接口
  358. CancleSaleStock(c.GetAdminUserInfo().CurrentOrgId, prescription, item.HisDoctorAdviceInfo, miConfig, "")
  359. if item.IsChange == 0 { //没变更,进行变更操作
  360. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  361. }
  362. }
  363. } else { //还没结算
  364. if item.IsChange == 0 { //没变更,进行变更操作
  365. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  366. }
  367. }
  368. } else { //其他方式
  369. if item.IsChange == 0 { //没变更,进行变更操作
  370. ChangeStock(item.Count, item.HisDoctorAdviceInfo, miConfig, "102")
  371. }
  372. }
  373. }
  374. }
  375. func ChangeStock(count int64, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  376. var struct3502 models.Struct3502
  377. struct3502.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  378. struct3502.FixmedinsHilistId = miConfig.Code
  379. struct3502.FixmedinsHilistName = miConfig.OrgName
  380. struct3502.FixmedinsCode = miConfig.Code
  381. struct3502.RxFlag = "0"
  382. struct3502.InvChgTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  383. struct3502.OrgName = miConfig.OrgName
  384. struct3502.AccessKey = miConfig.AccessKey
  385. struct3502.RequestUrl = miConfig.Url
  386. struct3502.SecretKey = miConfig.SecretKey
  387. struct3502.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. struct3502.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  389. struct3502.InvChgType = chgType
  390. struct3502.FixmedinsBchno = ""
  391. struct3502.Cnt = strconv.FormatInt(count, 10)
  392. struct3502.Pric = fmt.Sprintf("%.2f", drug.Price)
  393. result1, result2, result3 := service.FJyb3502(struct3502)
  394. fmt.Println(result1)
  395. fmt.Println(result2)
  396. fmt.Println(result3)
  397. }
  398. func SaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  399. var struct3505 models.Struct3505
  400. struct3505.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  401. struct3505.FixmedinsHilistId = miConfig.Code
  402. struct3505.FixmedinsHilistName = miConfig.OrgName
  403. struct3505.FixmedinsCode = miConfig.Code
  404. struct3505.FixmedinsBchno = ""
  405. roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  406. struct3505.PrscDrName = roles.UserName
  407. struct3505.PharName = ""
  408. struct3505.PharPracCertNo = ""
  409. order := service.GetHisOrderByNumber(pre.BatchNumber)
  410. struct3505.SetlId = order.SetlId
  411. struct3505.MdtrtSn = order.MdtrtId
  412. struct3505.ManuLotnum = ""
  413. struct3505.ManuDate = ""
  414. struct3505.ExpyEnd = ""
  415. struct3505.RxFlag = "0"
  416. struct3505.TrdnFlag = "1"
  417. struct3505.RtalDocno = order.Number
  418. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  419. struct3505.SelRetnCnt = strValue
  420. struct3505.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  421. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  422. struct3505.SelRetnOpterName = roles_two.UserName
  423. if order.IsMedicineInsurance == 1 {
  424. struct3505.MdtrtSetlType = "1"
  425. } else {
  426. struct3505.MdtrtSetlType = "2"
  427. }
  428. struct3505.OrgName = miConfig.OrgName
  429. struct3505.AccessKey = miConfig.AccessKey
  430. struct3505.RequestUrl = miConfig.Url
  431. struct3505.SecretKey = miConfig.SecretKey
  432. struct3505.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  433. struct3505.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  434. result1, result2, result3 := service.FJyb3505(struct3505)
  435. fmt.Println(result1)
  436. fmt.Println(result2)
  437. fmt.Println(result3)
  438. }
  439. func CancleSaleStock(org_id int64, pre models.HisPrescription, drug models.HisDoctorAdviceInfo, miConfig models.MedicalInsuranceOrgConfig, chgType string) {
  440. var struct3506 models.Struct3506
  441. struct3506.MedListCodg = drug.BaseDrugLib.MedicalInsuranceNumber
  442. struct3506.FixmedinsHilistId = miConfig.Code
  443. struct3506.FixmedinsHilistName = miConfig.OrgName
  444. struct3506.FixmedinsCode = miConfig.Code
  445. struct3506.FixmedinsBchno = ""
  446. order := service.GetHisOrderByNumber(pre.BatchNumber)
  447. //roles, _ := service.GetAdminUserInfoByID(org_id, pre.Creator)
  448. struct3506.ManuLotnum = ""
  449. struct3506.ManuDate = ""
  450. struct3506.MdtrtSn = order.MdtrtId
  451. struct3506.ExpyEnd = ""
  452. struct3506.RxFlag = "0"
  453. struct3506.TrdnFlag = "1"
  454. strValue := fmt.Sprintf("%.2f", drug.PrescribingNumber)
  455. struct3506.SelRetnCnt = strValue
  456. struct3506.SelRetnTime = time.Unix(drug.CreatedTime, 0).Format("2006-01-02 15:04:05")
  457. roles_two, _ := service.GetAdminUserInfoByID(org_id, order.Creator)
  458. struct3506.SelRetnOpterName = roles_two.UserName
  459. struct3506.OrgName = miConfig.OrgName
  460. struct3506.AccessKey = miConfig.AccessKey
  461. struct3506.RequestUrl = miConfig.Url
  462. struct3506.SecretKey = miConfig.SecretKey
  463. struct3506.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  464. struct3506.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  465. result1, result2, result3 := service.FJyb3506(struct3506)
  466. fmt.Println(result1)
  467. fmt.Println(result2)
  468. fmt.Println(result3)
  469. }
  470. func (c *HisApiController) Get1318() {
  471. adminUser := c.GetAdminUserInfo()
  472. admin_user_id, _ := c.GetInt64("admin_user_id")
  473. code := c.GetString("code")
  474. code = ""
  475. curRoles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  476. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  477. api := ""
  478. if miConfig.MdtrtareaAdmvs == "320921" {
  479. api = "http://192.168.2.3:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  480. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  481. } else {
  482. api = "http://192.168.5.251:9532/" + "jsyb/1318?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  483. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&h_code=" + code
  484. }
  485. resp, requestErr := http.Get(api)
  486. if requestErr != nil {
  487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  488. return
  489. }
  490. body, ioErr := ioutil.ReadAll(resp.Body)
  491. if ioErr != nil {
  492. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  494. return
  495. }
  496. var respJSON map[string]interface{}
  497. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  498. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  500. return
  501. }
  502. //var res Result2406
  503. /*respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  504. result, _ := json.Marshal(respJSON)
  505. if err := json.Unmarshal([]byte(result), &res); err != nil {
  506. utils.ErrorLog("解析失败:%v", err)
  507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  508. return
  509. }
  510. if res.Infcode == "0" {
  511. c.ServeSuccessJSON(map[string]interface{}{
  512. "result": "",
  513. })
  514. } else {
  515. c.ServeSuccessJSON(map[string]interface{}{
  516. "failed_code": -10,
  517. "msg": res.ErrMsg,
  518. })
  519. */return
  520. //}
  521. }
  522. func (c *HisApiController) Get2503() {
  523. adminUser := c.GetAdminUserInfo()
  524. admin_user_id, _ := c.GetInt64("admin_user_id")
  525. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  526. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  527. service.Gxyb2503(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.MdtrtareaAdmvs, miConfig.InsuplcAdmdvs, "", admin_user_id)
  528. }
  529. func (c *HisApiController) Get2406() {
  530. id, _ := c.GetInt64("id")
  531. record_time := c.GetString("record_time")
  532. his_patient_id, _ := c.GetInt64("his_patient_id")
  533. admin_user_id, _ := c.GetInt64("admin_user_id")
  534. diagnosis_id := c.GetString("diagnosis")
  535. timeLayout := "2006-01-02"
  536. loc, _ := time.LoadLocation("Local")
  537. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  538. if err != nil {
  539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  540. return
  541. }
  542. recordDateTime := theTime.Unix()
  543. adminUser := c.GetAdminUserInfo()
  544. diagnosis_ids := strings.Split(diagnosis_id, ",")
  545. var config []*models.HisXtDiagnoseConfig
  546. for _, item := range diagnosis_ids {
  547. id, _ := strconv.ParseInt(item, 10, 64)
  548. diagnosisConfig, _ := service.FindDiagnoseById(id)
  549. config = append(config, &diagnosisConfig)
  550. }
  551. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  552. fmt.Println(his_patient_id)
  553. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  554. //timestamp := time.Now().Unix()
  555. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  556. var patientPrescription models.HisPrescriptionInfo
  557. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  558. if patientPrescription.ID == 0 {
  559. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  560. }
  561. var res2 Result2406
  562. if miConfig.MdtrtareaAdmvs == "341203" {
  563. data := make(map[string]interface{})
  564. client := &http.Client{}
  565. data["psn_no"] = his.PsnNo
  566. data["mdtrt_id"] = his.Number
  567. data["operator"] = roles.UserName
  568. data["cert_no"] = his.IdCardNo
  569. data["org_name"] = miConfig.OrgName
  570. data["psn_name"] = his.Name
  571. data["ipt_otp_no"] = his.IptOtpNo
  572. data["ipt_psn_sp_flag_type"] = "0901"
  573. data["ipt_psn_sp_flag"] = "1"
  574. data["fixmedins_code"] = miConfig.Code
  575. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  576. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  577. data["url"] = miConfig.Url
  578. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  579. bytesData, _ := json.Marshal(data)
  580. var req *http.Request
  581. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  582. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  583. resp, _ := client.Do(req)
  584. defer resp.Body.Close()
  585. body, ioErr := ioutil.ReadAll(resp.Body)
  586. if ioErr != nil {
  587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  589. return
  590. }
  591. var respJSON map[string]interface{}
  592. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  595. return
  596. }
  597. status := respJSON["data"].(map[string]interface{})["status"].(string)
  598. if status == "0" {
  599. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  600. c.ServeSuccessJSON(map[string]interface{}{
  601. "failed_code": -10,
  602. "msg": err_msg,
  603. })
  604. return
  605. }
  606. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  607. userJSONBytes, _ := json.Marshal(respJSON)
  608. fmt.Println("log")
  609. fmt.Println(string(userJSONBytes))
  610. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  611. utils.ErrorLog("解析失败:%v", err)
  612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. }
  616. if res2.Infcode != 0 {
  617. adminUser := c.GetAdminUserInfo()
  618. errlog := &models.HisOrderError{
  619. UserOrgId: adminUser.CurrentOrgId,
  620. Ctime: time.Now().Unix(),
  621. Mtime: time.Now().Unix(),
  622. ErrMsg: res2.ErrMsg,
  623. Status: 1,
  624. PatientId: id,
  625. RecordTime: recordDateTime,
  626. Stage: 3,
  627. }
  628. service.CreateErrMsgLog(errlog)
  629. c.ServeSuccessJSON(map[string]interface{}{
  630. "failed_code": -10,
  631. "msg": res2.ErrMsg,
  632. })
  633. return
  634. } else {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "msg": "上传成功",
  637. })
  638. return
  639. }
  640. }
  641. func (c *HisApiController) Get4105() {
  642. }
  643. func (c *HisApiController) Post5302() {
  644. patient_id, _ := c.GetInt64("id")
  645. admin_user_id, _ := c.GetInt64("admin_user_id")
  646. p, _ := service.GetHisPatientById(patient_id)
  647. adminUser := c.GetAdminUserInfo()
  648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  649. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  650. service.Gxyb5302(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  651. }
  652. func (c *HisApiController) Get4104() {
  653. }
  654. type Output struct {
  655. CertNo string `json:"certno"`
  656. PsnName string `json:"psn_name"`
  657. CardNo string `json:"card_no"`
  658. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  659. CardSN string `json:"card_sn"`
  660. PsnCertType string `json:"psn_cert_type"`
  661. MdtrtCertNo string `json:"mdtrt_cert_no"`
  662. MdtrtCertType string `json:"mdtrt_cert_type"`
  663. QRCode string `json:"qrCode"`
  664. EcToken string `json:"ecToken"`
  665. }
  666. type AHResponse struct {
  667. Body AHBody `json:"body"`
  668. Code int `json:"code"`
  669. CSBCode int `json:"csbCode"`
  670. Message string `json:"message"`
  671. RequestID string `json:"requestId"`
  672. State struct{} `json:"state"`
  673. }
  674. type AHBody struct {
  675. ErrMsg string `json:"err_msg"`
  676. InfRefMsgID string `json:"inf_refmsgid"`
  677. InfCode int `json:"infcode"`
  678. Output struct {
  679. Result []struct {
  680. BasMednFlag string `json:"bas_medn_flag"`
  681. ChldMedcFlag string `json:"chld_medc_flag"`
  682. ChrgitmLv string `json:"chrgitm_lv"`
  683. Cnt float64 `json:"cnt"`
  684. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  685. DrtReimFlag string `json:"drt_reim_flag"`
  686. FeedetlSn string `json:"feedetl_sn"`
  687. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  688. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  689. InscpScpAmt float64 `json:"inscp_scp_amt"`
  690. ListSpItemFlag string `json:"list_sp_item_flag"`
  691. LmtUsedFlag string `json:"lmt_used_flag"`
  692. MedChrgitmType string `json:"med_chrgitm_type"`
  693. Memo string `json:"memo"`
  694. OverlmtAmt float64 `json:"overlmt_amt"`
  695. PreselfpayAmt float64 `json:"preselfpay_amt"`
  696. Pric float64 `json:"pric"`
  697. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  698. SelfpayProp float64 `json:"selfpay_prop"`
  699. } `json:"result"`
  700. } `json:"output"`
  701. }
  702. type Response struct {
  703. Output Output `json:"output"`
  704. Infcode int `json:"infcode"`
  705. InfRefMsgID string `json:"inf_refmsgid"`
  706. RefMsgTime string `json:"refmsg_time"`
  707. RespondTime string `json:"respond_time"`
  708. ErrMsg string `json:"err_msg"`
  709. WarnMsg string `json:"warn_msg"`
  710. SignType string `json:"signtype"`
  711. CAInfo string `json:"cainfo"`
  712. }
  713. func (c *HisApiController) Getquerydata() {
  714. query_type, _ := c.GetInt64("type")
  715. refd_setl_flag := c.GetString("refd_setl_flag")
  716. med_type := c.GetString("med_type")
  717. //admin_user_id,_ := c.GetInt64("admin_user_id")
  718. cert_no := c.GetString("cert_no")
  719. psn_no := c.GetString("psn_no")
  720. start_time := c.GetString("start_time")
  721. end_time := c.GetString("end_time")
  722. page, _ := c.GetInt64("page")
  723. limit, _ := c.GetInt64("limit")
  724. var bp models.BusinessParams5262
  725. bp.RefdSetlFlag = refd_setl_flag
  726. bp.MedType = med_type
  727. bp.Certno = cert_no
  728. bp.Psnno = psn_no
  729. bp.QBegntime = start_time
  730. bp.QEndtime = end_time
  731. if query_type == 1 { //本地
  732. Post5262(c, bp, page, limit)
  733. } else { //异地
  734. Post5267(c, bp, page, limit)
  735. }
  736. }
  737. func (c *HisApiController) Drugscheck() {
  738. admin_user_id, _ := c.GetInt64("admin_user_id")
  739. adminUser := c.GetAdminUserInfo()
  740. var queryResult []QueryResult
  741. drugs, _ := service.GetBatchDrugListtw(adminUser.CurrentOrgId)
  742. for _, item := range drugs {
  743. result := QueryResult{
  744. ID: item.ID,
  745. Name: item.DrugName,
  746. Code: item.MedicalInsuranceNumber,
  747. List_type_code: "101",
  748. }
  749. queryResult = append(queryResult, result)
  750. }
  751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  752. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  753. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  754. for _, item := range queryResult {
  755. 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)
  756. }
  757. }
  758. func (c *HisApiController) Goodcheck() {
  759. admin_user_id, _ := c.GetInt64("admin_user_id")
  760. adminUser := c.GetAdminUserInfo()
  761. var queryResult []QueryResult
  762. goods, _ := service.GetBatchGoodInformationListtwo(adminUser.CurrentOrgId)
  763. for _, item := range goods {
  764. result := QueryResult{
  765. ID: item.ID,
  766. Name: item.GoodName,
  767. Code: item.SocialSecurityDirectoryCode,
  768. List_type_code: "301",
  769. }
  770. queryResult = append(queryResult, result)
  771. }
  772. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  773. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  774. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  775. for _, item := range queryResult {
  776. 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)
  777. //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)
  778. }
  779. }
  780. func (c *HisApiController) Projectcheck() {
  781. admin_user_id, _ := c.GetInt64("admin_user_id")
  782. adminUser := c.GetAdminUserInfo()
  783. var queryResult []QueryResult
  784. projects, _ := service.GetBathchMyPorjecgListtwo(adminUser.CurrentOrgId)
  785. for _, item := range projects {
  786. result := QueryResult{
  787. ID: item.ID,
  788. Name: item.ProjectName,
  789. Code: item.MedicalCode,
  790. List_type_code: "201",
  791. }
  792. queryResult = append(queryResult, result)
  793. }
  794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  795. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  796. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  797. for _, item := range queryResult {
  798. 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)
  799. }
  800. }
  801. //func (c *HisApiController)CancleDia(){
  802. //
  803. // id, _ := c.GetInt64("id")
  804. // record_time := c.GetString("record_time")
  805. // his_patient_id, _ := c.GetInt64("his_patient_id")
  806. //
  807. // admin_user_id, _ := c.GetInt64("admin_user_id")
  808. //
  809. // diagnosis_id := c.GetString("diagnosis")
  810. // sick_type, _ := c.GetInt64("sick_type")
  811. // reg_type, _ := c.GetInt64("p_type")
  812. // begin_time := c.GetString("begin_time")
  813. // acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  814. //
  815. //
  816. // acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  817. //
  818. // fmt.Println(acct_used_flag)
  819. //
  820. //
  821. // timeLayout := "2006-01-02"
  822. // loc, _ := time.LoadLocation("Local")
  823. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  824. // if err != nil {
  825. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  826. // return
  827. // }
  828. // recordDateTime := theTime.Unix()
  829. // adminUser := c.GetAdminUserInfo()
  830. //
  831. //
  832. //
  833. //
  834. //
  835. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  836. // his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  837. // var patientPrescription models.HisPrescriptionInfo
  838. // patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  839. // if patientPrescription.ID == 0 {
  840. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  841. // }
  842. // //if patientPrescription.Do
  843. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  844. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  845. //
  846. // doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  847. //
  848. // diagnosis_ids := strings.Split(diagnosis_id, ",")
  849. //
  850. // var config []*models.HisXtDiagnoseConfig
  851. // for _, item := range diagnosis_ids {
  852. // id, _ := strconv.ParseInt(item, 10, 64)
  853. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  854. // config = append(config, &diagnosisConfig)
  855. // }
  856. //
  857. // sickConfig, _ := service.FindSickById(sick_type)
  858. //
  859. //
  860. // data := make(map[string]interface{})
  861. // client := &http.Client{}
  862. // data["psn_no"] = his.PsnNo
  863. // data["mdtrt_id"] = his.Number
  864. // data["doctor"] = roles.UserName
  865. // data["department"] = department.Name
  866. // data["org_name"] = miConfig.OrgName
  867. // data["med_type"] = strconv.FormatInt(reg_type, 10)
  868. // data["doctor_id"] = doctor_info.DoctorNumber
  869. // data["new_doctor_name"] = doctor_info.UserName
  870. // data["fixmedins_code"] = miConfig.Code
  871. // data["insuplc_admdvs"] = his.InsuplcAdmdvs
  872. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  873. // data["secret_key"] = miConfig.SecretKey
  874. // data["sick_code"] = sickConfig.CountryCode
  875. // data["sick_name"] = sickConfig.ClassName
  876. // data["url"] = miConfig.Url
  877. // data["ak"] = miConfig.AccessKey
  878. // data["begin_time"] = begin_time
  879. // data["cainfo"] = miConfig.Cainfo
  880. // data["is_vaild"] = "0"
  881. //
  882. // data["dept"] = strconv.FormatInt(department.ID, 10)
  883. // data["config"] = config
  884. // bytesData, _ := json.Marshal(data)
  885. //
  886. // var req *http.Request
  887. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203C", bytes.NewReader(bytesData))
  888. // resp, _ := client.Do(req)
  889. // defer resp.Body.Close()
  890. // body, ioErr := ioutil.ReadAll(resp.Body)
  891. // if ioErr != nil {
  892. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  894. // return
  895. // }
  896. // var respJSON map[string]interface{}
  897. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  898. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  900. // return
  901. // }
  902. //
  903. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  904. // userJSONBytes, _ := json.Marshal(respJSON)
  905. // fmt.Println("log")
  906. // fmt.Println(string(userJSONBytes))
  907. //
  908. // if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  909. // utils.ErrorLog("解析失败:%v", err)
  910. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  911. // return
  912. // }
  913. // res2.InfRefmsgid = ressix10265.InfRefmsgid
  914. // res2.Output = ressix10265.Output
  915. // res2.ErrMsg = ressix10265.ErrMsg
  916. // res2.Cainfo = ressix10265.Cainfo
  917. // res2.WarnMsg = ressix10265.WarnMsg
  918. // infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  919. // res2.Infcode = infocode
  920. //
  921. //}
  922. func (c *HisApiController) Get4102() {
  923. order_id, _ := c.GetInt64("order_id")
  924. admin_user_id, _ := c.GetInt64("admin_user_id")
  925. stas_type := c.GetString("stas_type")
  926. order, _ := service.GetHisOrderByIDTwo(order_id)
  927. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  928. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  929. var pp models.PublicParams
  930. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  931. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  932. pp.FixmedinsName = miConfig.OrgName
  933. pp.FixmedinsCode = miConfig.Code
  934. pp.RequestUrl = miConfig.Url
  935. pp.Cainfo = miConfig.Cainfo
  936. pp.SecretKey = miConfig.SecretKey
  937. pp.AccessKey = miConfig.AccessKey
  938. pp.OpterName = curRoles.UserName
  939. if miConfig.MdtrtareaAdmvs == "350500" {
  940. result, request, _ := service.Fjyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  941. //result, request := service.Jxyb4103(order.PsnNo,order.SetlId,pp)
  942. saveLog(result, request, "4102", "清单确认")
  943. var dat map[string]interface{}
  944. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  945. fmt.Println(dat)
  946. } else {
  947. fmt.Println(err)
  948. }
  949. var empty ResultFourteen
  950. userJSONBytes, _ := json.Marshal(dat)
  951. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  952. utils.ErrorLog("解析失败:%v", err)
  953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  954. return
  955. }
  956. if empty.Infcode == 0 {
  957. c.ServeSuccessJSON(map[string]interface{}{
  958. "msg": "确认成功",
  959. })
  960. return
  961. }
  962. } else {
  963. result, request := service.Jxyb4102(order.PsnNo, order.SetlId, pp, stas_type)
  964. result2, request2 := service.Jxyb4103(order.PsnNo, order.SetlId, pp)
  965. result3, request3 := service.Jxyb4105(pp)
  966. saveLog(result, request, "4102", "清单确认")
  967. saveLog(result2, request2, "4103", "清单确认")
  968. saveLog(result3, request3, "4105", "清单统计")
  969. var dat map[string]interface{}
  970. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  971. fmt.Println(dat)
  972. } else {
  973. fmt.Println(err)
  974. }
  975. var empty ResultFourteen
  976. userJSONBytes, _ := json.Marshal(dat)
  977. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  978. utils.ErrorLog("解析失败:%v", err)
  979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  980. return
  981. }
  982. if empty.Infcode == 0 {
  983. c.ServeSuccessJSON(map[string]interface{}{
  984. "msg": "确认成功",
  985. })
  986. return
  987. }
  988. }
  989. }
  990. // 对账权限查询
  991. func (c *HisApiController) Get3260() {
  992. admin_user_id, _ := c.GetInt64("admin_user_id")
  993. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  994. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  995. var api string
  996. var res models.JSResult3260
  997. if miConfig.MdtrtareaAdmvs == "320921" {
  998. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  999. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1000. } else {
  1001. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1002. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  1003. }
  1004. resp, requestErr := http.Get(api)
  1005. if requestErr != nil {
  1006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1007. return
  1008. }
  1009. body, ioErr := ioutil.ReadAll(resp.Body)
  1010. if ioErr != nil {
  1011. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. var respJSON map[string]interface{}
  1016. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1017. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1022. result, _ := json.Marshal(respJSON)
  1023. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1024. utils.ErrorLog("解析失败:%v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. if res.Infcode == "0" {
  1029. c.ServeSuccessJSON(map[string]interface{}{
  1030. "result": res.Output.Data,
  1031. })
  1032. } else {
  1033. c.ServeSuccessJSON(map[string]interface{}{
  1034. "failed_code": -10,
  1035. "msg": res.ErrMsg,
  1036. })
  1037. return
  1038. }
  1039. }
  1040. func (c *HisApiController) Get3261() {
  1041. admin_user_id, _ := c.GetInt64("admin_user_id")
  1042. //month := c.GetString("month")
  1043. startTime := c.GetString("start_time")
  1044. //endTime, _ := c.GetString("end_time")
  1045. times := strings.Split(startTime, "-")
  1046. stmt_mon := times[0] + times[1]
  1047. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1048. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1049. var api string
  1050. var res models.JSResult3261
  1051. //var res10265 Result5301For10265
  1052. if miConfig.MdtrtareaAdmvs == "320921" {
  1053. api = "http://192.168.2.3:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1054. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1055. } else {
  1056. api = "http://192.168.5.251:9532/" + "jsyb/3261?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  1057. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + stmt_mon
  1058. }
  1059. resp, requestErr := http.Get(api)
  1060. if requestErr != nil {
  1061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1062. return
  1063. }
  1064. body, ioErr := ioutil.ReadAll(resp.Body)
  1065. if ioErr != nil {
  1066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1068. return
  1069. }
  1070. var respJSON map[string]interface{}
  1071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1074. return
  1075. }
  1076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1077. result, _ := json.Marshal(respJSON)
  1078. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1079. utils.ErrorLog("解析失败:%v", err)
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1081. return
  1082. }
  1083. if res.Infcode == "0" {
  1084. c.ServeSuccessJSON(map[string]interface{}{
  1085. "result": res.Output,
  1086. })
  1087. } else {
  1088. c.ServeSuccessJSON(map[string]interface{}{
  1089. "failed_code": -10,
  1090. "msg": res.ErrMsg,
  1091. })
  1092. return
  1093. }
  1094. }
  1095. type TempFun struct {
  1096. FundKey string
  1097. FundCode string
  1098. }
  1099. func (c *HisApiController) Get3262() {
  1100. admin_user_id, _ := c.GetInt64("admin_user_id")
  1101. startTime := c.GetString("start_time")
  1102. endTime := c.GetString("end_time")
  1103. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1105. //timeLayout := "2006-01-02"
  1106. //loc, _ := time.LoadLocation("Local")
  1107. //var theStartTIme int64
  1108. //if len(startTime) > 0 {
  1109. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  1110. // if err != nil {
  1111. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1112. // return
  1113. // }
  1114. // theStartTIme = theTime.Unix()
  1115. //}
  1116. //var theEndtTIme int64
  1117. //if len(endTime) > 0 {
  1118. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
  1119. // if err != nil {
  1120. // utils.ErrorLog(err.Error())
  1121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1122. // return
  1123. // }
  1124. // theEndtTIme = theTime.Unix()
  1125. //}
  1126. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1127. datas_two, _ := service.GetOrderByTimeTentwo(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1128. for _, team := range datas {
  1129. fmt.Println(team.PsnTime)
  1130. for _, team_two := range datas_two {
  1131. fmt.Println(team_two.PsnTime)
  1132. if team.FundKey == team_two.FundKey {
  1133. fmt.Println(team_two.PsnTime)
  1134. team.PsnTime = team.PsnTime + team_two.PsnTime*2
  1135. fmt.Println(team.PsnTime)
  1136. }
  1137. }
  1138. }
  1139. fmt.Println("1111")
  1140. fmt.Println(datas)
  1141. fmt.Println("1111")
  1142. var twos []models.FixMonRecDetailFileInTwo
  1143. for _, team := range datas {
  1144. var two models.FixMonRecDetailFileInTwo
  1145. two.MedType = team.MedType
  1146. two.Insutype = team.Insutype
  1147. two.PsnType = team.PsnType
  1148. two.MedType = team.MedType
  1149. two.FixBlngAdmdvs = "999999"
  1150. two.InsuAdmdvs = "555555"
  1151. two.PsnTime = team.PsnTime
  1152. two.PsnCnt = team.PsnCnt
  1153. two.FundKey = team.FundKey
  1154. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1155. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1156. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1157. two.MedfeeSumAmt = ms
  1158. two.InscpAmt = ia
  1159. two.FundPaySumAmt = fps
  1160. twos = append(twos, two)
  1161. }
  1162. //startTime := c.GetString("start_time")
  1163. //endTime, _ := c.GetString("end_time")
  1164. times := strings.Split(startTime, "-")
  1165. stmt_mon := times[0] + times[1]
  1166. var funs []models.FundDetail
  1167. for _, item := range datas {
  1168. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1169. funs = append(funs, fun...)
  1170. }
  1171. var funInfos []models.Fund
  1172. //for _, item := range funs {
  1173. // var rf []models.FundInfo
  1174. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1175. // for _, subitem := range rf {
  1176. // var fund models.Fund
  1177. // fund.FundCode = subitem.FundPayType
  1178. // fund.FundName = subitem.FundPayTypeName
  1179. // fund.FundAmt = subitem.FundPayAmt
  1180. // fund.FundKey = item.FundKey
  1181. // fund.InsuAdmdvs = "555555"
  1182. // fund.FixBlngAdmdvs = "999999"
  1183. // funInfos = append(funInfos, fund)
  1184. // }
  1185. //}
  1186. var tempFuns []TempFun
  1187. for _, funInfo := range funInfos {
  1188. var tempFun TempFun
  1189. tempFun.FundKey = funInfo.FundKey
  1190. tempFun.FundCode = funInfo.FundCode
  1191. tempFuns = append(tempFuns, tempFun)
  1192. }
  1193. tempFuns = RemoveRepeatedFunElement(tempFuns)
  1194. fmt.Println(tempFuns)
  1195. var funInfosTwo []models.Fund
  1196. decimal.DivisionPrecision = 2
  1197. for _, item := range tempFuns {
  1198. var fund models.Fund
  1199. for _, subItem := range funInfos {
  1200. if item.FundKey == subItem.FundKey && item.FundCode == subItem.FundCode {
  1201. fund.FundKey = subItem.FundKey
  1202. fund.InsuAdmdvs = subItem.InsuAdmdvs
  1203. fund.FixBlngAdmdvs = subItem.FixBlngAdmdvs
  1204. fund.FundName = subItem.FundName
  1205. fund.FundCode = subItem.FundCode
  1206. fund.FundAmt, _ = decimal.NewFromFloat(fund.FundAmt).Add(decimal.NewFromFloat(subItem.FundAmt)).Float64()
  1207. }
  1208. }
  1209. funInfosTwo = append(funInfosTwo, fund)
  1210. }
  1211. fmt.Println("funInfosTwo")
  1212. fmt.Println(funInfosTwo)
  1213. var upld_btch string
  1214. var empty models.JSResultEmpty
  1215. data := make(map[string]interface{})
  1216. data["org_name"] = miConfig.OrgName
  1217. data["doctor"] = curRoles.UserName
  1218. data["doctor_name"] = curRoles.UserName
  1219. data["fixmedins_code"] = miConfig.Code
  1220. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1221. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1222. data["secret_key"] = miConfig.SecretKey
  1223. data["url"] = miConfig.Url
  1224. data["ak"] = miConfig.AccessKey
  1225. data["cainfo"] = miConfig.Cainfo
  1226. data["datas"] = twos
  1227. data["fund"] = funInfosTwo
  1228. fmt.Println(twos)
  1229. month := time.Unix(1557042972, 0).Format("1")
  1230. year := time.Now().Format("2006")
  1231. month = time.Now().Format("01")
  1232. day := time.Now().Format("02")
  1233. hour := time.Now().Format("15")
  1234. min := time.Now().Format("04")
  1235. sec := time.Now().Format("05")
  1236. fix_fill_date := year + month + day + hour + min + sec
  1237. data["fix_fill_dept"] = miConfig.OrgName
  1238. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1239. data["fix_fill_psn"] = curRoles.UserName
  1240. data["fix_fill_date"] = fix_fill_date
  1241. data["stmt_loc"] = "2"
  1242. data["setl_mon"] = stmt_mon
  1243. upld_btch = "0"
  1244. data["upld_btch"] = upld_btch
  1245. //fmt.Println(data)
  1246. client := &http.Client{}
  1247. bytesData, _ := json.Marshal(data)
  1248. var req *http.Request
  1249. if miConfig.MdtrtareaAdmvs == "320921" {
  1250. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1251. } else {
  1252. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3262", bytes.NewReader(bytesData))
  1253. }
  1254. resp, _ := client.Do(req)
  1255. defer resp.Body.Close()
  1256. body, ioErr := ioutil.ReadAll(resp.Body)
  1257. if ioErr != nil {
  1258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1260. }
  1261. var respJSON map[string]interface{}
  1262. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1265. }
  1266. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1267. //fmt.Println(respJSON)
  1268. result, _ := json.Marshal(respJSON)
  1269. //fmt.Println(result)
  1270. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1271. utils.ErrorLog("解析失败:%v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. }
  1274. if empty.Infcode != "0" {
  1275. c.ServeSuccessJSON(map[string]interface{}{
  1276. "failed_code": -10,
  1277. "msg": empty.ErrMsg,
  1278. })
  1279. return
  1280. } else {
  1281. c.ServeSuccessJSON(map[string]interface{}{
  1282. "msg": "上传成功",
  1283. })
  1284. return
  1285. }
  1286. }
  1287. func RemoveRepeatedFunElement(arr []TempFun) (newArr []TempFun) {
  1288. newArr = make([]TempFun, 0)
  1289. for i := 0; i < len(arr); i++ {
  1290. repeat := false
  1291. for j := i + 1; j < len(arr); j++ {
  1292. if arr[i].FundKey == arr[j].FundKey && arr[i].FundCode == arr[j].FundCode {
  1293. repeat = true
  1294. break
  1295. }
  1296. }
  1297. if !repeat {
  1298. newArr = append(newArr, arr[i])
  1299. }
  1300. }
  1301. return
  1302. }
  1303. func (c *HisApiController) Get3263() {
  1304. admin_user_id, _ := c.GetInt64("admin_user_id")
  1305. startTime := c.GetString("start_time")
  1306. //endTime, _ := c.GetString("end_time")
  1307. times := strings.Split(startTime, "-")
  1308. setl_mon := times[0] + times[1]
  1309. upld_btch := "0"
  1310. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1311. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1312. var result3263 models.JSResult3263
  1313. data := make(map[string]interface{})
  1314. data["org_name"] = miConfig.OrgName
  1315. data["doctor"] = curRoles.UserName
  1316. data["doctor_name"] = curRoles.UserName
  1317. data["fixmedins_code"] = miConfig.Code
  1318. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1319. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1320. data["secret_key"] = miConfig.SecretKey
  1321. data["url"] = miConfig.Url
  1322. data["ak"] = miConfig.AccessKey
  1323. data["cainfo"] = miConfig.Cainfo
  1324. data["setl_mon"] = setl_mon
  1325. data["stmt_loc"] = "2"
  1326. data["upld_btch"] = upld_btch
  1327. client := &http.Client{}
  1328. bytesData, _ := json.Marshal(data)
  1329. var req *http.Request
  1330. if miConfig.MdtrtareaAdmvs == "320921" {
  1331. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1332. } else {
  1333. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1334. }
  1335. resp, _ := client.Do(req)
  1336. defer resp.Body.Close()
  1337. body, ioErr := ioutil.ReadAll(resp.Body)
  1338. if ioErr != nil {
  1339. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1341. }
  1342. var respJSON map[string]interface{}
  1343. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1344. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1346. }
  1347. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1348. fmt.Println(respJSON)
  1349. result, _ := json.Marshal(respJSON)
  1350. fmt.Println(result)
  1351. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1352. utils.ErrorLog("解析失败:%v", err)
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1354. }
  1355. if result3263.Infcode != "0" {
  1356. c.ServeSuccessJSON(map[string]interface{}{
  1357. "failed_code": -10,
  1358. "msg": result3263.ErrMsg,
  1359. })
  1360. return
  1361. } else {
  1362. c.ServeSuccessJSON(map[string]interface{}{
  1363. "list": result3263.Output,
  1364. })
  1365. return
  1366. }
  1367. }
  1368. func (c *HisApiController) Get3264() {
  1369. admin_user_id, _ := c.GetInt64("admin_user_id")
  1370. startTime := c.GetString("start_time")
  1371. //endTime, _ := c.GetString("end_time")
  1372. times := strings.Split(startTime, "-")
  1373. setl_mon := times[0] + times[1]
  1374. upld_btch := "0"
  1375. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1376. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1377. //solidify_id := []
  1378. var result3263 models.JSResult3263
  1379. data := make(map[string]interface{})
  1380. data["org_name"] = miConfig.OrgName
  1381. data["doctor"] = curRoles.UserName
  1382. data["doctor_name"] = curRoles.UserName
  1383. data["fixmedins_code"] = miConfig.Code
  1384. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1385. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1386. data["secret_key"] = miConfig.SecretKey
  1387. data["url"] = miConfig.Url
  1388. data["ak"] = miConfig.AccessKey
  1389. data["cainfo"] = miConfig.Cainfo
  1390. data["setl_mon"] = setl_mon
  1391. data["stmt_loc"] = "2"
  1392. data["upld_btch"] = upld_btch
  1393. client := &http.Client{}
  1394. bytesData, _ := json.Marshal(data)
  1395. var req3263 *http.Request
  1396. if miConfig.MdtrtareaAdmvs == "320921" {
  1397. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1398. } else {
  1399. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData))
  1400. }
  1401. resp, _ := client.Do(req3263)
  1402. defer resp.Body.Close()
  1403. body, ioErr := ioutil.ReadAll(resp.Body)
  1404. if ioErr != nil {
  1405. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. }
  1408. var respJSON3263 map[string]interface{}
  1409. if err := json.Unmarshal([]byte(body), &respJSON3263); err != nil {
  1410. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1412. }
  1413. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1414. fmt.Println(respJSON3263)
  1415. result, _ := json.Marshal(respJSON3263)
  1416. fmt.Println(result)
  1417. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1418. utils.ErrorLog("解析失败:%v", err)
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1420. }
  1421. var ids []string
  1422. for _, item := range result3263.Output {
  1423. ids = append(ids, item.SolidifyID)
  1424. }
  1425. var empty models.JSResultEmpty
  1426. data2 := make(map[string]interface{})
  1427. data2["org_name"] = miConfig.OrgName
  1428. data2["doctor"] = curRoles.UserName
  1429. data2["doctor_name"] = curRoles.UserName
  1430. data2["fixmedins_code"] = miConfig.Code
  1431. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1432. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1433. data2["secret_key"] = miConfig.SecretKey
  1434. data2["url"] = miConfig.Url
  1435. data2["ak"] = miConfig.AccessKey
  1436. data2["cainfo"] = miConfig.Cainfo
  1437. data2["setl_mon"] = setl_mon
  1438. data2["stmt_loc"] = "2"
  1439. data2["upld_btch"] = upld_btch
  1440. data2["solidify_id"] = ids
  1441. client2 := &http.Client{}
  1442. bytesData2, _ := json.Marshal(data2)
  1443. var req *http.Request
  1444. if miConfig.MdtrtareaAdmvs == "320921" {
  1445. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1446. } else {
  1447. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3264", bytes.NewReader(bytesData2))
  1448. }
  1449. resp2, _ := client2.Do(req)
  1450. defer resp.Body.Close()
  1451. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1452. if ioErr2 != nil {
  1453. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. }
  1456. var respJSON map[string]interface{}
  1457. if err := json.Unmarshal([]byte(body2), &respJSON); err != nil {
  1458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1460. }
  1461. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  1462. fmt.Println(respJSON)
  1463. result2, _ := json.Marshal(respJSON)
  1464. fmt.Println(result2)
  1465. if err := json.Unmarshal([]byte(result2), &empty); err != nil {
  1466. utils.ErrorLog("解析失败:%v", err)
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. }
  1469. if empty.Infcode != "0" {
  1470. c.ServeSuccessJSON(map[string]interface{}{
  1471. "failed_code": -10,
  1472. "msg": empty.ErrMsg,
  1473. })
  1474. return
  1475. } else {
  1476. c.ServeSuccessJSON(map[string]interface{}{
  1477. "msg": "",
  1478. })
  1479. return
  1480. }
  1481. }
  1482. func (c *HisApiController) Get3265() {
  1483. admin_user_id, _ := c.GetInt64("admin_user_id")
  1484. startTime := c.GetString("start_time")
  1485. //endTime, _ := c.GetString("end_time")
  1486. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1487. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1488. times := strings.Split(startTime, "-")
  1489. setl_mon := times[0] + times[1]
  1490. var upld_btch string
  1491. upld_btch = "0"
  1492. //var empty models.JSResultEmpty
  1493. var result3265 models.JSResult3264
  1494. var result3263 models.JSResult3263
  1495. data2 := make(map[string]interface{})
  1496. data2["org_name"] = miConfig.OrgName
  1497. data2["doctor"] = curRoles.UserName
  1498. data2["doctor_name"] = curRoles.UserName
  1499. data2["fixmedins_code"] = miConfig.Code
  1500. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1501. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1502. data2["secret_key"] = miConfig.SecretKey
  1503. data2["url"] = miConfig.Url
  1504. data2["ak"] = miConfig.AccessKey
  1505. data2["cainfo"] = miConfig.Cainfo
  1506. data2["setl_mon"] = setl_mon
  1507. data2["stmt_loc"] = "2"
  1508. data2["upld_btch"] = upld_btch
  1509. client2 := &http.Client{}
  1510. bytesData2, _ := json.Marshal(data2)
  1511. var req3263 *http.Request
  1512. if miConfig.MdtrtareaAdmvs == "320921" {
  1513. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1514. } else {
  1515. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3263", bytes.NewReader(bytesData2))
  1516. }
  1517. resp2, _ := client2.Do(req3263)
  1518. defer resp2.Body.Close()
  1519. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1520. if ioErr2 != nil {
  1521. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1523. }
  1524. var respJSON3263 map[string]interface{}
  1525. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1526. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1528. }
  1529. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1530. fmt.Println(respJSON3263)
  1531. result2, _ := json.Marshal(respJSON3263)
  1532. fmt.Println(result2)
  1533. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1534. utils.ErrorLog("解析失败:%v", err)
  1535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1536. }
  1537. var ids []string
  1538. for _, item := range result3263.Output {
  1539. ids = append(ids, item.SolidifyID)
  1540. }
  1541. data := make(map[string]interface{})
  1542. data["org_name"] = miConfig.OrgName
  1543. data["doctor"] = curRoles.UserName
  1544. data["doctor_name"] = curRoles.UserName
  1545. data["fixmedins_code"] = miConfig.Code
  1546. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1547. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1548. data["secret_key"] = miConfig.SecretKey
  1549. data["url"] = miConfig.Url
  1550. data["ak"] = miConfig.AccessKey
  1551. data["cainfo"] = miConfig.Cainfo
  1552. data["setl_mon"] = setl_mon
  1553. data["solidify_id"] = ids
  1554. month := time.Unix(1557042972, 0).Format("1")
  1555. year := time.Now().Format("2006")
  1556. month = time.Now().Format("01")
  1557. day := time.Now().Format("02")
  1558. hour := time.Now().Format("15")
  1559. min := time.Now().Format("04")
  1560. sec := time.Now().Format("05")
  1561. fix_fill_date := year + month + day + hour + min + sec
  1562. data["fix_fill_dept"] = miConfig.OrgName
  1563. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1564. data["fix_fill_psn"] = curRoles.UserName
  1565. data["fix_fill_date"] = fix_fill_date
  1566. data["stmt_loc"] = "2"
  1567. data["upld_btch"] = upld_btch
  1568. client := &http.Client{}
  1569. bytesData, _ := json.Marshal(data)
  1570. var req *http.Request
  1571. if miConfig.MdtrtareaAdmvs == "320921" {
  1572. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1573. } else {
  1574. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3265", bytes.NewReader(bytesData))
  1575. }
  1576. resp, _ := client.Do(req)
  1577. defer resp.Body.Close()
  1578. body, ioErr := ioutil.ReadAll(resp.Body)
  1579. if ioErr != nil {
  1580. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1582. }
  1583. var respJSON map[string]interface{}
  1584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1587. }
  1588. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1589. fmt.Println(respJSON)
  1590. result, _ := json.Marshal(respJSON)
  1591. fmt.Println(result)
  1592. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. }
  1596. if result3265.Infcode != "0" {
  1597. c.ServeSuccessJSON(map[string]interface{}{
  1598. "failed_code": -10,
  1599. "msg": result3265.ErrMsg,
  1600. })
  1601. return
  1602. } else {
  1603. c.ServeSuccessJSON(map[string]interface{}{
  1604. "info": result3265.Output,
  1605. })
  1606. return
  1607. }
  1608. }
  1609. func (c *HisApiController) Get3266() {
  1610. admin_user_id, _ := c.GetInt64("admin_user_id")
  1611. startTime := c.GetString("start_time")
  1612. //endTime, _ := c.GetString("end_time")
  1613. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1614. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1615. times := strings.Split(startTime, "-")
  1616. stmt_mon := times[0] + times[1]
  1617. var upld_btch string
  1618. //var empty models.JSResultEmpty
  1619. var result3265 models.JSResult3264
  1620. data := make(map[string]interface{})
  1621. data["org_name"] = miConfig.OrgName
  1622. data["doctor"] = curRoles.UserName
  1623. data["doctor_name"] = curRoles.UserName
  1624. data["fixmedins_code"] = miConfig.Code
  1625. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1626. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1627. data["secret_key"] = miConfig.SecretKey
  1628. data["url"] = miConfig.Url
  1629. data["ak"] = miConfig.AccessKey
  1630. data["cainfo"] = miConfig.Cainfo
  1631. data["setl_mon"] = stmt_mon
  1632. month := time.Unix(1557042972, 0).Format("1")
  1633. year := time.Now().Format("2006")
  1634. month = time.Now().Format("01")
  1635. day := time.Now().Format("02")
  1636. hour := time.Now().Format("15")
  1637. min := time.Now().Format("04")
  1638. sec := time.Now().Format("05")
  1639. fix_fill_date := year + month + day + hour + min + sec
  1640. data["fix_fill_dept"] = miConfig.OrgName
  1641. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1642. data["fix_fill_psn"] = curRoles.UserName
  1643. data["fix_fill_date"] = fix_fill_date
  1644. data["stmt_loc"] = "2"
  1645. upld_btch = "0"
  1646. data["upld_btch"] = upld_btch
  1647. client := &http.Client{}
  1648. bytesData, _ := json.Marshal(data)
  1649. var req *http.Request
  1650. if miConfig.MdtrtareaAdmvs == "320921" {
  1651. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1652. } else {
  1653. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3266", bytes.NewReader(bytesData))
  1654. }
  1655. resp, _ := client.Do(req)
  1656. defer resp.Body.Close()
  1657. body, ioErr := ioutil.ReadAll(resp.Body)
  1658. if ioErr != nil {
  1659. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1661. }
  1662. var respJSON map[string]interface{}
  1663. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1664. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. }
  1667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1668. fmt.Println(respJSON)
  1669. result, _ := json.Marshal(respJSON)
  1670. fmt.Println(result)
  1671. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1672. utils.ErrorLog("解析失败:%v", err)
  1673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1674. }
  1675. if result3265.Infcode != "0" {
  1676. c.ServeSuccessJSON(map[string]interface{}{
  1677. "failed_code": -10,
  1678. "msg": result3265.ErrMsg,
  1679. })
  1680. return
  1681. } else {
  1682. c.ServeSuccessJSON(map[string]interface{}{
  1683. "info": result3265.Output,
  1684. })
  1685. return
  1686. }
  1687. }
  1688. func (c *HisApiController) Get3267() {
  1689. admin_user_id, _ := c.GetInt64("admin_user_id")
  1690. startTime := c.GetString("start_time")
  1691. //endTime, _ := c.GetString("end_time")
  1692. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1693. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1694. times := strings.Split(startTime, "-")
  1695. setl_mon := times[0] + times[1]
  1696. var upld_btch string
  1697. //var empty models.JSResultEmpty
  1698. var result3265 models.JSResult3264
  1699. upld_btch = "0"
  1700. data := make(map[string]interface{})
  1701. data["org_name"] = miConfig.OrgName
  1702. data["doctor"] = curRoles.UserName
  1703. data["doctor_name"] = curRoles.UserName
  1704. data["fixmedins_code"] = miConfig.Code
  1705. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1706. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1707. data["secret_key"] = miConfig.SecretKey
  1708. data["url"] = miConfig.Url
  1709. data["ak"] = miConfig.AccessKey
  1710. data["cainfo"] = miConfig.Cainfo
  1711. data["setl_mon"] = setl_mon
  1712. data["stmt_loc"] = "2"
  1713. data["upld_btch"] = upld_btch
  1714. client := &http.Client{}
  1715. bytesData, _ := json.Marshal(data)
  1716. var req *http.Request
  1717. if miConfig.MdtrtareaAdmvs == "320921" {
  1718. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1719. } else {
  1720. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3267", bytes.NewReader(bytesData))
  1721. }
  1722. resp, _ := client.Do(req)
  1723. defer resp.Body.Close()
  1724. body, ioErr := ioutil.ReadAll(resp.Body)
  1725. if ioErr != nil {
  1726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1728. }
  1729. var respJSON map[string]interface{}
  1730. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1733. }
  1734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1735. fmt.Println(respJSON)
  1736. result, _ := json.Marshal(respJSON)
  1737. fmt.Println(result)
  1738. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  1739. utils.ErrorLog("解析失败:%v", err)
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1741. }
  1742. if result3265.Infcode != "0" {
  1743. c.ServeSuccessJSON(map[string]interface{}{
  1744. "failed_code": -10,
  1745. "msg": result3265.ErrMsg,
  1746. })
  1747. return
  1748. } else {
  1749. c.ServeSuccessJSON(map[string]interface{}{
  1750. "info": result3265.Output.Data,
  1751. })
  1752. return
  1753. }
  1754. }
  1755. func (c *HisApiController) Get3268() {
  1756. admin_user_id, _ := c.GetInt64("admin_user_id")
  1757. startTime := c.GetString("start_time")
  1758. endTime := c.GetString("end_time")
  1759. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1760. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1761. times := strings.Split(startTime, "-")
  1762. setl_mon := times[0] + times[1]
  1763. datas, _ := service.GetOrderByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId)
  1764. var twos []models.FixMonRecDetailFileInTwo
  1765. var funs []models.FundDetail
  1766. for _, item := range datas {
  1767. fun, _ := service.GetOrderDetailByTimeTen(startTime, endTime, c.GetAdminUserInfo().CurrentOrgId, item.FundKey)
  1768. funs = append(funs, fun...)
  1769. }
  1770. var funInfos []models.Fund
  1771. //for _, item := range funs {
  1772. // var rf []models.FundInfo
  1773. // json.Unmarshal([]byte(item.SetlDetail), &rf)
  1774. // for _, subitem := range rf {
  1775. // var fund models.Fund
  1776. // fund.FundCode = subitem.FundPayType
  1777. // fund.FundName = subitem.FundPayTypeName
  1778. // fund.FundAmt = subitem.FundPayAmt
  1779. // fund.FundKey = item.FundKey
  1780. // fund.InsuAdmdvs = "555555"
  1781. // fund.FixBlngAdmdvs = miConfig.MdtrtareaAdmvs
  1782. // funInfos = append(funInfos, fund)
  1783. // }
  1784. //}
  1785. for _, team := range datas {
  1786. var two models.FixMonRecDetailFileInTwo
  1787. two.SetlDate = time.Now().Format("2006-01-02")
  1788. two.MedType = team.MedType
  1789. two.Insutype = team.Insutype
  1790. two.PsnType = team.PsnType
  1791. two.MedType = team.MedType
  1792. two.FixBlngAdmdvs = team.FixBlngAdmdvs
  1793. two.InsuAdmdvs = team.InsuAdmdvs
  1794. two.PsnTime = team.PsnTime
  1795. two.PsnCnt = team.PsnCnt
  1796. two.FundKey = team.FundKey
  1797. ms, _ := strconv.ParseFloat(team.Sumamt, 64)
  1798. fps, _ := strconv.ParseFloat(team.Fund, 64)
  1799. ia, _ := strconv.ParseFloat(team.Amt, 64)
  1800. two.MedfeeSumAmt = ms
  1801. two.InscpAmt = ia
  1802. two.FundPaySumAmt = fps
  1803. twos = append(twos, two)
  1804. }
  1805. var upld_btch string
  1806. upld_btch = "0"
  1807. var empty models.JSResultEmpty
  1808. data := make(map[string]interface{})
  1809. data["org_name"] = miConfig.OrgName
  1810. data["doctor"] = curRoles.UserName
  1811. data["doctor_name"] = curRoles.UserName
  1812. data["fixmedins_code"] = miConfig.Code
  1813. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1814. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1815. data["secret_key"] = miConfig.SecretKey
  1816. data["url"] = miConfig.Url
  1817. data["ak"] = miConfig.AccessKey
  1818. data["cainfo"] = miConfig.Cainfo
  1819. data["datas"] = twos
  1820. data["fund"] = funInfos
  1821. data["setl_mon"] = setl_mon
  1822. month := time.Unix(1557042972, 0).Format("1")
  1823. year := time.Now().Format("2006")
  1824. month = time.Now().Format("01")
  1825. day := time.Now().Format("02")
  1826. hour := time.Now().Format("15")
  1827. min := time.Now().Format("04")
  1828. sec := time.Now().Format("05")
  1829. fix_fill_date := year + month + day + hour + min + sec
  1830. data["fix_fill_dept"] = miConfig.OrgName
  1831. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  1832. data["fix_fill_psn"] = curRoles.UserName
  1833. data["fix_fill_date"] = fix_fill_date
  1834. data["stmt_loc"] = "2"
  1835. data["upld_btch"] = upld_btch
  1836. client := &http.Client{}
  1837. bytesData, _ := json.Marshal(data)
  1838. var req *http.Request
  1839. if miConfig.MdtrtareaAdmvs == "320921" {
  1840. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1841. } else {
  1842. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3268", bytes.NewReader(bytesData))
  1843. }
  1844. resp, _ := client.Do(req)
  1845. defer resp.Body.Close()
  1846. body, ioErr := ioutil.ReadAll(resp.Body)
  1847. if ioErr != nil {
  1848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1850. }
  1851. var respJSON map[string]interface{}
  1852. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1855. }
  1856. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1857. fmt.Println(respJSON)
  1858. result, _ := json.Marshal(respJSON)
  1859. fmt.Println(result)
  1860. if err := json.Unmarshal([]byte(result), &empty); err != nil {
  1861. utils.ErrorLog("解析失败:%v", err)
  1862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1863. }
  1864. if empty.Infcode != "0" {
  1865. c.ServeSuccessJSON(map[string]interface{}{
  1866. "failed_code": -10,
  1867. "msg": empty.ErrMsg,
  1868. })
  1869. return
  1870. } else {
  1871. c.ServeSuccessJSON(map[string]interface{}{
  1872. "msg": "上传成功",
  1873. })
  1874. return
  1875. }
  1876. }
  1877. func (c *HisApiController) Get3269() {
  1878. admin_user_id, _ := c.GetInt64("admin_user_id")
  1879. startTime := c.GetString("start_time")
  1880. //endTime, _ := c.GetString("end_time")
  1881. times := strings.Split(startTime, "-")
  1882. setl_mon := times[0] + times[1]
  1883. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1884. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1885. var result3263 models.JSResult3263
  1886. data := make(map[string]interface{})
  1887. data["org_name"] = miConfig.OrgName
  1888. data["doctor"] = curRoles.UserName
  1889. data["doctor_name"] = curRoles.UserName
  1890. data["fixmedins_code"] = miConfig.Code
  1891. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1892. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1893. data["secret_key"] = miConfig.SecretKey
  1894. data["url"] = miConfig.Url
  1895. data["ak"] = miConfig.AccessKey
  1896. data["cainfo"] = miConfig.Cainfo
  1897. data["setl_mon"] = setl_mon
  1898. data["stmt_loc"] = "2"
  1899. client := &http.Client{}
  1900. bytesData, _ := json.Marshal(data)
  1901. var req *http.Request
  1902. if miConfig.MdtrtareaAdmvs == "320921" {
  1903. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1904. } else {
  1905. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData))
  1906. }
  1907. resp, _ := client.Do(req)
  1908. defer resp.Body.Close()
  1909. body, ioErr := ioutil.ReadAll(resp.Body)
  1910. if ioErr != nil {
  1911. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1913. }
  1914. var respJSON map[string]interface{}
  1915. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1918. }
  1919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1920. fmt.Println(respJSON)
  1921. result, _ := json.Marshal(respJSON)
  1922. fmt.Println(result)
  1923. if err := json.Unmarshal([]byte(result), &result3263); err != nil {
  1924. utils.ErrorLog("解析失败:%v", err)
  1925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1926. }
  1927. if result3263.Infcode != "0" {
  1928. c.ServeSuccessJSON(map[string]interface{}{
  1929. "failed_code": -10,
  1930. "msg": result3263.ErrMsg,
  1931. })
  1932. return
  1933. } else {
  1934. c.ServeSuccessJSON(map[string]interface{}{
  1935. "msg": "上传成功",
  1936. })
  1937. return
  1938. }
  1939. }
  1940. func (c *HisApiController) Get3270() {
  1941. admin_user_id, _ := c.GetInt64("admin_user_id")
  1942. startTime := c.GetString("start_time")
  1943. //endTime, _ := c.GetString("end_time")
  1944. times := strings.Split(startTime, "-")
  1945. setl_mon := times[0] + times[1]
  1946. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1947. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1948. var result3263 models.JSResult3263
  1949. data2 := make(map[string]interface{})
  1950. data2["org_name"] = miConfig.OrgName
  1951. data2["doctor"] = curRoles.UserName
  1952. data2["doctor_name"] = curRoles.UserName
  1953. data2["fixmedins_code"] = miConfig.Code
  1954. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1955. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1956. data2["secret_key"] = miConfig.SecretKey
  1957. data2["url"] = miConfig.Url
  1958. data2["ak"] = miConfig.AccessKey
  1959. data2["cainfo"] = miConfig.Cainfo
  1960. data2["setl_mon"] = setl_mon
  1961. data2["stmt_loc"] = "2"
  1962. client2 := &http.Client{}
  1963. bytesData2, _ := json.Marshal(data2)
  1964. var req3263 *http.Request
  1965. if miConfig.MdtrtareaAdmvs == "320921" {
  1966. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1967. } else {
  1968. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  1969. }
  1970. resp2, _ := client2.Do(req3263)
  1971. defer resp2.Body.Close()
  1972. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  1973. if ioErr2 != nil {
  1974. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1976. }
  1977. var respJSON3263 map[string]interface{}
  1978. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  1979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1981. }
  1982. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1983. fmt.Println(respJSON3263)
  1984. result2, _ := json.Marshal(respJSON3263)
  1985. fmt.Println(result2)
  1986. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  1987. utils.ErrorLog("解析失败:%v", err)
  1988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1989. }
  1990. var ids []string
  1991. for _, item := range result3263.Output {
  1992. ids = append(ids, item.SolidifyID)
  1993. }
  1994. var result3264 models.JSResult3264
  1995. data := make(map[string]interface{})
  1996. data["org_name"] = miConfig.OrgName
  1997. data["doctor"] = curRoles.UserName
  1998. data["doctor_name"] = curRoles.UserName
  1999. data["fixmedins_code"] = miConfig.Code
  2000. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2001. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2002. data["secret_key"] = miConfig.SecretKey
  2003. data["url"] = miConfig.Url
  2004. data["ak"] = miConfig.AccessKey
  2005. data["cainfo"] = miConfig.Cainfo
  2006. data["setl_mon"] = setl_mon
  2007. data["stmt_loc"] = "2"
  2008. data["solidify_id"] = ids
  2009. client := &http.Client{}
  2010. bytesData, _ := json.Marshal(data)
  2011. var req *http.Request
  2012. if miConfig.MdtrtareaAdmvs == "320921" {
  2013. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2014. } else {
  2015. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3270", bytes.NewReader(bytesData))
  2016. }
  2017. resp, _ := client.Do(req)
  2018. defer resp.Body.Close()
  2019. body, ioErr := ioutil.ReadAll(resp.Body)
  2020. if ioErr != nil {
  2021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2023. }
  2024. var respJSON map[string]interface{}
  2025. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2026. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2028. }
  2029. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2030. fmt.Println(respJSON)
  2031. result, _ := json.Marshal(respJSON)
  2032. fmt.Println(result)
  2033. if err := json.Unmarshal([]byte(result), &result3264); err != nil {
  2034. utils.ErrorLog("解析失败:%v", err)
  2035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2036. }
  2037. if result3264.Infcode != "0" {
  2038. c.ServeSuccessJSON(map[string]interface{}{
  2039. "failed_code": -10,
  2040. "msg": result3264.ErrMsg,
  2041. })
  2042. return
  2043. } else {
  2044. c.ServeSuccessJSON(map[string]interface{}{
  2045. "info": result3264.Output,
  2046. })
  2047. return
  2048. }
  2049. }
  2050. func (c *HisApiController) Get3271() {
  2051. admin_user_id, _ := c.GetInt64("admin_user_id")
  2052. startTime := c.GetString("start_time")
  2053. //endTime, _ := c.GetString("end_time")
  2054. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2055. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2056. times := strings.Split(startTime, "-")
  2057. setl_mon := times[0] + times[1]
  2058. //var empty models.JSResultEmpty
  2059. var result3265 models.JSResult3264
  2060. var result3263 models.JSResult3263
  2061. data2 := make(map[string]interface{})
  2062. data2["org_name"] = miConfig.OrgName
  2063. data2["doctor"] = curRoles.UserName
  2064. data2["doctor_name"] = curRoles.UserName
  2065. data2["fixmedins_code"] = miConfig.Code
  2066. data2["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2067. data2["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2068. data2["secret_key"] = miConfig.SecretKey
  2069. data2["url"] = miConfig.Url
  2070. data2["ak"] = miConfig.AccessKey
  2071. data2["cainfo"] = miConfig.Cainfo
  2072. data2["setl_mon"] = setl_mon
  2073. data2["stmt_loc"] = "2"
  2074. client2 := &http.Client{}
  2075. bytesData2, _ := json.Marshal(data2)
  2076. var req3263 *http.Request
  2077. if miConfig.MdtrtareaAdmvs == "320921" {
  2078. req3263, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2079. } else {
  2080. req3263, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3269", bytes.NewReader(bytesData2))
  2081. }
  2082. resp2, _ := client2.Do(req3263)
  2083. defer resp2.Body.Close()
  2084. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  2085. if ioErr2 != nil {
  2086. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  2087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2088. }
  2089. var respJSON3263 map[string]interface{}
  2090. if err := json.Unmarshal([]byte(body2), &respJSON3263); err != nil {
  2091. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2093. }
  2094. respJSON3263 = respJSON3263["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2095. fmt.Println(respJSON3263)
  2096. result2, _ := json.Marshal(respJSON3263)
  2097. fmt.Println(result2)
  2098. if err := json.Unmarshal([]byte(result2), &result3263); err != nil {
  2099. utils.ErrorLog("解析失败:%v", err)
  2100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2101. }
  2102. var ids []string
  2103. for _, item := range result3263.Output {
  2104. ids = append(ids, item.SolidifyID)
  2105. }
  2106. data := make(map[string]interface{})
  2107. data["org_name"] = miConfig.OrgName
  2108. data["doctor"] = curRoles.UserName
  2109. data["doctor_name"] = curRoles.UserName
  2110. data["fixmedins_code"] = miConfig.Code
  2111. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2112. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2113. data["secret_key"] = miConfig.SecretKey
  2114. data["url"] = miConfig.Url
  2115. data["ak"] = miConfig.AccessKey
  2116. data["cainfo"] = miConfig.Cainfo
  2117. data["setl_mon"] = setl_mon
  2118. data["solidify_id"] = ids
  2119. month := time.Unix(1557042972, 0).Format("1")
  2120. year := time.Now().Format("2006")
  2121. month = time.Now().Format("01")
  2122. day := time.Now().Format("02")
  2123. hour := time.Now().Format("15")
  2124. min := time.Now().Format("04")
  2125. sec := time.Now().Format("05")
  2126. fix_fill_date := year + month + day + hour + min + sec
  2127. data["fix_fill_dept"] = miConfig.OrgName
  2128. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2129. data["fix_fill_psn"] = curRoles.UserName
  2130. data["fix_fill_date"] = fix_fill_date
  2131. data["stmt_loc"] = "2"
  2132. client := &http.Client{}
  2133. bytesData, _ := json.Marshal(data)
  2134. var req *http.Request
  2135. if miConfig.MdtrtareaAdmvs == "320921" {
  2136. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2137. } else {
  2138. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3271", bytes.NewReader(bytesData))
  2139. }
  2140. resp, _ := client.Do(req)
  2141. defer resp.Body.Close()
  2142. body, ioErr := ioutil.ReadAll(resp.Body)
  2143. if ioErr != nil {
  2144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2146. }
  2147. var respJSON map[string]interface{}
  2148. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2149. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2151. }
  2152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2153. fmt.Println(respJSON)
  2154. result, _ := json.Marshal(respJSON)
  2155. fmt.Println(result)
  2156. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2157. utils.ErrorLog("解析失败:%v", err)
  2158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2159. }
  2160. if result3265.Infcode != "0" {
  2161. c.ServeSuccessJSON(map[string]interface{}{
  2162. "failed_code": -10,
  2163. "msg": result3265.ErrMsg,
  2164. })
  2165. return
  2166. } else {
  2167. c.ServeSuccessJSON(map[string]interface{}{
  2168. "info": result3265.Output.Data,
  2169. })
  2170. return
  2171. }
  2172. }
  2173. func (c *HisApiController) Get3272() {
  2174. admin_user_id, _ := c.GetInt64("admin_user_id")
  2175. startTime := c.GetString("start_time")
  2176. //endTime, _ := c.GetString("end_time")
  2177. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2178. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2179. times := strings.Split(startTime, "-")
  2180. setl_mon := times[0] + times[1]
  2181. var upld_btch string
  2182. //var empty models.JSResultEmpty
  2183. var result3265 models.JSResult3264
  2184. data := make(map[string]interface{})
  2185. data["org_name"] = miConfig.OrgName
  2186. data["doctor"] = curRoles.UserName
  2187. data["doctor_name"] = curRoles.UserName
  2188. data["fixmedins_code"] = miConfig.Code
  2189. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2190. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2191. data["secret_key"] = miConfig.SecretKey
  2192. data["url"] = miConfig.Url
  2193. data["ak"] = miConfig.AccessKey
  2194. data["cainfo"] = miConfig.Cainfo
  2195. data["setl_mon"] = setl_mon
  2196. month := time.Unix(1557042972, 0).Format("1")
  2197. year := time.Now().Format("2006")
  2198. month = time.Now().Format("01")
  2199. day := time.Now().Format("02")
  2200. hour := time.Now().Format("15")
  2201. min := time.Now().Format("04")
  2202. sec := time.Now().Format("05")
  2203. fix_fill_date := year + month + day + hour + min + sec
  2204. data["fix_fill_dept"] = miConfig.OrgName
  2205. data["fix_fill_psn_id"] = strconv.FormatInt(curRoles.AdminUserId, 10)
  2206. data["fix_fill_psn"] = curRoles.UserName
  2207. data["fix_fill_date"] = fix_fill_date
  2208. data["stmt_loc"] = "2"
  2209. data["upld_btch"] = upld_btch
  2210. client := &http.Client{}
  2211. bytesData, _ := json.Marshal(data)
  2212. var req *http.Request
  2213. if miConfig.MdtrtareaAdmvs == "320921" {
  2214. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2215. } else {
  2216. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3272", bytes.NewReader(bytesData))
  2217. }
  2218. resp, _ := client.Do(req)
  2219. defer resp.Body.Close()
  2220. body, ioErr := ioutil.ReadAll(resp.Body)
  2221. if ioErr != nil {
  2222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2224. }
  2225. var respJSON map[string]interface{}
  2226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2229. }
  2230. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2231. fmt.Println(respJSON)
  2232. result, _ := json.Marshal(respJSON)
  2233. fmt.Println(result)
  2234. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2235. utils.ErrorLog("解析失败:%v", err)
  2236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2237. }
  2238. if result3265.Infcode != "0" {
  2239. c.ServeSuccessJSON(map[string]interface{}{
  2240. "failed_code": -10,
  2241. "msg": result3265.ErrMsg,
  2242. })
  2243. return
  2244. } else {
  2245. c.ServeSuccessJSON(map[string]interface{}{
  2246. "info": result3265.Output,
  2247. })
  2248. return
  2249. }
  2250. }
  2251. func (c *HisApiController) Get3273() {
  2252. admin_user_id, _ := c.GetInt64("admin_user_id")
  2253. startTime := c.GetString("start_time")
  2254. //endTime, _ := c.GetString("end_time")
  2255. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2256. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2257. times := strings.Split(startTime, "-")
  2258. setl_mon := times[0] + times[1]
  2259. var result3265 models.JSResult3264
  2260. data := make(map[string]interface{})
  2261. data["org_name"] = miConfig.OrgName
  2262. data["doctor"] = curRoles.UserName
  2263. data["doctor_name"] = curRoles.UserName
  2264. data["fixmedins_code"] = miConfig.Code
  2265. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2266. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2267. data["secret_key"] = miConfig.SecretKey
  2268. data["url"] = miConfig.Url
  2269. data["ak"] = miConfig.AccessKey
  2270. data["cainfo"] = miConfig.Cainfo
  2271. data["setl_mon"] = setl_mon
  2272. data["stmt_loc"] = "2"
  2273. client := &http.Client{}
  2274. bytesData, _ := json.Marshal(data)
  2275. var req *http.Request
  2276. if miConfig.MdtrtareaAdmvs == "320921" {
  2277. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2278. } else {
  2279. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3273", bytes.NewReader(bytesData))
  2280. }
  2281. resp, _ := client.Do(req)
  2282. defer resp.Body.Close()
  2283. body, ioErr := ioutil.ReadAll(resp.Body)
  2284. if ioErr != nil {
  2285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2287. }
  2288. var respJSON map[string]interface{}
  2289. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2290. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2292. }
  2293. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2294. fmt.Println(respJSON)
  2295. result, _ := json.Marshal(respJSON)
  2296. fmt.Println(result)
  2297. if err := json.Unmarshal([]byte(result), &result3265); err != nil {
  2298. utils.ErrorLog("解析失败:%v", err)
  2299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2300. }
  2301. if result3265.Infcode != "0" {
  2302. c.ServeSuccessJSON(map[string]interface{}{
  2303. "failed_code": -10,
  2304. "msg": result3265.ErrMsg,
  2305. })
  2306. return
  2307. } else {
  2308. c.ServeSuccessJSON(map[string]interface{}{
  2309. "info": result3265.Output.Data,
  2310. })
  2311. return
  2312. }
  2313. }
  2314. func (c *HisApiController) Get3274() {
  2315. //if miConfig.MdtrtareaAdmvs == "320921" {
  2316. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2317. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2318. // "&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
  2319. //
  2320. //} else {
  2321. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2322. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2323. // "&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
  2324. //
  2325. //}
  2326. }
  2327. func (c *HisApiController) Get3275() {
  2328. //if miConfig.MdtrtareaAdmvs == "320921" {
  2329. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2330. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2331. // "&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
  2332. //
  2333. //} else {
  2334. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  2335. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  2336. // "&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
  2337. //
  2338. //}
  2339. }
  2340. func (c *HisApiController) Get3276() {
  2341. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2342. //month := c.GetString("month")
  2343. //
  2344. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2345. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2346. //var api string
  2347. //var res Result5301
  2348. //
  2349. //if miConfig.MdtrtareaAdmvs == "320921" {
  2350. // api = "http://192.168.2.3:9532/" + "jsyb/3276?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2351. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2352. //} else {
  2353. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2354. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2355. //}
  2356. //
  2357. //resp, requestErr := http.Get(api)
  2358. //if requestErr != nil {
  2359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2360. // return
  2361. //}
  2362. //
  2363. //body, ioErr := ioutil.ReadAll(resp.Body)
  2364. //if ioErr != nil {
  2365. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2367. // return
  2368. //}
  2369. //var respJSON map[string]interface{}
  2370. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2371. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2373. // return
  2374. //}
  2375. //
  2376. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2377. //result, _ := json.Marshal(respJSON)
  2378. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2379. // utils.ErrorLog("解析失败:%v", err)
  2380. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2381. // return
  2382. //}
  2383. }
  2384. func (c *HisApiController) Get3277() {
  2385. //admin_user_id, _ := c.GetInt64("admin_user_id")
  2386. //month := c.GetString("month")
  2387. //
  2388. //curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2389. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2390. //var api string
  2391. //var res Result5301
  2392. //
  2393. //if miConfig.MdtrtareaAdmvs == "320921" {
  2394. // api = "http://192.168.2.3:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2395. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2396. //} else {
  2397. // api = "http://192.168.5.251:9532/" + "jsyb/3264?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  2398. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo + "&month=" + month
  2399. //}
  2400. //
  2401. //resp, requestErr := http.Get(api)
  2402. //if requestErr != nil {
  2403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. // return
  2405. //}
  2406. //
  2407. //body, ioErr := ioutil.ReadAll(resp.Body)
  2408. //if ioErr != nil {
  2409. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2410. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2411. // return
  2412. //}
  2413. //var respJSON map[string]interface{}
  2414. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2415. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2416. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2417. // return
  2418. //}
  2419. //
  2420. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2421. //result, _ := json.Marshal(respJSON)
  2422. //if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2423. // utils.ErrorLog("解析失败:%v", err)
  2424. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2425. // return
  2426. //}
  2427. }
  2428. func (c *HisApiController) GetCFYLJG001() {
  2429. admin_user_id, _ := c.GetInt64("admin_user_id")
  2430. patient_id, _ := c.GetInt64("patient_id")
  2431. his_patient_id, _ := c.GetInt64("his_patient_id")
  2432. record_time := c.GetString("record_time")
  2433. admin_user_id = 3626
  2434. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2435. psn, _ := service.GetPsnByPatientId(patient_id)
  2436. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2437. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2438. var cFYLJG001 models.CFYLJG001
  2439. timeLayout := "2006-01-02"
  2440. loc, _ := time.LoadLocation("Local")
  2441. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2442. if err != nil {
  2443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2444. return
  2445. }
  2446. recordDateTime := theTime.Unix()
  2447. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2448. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2449. //info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2450. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2451. //dept, _ := service.GetDepartMentDetail(info.Departments)
  2452. for _, item := range prescriptions {
  2453. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  2454. if his.IdCardType == 1 {
  2455. bas := strings.Split(psn.CardInfo, "|")
  2456. basNumber := bas[1]
  2457. fmt.Println(basNumber)
  2458. card_sn := bas[3]
  2459. card_no := bas[2]
  2460. cFYLJG001.MdtrtCertType = "03"
  2461. cFYLJG001.CardSn = card_sn
  2462. cFYLJG001.MdtrtCertNo = card_no
  2463. cFYLJG001.EcToken = ""
  2464. cFYLJG001.AuthNo = ""
  2465. } else if his.IdCardType == 2 {
  2466. cFYLJG001.MdtrtCertType = "02"
  2467. cFYLJG001.CardSn = ""
  2468. cFYLJG001.MdtrtCertNo = his.IdCardNo
  2469. cFYLJG001.EcToken = ""
  2470. cFYLJG001.AuthNo = ""
  2471. } else if his.IdCardType == 4 {
  2472. cFYLJG001.MdtrtCertType = "01"
  2473. cFYLJG001.CardSn = ""
  2474. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  2475. cFYLJG001.EcToken = psn.VerifyNumber
  2476. cFYLJG001.AuthNo = ""
  2477. }
  2478. cFYLJG001.BizTypeCode = "01"
  2479. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  2480. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  2481. cFYLJG001.RxTypeCode = "1"
  2482. tempTime := time.Unix(item.PreTime, 0)
  2483. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  2484. cFYLJG001.PrscTime = timeFormatOne
  2485. var count float64
  2486. if item.Type == 1 {
  2487. for _, sumItem := range item.HisDoctorAdviceInfo {
  2488. count = count + sumItem.PrescribingNumber
  2489. }
  2490. }
  2491. cFYLJG001.RxDrugCnt = count
  2492. cFYLJG001.ValiDays = "5"
  2493. ts := time.Unix(item.PreTime, 0)
  2494. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  2495. tempTime3 := time.Unix(record_time2, 0)
  2496. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  2497. cFYLJG001.ValiEndTime = timeFormat3
  2498. cFYLJG001.RxCotnFlag = "0"
  2499. for _, subItem := range item.HisDoctorAdviceInfo {
  2500. var drug models.RxDrug
  2501. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2502. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  2503. drug.RxItemTypeCode = "11"
  2504. drug.DrugDosform = "乳膏剂" //TODO
  2505. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  2506. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  2507. }
  2508. drug.MedcWayDscr = subItem.DeliveryWay
  2509. tempTime2 := time.Unix(subItem.StartTime, 0)
  2510. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2511. drug.MedcBegntime = timeFormatTwo
  2512. if subItem.Day > 0 {
  2513. ts := time.Unix(subItem.StartTime, 0)
  2514. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  2515. tempTime4 := time.Unix(record_time, 0)
  2516. timeFormat5 := tempTime4.Format("2006-01-02 15:04:05")
  2517. drug.MedcEndtime = timeFormat5
  2518. } else {
  2519. tempTime2 := time.Unix(subItem.StartTime, 0)
  2520. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2521. drug.MedcEndtime = timeFormatTwo
  2522. }
  2523. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  2524. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  2525. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  2526. drug.DrugCnt = subItem.PrescribingNumber
  2527. drug.DrugDosunt = subItem.PrescribingNumberUnit
  2528. drug.DrugGenname = subItem.AdviceName
  2529. drug.MedcWayCodg = subItem.DeliveryWay
  2530. //drug.DrugTotlcnt = subItem.PrescribingNumber
  2531. drug.SinDoscnt = subItem.SingleDose
  2532. drug.SinDosunt = subItem.SingleDoseUnit
  2533. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  2534. drug.UsedFrquName = subItem.ExecutionFrequency
  2535. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2536. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  2537. drug.HospApprFlag = "1"
  2538. cFYLJG001.List = append(cFYLJG001.List, drug)
  2539. }
  2540. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  2541. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  2542. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  2543. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  2544. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  2545. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  2546. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  2547. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  2548. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  2549. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  2550. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2551. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  2552. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  2553. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  2554. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  2555. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  2556. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  2557. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  2558. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  2559. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  2560. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  2561. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  2562. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  2563. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  2564. tempTime2 := time.Now().Unix()
  2565. tempTime6 := time.Unix(tempTime2, 0)
  2566. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  2567. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  2568. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  2569. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  2570. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  2571. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  2572. //memo := make(map[string]interface{})
  2573. //inputData := make(map[string]interface{}, 0)
  2574. //type MyData struct {
  2575. // Insutype string `json:"insutype"`
  2576. //}
  2577. //
  2578. // data := MyData{
  2579. // Insutype: his.Insutype,
  2580. //}
  2581. //
  2582. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  2583. var config []*models.HisXtDiagnoseConfig
  2584. for _, item := range diagnosis_ids {
  2585. id, _ := strconv.ParseInt(item, 10, 64)
  2586. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2587. config = append(config, &diagnosisConfig)
  2588. }
  2589. for index, subitem := range config {
  2590. if index == 0 {
  2591. var dia models.DiseInfo
  2592. dia.DiagType = "1"
  2593. dia.MaindiagFlag = "1"
  2594. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2595. dia.DiagCode = subitem.CountryCode
  2596. dia.DiagName = subitem.ClassName
  2597. dia.DiagDept = "肾内科"
  2598. dia.DiagDrNo = doctor.DoctorNumber
  2599. dia.DiagDrName = doctor.UserName
  2600. tempTime3 := time.Unix(item.PreTime, 0)
  2601. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2602. dia.DiagTime = timeFormatTwo
  2603. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2604. } else {
  2605. var dia models.DiseInfo
  2606. dia.DiagType = "1"
  2607. dia.MaindiagFlag = "0"
  2608. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  2609. dia.DiagCode = subitem.CountryCode
  2610. dia.DiagName = subitem.ClassName
  2611. dia.DiagDept = "肾内科"
  2612. dia.DiagDrNo = doctor.DoctorNumber
  2613. dia.DiagDrName = doctor.UserName
  2614. tempTime3 := time.Unix(item.PreTime, 0)
  2615. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  2616. dia.DiagTime = timeFormatTwo
  2617. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  2618. }
  2619. }
  2620. result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001, his.Insutype)
  2621. saveLog(result, request, "GetCFYLJG001", "GetCFYLJG001")
  2622. var res ResultCFYLJG001
  2623. var respJSON2 map[string]interface{}
  2624. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2625. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2627. return
  2628. }
  2629. userJSONBytes2, _ := json.Marshal(respJSON2)
  2630. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2631. utils.ErrorLog("解析失败:%v", err)
  2632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2633. return
  2634. }
  2635. if res.Infcode == -1 {
  2636. c.ServeSuccessJSON(map[string]interface{}{
  2637. "failed_code": -10,
  2638. "msg": res.ErrMsg,
  2639. })
  2640. return
  2641. } else {
  2642. var flow models.HisPrescriptionFlow
  2643. flow.Ctime = time.Now().Unix()
  2644. flow.SignDigest = ""
  2645. flow.RxTraceCode = res.Output.RxTraceCode
  2646. flow.HiRxno = res.Output.HiRxno
  2647. flow.MID = his.Number
  2648. flow.Status = 1
  2649. flow.DCode = doctor_info.DoctorNumber
  2650. flow.OriginalRxFile = ""
  2651. flow.OriginalValue = ""
  2652. flow.SignCertDn = ""
  2653. flow.UserOrgId = 10454
  2654. flow.SignCertSn = ""
  2655. flow.Mtime = time.Now().Unix()
  2656. service.Createflow(&flow)
  2657. c.ServeSuccessJSON(map[string]interface{}{
  2658. "msg": "上传成功",
  2659. })
  2660. }
  2661. }
  2662. }
  2663. func (c *HisApiController) GetCFYLJG002() {
  2664. admin_user_id, _ := c.GetInt64("admin_user_id")
  2665. his_patient_id, _ := c.GetInt64("his_patient_id")
  2666. record_time := c.GetString("record_time")
  2667. admin_user_id = 3626
  2668. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2669. //id, _ := c.GetInt64("id")
  2670. admin_user_id = 3626
  2671. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2672. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2673. flow, _ := service.Getflowtwo(his.Number)
  2674. //his, _ := service.GetHisPatientByNumber(flow.MID)
  2675. //record_time := c.GetString("record_time")
  2676. patient_id, _ := c.GetInt64("patient_id")
  2677. //patient_id = 23834
  2678. //record_time = "2023-09-18"
  2679. timeLayout := "2006-01-02"
  2680. loc, _ := time.LoadLocation("Local")
  2681. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2682. if err != nil {
  2683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2684. return
  2685. }
  2686. recordDateTime := theTime.Unix()
  2687. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2688. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2689. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2690. dept, _ := service.GetDepartMentDetail(info.Departments)
  2691. inputData := make(map[string]interface{})
  2692. inputData["rxTraceCode"] = flow.RxTraceCode
  2693. inputData["hiRxno"] = flow.HiRxno
  2694. inputData["mdtrtId"] = flow.MID
  2695. inputData["patnName"] = his.PsnName
  2696. inputData["psnCertType"] = his.PsnCertType
  2697. inputData["certno"] = his.Certno
  2698. inputData["fixmedinsName"] = miConfig.OrgName
  2699. inputData["fixmedinsCode"] = miConfig.Code
  2700. inputData["drCode"] = doctor_info.DoctorNumber
  2701. inputData["prscDrName"] = doctor_info.UserName
  2702. inputData["pharDeptName"] = dept.Name
  2703. inputData["pharDeptCode"] = dept.Number
  2704. inputData["pharProfttlCodg"] = dept.Name
  2705. inputData["pharProfttlName"] = ""
  2706. inputData["pharCode"] = "HY440309002107"
  2707. inputData["pharCertType"] = "01"
  2708. inputData["pharCertno"] = "430482199408260023"
  2709. inputData["pharName"] = "彭斯遥"
  2710. inputData["pharPracCertNo"] = ""
  2711. tempTime2 := time.Unix(info.Ctime, 0)
  2712. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2713. inputData["pharChkTime"] = timeFormatTwo
  2714. bytesData, _ := json.Marshal(inputData)
  2715. fmt.Println(string(bytesData))
  2716. encoded := base64.StdEncoding.EncodeToString(bytesData)
  2717. pdfContent, err := ioutil.ReadFile("signed_data.pdf")
  2718. if err != nil {
  2719. fmt.Println("Error reading PDF file:", err)
  2720. return
  2721. }
  2722. // 将 PDF 文件内容进行 Base64 编码
  2723. rx_encoded := base64.StdEncoding.EncodeToString(pdfContent)
  2724. fmt.Println(err)
  2725. result, request := service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, encoded, rx_encoded, "")
  2726. //result, request := service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001,his.Insutype)
  2727. saveLog(result, request, "GetCFYLJG002", "GetCFYLJG002")
  2728. var res2 Result002
  2729. var respJSON2 map[string]interface{}
  2730. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2733. return
  2734. }
  2735. userJSONBytes2, _ := json.Marshal(respJSON2)
  2736. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2737. utils.ErrorLog("解析失败:%v", err)
  2738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2739. return
  2740. }
  2741. if res2.Infcode == 0 {
  2742. flow.Ctime = time.Now().Unix()
  2743. flow.SignDigest = res2.Output.SignDigest
  2744. flow.RxFile = res2.Output.RxFile
  2745. flow.MID = his.Number
  2746. flow.Status = 1
  2747. flow.DCode = doctor_info.DoctorNumber
  2748. flow.OriginalRxFile = rx_encoded
  2749. flow.OriginalValue = encoded
  2750. flow.SignCertDn = res2.Output.SignCertDn
  2751. flow.SignCertSn = res2.Output.SignCertSn
  2752. flow.Mtime = time.Now().Unix()
  2753. service.Saveflow(flow)
  2754. c.ServeSuccessJSON(map[string]interface{}{
  2755. "msg": "预签名成功",
  2756. })
  2757. } else {
  2758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. return
  2760. }
  2761. }
  2762. func (c *HisApiController) GetCFYLJG003() {
  2763. admin_user_id, _ := c.GetInt64("admin_user_id")
  2764. his_patient_id, _ := c.GetInt64("his_patient_id")
  2765. record_time := c.GetString("record_time")
  2766. admin_user_id = 3626
  2767. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2768. //id, _ := c.GetInt64("id")
  2769. admin_user_id = 3626
  2770. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2771. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2772. flow, _ := service.Getflowtwo(his.Number)
  2773. //id = 3
  2774. patient_id, _ := c.GetInt64("patient_id")
  2775. //patient_id = 23834
  2776. //record_time = "2023-09-18"
  2777. timeLayout := "2006-01-02"
  2778. loc, _ := time.LoadLocation("Local")
  2779. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2780. if err != nil {
  2781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2782. return
  2783. }
  2784. recordDateTime := theTime.Unix()
  2785. //prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2786. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2787. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2788. dept, _ := service.GetDepartMentDetail(info.Departments)
  2789. //psn_info,_ := service.GetPsnByPatientId(his.PatientId)
  2790. var cFYLJG003 models.CFYLJG003
  2791. cFYLJG003.RxTraceCode = flow.RxTraceCode
  2792. cFYLJG003.HiRxno = flow.HiRxno
  2793. cFYLJG003.MdtrtID = flow.MID
  2794. cFYLJG003.PatnName = his.Name
  2795. cFYLJG003.Certno = his.Certno
  2796. cFYLJG003.FixmedinsName = miConfig.OrgName
  2797. cFYLJG003.FixmedinsCode = miConfig.Code
  2798. cFYLJG003.DrCode = doctor_info.DoctorNumber
  2799. cFYLJG003.PrscDrName = doctor_info.UserName
  2800. cFYLJG003.PharDeptName = dept.Name
  2801. cFYLJG003.PharDeptCode = dept.Number
  2802. cFYLJG003.PharCode = "HY440309002107"
  2803. cFYLJG003.PharCertType = "01"
  2804. cFYLJG003.PharCertno = "430482199408260023"
  2805. cFYLJG003.PharName = "彭斯遥"
  2806. cFYLJG003.PsnCertType = "01"
  2807. cFYLJG003.RxFile = flow.RxFile
  2808. cFYLJG003.SignDigest = flow.SignDigest
  2809. cFYLJG003.FixmedinsCode = miConfig.Code
  2810. cFYLJG003.PsnCertType = "01"
  2811. cFYLJG003.PharProfttlCodg = dept.Name
  2812. //inputData["pharProfttlCodg"] =dept.Name
  2813. tempTime2 := time.Unix(info.Ctime, 0)
  2814. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  2815. cFYLJG003.PharChkTime = timeFormatTwo
  2816. result, request := service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  2817. saveLog(result, request, "GetCFYLJG003", "GetCFYLJG003")
  2818. var res ResultCFYLJG003
  2819. var respJSON2 map[string]interface{}
  2820. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2823. return
  2824. }
  2825. userJSONBytes2, _ := json.Marshal(respJSON2)
  2826. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2827. utils.ErrorLog("解析失败:%v", err)
  2828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2829. return
  2830. }
  2831. if res.Infcode == -1 {
  2832. c.ServeSuccessJSON(map[string]interface{}{
  2833. "failed_code": -10,
  2834. "msg": res.ErrMsg,
  2835. })
  2836. return
  2837. } else {
  2838. c.ServeSuccessJSON(map[string]interface{}{
  2839. "info": res.Output,
  2840. })
  2841. }
  2842. }
  2843. func (c *HisApiController) GetCFYLJG004() {
  2844. admin_user_id, _ := c.GetInt64("admin_user_id")
  2845. his_patient_id, _ := c.GetInt64("his_patient_id")
  2846. record_time := c.GetString("record_time")
  2847. admin_user_id = 3626
  2848. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2849. //id, _ := c.GetInt64("id")
  2850. admin_user_id = 3626
  2851. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2852. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2853. flow, _ := service.Getflowtwo(his.Number)
  2854. //id = 3
  2855. patient_id, _ := c.GetInt64("patient_id")
  2856. //patient_id = 23834
  2857. //record_time = "2023-09-18"
  2858. timeLayout := "2006-01-02"
  2859. loc, _ := time.LoadLocation("Local")
  2860. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2861. if err != nil {
  2862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2863. return
  2864. }
  2865. recordDateTime := theTime.Unix()
  2866. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  2867. doctor_info, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, info.DoctorId)
  2868. var cFYLJG004 models.CFYLJG004
  2869. cFYLJG004.HiRxno = flow.HiRxno
  2870. cFYLJG004.FixmedinsCode = miConfig.Code
  2871. cFYLJG004.UndoDrCertno = doctor_info.IdCard
  2872. cFYLJG004.UndoDrCertType = "01"
  2873. cFYLJG004.UndoRea = "撤销处方"
  2874. cFYLJG004.UndoTime = time.Now().Format("2006-01-02 15:04:05")
  2875. cFYLJG004.UndoDrName = doctor_info.UserName
  2876. cFYLJG004.UndoDrCode = doctor_info.DoctorNumber
  2877. result, request := service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  2878. saveLog(result, request, "GetCFYLJG004", "GetCFYLJG004")
  2879. var res ResultCFYLJG004
  2880. var respJSON2 map[string]interface{}
  2881. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2882. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2884. return
  2885. }
  2886. userJSONBytes2, _ := json.Marshal(respJSON2)
  2887. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2888. utils.ErrorLog("解析失败:%v", err)
  2889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2890. return
  2891. }
  2892. if res.Infcode == -1 {
  2893. c.ServeSuccessJSON(map[string]interface{}{
  2894. "failed_code": -10,
  2895. "msg": res.ErrMsg,
  2896. })
  2897. return
  2898. } else {
  2899. flow.Status = 0
  2900. service.Saveflow(flow)
  2901. c.ServeSuccessJSON(map[string]interface{}{
  2902. "msg": "撤销成功",
  2903. })
  2904. return
  2905. }
  2906. }
  2907. func (c *HisApiController) GetCFYLJG005() {
  2908. admin_user_id, _ := c.GetInt64("admin_user_id")
  2909. his_patient_id, _ := c.GetInt64("his_patient_id")
  2910. //record_time := c.GetString("record_time")
  2911. admin_user_id = 3626
  2912. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2913. //id, _ := c.GetInt64("id")
  2914. admin_user_id = 3626
  2915. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2916. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2917. flow, _ := service.Getflowtwo(his.Number)
  2918. //id = 3
  2919. var cFYLJG005 models.CFYLJG005
  2920. //patient_id, _ := c.GetInt64("patient_id")
  2921. cFYLJG005.HiRxno = flow.HiRxno
  2922. cFYLJG005.MdtrtID = flow.MID
  2923. cFYLJG005.EcToken = ""
  2924. cFYLJG005.PsnName = his.Name
  2925. cFYLJG005.PsnCertType = "01"
  2926. cFYLJG005.Certno = his.IdCardNo
  2927. result, request := service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  2928. saveLog(result, request, "GetCFYLJG005", "GetCFYLJG005")
  2929. var res ResultCFYLJG005
  2930. var respJSON2 map[string]interface{}
  2931. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2934. return
  2935. }
  2936. userJSONBytes2, _ := json.Marshal(respJSON2)
  2937. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2938. utils.ErrorLog("解析失败:%v", err)
  2939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2940. return
  2941. }
  2942. if res.Infcode == -1 {
  2943. c.ServeSuccessJSON(map[string]interface{}{
  2944. "failed_code": -10,
  2945. "msg": res.ErrMsg,
  2946. })
  2947. return
  2948. } else {
  2949. c.ServeSuccessJSON(map[string]interface{}{
  2950. "info": res.Output,
  2951. })
  2952. return
  2953. }
  2954. }
  2955. func (c *HisApiController) GetCFYLJG006() {
  2956. admin_user_id, _ := c.GetInt64("admin_user_id")
  2957. his_patient_id, _ := c.GetInt64("his_patient_id")
  2958. admin_user_id = 3626
  2959. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2960. //id, _ := c.GetInt64("id")
  2961. admin_user_id = 3626
  2962. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2963. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2964. flow, _ := service.Getflowtwo(his.Number)
  2965. //id = 3
  2966. patient_id, _ := c.GetInt64("patient_id")
  2967. var cFYLJG006 models.CFYLJG006
  2968. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  2969. cFYLJG006.HiRxno = flow.HiRxno
  2970. cFYLJG006.MdtrtID = flow.MID
  2971. cFYLJG006.PsnName = patient.Name
  2972. cFYLJG006.PsnCertType = "01"
  2973. cFYLJG006.Certno = patient.IdCardNo
  2974. result, request := service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  2975. saveLog(result, request, "GetCFYLJG006", "GetCFYLJG006")
  2976. var res ResultCFYLJG006
  2977. var respJSON2 map[string]interface{}
  2978. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2981. return
  2982. }
  2983. userJSONBytes2, _ := json.Marshal(respJSON2)
  2984. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  2985. utils.ErrorLog("解析失败:%v", err)
  2986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2987. return
  2988. }
  2989. if res.Infcode == -1 {
  2990. c.ServeSuccessJSON(map[string]interface{}{
  2991. "failed_code": -10,
  2992. "msg": res.ErrMsg,
  2993. })
  2994. return
  2995. } else {
  2996. c.ServeSuccessJSON(map[string]interface{}{
  2997. "info": res.Output,
  2998. })
  2999. return
  3000. }
  3001. }
  3002. func (c *HisApiController) GetCFYLJG007() {
  3003. admin_user_id, _ := c.GetInt64("admin_user_id")
  3004. his_patient_id, _ := c.GetInt64("his_patient_id")
  3005. admin_user_id = 3626
  3006. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3007. //id, _ := c.GetInt64("id")
  3008. admin_user_id = 3626
  3009. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3010. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3011. flow, _ := service.Getflowtwo(his.Number)
  3012. //id = 3
  3013. patient_id, _ := c.GetInt64("patient_id")
  3014. var cFYLJG007 models.CFYLJG007
  3015. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, patient_id)
  3016. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3017. cFYLJG007.HiRxno = flow.HiRxno
  3018. cFYLJG007.MdtrtID = flow.MID
  3019. cFYLJG007.PsnNo = his.PsnNo
  3020. cFYLJG007.PsnCertType = "01"
  3021. cFYLJG007.Certno = patient.IdCardNo
  3022. cFYLJG007.PsnName = patient.Name
  3023. result, request := service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  3024. saveLog(result, request, "GetCFYLJG007", "GetCFYLJG007")
  3025. var res ResultCFYLJG007
  3026. var respJSON2 map[string]interface{}
  3027. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3030. return
  3031. }
  3032. userJSONBytes2, _ := json.Marshal(respJSON2)
  3033. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3034. utils.ErrorLog("解析失败:%v", err)
  3035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3036. return
  3037. }
  3038. if res.Infcode == -1 {
  3039. c.ServeSuccessJSON(map[string]interface{}{
  3040. "failed_code": -10,
  3041. "msg": res.ErrMsg,
  3042. })
  3043. return
  3044. } else {
  3045. c.ServeSuccessJSON(map[string]interface{}{
  3046. "info": res,
  3047. })
  3048. return
  3049. }
  3050. }
  3051. func (c *HisApiController) GetCFYLJG008() {
  3052. admin_user_id, _ := c.GetInt64("admin_user_id")
  3053. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3054. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3055. var cFYLJG008 models.CFYLJG008
  3056. //id, _ := c.GetInt64("id")
  3057. patient_id, _ := c.GetInt64("patient_id")
  3058. //patient, _ := service.G/etPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3059. //his, _ := service.GetHisPatient(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  3060. //id = 3
  3061. //flow, _ := service.Getflow(id)
  3062. //his, _ := service.GetHisPatientByNumber(flow.MID)
  3063. //
  3064. //admin_user_id, _ := c.GetInt64("admin_user_id")
  3065. //patient_id, _ := c.GetInt64("patient_id")
  3066. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3067. record_time := c.GetString("record_time")
  3068. admin_user_id = 3626
  3069. patient_id = 19424
  3070. //his_patient_id = 263947
  3071. record_time = "2023-08-29"
  3072. timeLayout := "2006-01-02"
  3073. loc, _ := time.LoadLocation("Local")
  3074. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3075. if err != nil {
  3076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3077. return
  3078. }
  3079. recordDateTime := theTime.Unix()
  3080. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  3081. cFYLJG008.FixmedinsName = ""
  3082. cFYLJG008.Lat = ""
  3083. cFYLJG008.Lng = ""
  3084. cFYLJG008.OrderType = "1"
  3085. cFYLJG008.PoolareaNo = ""
  3086. cFYLJG008.Lng = ""
  3087. cFYLJG008.PageNum = 1
  3088. cFYLJG008.PageSize = 10
  3089. var MPI models.MedinsProdInvChgDDTO
  3090. MPI.MedListCodg = prescriptions[0].HisDoctorAdviceInfo[0].MedListCodg
  3091. MPI.Cnt = prescriptions[0].HisDoctorAdviceInfo[0].PrescribingNumber
  3092. cFYLJG008.MedList = append(cFYLJG008.MedList, MPI)
  3093. result, request := service.GetCFYLJG008(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG008)
  3094. saveLog(result, request, "GetCFYLJG008", "GetCFYLJG008")
  3095. var res ResultCFYLJG008
  3096. var respJSON2 map[string]interface{}
  3097. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3100. return
  3101. }
  3102. userJSONBytes2, _ := json.Marshal(respJSON2)
  3103. if err := json.Unmarshal(userJSONBytes2, &res); err != nil {
  3104. utils.ErrorLog("解析失败:%v", err)
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3106. return
  3107. }
  3108. if res.Infcode == -1 {
  3109. c.ServeSuccessJSON(map[string]interface{}{
  3110. "failed_code": -10,
  3111. "msg": res.ErrMsg,
  3112. })
  3113. return
  3114. } else {
  3115. c.ServeSuccessJSON(map[string]interface{}{
  3116. "info": res.Output,
  3117. })
  3118. return
  3119. }
  3120. }
  3121. func (c *HisApiController) GetBL4201A() {
  3122. order_id, _ := c.GetInt64("order_id")
  3123. admin_user_id, _ := c.GetInt64("admin_user_id")
  3124. order, _ := service.GetHisOrderByIDTwo(order_id)
  3125. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3126. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3127. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3128. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3129. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3130. department, _ := service.GetDepartMentDetail(his.Departments)
  3131. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3132. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3133. if order.ID == 0 {
  3134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3135. return
  3136. }
  3137. var struct4201A models.Struct4201A
  3138. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3139. for _, items := range order_info {
  3140. memo := make(map[string]interface{})
  3141. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3142. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3143. fsiOPFLD.MedType = "14"
  3144. fsiOPFLD.BkkpSn = items.FeedetlSn
  3145. fsiOPFLD.FixmedinsCode = miConfig.Code
  3146. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3147. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3148. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3149. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3150. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3151. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3152. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3153. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3154. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3155. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3156. fsiOPFLD.BilgDeptName = department.Name
  3157. fsiOPFLD.BilgDeptCodg = department.Number
  3158. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3159. fsiOPFLD.BilgDrName = doctor.UserName
  3160. fsiOPFLD.MedChrgitmType = "09"
  3161. memo["hosp_appr_flag"] = "1"
  3162. memo["invoice_no"] = order.MdtrtId
  3163. memo["memo"] = "自费"
  3164. bytesData, _ := json.Marshal(memo)
  3165. fsiOPFLD.Memo = string(bytesData)
  3166. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3167. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3168. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3169. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3170. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3171. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3172. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3173. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3174. fsiOPFLD.BilgDeptName = department.Name
  3175. fsiOPFLD.BilgDeptCodg = department.Number
  3176. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3177. fsiOPFLD.BilgDrName = doctor.UserName
  3178. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3179. case 0:
  3180. break
  3181. case 1:
  3182. fsiOPFLD.MedChrgitmType = "14"
  3183. break
  3184. case 2:
  3185. fsiOPFLD.MedChrgitmType = "05"
  3186. break
  3187. case 3:
  3188. fsiOPFLD.MedChrgitmType = "03"
  3189. break
  3190. case 4:
  3191. fsiOPFLD.MedChrgitmType = "03"
  3192. break
  3193. case 5:
  3194. fsiOPFLD.MedChrgitmType = "08"
  3195. break
  3196. case 6:
  3197. fsiOPFLD.MedChrgitmType = "14"
  3198. break
  3199. case 7:
  3200. fsiOPFLD.MedChrgitmType = "14"
  3201. break
  3202. case 8:
  3203. fsiOPFLD.MedChrgitmType = "03"
  3204. break
  3205. case 9:
  3206. fsiOPFLD.MedChrgitmType = "14"
  3207. break
  3208. case 10:
  3209. fsiOPFLD.MedChrgitmType = "14"
  3210. break
  3211. case 11:
  3212. fsiOPFLD.MedChrgitmType = "06"
  3213. break
  3214. case 12:
  3215. fsiOPFLD.MedChrgitmType = "12"
  3216. break
  3217. case 13:
  3218. fsiOPFLD.MedChrgitmType = "01"
  3219. break
  3220. case 14:
  3221. fsiOPFLD.MedChrgitmType = "04"
  3222. break
  3223. case 15:
  3224. fsiOPFLD.MedChrgitmType = "14"
  3225. break
  3226. }
  3227. memo["hosp_appr_flag"] = "1"
  3228. memo["invoice_no"] = order.MdtrtId
  3229. memo["memo"] = "自费"
  3230. bytesData, _ := json.Marshal(memo)
  3231. fsiOPFLD.Memo = string(bytesData)
  3232. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3233. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3234. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3235. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3236. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3237. fsiOPFLD.BilgDeptName = department.Name
  3238. fsiOPFLD.BilgDeptCodg = department.Number
  3239. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3240. fsiOPFLD.BilgDrName = doctor.UserName
  3241. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3242. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3243. fsiOPFLD.MedChrgitmType = "08"
  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. }
  3251. }
  3252. }
  3253. for _, items := range order_info_two {
  3254. memo := make(map[string]interface{})
  3255. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3256. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3257. fsiOPFLD.MedType = "14"
  3258. fsiOPFLD.BkkpSn = items.FeedetlSn
  3259. fsiOPFLD.FixmedinsCode = miConfig.Code
  3260. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3261. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3262. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3263. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3264. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3265. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3266. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3267. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3268. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3269. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3270. fsiOPFLD.BilgDeptName = department.Name
  3271. fsiOPFLD.BilgDeptCodg = department.Number
  3272. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3273. fsiOPFLD.BilgDrName = doctor.UserName
  3274. fsiOPFLD.MedChrgitmType = "09"
  3275. memo["hosp_appr_flag"] = "1"
  3276. memo["invoice_no"] = order.MdtrtId
  3277. memo["memo"] = "自费"
  3278. bytesData, _ := json.Marshal(memo)
  3279. fsiOPFLD.Memo = string(bytesData)
  3280. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3281. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3282. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3283. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3284. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3285. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3286. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3287. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3288. fsiOPFLD.BilgDeptName = department.Name
  3289. fsiOPFLD.BilgDeptCodg = department.Number
  3290. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3291. fsiOPFLD.BilgDrName = doctor.UserName
  3292. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3293. case 0:
  3294. break
  3295. case 1:
  3296. fsiOPFLD.MedChrgitmType = "14"
  3297. break
  3298. case 2:
  3299. fsiOPFLD.MedChrgitmType = "05"
  3300. break
  3301. case 3:
  3302. fsiOPFLD.MedChrgitmType = "03"
  3303. break
  3304. case 4:
  3305. fsiOPFLD.MedChrgitmType = "03"
  3306. break
  3307. case 5:
  3308. fsiOPFLD.MedChrgitmType = "08"
  3309. break
  3310. case 6:
  3311. fsiOPFLD.MedChrgitmType = "14"
  3312. break
  3313. case 7:
  3314. fsiOPFLD.MedChrgitmType = "14"
  3315. break
  3316. case 8:
  3317. fsiOPFLD.MedChrgitmType = "03"
  3318. break
  3319. case 9:
  3320. fsiOPFLD.MedChrgitmType = "14"
  3321. break
  3322. case 10:
  3323. fsiOPFLD.MedChrgitmType = "14"
  3324. break
  3325. case 11:
  3326. fsiOPFLD.MedChrgitmType = "06"
  3327. break
  3328. case 12:
  3329. fsiOPFLD.MedChrgitmType = "12"
  3330. break
  3331. case 13:
  3332. fsiOPFLD.MedChrgitmType = "01"
  3333. break
  3334. case 14:
  3335. fsiOPFLD.MedChrgitmType = "04"
  3336. break
  3337. case 15:
  3338. fsiOPFLD.MedChrgitmType = "14"
  3339. break
  3340. }
  3341. memo["hosp_appr_flag"] = "1"
  3342. memo["invoice_no"] = order.MdtrtId
  3343. memo["memo"] = "自费"
  3344. bytesData, _ := json.Marshal(memo)
  3345. fsiOPFLD.Memo = string(bytesData)
  3346. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3347. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3348. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3349. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3350. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3351. fsiOPFLD.BilgDeptName = department.Name
  3352. fsiOPFLD.BilgDeptCodg = department.Number
  3353. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3354. fsiOPFLD.BilgDrName = doctor.UserName
  3355. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3356. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3357. fsiOPFLD.MedChrgitmType = "08"
  3358. memo["hosp_appr_flag"] = "1"
  3359. memo["invoice_no"] = order.MdtrtId
  3360. memo["memo"] = "自费"
  3361. bytesData, _ := json.Marshal(memo)
  3362. fsiOPFLD.Memo = string(bytesData)
  3363. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3364. }
  3365. }
  3366. }
  3367. fmt.Println(fsiOPFLDs)
  3368. struct4201A.Fopfd = fsiOPFLDs
  3369. fmt.Println(struct4201A.Fopfd)
  3370. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3371. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3372. var res2 ResultSix
  3373. var respJSON2 map[string]interface{}
  3374. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3375. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3377. return
  3378. }
  3379. userJSONBytes2, _ := json.Marshal(respJSON2)
  3380. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3381. utils.ErrorLog("解析失败:%v", err)
  3382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3383. return
  3384. }
  3385. if res2.Infcode != 0 {
  3386. c.ServeSuccessJSON(map[string]interface{}{
  3387. "failed_code": -10,
  3388. "msg": res2.ErrMsg,
  3389. })
  3390. return
  3391. } else {
  3392. order.IsUploadOrderInfo = 1
  3393. service.UpdateOrder(order)
  3394. c.ServeSuccessJSON(map[string]interface{}{
  3395. "msg": "上传成功",
  3396. })
  3397. }
  3398. }
  3399. func (c *HisApiController) Get2505() {
  3400. admin_user_id, _ := c.GetInt64("admin_user_id")
  3401. miConfig, _ := service.FindMedicalInsuranceInfo(10375)
  3402. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3403. 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)
  3404. }
  3405. func (c *HisApiController) Get4201A() {
  3406. order_id, _ := c.GetInt64("order_id")
  3407. admin_user_id, _ := c.GetInt64("admin_user_id")
  3408. order, _ := service.GetHisOrderByIDTwo(order_id)
  3409. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3410. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  3411. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  3412. //order_info = append(order_info, order_info_two...)
  3413. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3414. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3415. department, _ := service.GetDepartMentDetail(his.Departments)
  3416. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3417. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3418. if order.ID == 0 {
  3419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3420. return
  3421. }
  3422. var struct4201A models.Struct4201A
  3423. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3424. for _, items := range order_info {
  3425. memo := make(map[string]interface{})
  3426. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3427. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3428. fsiOPFLD.MedType = "14"
  3429. fsiOPFLD.BkkpSn = items.FeedetlSn
  3430. fsiOPFLD.FixmedinsCode = miConfig.Code
  3431. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3432. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3433. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3434. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3435. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3436. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3437. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3438. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3439. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3440. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3441. fsiOPFLD.BilgDeptName = department.Name
  3442. fsiOPFLD.BilgDeptCodg = department.Number
  3443. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3444. fsiOPFLD.BilgDrName = doctor.UserName
  3445. fsiOPFLD.MedChrgitmType = "09"
  3446. memo["hosp_appr_flag"] = "1"
  3447. memo["invoice_no"] = order.MdtrtId
  3448. memo["memo"] = "自费"
  3449. bytesData, _ := json.Marshal(memo)
  3450. fsiOPFLD.Memo = string(bytesData)
  3451. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3452. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3453. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3454. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3455. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3456. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3457. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3458. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3459. fsiOPFLD.BilgDeptName = department.Name
  3460. fsiOPFLD.BilgDeptCodg = department.Number
  3461. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3462. fsiOPFLD.BilgDrName = doctor.UserName
  3463. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3464. case 0:
  3465. break
  3466. case 1:
  3467. fsiOPFLD.MedChrgitmType = "14"
  3468. break
  3469. case 2:
  3470. fsiOPFLD.MedChrgitmType = "05"
  3471. break
  3472. case 3:
  3473. fsiOPFLD.MedChrgitmType = "03"
  3474. break
  3475. case 4:
  3476. fsiOPFLD.MedChrgitmType = "03"
  3477. break
  3478. case 5:
  3479. fsiOPFLD.MedChrgitmType = "08"
  3480. break
  3481. case 6:
  3482. fsiOPFLD.MedChrgitmType = "14"
  3483. break
  3484. case 7:
  3485. fsiOPFLD.MedChrgitmType = "14"
  3486. break
  3487. case 8:
  3488. fsiOPFLD.MedChrgitmType = "03"
  3489. break
  3490. case 9:
  3491. fsiOPFLD.MedChrgitmType = "14"
  3492. break
  3493. case 10:
  3494. fsiOPFLD.MedChrgitmType = "14"
  3495. break
  3496. case 11:
  3497. fsiOPFLD.MedChrgitmType = "06"
  3498. break
  3499. case 12:
  3500. fsiOPFLD.MedChrgitmType = "12"
  3501. break
  3502. case 13:
  3503. fsiOPFLD.MedChrgitmType = "01"
  3504. break
  3505. case 14:
  3506. fsiOPFLD.MedChrgitmType = "04"
  3507. break
  3508. case 15:
  3509. fsiOPFLD.MedChrgitmType = "14"
  3510. break
  3511. }
  3512. memo["hosp_appr_flag"] = "1"
  3513. memo["invoice_no"] = order.MdtrtId
  3514. memo["memo"] = "自费"
  3515. bytesData, _ := json.Marshal(memo)
  3516. fsiOPFLD.Memo = string(bytesData)
  3517. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3518. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3519. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3520. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3521. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3522. fsiOPFLD.BilgDeptName = department.Name
  3523. fsiOPFLD.BilgDeptCodg = department.Number
  3524. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3525. fsiOPFLD.BilgDrName = doctor.UserName
  3526. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3527. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3528. fsiOPFLD.MedChrgitmType = "08"
  3529. memo["hosp_appr_flag"] = "1"
  3530. memo["invoice_no"] = order.MdtrtId
  3531. memo["memo"] = "自费"
  3532. bytesData, _ := json.Marshal(memo)
  3533. fsiOPFLD.Memo = string(bytesData)
  3534. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3535. }
  3536. }
  3537. }
  3538. for _, items := range order_info_two {
  3539. memo := make(map[string]interface{})
  3540. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3541. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3542. fsiOPFLD.MedType = "14"
  3543. fsiOPFLD.BkkpSn = items.FeedetlSn
  3544. fsiOPFLD.FixmedinsCode = miConfig.Code
  3545. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3546. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3547. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3548. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3549. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3550. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3551. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3552. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3553. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3554. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3555. fsiOPFLD.BilgDeptName = department.Name
  3556. fsiOPFLD.BilgDeptCodg = department.Number
  3557. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3558. fsiOPFLD.BilgDrName = doctor.UserName
  3559. fsiOPFLD.MedChrgitmType = "09"
  3560. memo["hosp_appr_flag"] = "1"
  3561. memo["invoice_no"] = order.MdtrtId
  3562. memo["memo"] = "自费"
  3563. bytesData, _ := json.Marshal(memo)
  3564. fsiOPFLD.Memo = string(bytesData)
  3565. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3566. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3567. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3568. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3569. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3570. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3571. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3572. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3573. fsiOPFLD.BilgDeptName = department.Name
  3574. fsiOPFLD.BilgDeptCodg = department.Number
  3575. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3576. fsiOPFLD.BilgDrName = doctor.UserName
  3577. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3578. case 0:
  3579. break
  3580. case 1:
  3581. fsiOPFLD.MedChrgitmType = "14"
  3582. break
  3583. case 2:
  3584. fsiOPFLD.MedChrgitmType = "05"
  3585. break
  3586. case 3:
  3587. fsiOPFLD.MedChrgitmType = "03"
  3588. break
  3589. case 4:
  3590. fsiOPFLD.MedChrgitmType = "03"
  3591. break
  3592. case 5:
  3593. fsiOPFLD.MedChrgitmType = "08"
  3594. break
  3595. case 6:
  3596. fsiOPFLD.MedChrgitmType = "14"
  3597. break
  3598. case 7:
  3599. fsiOPFLD.MedChrgitmType = "14"
  3600. break
  3601. case 8:
  3602. fsiOPFLD.MedChrgitmType = "03"
  3603. break
  3604. case 9:
  3605. fsiOPFLD.MedChrgitmType = "14"
  3606. break
  3607. case 10:
  3608. fsiOPFLD.MedChrgitmType = "14"
  3609. break
  3610. case 11:
  3611. fsiOPFLD.MedChrgitmType = "06"
  3612. break
  3613. case 12:
  3614. fsiOPFLD.MedChrgitmType = "12"
  3615. break
  3616. case 13:
  3617. fsiOPFLD.MedChrgitmType = "01"
  3618. break
  3619. case 14:
  3620. fsiOPFLD.MedChrgitmType = "04"
  3621. break
  3622. case 15:
  3623. fsiOPFLD.MedChrgitmType = "14"
  3624. break
  3625. }
  3626. memo["hosp_appr_flag"] = "1"
  3627. memo["invoice_no"] = order.MdtrtId
  3628. memo["memo"] = "自费"
  3629. bytesData, _ := json.Marshal(memo)
  3630. fsiOPFLD.Memo = string(bytesData)
  3631. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3632. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  3633. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3634. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3635. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3636. fsiOPFLD.BilgDeptName = department.Name
  3637. fsiOPFLD.BilgDeptCodg = department.Number
  3638. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3639. fsiOPFLD.BilgDrName = doctor.UserName
  3640. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3641. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3642. fsiOPFLD.MedChrgitmType = "08"
  3643. memo["hosp_appr_flag"] = "1"
  3644. memo["invoice_no"] = order.MdtrtId
  3645. memo["memo"] = "自费"
  3646. bytesData, _ := json.Marshal(memo)
  3647. fsiOPFLD.Memo = string(bytesData)
  3648. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3649. }
  3650. }
  3651. }
  3652. fmt.Println(fsiOPFLDs)
  3653. struct4201A.Fopfd = fsiOPFLDs
  3654. fmt.Println(struct4201A.Fopfd)
  3655. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  3656. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  3657. var res2 ResultSix
  3658. var respJSON2 map[string]interface{}
  3659. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3660. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3662. return
  3663. }
  3664. userJSONBytes2, _ := json.Marshal(respJSON2)
  3665. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3666. utils.ErrorLog("解析失败:%v", err)
  3667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3668. return
  3669. }
  3670. if res2.Infcode != 0 {
  3671. c.ServeSuccessJSON(map[string]interface{}{
  3672. "failed_code": -10,
  3673. "msg": res2.ErrMsg,
  3674. })
  3675. return
  3676. } else {
  3677. order.IsUploadOrderInfo = 1
  3678. service.UpdateOrder(order)
  3679. c.ServeSuccessJSON(map[string]interface{}{
  3680. "msg": "上传成功",
  3681. })
  3682. }
  3683. }
  3684. func (c *HisApiController) Get4202() {
  3685. order_id, _ := c.GetInt64("order_id")
  3686. admin_user_id, _ := c.GetInt64("admin_user_id")
  3687. order, _ := service.GetHisOrderByIDTwo(order_id)
  3688. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3691. if order.ID == 0 {
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3693. return
  3694. }
  3695. var struct4202 models.Struct4202
  3696. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  3697. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  3698. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  3699. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  3700. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  3701. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  3702. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  3703. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  3704. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  3705. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3706. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  3707. var config []*models.HisXtDiagnoseConfig
  3708. for _, item := range diagnosis_ids {
  3709. id, _ := strconv.ParseInt(item, 10, 64)
  3710. diagnosisConfig, _ := service.FindDiagnoseById(id)
  3711. config = append(config, &diagnosisConfig)
  3712. }
  3713. var tempDiaginfos []models.OwnPayPatnDiagListD
  3714. for index, item := range config {
  3715. if index == 0 {
  3716. var tempDiaginfo models.OwnPayPatnDiagListD
  3717. tempDiaginfo.InoutDiagType = "1"
  3718. tempDiaginfo.DiagCode = item.CountryCode
  3719. tempDiaginfo.DiagName = item.CountryContentName
  3720. tempDiaginfo.DiagType = "1"
  3721. tempDiaginfo.DiagSrtNo = "1"
  3722. tempDiaginfo.MaindiagFlag = "1"
  3723. tempDiaginfo.ValiFlag = "1"
  3724. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3725. } else {
  3726. var tempDiaginfo models.OwnPayPatnDiagListD
  3727. tempDiaginfo.DiagCode = item.CountryCode
  3728. tempDiaginfo.DiagName = item.CountryContentName
  3729. tempDiaginfo.DiagType = "2"
  3730. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  3731. tempDiaginfo.MaindiagFlag = "0"
  3732. tempDiaginfo.ValiFlag = "1"
  3733. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3734. }
  3735. }
  3736. struct4202.ODiagListD = tempDiaginfos
  3737. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  3738. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  3739. var res2 ResultSix
  3740. var respJSON2 map[string]interface{}
  3741. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3742. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3744. return
  3745. }
  3746. userJSONBytes2, _ := json.Marshal(respJSON2)
  3747. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3748. utils.ErrorLog("解析失败:%v", err)
  3749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3750. return
  3751. }
  3752. if res2.Infcode != 0 {
  3753. c.ServeSuccessJSON(map[string]interface{}{
  3754. "failed_code": -10,
  3755. "msg": res2.ErrMsg,
  3756. })
  3757. return
  3758. } else {
  3759. order.IsUploadDiagnose = 1
  3760. service.UpdateOrder(order)
  3761. c.ServeSuccessJSON(map[string]interface{}{
  3762. "msg": "上传成功",
  3763. })
  3764. }
  3765. }
  3766. func (c *HisApiController) Get4203() {
  3767. admin_user_id, _ := c.GetInt64("admin_user_id")
  3768. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3769. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3770. order_id, _ := c.GetInt64("order_id")
  3771. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3772. number := ""
  3773. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3774. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  3775. if his.ID == 0 {
  3776. number = hospital.Number
  3777. } else {
  3778. number = his.Number
  3779. }
  3780. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  3781. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  3782. var res2 ResultSix
  3783. var respJSON2 map[string]interface{}
  3784. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  3785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3787. return
  3788. }
  3789. userJSONBytes2, _ := json.Marshal(respJSON2)
  3790. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  3791. utils.ErrorLog("解析失败:%v", err)
  3792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3793. return
  3794. }
  3795. if res2.Infcode != 0 {
  3796. c.ServeSuccessJSON(map[string]interface{}{
  3797. "failed_code": -10,
  3798. "msg": res2.ErrMsg,
  3799. })
  3800. return
  3801. } else {
  3802. order.IsUploadSuccess = 1
  3803. service.UpdateOrderTwo(order)
  3804. c.ServeSuccessJSON(map[string]interface{}{
  3805. "msg": "上传成功",
  3806. })
  3807. }
  3808. }
  3809. func (c *HisApiController) Get4205() {
  3810. order_id, _ := c.GetInt64("order_id")
  3811. admin_user_id, _ := c.GetInt64("admin_user_id")
  3812. fapiao_code := c.GetString("fapiao_code")
  3813. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  3814. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  3815. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3816. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3817. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  3818. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  3819. //order_info = append(order_info, order_info_two...)
  3820. department, _ := service.GetDepartMentDetail(his.Departments)
  3821. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  3822. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  3823. if order.ID == 0 {
  3824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  3825. return
  3826. }
  3827. var struct4201A models.Struct4201A
  3828. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  3829. for _, items := range order_info {
  3830. memo := make(map[string]interface{})
  3831. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3832. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3833. fsiOPFLD.MedType = pre.MedType
  3834. fsiOPFLD.FixmedinsCode = miConfig.Code
  3835. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3836. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3837. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3838. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3839. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3840. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3841. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3842. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  3843. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3844. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3845. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3846. fsiOPFLD.BilgDeptName = department.Name
  3847. fsiOPFLD.BilgDeptCodg = department.Number
  3848. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3849. fsiOPFLD.BilgDrName = doctor.UserName
  3850. fsiOPFLD.MedChrgitmType = "09"
  3851. memo["hosp_appr_flag"] = "1"
  3852. memo["invoice_no"] = fapiao_code
  3853. memo["memo"] = "自费"
  3854. bytesData, _ := json.Marshal(memo)
  3855. fsiOPFLD.Memo = string(bytesData)
  3856. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3857. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3858. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3859. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3860. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3861. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3862. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3863. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3864. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3865. fsiOPFLD.BilgDeptName = department.Name
  3866. fsiOPFLD.BilgDeptCodg = department.Number
  3867. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3868. fsiOPFLD.BilgDrName = doctor.UserName
  3869. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3870. case 0:
  3871. break
  3872. case 1:
  3873. fsiOPFLD.MedChrgitmType = "14"
  3874. break
  3875. case 2:
  3876. fsiOPFLD.MedChrgitmType = "05"
  3877. break
  3878. case 3:
  3879. fsiOPFLD.MedChrgitmType = "03"
  3880. break
  3881. case 4:
  3882. fsiOPFLD.MedChrgitmType = "03"
  3883. break
  3884. case 5:
  3885. fsiOPFLD.MedChrgitmType = "08"
  3886. break
  3887. case 6:
  3888. fsiOPFLD.MedChrgitmType = "14"
  3889. break
  3890. case 7:
  3891. fsiOPFLD.MedChrgitmType = "14"
  3892. break
  3893. case 8:
  3894. fsiOPFLD.MedChrgitmType = "03"
  3895. break
  3896. case 9:
  3897. fsiOPFLD.MedChrgitmType = "14"
  3898. break
  3899. case 10:
  3900. fsiOPFLD.MedChrgitmType = "14"
  3901. break
  3902. case 11:
  3903. fsiOPFLD.MedChrgitmType = "06"
  3904. break
  3905. case 12:
  3906. fsiOPFLD.MedChrgitmType = "12"
  3907. break
  3908. case 13:
  3909. fsiOPFLD.MedChrgitmType = "01"
  3910. break
  3911. case 14:
  3912. fsiOPFLD.MedChrgitmType = "04"
  3913. break
  3914. case 15:
  3915. fsiOPFLD.MedChrgitmType = "14"
  3916. break
  3917. }
  3918. memo["hosp_appr_flag"] = "1"
  3919. memo["invoice_no"] = fapiao_code
  3920. memo["memo"] = "自费"
  3921. bytesData, _ := json.Marshal(memo)
  3922. fsiOPFLD.Memo = string(bytesData)
  3923. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3924. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  3925. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3926. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3927. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  3928. fsiOPFLD.BilgDeptName = department.Name
  3929. fsiOPFLD.BilgDeptCodg = department.Number
  3930. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3931. fsiOPFLD.BilgDrName = doctor.UserName
  3932. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  3933. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  3934. fsiOPFLD.MedChrgitmType = "08"
  3935. memo["hosp_appr_flag"] = "1"
  3936. memo["invoice_no"] = fapiao_code
  3937. memo["memo"] = "自费"
  3938. bytesData, _ := json.Marshal(memo)
  3939. fsiOPFLD.Memo = string(bytesData)
  3940. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3941. }
  3942. }
  3943. }
  3944. for _, items := range order_info_two {
  3945. memo := make(map[string]interface{})
  3946. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  3947. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  3948. fsiOPFLD.MedType = pre.MedType
  3949. fsiOPFLD.BkkpSn = items.FeedetlSn
  3950. fsiOPFLD.FixmedinsCode = miConfig.Code
  3951. fsiOPFLD.FixmedinsName = miConfig.OrgName
  3952. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  3953. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  3954. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  3955. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  3956. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  3957. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3958. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  3959. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3960. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  3961. fsiOPFLD.BilgDeptName = department.Name
  3962. fsiOPFLD.BilgDeptCodg = department.Number
  3963. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3964. fsiOPFLD.BilgDrName = doctor.UserName
  3965. fsiOPFLD.MedChrgitmType = "09"
  3966. memo["hosp_appr_flag"] = "1"
  3967. memo["invoice_no"] = fapiao_code
  3968. memo["memo"] = "自费"
  3969. bytesData, _ := json.Marshal(memo)
  3970. fsiOPFLD.Memo = string(bytesData)
  3971. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  3972. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  3973. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  3974. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  3975. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  3976. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3977. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  3978. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  3979. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  3980. fsiOPFLD.BilgDeptName = department.Name
  3981. fsiOPFLD.BilgDeptCodg = department.Number
  3982. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  3983. fsiOPFLD.BilgDrName = doctor.UserName
  3984. switch items.HisPrescriptionProject.HisProject.CostClassify {
  3985. case 0:
  3986. break
  3987. case 1:
  3988. fsiOPFLD.MedChrgitmType = "14"
  3989. break
  3990. case 2:
  3991. fsiOPFLD.MedChrgitmType = "05"
  3992. break
  3993. case 3:
  3994. fsiOPFLD.MedChrgitmType = "03"
  3995. break
  3996. case 4:
  3997. fsiOPFLD.MedChrgitmType = "03"
  3998. break
  3999. case 5:
  4000. fsiOPFLD.MedChrgitmType = "08"
  4001. break
  4002. case 6:
  4003. fsiOPFLD.MedChrgitmType = "14"
  4004. break
  4005. case 7:
  4006. fsiOPFLD.MedChrgitmType = "14"
  4007. break
  4008. case 8:
  4009. fsiOPFLD.MedChrgitmType = "03"
  4010. break
  4011. case 9:
  4012. fsiOPFLD.MedChrgitmType = "14"
  4013. break
  4014. case 10:
  4015. fsiOPFLD.MedChrgitmType = "14"
  4016. break
  4017. case 11:
  4018. fsiOPFLD.MedChrgitmType = "06"
  4019. break
  4020. case 12:
  4021. fsiOPFLD.MedChrgitmType = "12"
  4022. break
  4023. case 13:
  4024. fsiOPFLD.MedChrgitmType = "01"
  4025. break
  4026. case 14:
  4027. fsiOPFLD.MedChrgitmType = "04"
  4028. break
  4029. case 15:
  4030. fsiOPFLD.MedChrgitmType = "14"
  4031. break
  4032. }
  4033. memo["hosp_appr_flag"] = "1"
  4034. memo["invoice_no"] = fapiao_code
  4035. memo["memo"] = "自费"
  4036. bytesData, _ := json.Marshal(memo)
  4037. fsiOPFLD.Memo = string(bytesData)
  4038. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4039. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  4040. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  4041. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4042. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  4043. fsiOPFLD.BilgDeptName = department.Name
  4044. fsiOPFLD.BilgDeptCodg = department.Number
  4045. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  4046. fsiOPFLD.BilgDrName = doctor.UserName
  4047. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  4048. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  4049. fsiOPFLD.MedChrgitmType = "08"
  4050. memo["hosp_appr_flag"] = "1"
  4051. memo["invoice_no"] = fapiao_code
  4052. memo["memo"] = "自费"
  4053. bytesData, _ := json.Marshal(memo)
  4054. fsiOPFLD.Memo = string(bytesData)
  4055. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  4056. }
  4057. }
  4058. }
  4059. fmt.Println(fsiOPFLDs)
  4060. struct4201A.Fopfd = fsiOPFLDs
  4061. fmt.Println(struct4201A.Fopfd)
  4062. var struct4202 models.Struct4202
  4063. timeLayout := "2006-01-02 15:04:05"
  4064. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  4065. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  4066. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  4067. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  4068. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  4069. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  4070. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  4071. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  4072. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  4073. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  4074. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  4075. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4076. var config []*models.HisXtDiagnoseConfig
  4077. for _, item := range diagnosis_ids {
  4078. id, _ := strconv.ParseInt(item, 10, 64)
  4079. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4080. config = append(config, &diagnosisConfig)
  4081. }
  4082. var tempDiaginfos []models.OwnPayPatnDiagListD
  4083. for index, item := range config {
  4084. if index == 0 {
  4085. var tempDiaginfo models.OwnPayPatnDiagListD
  4086. tempDiaginfo.InoutDiagType = "1"
  4087. tempDiaginfo.DiagCode = item.CountryCode
  4088. tempDiaginfo.DiagName = item.CountryContentName
  4089. tempDiaginfo.DiagType = "1"
  4090. tempDiaginfo.DiagSrtNo = "1"
  4091. tempDiaginfo.MaindiagFlag = "1"
  4092. tempDiaginfo.ValiFlag = "1"
  4093. tempDiaginfo.DiagDrName = doctor.UserName
  4094. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4095. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4096. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4097. } else {
  4098. var tempDiaginfo models.OwnPayPatnDiagListD
  4099. tempDiaginfo.DiagCode = item.CountryCode
  4100. tempDiaginfo.DiagName = item.CountryContentName
  4101. tempDiaginfo.DiagType = "2"
  4102. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  4103. tempDiaginfo.MaindiagFlag = "0"
  4104. tempDiaginfo.ValiFlag = "1"
  4105. tempDiaginfo.DiagDrName = doctor.UserName
  4106. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  4107. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  4108. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  4109. }
  4110. }
  4111. struct4202.ODiagListD = tempDiaginfos
  4112. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  4113. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  4114. var res2 ResultSix
  4115. var respJSON2 map[string]interface{}
  4116. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4119. return
  4120. }
  4121. userJSONBytes2, _ := json.Marshal(respJSON2)
  4122. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4123. utils.ErrorLog("解析失败:%v", err)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. if res2.Infcode != 0 {
  4128. c.ServeSuccessJSON(map[string]interface{}{
  4129. "failed_code": -10,
  4130. "msg": res2.ErrMsg,
  4131. })
  4132. return
  4133. } else {
  4134. order.IsUploadDiagnose = 1
  4135. order.IsUploadOrderInfo = 1
  4136. service.UpdateOrderTwo(order)
  4137. c.ServeSuccessJSON(map[string]interface{}{
  4138. "msg": "上传成功",
  4139. })
  4140. }
  4141. }
  4142. func (c *HisApiController) Get4207() {
  4143. admin_user_id, _ := c.GetInt64("admin_user_id")
  4144. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4145. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4146. order_id, _ := c.GetInt64("order_id")
  4147. order, _ := service.GetHisOrderByIDTwo(order_id)
  4148. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4149. var struct4207 models.Struct4207
  4150. struct4207.PageNum = "1"
  4151. struct4207.PageSize = "1000"
  4152. struct4207.FixmedinsCode = miConfig.Code
  4153. struct4207.FixmedinsMdtrtID = order.Number
  4154. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  4155. saveLog(result, requestLog, "4207", "查询")
  4156. var res2 ResultSix
  4157. var respJSON2 map[string]interface{}
  4158. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4161. return
  4162. }
  4163. userJSONBytes2, _ := json.Marshal(respJSON2)
  4164. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4165. utils.ErrorLog("解析失败:%v", err)
  4166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4167. return
  4168. }
  4169. if res2.Infcode != 0 {
  4170. c.ServeSuccessJSON(map[string]interface{}{
  4171. "failed_code": -10,
  4172. "msg": res2.ErrMsg,
  4173. })
  4174. return
  4175. } else {
  4176. c.ServeSuccessJSON(map[string]interface{}{
  4177. "msg": "查询成功",
  4178. })
  4179. }
  4180. }
  4181. func (c *HisApiController) Get4208() {
  4182. admin_user_id, _ := c.GetInt64("admin_user_id")
  4183. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4185. order_id, _ := c.GetInt64("order_id")
  4186. order, _ := service.GetHisOrderByIDTwo(order_id)
  4187. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4188. var struct4208 models.Struct4208
  4189. struct4208.PageNum = "1"
  4190. struct4208.PageSize = "1000"
  4191. struct4208.PsnCertType = "01"
  4192. struct4208.Certno = his.Certno
  4193. struct4208.MedType = order.MedType
  4194. struct4208.PsnName = his.Name
  4195. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  4196. saveLog(result, requestLog, "4208", "查询")
  4197. var res2 ResultSix
  4198. var respJSON2 map[string]interface{}
  4199. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4200. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4202. return
  4203. }
  4204. userJSONBytes2, _ := json.Marshal(respJSON2)
  4205. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4206. utils.ErrorLog("解析失败:%v", err)
  4207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4208. return
  4209. }
  4210. if res2.Infcode != 0 {
  4211. c.ServeSuccessJSON(map[string]interface{}{
  4212. "failed_code": -10,
  4213. "msg": res2.ErrMsg,
  4214. })
  4215. return
  4216. } else {
  4217. c.ServeSuccessJSON(map[string]interface{}{
  4218. "msg": "查询成功",
  4219. })
  4220. }
  4221. }
  4222. func (c *HisApiController) Get4209() {
  4223. admin_user_id, _ := c.GetInt64("admin_user_id")
  4224. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4225. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4226. order_id, _ := c.GetInt64("order_id")
  4227. order, _ := service.GetHisOrderByIDTwo(order_id)
  4228. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  4229. var struct4209 models.Struct4209
  4230. struct4209.FixmedinsMdtrtID = order.Number
  4231. struct4209.FixmedinsCode = miConfig.Code
  4232. struct4209.PageSize = "1000"
  4233. struct4209.PageNum = "1"
  4234. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  4235. saveLog(result, requestLog, "4209", "查询")
  4236. var res2 ResultSix
  4237. var respJSON2 map[string]interface{}
  4238. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4239. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4241. return
  4242. }
  4243. userJSONBytes2, _ := json.Marshal(respJSON2)
  4244. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4245. utils.ErrorLog("解析失败:%v", err)
  4246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4247. return
  4248. }
  4249. if res2.Infcode != 0 {
  4250. c.ServeSuccessJSON(map[string]interface{}{
  4251. "failed_code": -10,
  4252. "msg": res2.ErrMsg,
  4253. })
  4254. return
  4255. } else {
  4256. c.ServeSuccessJSON(map[string]interface{}{
  4257. "msg": "查询成功",
  4258. })
  4259. }
  4260. }
  4261. type Result3101 struct {
  4262. Infcode string `json:"infcode"`
  4263. InfRefmsgid string `json:"inf_refmsgid"`
  4264. RefmsgTime string `json:"refmsg_time"`
  4265. RespondTime string `json:"respond_time"`
  4266. Enctype string `json:"enctype"`
  4267. Signtype string `json:"signtype"`
  4268. ErrMsg string `json:"err_msg"`
  4269. Output struct {
  4270. Result []struct {
  4271. JudgeResultDetailDtos []struct {
  4272. VolaItemType string `json:"vola_item_type"`
  4273. MdtrtID string `json:"mdtrt_id"`
  4274. JrdID string `json:"jrd_id"`
  4275. PatnID string `json:"patn_id"`
  4276. RxID string `json:"rx_id"`
  4277. VolaAmt interface{} `json:"vola_amt"`
  4278. } `json:"judge_result_detail_dtos"`
  4279. RuleID string `json:"rule_id"`
  4280. VolaEvid string `json:"vola_evid"`
  4281. MdtrtID string `json:"mdtrt_id"`
  4282. RuleName string `json:"rule_name"`
  4283. VolaAmtStas string `json:"vola_amt_stas"`
  4284. JrID string `json:"jr_id"`
  4285. PatnID string `json:"patn_id"`
  4286. SevDeg string `json:"sev_deg"`
  4287. VolaAmt float64 `json:"vola_amt"`
  4288. VolaBhvrType string `json:"vola_bhvr_type"`
  4289. VolaCont string `json:"vola_cont"`
  4290. } `json:"result"`
  4291. } `json:"output"`
  4292. }
  4293. type Resultgd3101 struct {
  4294. Infcode int64 `json:"infcode"`
  4295. InfRefmsgid string `json:"inf_refmsgid"`
  4296. RefmsgTime string `json:"refmsg_time"`
  4297. RespondTime string `json:"respond_time"`
  4298. Enctype string `json:"enctype"`
  4299. Signtype string `json:"signtype"`
  4300. ErrMsg string `json:"err_msg"`
  4301. Output struct {
  4302. Result []struct {
  4303. JudgeResultDetailDtos []struct {
  4304. VolaItemType string `json:"vola_item_type"`
  4305. MdtrtID string `json:"mdtrt_id"`
  4306. JrdID string `json:"jrd_id"`
  4307. PatnID string `json:"patn_id"`
  4308. RxID string `json:"rx_id"`
  4309. VolaAmt interface{} `json:"vola_amt"`
  4310. } `json:"judge_result_detail_dtos"`
  4311. RuleID string `json:"rule_id"`
  4312. VolaEvid string `json:"vola_evid"`
  4313. MdtrtID string `json:"mdtrt_id"`
  4314. RuleName string `json:"rule_name"`
  4315. VolaAmtStas string `json:"vola_amt_stas"`
  4316. JrID string `json:"jr_id"`
  4317. PatnID string `json:"patn_id"`
  4318. SevDeg string `json:"sev_deg"`
  4319. VolaAmt float64 `json:"vola_amt"`
  4320. VolaBhvrType string `json:"vola_bhvr_type"`
  4321. VolaCont string `json:"vola_cont"`
  4322. } `json:"result"`
  4323. } `json:"output"`
  4324. }
  4325. func (c *HisApiController) ReadEleToken() {
  4326. admin_user_id, _ := c.GetInt64("admin_user_id")
  4327. his_patient_id, _ := c.GetInt64("his_patient_id")
  4328. adminUser := c.GetAdminUserInfo()
  4329. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4330. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4331. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4332. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4333. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4334. if len(tokens) > 0 {
  4335. c.ServeSuccessJSON(map[string]interface{}{
  4336. "msg": "读取成功",
  4337. })
  4338. } else {
  4339. c.ServeSuccessJSON(map[string]interface{}{
  4340. "failed_code": -10,
  4341. "msg": "读取失败",
  4342. })
  4343. }
  4344. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4345. tokens := ReadEleCardforah(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4346. if len(tokens) > 0 {
  4347. c.ServeSuccessJSON(map[string]interface{}{
  4348. "msg": "读取成功",
  4349. })
  4350. } else {
  4351. c.ServeSuccessJSON(map[string]interface{}{
  4352. "failed_code": -10,
  4353. "msg": "读取失败",
  4354. })
  4355. }
  4356. } else if miConfig.MdtrtareaAdmvs == "150499" {
  4357. var api string
  4358. 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 +
  4359. "&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"
  4360. resp, requestErr := http.Get(api)
  4361. if requestErr != nil {
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4363. }
  4364. body, ioErr := ioutil.ReadAll(resp.Body)
  4365. if ioErr != nil {
  4366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4368. }
  4369. var respJSON map[string]interface{}
  4370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4373. return
  4374. }
  4375. var status string
  4376. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4377. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4378. var token string
  4379. var res ResultTwo //1101结果
  4380. var res10265 ResultTwo10265 //1101结果
  4381. if status == "0" { //读卡成功
  4382. var card_info string //卡信息
  4383. var busi_card_info string
  4384. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4385. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4386. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4387. fmt.Println(card_info)
  4388. fmt.Println(busi_card_info)
  4389. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4390. result, _ := json.Marshal(respJSON)
  4391. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4392. utils.ErrorLog("解析失败:%v", err)
  4393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4394. return
  4395. }
  4396. res.ErrMsg = res10265.ErrMsg
  4397. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4398. res.Infcode = infocode
  4399. res.Output = res10265.Output
  4400. res.InfRefmsgid = res10265.InfRefmsgid
  4401. if res.Infcode == 0 {
  4402. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4403. if err == gorm.ErrRecordNotFound {
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4405. return
  4406. } else if err != nil {
  4407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4408. return
  4409. } else {
  4410. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4411. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4412. infoStr := string(Iinfos)
  4413. idetinfoStr := string(Idetinfos)
  4414. //date,age,_ := GetBirthdateAndAge(res.Output.Baseinfo.Certno),
  4415. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  4416. psn := &models.HisPsn{
  4417. PsnNo: res.Output.Baseinfo.PsnNo,
  4418. PatientId: patient.ID,
  4419. Certno: res.Output.Baseinfo.Certno,
  4420. Gend: res.Output.Baseinfo.Gend,
  4421. Naty: res.Output.Baseinfo.Naty,
  4422. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4423. PsnName: res.Output.Baseinfo.PsnName,
  4424. Age: float64(age),
  4425. Brdy: b,
  4426. Idetinfo: idetinfoStr,
  4427. Insuinfo: infoStr,
  4428. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4429. CardInfo: card_info,
  4430. VerifyNumber: token,
  4431. IdCardType: 4,
  4432. }
  4433. var rf []*ResultFive
  4434. json.Unmarshal([]byte(infoStr), &rf)
  4435. var insutypes []*ResultFive
  4436. var insutype string
  4437. var is390 int = 0
  4438. var is310 int = 0
  4439. for _, item := range rf {
  4440. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4441. insutypes = append(insutypes, item)
  4442. }
  4443. }
  4444. if len(insutypes) == 1 {
  4445. insutype = insutypes[0].Insutype
  4446. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4447. } else {
  4448. for _, i := range insutypes {
  4449. if i.Insutype == "390" {
  4450. is390 = 1
  4451. }
  4452. if i.Insutype == "310" {
  4453. is310 = 1
  4454. }
  4455. }
  4456. }
  4457. if is390 == 1 {
  4458. insutype = "390"
  4459. }
  4460. if is310 == 1 {
  4461. insutype = "310"
  4462. }
  4463. if len(insutypes) == 0 {
  4464. insutype = "310"
  4465. }
  4466. service.CreateHisPsn(psn)
  4467. c.ServeSuccessJSON(map[string]interface{}{
  4468. "patient": patient,
  4469. "number": token,
  4470. "insutype": insutype,
  4471. })
  4472. }
  4473. } else {
  4474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4475. return
  4476. }
  4477. } else { //读卡失败
  4478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4479. return
  4480. }
  4481. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4482. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  4483. if len(errMsg) == 0 {
  4484. type ELeData struct {
  4485. Data struct {
  4486. IdNo string `json:"idNo"`
  4487. IdType string `json:"idType"`
  4488. UserName string `json:"userName"`
  4489. EcToken string `json:"ecToken"`
  4490. InsuOrg string `json:"insuOrg"`
  4491. Gender string `json:"gender"`
  4492. Birthday string `json:"birthday"`
  4493. Nationality string `json:"nationality"`
  4494. Email string `json:"email"`
  4495. Extra string `json:"extra"`
  4496. } `json:"data"`
  4497. Code int `json:"code"`
  4498. Message string `json:"message"`
  4499. }
  4500. var ele ELeData
  4501. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4502. if err != nil {
  4503. utils.ErrorLog("解析失败:%v", err)
  4504. }
  4505. token := ele.Data.EcToken
  4506. if len(token) > 0 {
  4507. psn := &models.HisPsn{
  4508. PsnNo: his.PsnNo,
  4509. Age: 0,
  4510. PatientId: his.PatientId,
  4511. Certno: his.Certno,
  4512. Brdy: his.Brdy,
  4513. Gend: his.Gend,
  4514. Naty: his.Naty,
  4515. PsnCertType: his.PsnCertType,
  4516. PsnName: his.PsnName,
  4517. Idetinfo: his.Idetinfo,
  4518. Insuinfo: his.Iinfo,
  4519. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4520. CardInfo: outPutInfo,
  4521. VerifyNumber: token,
  4522. }
  4523. service.CreateHisPsn(psn)
  4524. }
  4525. if len(token) > 0 {
  4526. c.ServeSuccessJSON(map[string]interface{}{
  4527. "msg": "读取成功",
  4528. })
  4529. } else {
  4530. c.ServeSuccessJSON(map[string]interface{}{
  4531. "failed_code": -10,
  4532. "msg": "读取失败",
  4533. })
  4534. }
  4535. }
  4536. } else if miConfig.MdtrtareaAdmvs == "360302" {
  4537. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4538. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4539. type ELeData struct {
  4540. Data struct {
  4541. IdNo string `json:"idNo"`
  4542. IdType string `json:"idType"`
  4543. UserName string `json:"userName"`
  4544. EcToken string `json:"ecToken"`
  4545. InsuOrg string `json:"insuOrg"`
  4546. Gender string `json:"gender"`
  4547. Birthday string `json:"birthday"`
  4548. Nationality string `json:"nationality"`
  4549. Email string `json:"email"`
  4550. Extra string `json:"extra"`
  4551. } `json:"data"`
  4552. Code int `json:"code"`
  4553. Message string `json:"message"`
  4554. }
  4555. var ele ELeData
  4556. err := json.Unmarshal([]byte(result), &ele)
  4557. if err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. }
  4560. token := ele.Data.EcToken
  4561. token = Remove0000(token)
  4562. fmt.Println(ele.Data.UserName)
  4563. 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)
  4564. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4565. var res ResultTwo
  4566. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4567. utils.ErrorLog("解析失败:%v", err)
  4568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4569. return
  4570. }
  4571. if res.Infcode == 0 {
  4572. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4573. if err == gorm.ErrRecordNotFound {
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4575. return
  4576. } else if err != nil {
  4577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4578. return
  4579. } else {
  4580. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4581. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4582. infoStr := string(Iinfos)
  4583. idetinfoStr := string(Idetinfos)
  4584. psn := &models.HisPsn{
  4585. PsnNo: res.Output.Baseinfo.PsnNo,
  4586. PatientId: patient.ID,
  4587. Certno: res.Output.Baseinfo.Certno,
  4588. Gend: res.Output.Baseinfo.Gend,
  4589. Naty: res.Output.Baseinfo.Naty,
  4590. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4591. PsnName: res.Output.Baseinfo.PsnName,
  4592. Idetinfo: idetinfoStr,
  4593. Insuinfo: infoStr,
  4594. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4595. CardInfo: "",
  4596. VerifyNumber: token,
  4597. }
  4598. service.CreateHisPsn(psn)
  4599. c.ServeSuccessJSON(map[string]interface{}{
  4600. "patient": patient,
  4601. "number": token,
  4602. })
  4603. }
  4604. } else {
  4605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4606. return
  4607. }
  4608. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4609. idNo := c.GetString("idNo")
  4610. userName := c.GetString("userName")
  4611. ecToken := c.GetString("ecToken")
  4612. insuOrg := c.GetString("insuOrg")
  4613. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4614. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4615. var res ResultTwo
  4616. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4617. utils.ErrorLog("解析失败:%v", err)
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4619. return
  4620. }
  4621. if res.Infcode == 0 {
  4622. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4623. if err == gorm.ErrRecordNotFound {
  4624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4625. return
  4626. } else if err != nil {
  4627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4628. return
  4629. } else {
  4630. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4631. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4632. infoStr := string(Iinfos)
  4633. idetinfoStr := string(Idetinfos)
  4634. psn := &models.HisPsn{
  4635. PsnNo: res.Output.Baseinfo.PsnNo,
  4636. PatientId: patient.ID,
  4637. Certno: res.Output.Baseinfo.Certno,
  4638. Gend: res.Output.Baseinfo.Gend,
  4639. Naty: res.Output.Baseinfo.Naty,
  4640. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4641. PsnName: res.Output.Baseinfo.PsnName,
  4642. Idetinfo: idetinfoStr,
  4643. Insuinfo: infoStr,
  4644. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4645. CardInfo: "",
  4646. VerifyNumber: ecToken,
  4647. InsuplcAdmdvs: insuOrg,
  4648. }
  4649. service.CreateHisPsn(psn)
  4650. c.ServeSuccessJSON(map[string]interface{}{
  4651. "patient": patient,
  4652. "number": ecToken,
  4653. })
  4654. }
  4655. } else {
  4656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4657. return
  4658. }
  4659. } else if miConfig.MdtrtareaAdmvs == "450721" {
  4660. res := c.GetoleInfo()
  4661. if res.Infcode == 0 {
  4662. var result string
  4663. if res.Output.MdtrtCertType == "01" {
  4664. 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)
  4665. } else if res.Output.MdtrtCertType == "02" {
  4666. 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)
  4667. } else if res.Output.MdtrtCertType == "03" {
  4668. 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)
  4669. }
  4670. var dat map[string]interface{}
  4671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4672. fmt.Println(dat)
  4673. } else {
  4674. fmt.Println(err)
  4675. }
  4676. userJSONBytes, _ := json.Marshal(dat)
  4677. var res2 ResultTwo
  4678. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4679. utils.ErrorLog("解析失败:%v", err)
  4680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4681. return
  4682. }
  4683. if res2.Infcode == 0 {
  4684. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  4685. if err == gorm.ErrRecordNotFound {
  4686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4687. return
  4688. } else if err != nil {
  4689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4690. return
  4691. } else {
  4692. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  4693. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  4694. infoStr := string(Iinfos)
  4695. idetinfoStr := string(Idetinfos)
  4696. var rf []*ResultFive
  4697. json.Unmarshal([]byte(infoStr), &rf)
  4698. var insutypes []*ResultFive
  4699. var insutype string
  4700. var is390 int = 0
  4701. var is310 int = 0
  4702. //var insuplc_admdvs string
  4703. for _, item := range rf {
  4704. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4705. insutypes = append(insutypes, item)
  4706. }
  4707. }
  4708. if len(insutypes) == 1 {
  4709. insutype = insutypes[0].Insutype
  4710. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4711. } else {
  4712. for _, i := range insutypes {
  4713. if i.Insutype == "390" {
  4714. is390 = 1
  4715. }
  4716. if i.Insutype == "310" {
  4717. is310 = 1
  4718. }
  4719. }
  4720. }
  4721. if is390 == 1 {
  4722. insutype = "390"
  4723. }
  4724. if is310 == 1 {
  4725. insutype = "310"
  4726. }
  4727. if len(insutypes) == 0 {
  4728. insutype = "310"
  4729. }
  4730. psn := &models.HisPsn{
  4731. PsnNo: res2.Output.Baseinfo.PsnNo,
  4732. PatientId: patient.ID,
  4733. Certno: res2.Output.Baseinfo.Certno,
  4734. Gend: res2.Output.Baseinfo.Gend,
  4735. Naty: res2.Output.Baseinfo.Naty,
  4736. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  4737. PsnName: res2.Output.Baseinfo.PsnName,
  4738. Idetinfo: idetinfoStr,
  4739. Insuinfo: infoStr,
  4740. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4741. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  4742. VerifyNumber: res.Output.EcToken,
  4743. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  4744. }
  4745. service.CreateHisPsn(psn)
  4746. c.ServeSuccessJSON(map[string]interface{}{
  4747. "patient": patient,
  4748. "number": res.Output.CardNo,
  4749. "insutype": insutype,
  4750. })
  4751. }
  4752. } else {
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4754. return
  4755. }
  4756. } else {
  4757. c.ServeSuccessJSON(map[string]interface{}{
  4758. "failed_code": -10,
  4759. "msg": res.ErrMsg,
  4760. })
  4761. }
  4762. } else {
  4763. //if initFlag == 0 {
  4764. // c.TestGetBasBaseInit()
  4765. //}
  4766. //token := c.GetEleBaseInfo()
  4767. //token = Remove0000(token)
  4768. type ELeData struct {
  4769. Code string `json:"code"`
  4770. Data struct {
  4771. Aac002 string `json:"aac002"`
  4772. Aaz500 string `json:"aaz500"`
  4773. ActCardNo string `json:"actCardNo"`
  4774. Bab520 string `json:"bab520"`
  4775. Bkz543 string `json:"bkz543"`
  4776. BusinessType string `json:"businessType"`
  4777. CertfCodg string `json:"certfCodg"`
  4778. EcIndexNo string `json:"ecIndexNo"`
  4779. EcToken string `json:"ecToken"`
  4780. ID0000 string `json:"id0000"`
  4781. IDNo string `json:"idNo"`
  4782. IDType string `json:"idType"`
  4783. Idcode string `json:"idcode"`
  4784. IdentityToken string `json:"identity_token"`
  4785. InsuOrg string `json:"insuOrg"`
  4786. OfficeID string `json:"officeId"`
  4787. OfficeName string `json:"officeName"`
  4788. OperatorID string `json:"operatorId"`
  4789. OperatorName string `json:"operatorName"`
  4790. OrgID string `json:"orgId"`
  4791. UserName string `json:"userName"`
  4792. } `json:"data"`
  4793. Infno interface{} `json:"infno"`
  4794. Message string `json:"message"`
  4795. OrgID string `json:"orgId"`
  4796. TransType string `json:"transType"`
  4797. }
  4798. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  4799. fmt.Println(result)
  4800. outPutInfo := Remove0000(result)
  4801. fmt.Println(outPutInfo)
  4802. var ele ELeData
  4803. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4804. if err != nil {
  4805. utils.ErrorLog("解析失败:%v", err)
  4806. }
  4807. token := ele.Data.EcToken
  4808. var result2 string
  4809. var requestLog2 string
  4810. if len(token) > 0 {
  4811. if strings.Contains(ele.Data.IDNo, "HKG") {
  4812. 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)
  4813. } else {
  4814. result2, requestLog2 = service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4815. }
  4816. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4817. var res ResultTwo
  4818. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4819. utils.ErrorLog("解析失败:%v", err)
  4820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4821. return
  4822. }
  4823. if res.Infcode == 0 {
  4824. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4825. if err == gorm.ErrRecordNotFound {
  4826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4827. return
  4828. } else if err != nil {
  4829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4830. return
  4831. } else {
  4832. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4833. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4834. infoStr := string(Iinfos)
  4835. idetinfoStr := string(Idetinfos)
  4836. psn := &models.HisPsn{
  4837. PsnNo: res.Output.Baseinfo.PsnNo,
  4838. PatientId: patient.ID,
  4839. Certno: res.Output.Baseinfo.Certno,
  4840. Gend: res.Output.Baseinfo.Gend,
  4841. Naty: res.Output.Baseinfo.Naty,
  4842. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4843. PsnName: res.Output.Baseinfo.PsnName,
  4844. Idetinfo: idetinfoStr,
  4845. Insuinfo: infoStr,
  4846. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4847. CardInfo: "",
  4848. VerifyNumber: token,
  4849. }
  4850. service.CreateHisPsn(psn)
  4851. c.ServeSuccessJSON(map[string]interface{}{
  4852. "msg": "读取成功",
  4853. })
  4854. }
  4855. } else {
  4856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4857. return
  4858. }
  4859. } else {
  4860. c.ServeSuccessJSON(map[string]interface{}{
  4861. "failed_code": -10,
  4862. "msg": "读取失败",
  4863. })
  4864. }
  4865. }
  4866. }
  4867. func (c *HisApiController) ReadEleFace() {
  4868. admin_user_id, _ := c.GetInt64("admin_user_id")
  4869. //his_patient_id, _ := c.GetInt64("his_patient_id")
  4870. adminUser := c.GetAdminUserInfo()
  4871. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4872. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4873. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  4874. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4875. tokens := ReadEleFace(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  4876. if len(tokens) > 0 {
  4877. c.ServeSuccessJSON(map[string]interface{}{
  4878. "msg": "读取成功",
  4879. })
  4880. } else {
  4881. c.ServeSuccessJSON(map[string]interface{}{
  4882. "failed_code": -10,
  4883. "msg": "读取失败",
  4884. })
  4885. }
  4886. }
  4887. }
  4888. func (c *HisApiController) Get9001() {
  4889. adminUser := c.GetAdminUserInfo()
  4890. admin_user_id, _ := c.GetInt64("admin_user_id")
  4891. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4892. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4893. if miConfig.MdtrtareaAdmvs == "350500" {
  4894. service.GetFjAuthorizationInfo(miConfig.Code)
  4895. } else if miConfig.MdtrtareaAdmvs == "131023" {
  4896. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  4897. var dat map[string]interface{}
  4898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4899. fmt.Println(dat)
  4900. } else {
  4901. fmt.Println(err)
  4902. }
  4903. userJSONBytes, _ := json.Marshal(dat)
  4904. var res models.Result9001
  4905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4906. utils.ErrorLog("解析失败:%v", err)
  4907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4908. return
  4909. }
  4910. } else if miConfig.MdtrtareaAdmvs == "341203" {
  4911. fmt.Println(miConfig.SecretKey)
  4912. var res models.Result9001Two
  4913. 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 +
  4914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&cainfo=" + miConfig.Cainfo + "&url=" + miConfig.Url
  4915. resp, requestErr := http.Get(api)
  4916. if requestErr != nil {
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. body, ioErr := ioutil.ReadAll(resp.Body)
  4921. if ioErr != nil {
  4922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4924. return
  4925. }
  4926. var respJSON map[string]interface{}
  4927. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4930. return
  4931. }
  4932. status := respJSON["data"].(map[string]interface{})["status"].(string)
  4933. if status == "0" {
  4934. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  4935. c.ServeSuccessJSON(map[string]interface{}{
  4936. "failed_code": -10,
  4937. "msg": err_msg,
  4938. })
  4939. return
  4940. }
  4941. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4942. result, _ := json.Marshal(respJSON)
  4943. fmt.Println("log")
  4944. fmt.Println(string(result))
  4945. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4946. utils.ErrorLog("解析失败:%v", err)
  4947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4948. return
  4949. }
  4950. if res.Infcode == 0 {
  4951. sign := models.HisSignIn{
  4952. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4953. SignNo: res.Output.Signinoutb.SignNo,
  4954. SignTime: "",
  4955. Ctime: time.Now().Unix(),
  4956. Mtime: time.Now().Unix(),
  4957. Status: 1,
  4958. InputLog: "",
  4959. OutputLog: "",
  4960. FixmedinsCode: miConfig.Code,
  4961. }
  4962. err := service.CreateSignIn(&sign)
  4963. if err == nil {
  4964. c.ServeSuccessJSON(map[string]interface{}{
  4965. "msg": "签到成功",
  4966. })
  4967. }
  4968. } else {
  4969. c.ServeSuccessJSON(map[string]interface{}{
  4970. "failed_code": -10,
  4971. "msg": res.ErrMsg,
  4972. })
  4973. return
  4974. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4975. //return
  4976. }
  4977. } else {
  4978. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  4979. var dat map[string]interface{}
  4980. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4981. fmt.Println(dat)
  4982. } else {
  4983. fmt.Println(err)
  4984. }
  4985. userJSONBytes, _ := json.Marshal(dat)
  4986. var res models.Result9001
  4987. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4988. utils.ErrorLog("解析失败:%v", err)
  4989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4990. return
  4991. }
  4992. if res.Infcode == 0 {
  4993. sign := models.HisSignIn{
  4994. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4995. SignNo: res.Output.Signinoutb.SignNo,
  4996. SignTime: res.Output.Signinoutb.SignTime,
  4997. Ctime: time.Now().Unix(),
  4998. Mtime: time.Now().Unix(),
  4999. Status: 1,
  5000. InputLog: "",
  5001. OutputLog: "",
  5002. FixmedinsCode: miConfig.Code,
  5003. }
  5004. err := service.CreateSignIn(&sign)
  5005. if err == nil {
  5006. c.ServeSuccessJSON(map[string]interface{}{
  5007. "msg": "签到成功",
  5008. })
  5009. }
  5010. }
  5011. }
  5012. }
  5013. 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) {
  5014. var res Result3101
  5015. adminUser := c.GetAdminUserInfo()
  5016. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5017. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5018. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5019. //record_time := c.GetString("record_time")
  5020. //trig_scen := c.GetString("trig_scen")
  5021. timeLayout := "2006-01-02"
  5022. loc, _ := time.LoadLocation("Local")
  5023. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5024. if err != nil {
  5025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5026. return res
  5027. }
  5028. recordDateTime := theTime.Unix()
  5029. var patientPrescription models.HisPrescriptionInfo
  5030. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5031. //if patientPrescription.ID == 0 {
  5032. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5033. //}
  5034. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5035. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5036. //
  5037. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5038. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5039. var pp models.PublicParams
  5040. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5041. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5042. pp.FixmedinsName = miConfig.OrgName
  5043. pp.FixmedinsCode = miConfig.Code
  5044. pp.RequestUrl = miConfig.Url
  5045. pp.Cainfo = miConfig.Cainfo
  5046. pp.SecretKey = miConfig.SecretKey
  5047. pp.AccessKey = miConfig.AccessKey
  5048. pp.OpterName = roles.UserName
  5049. var config []*models.HisXtDiagnoseConfig
  5050. for _, item := range diagnosis_ids {
  5051. id, _ := strconv.ParseInt(item, 10, 64)
  5052. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5053. config = append(config, &diagnosisConfig)
  5054. }
  5055. var pd models.PatientDtos
  5056. pd.PatnID = his.PsnNo
  5057. pd.PatnName = his.Name
  5058. pd.Gend = his.Gend
  5059. pd.Brdy = his.Brdy
  5060. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5061. pd.CurrMdtrtID = his.Number
  5062. var fed models.FsiEncounterDtos
  5063. fed.MdtrtID = his.Number
  5064. fed.MedinsID = miConfig.Code
  5065. fed.MedinsName = miConfig.OrgName
  5066. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5067. fed.MedMdtrtType = "1"
  5068. fed.MedinsType = "1"
  5069. fed.MedinsLv = "11"
  5070. tm := time.Unix(his.RecordDate, 0)
  5071. s_tm := tm.Format("2006-01-02 15:04:05")
  5072. fed.AdmDate = s_tm
  5073. fed.DscgDate = s_tm
  5074. fed.DscgMainDiseCodg = config[0].CountryCode
  5075. fed.DscgMainDiseName = config[0].CountryContentName
  5076. //诊断信息
  5077. var fdds []*models.FsiDiagnoseDtos
  5078. for index, item := range config {
  5079. if index == 0 {
  5080. var fdd models.FsiDiagnoseDtos
  5081. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5082. fdd.InoutDiseType = "1"
  5083. fdd.MaindiseFlag = "1"
  5084. fdd.DiseDate = s_tm
  5085. fdd.DiasSrtNo = "1"
  5086. fdd.DiseName = item.CountryContentName
  5087. fdd.DiseCodg = item.CountryCode
  5088. fdds = append(fdds, &fdd)
  5089. } else {
  5090. var fdd models.FsiDiagnoseDtos
  5091. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5092. fdd.InoutDiseType = "1"
  5093. fdd.MaindiseFlag = "1"
  5094. fdd.DiseDate = s_tm
  5095. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5096. fdd.DiseName = item.CountryContentName
  5097. fdd.DiseCodg = item.CountryCode
  5098. fdds = append(fdds, &fdd)
  5099. }
  5100. }
  5101. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5102. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5103. fed.AdmDeptName = department.Name
  5104. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5105. fed.DscgDeptName = department.Name
  5106. fed.MedMdtrtType = "1"
  5107. fed.MedType = "11"
  5108. //if his.Insutype == "390" {
  5109. // fed.MedType = "1402"
  5110. //} else {
  5111. // fed.MedType = "9933"
  5112. //}
  5113. var orders []*models.FsiOrderDtos
  5114. if trig_scen == "2" {
  5115. //处方医嘱信息
  5116. for _, item := range prescriptions {
  5117. for _, subItem := range item.HisDoctorAdviceInfo {
  5118. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5119. var order models.FsiOrderDtos
  5120. order.RxID = strconv.FormatInt(item.ID, 10)
  5121. order.Rxno = strconv.FormatInt(item.ID, 10)
  5122. order.LongDrordFlag = "0"
  5123. order.HilistType = "1"
  5124. order.ChrgType = "1"
  5125. order.DrordBhvr = "-"
  5126. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5127. order.HosplistName = subItem.BaseDrugLib.DrugName
  5128. order.HilistLv = "1"
  5129. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5130. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5131. order.HosplistName = subItem.BaseDrugLib.DrugName
  5132. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5133. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5134. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5135. order.OwnpayAmt = ""
  5136. order.SelfpayAmt = ""
  5137. order.Spec = ""
  5138. order.SpecUnt = ""
  5139. order.DrordBegnDate = s_tm
  5140. order.DrordStopDate = ""
  5141. order.DrordDrCodg = doctor_info.DoctorNumber
  5142. order.DrordDeptName = department.Name
  5143. order.DrordDeptCodg = department.Number
  5144. order.DrordDrName = doctor_info.UserName
  5145. order.DrordDrProfttl = "234"
  5146. order.CurrDrordFlag = "1"
  5147. orders = append(orders, &order)
  5148. }
  5149. }
  5150. for _, subItem := range item.HisPrescriptionProject {
  5151. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5152. var order models.FsiOrderDtos
  5153. order.RxID = strconv.FormatInt(item.ID, 10)
  5154. order.Rxno = strconv.FormatInt(item.ID, 10)
  5155. order.LongDrordFlag = "0"
  5156. order.HilistType = "1"
  5157. order.ChrgType = "1"
  5158. order.DrordBhvr = "-"
  5159. order.HilistCode = subItem.HisProject.MedicalCode
  5160. order.HosplistName = subItem.HisProject.ProjectName
  5161. order.HilistLv = "1"
  5162. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5163. order.HosplistCode = subItem.HisProject.MedicalCode
  5164. order.HosplistName = subItem.HisProject.ProjectName
  5165. order.Cnt = subItem.Count
  5166. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5167. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5168. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5169. order.OwnpayAmt = ""
  5170. order.SelfpayAmt = ""
  5171. order.Spec = ""
  5172. order.SpecUnt = ""
  5173. order.DrordBegnDate = s_tm
  5174. order.DrordStopDate = ""
  5175. order.DrordDrCodg = doctor_info.DoctorNumber
  5176. order.DrordDeptName = department.Name
  5177. order.DrordDeptCodg = department.Number
  5178. order.DrordDrName = doctor_info.UserName
  5179. order.DrordDrProfttl = "234"
  5180. order.CurrDrordFlag = "1"
  5181. orders = append(orders, &order)
  5182. }
  5183. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5184. var order models.FsiOrderDtos
  5185. order.RxID = strconv.FormatInt(item.ID, 10)
  5186. order.Rxno = strconv.FormatInt(item.ID, 10)
  5187. order.LongDrordFlag = "0"
  5188. order.HilistType = "1"
  5189. order.ChrgType = "1"
  5190. order.DrordBhvr = "-"
  5191. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5192. order.HosplistName = subItem.GoodInfo.GoodName
  5193. order.HilistLv = "1"
  5194. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5195. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5196. order.HosplistName = subItem.GoodInfo.GoodName
  5197. order.Cnt = subItem.Count
  5198. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5199. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5200. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5201. order.OwnpayAmt = ""
  5202. order.SelfpayAmt = ""
  5203. order.Spec = ""
  5204. order.SpecUnt = ""
  5205. order.DrordBegnDate = s_tm
  5206. order.DrordStopDate = ""
  5207. order.DrordDrCodg = doctor_info.DoctorNumber
  5208. order.DrordDeptName = department.Name
  5209. order.DrordDeptCodg = department.Number
  5210. order.DrordDrName = doctor_info.UserName
  5211. order.DrordDrProfttl = "234"
  5212. order.CurrDrordFlag = "1"
  5213. orders = append(orders, &order)
  5214. }
  5215. }
  5216. }
  5217. //处方医嘱信息
  5218. }
  5219. fed.MatnStas = "0"
  5220. fed.MedfeeSumamt = "0"
  5221. fed.OwnpayAmt = "0"
  5222. fed.SelfpayAmt = "0"
  5223. fed.AcctPayamt = "0"
  5224. fed.MaAmt = "0"
  5225. fed.HifpPayamt = "0"
  5226. fed.SetlTotlnum = "1"
  5227. fed.Insutype = his.Insutype
  5228. fed.ReimFlag = "0"
  5229. fed.OutSetlFlag = "0"
  5230. var fopd []*models.FsiOperationDtosData
  5231. data := make(map[string]interface{})
  5232. data["fed"] = fed
  5233. data["fdd"] = fdds
  5234. data["fod"] = orders
  5235. data["pd"] = pd
  5236. data["pp"] = pp
  5237. data["fopd"] = fopd
  5238. data["trig_scen"] = trig_scen
  5239. fmt.Println(data)
  5240. fmt.Println(fed)
  5241. fmt.Println(fdds)
  5242. fmt.Println(orders)
  5243. fmt.Println(pd)
  5244. fmt.Println(pp)
  5245. fmt.Println(fopd)
  5246. client := &http.Client{}
  5247. bytesData, _ := json.Marshal(data)
  5248. var req *http.Request
  5249. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5250. if miConfig.MdtrtareaAdmvs == "320921" {
  5251. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5252. } else {
  5253. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5254. }
  5255. resp, _ := client.Do(req)
  5256. defer resp.Body.Close()
  5257. body, ioErr := ioutil.ReadAll(resp.Body)
  5258. if ioErr != nil {
  5259. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5261. return res
  5262. }
  5263. var respJSON map[string]interface{}
  5264. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5265. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5267. return res
  5268. }
  5269. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5270. fmt.Println(respJSON)
  5271. result, _ := json.Marshal(respJSON)
  5272. fmt.Println(result)
  5273. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5274. utils.ErrorLog("解析失败:%v", err)
  5275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5276. return res
  5277. }
  5278. return res
  5279. } else {
  5280. //if miConfig.MdtrtareaAdmvs == "441202" {
  5281. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5282. saveLog(output, input, "3101", "事前")
  5283. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5284. utils.ErrorLog("解析失败:%v", err)
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5286. return
  5287. }
  5288. return res
  5289. //}
  5290. }
  5291. }
  5292. 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) {
  5293. adminUser := c.GetAdminUserInfo()
  5294. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5295. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5296. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5297. //record_time := c.GetString("record_time")
  5298. //trig_scen := c.GetString("trig_scen")
  5299. timeLayout := "2006-01-02"
  5300. loc, _ := time.LoadLocation("Local")
  5301. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5302. if err != nil {
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5304. return res
  5305. }
  5306. recordDateTime := theTime.Unix()
  5307. var patientPrescription models.HisPrescriptionInfo
  5308. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5309. if patientPrescription.ID == 0 {
  5310. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5311. }
  5312. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5313. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5314. //
  5315. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5316. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5317. var pp models.PublicParams
  5318. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5319. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5320. pp.FixmedinsName = miConfig.OrgName
  5321. pp.FixmedinsCode = miConfig.Code
  5322. pp.RequestUrl = miConfig.Url
  5323. pp.Cainfo = miConfig.Cainfo
  5324. pp.SecretKey = miConfig.SecretKey
  5325. pp.AccessKey = miConfig.AccessKey
  5326. pp.OpterName = roles.UserName
  5327. var config []*models.HisXtDiagnoseConfig
  5328. for _, item := range diagnosis_ids {
  5329. id, _ := strconv.ParseInt(item, 10, 64)
  5330. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5331. config = append(config, &diagnosisConfig)
  5332. }
  5333. var pd models.PatientDtos
  5334. pd.PatnID = his.PsnNo
  5335. pd.PatnName = his.Name
  5336. pd.Gend = his.Gend
  5337. pd.Brdy = his.Brdy
  5338. pd.Poolarea = his.InsuplcAdmdvs
  5339. pd.CurrMdtrtID = his.Number
  5340. var fed models.FsiEncounterDtos
  5341. fed.MdtrtID = his.Number
  5342. fed.MedinsID = miConfig.Code
  5343. fed.MedinsName = miConfig.OrgName
  5344. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5345. fed.MedMdtrtType = "1"
  5346. fed.MedinsType = "1"
  5347. fed.MedinsLv = "11"
  5348. tm := time.Unix(his.RecordDate, 0)
  5349. s_tm := tm.Format("2006-01-02 15:04:05")
  5350. fed.AdmDate = s_tm
  5351. fed.DscgDate = s_tm
  5352. fed.DscgMainDiseCodg = config[0].CountryCode
  5353. fed.DscgMainDiseName = config[0].CountryContentName
  5354. //诊断信息
  5355. var fdds []*models.FsiDiagnoseDtos
  5356. for index, item := range config {
  5357. if index == 0 {
  5358. var fdd models.FsiDiagnoseDtos
  5359. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5360. fdd.InoutDiseType = "1"
  5361. fdd.MaindiseFlag = "1"
  5362. fdd.DiseDate = s_tm
  5363. fdd.DiasSrtNo = "1"
  5364. fdd.DiseName = item.CountryContentName
  5365. fdd.DiseCodg = item.CountryCode
  5366. fdds = append(fdds, &fdd)
  5367. } else {
  5368. var fdd models.FsiDiagnoseDtos
  5369. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5370. fdd.InoutDiseType = "1"
  5371. fdd.MaindiseFlag = "1"
  5372. fdd.DiseDate = s_tm
  5373. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5374. fdd.DiseName = item.CountryContentName
  5375. fdd.DiseCodg = item.CountryCode
  5376. fdds = append(fdds, &fdd)
  5377. }
  5378. }
  5379. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5380. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5381. fed.AdmDeptName = department.Name
  5382. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5383. fed.DscgDeptName = department.Name
  5384. fed.MedMdtrtType = "1"
  5385. fed.MedType = "11"
  5386. //if his.Insutype == "390" {
  5387. // fed.MedType = "1402"
  5388. //} else {
  5389. // fed.MedType = "9933"
  5390. //}
  5391. var orders []*models.FsiOrderDtos
  5392. if trig_scen == "2" {
  5393. //处方医嘱信息
  5394. for _, item := range prescriptions {
  5395. for _, subItem := range item.HisDoctorAdviceInfo {
  5396. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5397. var order models.FsiOrderDtos
  5398. order.RxID = strconv.FormatInt(item.ID, 10)
  5399. order.Rxno = strconv.FormatInt(item.ID, 10)
  5400. order.LongDrordFlag = "0"
  5401. order.HilistType = "1"
  5402. order.ChrgType = "1"
  5403. order.DrordBhvr = "-"
  5404. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5405. order.HosplistName = subItem.BaseDrugLib.DrugName
  5406. order.HilistLv = "1"
  5407. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5408. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5409. order.HosplistName = subItem.BaseDrugLib.DrugName
  5410. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5411. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5412. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5413. order.OwnpayAmt = ""
  5414. order.SelfpayAmt = ""
  5415. order.Spec = ""
  5416. order.SpecUnt = ""
  5417. order.DrordBegnDate = s_tm
  5418. order.DrordStopDate = ""
  5419. order.DrordDrCodg = doctor_info.DoctorNumber
  5420. order.DrordDeptName = department.Name
  5421. order.DrordDeptCodg = department.Number
  5422. order.DrordDrName = doctor_info.UserName
  5423. order.DrordDrProfttl = "234"
  5424. order.CurrDrordFlag = "1"
  5425. orders = append(orders, &order)
  5426. }
  5427. }
  5428. for _, subItem := range item.HisPrescriptionProject {
  5429. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5430. var order models.FsiOrderDtos
  5431. order.RxID = strconv.FormatInt(item.ID, 10)
  5432. order.Rxno = strconv.FormatInt(item.ID, 10)
  5433. order.LongDrordFlag = "0"
  5434. order.HilistType = "1"
  5435. order.ChrgType = "1"
  5436. order.DrordBhvr = "-"
  5437. order.HilistCode = subItem.HisProject.MedicalCode
  5438. order.HosplistName = subItem.HisProject.ProjectName
  5439. order.HilistLv = "1"
  5440. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5441. order.HosplistCode = subItem.HisProject.MedicalCode
  5442. order.HosplistName = subItem.HisProject.ProjectName
  5443. order.Cnt = subItem.Count
  5444. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5445. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5446. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5447. order.OwnpayAmt = ""
  5448. order.SelfpayAmt = ""
  5449. order.Spec = ""
  5450. order.SpecUnt = ""
  5451. order.DrordBegnDate = s_tm
  5452. order.DrordStopDate = ""
  5453. order.DrordDrCodg = doctor_info.DoctorNumber
  5454. order.DrordDeptName = department.Name
  5455. order.DrordDeptCodg = department.Number
  5456. order.DrordDrName = doctor_info.UserName
  5457. order.DrordDrProfttl = "234"
  5458. order.CurrDrordFlag = "1"
  5459. orders = append(orders, &order)
  5460. }
  5461. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5462. var order models.FsiOrderDtos
  5463. order.RxID = strconv.FormatInt(item.ID, 10)
  5464. order.Rxno = strconv.FormatInt(item.ID, 10)
  5465. order.LongDrordFlag = "0"
  5466. order.HilistType = "1"
  5467. order.ChrgType = "1"
  5468. order.DrordBhvr = "-"
  5469. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5470. order.HosplistName = subItem.GoodInfo.GoodName
  5471. order.HilistLv = "1"
  5472. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5473. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5474. order.HosplistName = subItem.GoodInfo.GoodName
  5475. order.Cnt = subItem.Count
  5476. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5477. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5478. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5479. order.OwnpayAmt = ""
  5480. order.SelfpayAmt = ""
  5481. order.Spec = ""
  5482. order.SpecUnt = ""
  5483. order.DrordBegnDate = s_tm
  5484. order.DrordStopDate = ""
  5485. order.DrordDrCodg = doctor_info.DoctorNumber
  5486. order.DrordDeptName = department.Name
  5487. order.DrordDeptCodg = department.Number
  5488. order.DrordDrName = doctor_info.UserName
  5489. order.DrordDrProfttl = "234"
  5490. order.CurrDrordFlag = "1"
  5491. orders = append(orders, &order)
  5492. }
  5493. }
  5494. }
  5495. //处方医嘱信息
  5496. }
  5497. fed.MatnStas = "0"
  5498. fed.MedfeeSumamt = "0"
  5499. fed.OwnpayAmt = "0"
  5500. fed.SelfpayAmt = "0"
  5501. fed.AcctPayamt = "0"
  5502. fed.MaAmt = "0"
  5503. fed.HifpPayamt = "0"
  5504. fed.SetlTotlnum = "1"
  5505. fed.Insutype = his.Insutype
  5506. fed.ReimFlag = "0"
  5507. fed.OutSetlFlag = "0"
  5508. var fopd []*models.FsiOperationDtosData
  5509. data := make(map[string]interface{})
  5510. data["fed"] = fed
  5511. data["fdd"] = fdds
  5512. data["fod"] = orders
  5513. data["pd"] = pd
  5514. data["pp"] = pp
  5515. data["fopd"] = fopd
  5516. data["trig_scen"] = trig_scen
  5517. fmt.Println(data)
  5518. fmt.Println(fed)
  5519. fmt.Println(fdds)
  5520. fmt.Println(orders)
  5521. fmt.Println(pd)
  5522. fmt.Println(pp)
  5523. fmt.Println(fopd)
  5524. client := &http.Client{}
  5525. bytesData, _ := json.Marshal(data)
  5526. var req *http.Request
  5527. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5528. if miConfig.MdtrtareaAdmvs == "320921" {
  5529. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5530. } else {
  5531. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  5532. }
  5533. resp, _ := client.Do(req)
  5534. defer resp.Body.Close()
  5535. body, ioErr := ioutil.ReadAll(resp.Body)
  5536. if ioErr != nil {
  5537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5539. return res
  5540. }
  5541. var respJSON map[string]interface{}
  5542. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5545. return res
  5546. }
  5547. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5548. fmt.Println(respJSON)
  5549. result, _ := json.Marshal(respJSON)
  5550. fmt.Println(result)
  5551. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5552. utils.ErrorLog("解析失败:%v", err)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return res
  5555. }
  5556. return res
  5557. } else {
  5558. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5559. saveLog(output, input, "3101", "事前")
  5560. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5561. utils.ErrorLog("解析失败:%v", err)
  5562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5563. return
  5564. }
  5565. return res
  5566. }
  5567. return res
  5568. }
  5569. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  5570. ////patient_id, _ := c.GetInt64("patient_id")
  5571. //order_id, _ := c.GetInt64("order_id")
  5572. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  5573. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  5574. //trig_scen := c.GetString("trig_scen")
  5575. adminUser := c.GetAdminUserInfo()
  5576. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5577. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5578. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5579. record_time := c.GetString("record_time")
  5580. order, _ := service.GetHisOrderByID(order_id)
  5581. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5582. timeLayout := "2006-01-02"
  5583. loc, _ := time.LoadLocation("Local")
  5584. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5585. if err != nil {
  5586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5587. return
  5588. }
  5589. recordDateTime := theTime.Unix()
  5590. var patientPrescription models.HisPrescriptionInfo
  5591. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5592. if patientPrescription.ID == 0 {
  5593. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5594. }
  5595. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5596. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5597. //
  5598. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5599. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5600. var pp models.PublicParams
  5601. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5602. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5603. pp.FixmedinsName = miConfig.OrgName
  5604. pp.FixmedinsCode = miConfig.Code
  5605. pp.RequestUrl = miConfig.Url
  5606. pp.Cainfo = miConfig.Cainfo
  5607. pp.SecretKey = miConfig.SecretKey
  5608. pp.AccessKey = miConfig.AccessKey
  5609. pp.OpterName = roles.UserName
  5610. var config []*models.HisXtDiagnoseConfig
  5611. for _, item := range diagnosis_ids {
  5612. id, _ := strconv.ParseInt(item, 10, 64)
  5613. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5614. config = append(config, &diagnosisConfig)
  5615. }
  5616. var pd models.PatientDtos
  5617. pd.PatnID = his.PsnNo
  5618. pd.PatnName = his.Name
  5619. pd.Gend = his.Gend
  5620. pd.Brdy = psn_info.Brdy
  5621. pd.Poolarea = his.InsuplcAdmdvs
  5622. pd.CurrMdtrtID = his.Number
  5623. var fed models.FsiEncounterDtos
  5624. fed.MdtrtID = his.Number
  5625. fed.MedinsID = miConfig.Code
  5626. fed.MedinsName = miConfig.OrgName
  5627. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5628. fed.MedMdtrtType = "1"
  5629. fed.MedinsType = "1"
  5630. fed.MedinsLv = "11"
  5631. tm := time.Unix(his.RecordDate, 0)
  5632. s_tm := tm.Format("2006-01-02 15:04:05")
  5633. fed.AdmDate = s_tm
  5634. fed.DscgDate = s_tm
  5635. fed.DscgMainDiseCodg = config[0].CountryCode
  5636. fed.DscgMainDiseName = config[0].CountryContentName
  5637. //诊断信息
  5638. var fdds []*models.FsiDiagnoseDtos
  5639. for index, item := range config {
  5640. if index == 0 {
  5641. var fdd models.FsiDiagnoseDtos
  5642. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5643. fdd.InoutDiseType = "1"
  5644. fdd.MaindiseFlag = "1"
  5645. fdd.DiseDate = s_tm
  5646. fdd.DiasSrtNo = "1"
  5647. fdd.DiseName = item.CountryContentName
  5648. fdd.DiseCodg = item.CountryCode
  5649. fdds = append(fdds, &fdd)
  5650. } else {
  5651. var fdd models.FsiDiagnoseDtos
  5652. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  5653. fdd.InoutDiseType = "1"
  5654. fdd.MaindiseFlag = "1"
  5655. fdd.DiseDate = s_tm
  5656. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  5657. fdd.DiseName = item.CountryContentName
  5658. fdd.DiseCodg = item.CountryCode
  5659. fdds = append(fdds, &fdd)
  5660. }
  5661. }
  5662. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  5663. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  5664. fed.AdmDeptName = department.Name
  5665. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  5666. fed.DscgDeptName = department.Name
  5667. fed.MedType = order.MedType
  5668. //处方医嘱信息
  5669. var orders []*models.FsiOrderDtos
  5670. //for _, item := range prescriptions {
  5671. // for _, subItem := range item.HisDoctorAdviceInfo {
  5672. // var order models.FsiOrderDtos
  5673. // order.RxID = strconv.FormatInt(item.ID, 10)
  5674. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5675. // order.LongDrordFlag = "0"
  5676. // order.HilistType = "1"
  5677. // order.ChrgType = "1"
  5678. // order.DrordBhvr = "-"
  5679. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5680. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5681. // order.HilistLv = "1"
  5682. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5683. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5684. // order.HosplistName = subItem.BaseDrugLib.DrugName
  5685. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  5686. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5687. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  5688. // order.OwnpayAmt = ""
  5689. // order.SelfpayAmt = ""
  5690. // order.Spec = ""
  5691. // order.SpecUnt = ""
  5692. // order.DrordBegnDate = s_tm
  5693. // order.DrordStopDate = ""
  5694. // order.DrordDrCodg = "1"
  5695. // order.DrordDeptName = department.Name
  5696. // order.DrordDrCodg = "1"
  5697. // order.DrordDrName = doctor_info.UserName
  5698. // order.DrordDrProfttl = ""
  5699. // order.CurrDrordFlag = "1"
  5700. // orders = append(orders, &order)
  5701. // }
  5702. // for _, subItem := range item.HisPrescriptionProject {
  5703. // if subItem.Type == 2 {
  5704. // var order models.FsiOrderDtos
  5705. // order.RxID = strconv.FormatInt(item.ID, 10)
  5706. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5707. // order.LongDrordFlag = "0"
  5708. // order.HilistType = "1"
  5709. // order.ChrgType = "1"
  5710. // order.DrordBhvr = "-"
  5711. // order.HilistCode = subItem.HisProject.MedicalCode
  5712. // order.HosplistName = subItem.HisProject.ProjectName
  5713. // order.HilistLv = "1"
  5714. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5715. // order.HosplistCode = subItem.HisProject.MedicalCode
  5716. // order.HosplistName = subItem.HisProject.ProjectName
  5717. // order.Cnt = subItem.Count
  5718. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5719. //
  5720. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5721. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5722. // order.OwnpayAmt = ""
  5723. // order.SelfpayAmt = ""
  5724. // order.Spec = ""
  5725. // order.SpecUnt = ""
  5726. // order.DrordBegnDate = s_tm
  5727. // order.DrordStopDate = ""
  5728. // order.DrordDrCodg = "1"
  5729. // order.DrordDeptName = department.Name
  5730. // order.DrordDrCodg = "1"
  5731. // order.DrordDrName = doctor_info.UserName
  5732. // order.DrordDrProfttl = ""
  5733. // order.CurrDrordFlag = "1"
  5734. // orders = append(orders, &order)
  5735. //
  5736. // }
  5737. // if subItem.Type == 3 {
  5738. //
  5739. // var order models.FsiOrderDtos
  5740. // order.RxID = strconv.FormatInt(item.ID, 10)
  5741. // order.Rxno = strconv.FormatInt(item.ID, 10)
  5742. // order.LongDrordFlag = "0"
  5743. // order.HilistType = "1"
  5744. // order.ChrgType = "1"
  5745. // order.DrordBhvr = "-"
  5746. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5747. // order.HosplistName = subItem.GoodInfo.GoodName
  5748. // order.HilistLv = "1"
  5749. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5750. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5751. // order.HosplistName = subItem.GoodInfo.GoodName
  5752. // order.Cnt = subItem.Count
  5753. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5754. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  5755. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  5756. // order.OwnpayAmt = ""
  5757. // order.SelfpayAmt = ""
  5758. // order.Spec = ""
  5759. // order.SpecUnt = ""
  5760. // order.DrordBegnDate = s_tm
  5761. // order.DrordStopDate = ""
  5762. // order.DrordDrCodg = "1"
  5763. // order.DrordDeptName = department.Name
  5764. // order.DrordDrCodg = "1"
  5765. // order.DrordDrName = doctor_info.UserName
  5766. // order.DrordDrProfttl = ""
  5767. // order.CurrDrordFlag = "1"
  5768. // orders = append(orders, &order)
  5769. //
  5770. // }
  5771. // }
  5772. //}
  5773. for _, item := range prescriptions {
  5774. for _, subItem := range item.HisDoctorAdviceInfo {
  5775. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  5776. var order models.FsiOrderDtos
  5777. order.RxID = strconv.FormatInt(item.ID, 10)
  5778. order.Rxno = strconv.FormatInt(item.ID, 10)
  5779. order.LongDrordFlag = "0"
  5780. order.HilistType = "1"
  5781. order.ChrgType = "1"
  5782. order.DrordBhvr = "-"
  5783. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5784. order.HosplistName = subItem.BaseDrugLib.DrugName
  5785. order.HilistLv = "1"
  5786. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5787. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  5788. order.HosplistName = subItem.BaseDrugLib.DrugName
  5789. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  5790. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5791. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  5792. order.OwnpayAmt = ""
  5793. order.SelfpayAmt = ""
  5794. order.Spec = ""
  5795. order.SpecUnt = ""
  5796. order.DrordBegnDate = s_tm
  5797. order.DrordStopDate = ""
  5798. order.DrordDrCodg = doctor_info.DoctorNumber
  5799. order.DrordDeptName = department.Name
  5800. order.DrordDeptCodg = department.Number
  5801. order.DrordDrName = doctor_info.UserName
  5802. order.DrordDrProfttl = "234"
  5803. order.CurrDrordFlag = "1"
  5804. orders = append(orders, &order)
  5805. }
  5806. }
  5807. for _, subItem := range item.HisPrescriptionProject {
  5808. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  5809. var order models.FsiOrderDtos
  5810. order.RxID = strconv.FormatInt(item.ID, 10)
  5811. order.Rxno = strconv.FormatInt(item.ID, 10)
  5812. order.LongDrordFlag = "0"
  5813. order.HilistType = "1"
  5814. order.ChrgType = "1"
  5815. order.DrordBhvr = "-"
  5816. order.HilistCode = subItem.HisProject.MedicalCode
  5817. order.HosplistName = subItem.HisProject.ProjectName
  5818. order.HilistLv = "1"
  5819. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5820. order.HosplistCode = subItem.HisProject.MedicalCode
  5821. order.HosplistName = subItem.HisProject.ProjectName
  5822. order.Cnt = subItem.Count
  5823. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5824. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5825. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5826. order.OwnpayAmt = ""
  5827. order.SelfpayAmt = ""
  5828. order.Spec = ""
  5829. order.SpecUnt = ""
  5830. order.DrordBegnDate = s_tm
  5831. order.DrordStopDate = ""
  5832. order.DrordDrCodg = doctor_info.DoctorNumber
  5833. order.DrordDeptName = department.Name
  5834. order.DrordDeptCodg = department.Number
  5835. order.DrordDrName = doctor_info.UserName
  5836. order.DrordDrProfttl = "234"
  5837. order.CurrDrordFlag = "1"
  5838. orders = append(orders, &order)
  5839. }
  5840. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  5841. var order models.FsiOrderDtos
  5842. order.RxID = strconv.FormatInt(item.ID, 10)
  5843. order.Rxno = strconv.FormatInt(item.ID, 10)
  5844. order.LongDrordFlag = "0"
  5845. order.HilistType = "1"
  5846. order.ChrgType = "1"
  5847. order.DrordBhvr = "0"
  5848. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5849. order.HosplistName = subItem.GoodInfo.GoodName
  5850. order.HilistLv = "1"
  5851. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  5852. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  5853. order.HosplistName = subItem.GoodInfo.GoodName
  5854. order.Cnt = subItem.Count
  5855. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5856. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  5857. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  5858. order.OwnpayAmt = ""
  5859. order.SelfpayAmt = ""
  5860. order.Spec = ""
  5861. order.SpecUnt = ""
  5862. order.DrordBegnDate = s_tm
  5863. order.DrordStopDate = ""
  5864. order.DrordDrCodg = doctor_info.DoctorNumber
  5865. order.DrordDeptName = department.Name
  5866. order.DrordDeptCodg = department.Number
  5867. order.DrordDrName = doctor_info.UserName
  5868. order.DrordDrProfttl = "234"
  5869. order.CurrDrordFlag = "1"
  5870. orders = append(orders, &order)
  5871. }
  5872. }
  5873. }
  5874. //处方医嘱信息
  5875. fed.MatnStas = "0"
  5876. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  5877. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  5878. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  5879. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  5880. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  5881. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  5882. fed.SetlTotlnum = "1"
  5883. fed.Insutype = his.Insutype
  5884. fed.ReimFlag = "0"
  5885. fed.OutSetlFlag = "0"
  5886. var fopd []*models.FsiOperationDtosData
  5887. data := make(map[string]interface{})
  5888. data["fed"] = fed
  5889. data["fdd"] = fdds
  5890. data["fod"] = orders
  5891. data["pd"] = pd
  5892. data["pp"] = pp
  5893. data["fopd"] = fopd
  5894. data["trig_scen"] = trig_scen
  5895. client := &http.Client{}
  5896. bytesData, _ := json.Marshal(data)
  5897. var req *http.Request
  5898. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5899. if miConfig.MdtrtareaAdmvs == "320921" {
  5900. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5901. } else {
  5902. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  5903. }
  5904. resp, _ := client.Do(req)
  5905. defer resp.Body.Close()
  5906. body, ioErr := ioutil.ReadAll(resp.Body)
  5907. if ioErr != nil {
  5908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return res
  5911. }
  5912. var respJSON map[string]interface{}
  5913. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return res
  5917. }
  5918. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5919. result, _ := json.Marshal(respJSON)
  5920. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5921. utils.ErrorLog("解析失败:%v", err)
  5922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5923. return res
  5924. }
  5925. return res
  5926. } else {
  5927. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  5928. saveLog(output, input, "3102", "事中")
  5929. if err := json.Unmarshal([]byte(output), &res); err != nil {
  5930. utils.ErrorLog("解析失败:%v", err)
  5931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5932. return
  5933. }
  5934. return res
  5935. }
  5936. return res
  5937. }
  5938. 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) {
  5939. var res Resultgd3101
  5940. adminUser := c.GetAdminUserInfo()
  5941. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5942. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  5943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5944. //record_time := c.GetString("record_time")
  5945. //trig_scen := c.GetString("trig_scen")
  5946. psn_info, _ := service.GetPsnByPatientId(patient_id)
  5947. timeLayout := "2006-01-02"
  5948. loc, _ := time.LoadLocation("Local")
  5949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5950. if err != nil {
  5951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5952. return res
  5953. }
  5954. recordDateTime := theTime.Unix()
  5955. var patientPrescription models.HisPrescriptionInfo
  5956. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5957. //if patientPrescription.ID == 0 {
  5958. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  5959. //}
  5960. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5961. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5962. //
  5963. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  5964. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5965. var pp models.PublicParams
  5966. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5967. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5968. pp.FixmedinsName = miConfig.OrgName
  5969. pp.FixmedinsCode = miConfig.Code
  5970. pp.RequestUrl = miConfig.Url
  5971. pp.Cainfo = miConfig.Cainfo
  5972. pp.SecretKey = miConfig.SecretKey
  5973. pp.AccessKey = miConfig.AccessKey
  5974. pp.OpterName = roles.UserName
  5975. var config []*models.HisXtDiagnoseConfig
  5976. for _, item := range diagnosis_ids {
  5977. id, _ := strconv.ParseInt(item, 10, 64)
  5978. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5979. config = append(config, &diagnosisConfig)
  5980. }
  5981. var pd models.PatientDtos
  5982. pd.PatnID = his.PsnNo
  5983. pd.PatnName = his.Name
  5984. pd.Gend = his.Gend
  5985. pd.Brdy = psn_info.Brdy
  5986. pd.Poolarea = miConfig.MdtrtareaAdmvs
  5987. pd.CurrMdtrtID = his.Number
  5988. var fed models.FsiEncounterDtos
  5989. fed.MdtrtID = his.Number
  5990. fed.MedinsID = miConfig.Code
  5991. fed.MedinsName = miConfig.OrgName
  5992. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  5993. fed.MedMdtrtType = "1"
  5994. fed.MedinsType = "1"
  5995. fed.MedinsLv = "11"
  5996. tm := time.Unix(his.RecordDate, 0)
  5997. s_tm := tm.Format("2006-01-02 15:04:05")
  5998. fed.AdmDate = s_tm
  5999. fed.DscgDate = s_tm
  6000. fed.DscgMainDiseCodg = config[0].CountryCode
  6001. fed.DscgMainDiseName = config[0].CountryContentName
  6002. //诊断信息
  6003. var fdds []*models.FsiDiagnoseDtos
  6004. for index, item := range config {
  6005. if index == 0 {
  6006. var fdd models.FsiDiagnoseDtos
  6007. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6008. fdd.InoutDiseType = "1"
  6009. fdd.MaindiseFlag = "1"
  6010. fdd.DiseDate = s_tm
  6011. fdd.DiasSrtNo = "1"
  6012. fdd.DiseName = item.CountryContentName
  6013. fdd.DiseCodg = item.CountryCode
  6014. fdds = append(fdds, &fdd)
  6015. } else {
  6016. var fdd models.FsiDiagnoseDtos
  6017. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6018. fdd.InoutDiseType = "1"
  6019. fdd.MaindiseFlag = "1"
  6020. fdd.DiseDate = s_tm
  6021. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6022. fdd.DiseName = item.CountryContentName
  6023. fdd.DiseCodg = item.CountryCode
  6024. fdds = append(fdds, &fdd)
  6025. }
  6026. }
  6027. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6028. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6029. fed.AdmDeptName = department.Name
  6030. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6031. fed.DscgDeptName = department.Name
  6032. fed.MedMdtrtType = "1"
  6033. fed.MedType = "11"
  6034. //if his.Insutype == "390" {
  6035. // fed.MedType = "1402"
  6036. //} else {
  6037. // fed.MedType = "9933"
  6038. //}
  6039. var orders []*models.FsiOrderDtos
  6040. if trig_scen == "2" {
  6041. //处方医嘱信息
  6042. for _, item := range prescriptions {
  6043. for _, subItem := range item.HisDoctorAdviceInfo {
  6044. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6045. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6046. var order models.FsiOrderDtos
  6047. order.RxID = strconv.FormatInt(item.ID, 10)
  6048. order.Rxno = strconv.FormatInt(item.ID, 10)
  6049. order.LongDrordFlag = "0"
  6050. order.HilistType = "1"
  6051. order.ChrgType = "1"
  6052. order.DrordBhvr = "0"
  6053. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6054. order.HosplistName = subItem.BaseDrugLib.DrugName
  6055. order.HilistLv = "1"
  6056. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6057. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6058. order.HosplistName = subItem.BaseDrugLib.DrugName
  6059. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6060. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6061. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6062. order.OwnpayAmt = ""
  6063. order.SelfpayAmt = ""
  6064. order.Spec = spec
  6065. order.SpecUnt = subItem.PrescribingNumberUnit
  6066. order.DrordBegnDate = s_tm
  6067. order.DrordStopDate = ""
  6068. order.DrordDrCodg = doctor_info.DoctorNumber
  6069. order.DrordDeptName = department.Name
  6070. order.DrordDeptCodg = department.Number
  6071. order.DrordDrName = doctor_info.UserName
  6072. order.DrordDrProfttl = "234"
  6073. order.CurrDrordFlag = "1"
  6074. orders = append(orders, &order)
  6075. }
  6076. }
  6077. for _, subItem := range item.HisPrescriptionProject {
  6078. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6079. var order models.FsiOrderDtos
  6080. order.RxID = strconv.FormatInt(item.ID, 10)
  6081. order.Rxno = strconv.FormatInt(item.ID, 10)
  6082. order.LongDrordFlag = "0"
  6083. order.HilistType = "1"
  6084. order.ChrgType = "1"
  6085. order.DrordBhvr = "0"
  6086. order.HilistCode = subItem.HisProject.MedicalCode
  6087. order.HosplistName = subItem.HisProject.ProjectName
  6088. order.HilistLv = "1"
  6089. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6090. order.HosplistCode = subItem.HisProject.MedicalCode
  6091. order.HosplistName = subItem.HisProject.ProjectName
  6092. order.Cnt = subItem.Count
  6093. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6094. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6095. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6096. order.OwnpayAmt = ""
  6097. order.SelfpayAmt = ""
  6098. order.Spec = subItem.Unit
  6099. order.SpecUnt = subItem.Unit
  6100. order.DrordBegnDate = s_tm
  6101. order.DrordStopDate = ""
  6102. order.DrordDrCodg = doctor_info.DoctorNumber
  6103. order.DrordDeptName = department.Name
  6104. order.DrordDeptCodg = department.Number
  6105. order.DrordDrName = doctor_info.UserName
  6106. order.DrordDrProfttl = "234"
  6107. order.CurrDrordFlag = "1"
  6108. orders = append(orders, &order)
  6109. }
  6110. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6111. var order models.FsiOrderDtos
  6112. order.RxID = strconv.FormatInt(item.ID, 10)
  6113. order.Rxno = strconv.FormatInt(item.ID, 10)
  6114. order.LongDrordFlag = "0"
  6115. order.HilistType = "1"
  6116. order.ChrgType = "1"
  6117. order.DrordBhvr = "0"
  6118. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6119. order.HosplistName = subItem.GoodInfo.GoodName
  6120. order.HilistLv = "1"
  6121. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6122. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6123. order.HosplistName = subItem.GoodInfo.GoodName
  6124. order.Cnt = subItem.Count
  6125. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6126. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6127. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6128. order.OwnpayAmt = ""
  6129. order.SelfpayAmt = ""
  6130. order.Spec = subItem.GoodInfo.SpecificationName
  6131. order.SpecUnt = subItem.Unit
  6132. order.DrordBegnDate = s_tm
  6133. order.DrordStopDate = ""
  6134. order.DrordDrCodg = doctor_info.DoctorNumber
  6135. order.DrordDeptName = department.Name
  6136. order.DrordDeptCodg = department.Number
  6137. order.DrordDrName = doctor_info.UserName
  6138. order.DrordDrProfttl = "234"
  6139. order.CurrDrordFlag = "1"
  6140. orders = append(orders, &order)
  6141. }
  6142. }
  6143. }
  6144. //处方医嘱信息
  6145. }
  6146. fed.MatnStas = "0"
  6147. fed.MedfeeSumamt = "0"
  6148. fed.OwnpayAmt = "0"
  6149. fed.SelfpayAmt = "0"
  6150. fed.AcctPayamt = "0"
  6151. fed.MaAmt = "0"
  6152. fed.HifpPayamt = "0"
  6153. fed.SetlTotlnum = "1"
  6154. fed.Insutype = his.Insutype
  6155. fed.ReimFlag = "0"
  6156. fed.OutSetlFlag = "0"
  6157. var fopd []*models.FsiOperationDtosData
  6158. data := make(map[string]interface{})
  6159. data["fed"] = fed
  6160. data["fdd"] = fdds
  6161. data["fod"] = orders
  6162. data["pd"] = pd
  6163. data["pp"] = pp
  6164. data["fopd"] = fopd
  6165. data["trig_scen"] = trig_scen
  6166. fmt.Println(data)
  6167. fmt.Println(fed)
  6168. fmt.Println(fdds)
  6169. fmt.Println(orders)
  6170. fmt.Println(pd)
  6171. fmt.Println(pp)
  6172. fmt.Println(fopd)
  6173. client := &http.Client{}
  6174. bytesData, _ := json.Marshal(data)
  6175. var req *http.Request
  6176. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6177. if miConfig.MdtrtareaAdmvs == "320921" {
  6178. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6179. } else {
  6180. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6181. }
  6182. resp, _ := client.Do(req)
  6183. defer resp.Body.Close()
  6184. body, ioErr := ioutil.ReadAll(resp.Body)
  6185. if ioErr != nil {
  6186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6188. return res
  6189. }
  6190. var respJSON map[string]interface{}
  6191. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return res
  6195. }
  6196. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6197. fmt.Println(respJSON)
  6198. result, _ := json.Marshal(respJSON)
  6199. fmt.Println(result)
  6200. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6201. utils.ErrorLog("解析失败:%v", err)
  6202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6203. return res
  6204. }
  6205. return res
  6206. } else {
  6207. //if miConfig.MdtrtareaAdmvs == "441202" {
  6208. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6209. saveLog(output, input, "3101", "事前")
  6210. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6211. utils.ErrorLog("解析失败:%v", err)
  6212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6213. return
  6214. }
  6215. return res
  6216. //}
  6217. }
  6218. }
  6219. 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) {
  6220. adminUser := c.GetAdminUserInfo()
  6221. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6222. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6223. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6224. //record_time := c.GetString("record_time")
  6225. //trig_scen := c.GetString("trig_scen")
  6226. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6227. timeLayout := "2006-01-02"
  6228. loc, _ := time.LoadLocation("Local")
  6229. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6230. if err != nil {
  6231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6232. return res
  6233. }
  6234. recordDateTime := theTime.Unix()
  6235. var patientPrescription models.HisPrescriptionInfo
  6236. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6237. if patientPrescription.ID == 0 {
  6238. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6239. }
  6240. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6241. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6242. //
  6243. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  6244. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6245. var pp models.PublicParams
  6246. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6247. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6248. pp.FixmedinsName = miConfig.OrgName
  6249. pp.FixmedinsCode = miConfig.Code
  6250. pp.RequestUrl = miConfig.Url
  6251. pp.Cainfo = miConfig.Cainfo
  6252. pp.SecretKey = miConfig.SecretKey
  6253. pp.AccessKey = miConfig.AccessKey
  6254. pp.OpterName = roles.UserName
  6255. var config []*models.HisXtDiagnoseConfig
  6256. for _, item := range diagnosis_ids {
  6257. id, _ := strconv.ParseInt(item, 10, 64)
  6258. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6259. config = append(config, &diagnosisConfig)
  6260. }
  6261. var pd models.PatientDtos
  6262. pd.PatnID = his.PsnNo
  6263. pd.PatnName = his.Name
  6264. pd.Gend = his.Gend
  6265. pd.Brdy = psn_info.Brdy
  6266. pd.Poolarea = his.InsuplcAdmdvs
  6267. pd.CurrMdtrtID = his.Number
  6268. var fed models.FsiEncounterDtos
  6269. fed.MdtrtID = his.Number
  6270. fed.MedinsID = miConfig.Code
  6271. fed.MedinsName = miConfig.OrgName
  6272. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6273. fed.MedMdtrtType = "1"
  6274. fed.MedinsType = "1"
  6275. fed.MedinsLv = "11"
  6276. tm := time.Unix(his.RecordDate, 0)
  6277. s_tm := tm.Format("2006-01-02 15:04:05")
  6278. fed.AdmDate = s_tm
  6279. fed.DscgDate = s_tm
  6280. fed.DscgMainDiseCodg = config[0].CountryCode
  6281. fed.DscgMainDiseName = config[0].CountryContentName
  6282. //诊断信息
  6283. var fdds []*models.FsiDiagnoseDtos
  6284. for index, item := range config {
  6285. if index == 0 {
  6286. var fdd models.FsiDiagnoseDtos
  6287. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6288. fdd.InoutDiseType = "1"
  6289. fdd.MaindiseFlag = "1"
  6290. fdd.DiseDate = s_tm
  6291. fdd.DiasSrtNo = "1"
  6292. fdd.DiseName = item.CountryContentName
  6293. fdd.DiseCodg = item.CountryCode
  6294. fdds = append(fdds, &fdd)
  6295. } else {
  6296. var fdd models.FsiDiagnoseDtos
  6297. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6298. fdd.InoutDiseType = "1"
  6299. fdd.MaindiseFlag = "1"
  6300. fdd.DiseDate = s_tm
  6301. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6302. fdd.DiseName = item.CountryContentName
  6303. fdd.DiseCodg = item.CountryCode
  6304. fdds = append(fdds, &fdd)
  6305. }
  6306. }
  6307. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6308. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6309. fed.AdmDeptName = department.Name
  6310. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6311. fed.DscgDeptName = department.Name
  6312. fed.MedMdtrtType = "1"
  6313. fed.MedType = "11"
  6314. //if his.Insutype == "390" {
  6315. // fed.MedType = "1402"
  6316. //} else {
  6317. // fed.MedType = "9933"
  6318. //}
  6319. var orders []*models.FsiOrderDtos
  6320. if trig_scen == "2" {
  6321. //处方医嘱信息
  6322. for _, item := range prescriptions {
  6323. for _, subItem := range item.HisDoctorAdviceInfo {
  6324. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6325. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6326. var order models.FsiOrderDtos
  6327. order.RxID = strconv.FormatInt(item.ID, 10)
  6328. order.Rxno = strconv.FormatInt(item.ID, 10)
  6329. order.LongDrordFlag = "0"
  6330. order.HilistType = "1"
  6331. order.ChrgType = "1"
  6332. order.DrordBhvr = "0"
  6333. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6334. order.HosplistName = subItem.BaseDrugLib.DrugName
  6335. order.HilistLv = "1"
  6336. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6337. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6338. order.HosplistName = subItem.BaseDrugLib.DrugName
  6339. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6340. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6341. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6342. order.OwnpayAmt = ""
  6343. order.SelfpayAmt = ""
  6344. order.Spec = spec
  6345. order.SpecUnt = subItem.PrescribingNumberUnit
  6346. order.DrordBegnDate = s_tm
  6347. order.DrordStopDate = ""
  6348. order.DrordDrCodg = doctor_info.DoctorNumber
  6349. order.DrordDeptName = department.Name
  6350. order.DrordDeptCodg = department.Number
  6351. order.DrordDrName = doctor_info.UserName
  6352. order.DrordDrProfttl = "234"
  6353. order.CurrDrordFlag = "1"
  6354. orders = append(orders, &order)
  6355. }
  6356. }
  6357. for _, subItem := range item.HisPrescriptionProject {
  6358. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6359. var order models.FsiOrderDtos
  6360. order.RxID = strconv.FormatInt(item.ID, 10)
  6361. order.Rxno = strconv.FormatInt(item.ID, 10)
  6362. order.LongDrordFlag = "0"
  6363. order.HilistType = "1"
  6364. order.ChrgType = "1"
  6365. order.DrordBhvr = "0"
  6366. order.HilistCode = subItem.HisProject.MedicalCode
  6367. order.HosplistName = subItem.HisProject.ProjectName
  6368. order.HilistLv = "1"
  6369. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6370. order.HosplistCode = subItem.HisProject.MedicalCode
  6371. order.HosplistName = subItem.HisProject.ProjectName
  6372. order.Cnt = subItem.Count
  6373. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6374. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6375. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6376. order.OwnpayAmt = ""
  6377. order.SelfpayAmt = ""
  6378. order.Spec = subItem.Unit
  6379. order.SpecUnt = subItem.Unit
  6380. order.DrordBegnDate = s_tm
  6381. order.DrordStopDate = ""
  6382. order.DrordDrCodg = doctor_info.DoctorNumber
  6383. order.DrordDeptName = department.Name
  6384. order.DrordDeptCodg = department.Number
  6385. order.DrordDrName = doctor_info.UserName
  6386. order.DrordDrProfttl = "234"
  6387. order.CurrDrordFlag = "1"
  6388. orders = append(orders, &order)
  6389. }
  6390. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  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.GoodInfo.MedicalInsuranceNumber
  6399. order.HosplistName = subItem.GoodInfo.GoodName
  6400. order.HilistLv = "1"
  6401. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6402. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6403. order.HosplistName = subItem.GoodInfo.GoodName
  6404. order.Cnt = subItem.Count
  6405. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6406. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6407. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6408. order.OwnpayAmt = ""
  6409. order.SelfpayAmt = ""
  6410. order.Spec = subItem.GoodInfo.SpecificationName
  6411. order.SpecUnt = subItem.Unit
  6412. order.DrordBegnDate = s_tm
  6413. order.DrordStopDate = ""
  6414. order.DrordDrCodg = doctor_info.DoctorNumber
  6415. order.DrordDeptName = department.Name
  6416. order.DrordDeptCodg = department.Number
  6417. order.DrordDrName = doctor_info.UserName
  6418. order.DrordDrProfttl = "234"
  6419. order.CurrDrordFlag = "1"
  6420. orders = append(orders, &order)
  6421. }
  6422. }
  6423. }
  6424. //处方医嘱信息
  6425. }
  6426. fed.MatnStas = "0"
  6427. fed.MedfeeSumamt = "0"
  6428. fed.OwnpayAmt = "0"
  6429. fed.SelfpayAmt = "0"
  6430. fed.AcctPayamt = "0"
  6431. fed.MaAmt = "0"
  6432. fed.HifpPayamt = "0"
  6433. fed.SetlTotlnum = "1"
  6434. fed.Insutype = his.Insutype
  6435. fed.ReimFlag = "0"
  6436. fed.OutSetlFlag = "0"
  6437. var fopd []*models.FsiOperationDtosData
  6438. data := make(map[string]interface{})
  6439. data["fed"] = fed
  6440. data["fdd"] = fdds
  6441. data["fod"] = orders
  6442. data["pd"] = pd
  6443. data["pp"] = pp
  6444. data["fopd"] = fopd
  6445. data["trig_scen"] = trig_scen
  6446. fmt.Println(data)
  6447. fmt.Println(fed)
  6448. fmt.Println(fdds)
  6449. fmt.Println(orders)
  6450. fmt.Println(pd)
  6451. fmt.Println(pp)
  6452. fmt.Println(fopd)
  6453. client := &http.Client{}
  6454. bytesData, _ := json.Marshal(data)
  6455. var req *http.Request
  6456. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6457. if miConfig.MdtrtareaAdmvs == "320921" {
  6458. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6459. } else {
  6460. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  6461. }
  6462. resp, _ := client.Do(req)
  6463. defer resp.Body.Close()
  6464. body, ioErr := ioutil.ReadAll(resp.Body)
  6465. if ioErr != nil {
  6466. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6468. return res
  6469. }
  6470. var respJSON map[string]interface{}
  6471. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6472. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return res
  6475. }
  6476. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6477. fmt.Println(respJSON)
  6478. result, _ := json.Marshal(respJSON)
  6479. fmt.Println(result)
  6480. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6481. utils.ErrorLog("解析失败:%v", err)
  6482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6483. return res
  6484. }
  6485. return res
  6486. } else {
  6487. output, input := service.Gdyb3101(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6488. saveLog(output, input, "3101", "事前")
  6489. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6490. utils.ErrorLog("解析失败:%v", err)
  6491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6492. return
  6493. }
  6494. return res
  6495. }
  6496. return res
  6497. }
  6498. func Checkgd3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Resultgd3101) {
  6499. ////patient_id, _ := c.GetInt64("patient_id")
  6500. //order_id, _ := c.GetInt64("order_id")
  6501. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  6502. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  6503. //trig_scen := c.GetString("trig_scen")
  6504. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6505. utils.ErrorLog("解析失败:%v", psn_info)
  6506. adminUser := c.GetAdminUserInfo()
  6507. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6508. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  6509. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6510. record_time := c.GetString("record_time")
  6511. order, _ := service.GetHisOrderByID(order_id)
  6512. timeLayout := "2006-01-02"
  6513. loc, _ := time.LoadLocation("Local")
  6514. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6515. if err != nil {
  6516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6517. return
  6518. }
  6519. recordDateTime := theTime.Unix()
  6520. var patientPrescription models.HisPrescriptionInfo
  6521. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6522. if patientPrescription.ID == 0 {
  6523. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  6524. }
  6525. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6526. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6527. //
  6528. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6529. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6530. var pp models.PublicParams
  6531. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6532. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6533. pp.FixmedinsName = miConfig.OrgName
  6534. pp.FixmedinsCode = miConfig.Code
  6535. pp.RequestUrl = miConfig.Url
  6536. pp.Cainfo = miConfig.Cainfo
  6537. pp.SecretKey = miConfig.SecretKey
  6538. pp.AccessKey = miConfig.AccessKey
  6539. pp.OpterName = roles.UserName
  6540. var config []*models.HisXtDiagnoseConfig
  6541. for _, item := range diagnosis_ids {
  6542. id, _ := strconv.ParseInt(item, 10, 64)
  6543. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6544. config = append(config, &diagnosisConfig)
  6545. }
  6546. var pd models.PatientDtos
  6547. pd.PatnID = his.PsnNo
  6548. pd.PatnName = his.Name
  6549. pd.Gend = his.Gend
  6550. pd.Brdy = psn_info.Brdy
  6551. pd.Poolarea = his.InsuplcAdmdvs
  6552. pd.CurrMdtrtID = his.Number
  6553. var fed models.FsiEncounterDtos
  6554. fed.MdtrtID = his.Number
  6555. fed.MedinsID = miConfig.Code
  6556. fed.MedinsName = miConfig.OrgName
  6557. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  6558. fed.MedMdtrtType = "1"
  6559. fed.MedinsType = "1"
  6560. fed.MedinsLv = "11"
  6561. tm := time.Unix(his.RecordDate, 0)
  6562. s_tm := tm.Format("2006-01-02 15:04:05")
  6563. fed.AdmDate = s_tm
  6564. fed.DscgDate = s_tm
  6565. fed.DscgMainDiseCodg = config[0].CountryCode
  6566. fed.DscgMainDiseName = config[0].CountryContentName
  6567. //诊断信息
  6568. var fdds []*models.FsiDiagnoseDtos
  6569. for index, item := range config {
  6570. if index == 0 {
  6571. var fdd models.FsiDiagnoseDtos
  6572. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6573. fdd.InoutDiseType = "1"
  6574. fdd.MaindiseFlag = "1"
  6575. fdd.DiseDate = s_tm
  6576. fdd.DiasSrtNo = "1"
  6577. fdd.DiseName = item.CountryContentName
  6578. fdd.DiseCodg = item.CountryCode
  6579. fdds = append(fdds, &fdd)
  6580. } else {
  6581. var fdd models.FsiDiagnoseDtos
  6582. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  6583. fdd.InoutDiseType = "1"
  6584. fdd.MaindiseFlag = "1"
  6585. fdd.DiseDate = s_tm
  6586. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  6587. fdd.DiseName = item.CountryContentName
  6588. fdd.DiseCodg = item.CountryCode
  6589. fdds = append(fdds, &fdd)
  6590. }
  6591. }
  6592. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  6593. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  6594. fed.AdmDeptName = department.Name
  6595. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  6596. fed.DscgDeptName = department.Name
  6597. fed.MedType = order.MedType
  6598. //处方医嘱信息
  6599. var orders []*models.FsiOrderDtos
  6600. //for _, item := range prescriptions {
  6601. // for _, subItem := range item.HisDoctorAdviceInfo {
  6602. // var order models.FsiOrderDtos
  6603. // order.RxID = strconv.FormatInt(item.ID, 10)
  6604. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6605. // order.LongDrordFlag = "0"
  6606. // order.HilistType = "1"
  6607. // order.ChrgType = "1"
  6608. // order.DrordBhvr = "-"
  6609. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6610. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6611. // order.HilistLv = "1"
  6612. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6613. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6614. // order.HosplistName = subItem.BaseDrugLib.DrugName
  6615. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  6616. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6617. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  6618. // order.OwnpayAmt = ""
  6619. // order.SelfpayAmt = ""
  6620. // order.Spec = ""
  6621. // order.SpecUnt = ""
  6622. // order.DrordBegnDate = s_tm
  6623. // order.DrordStopDate = ""
  6624. // order.DrordDrCodg = "1"
  6625. // order.DrordDeptName = department.Name
  6626. // order.DrordDrCodg = "1"
  6627. // order.DrordDrName = doctor_info.UserName
  6628. // order.DrordDrProfttl = ""
  6629. // order.CurrDrordFlag = "1"
  6630. // orders = append(orders, &order)
  6631. // }
  6632. // for _, subItem := range item.HisPrescriptionProject {
  6633. // if subItem.Type == 2 {
  6634. // var order models.FsiOrderDtos
  6635. // order.RxID = strconv.FormatInt(item.ID, 10)
  6636. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6637. // order.LongDrordFlag = "0"
  6638. // order.HilistType = "1"
  6639. // order.ChrgType = "1"
  6640. // order.DrordBhvr = "-"
  6641. // order.HilistCode = subItem.HisProject.MedicalCode
  6642. // order.HosplistName = subItem.HisProject.ProjectName
  6643. // order.HilistLv = "1"
  6644. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6645. // order.HosplistCode = subItem.HisProject.MedicalCode
  6646. // order.HosplistName = subItem.HisProject.ProjectName
  6647. // order.Cnt = subItem.Count
  6648. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6649. //
  6650. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6651. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6652. // order.OwnpayAmt = ""
  6653. // order.SelfpayAmt = ""
  6654. // order.Spec = ""
  6655. // order.SpecUnt = ""
  6656. // order.DrordBegnDate = s_tm
  6657. // order.DrordStopDate = ""
  6658. // order.DrordDrCodg = "1"
  6659. // order.DrordDeptName = department.Name
  6660. // order.DrordDrCodg = "1"
  6661. // order.DrordDrName = doctor_info.UserName
  6662. // order.DrordDrProfttl = ""
  6663. // order.CurrDrordFlag = "1"
  6664. // orders = append(orders, &order)
  6665. //
  6666. // }
  6667. // if subItem.Type == 3 {
  6668. //
  6669. // var order models.FsiOrderDtos
  6670. // order.RxID = strconv.FormatInt(item.ID, 10)
  6671. // order.Rxno = strconv.FormatInt(item.ID, 10)
  6672. // order.LongDrordFlag = "0"
  6673. // order.HilistType = "1"
  6674. // order.ChrgType = "1"
  6675. // order.DrordBhvr = "-"
  6676. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6677. // order.HosplistName = subItem.GoodInfo.GoodName
  6678. // order.HilistLv = "1"
  6679. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6680. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6681. // order.HosplistName = subItem.GoodInfo.GoodName
  6682. // order.Cnt = subItem.Count
  6683. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6684. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  6685. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  6686. // order.OwnpayAmt = ""
  6687. // order.SelfpayAmt = ""
  6688. // order.Spec = ""
  6689. // order.SpecUnt = ""
  6690. // order.DrordBegnDate = s_tm
  6691. // order.DrordStopDate = ""
  6692. // order.DrordDrCodg = "1"
  6693. // order.DrordDeptName = department.Name
  6694. // order.DrordDrCodg = "1"
  6695. // order.DrordDrName = doctor_info.UserName
  6696. // order.DrordDrProfttl = ""
  6697. // order.CurrDrordFlag = "1"
  6698. // orders = append(orders, &order)
  6699. //
  6700. // }
  6701. // }
  6702. //}
  6703. for _, item := range prescriptions {
  6704. for _, subItem := range item.HisDoctorAdviceInfo {
  6705. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  6706. spec := (subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit) + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  6707. var order models.FsiOrderDtos
  6708. order.RxID = strconv.FormatInt(item.ID, 10)
  6709. order.Rxno = strconv.FormatInt(item.ID, 10)
  6710. order.LongDrordFlag = "0"
  6711. order.HilistType = "1"
  6712. order.ChrgType = "1"
  6713. order.DrordBhvr = "0"
  6714. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6715. order.HosplistName = subItem.BaseDrugLib.DrugName
  6716. order.HilistLv = "1"
  6717. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6718. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  6719. order.HosplistName = subItem.BaseDrugLib.DrugName
  6720. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  6721. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6722. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  6723. order.OwnpayAmt = ""
  6724. order.SelfpayAmt = ""
  6725. order.Spec = spec
  6726. order.SpecUnt = subItem.PrescribingNumberUnit
  6727. order.DrordBegnDate = s_tm
  6728. order.DrordStopDate = ""
  6729. order.DrordDrCodg = doctor_info.DoctorNumber
  6730. order.DrordDeptName = department.Name
  6731. order.DrordDeptCodg = department.Number
  6732. order.DrordDrName = doctor_info.UserName
  6733. order.DrordDrProfttl = "234"
  6734. order.CurrDrordFlag = "1"
  6735. orders = append(orders, &order)
  6736. }
  6737. }
  6738. for _, subItem := range item.HisPrescriptionProject {
  6739. if subItem.Type == 2 && len(subItem.HisProject.MedicalCode) > 0 {
  6740. var order models.FsiOrderDtos
  6741. order.RxID = strconv.FormatInt(item.ID, 10)
  6742. order.Rxno = strconv.FormatInt(item.ID, 10)
  6743. order.LongDrordFlag = "0"
  6744. order.HilistType = "1"
  6745. order.ChrgType = "1"
  6746. order.DrordBhvr = "0"
  6747. order.HilistCode = subItem.HisProject.MedicalCode
  6748. order.HosplistName = subItem.HisProject.ProjectName
  6749. order.HilistLv = "1"
  6750. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6751. order.HosplistCode = subItem.HisProject.MedicalCode
  6752. order.HosplistName = subItem.HisProject.ProjectName
  6753. order.Cnt = subItem.Count
  6754. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6755. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6756. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6757. order.OwnpayAmt = ""
  6758. order.SelfpayAmt = ""
  6759. order.Spec = subItem.Unit
  6760. order.SpecUnt = subItem.Unit
  6761. order.DrordBegnDate = s_tm
  6762. order.DrordStopDate = ""
  6763. order.DrordDrCodg = doctor_info.DoctorNumber
  6764. order.DrordDeptName = department.Name
  6765. order.DrordDeptCodg = department.Number
  6766. order.DrordDrName = doctor_info.UserName
  6767. order.DrordDrProfttl = "234"
  6768. order.CurrDrordFlag = "1"
  6769. orders = append(orders, &order)
  6770. }
  6771. if subItem.Type == 3 && len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 {
  6772. var order models.FsiOrderDtos
  6773. order.RxID = strconv.FormatInt(item.ID, 10)
  6774. order.Rxno = strconv.FormatInt(item.ID, 10)
  6775. order.LongDrordFlag = "0"
  6776. order.HilistType = "1"
  6777. order.ChrgType = "1"
  6778. order.DrordBhvr = "0"
  6779. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6780. order.HosplistName = subItem.GoodInfo.GoodName
  6781. order.HilistLv = "1"
  6782. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  6783. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  6784. order.HosplistName = subItem.GoodInfo.GoodName
  6785. order.Cnt = subItem.Count
  6786. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6787. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  6788. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  6789. order.OwnpayAmt = ""
  6790. order.SelfpayAmt = ""
  6791. order.Spec = subItem.GoodInfo.SpecificationName
  6792. order.SpecUnt = subItem.Unit
  6793. order.DrordBegnDate = s_tm
  6794. order.DrordStopDate = ""
  6795. order.DrordDrCodg = doctor_info.DoctorNumber
  6796. order.DrordDeptName = department.Name
  6797. order.DrordDeptCodg = department.Number
  6798. order.DrordDrName = doctor_info.UserName
  6799. order.DrordDrProfttl = "234"
  6800. order.CurrDrordFlag = "1"
  6801. orders = append(orders, &order)
  6802. }
  6803. }
  6804. }
  6805. //处方医嘱信息
  6806. fed.MatnStas = "0"
  6807. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  6808. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  6809. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  6810. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  6811. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  6812. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  6813. fed.SetlTotlnum = "1"
  6814. fed.Insutype = his.Insutype
  6815. fed.ReimFlag = "0"
  6816. fed.OutSetlFlag = "0"
  6817. var fopd []*models.FsiOperationDtosData
  6818. data := make(map[string]interface{})
  6819. data["fed"] = fed
  6820. data["fdd"] = fdds
  6821. data["fod"] = orders
  6822. data["pd"] = pd
  6823. data["pp"] = pp
  6824. data["fopd"] = fopd
  6825. data["trig_scen"] = trig_scen
  6826. client := &http.Client{}
  6827. bytesData, _ := json.Marshal(data)
  6828. var req *http.Request
  6829. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6830. if miConfig.MdtrtareaAdmvs == "320921" {
  6831. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6832. } else {
  6833. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  6834. }
  6835. resp, _ := client.Do(req)
  6836. defer resp.Body.Close()
  6837. body, ioErr := ioutil.ReadAll(resp.Body)
  6838. if ioErr != nil {
  6839. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6841. return res
  6842. }
  6843. var respJSON map[string]interface{}
  6844. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6845. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6847. return res
  6848. }
  6849. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6850. result, _ := json.Marshal(respJSON)
  6851. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6852. utils.ErrorLog("解析失败:%v", err)
  6853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6854. return res
  6855. }
  6856. return res
  6857. } else {
  6858. output, input := service.Gdyb3102(pd, fed, fdds, orders, fopd, pp, trig_scen)
  6859. saveLog(output, input, "3102", "事中")
  6860. if err := json.Unmarshal([]byte(output), &res); err != nil {
  6861. utils.ErrorLog("解析失败:%v", err)
  6862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6863. return
  6864. }
  6865. return res
  6866. }
  6867. return res
  6868. }
  6869. func (c *HisApiController) Check() {
  6870. psn_no := c.GetString("psn_no")
  6871. in := c.GetString("in")
  6872. mt := c.GetString("mt")
  6873. baseParams := models.BaseParams{
  6874. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  6875. FixmedinsCode: "H15049901371",
  6876. InsuplcAdmdvs: "150499",
  6877. MdtrtareaAdmvs: "150499",
  6878. OrgName: "赤峰费森血液透析中心",
  6879. Doctor: "1111",
  6880. }
  6881. service.Gdyb2001(baseParams, psn_no, in, mt)
  6882. }
  6883. func (c *HisApiController) GetPsnNcdsInfo() {
  6884. admin_user_id, _ := c.GetInt64("admin_user_id")
  6885. patient_id, _ := c.GetInt64("patient_id")
  6886. //id, _ := c.GetInt64("id")
  6887. adminUser := c.GetAdminUserInfo()
  6888. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6889. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6890. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  6891. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6892. //psn_record, _ := service.GetP(id)
  6893. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6894. //psn_record, _ := service.GetPsnNCDSRecordById(id)
  6895. //
  6896. //if psn_record.ID == 0 {
  6897. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  6898. // return
  6899. //}
  6900. var res Result5301
  6901. var res10265 Result5301For10265
  6902. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6903. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6904. var api string
  6905. if miConfig.MdtrtareaAdmvs == "320921" {
  6906. 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 +
  6907. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6908. } else {
  6909. 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 +
  6910. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6911. }
  6912. resp, requestErr := http.Get(api)
  6913. if requestErr != nil {
  6914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6915. return
  6916. }
  6917. body, ioErr := ioutil.ReadAll(resp.Body)
  6918. if ioErr != nil {
  6919. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6921. return
  6922. }
  6923. var respJSON map[string]interface{}
  6924. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6925. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. return
  6928. }
  6929. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6930. result, _ := json.Marshal(respJSON)
  6931. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  6932. utils.ErrorLog("解析失败:%v", err)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. res.ErrMsg = res10265.ErrMsg
  6937. res.Output = res10265.Output
  6938. res.InfRefmsgid = res10265.InfRefmsgid
  6939. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  6940. res.Infcode = infocode
  6941. } else if miConfig.MdtrtareaAdmvs == "341203" {
  6942. psn_info, _ := service.GetPsnByPatientId(patient_id)
  6943. var api string
  6944. api = miConfig.SecretKey + "ahyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  6945. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  6946. resp, requestErr := http.Get(api)
  6947. if requestErr != nil {
  6948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6949. return
  6950. }
  6951. body, ioErr := ioutil.ReadAll(resp.Body)
  6952. if ioErr != nil {
  6953. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. var respJSON map[string]interface{}
  6958. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6959. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6961. return
  6962. }
  6963. status := respJSON["data"].(map[string]interface{})["status"].(string)
  6964. if status == "0" {
  6965. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  6966. c.ServeSuccessJSON(map[string]interface{}{
  6967. "failed_code": -10,
  6968. "msg": err_msg,
  6969. })
  6970. return
  6971. }
  6972. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6973. result, _ := json.Marshal(respJSON)
  6974. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6975. utils.ErrorLog("解析失败:%v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. } else if miConfig.MdtrtareaAdmvs == "360302" {
  6980. p, _ := service.GetHisPatientById(patient_id)
  6981. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6982. var dat map[string]interface{}
  6983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6984. fmt.Println(dat)
  6985. } else {
  6986. fmt.Println(err)
  6987. }
  6988. userJSONBytes, _ := json.Marshal(dat)
  6989. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6990. utils.ErrorLog("解析失败:%v", err)
  6991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6992. return
  6993. }
  6994. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6995. p, _ := service.GetHisPatientById(patient_id)
  6996. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  6997. var dat map[string]interface{}
  6998. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6999. fmt.Println(dat)
  7000. } else {
  7001. fmt.Println(err)
  7002. }
  7003. userJSONBytes, _ := json.Marshal(dat)
  7004. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7005. utils.ErrorLog("解析失败:%v", err)
  7006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7007. return
  7008. }
  7009. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7010. p, _ := service.GetHisPatientById(patient_id)
  7011. api := "http://192.168.0.197:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7012. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7014. resp, requestErr := http.Get(api)
  7015. if requestErr != nil {
  7016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7017. return
  7018. }
  7019. body, ioErr := ioutil.ReadAll(resp.Body)
  7020. if ioErr != nil {
  7021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7023. return
  7024. }
  7025. var respJSON map[string]interface{}
  7026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7029. return
  7030. }
  7031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7032. result, _ := json.Marshal(respJSON)
  7033. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7034. utils.ErrorLog("解析失败:%v", err)
  7035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7036. return
  7037. }
  7038. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7039. p, _ := service.GetHisPatientById(patient_id)
  7040. api := miConfig.Url + "hbyb/5301?psn_no=" + p.PsnNo +
  7041. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7042. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7043. resp, requestErr := http.Get(api)
  7044. if requestErr != nil {
  7045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7046. return
  7047. }
  7048. body, ioErr := ioutil.ReadAll(resp.Body)
  7049. if ioErr != nil {
  7050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7052. return
  7053. }
  7054. var respJSON map[string]interface{}
  7055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7058. return
  7059. }
  7060. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7061. result, _ := json.Marshal(respJSON)
  7062. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7063. utils.ErrorLog("解析失败:%v", err)
  7064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7065. return
  7066. }
  7067. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7068. p, _ := service.GetHisPatientById(patient_id)
  7069. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7070. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7071. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7072. resp, requestErr := http.Get(api)
  7073. if requestErr != nil {
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7075. return
  7076. }
  7077. body, ioErr := ioutil.ReadAll(resp.Body)
  7078. if ioErr != nil {
  7079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7081. return
  7082. }
  7083. var respJSON map[string]interface{}
  7084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7087. return
  7088. }
  7089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7090. result, _ := json.Marshal(respJSON)
  7091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7092. utils.ErrorLog("解析失败:%v", err)
  7093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7094. return
  7095. }
  7096. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7097. p, _ := service.GetHisPatientById(patient_id)
  7098. api := miConfig.Url + "/hbyb/5301?psn_no=" + p.PsnNo +
  7099. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7101. resp, requestErr := http.Get(api)
  7102. if requestErr != nil {
  7103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7104. return
  7105. }
  7106. body, ioErr := ioutil.ReadAll(resp.Body)
  7107. if ioErr != nil {
  7108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7110. return
  7111. }
  7112. var respJSON map[string]interface{}
  7113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7116. return
  7117. }
  7118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7119. result, _ := json.Marshal(respJSON)
  7120. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7121. utils.ErrorLog("解析失败:%v", err)
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. return
  7124. }
  7125. } else if miConfig.MdtrtareaAdmvs == "421300" {
  7126. p, _ := service.GetHisPatientById(patient_id)
  7127. api := "http://192.168.124.4:9532/" + "/hbyb/5301?psn_no=" + p.PsnNo +
  7128. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7129. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7130. resp, requestErr := http.Get(api)
  7131. if requestErr != nil {
  7132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7133. return
  7134. }
  7135. body, ioErr := ioutil.ReadAll(resp.Body)
  7136. if ioErr != nil {
  7137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7139. return
  7140. }
  7141. var respJSON map[string]interface{}
  7142. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. return
  7146. }
  7147. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7148. result, _ := json.Marshal(respJSON)
  7149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7150. utils.ErrorLog("解析失败:%v", err)
  7151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7152. return
  7153. }
  7154. } else if miConfig.MdtrtareaAdmvs == "441799" {
  7155. p, _ := service.GetHisPatientById(patient_id)
  7156. api := miConfig.Url + "gdyb/5301?psn_no=" + p.PsnNo +
  7157. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  7158. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7159. resp, requestErr := http.Get(api)
  7160. if requestErr != nil {
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. body, ioErr := ioutil.ReadAll(resp.Body)
  7165. if ioErr != nil {
  7166. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. var respJSON map[string]interface{}
  7171. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7172. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7174. return
  7175. }
  7176. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7177. result, _ := json.Marshal(respJSON)
  7178. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7179. utils.ErrorLog("解析失败:%v", err)
  7180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7181. return
  7182. }
  7183. } else {
  7184. result := service.Gdyb5301(psn_info.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  7185. var dat map[string]interface{}
  7186. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7187. fmt.Println(dat)
  7188. } else {
  7189. fmt.Println(err)
  7190. }
  7191. userJSONBytes, _ := json.Marshal(dat)
  7192. if miConfig.Code == "H15049901371" {
  7193. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  7194. utils.ErrorLog("解析失败:%v", err)
  7195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7196. return
  7197. }
  7198. res.InfRefmsgid = res10265.InfRefmsgid
  7199. res.Output = res10265.Output
  7200. res.ErrMsg = res10265.ErrMsg
  7201. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7202. res.Infcode = infocode
  7203. } else {
  7204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7205. utils.ErrorLog("解析失败:%v", err)
  7206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7207. return
  7208. }
  7209. }
  7210. }
  7211. if res.Infcode == 0 {
  7212. c.ServeSuccessJSON(map[string]interface{}{
  7213. "result": res.Output.Result,
  7214. })
  7215. }
  7216. }
  7217. func (c *HisApiController) CheckInsutype() {
  7218. his_patient_id, _ := c.GetInt64("his_patient_id")
  7219. admin_user_id, _ := c.GetInt64("admin_user_id")
  7220. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7221. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7222. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7223. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  7224. var dat map[string]interface{}
  7225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7226. fmt.Println(dat)
  7227. } else {
  7228. fmt.Println(err)
  7229. }
  7230. userJSONBytes, _ := json.Marshal(dat)
  7231. var res Result90100
  7232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7233. utils.ErrorLog("解析失败:%v", err)
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. return
  7236. }
  7237. if res.Infcode != 0 {
  7238. c.ServeSuccessJSON(map[string]interface{}{
  7239. "failed_code": -10,
  7240. "msg": res.ErrMsg,
  7241. })
  7242. return
  7243. } else {
  7244. fmt.Println(res)
  7245. }
  7246. }
  7247. func (c *HisApiController) CheckCardPWD() {
  7248. card_pwd := c.GetString("card_pwd")
  7249. his_patient_id, _ := c.GetInt64("his_patient_id")
  7250. admin_user_id, _ := c.GetInt64("admin_user_id")
  7251. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7252. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7253. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  7254. psn, _ := service.GetPsnByPatientId(his.PatientId)
  7255. bas := strings.Split(psn.CardInfo, "|")
  7256. basNumber := bas[2]
  7257. if psn.InsuplcAdmdvs[:4] == "4403" {
  7258. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  7259. var dat map[string]interface{}
  7260. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7261. fmt.Println(dat)
  7262. } else {
  7263. fmt.Println(err)
  7264. }
  7265. userJSONBytes, _ := json.Marshal(dat)
  7266. var res Result90991
  7267. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7268. utils.ErrorLog("解析失败:%v", err)
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. if res.Infcode != 0 {
  7273. c.ServeSuccessJSON(map[string]interface{}{
  7274. "failed_code": -10,
  7275. "msg": res.ErrMsg,
  7276. })
  7277. return
  7278. } else {
  7279. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  7280. var msg string
  7281. switch res.Output.Result.CardStat {
  7282. case "00":
  7283. msg = "未激活"
  7284. break
  7285. case "10":
  7286. msg = "激活"
  7287. break
  7288. case "20":
  7289. msg = "窗口挂失"
  7290. break
  7291. case "21":
  7292. msg = "电话挂失"
  7293. break
  7294. case "22":
  7295. msg = "单位网上申报挂失"
  7296. break
  7297. case "23":
  7298. msg = "保健办挂失"
  7299. break
  7300. case "24":
  7301. msg = "个人网上挂失"
  7302. break
  7303. case "25":
  7304. msg = "网上服务大厅挂失"
  7305. break
  7306. case "30":
  7307. msg = "注销"
  7308. break
  7309. case "40":
  7310. msg = "回收"
  7311. break
  7312. case "99":
  7313. msg = "制卡中(无效卡)"
  7314. break
  7315. }
  7316. c.ServeSuccessJSON(map[string]interface{}{
  7317. "failed_code": -10,
  7318. "msg": msg,
  7319. })
  7320. return
  7321. } else {
  7322. c.ServeSuccessJSON(map[string]interface{}{
  7323. "msg": "校验成功",
  7324. })
  7325. return
  7326. }
  7327. }
  7328. } else {
  7329. c.ServeSuccessJSON(map[string]interface{}{
  7330. "msg": "校验成功",
  7331. })
  7332. return
  7333. }
  7334. }
  7335. func (c *HisApiController) CheckCardPWDTwo() {
  7336. //card_pwd := c.GetString("card_pwd")
  7337. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7338. admin_user_id, _ := c.GetInt64("admin_user_id")
  7339. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7340. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7341. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  7342. var dat map[string]interface{}
  7343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7344. fmt.Println(dat)
  7345. } else {
  7346. fmt.Println(err)
  7347. }
  7348. userJSONBytes, _ := json.Marshal(dat)
  7349. var res Result90991
  7350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7351. utils.ErrorLog("解析失败:%v", err)
  7352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7353. return
  7354. }
  7355. if res.Infcode != 0 {
  7356. c.ServeSuccessJSON(map[string]interface{}{
  7357. "failed_code": -10,
  7358. "msg": res.ErrMsg,
  7359. })
  7360. return
  7361. } else {
  7362. if res.Output.Result.SscnoCheckStat == "0" {
  7363. var msg string
  7364. switch res.Output.Result.CardStat {
  7365. case "00":
  7366. msg = "未激活"
  7367. break
  7368. case "10":
  7369. msg = "激活"
  7370. break
  7371. case "20":
  7372. msg = "窗口挂失"
  7373. break
  7374. case "21":
  7375. msg = "电话挂失"
  7376. break
  7377. case "22":
  7378. msg = "单位网上申报挂失"
  7379. break
  7380. case "23":
  7381. msg = "保健办挂失"
  7382. break
  7383. case "24":
  7384. msg = "个人网上挂失"
  7385. break
  7386. case "25":
  7387. msg = "网上服务大厅挂失"
  7388. break
  7389. case "30":
  7390. msg = "注销"
  7391. break
  7392. case "40":
  7393. msg = "回收"
  7394. break
  7395. case "99":
  7396. msg = "制卡中(无效卡)"
  7397. break
  7398. }
  7399. c.ServeSuccessJSON(map[string]interface{}{
  7400. "failed_code": -10,
  7401. "msg": msg,
  7402. })
  7403. return
  7404. } else {
  7405. c.ServeSuccessJSON(map[string]interface{}{
  7406. "msg": "校验成功",
  7407. })
  7408. return
  7409. }
  7410. }
  7411. }
  7412. type ELeCertData struct {
  7413. Data struct {
  7414. Extra string `json:"extra"`
  7415. IDNo string `json:"idNo"`
  7416. IDType string `json:"idType"`
  7417. EcToken string `json:"ecToken"`
  7418. InsuOrg string `json:"insuOrg"`
  7419. UserName string `json:"userName"`
  7420. EcIndexNo string `json:"ecIndexNo"`
  7421. Gender string `json:"gender"`
  7422. Birthday string `json:"birthday"`
  7423. Nationality string `json:"nationality"`
  7424. Email string `json:"email"`
  7425. } `json:"OutData"`
  7426. }
  7427. func (c *HisApiController) ReadCard() {
  7428. id_card_type, _ := c.GetInt64("id_card_type")
  7429. admin_user_id, _ := c.GetInt64("admin_user_id")
  7430. certificates, _ := c.GetInt64("certificates")
  7431. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  7432. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  7433. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  7434. switch id_card_type {
  7435. case 1:
  7436. if miConfig.MdtrtareaAdmvs == "421300" {
  7437. var res ResultTwo
  7438. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  7439. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7440. "&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)
  7441. resp, requestErr := http.Get(api)
  7442. if requestErr != nil {
  7443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7444. return
  7445. }
  7446. body, ioErr := ioutil.ReadAll(resp.Body)
  7447. if ioErr != nil {
  7448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7450. return
  7451. }
  7452. var respJSON map[string]interface{}
  7453. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7456. return
  7457. }
  7458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7459. result, _ := json.Marshal(respJSON)
  7460. fmt.Println("log")
  7461. fmt.Println(string(result))
  7462. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7463. utils.ErrorLog("解析失败:%v", err)
  7464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7465. return
  7466. }
  7467. if res.Infcode == 0 {
  7468. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7469. if err == gorm.ErrRecordNotFound {
  7470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7471. return
  7472. } else if err != nil {
  7473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7474. return
  7475. } else {
  7476. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7477. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7478. infoStr := string(Iinfos)
  7479. idetinfoStr := string(Idetinfos)
  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") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  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 = "390"
  7512. }
  7513. var insuplc_admdvs string
  7514. for _, item := range rf {
  7515. if item.Insutype == insutype {
  7516. insuplc_admdvs = item.InsuplcAdmdvs
  7517. }
  7518. }
  7519. if strings.Contains(insuplc_admdvs, "4213") {
  7520. insuplc_admdvs = miConfig.MdtrtareaAdmvs
  7521. }
  7522. psn := &models.HisPsn{
  7523. PsnNo: res.Output.Baseinfo.PsnNo,
  7524. PatientId: patient.ID,
  7525. Certno: res.Output.Baseinfo.Certno,
  7526. Gend: res.Output.Baseinfo.Gend,
  7527. Naty: res.Output.Baseinfo.Naty,
  7528. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7529. PsnName: res.Output.Baseinfo.PsnName,
  7530. Idetinfo: idetinfoStr,
  7531. Insuinfo: infoStr,
  7532. InsuplcAdmdvs: insuplc_admdvs,
  7533. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7534. }
  7535. service.CreateHisPsn(psn)
  7536. c.ServeSuccessJSON(map[string]interface{}{
  7537. "patient": patient,
  7538. "number": res.Output.Baseinfo.Certno,
  7539. })
  7540. }
  7541. } else {
  7542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7543. return
  7544. }
  7545. } else if miConfig.MdtrtareaAdmvs == "420200" {
  7546. var res ResultTwo
  7547. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  7548. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7549. "&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)
  7550. resp, requestErr := http.Get(api)
  7551. if requestErr != nil {
  7552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7553. return
  7554. }
  7555. body, ioErr := ioutil.ReadAll(resp.Body)
  7556. if ioErr != nil {
  7557. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7558. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7559. return
  7560. }
  7561. var respJSON map[string]interface{}
  7562. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7563. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7568. result, _ := json.Marshal(respJSON)
  7569. fmt.Println("log")
  7570. fmt.Println(string(result))
  7571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7572. utils.ErrorLog("解析失败:%v", err)
  7573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7574. return
  7575. }
  7576. if res.Infcode == 0 {
  7577. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7578. if err == gorm.ErrRecordNotFound {
  7579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7580. return
  7581. } else if err != nil {
  7582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7583. return
  7584. } else {
  7585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7587. infoStr := string(Iinfos)
  7588. idetinfoStr := string(Idetinfos)
  7589. psn := &models.HisPsn{
  7590. PsnNo: res.Output.Baseinfo.PsnNo,
  7591. PatientId: patient.ID,
  7592. Certno: res.Output.Baseinfo.Certno,
  7593. Gend: res.Output.Baseinfo.Gend,
  7594. Naty: res.Output.Baseinfo.Naty,
  7595. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7596. PsnName: res.Output.Baseinfo.PsnName,
  7597. Idetinfo: idetinfoStr,
  7598. Insuinfo: infoStr,
  7599. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7600. }
  7601. service.CreateHisPsn(psn)
  7602. var rf []*ResultFive
  7603. json.Unmarshal([]byte(infoStr), &rf)
  7604. var insutypes []*ResultFive
  7605. var insutype string
  7606. var is390 int = 0
  7607. var is310 int = 0
  7608. for _, item := range rf {
  7609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7610. insutypes = append(insutypes, item)
  7611. }
  7612. }
  7613. if len(insutypes) == 1 {
  7614. insutype = insutypes[0].Insutype
  7615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7616. } else {
  7617. for _, i := range insutypes {
  7618. if i.Insutype == "390" {
  7619. is390 = 1
  7620. }
  7621. if i.Insutype == "310" {
  7622. is310 = 1
  7623. }
  7624. }
  7625. }
  7626. if is390 == 1 {
  7627. insutype = "390"
  7628. }
  7629. if is310 == 1 {
  7630. insutype = "310"
  7631. }
  7632. if len(insutypes) == 0 {
  7633. insutype = "310"
  7634. }
  7635. c.ServeSuccessJSON(map[string]interface{}{
  7636. "patient": patient,
  7637. "number": res.Output.Baseinfo.Certno,
  7638. "insutype": insutype,
  7639. })
  7640. }
  7641. } else {
  7642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7643. return
  7644. }
  7645. } else if miConfig.MdtrtareaAdmvs == "420902" {
  7646. var res ResultTwo
  7647. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  7648. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7649. "&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)
  7650. resp, requestErr := http.Get(api)
  7651. if requestErr != nil {
  7652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7653. return
  7654. }
  7655. body, ioErr := ioutil.ReadAll(resp.Body)
  7656. if ioErr != nil {
  7657. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7659. return
  7660. }
  7661. var respJSON map[string]interface{}
  7662. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7665. return
  7666. }
  7667. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7668. result, _ := json.Marshal(respJSON)
  7669. fmt.Println("log")
  7670. fmt.Println(string(result))
  7671. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7672. utils.ErrorLog("解析失败:%v", err)
  7673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7674. return
  7675. }
  7676. if res.Infcode == 0 {
  7677. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7678. if err == gorm.ErrRecordNotFound {
  7679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7680. return
  7681. } else if err != nil {
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7683. return
  7684. } else {
  7685. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7686. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7687. infoStr := string(Iinfos)
  7688. idetinfoStr := string(Idetinfos)
  7689. var rf []*ResultFive
  7690. json.Unmarshal([]byte(infoStr), &rf)
  7691. var insutypes []*ResultFive
  7692. var insutype string
  7693. var is390 int = 0
  7694. var is310 int = 0
  7695. for _, item := range rf {
  7696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  7697. insutypes = append(insutypes, item)
  7698. }
  7699. }
  7700. if len(insutypes) == 1 {
  7701. insutype = insutypes[0].Insutype
  7702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7703. } else {
  7704. for _, i := range insutypes {
  7705. if i.Insutype == "390" {
  7706. is390 = 1
  7707. }
  7708. if i.Insutype == "310" {
  7709. is310 = 1
  7710. }
  7711. }
  7712. }
  7713. if is390 == 1 {
  7714. insutype = "390"
  7715. }
  7716. if is310 == 1 {
  7717. insutype = "310"
  7718. }
  7719. if len(insutypes) == 0 {
  7720. insutype = "390"
  7721. }
  7722. var insuplc_admdvs string
  7723. for _, item := range rf {
  7724. if item.Insutype == insutype {
  7725. insuplc_admdvs = item.InsuplcAdmdvs
  7726. }
  7727. }
  7728. psn := &models.HisPsn{
  7729. PsnNo: res.Output.Baseinfo.PsnNo,
  7730. PatientId: patient.ID,
  7731. Certno: res.Output.Baseinfo.Certno,
  7732. Gend: res.Output.Baseinfo.Gend,
  7733. Naty: res.Output.Baseinfo.Naty,
  7734. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7735. PsnName: res.Output.Baseinfo.PsnName,
  7736. Idetinfo: idetinfoStr,
  7737. Insuinfo: infoStr,
  7738. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7739. InsuplcAdmdvs: insuplc_admdvs,
  7740. }
  7741. service.CreateHisPsn(psn)
  7742. for _, item := range rf {
  7743. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7744. insutypes = append(insutypes, item)
  7745. }
  7746. }
  7747. if len(insutypes) == 1 {
  7748. insutype = insutypes[0].Insutype
  7749. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7750. } else {
  7751. for _, i := range insutypes {
  7752. if i.Insutype == "390" {
  7753. is390 = 1
  7754. }
  7755. if i.Insutype == "310" {
  7756. is310 = 1
  7757. }
  7758. }
  7759. }
  7760. if is390 == 1 {
  7761. insutype = "390"
  7762. }
  7763. if is310 == 1 {
  7764. insutype = "310"
  7765. }
  7766. if len(insutypes) == 0 {
  7767. insutype = "310"
  7768. }
  7769. c.ServeSuccessJSON(map[string]interface{}{
  7770. "patient": patient,
  7771. "number": res.Output.Baseinfo.Certno,
  7772. "insutype": insutype,
  7773. })
  7774. }
  7775. } else {
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7777. return
  7778. }
  7779. } else if miConfig.MdtrtareaAdmvs == "421182" {
  7780. var res ResultTwo
  7781. api := "http://192.168.0:9532/" + "hbyb/1101?cert_no=" + "" +
  7782. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7783. "&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)
  7784. resp, requestErr := http.Get(api)
  7785. if requestErr != nil {
  7786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7787. return
  7788. }
  7789. body, ioErr := ioutil.ReadAll(resp.Body)
  7790. if ioErr != nil {
  7791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. var respJSON map[string]interface{}
  7796. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7799. return
  7800. }
  7801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7802. result, _ := json.Marshal(respJSON)
  7803. fmt.Println("log")
  7804. fmt.Println(string(result))
  7805. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7806. utils.ErrorLog("解析失败:%v", err)
  7807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7808. return
  7809. }
  7810. if res.Infcode == 0 {
  7811. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7812. if err == gorm.ErrRecordNotFound {
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7814. return
  7815. } else if err != nil {
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7817. return
  7818. } else {
  7819. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7820. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7821. infoStr := string(Iinfos)
  7822. idetinfoStr := string(Idetinfos)
  7823. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7824. psn := &models.HisPsn{
  7825. PsnNo: res.Output.Baseinfo.PsnNo,
  7826. PatientId: patient.ID,
  7827. Certno: res.Output.Baseinfo.Certno,
  7828. Brdy: b,
  7829. Age: float64(age),
  7830. Gend: res.Output.Baseinfo.Gend,
  7831. Naty: res.Output.Baseinfo.Naty,
  7832. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7833. PsnName: res.Output.Baseinfo.PsnName,
  7834. Idetinfo: idetinfoStr,
  7835. Insuinfo: infoStr,
  7836. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7837. }
  7838. service.CreateHisPsn(psn)
  7839. var rf []*ResultFive
  7840. json.Unmarshal([]byte(infoStr), &rf)
  7841. var insutypes []*ResultFive
  7842. var insutype string
  7843. var is390 int = 0
  7844. var is310 int = 0
  7845. for _, item := range rf {
  7846. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7847. insutypes = append(insutypes, item)
  7848. }
  7849. }
  7850. if len(insutypes) == 1 {
  7851. insutype = insutypes[0].Insutype
  7852. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  7853. } else {
  7854. for _, i := range insutypes {
  7855. if i.Insutype == "390" {
  7856. is390 = 1
  7857. }
  7858. if i.Insutype == "310" {
  7859. is310 = 1
  7860. }
  7861. }
  7862. }
  7863. if is390 == 1 {
  7864. insutype = "390"
  7865. }
  7866. if is310 == 1 {
  7867. insutype = "310"
  7868. }
  7869. if len(insutypes) == 0 {
  7870. insutype = "310"
  7871. }
  7872. c.ServeSuccessJSON(map[string]interface{}{
  7873. "patient": patient,
  7874. "number": res.Output.Baseinfo.Certno,
  7875. "insutype": insutype,
  7876. })
  7877. }
  7878. } else {
  7879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7880. return
  7881. }
  7882. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7883. var api string
  7884. if miConfig.MdtrtareaAdmvs == "320921" {
  7885. 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 +
  7886. "&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
  7887. fmt.Println(api)
  7888. } else {
  7889. 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 +
  7890. "&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)
  7891. }
  7892. resp, requestErr := http.Get(api)
  7893. if requestErr != nil {
  7894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7895. return
  7896. }
  7897. body, ioErr := ioutil.ReadAll(resp.Body)
  7898. if ioErr != nil {
  7899. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7901. return
  7902. }
  7903. var respJSON map[string]interface{}
  7904. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7907. return
  7908. }
  7909. var status string
  7910. status = respJSON["data"].(map[string]interface{})["status"].(string)
  7911. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  7912. //console.log()
  7913. fmt.Println("type===")
  7914. fmt.Println(card_type)
  7915. var token string
  7916. var res ResultTwo //1101结果
  7917. var res10265 ResultTwo10265 //1101结果
  7918. var card_info string //卡信息
  7919. var busi_card_info string
  7920. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  7921. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7922. if status == "0" { //读卡成功
  7923. if card_type == "1" {
  7924. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7925. result, _ := json.Marshal(respJSON)
  7926. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7927. utils.ErrorLog("解析失败:%v", err)
  7928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7929. return
  7930. }
  7931. res.ErrMsg = res10265.ErrMsg
  7932. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7933. res.Infcode = infocode
  7934. res.Output = res10265.Output
  7935. res.InfRefmsgid = res10265.InfRefmsgid
  7936. } else {
  7937. //var card_info string //卡信息
  7938. //var busi_card_info string
  7939. token = respJSON["data"].(map[string]interface{})["token"].(string)
  7940. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  7941. //fmt.Println(card_info)
  7942. //fmt.Println(busi_card_info)
  7943. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  7944. result, _ := json.Marshal(respJSON)
  7945. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  7946. utils.ErrorLog("解析失败:%v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. res.ErrMsg = res10265.ErrMsg
  7951. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  7952. res.Infcode = infocode
  7953. res.Output = res10265.Output
  7954. res.InfRefmsgid = res10265.InfRefmsgid
  7955. }
  7956. if res.Infcode == 0 {
  7957. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  7958. if err == gorm.ErrRecordNotFound {
  7959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  7960. return
  7961. } else if err != nil {
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  7963. return
  7964. } else {
  7965. if card_type == "1" {
  7966. bas := strings.Split(card_info, "|")
  7967. basNumber := bas[2]
  7968. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7969. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7970. infoStr := string(Iinfos)
  7971. idetinfoStr := string(Idetinfos)
  7972. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  7973. psn := &models.HisPsn{
  7974. PsnNo: res.Output.Baseinfo.PsnNo,
  7975. PatientId: patient.ID,
  7976. Certno: res.Output.Baseinfo.Certno,
  7977. Brdy: b,
  7978. Age: float64(age),
  7979. Gend: res.Output.Baseinfo.Gend,
  7980. Naty: res.Output.Baseinfo.Naty,
  7981. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7982. PsnName: res.Output.Baseinfo.PsnName,
  7983. Idetinfo: idetinfoStr,
  7984. Insuinfo: infoStr,
  7985. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7986. CardInfo: card_info,
  7987. VerifyNumber: busi_card_info,
  7988. }
  7989. service.CreateHisPsn(psn)
  7990. var rf []*ResultFive
  7991. json.Unmarshal([]byte(infoStr), &rf)
  7992. var insutypes []*ResultFive
  7993. var insutype string
  7994. var is390 int = 0
  7995. var is310 int = 0
  7996. for _, item := range rf {
  7997. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7998. insutypes = append(insutypes, item)
  7999. }
  8000. }
  8001. if len(insutypes) == 1 {
  8002. insutype = insutypes[0].Insutype
  8003. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8004. } else {
  8005. for _, i := range insutypes {
  8006. if i.Insutype == "390" {
  8007. is390 = 1
  8008. }
  8009. if i.Insutype == "310" {
  8010. is310 = 1
  8011. }
  8012. }
  8013. }
  8014. if is390 == 1 {
  8015. insutype = "390"
  8016. }
  8017. if is310 == 1 {
  8018. insutype = "310"
  8019. }
  8020. if len(insutypes) == 0 {
  8021. insutype = "310"
  8022. }
  8023. c.ServeSuccessJSON(map[string]interface{}{
  8024. "patient": patient,
  8025. "number": basNumber,
  8026. "insutype": insutype,
  8027. })
  8028. } else {
  8029. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8030. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8031. infoStr := string(Iinfos)
  8032. idetinfoStr := string(Idetinfos)
  8033. psn := &models.HisPsn{
  8034. PsnNo: res.Output.Baseinfo.PsnNo,
  8035. PatientId: patient.ID,
  8036. Certno: res.Output.Baseinfo.Certno,
  8037. Gend: res.Output.Baseinfo.Gend,
  8038. Naty: res.Output.Baseinfo.Naty,
  8039. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8040. PsnName: res.Output.Baseinfo.PsnName,
  8041. Idetinfo: idetinfoStr,
  8042. Insuinfo: infoStr,
  8043. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8044. CardInfo: card_info,
  8045. VerifyNumber: token,
  8046. }
  8047. service.CreateHisPsn(psn)
  8048. c.ServeSuccessJSON(map[string]interface{}{
  8049. "patient": patient,
  8050. "number": token,
  8051. })
  8052. }
  8053. }
  8054. } else {
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8056. return
  8057. }
  8058. } else { //读卡失败
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8060. return
  8061. }
  8062. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8063. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  8064. cardnum = DeleteExtraSpaceTwo(cardnum)
  8065. cardCode = DeleteExtraSpaceTwo(cardCode)
  8066. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  8067. name = DeleteExtraSpaceTwo(name)
  8068. errmsg = DeleteExtraSpaceTwo(errmsg)
  8069. cardnum = Remove0000(cardnum)
  8070. cardCode = Remove0000(cardCode)
  8071. id_card_no = Remove0000(id_card_no)
  8072. name = Remove0000(name)
  8073. errmsg = Remove0000(errmsg)
  8074. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  8075. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  8076. //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)
  8077. //fmt.Println(result2)
  8078. //fmt.Println(requestLog2)
  8079. //fmt.Println(errMsgLog2)
  8080. 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)
  8081. saveLog(result, requestLog, "1101", "获取人员信息")
  8082. fmt.Println(errMsgLog)
  8083. if len(errMsgLog) > 0 {
  8084. } else {
  8085. var dat map[string]interface{}
  8086. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8087. fmt.Println(dat)
  8088. } else {
  8089. fmt.Println(err)
  8090. }
  8091. userJSONBytes, _ := json.Marshal(dat)
  8092. var res ResultTwo
  8093. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8094. utils.ErrorLog("解析失败:%v", err)
  8095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8096. return
  8097. }
  8098. res.ErrMsg = errMsgLog
  8099. if res.Infcode == 0 {
  8100. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  8101. if err == gorm.ErrRecordNotFound {
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8103. return
  8104. } else if err != nil {
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8106. return
  8107. } else {
  8108. fmt.Println(res)
  8109. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8110. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8111. infoStr := string(Iinfos)
  8112. idetinfoStr := string(Idetinfos)
  8113. var rf []*ResultFive
  8114. json.Unmarshal([]byte(infoStr), &rf)
  8115. var insutypes []*ResultFive
  8116. var insutype string
  8117. var is390 int = 0
  8118. var is310 int = 0
  8119. for _, item := range rf {
  8120. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  8121. insutypes = append(insutypes, item)
  8122. }
  8123. }
  8124. if len(insutypes) == 1 {
  8125. insutype = insutypes[0].Insutype
  8126. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8127. } else {
  8128. for _, i := range insutypes {
  8129. if i.Insutype == "390" {
  8130. is390 = 1
  8131. }
  8132. if i.Insutype == "310" {
  8133. is310 = 1
  8134. }
  8135. }
  8136. }
  8137. if is390 == 1 {
  8138. insutype = "390"
  8139. }
  8140. if is310 == 1 {
  8141. insutype = "310"
  8142. }
  8143. if len(insutypes) == 0 {
  8144. insutype = "390"
  8145. }
  8146. var insuplc_admdvs string
  8147. for _, item := range rf {
  8148. if item.Insutype == insutype {
  8149. insuplc_admdvs = item.InsuplcAdmdvs
  8150. }
  8151. }
  8152. psn := &models.HisPsn{
  8153. PsnNo: res.Output.Baseinfo.PsnNo,
  8154. PatientId: patient.ID,
  8155. Certno: res.Output.Baseinfo.Certno,
  8156. Gend: res.Output.Baseinfo.Gend,
  8157. Naty: res.Output.Baseinfo.Naty,
  8158. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8159. PsnName: res.Output.Baseinfo.PsnName,
  8160. Idetinfo: idetinfoStr,
  8161. Insuinfo: infoStr,
  8162. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8163. CardInfo: basStr,
  8164. VerifyNumber: "",
  8165. InsuplcAdmdvs: insuplc_admdvs,
  8166. }
  8167. service.CreateHisPsn(psn)
  8168. c.ServeSuccessJSON(map[string]interface{}{
  8169. "patient": patient,
  8170. "number": cardnum,
  8171. "insutype": insutype,
  8172. })
  8173. }
  8174. } else {
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8176. return
  8177. }
  8178. }
  8179. } else if miConfig.MdtrtareaAdmvs == "360302" {
  8180. fmt.Println(initFlag)
  8181. fmt.Println("initFlag")
  8182. if initFlag == 0 {
  8183. c.TestGetJiangXiBasBaseInit()
  8184. }
  8185. basStr := c.GetBasBaseInfo()
  8186. if len(basStr) == 0 {
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8188. return
  8189. }
  8190. fmt.Println(basStr)
  8191. bas := strings.Split(basStr, "|")
  8192. basNumber := bas[1]
  8193. fmt.Println(basNumber)
  8194. card_sn := bas[3]
  8195. fmt.Println(card_sn)
  8196. 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, "")
  8197. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8198. var dat map[string]interface{}
  8199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8200. fmt.Println(dat)
  8201. } else {
  8202. fmt.Println(err)
  8203. }
  8204. userJSONBytes, _ := json.Marshal(dat)
  8205. var res ResultTwo
  8206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8207. utils.ErrorLog("解析失败:%v", err)
  8208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8209. return
  8210. }
  8211. if res.Infcode == 0 {
  8212. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8213. if err == gorm.ErrRecordNotFound {
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8215. return
  8216. } else if err != nil {
  8217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8218. return
  8219. } else {
  8220. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8221. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8222. infoStr := string(Iinfos)
  8223. idetinfoStr := string(Idetinfos)
  8224. var rf []*ResultFive
  8225. json.Unmarshal([]byte(infoStr), &rf)
  8226. var insutypes []*ResultFive
  8227. var insutype string
  8228. var is390 int = 0
  8229. var is310 int = 0
  8230. var insuplc_admdvs string
  8231. for _, item := range rf {
  8232. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8233. insutypes = append(insutypes, item)
  8234. }
  8235. }
  8236. if len(insutypes) == 1 {
  8237. insutype = insutypes[0].Insutype
  8238. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8239. } else {
  8240. for _, i := range insutypes {
  8241. if i.Insutype == "390" {
  8242. is390 = 1
  8243. }
  8244. if i.Insutype == "310" {
  8245. is310 = 1
  8246. }
  8247. }
  8248. }
  8249. if is390 == 1 {
  8250. insutype = "390"
  8251. }
  8252. if is310 == 1 {
  8253. insutype = "310"
  8254. }
  8255. if len(insutypes) == 0 {
  8256. insutype = "310"
  8257. }
  8258. for _, item := range rf {
  8259. if item.Insutype == insutype && item.PsnInsuStas == "1" {
  8260. insuplc_admdvs = item.InsuplcAdmdvs
  8261. }
  8262. }
  8263. psn := &models.HisPsn{
  8264. PsnNo: res.Output.Baseinfo.PsnNo,
  8265. PatientId: patient.ID,
  8266. Certno: res.Output.Baseinfo.Certno,
  8267. Gend: res.Output.Baseinfo.Gend,
  8268. Naty: res.Output.Baseinfo.Naty,
  8269. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8270. PsnName: res.Output.Baseinfo.PsnName,
  8271. Idetinfo: idetinfoStr,
  8272. Insuinfo: infoStr,
  8273. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8274. CardInfo: basStr,
  8275. InsuplcAdmdvs: insuplc_admdvs,
  8276. VerifyNumber: "",
  8277. }
  8278. service.CreateHisPsn(psn)
  8279. c.ServeSuccessJSON(map[string]interface{}{
  8280. "patient": patient,
  8281. "number": basNumber,
  8282. "insutype": insutype,
  8283. })
  8284. }
  8285. } else {
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8287. return
  8288. }
  8289. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8290. fmt.Println(initFlag)
  8291. fmt.Println("initFlag")
  8292. if initFlag == 0 {
  8293. c.TestGetHnBasBaseInit()
  8294. }
  8295. basStr := c.GetBasBaseInfo()
  8296. if len(basStr) == 0 {
  8297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8298. return
  8299. }
  8300. fmt.Println(basStr)
  8301. bas := strings.Split(basStr, "|")
  8302. basNumber := bas[1]
  8303. fmt.Println(basNumber)
  8304. card_sn := bas[3]
  8305. card_no := bas[2]
  8306. fmt.Println(card_sn)
  8307. name := bas[4]
  8308. name = ConvertToString(name, "gbk", "utf-8")
  8309. 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)
  8310. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  8311. var dat map[string]interface{}
  8312. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8313. fmt.Println(dat)
  8314. } else {
  8315. fmt.Println(err)
  8316. }
  8317. userJSONBytes, _ := json.Marshal(dat)
  8318. var res ResultTwo
  8319. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8320. utils.ErrorLog("解析失败:%v", err)
  8321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8322. return
  8323. }
  8324. if res.Infcode == 0 {
  8325. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8326. if err == gorm.ErrRecordNotFound {
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8328. return
  8329. } else if err != nil {
  8330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8331. return
  8332. } else {
  8333. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8334. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8335. infoStr := string(Iinfos)
  8336. idetinfoStr := string(Idetinfos)
  8337. psn := &models.HisPsn{
  8338. PsnNo: res.Output.Baseinfo.PsnNo,
  8339. PatientId: patient.ID,
  8340. Certno: res.Output.Baseinfo.Certno,
  8341. Gend: res.Output.Baseinfo.Gend,
  8342. Naty: res.Output.Baseinfo.Naty,
  8343. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8344. PsnName: res.Output.Baseinfo.PsnName,
  8345. Idetinfo: idetinfoStr,
  8346. Insuinfo: infoStr,
  8347. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8348. CardInfo: basStr,
  8349. VerifyNumber: "",
  8350. }
  8351. service.CreateHisPsn(psn)
  8352. var rf []*ResultFive
  8353. json.Unmarshal([]byte(infoStr), &rf)
  8354. var insutypes []*ResultFive
  8355. var insutype string
  8356. var is390 int = 0
  8357. var is310 int = 0
  8358. for _, item := range rf {
  8359. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8360. insutypes = append(insutypes, item)
  8361. }
  8362. }
  8363. if len(insutypes) == 1 {
  8364. insutype = insutypes[0].Insutype
  8365. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8366. } else {
  8367. for _, i := range insutypes {
  8368. if i.Insutype == "390" {
  8369. is390 = 1
  8370. }
  8371. if i.Insutype == "310" {
  8372. is310 = 1
  8373. }
  8374. }
  8375. }
  8376. if is390 == 1 {
  8377. insutype = "390"
  8378. }
  8379. if is310 == 1 {
  8380. insutype = "310"
  8381. }
  8382. if len(insutypes) == 0 {
  8383. insutype = "310"
  8384. }
  8385. c.ServeSuccessJSON(map[string]interface{}{
  8386. "patient": patient,
  8387. "number": basNumber,
  8388. "insutype": insutype,
  8389. })
  8390. }
  8391. } else {
  8392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8393. return
  8394. }
  8395. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8396. var api string
  8397. 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 +
  8398. "&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
  8399. fmt.Println(api)
  8400. resp, requestErr := http.Get(api)
  8401. if requestErr != nil {
  8402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8403. return
  8404. }
  8405. body, ioErr := ioutil.ReadAll(resp.Body)
  8406. if ioErr != nil {
  8407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8409. return
  8410. }
  8411. var respJSON map[string]interface{}
  8412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8415. return
  8416. }
  8417. var res ResultTwo //1101结果
  8418. var res10265 ResultTwo10265 //1101结果
  8419. var card_info string //卡信息
  8420. token := respJSON["data"].(map[string]interface{})["token"].(string)
  8421. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8422. result, _ := json.Marshal(respJSON)
  8423. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8424. utils.ErrorLog("解析失败:%v", err)
  8425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8426. return
  8427. }
  8428. res.ErrMsg = res10265.ErrMsg
  8429. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8430. res.Infcode = infocode
  8431. res.Output = res10265.Output
  8432. res.InfRefmsgid = res10265.InfRefmsgid
  8433. if res.Infcode == 0 {
  8434. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8435. if err == gorm.ErrRecordNotFound {
  8436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8437. return
  8438. } else if err != nil {
  8439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8440. return
  8441. } else {
  8442. bas := strings.Split(card_info, "|")
  8443. basNumber := bas[2]
  8444. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8445. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8446. infoStr := string(Iinfos)
  8447. idetinfoStr := string(Idetinfos)
  8448. psn := &models.HisPsn{
  8449. PsnNo: res.Output.Baseinfo.PsnNo,
  8450. PatientId: patient.ID,
  8451. Certno: res.Output.Baseinfo.Certno,
  8452. Gend: res.Output.Baseinfo.Gend,
  8453. Naty: res.Output.Baseinfo.Naty,
  8454. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8455. PsnName: res.Output.Baseinfo.PsnName,
  8456. Idetinfo: idetinfoStr,
  8457. Insuinfo: infoStr,
  8458. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8459. CardInfo: card_info,
  8460. VerifyNumber: token,
  8461. }
  8462. service.CreateHisPsn(psn)
  8463. var rf []*ResultFive
  8464. json.Unmarshal([]byte(infoStr), &rf)
  8465. var insutypes []*ResultFive
  8466. var insutype string
  8467. var is390 int = 0
  8468. var is310 int = 0
  8469. for _, item := range rf {
  8470. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8471. insutypes = append(insutypes, item)
  8472. }
  8473. }
  8474. if len(insutypes) == 1 {
  8475. insutype = insutypes[0].Insutype
  8476. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8477. } else {
  8478. for _, i := range insutypes {
  8479. if i.Insutype == "390" {
  8480. is390 = 1
  8481. }
  8482. if i.Insutype == "310" {
  8483. is310 = 1
  8484. }
  8485. }
  8486. }
  8487. if is390 == 1 {
  8488. insutype = "390"
  8489. }
  8490. if is310 == 1 {
  8491. insutype = "310"
  8492. }
  8493. if len(insutypes) == 0 {
  8494. insutype = "310"
  8495. }
  8496. c.ServeSuccessJSON(map[string]interface{}{
  8497. "patient": patient,
  8498. "number": basNumber,
  8499. "insutype": insutype,
  8500. })
  8501. }
  8502. } else {
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8504. return
  8505. }
  8506. } else if miConfig.MdtrtareaAdmvs == "450721" {
  8507. res := c.GetoleInfo()
  8508. if res.Infcode == 0 {
  8509. var result string
  8510. if res.Output.MdtrtCertType == "01" {
  8511. 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)
  8512. } else if res.Output.MdtrtCertType == "02" {
  8513. 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)
  8514. } else if res.Output.MdtrtCertType == "03" {
  8515. 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)
  8516. }
  8517. var dat map[string]interface{}
  8518. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8519. fmt.Println(dat)
  8520. } else {
  8521. fmt.Println(err)
  8522. }
  8523. userJSONBytes, _ := json.Marshal(dat)
  8524. var res2 ResultTwo
  8525. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. if res2.Infcode == 0 {
  8531. patient, err := service.GetPatientByNumber(res.Output.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(res2.Output.Iinfo)
  8540. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  8541. infoStr := string(Iinfos)
  8542. idetinfoStr := string(Idetinfos)
  8543. var rf []*ResultFive
  8544. json.Unmarshal([]byte(infoStr), &rf)
  8545. var insutypes []*ResultFive
  8546. var insutype string
  8547. var is390 int = 0
  8548. var is310 int = 0
  8549. //var insuplc_admdvs string
  8550. for _, item := range rf {
  8551. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8552. insutypes = append(insutypes, item)
  8553. }
  8554. }
  8555. if len(insutypes) == 1 {
  8556. insutype = insutypes[0].Insutype
  8557. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8558. } else {
  8559. for _, i := range insutypes {
  8560. if i.Insutype == "390" {
  8561. is390 = 1
  8562. }
  8563. if i.Insutype == "310" {
  8564. is310 = 1
  8565. }
  8566. }
  8567. }
  8568. if is390 == 1 {
  8569. insutype = "390"
  8570. }
  8571. if is310 == 1 {
  8572. insutype = "310"
  8573. }
  8574. if len(insutypes) == 0 {
  8575. insutype = "310"
  8576. }
  8577. psn := &models.HisPsn{
  8578. PsnNo: res2.Output.Baseinfo.PsnNo,
  8579. PatientId: patient.ID,
  8580. Certno: res2.Output.Baseinfo.Certno,
  8581. Gend: res2.Output.Baseinfo.Gend,
  8582. Naty: res2.Output.Baseinfo.Naty,
  8583. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  8584. PsnName: res2.Output.Baseinfo.PsnName,
  8585. Idetinfo: idetinfoStr,
  8586. Insuinfo: infoStr,
  8587. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8588. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  8589. VerifyNumber: res.Output.EcToken,
  8590. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  8591. }
  8592. if res.Output.MdtrtCertType == "01" {
  8593. psn.VerifyNumber = res.Output.EcToken
  8594. //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)
  8595. } else if res.Output.MdtrtCertType == "02" {
  8596. psn.VerifyNumber = res.Output.MdtrtCertNo
  8597. //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)
  8598. } else if res.Output.MdtrtCertType == "03" {
  8599. psn.VerifyNumber = res.Output.MdtrtCertNo
  8600. //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)
  8601. }
  8602. var balc float64
  8603. for _, item := range rf {
  8604. if item.Insutype == insutype {
  8605. balc = item.Balc
  8606. }
  8607. }
  8608. service.CreateHisPsn(psn)
  8609. c.ServeSuccessJSON(map[string]interface{}{
  8610. "patient": patient,
  8611. "number": res.Output.CardNo,
  8612. "insutype": insutype,
  8613. "blac": balc,
  8614. "desc": idetinfoStr,
  8615. })
  8616. }
  8617. } else {
  8618. c.ServeSuccessJSON(map[string]interface{}{
  8619. "failed_code": -10,
  8620. "msg": res2.ErrMsg,
  8621. })
  8622. }
  8623. } else {
  8624. c.ServeSuccessJSON(map[string]interface{}{
  8625. "failed_code": -10,
  8626. "msg": res.ErrMsg,
  8627. })
  8628. }
  8629. } else if miConfig.MdtrtareaAdmvs == "341203" {
  8630. var api string
  8631. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  8632. "&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
  8633. fmt.Println(api)
  8634. resp, requestErr := http.Get(api)
  8635. if requestErr != nil {
  8636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8637. return
  8638. }
  8639. body, ioErr := ioutil.ReadAll(resp.Body)
  8640. if ioErr != nil {
  8641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. var respJSON map[string]interface{}
  8646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8649. return
  8650. }
  8651. var status string
  8652. status = respJSON["data"].(map[string]interface{})["status"].(string)
  8653. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  8654. //console.log()
  8655. fmt.Println("type===")
  8656. fmt.Println(card_type)
  8657. var token string
  8658. var res ResultTwo //1101结果
  8659. //var res10265 ResultTwoesultTwo10265 //1101结果
  8660. var card_info string //卡信息
  8661. var busi_card_info string
  8662. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  8663. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  8664. if status == "0" { //读卡成功
  8665. if card_type == "1" {
  8666. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8667. result, _ := json.Marshal(respJSON)
  8668. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8669. utils.ErrorLog("解析失败:%v", err)
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. } else {
  8674. token = respJSON["data"].(map[string]interface{})["token"].(string)
  8675. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  8676. result, _ := json.Marshal(respJSON)
  8677. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8678. utils.ErrorLog("解析失败:%v", err)
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. }
  8683. if res.Infcode == 0 {
  8684. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  8685. if err == gorm.ErrRecordNotFound {
  8686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8687. return
  8688. } else if err != nil {
  8689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8690. return
  8691. } else {
  8692. if card_type == "1" {
  8693. bas := strings.Split(card_info, "|")
  8694. basNumber := bas[2]
  8695. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8696. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8697. infoStr := string(Iinfos)
  8698. idetinfoStr := string(Idetinfos)
  8699. psn := &models.HisPsn{
  8700. PsnNo: res.Output.Baseinfo.PsnNo,
  8701. PatientId: patient.ID,
  8702. Certno: res.Output.Baseinfo.Certno,
  8703. Gend: res.Output.Baseinfo.Gend,
  8704. Naty: res.Output.Baseinfo.Naty,
  8705. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8706. PsnName: res.Output.Baseinfo.PsnName,
  8707. Idetinfo: idetinfoStr,
  8708. Insuinfo: infoStr,
  8709. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8710. CardInfo: card_info,
  8711. VerifyNumber: busi_card_info,
  8712. }
  8713. service.CreateHisPsn(psn)
  8714. var rf []*ResultFive
  8715. json.Unmarshal([]byte(infoStr), &rf)
  8716. var insutypes []*ResultFive
  8717. var insutype string
  8718. var is390 int = 0
  8719. var is310 int = 0
  8720. for _, item := range rf {
  8721. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8722. insutypes = append(insutypes, item)
  8723. }
  8724. }
  8725. if len(insutypes) == 1 {
  8726. insutype = insutypes[0].Insutype
  8727. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8728. } else {
  8729. for _, i := range insutypes {
  8730. if i.Insutype == "390" {
  8731. is390 = 1
  8732. }
  8733. if i.Insutype == "310" {
  8734. is310 = 1
  8735. }
  8736. }
  8737. }
  8738. if is390 == 1 {
  8739. insutype = "390"
  8740. }
  8741. if is310 == 1 {
  8742. insutype = "310"
  8743. }
  8744. if len(insutypes) == 0 {
  8745. insutype = "310"
  8746. }
  8747. c.ServeSuccessJSON(map[string]interface{}{
  8748. "patient": patient,
  8749. "number": basNumber,
  8750. "insutype": insutype,
  8751. })
  8752. } else {
  8753. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8754. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8755. infoStr := string(Iinfos)
  8756. idetinfoStr := string(Idetinfos)
  8757. psn := &models.HisPsn{
  8758. PsnNo: res.Output.Baseinfo.PsnNo,
  8759. PatientId: patient.ID,
  8760. Certno: res.Output.Baseinfo.Certno,
  8761. Gend: res.Output.Baseinfo.Gend,
  8762. Naty: res.Output.Baseinfo.Naty,
  8763. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8764. PsnName: res.Output.Baseinfo.PsnName,
  8765. Idetinfo: idetinfoStr,
  8766. Insuinfo: infoStr,
  8767. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8768. CardInfo: card_info,
  8769. VerifyNumber: token,
  8770. }
  8771. service.CreateHisPsn(psn)
  8772. c.ServeSuccessJSON(map[string]interface{}{
  8773. "patient": patient,
  8774. "number": token,
  8775. })
  8776. }
  8777. }
  8778. } else {
  8779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8780. return
  8781. }
  8782. } else { //读卡失败
  8783. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8784. return
  8785. }
  8786. } else {
  8787. if initFlag == 0 {
  8788. c.TestGetBasBaseInit()
  8789. }
  8790. basStr := c.GetBasBaseInfo()
  8791. if len(basStr) == 0 {
  8792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8793. return
  8794. }
  8795. fmt.Println(basStr)
  8796. bas := strings.Split(basStr, "|")
  8797. basNumber := bas[1]
  8798. fmt.Println(basNumber)
  8799. card_sn := bas[3]
  8800. fmt.Println(card_sn)
  8801. cardNumber := bas[2]
  8802. fmt.Println(cardNumber)
  8803. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  8804. var result string
  8805. if bas[0][:2] == "44" {
  8806. 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)
  8807. } else {
  8808. 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)
  8809. }
  8810. var dat map[string]interface{}
  8811. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8812. fmt.Println(dat)
  8813. } else {
  8814. fmt.Println(err)
  8815. }
  8816. userJSONBytes, _ := json.Marshal(dat)
  8817. var res ResultTwo
  8818. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8819. utils.ErrorLog("解析失败:%v", err)
  8820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8821. return
  8822. }
  8823. if res.Infcode == 0 {
  8824. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  8825. if err == gorm.ErrRecordNotFound {
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8827. return
  8828. } else if err != nil {
  8829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8830. return
  8831. } else {
  8832. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8833. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8834. infoStr := string(Iinfos)
  8835. idetinfoStr := string(Idetinfos)
  8836. var rf []*ResultFive
  8837. json.Unmarshal([]byte(infoStr), &rf)
  8838. var insutypes []*ResultFive
  8839. var insutype string
  8840. var is390 int = 0
  8841. var is310 int = 0
  8842. var insuplc_admdvs string
  8843. for _, item := range rf {
  8844. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8845. insutypes = append(insutypes, item)
  8846. }
  8847. }
  8848. if len(insutypes) == 1 {
  8849. insutype = insutypes[0].Insutype
  8850. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8851. } else {
  8852. for _, i := range insutypes {
  8853. if i.Insutype == "390" {
  8854. is390 = 1
  8855. }
  8856. if i.Insutype == "310" {
  8857. is310 = 1
  8858. }
  8859. }
  8860. }
  8861. if is390 == 1 {
  8862. insutype = "390"
  8863. }
  8864. if is310 == 1 {
  8865. insutype = "310"
  8866. }
  8867. if len(insutypes) == 0 {
  8868. insutype = "310"
  8869. }
  8870. for _, item := range rf {
  8871. if item.Insutype == insutype {
  8872. insuplc_admdvs = item.InsuplcAdmdvs
  8873. }
  8874. }
  8875. psn := &models.HisPsn{
  8876. PsnNo: res.Output.Baseinfo.PsnNo,
  8877. PatientId: patient.ID,
  8878. Certno: res.Output.Baseinfo.Certno,
  8879. Gend: res.Output.Baseinfo.Gend,
  8880. Naty: res.Output.Baseinfo.Naty,
  8881. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8882. PsnName: res.Output.Baseinfo.PsnName,
  8883. Idetinfo: idetinfoStr,
  8884. Insuinfo: infoStr,
  8885. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8886. CardInfo: basStr,
  8887. VerifyNumber: "",
  8888. InsuplcAdmdvs: insuplc_admdvs,
  8889. }
  8890. service.CreateHisPsn(psn)
  8891. c.ServeSuccessJSON(map[string]interface{}{
  8892. "patient": patient,
  8893. "number": basNumber,
  8894. })
  8895. }
  8896. } else {
  8897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8898. return
  8899. }
  8900. break
  8901. }
  8902. case 2:
  8903. if miConfig.MdtrtareaAdmvs == "430800" {
  8904. if initFlag == 0 {
  8905. c.TestGetHnBasBaseInit()
  8906. }
  8907. SFZStr := c.GetSFZBaseInfo()
  8908. if len(SFZStr) == 0 {
  8909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  8910. return
  8911. }
  8912. fmt.Println(SFZStr)
  8913. id_card_str := strings.Split(SFZStr, "^")
  8914. card_no := id_card_str[0]
  8915. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8916. //name := id_card_str[1]
  8917. //name = ConvertToString(name, "gbk", "utf-8")
  8918. 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)
  8919. var dat map[string]interface{}
  8920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8921. fmt.Println(dat)
  8922. } else {
  8923. fmt.Println(err)
  8924. }
  8925. userJSONBytes, _ := json.Marshal(dat)
  8926. var res ResultTwo
  8927. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8928. utils.ErrorLog("解析失败:%v", err)
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. return
  8931. }
  8932. if res.Infcode == 0 {
  8933. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  8934. if err == gorm.ErrRecordNotFound {
  8935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  8936. return
  8937. } else if err != nil {
  8938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  8939. return
  8940. } else {
  8941. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8942. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8943. infoStr := string(Iinfos)
  8944. idetinfoStr := string(Idetinfos)
  8945. var rf []*ResultFive
  8946. json.Unmarshal([]byte(infoStr), &rf)
  8947. var insutypes []*ResultFive
  8948. var insutype string
  8949. var is390 int = 0
  8950. var is310 int = 0
  8951. for _, item := range rf {
  8952. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8953. insutypes = append(insutypes, item)
  8954. }
  8955. }
  8956. if len(insutypes) == 1 {
  8957. insutype = insutypes[0].Insutype
  8958. } else {
  8959. for _, i := range insutypes {
  8960. if i.Insutype == "390" {
  8961. is390 = 1
  8962. }
  8963. if i.Insutype == "310" {
  8964. is310 = 1
  8965. }
  8966. }
  8967. }
  8968. if is390 == 1 {
  8969. insutype = "390"
  8970. }
  8971. if is310 == 1 {
  8972. insutype = "310"
  8973. }
  8974. if len(insutypes) == 0 {
  8975. insutype = "310"
  8976. }
  8977. var InsuplcAdmdvs string
  8978. for _, item := range rf {
  8979. if item.Insutype == insutype {
  8980. InsuplcAdmdvs = item.InsuplcAdmdvs
  8981. }
  8982. }
  8983. psn := &models.HisPsn{
  8984. PsnNo: res.Output.Baseinfo.PsnNo,
  8985. PatientId: patient.ID,
  8986. Certno: res.Output.Baseinfo.Certno,
  8987. Gend: res.Output.Baseinfo.Gend,
  8988. Naty: res.Output.Baseinfo.Naty,
  8989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  8990. PsnName: res.Output.Baseinfo.PsnName,
  8991. Idetinfo: idetinfoStr,
  8992. Insuinfo: infoStr,
  8993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  8994. CardInfo: SFZStr,
  8995. VerifyNumber: "",
  8996. InsuplcAdmdvs: InsuplcAdmdvs,
  8997. }
  8998. service.CreateHisPsn(psn)
  8999. c.ServeSuccessJSON(map[string]interface{}{
  9000. "patient": patient,
  9001. "number": card_no,
  9002. "insutype": insutype,
  9003. })
  9004. }
  9005. } else {
  9006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9007. return
  9008. }
  9009. } else if miConfig.MdtrtareaAdmvs == "420200" {
  9010. var res ResultTwo
  9011. api := "http://192.168.0.197:9532/" + "hbyb/1101?cert_no=" + "" +
  9012. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9013. "&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)
  9014. resp, requestErr := http.Get(api)
  9015. if requestErr != nil {
  9016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9017. return
  9018. }
  9019. body, ioErr := ioutil.ReadAll(resp.Body)
  9020. if ioErr != nil {
  9021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9023. return
  9024. }
  9025. var respJSON map[string]interface{}
  9026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9029. return
  9030. }
  9031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9032. result, _ := json.Marshal(respJSON)
  9033. fmt.Println("log")
  9034. fmt.Println(string(result))
  9035. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9036. utils.ErrorLog("解析失败:%v", err)
  9037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9038. return
  9039. }
  9040. if res.Infcode == 0 {
  9041. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9042. if err == gorm.ErrRecordNotFound {
  9043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9044. return
  9045. } else if err != nil {
  9046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9047. return
  9048. } else {
  9049. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9050. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9051. infoStr := string(Iinfos)
  9052. idetinfoStr := string(Idetinfos)
  9053. psn := &models.HisPsn{
  9054. PsnNo: res.Output.Baseinfo.PsnNo,
  9055. PatientId: patient.ID,
  9056. Certno: res.Output.Baseinfo.Certno,
  9057. Gend: res.Output.Baseinfo.Gend,
  9058. Naty: res.Output.Baseinfo.Naty,
  9059. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9060. PsnName: res.Output.Baseinfo.PsnName,
  9061. Idetinfo: idetinfoStr,
  9062. Insuinfo: infoStr,
  9063. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9064. }
  9065. service.CreateHisPsn(psn)
  9066. c.ServeSuccessJSON(map[string]interface{}{
  9067. "patient": patient,
  9068. "number": res.Output.Baseinfo.Certno,
  9069. })
  9070. }
  9071. } else {
  9072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9073. return
  9074. }
  9075. } else if miConfig.MdtrtareaAdmvs == "421182" {
  9076. var res ResultTwo
  9077. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9078. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9079. "&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)
  9080. resp, requestErr := http.Get(api)
  9081. if requestErr != nil {
  9082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9083. return
  9084. }
  9085. body, ioErr := ioutil.ReadAll(resp.Body)
  9086. if ioErr != nil {
  9087. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9089. return
  9090. }
  9091. var respJSON map[string]interface{}
  9092. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9093. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9095. return
  9096. }
  9097. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9098. result, _ := json.Marshal(respJSON)
  9099. fmt.Println("log")
  9100. fmt.Println(string(result))
  9101. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9102. utils.ErrorLog("解析失败:%v", err)
  9103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9104. return
  9105. }
  9106. if res.Infcode == 0 {
  9107. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9108. if err == gorm.ErrRecordNotFound {
  9109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9110. return
  9111. } else if err != nil {
  9112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9113. return
  9114. } else {
  9115. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9116. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9117. infoStr := string(Iinfos)
  9118. idetinfoStr := string(Idetinfos)
  9119. psn := &models.HisPsn{
  9120. PsnNo: res.Output.Baseinfo.PsnNo,
  9121. PatientId: patient.ID,
  9122. Certno: res.Output.Baseinfo.Certno,
  9123. Gend: res.Output.Baseinfo.Gend,
  9124. Naty: res.Output.Baseinfo.Naty,
  9125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9126. PsnName: res.Output.Baseinfo.PsnName,
  9127. Idetinfo: idetinfoStr,
  9128. Insuinfo: infoStr,
  9129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9130. }
  9131. service.CreateHisPsn(psn)
  9132. c.ServeSuccessJSON(map[string]interface{}{
  9133. "patient": patient,
  9134. "number": res.Output.Baseinfo.Certno,
  9135. })
  9136. }
  9137. } else {
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9139. return
  9140. }
  9141. } else if miConfig.MdtrtareaAdmvs == "420902" {
  9142. var res ResultTwo
  9143. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  9144. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9145. "&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)
  9146. resp, requestErr := http.Get(api)
  9147. if requestErr != nil {
  9148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9149. return
  9150. }
  9151. body, ioErr := ioutil.ReadAll(resp.Body)
  9152. if ioErr != nil {
  9153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. return
  9156. }
  9157. var respJSON map[string]interface{}
  9158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9164. result, _ := json.Marshal(respJSON)
  9165. fmt.Println("log")
  9166. fmt.Println(string(result))
  9167. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9168. utils.ErrorLog("解析失败:%v", err)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. if res.Infcode == 0 {
  9173. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9174. if err == gorm.ErrRecordNotFound {
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9176. return
  9177. } else if err != nil {
  9178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9179. return
  9180. } else {
  9181. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9182. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9183. infoStr := string(Iinfos)
  9184. idetinfoStr := string(Idetinfos)
  9185. var rf []*ResultFive
  9186. json.Unmarshal([]byte(infoStr), &rf)
  9187. var insutypes []*ResultFive
  9188. var insutype string
  9189. var is390 int = 0
  9190. var is310 int = 0
  9191. for _, item := range rf {
  9192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  9193. insutypes = append(insutypes, item)
  9194. }
  9195. }
  9196. if len(insutypes) == 1 {
  9197. insutype = insutypes[0].Insutype
  9198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9199. } else {
  9200. for _, i := range insutypes {
  9201. if i.Insutype == "390" {
  9202. is390 = 1
  9203. }
  9204. if i.Insutype == "310" {
  9205. is310 = 1
  9206. }
  9207. }
  9208. }
  9209. if is390 == 1 {
  9210. insutype = "390"
  9211. }
  9212. if is310 == 1 {
  9213. insutype = "310"
  9214. }
  9215. if len(insutypes) == 0 {
  9216. insutype = "390"
  9217. }
  9218. var insuplc_admdvs string
  9219. for _, item := range rf {
  9220. if item.Insutype == insutype {
  9221. insuplc_admdvs = item.InsuplcAdmdvs
  9222. }
  9223. }
  9224. psn := &models.HisPsn{
  9225. PsnNo: res.Output.Baseinfo.PsnNo,
  9226. PatientId: patient.ID,
  9227. Certno: res.Output.Baseinfo.Certno,
  9228. Gend: res.Output.Baseinfo.Gend,
  9229. Naty: res.Output.Baseinfo.Naty,
  9230. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9231. PsnName: res.Output.Baseinfo.PsnName,
  9232. Idetinfo: idetinfoStr,
  9233. Insuinfo: infoStr,
  9234. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9235. InsuplcAdmdvs: insuplc_admdvs,
  9236. }
  9237. service.CreateHisPsn(psn)
  9238. c.ServeSuccessJSON(map[string]interface{}{
  9239. "patient": patient,
  9240. "number": res.Output.Baseinfo.Certno,
  9241. })
  9242. }
  9243. } else {
  9244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9245. return
  9246. }
  9247. } else if miConfig.MdtrtareaAdmvs == "450721" {
  9248. res := c.GetoleInfo()
  9249. if res.Infcode == 0 {
  9250. var result string
  9251. if res.Output.MdtrtCertType == "01" {
  9252. 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)
  9253. } else if res.Output.MdtrtCertType == "02" {
  9254. 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)
  9255. } else if res.Output.MdtrtCertType == "03" {
  9256. 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)
  9257. }
  9258. var dat map[string]interface{}
  9259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9260. fmt.Println(dat)
  9261. } else {
  9262. fmt.Println(err)
  9263. }
  9264. userJSONBytes, _ := json.Marshal(dat)
  9265. var res2 ResultTwo
  9266. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9267. utils.ErrorLog("解析失败:%v", err)
  9268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9269. return
  9270. }
  9271. if res2.Infcode == 0 {
  9272. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  9273. if err == gorm.ErrRecordNotFound {
  9274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9275. return
  9276. } else if err != nil {
  9277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9278. return
  9279. } else {
  9280. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  9281. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  9282. infoStr := string(Iinfos)
  9283. idetinfoStr := string(Idetinfos)
  9284. var rf []*ResultFive
  9285. json.Unmarshal([]byte(infoStr), &rf)
  9286. var insutypes []*ResultFive
  9287. var insutype string
  9288. var is390 int = 0
  9289. var is310 int = 0
  9290. //var insuplc_admdvs string
  9291. for _, item := range rf {
  9292. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9293. insutypes = append(insutypes, item)
  9294. }
  9295. }
  9296. if len(insutypes) == 1 {
  9297. insutype = insutypes[0].Insutype
  9298. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9299. } else {
  9300. for _, i := range insutypes {
  9301. if i.Insutype == "390" {
  9302. is390 = 1
  9303. }
  9304. if i.Insutype == "310" {
  9305. is310 = 1
  9306. }
  9307. }
  9308. }
  9309. if is390 == 1 {
  9310. insutype = "390"
  9311. }
  9312. if is310 == 1 {
  9313. insutype = "310"
  9314. }
  9315. if len(insutypes) == 0 {
  9316. insutype = "310"
  9317. }
  9318. psn := &models.HisPsn{
  9319. PsnNo: res2.Output.Baseinfo.PsnNo,
  9320. PatientId: patient.ID,
  9321. //Brdy: res2.Output.Baseinfo.Brdy,
  9322. Certno: res2.Output.Baseinfo.Certno,
  9323. Gend: res2.Output.Baseinfo.Gend,
  9324. Naty: res2.Output.Baseinfo.Naty,
  9325. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  9326. PsnName: res2.Output.Baseinfo.PsnName,
  9327. Idetinfo: idetinfoStr,
  9328. Insuinfo: infoStr,
  9329. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9330. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  9331. VerifyNumber: res.Output.EcToken,
  9332. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  9333. }
  9334. service.CreateHisPsn(psn)
  9335. var balc float64
  9336. for _, item := range rf {
  9337. if item.Insutype == insutype {
  9338. balc = item.Balc
  9339. }
  9340. }
  9341. c.ServeSuccessJSON(map[string]interface{}{
  9342. "patient": patient,
  9343. "number": res.Output.CardNo,
  9344. "insutype": insutype,
  9345. "blac": balc,
  9346. "desc": idetinfoStr,
  9347. })
  9348. }
  9349. } else {
  9350. c.ServeSuccessJSON(map[string]interface{}{
  9351. "failed_code": -10,
  9352. "msg": res2.ErrMsg,
  9353. })
  9354. }
  9355. } else {
  9356. c.ServeSuccessJSON(map[string]interface{}{
  9357. "failed_code": -10,
  9358. "msg": res.ErrMsg,
  9359. })
  9360. }
  9361. } else {
  9362. SFZStr := c.GetSFZBaseInfo()
  9363. id_card_str := strings.Split(SFZStr, "^")
  9364. id_card_number := id_card_str[0]
  9365. card_sn := ""
  9366. 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)
  9367. var dat map[string]interface{}
  9368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9369. fmt.Println(dat)
  9370. } else {
  9371. fmt.Println(err)
  9372. }
  9373. userJSONBytes, _ := json.Marshal(dat)
  9374. var res ResultTwo
  9375. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9376. utils.ErrorLog("解析失败:%v", err)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. if res.Infcode == 0 {
  9381. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  9382. if err == gorm.ErrRecordNotFound {
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9384. return
  9385. } else if err != nil {
  9386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9387. return
  9388. } else {
  9389. c.ServeSuccessJSON(map[string]interface{}{
  9390. "patient": patient,
  9391. "number": id_card_number,
  9392. })
  9393. }
  9394. } else {
  9395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9396. return
  9397. }
  9398. }
  9399. break
  9400. case 3:
  9401. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9402. var api string
  9403. if miConfig.MdtrtareaAdmvs == "320921" {
  9404. 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 +
  9405. "&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
  9406. fmt.Println(api)
  9407. } else {
  9408. 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 +
  9409. "&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)
  9410. }
  9411. resp, requestErr := http.Get(api)
  9412. if requestErr != nil {
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. body, ioErr := ioutil.ReadAll(resp.Body)
  9417. if ioErr != nil {
  9418. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. var respJSON map[string]interface{}
  9423. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9424. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9426. return
  9427. }
  9428. var status string
  9429. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9430. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9431. var token string
  9432. var res ResultTwo //1101结果
  9433. var res10265 ResultTwo10265 //1101结果
  9434. var card_info string //卡信息
  9435. var busi_card_info string
  9436. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9437. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9438. if status == "0" { //读卡成功
  9439. if card_type == "1" {
  9440. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9441. result, _ := json.Marshal(respJSON)
  9442. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9443. utils.ErrorLog("解析失败:%v", err)
  9444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9445. return
  9446. }
  9447. res.ErrMsg = res10265.ErrMsg
  9448. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9449. res.Infcode = infocode
  9450. res.Output = res10265.Output
  9451. res.InfRefmsgid = res10265.InfRefmsgid
  9452. } else {
  9453. //var card_info string //卡信息
  9454. //var busi_card_info string
  9455. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9456. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9457. //fmt.Println(card_info)
  9458. //fmt.Println(busi_card_info)
  9459. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9460. result, _ := json.Marshal(respJSON)
  9461. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9462. utils.ErrorLog("解析失败:%v", err)
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. return
  9465. }
  9466. res.ErrMsg = res10265.ErrMsg
  9467. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9468. res.Infcode = infocode
  9469. res.Output = res10265.Output
  9470. res.InfRefmsgid = res10265.InfRefmsgid
  9471. }
  9472. if res.Infcode == 0 {
  9473. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9474. if err == gorm.ErrRecordNotFound {
  9475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9476. return
  9477. } else if err != nil {
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9479. return
  9480. } else {
  9481. if card_type == "1" {
  9482. bas := strings.Split(card_info, "|")
  9483. basNumber := bas[2]
  9484. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9485. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9486. infoStr := string(Iinfos)
  9487. idetinfoStr := string(Idetinfos)
  9488. psn := &models.HisPsn{
  9489. PsnNo: res.Output.Baseinfo.PsnNo,
  9490. PatientId: patient.ID,
  9491. Certno: res.Output.Baseinfo.Certno,
  9492. //Brdy: res.Output.Baseinfo.Brdy,
  9493. Gend: res.Output.Baseinfo.Gend,
  9494. Naty: res.Output.Baseinfo.Naty,
  9495. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9496. PsnName: res.Output.Baseinfo.PsnName,
  9497. Idetinfo: idetinfoStr,
  9498. Insuinfo: infoStr,
  9499. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9500. CardInfo: card_info,
  9501. VerifyNumber: busi_card_info,
  9502. }
  9503. service.CreateHisPsn(psn)
  9504. c.ServeSuccessJSON(map[string]interface{}{
  9505. "patient": patient,
  9506. "number": basNumber,
  9507. })
  9508. } else {
  9509. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9510. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9511. infoStr := string(Iinfos)
  9512. idetinfoStr := string(Idetinfos)
  9513. psn := &models.HisPsn{
  9514. PsnNo: res.Output.Baseinfo.PsnNo,
  9515. PatientId: patient.ID,
  9516. Certno: res.Output.Baseinfo.Certno,
  9517. Gend: res.Output.Baseinfo.Gend,
  9518. Naty: res.Output.Baseinfo.Naty,
  9519. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9520. PsnName: res.Output.Baseinfo.PsnName,
  9521. Idetinfo: idetinfoStr,
  9522. Insuinfo: infoStr,
  9523. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9524. CardInfo: card_info,
  9525. VerifyNumber: token,
  9526. }
  9527. service.CreateHisPsn(psn)
  9528. var rf []*ResultFive
  9529. json.Unmarshal([]byte(infoStr), &rf)
  9530. var insutypes []*ResultFive
  9531. var insutype string
  9532. var is390 int = 0
  9533. var is310 int = 0
  9534. for _, item := range rf {
  9535. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9536. insutypes = append(insutypes, item)
  9537. }
  9538. }
  9539. if len(insutypes) == 1 {
  9540. insutype = insutypes[0].Insutype
  9541. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9542. } else {
  9543. for _, i := range insutypes {
  9544. if i.Insutype == "390" {
  9545. is390 = 1
  9546. }
  9547. if i.Insutype == "310" {
  9548. is310 = 1
  9549. }
  9550. }
  9551. }
  9552. if is390 == 1 {
  9553. insutype = "390"
  9554. }
  9555. if is310 == 1 {
  9556. insutype = "310"
  9557. }
  9558. if len(insutypes) == 0 {
  9559. insutype = "310"
  9560. }
  9561. c.ServeSuccessJSON(map[string]interface{}{
  9562. "patient": patient,
  9563. "number": token,
  9564. "insutype": insutype,
  9565. })
  9566. }
  9567. }
  9568. } else {
  9569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9570. return
  9571. }
  9572. } else { //读卡失败
  9573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9574. return
  9575. }
  9576. }
  9577. break
  9578. case 4:
  9579. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9580. var api string
  9581. if miConfig.MdtrtareaAdmvs == "320921" {
  9582. 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 +
  9583. "&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
  9584. fmt.Println(api)
  9585. } else {
  9586. 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 +
  9587. "&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)
  9588. }
  9589. resp, requestErr := http.Get(api)
  9590. if requestErr != nil {
  9591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9592. return
  9593. }
  9594. body, ioErr := ioutil.ReadAll(resp.Body)
  9595. if ioErr != nil {
  9596. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9598. return
  9599. }
  9600. var respJSON map[string]interface{}
  9601. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9602. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9604. return
  9605. }
  9606. var status string
  9607. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9608. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9609. var token string
  9610. var res ResultTwo //1101结果
  9611. var res10265 ResultTwo10265 //1101结果
  9612. if status == "0" { //读卡成功
  9613. var card_info string //卡信息
  9614. var busi_card_info string
  9615. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9616. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9617. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9618. fmt.Println(card_info)
  9619. fmt.Println(busi_card_info)
  9620. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9621. result, _ := json.Marshal(respJSON)
  9622. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9623. utils.ErrorLog("解析失败:%v", err)
  9624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9625. return
  9626. }
  9627. res.ErrMsg = res10265.ErrMsg
  9628. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9629. res.Infcode = infocode
  9630. res.Output = res10265.Output
  9631. res.InfRefmsgid = res10265.InfRefmsgid
  9632. if res.Infcode == 0 {
  9633. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9634. if err == gorm.ErrRecordNotFound {
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9636. return
  9637. } else if err != nil {
  9638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9639. return
  9640. } else {
  9641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9643. infoStr := string(Iinfos)
  9644. idetinfoStr := string(Idetinfos)
  9645. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  9646. psn := &models.HisPsn{
  9647. PsnNo: res.Output.Baseinfo.PsnNo,
  9648. PatientId: patient.ID,
  9649. Certno: res.Output.Baseinfo.Certno,
  9650. Brdy: b,
  9651. Age: float64(age),
  9652. //Brdy: res.Output.Baseinfo.Brdy,
  9653. Gend: res.Output.Baseinfo.Gend,
  9654. Naty: res.Output.Baseinfo.Naty,
  9655. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9656. PsnName: res.Output.Baseinfo.PsnName,
  9657. Idetinfo: idetinfoStr,
  9658. Insuinfo: infoStr,
  9659. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9660. CardInfo: card_info,
  9661. VerifyNumber: token,
  9662. }
  9663. var rf []*ResultFive
  9664. json.Unmarshal([]byte(infoStr), &rf)
  9665. var insutypes []*ResultFive
  9666. var insutype string
  9667. var is390 int = 0
  9668. var is310 int = 0
  9669. for _, item := range rf {
  9670. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9671. insutypes = append(insutypes, item)
  9672. }
  9673. }
  9674. if len(insutypes) == 1 {
  9675. insutype = insutypes[0].Insutype
  9676. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9677. } else {
  9678. for _, i := range insutypes {
  9679. if i.Insutype == "390" {
  9680. is390 = 1
  9681. }
  9682. if i.Insutype == "310" {
  9683. is310 = 1
  9684. }
  9685. }
  9686. }
  9687. if is390 == 1 {
  9688. insutype = "390"
  9689. }
  9690. if is310 == 1 {
  9691. insutype = "310"
  9692. }
  9693. if len(insutypes) == 0 {
  9694. insutype = "310"
  9695. }
  9696. service.CreateHisPsn(psn)
  9697. c.ServeSuccessJSON(map[string]interface{}{
  9698. "patient": patient,
  9699. "number": token,
  9700. "insutype": insutype,
  9701. })
  9702. }
  9703. } else {
  9704. c.ServeSuccessJSON(map[string]interface{}{
  9705. "failed_code": -10,
  9706. "msg": res.ErrMsg,
  9707. })
  9708. }
  9709. } else { //读卡失败
  9710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9711. return
  9712. }
  9713. } else if miConfig.MdtrtareaAdmvs == "341203" {
  9714. var api string
  9715. api = miConfig.SecretKey + "ahyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  9716. "&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
  9717. resp, requestErr := http.Get(api)
  9718. if requestErr != nil {
  9719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9720. return
  9721. }
  9722. body, ioErr := ioutil.ReadAll(resp.Body)
  9723. if ioErr != nil {
  9724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9726. return
  9727. }
  9728. var respJSON map[string]interface{}
  9729. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9732. return
  9733. }
  9734. var status string
  9735. status = respJSON["data"].(map[string]interface{})["status"].(string)
  9736. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  9737. var token string
  9738. var res ResultTwo //1101结果
  9739. if status == "1" { //读卡成功
  9740. var card_info string //卡信息
  9741. var busi_card_info string
  9742. token = respJSON["data"].(map[string]interface{})["token"].(string)
  9743. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  9744. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  9745. fmt.Println(card_info)
  9746. fmt.Println(busi_card_info)
  9747. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  9748. result, _ := json.Marshal(respJSON)
  9749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9750. utils.ErrorLog("解析失败:%v", err)
  9751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9752. return
  9753. }
  9754. if res.Infcode == 0 {
  9755. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9756. if err == gorm.ErrRecordNotFound {
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9758. return
  9759. } else if err != nil {
  9760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9761. return
  9762. } else {
  9763. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9764. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9765. infoStr := string(Iinfos)
  9766. idetinfoStr := string(Idetinfos)
  9767. psn := &models.HisPsn{
  9768. PsnNo: res.Output.Baseinfo.PsnNo,
  9769. PatientId: patient.ID,
  9770. Certno: res.Output.Baseinfo.Certno,
  9771. Gend: res.Output.Baseinfo.Gend,
  9772. Naty: res.Output.Baseinfo.Naty,
  9773. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9774. PsnName: res.Output.Baseinfo.PsnName,
  9775. Idetinfo: idetinfoStr,
  9776. Insuinfo: infoStr,
  9777. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9778. CardInfo: card_info,
  9779. VerifyNumber: token,
  9780. }
  9781. var rf []*ResultFive
  9782. json.Unmarshal([]byte(infoStr), &rf)
  9783. var insutypes []*ResultFive
  9784. var insutype string
  9785. var is390 int = 0
  9786. var is310 int = 0
  9787. for _, item := range rf {
  9788. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9789. insutypes = append(insutypes, item)
  9790. }
  9791. }
  9792. if len(insutypes) == 1 {
  9793. insutype = insutypes[0].Insutype
  9794. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9795. } else {
  9796. for _, i := range insutypes {
  9797. if i.Insutype == "390" {
  9798. is390 = 1
  9799. }
  9800. if i.Insutype == "310" {
  9801. is310 = 1
  9802. }
  9803. }
  9804. }
  9805. if is390 == 1 {
  9806. insutype = "390"
  9807. }
  9808. if is310 == 1 {
  9809. insutype = "310"
  9810. }
  9811. if len(insutypes) == 0 {
  9812. insutype = "310"
  9813. }
  9814. service.CreateHisPsn(psn)
  9815. c.ServeSuccessJSON(map[string]interface{}{
  9816. "patient": patient,
  9817. "number": token,
  9818. "insutype": insutype,
  9819. })
  9820. }
  9821. } else {
  9822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9823. return
  9824. }
  9825. } else { //读卡失败
  9826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9827. return
  9828. }
  9829. } else if miConfig.MdtrtareaAdmvs == "430800" {
  9830. idNo := c.GetString("idNo")
  9831. userName := c.GetString("userName")
  9832. ecToken := c.GetString("ecToken")
  9833. insuOrg := c.GetString("insuOrg")
  9834. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  9835. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9836. var res ResultTwo
  9837. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9838. utils.ErrorLog("解析失败:%v", err)
  9839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9840. return
  9841. }
  9842. if res.Infcode == 0 {
  9843. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  9844. if err == gorm.ErrRecordNotFound {
  9845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  9846. return
  9847. } else if err != nil {
  9848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  9849. return
  9850. } else {
  9851. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9852. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9853. infoStr := string(Iinfos)
  9854. idetinfoStr := string(Idetinfos)
  9855. psn := &models.HisPsn{
  9856. PsnNo: res.Output.Baseinfo.PsnNo,
  9857. PatientId: patient.ID,
  9858. Certno: res.Output.Baseinfo.Certno,
  9859. Gend: res.Output.Baseinfo.Gend,
  9860. Naty: res.Output.Baseinfo.Naty,
  9861. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9862. PsnName: res.Output.Baseinfo.PsnName,
  9863. Idetinfo: idetinfoStr,
  9864. Insuinfo: infoStr,
  9865. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9866. CardInfo: "",
  9867. Stage: "1",
  9868. VerifyNumber: ecToken,
  9869. InsuplcAdmdvs: insuOrg,
  9870. }
  9871. service.CreateHisPsn(psn)
  9872. var rf []*ResultFive
  9873. json.Unmarshal([]byte(infoStr), &rf)
  9874. var insutypes []*ResultFive
  9875. var insutype string
  9876. var is390 int = 0
  9877. var is310 int = 0
  9878. for _, item := range rf {
  9879. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9880. insutypes = append(insutypes, item)
  9881. }
  9882. }
  9883. if len(insutypes) == 1 {
  9884. insutype = insutypes[0].Insutype
  9885. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9886. } else {
  9887. for _, i := range insutypes {
  9888. if i.Insutype == "390" {
  9889. is390 = 1
  9890. }
  9891. if i.Insutype == "310" {
  9892. is310 = 1
  9893. }
  9894. }
  9895. }
  9896. if is390 == 1 {
  9897. insutype = "390"
  9898. }
  9899. if is310 == 1 {
  9900. insutype = "310"
  9901. }
  9902. if len(insutypes) == 0 {
  9903. insutype = "310"
  9904. }
  9905. c.ServeSuccessJSON(map[string]interface{}{
  9906. "patient": patient,
  9907. "number": ecToken,
  9908. "insutype": insutype,
  9909. })
  9910. }
  9911. } else {
  9912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9913. return
  9914. }
  9915. } else if miConfig.MdtrtareaAdmvs == "360302" {
  9916. //if initFlag == 0 {
  9917. //c.TestGetJiangXiBasBaseInit()
  9918. //}
  9919. //if initEleFlag == 0 {
  9920. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  9921. //}
  9922. //_, result2 := GetjxELekeyInfo(miConfig.Code, "1", roles.UserName)
  9923. _, result := GetjxELeInfoaaa(miConfig.Code, "1", roles.UserName)
  9924. //json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  9925. type ELeData struct {
  9926. Data struct {
  9927. IdNo string `json:"idNo"`
  9928. IdType string `json:"idType"`
  9929. UserName string `json:"userName"`
  9930. EcToken string `json:"ecToken"`
  9931. InsuOrg string `json:"insuOrg"`
  9932. Gender string `json:"gender"`
  9933. Birthday string `json:"birthday"`
  9934. Nationality string `json:"nationality"`
  9935. Email string `json:"email"`
  9936. Extra string `json:"extra"`
  9937. } `json:"data"`
  9938. Code int `json:"code"`
  9939. Message string `json:"message"`
  9940. }
  9941. var ele ELeData
  9942. err := json.Unmarshal([]byte(result), &ele)
  9943. if err != nil {
  9944. utils.ErrorLog("解析失败:%v", err)
  9945. }
  9946. token := ele.Data.EcToken
  9947. token = Remove0000(token)
  9948. 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)
  9949. saveLog(result2, requestLog2, "1101", "获取人员信息")
  9950. var res ResultTwo
  9951. if err := json.Unmarshal([]byte(result2), &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(res.Output.Baseinfo.Certno, 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. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9966. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9967. infoStr := string(Iinfos)
  9968. idetinfoStr := string(Idetinfos)
  9969. psn := &models.HisPsn{
  9970. PsnNo: res.Output.Baseinfo.PsnNo,
  9971. PatientId: patient.ID,
  9972. Certno: res.Output.Baseinfo.Certno,
  9973. Gend: res.Output.Baseinfo.Gend,
  9974. Naty: res.Output.Baseinfo.Naty,
  9975. PsnCertType: res.Output.Baseinfo.PsnCertType,
  9976. PsnName: res.Output.Baseinfo.PsnName,
  9977. Idetinfo: idetinfoStr,
  9978. Insuinfo: infoStr,
  9979. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9980. CardInfo: "",
  9981. VerifyNumber: token,
  9982. }
  9983. service.CreateHisPsn(psn)
  9984. var rf []*ResultFive
  9985. json.Unmarshal([]byte(infoStr), &rf)
  9986. var insutypes []*ResultFive
  9987. var insutype string
  9988. var is390 int = 0
  9989. var is310 int = 0
  9990. for _, item := range rf {
  9991. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9992. insutypes = append(insutypes, item)
  9993. }
  9994. }
  9995. if len(insutypes) == 1 {
  9996. insutype = insutypes[0].Insutype
  9997. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9998. } else {
  9999. for _, i := range insutypes {
  10000. if i.Insutype == "390" {
  10001. is390 = 1
  10002. }
  10003. if i.Insutype == "310" {
  10004. is310 = 1
  10005. }
  10006. }
  10007. }
  10008. if is390 == 1 {
  10009. insutype = "390"
  10010. }
  10011. if is310 == 1 {
  10012. insutype = "310"
  10013. }
  10014. if len(insutypes) == 0 {
  10015. insutype = "310"
  10016. }
  10017. c.ServeSuccessJSON(map[string]interface{}{
  10018. "patient": patient,
  10019. "number": token,
  10020. "insutype": insutype,
  10021. })
  10022. }
  10023. } else {
  10024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10025. return
  10026. }
  10027. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10028. //if initFlag == 0 {
  10029. c.TestGetJiangXiBasBaseInit()
  10030. //}
  10031. //if initEleFlag == 0 {
  10032. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  10033. //}
  10034. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  10035. type ELeData struct {
  10036. Data struct {
  10037. IdNo string `json:"idNo"`
  10038. IdType string `json:"idType"`
  10039. UserName string `json:"userName"`
  10040. EcToken string `json:"ecToken"`
  10041. InsuOrg string `json:"insuOrg"`
  10042. Gender string `json:"gender"`
  10043. Birthday string `json:"birthday"`
  10044. Nationality string `json:"nationality"`
  10045. Email string `json:"email"`
  10046. Extra string `json:"extra"`
  10047. } `json:"data"`
  10048. Code int `json:"code"`
  10049. Message string `json:"message"`
  10050. }
  10051. var ele ELeData
  10052. err := json.Unmarshal([]byte(json_result), &ele)
  10053. if err != nil {
  10054. utils.ErrorLog("解析失败:%v", err)
  10055. }
  10056. token := ele.Data.EcToken
  10057. token = Remove0000(token)
  10058. 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)
  10059. saveLog(result2, requestLog2, "1101", "获取人员信息")
  10060. var res ResultTwo
  10061. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10062. utils.ErrorLog("解析失败:%v", err)
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10064. return
  10065. }
  10066. if res.Infcode == 0 {
  10067. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10068. if err == gorm.ErrRecordNotFound {
  10069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10070. return
  10071. } else if err != nil {
  10072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10073. return
  10074. } else {
  10075. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10076. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10077. infoStr := string(Iinfos)
  10078. idetinfoStr := string(Idetinfos)
  10079. psn := &models.HisPsn{
  10080. PsnNo: res.Output.Baseinfo.PsnNo,
  10081. PatientId: patient.ID,
  10082. Certno: res.Output.Baseinfo.Certno,
  10083. Gend: res.Output.Baseinfo.Gend,
  10084. Naty: res.Output.Baseinfo.Naty,
  10085. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10086. PsnName: res.Output.Baseinfo.PsnName,
  10087. Idetinfo: idetinfoStr,
  10088. Insuinfo: infoStr,
  10089. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10090. CardInfo: "",
  10091. VerifyNumber: token,
  10092. }
  10093. service.CreateHisPsn(psn)
  10094. var rf []*ResultFive
  10095. json.Unmarshal([]byte(infoStr), &rf)
  10096. var insutypes []*ResultFive
  10097. var insutype string
  10098. var is390 int = 0
  10099. var is310 int = 0
  10100. for _, item := range rf {
  10101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10102. insutypes = append(insutypes, item)
  10103. }
  10104. }
  10105. if len(insutypes) == 1 {
  10106. insutype = insutypes[0].Insutype
  10107. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10108. } else {
  10109. for _, i := range insutypes {
  10110. if i.Insutype == "390" {
  10111. is390 = 1
  10112. }
  10113. if i.Insutype == "310" {
  10114. is310 = 1
  10115. }
  10116. }
  10117. }
  10118. if is390 == 1 {
  10119. insutype = "390"
  10120. }
  10121. if is310 == 1 {
  10122. insutype = "310"
  10123. }
  10124. if len(insutypes) == 0 {
  10125. insutype = "310"
  10126. }
  10127. c.ServeSuccessJSON(map[string]interface{}{
  10128. "patient": patient,
  10129. "number": token,
  10130. "insutype": insutype,
  10131. })
  10132. }
  10133. } else {
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10135. return
  10136. }
  10137. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10138. type ELeData struct {
  10139. Code string `json:"code"`
  10140. Data struct {
  10141. Aac002 string `json:"aac002"`
  10142. Aaz500 string `json:"aaz500"`
  10143. ActCardNo string `json:"actCardNo"`
  10144. Bab520 string `json:"bab520"`
  10145. Bkz543 string `json:"bkz543"`
  10146. BusinessType string `json:"businessType"`
  10147. CertfCodg string `json:"certfCodg"`
  10148. EcIndexNo string `json:"ecIndexNo"`
  10149. EcToken string `json:"ecToken"`
  10150. ID0000 string `json:"id0000"`
  10151. IDNo string `json:"idNo"`
  10152. IDType string `json:"idType"`
  10153. Idcode string `json:"idcode"`
  10154. IdentityToken string `json:"identity_token"`
  10155. InsuOrg string `json:"insuOrg"`
  10156. OfficeID string `json:"officeId"`
  10157. OfficeName string `json:"officeName"`
  10158. OperatorID string `json:"operatorId"`
  10159. OperatorName string `json:"operatorName"`
  10160. OrgID string `json:"orgId"`
  10161. UserName string `json:"userName"`
  10162. } `json:"data"`
  10163. Infno interface{} `json:"infno"`
  10164. Message string `json:"message"`
  10165. OrgID string `json:"orgId"`
  10166. TransType string `json:"transType"`
  10167. }
  10168. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  10169. outPutInfo = Remove0000(outPutInfo)
  10170. if len(outPutInfo) > 0 {
  10171. var ele ELeData
  10172. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10173. if err != nil {
  10174. utils.ErrorLog("解析失败:%v", err)
  10175. }
  10176. token := ele.Data.EcToken
  10177. fmt.Println(inputInfo)
  10178. fmt.Println(outPutInfo)
  10179. 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)
  10180. saveLog(result, requestLog, "1101", "获取人员信息")
  10181. var dat map[string]interface{}
  10182. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10183. fmt.Println(dat)
  10184. } else {
  10185. fmt.Println(err)
  10186. }
  10187. userJSONBytes, _ := json.Marshal(dat)
  10188. var res ResultTwo
  10189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10190. utils.ErrorLog("解析失败:%v", err)
  10191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10192. return
  10193. }
  10194. res.ErrMsg = errMsgLog
  10195. if res.Infcode == 0 {
  10196. patient, err := service.GetPatientByNumber(ele.Data.IDNo, 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. fmt.Println(res)
  10205. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10206. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10207. infoStr := string(Iinfos)
  10208. idetinfoStr := string(Idetinfos)
  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. Naty: res.Output.Baseinfo.Naty,
  10215. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10216. PsnName: res.Output.Baseinfo.PsnName,
  10217. Idetinfo: idetinfoStr,
  10218. Insuinfo: infoStr,
  10219. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10220. CardInfo: outPutInfo,
  10221. VerifyNumber: token,
  10222. InsuplcAdmdvs: ele.Data.InsuOrg,
  10223. }
  10224. service.CreateHisPsn(psn)
  10225. var rf []*ResultFive
  10226. json.Unmarshal([]byte(infoStr), &rf)
  10227. var insutypes []*ResultFive
  10228. var insutype string
  10229. var is390 int = 0
  10230. var is310 int = 0
  10231. for _, item := range rf {
  10232. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10233. insutypes = append(insutypes, item)
  10234. }
  10235. }
  10236. if len(insutypes) == 1 {
  10237. insutype = insutypes[0].Insutype
  10238. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10239. } else {
  10240. for _, i := range insutypes {
  10241. if i.Insutype == "390" {
  10242. is390 = 1
  10243. }
  10244. if i.Insutype == "310" {
  10245. is310 = 1
  10246. }
  10247. }
  10248. }
  10249. if is390 == 1 {
  10250. insutype = "390"
  10251. }
  10252. if is310 == 1 {
  10253. insutype = "310"
  10254. }
  10255. if len(insutypes) == 0 {
  10256. insutype = "310"
  10257. }
  10258. c.ServeSuccessJSON(map[string]interface{}{
  10259. "patient": patient,
  10260. "number": token,
  10261. "insutype": insutype,
  10262. })
  10263. }
  10264. } else {
  10265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10266. return
  10267. }
  10268. }
  10269. } else if miConfig.MdtrtareaAdmvs == "150499" {
  10270. var api string
  10271. 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 +
  10272. "&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
  10273. resp, requestErr := http.Get(api)
  10274. if requestErr != nil {
  10275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10276. return
  10277. }
  10278. body, ioErr := ioutil.ReadAll(resp.Body)
  10279. if ioErr != nil {
  10280. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10282. return
  10283. }
  10284. var respJSON map[string]interface{}
  10285. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10286. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10288. return
  10289. }
  10290. var status string
  10291. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10292. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10293. var token string
  10294. var res ResultTwo //1101结果
  10295. var res10265 ResultTwo10265 //1101结果
  10296. if status == "0" { //读卡成功
  10297. var card_info string //卡信息
  10298. var busi_card_info string
  10299. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10300. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10301. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10302. fmt.Println(card_info)
  10303. fmt.Println(busi_card_info)
  10304. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10305. result, _ := json.Marshal(respJSON)
  10306. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10307. utils.ErrorLog("解析失败:%v", err)
  10308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10309. return
  10310. }
  10311. res.ErrMsg = res10265.ErrMsg
  10312. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10313. res.Infcode = infocode
  10314. res.Output = res10265.Output
  10315. res.InfRefmsgid = res10265.InfRefmsgid
  10316. if res.Infcode == 0 {
  10317. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10318. if err == gorm.ErrRecordNotFound {
  10319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10320. return
  10321. } else if err != nil {
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10323. return
  10324. } else {
  10325. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10326. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10327. infoStr := string(Iinfos)
  10328. idetinfoStr := string(Idetinfos)
  10329. psn := &models.HisPsn{
  10330. PsnNo: res.Output.Baseinfo.PsnNo,
  10331. PatientId: patient.ID,
  10332. Certno: res.Output.Baseinfo.Certno,
  10333. Gend: res.Output.Baseinfo.Gend,
  10334. Naty: res.Output.Baseinfo.Naty,
  10335. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10336. PsnName: res.Output.Baseinfo.PsnName,
  10337. Idetinfo: idetinfoStr,
  10338. Insuinfo: infoStr,
  10339. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10340. CardInfo: card_info,
  10341. VerifyNumber: token,
  10342. }
  10343. var rf []*ResultFive
  10344. json.Unmarshal([]byte(infoStr), &rf)
  10345. var insutypes []*ResultFive
  10346. var insutype string
  10347. var is390 int = 0
  10348. var is310 int = 0
  10349. for _, item := range rf {
  10350. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10351. insutypes = append(insutypes, item)
  10352. }
  10353. }
  10354. if len(insutypes) == 1 {
  10355. insutype = insutypes[0].Insutype
  10356. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10357. } else {
  10358. for _, i := range insutypes {
  10359. if i.Insutype == "390" {
  10360. is390 = 1
  10361. }
  10362. if i.Insutype == "310" {
  10363. is310 = 1
  10364. }
  10365. }
  10366. }
  10367. if is390 == 1 {
  10368. insutype = "390"
  10369. }
  10370. if is310 == 1 {
  10371. insutype = "310"
  10372. }
  10373. if len(insutypes) == 0 {
  10374. insutype = "310"
  10375. }
  10376. service.CreateHisPsn(psn)
  10377. c.ServeSuccessJSON(map[string]interface{}{
  10378. "patient": patient,
  10379. "number": token,
  10380. "insutype": insutype,
  10381. })
  10382. }
  10383. } else {
  10384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10385. return
  10386. }
  10387. } else { //读卡失败
  10388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10389. return
  10390. }
  10391. } else if miConfig.MdtrtareaAdmvs == "450721" {
  10392. res := c.GetoleInfo()
  10393. if res.Infcode == 0 {
  10394. var result string
  10395. if res.Output.MdtrtCertType == "01" {
  10396. 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)
  10397. } else if res.Output.MdtrtCertType == "02" {
  10398. 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)
  10399. } else if res.Output.MdtrtCertType == "03" {
  10400. 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)
  10401. }
  10402. var dat map[string]interface{}
  10403. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10404. fmt.Println(dat)
  10405. } else {
  10406. fmt.Println(err)
  10407. }
  10408. userJSONBytes, _ := json.Marshal(dat)
  10409. var res2 ResultTwo
  10410. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10411. utils.ErrorLog("解析失败:%v", err)
  10412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10413. return
  10414. }
  10415. if res2.Infcode == 0 {
  10416. patient, err := service.GetPatientByNumber(res.Output.CertNo, c.GetAdminUserInfo().CurrentOrgId)
  10417. if err == gorm.ErrRecordNotFound {
  10418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10419. return
  10420. } else if err != nil {
  10421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10422. return
  10423. } else {
  10424. Iinfos, _ := json.Marshal(res2.Output.Iinfo)
  10425. Idetinfos, _ := json.Marshal(res2.Output.Idetinfo)
  10426. infoStr := string(Iinfos)
  10427. idetinfoStr := string(Idetinfos)
  10428. var rf []*ResultFive
  10429. json.Unmarshal([]byte(infoStr), &rf)
  10430. var insutypes []*ResultFive
  10431. var insutype string
  10432. var is390 int = 0
  10433. var is310 int = 0
  10434. //var insuplc_admdvs string
  10435. for _, item := range rf {
  10436. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10437. insutypes = append(insutypes, item)
  10438. }
  10439. }
  10440. if len(insutypes) == 1 {
  10441. insutype = insutypes[0].Insutype
  10442. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10443. } else {
  10444. for _, i := range insutypes {
  10445. if i.Insutype == "390" {
  10446. is390 = 1
  10447. }
  10448. if i.Insutype == "310" {
  10449. is310 = 1
  10450. }
  10451. }
  10452. }
  10453. if is390 == 1 {
  10454. insutype = "390"
  10455. }
  10456. if is310 == 1 {
  10457. insutype = "310"
  10458. }
  10459. if len(insutypes) == 0 {
  10460. insutype = "310"
  10461. }
  10462. psn := &models.HisPsn{
  10463. PsnNo: res2.Output.Baseinfo.PsnNo,
  10464. PatientId: patient.ID,
  10465. Certno: res2.Output.Baseinfo.Certno,
  10466. Gend: res2.Output.Baseinfo.Gend,
  10467. Naty: res2.Output.Baseinfo.Naty,
  10468. PsnCertType: res2.Output.Baseinfo.PsnCertType,
  10469. PsnName: res2.Output.Baseinfo.PsnName,
  10470. Idetinfo: idetinfoStr,
  10471. Insuinfo: infoStr,
  10472. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10473. CardInfo: res.Output.CertNo + "|" + res.Output.CardSN,
  10474. VerifyNumber: res.Output.EcToken,
  10475. InsuplcAdmdvs: res.Output.InsuplcAdmdvs,
  10476. }
  10477. if res.Output.MdtrtCertType == "01" {
  10478. psn.VerifyNumber = res.Output.EcToken
  10479. //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)
  10480. } else if res.Output.MdtrtCertType == "02" {
  10481. psn.VerifyNumber = res.Output.CardNo
  10482. //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)
  10483. } else if res.Output.MdtrtCertType == "03" {
  10484. psn.VerifyNumber = res.Output.MdtrtCertNo
  10485. //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)
  10486. }
  10487. service.CreateHisPsn(psn)
  10488. var balc float64
  10489. for _, item := range rf {
  10490. if item.Insutype == insutype {
  10491. balc = item.Balc
  10492. }
  10493. }
  10494. c.ServeSuccessJSON(map[string]interface{}{
  10495. "patient": patient,
  10496. "number": res.Output.CardNo,
  10497. "insutype": insutype,
  10498. "blac": balc,
  10499. "desc": idetinfoStr,
  10500. })
  10501. }
  10502. } else {
  10503. c.ServeSuccessJSON(map[string]interface{}{
  10504. "failed_code": -10,
  10505. "msg": res2.ErrMsg,
  10506. })
  10507. }
  10508. } else {
  10509. c.ServeSuccessJSON(map[string]interface{}{
  10510. "failed_code": -10,
  10511. "msg": res.ErrMsg,
  10512. })
  10513. }
  10514. } else if miConfig.MdtrtareaAdmvs == "420902" {
  10515. var res ResultTwo
  10516. api := miConfig.Url + "hbyb/1101?cert_no=" + "" +
  10517. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10518. "&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)
  10519. resp, requestErr := http.Get(api)
  10520. if requestErr != nil {
  10521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10522. return
  10523. }
  10524. body, ioErr := ioutil.ReadAll(resp.Body)
  10525. if ioErr != nil {
  10526. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10528. return
  10529. }
  10530. var respJSON map[string]interface{}
  10531. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10532. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10534. return
  10535. }
  10536. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10537. result, _ := json.Marshal(respJSON)
  10538. fmt.Println("log")
  10539. fmt.Println(string(result))
  10540. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10541. utils.ErrorLog("解析失败:%v", err)
  10542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10543. return
  10544. }
  10545. if res.Infcode == 0 {
  10546. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10547. if err == gorm.ErrRecordNotFound {
  10548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10549. return
  10550. } else if err != nil {
  10551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10552. return
  10553. } else {
  10554. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10555. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10556. infoStr := string(Iinfos)
  10557. idetinfoStr := string(Idetinfos)
  10558. var rf []*ResultFive
  10559. json.Unmarshal([]byte(infoStr), &rf)
  10560. var insutypes []*ResultFive
  10561. var insutype string
  10562. var is390 int = 0
  10563. var is310 int = 0
  10564. for _, item := range rf {
  10565. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "") || (item.Insutype == "390" && item.PsnInsuStas == "") {
  10566. insutypes = append(insutypes, item)
  10567. }
  10568. }
  10569. if len(insutypes) == 1 {
  10570. insutype = insutypes[0].Insutype
  10571. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10572. } else {
  10573. for _, i := range insutypes {
  10574. if i.Insutype == "390" {
  10575. is390 = 1
  10576. }
  10577. if i.Insutype == "310" {
  10578. is310 = 1
  10579. }
  10580. }
  10581. }
  10582. if is390 == 1 {
  10583. insutype = "390"
  10584. }
  10585. if is310 == 1 {
  10586. insutype = "310"
  10587. }
  10588. if len(insutypes) == 0 {
  10589. insutype = "390"
  10590. }
  10591. var insuplc_admdvs string
  10592. for _, item := range rf {
  10593. if item.Insutype == insutype {
  10594. insuplc_admdvs = item.InsuplcAdmdvs
  10595. }
  10596. }
  10597. psn := &models.HisPsn{
  10598. PsnNo: res.Output.Baseinfo.PsnNo,
  10599. PatientId: patient.ID,
  10600. Certno: res.Output.Baseinfo.Certno,
  10601. Gend: res.Output.Baseinfo.Gend,
  10602. Naty: res.Output.Baseinfo.Naty,
  10603. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10604. PsnName: res.Output.Baseinfo.PsnName,
  10605. Idetinfo: idetinfoStr,
  10606. Insuinfo: infoStr,
  10607. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10608. InsuplcAdmdvs: insuplc_admdvs,
  10609. }
  10610. service.CreateHisPsn(psn)
  10611. c.ServeSuccessJSON(map[string]interface{}{
  10612. "patient": patient,
  10613. "number": res.Output.Baseinfo.Certno,
  10614. })
  10615. }
  10616. } else {
  10617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10618. return
  10619. }
  10620. } else {
  10621. type ELeData struct {
  10622. Code string `json:"code"`
  10623. Data struct {
  10624. Aac002 string `json:"aac002"`
  10625. Aaz500 string `json:"aaz500"`
  10626. ActCardNo string `json:"actCardNo"`
  10627. Bab520 string `json:"bab520"`
  10628. Bkz543 string `json:"bkz543"`
  10629. BusinessType string `json:"businessType"`
  10630. CertfCodg string `json:"certfCodg"`
  10631. EcIndexNo string `json:"ecIndexNo"`
  10632. EcToken string `json:"ecToken"`
  10633. ID0000 string `json:"id0000"`
  10634. IDNo string `json:"idNo"`
  10635. IDType string `json:"idType"`
  10636. Idcode string `json:"idcode"`
  10637. IdentityToken string `json:"identity_token"`
  10638. InsuOrg string `json:"insuOrg"`
  10639. OfficeID string `json:"officeId"`
  10640. OfficeName string `json:"officeName"`
  10641. OperatorID string `json:"operatorId"`
  10642. OperatorName string `json:"operatorName"`
  10643. OrgID string `json:"orgId"`
  10644. UserName string `json:"userName"`
  10645. } `json:"data"`
  10646. Infno interface{} `json:"infno"`
  10647. Message string `json:"message"`
  10648. OrgID string `json:"orgId"`
  10649. TransType string `json:"transType"`
  10650. }
  10651. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName, miConfig.MdtrtareaAdmvs)
  10652. fmt.Println(result)
  10653. outPutInfo := Remove0000(result)
  10654. fmt.Println(outPutInfo)
  10655. if len(outPutInfo) > 0 {
  10656. var ele ELeData
  10657. err := json.Unmarshal([]byte(outPutInfo), &ele)
  10658. if err != nil {
  10659. utils.ErrorLog("解析失败:%v", err)
  10660. }
  10661. token := ele.Data.EcToken
  10662. fmt.Println(outPutInfo)
  10663. 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)
  10664. saveLog(result, requestLog, "1101", "获取人员信息")
  10665. var dat map[string]interface{}
  10666. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10667. fmt.Println(dat)
  10668. } else {
  10669. fmt.Println(err)
  10670. }
  10671. userJSONBytes, _ := json.Marshal(dat)
  10672. var res ResultTwo
  10673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10674. utils.ErrorLog("解析失败:%v", err)
  10675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10676. return
  10677. }
  10678. if res.Infcode == 0 {
  10679. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  10680. if err == gorm.ErrRecordNotFound {
  10681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10682. return
  10683. } else if err != nil {
  10684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10685. return
  10686. } else {
  10687. fmt.Println(res)
  10688. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10689. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10690. infoStr := string(Iinfos)
  10691. idetinfoStr := string(Idetinfos)
  10692. psn := &models.HisPsn{
  10693. PsnNo: res.Output.Baseinfo.PsnNo,
  10694. PatientId: patient.ID,
  10695. Certno: res.Output.Baseinfo.Certno,
  10696. Gend: res.Output.Baseinfo.Gend,
  10697. Naty: res.Output.Baseinfo.Naty,
  10698. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10699. PsnName: res.Output.Baseinfo.PsnName,
  10700. Idetinfo: idetinfoStr,
  10701. Insuinfo: infoStr,
  10702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10703. CardInfo: outPutInfo,
  10704. VerifyNumber: token,
  10705. InsuplcAdmdvs: ele.Data.InsuOrg,
  10706. }
  10707. service.CreateHisPsn(psn)
  10708. var rf []*ResultFive
  10709. json.Unmarshal([]byte(infoStr), &rf)
  10710. var insutypes []*ResultFive
  10711. var insutype string
  10712. var is390 int = 0
  10713. var is310 int = 0
  10714. for _, item := range rf {
  10715. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10716. insutypes = append(insutypes, item)
  10717. }
  10718. }
  10719. if len(insutypes) == 1 {
  10720. insutype = insutypes[0].Insutype
  10721. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10722. } else {
  10723. for _, i := range insutypes {
  10724. if i.Insutype == "390" {
  10725. is390 = 1
  10726. }
  10727. if i.Insutype == "310" {
  10728. is310 = 1
  10729. }
  10730. }
  10731. }
  10732. if is390 == 1 {
  10733. insutype = "390"
  10734. }
  10735. if is310 == 1 {
  10736. insutype = "310"
  10737. }
  10738. if len(insutypes) == 0 {
  10739. insutype = "310"
  10740. }
  10741. c.ServeSuccessJSON(map[string]interface{}{
  10742. "patient": patient,
  10743. "number": token,
  10744. "insutype": insutype,
  10745. })
  10746. }
  10747. } else {
  10748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10749. return
  10750. }
  10751. }
  10752. //fmt.Println(result)
  10753. //
  10754. //if initFlag == 0 {
  10755. // c.TestGetBasBaseInit()
  10756. //}
  10757. //token := c.GetEleBaseInfo()
  10758. //
  10759. //token = Remove0000(token)
  10760. //
  10761. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  10762. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  10763. ////
  10764. //var res ResultTwo
  10765. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  10766. // utils.ErrorLog("解析失败:%v", err)
  10767. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10768. // return
  10769. //}
  10770. //
  10771. //if res.Infcode == 0 {
  10772. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10773. // if err == gorm.ErrRecordNotFound {
  10774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10775. // return
  10776. // } else if err != nil {
  10777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10778. // return
  10779. //
  10780. // } else {
  10781. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10782. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10783. // infoStr := string(Iinfos)
  10784. // idetinfoStr := string(Idetinfos)
  10785. //
  10786. //
  10787. //
  10788. //
  10789. // var rf []*ResultFive
  10790. // json.Unmarshal([]byte(infoStr), &rf)
  10791. //
  10792. // var insutypes []*ResultFive
  10793. // var insutype string
  10794. // var is390 int = 0
  10795. // var is310 int = 0
  10796. // var insuplc_admdvs string
  10797. //
  10798. // for _, item := range rf {
  10799. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10800. // insutypes = append(insutypes, item)
  10801. // }
  10802. // }
  10803. //
  10804. // if len(insutypes) == 1 {
  10805. // insutype = insutypes[0].Insutype
  10806. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10807. // } else {
  10808. // for _, i := range insutypes {
  10809. // if i.Insutype == "390" {
  10810. // is390 = 1
  10811. // }
  10812. //
  10813. // if i.Insutype == "310" {
  10814. // is310 = 1
  10815. // }
  10816. // }
  10817. // }
  10818. // if is390 == 1 {
  10819. // insutype = "390"
  10820. // }
  10821. //
  10822. // if is310 == 1 {
  10823. // insutype = "310"
  10824. // }
  10825. // if len(insutypes) == 0 {
  10826. // insutype = "310"
  10827. // }
  10828. // for _, item := range rf {
  10829. // if item.Insutype == insutype {
  10830. // insuplc_admdvs = item.InsuplcAdmdvs
  10831. // }
  10832. // }
  10833. // psn := &models.HisPsn{
  10834. // PsnNo: res.Output.Baseinfo.PsnNo,
  10835. // Age: res.Output.Baseinfo.Age,
  10836. // PatientId: patient.ID,
  10837. // Certno: res.Output.Baseinfo.Certno,
  10838. // Brdy: res.Output.Baseinfo.Brdy,
  10839. // Gend: res.Output.Baseinfo.Gend,
  10840. // Naty: res.Output.Baseinfo.Naty,
  10841. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  10842. // PsnName: res.Output.Baseinfo.PsnName,
  10843. // Idetinfo: idetinfoStr,
  10844. // Insuinfo: infoStr,
  10845. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10846. // CardInfo: "",
  10847. // VerifyNumber: token,
  10848. // InsuplcAdmdvs: insuplc_admdvs,
  10849. // }
  10850. // service.CreateHisPsn(psn)
  10851. //
  10852. // c.ServeSuccessJSON(map[string]interface{}{
  10853. // "patient": patient,
  10854. // "number": token,
  10855. // })
  10856. // }
  10857. //} else {
  10858. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10859. // return
  10860. //}
  10861. }
  10862. break
  10863. case 5:
  10864. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10865. var api string
  10866. if miConfig.MdtrtareaAdmvs == "320921" {
  10867. 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 +
  10868. "&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
  10869. fmt.Println(api)
  10870. } else {
  10871. 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 +
  10872. "&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)
  10873. }
  10874. resp, requestErr := http.Get(api)
  10875. if requestErr != nil {
  10876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10877. return
  10878. }
  10879. body, ioErr := ioutil.ReadAll(resp.Body)
  10880. if ioErr != nil {
  10881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10883. return
  10884. }
  10885. var respJSON map[string]interface{}
  10886. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10889. return
  10890. }
  10891. var status string
  10892. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10893. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10894. var token string
  10895. var res ResultTwo //1101结果
  10896. var res10265 ResultTwo10265 //1101结果
  10897. if status == "0" { //读卡成功
  10898. var card_info string //卡信息
  10899. //var busi_card_info string
  10900. var auth_info string
  10901. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10902. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10903. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10904. auth_info = respJSON["data"].(map[string]interface{})["eletwo"].(string)
  10905. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  10906. result, _ := json.Marshal(respJSON)
  10907. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10908. utils.ErrorLog("解析失败:%v", err)
  10909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10910. return
  10911. }
  10912. res.ErrMsg = res10265.ErrMsg
  10913. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10914. res.Infcode = infocode
  10915. res.Output = res10265.Output
  10916. res.InfRefmsgid = res10265.InfRefmsgid
  10917. if res.Infcode == 0 {
  10918. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  10919. if err == gorm.ErrRecordNotFound {
  10920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  10921. return
  10922. } else if err != nil {
  10923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  10924. return
  10925. } else {
  10926. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10927. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  10928. infoStr := string(Iinfos)
  10929. idetinfoStr := string(Idetinfos)
  10930. b, age, _ := getBirthdateAndAge(res.Output.Baseinfo.Certno)
  10931. psn := &models.HisPsn{
  10932. PsnNo: res.Output.Baseinfo.PsnNo,
  10933. PatientId: patient.ID,
  10934. Certno: res.Output.Baseinfo.Certno,
  10935. Gend: res.Output.Baseinfo.Gend,
  10936. Brdy: b,
  10937. Age: float64(age),
  10938. Naty: res.Output.Baseinfo.Naty,
  10939. PsnCertType: res.Output.Baseinfo.PsnCertType,
  10940. PsnName: res.Output.Baseinfo.PsnName,
  10941. Idetinfo: idetinfoStr,
  10942. Insuinfo: infoStr,
  10943. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10944. CardInfo: card_info,
  10945. VerifyNumber: token,
  10946. AuthInfo: auth_info,
  10947. }
  10948. var rf []*ResultFive
  10949. json.Unmarshal([]byte(infoStr), &rf)
  10950. var insutypes []*ResultFive
  10951. var insutype string
  10952. var is390 int = 0
  10953. var is310 int = 0
  10954. for _, item := range rf {
  10955. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10956. insutypes = append(insutypes, item)
  10957. }
  10958. }
  10959. if len(insutypes) == 1 {
  10960. insutype = insutypes[0].Insutype
  10961. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10962. } else {
  10963. for _, i := range insutypes {
  10964. if i.Insutype == "390" {
  10965. is390 = 1
  10966. }
  10967. if i.Insutype == "310" {
  10968. is310 = 1
  10969. }
  10970. }
  10971. }
  10972. if is390 == 1 {
  10973. insutype = "390"
  10974. }
  10975. if is310 == 1 {
  10976. insutype = "310"
  10977. }
  10978. if len(insutypes) == 0 {
  10979. insutype = "310"
  10980. }
  10981. service.CreateHisPsn(psn)
  10982. c.ServeSuccessJSON(map[string]interface{}{
  10983. "patient": patient,
  10984. "number": token,
  10985. "insutype": insutype,
  10986. })
  10987. }
  10988. } else {
  10989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10990. return
  10991. }
  10992. } else { //读卡失败
  10993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  10994. return
  10995. }
  10996. }
  10997. break
  10998. }
  10999. }
  11000. var initFlag int64 = 0
  11001. var initEleFlag int64 = 0
  11002. func (c *HisApiController) TestGetBasBaseInit() {
  11003. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11004. Iinit := DllDef.MustFindProc("Init")
  11005. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11006. fmt.Println("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll")
  11007. ret, _, err := Iinit.Call(StrPtr("http://hosp-sz.gd.hsip.gov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  11008. if ret != 0 {
  11009. fmt.Println("SSCard的报错原因:", err)
  11010. fmt.Println("SSCard的运算结果为:", ret)
  11011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11012. return
  11013. }
  11014. result := int(ret)
  11015. fmt.Println("SSCard的运算结果为1:", result)
  11016. initFlag = 1
  11017. return
  11018. }
  11019. func (c *HisApiController) HandleJiangXiReadCard() {
  11020. fmt.Println("~~~~~~")
  11021. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11022. admin_user_id, _ := c.GetInt64("admin_user_id")
  11023. id_card_type, _ := c.GetInt64("id_card_type")
  11024. //certificates, _ := c.GetInt64("certificates")
  11025. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11026. if initFlag == 0 {
  11027. c.TestGetJiangXiBasBaseInit()
  11028. }
  11029. basStr := c.GetBasBaseInfo()
  11030. if len(basStr) == 0 {
  11031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11032. return
  11033. }
  11034. fmt.Println(basStr)
  11035. bas := strings.Split(basStr, "|")
  11036. basNumber := bas[1]
  11037. fmt.Println(basNumber)
  11038. card_sn := bas[3]
  11039. fmt.Println(card_sn)
  11040. 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, "")
  11041. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  11042. var dat map[string]interface{}
  11043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11044. fmt.Println(dat)
  11045. } else {
  11046. fmt.Println(err)
  11047. }
  11048. userJSONBytes, _ := json.Marshal(dat)
  11049. var res ResultTwo
  11050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11051. utils.ErrorLog("解析失败:%v", err)
  11052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11053. return
  11054. }
  11055. if res.Infcode == 0 {
  11056. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  11057. if err == gorm.ErrRecordNotFound {
  11058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  11059. return
  11060. } else if err != nil {
  11061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  11062. return
  11063. } else {
  11064. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  11065. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  11066. infoStr := string(Iinfos)
  11067. idetinfoStr := string(Idetinfos)
  11068. psn := &models.HisPsn{
  11069. PsnNo: res.Output.Baseinfo.PsnNo,
  11070. PatientId: patient.ID,
  11071. Certno: res.Output.Baseinfo.Certno,
  11072. Gend: res.Output.Baseinfo.Gend,
  11073. Naty: res.Output.Baseinfo.Naty,
  11074. PsnCertType: res.Output.Baseinfo.PsnCertType,
  11075. PsnName: res.Output.Baseinfo.PsnName,
  11076. Idetinfo: idetinfoStr,
  11077. Insuinfo: infoStr,
  11078. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11079. CardInfo: basStr,
  11080. VerifyNumber: "",
  11081. }
  11082. service.CreateHisPsn(psn)
  11083. c.ServeSuccessJSON(map[string]interface{}{
  11084. "patient": patient,
  11085. "number": basNumber,
  11086. })
  11087. }
  11088. } else {
  11089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11090. return
  11091. }
  11092. }
  11093. func (c *HisApiController) TestGetHnBasBaseInit() {
  11094. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11095. Iinit := DllDef.MustFindProc("Init")
  11096. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11097. //http://10.77.211.236/CSB/hsa-fsi-1303
  11098. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  11099. if ret != 0 {
  11100. fmt.Println("SSCard的报错原因:", err)
  11101. fmt.Println("SSCard的运算结果为:", ret)
  11102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11103. return
  11104. }
  11105. result := int(ret)
  11106. fmt.Println("SSCard的运算结果为1:", result)
  11107. initFlag = 1
  11108. return
  11109. }
  11110. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  11111. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11112. Iinit := DllDef.MustFindProc("Init")
  11113. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11114. //http://10.77.211.236/CSB/hsa-fsi-1303
  11115. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360302"))
  11116. if ret != 0 {
  11117. fmt.Println("SSCard的报错原因:", err)
  11118. fmt.Println("SSCard的运算结果为:", ret)
  11119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  11120. return
  11121. }
  11122. result := int(ret)
  11123. fmt.Println("SSCard的运算结果为1:", result)
  11124. initFlag = 1
  11125. return
  11126. }
  11127. func (c *HisApiController) GetSFZBaseInfo() string {
  11128. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11129. readCard := DllDef.MustFindProc("ReadSFZ")
  11130. if readCard == nil {
  11131. fmt.Println("readcard is nil")
  11132. readCard = DllDef.MustFindProc("ReadSFZ")
  11133. }
  11134. str := make([]byte, 8096)
  11135. str1 := make([]byte, 8096)
  11136. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  11137. fmt.Println(r)
  11138. return Remove0000(string(str))
  11139. }
  11140. func (c *HisApiController) GetEleBaseInfo() string {
  11141. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11142. readCard := DllDef.MustFindProc("GetQRBase")
  11143. fmt.Println(readCard)
  11144. if readCard == nil {
  11145. fmt.Println("readcard is nil")
  11146. readCard = DllDef.MustFindProc("GetQRBase")
  11147. }
  11148. str := make([]byte, 1024)
  11149. str1 := make([]byte, 1024)
  11150. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11151. fmt.Println(ret2)
  11152. fmt.Println(string(str1))
  11153. fmt.Println(string(str))
  11154. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11155. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11156. if ret2 != 0 {
  11157. return ""
  11158. }
  11159. return string(str)
  11160. }
  11161. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11162. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11163. readCard := DllDef.MustFindProc("NationEcTrans")
  11164. fmt.Println(readCard)
  11165. fmt.Println("!!!!!")
  11166. pBusiCardInfo := make([]byte, 2048)
  11167. input := make(map[string]interface{})
  11168. inputData := make(map[string]interface{})
  11169. inputData["orgId"] = code
  11170. inputData["businessType"] = "01101"
  11171. inputData["operatorId"] = "1"
  11172. inputData["operatorName"] = "admin"
  11173. inputData["officeId"] = "001"
  11174. inputData["officeName"] = "血透室"
  11175. inputData["deviceType"] = ""
  11176. input["data"] = inputData
  11177. input["orgId"] = code
  11178. input["transType"] = "ec.query"
  11179. bytesData, _ := json.Marshal(input)
  11180. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11181. fmt.Println(ret2)
  11182. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11183. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11184. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  11185. }
  11186. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  11187. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11188. readCard := DllDef.MustFindProc("NationEcTrans")
  11189. fmt.Println(readCard)
  11190. fmt.Println("!!!!!")
  11191. pBusiCardInfo := make([]byte, 2048)
  11192. input := make(map[string]interface{})
  11193. inputData := make(map[string]interface{})
  11194. inputData["orgId"] = code
  11195. inputData["businessType"] = "01101"
  11196. inputData["operatorId"] = "9"
  11197. inputData["operatorName"] = "admin"
  11198. inputData["officeId"] = "001"
  11199. inputData["officeName"] = "血透室"
  11200. inputData["deviceType"] = ""
  11201. input["data"] = inputData
  11202. input["orgId"] = code
  11203. input["transType"] = "ec.query"
  11204. bytesData, _ := json.Marshal(input)
  11205. 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])))
  11206. fmt.Println(ret2)
  11207. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11208. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11209. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11210. }
  11211. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  11212. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  11213. readCard := DllDef.MustFindProc("NationEcTrans")
  11214. fmt.Println(readCard)
  11215. fmt.Println("!!!!!")
  11216. pBusiCardInfo := make([]byte, 2048)
  11217. input := make(map[string]interface{})
  11218. inputData := make(map[string]interface{})
  11219. inputData["orgId"] = code
  11220. inputData["businessType"] = "01301"
  11221. inputData["operatorId"] = "9"
  11222. inputData["operatorName"] = "admin"
  11223. inputData["officeId"] = "001"
  11224. inputData["officeName"] = "血透室"
  11225. inputData["deviceType"] = ""
  11226. input["data"] = inputData
  11227. input["orgId"] = code
  11228. input["transType"] = "ec.query"
  11229. bytesData, _ := json.Marshal(input)
  11230. 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])))
  11231. fmt.Println(ret2)
  11232. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11233. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11234. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  11235. }
  11236. func GetJxEleBaseInfo(org_id int64) string {
  11237. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11238. readCard := DllDef.MustFindProc("NationEcTrans")
  11239. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11240. if readCard == nil {
  11241. fmt.Println("readcard is nil")
  11242. readCard = DllDef.MustFindProc("NationEcTrans")
  11243. }
  11244. str1 := make([]byte, 1024)
  11245. data := make(map[string]interface{})
  11246. inputData := make(map[string]interface{})
  11247. inputData["orgId"] = miConfig.Code
  11248. inputData["businessType"] = "01101"
  11249. inputData["operatorId"] = "test001"
  11250. inputData["operatorName"] = "cn"
  11251. inputData["officeId"] = "32760"
  11252. inputData["officeName"] = "waike"
  11253. inputData["deviceType"] = ""
  11254. data["data"] = inputData
  11255. data["transType"] = "ec.query"
  11256. data["extra "] = ""
  11257. data["orgId"] = miConfig.Code
  11258. bytesData, _ := json.Marshal(data)
  11259. //bytesData, _ := json.Marshal(data)
  11260. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11261. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11262. fmt.Println(ret2)
  11263. fmt.Println(string(str1))
  11264. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11265. if ret2 != 0 {
  11266. return ""
  11267. }
  11268. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11269. }
  11270. func GetJxEleBaseInitInfo(org_id int64) string {
  11271. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11272. readCard := DllDef.MustFindProc("NationEcTrans")
  11273. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11274. if readCard == nil {
  11275. fmt.Println("readcard is nil")
  11276. readCard = DllDef.MustFindProc("NationEcTrans")
  11277. }
  11278. str1 := make([]byte, 2048)
  11279. data := make(map[string]interface{})
  11280. inputData := make(map[string]interface{})
  11281. inputData["orgId"] = miConfig.Code
  11282. inputData["businessType"] = "01101"
  11283. inputData["operatorId"] = "1"
  11284. inputData["operatorName"] = "huangchuang"
  11285. inputData["officeId"] = "101"
  11286. inputData["officeName"] = "xuetou"
  11287. inputData["deviceType"] = ""
  11288. data["data"] = inputData
  11289. data["transType"] = "ec.query"
  11290. data["orgId"] = miConfig.Code
  11291. bytesData, _ := json.Marshal(data)
  11292. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  11293. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11294. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  11295. fmt.Println(ret2)
  11296. fmt.Println(string(str1))
  11297. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11298. if ret2 != 0 {
  11299. return ""
  11300. }
  11301. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  11302. initEleFlag = 1
  11303. }
  11304. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  11305. }
  11306. //func (c *HisApiController)GetgxBasBaseInfotwo() {
  11307. // // 构建命令
  11308. // cmd := exec.Command("python", "b.py")
  11309. //
  11310. // // 执行命令并等待完成
  11311. // output, err := cmd.CombinedOutput()
  11312. // if err != nil {
  11313. // fmt.Println("Error executing Python script:", err)
  11314. // return
  11315. // }
  11316. //
  11317. // // 打印Python脚本的输出
  11318. // fmt.Println(string(output))
  11319. //}
  11320. func (c *HisApiController) GetgxBasBaseInfo(code string) string {
  11321. DllDef := syscall.MustLoadDLL("yh_interface_xyb.dll")
  11322. readCard := DllDef.MustFindProc("gxyb_call")
  11323. if readCard == nil {
  11324. fmt.Println("readcard is nil")
  11325. readCard = DllDef.MustFindProc("gxyb_call")
  11326. }
  11327. str := make([]byte, 1024)
  11328. str1 := make([]byte, 1024)
  11329. //data := make(map[string]interface{})
  11330. currentTime := time.Now()
  11331. // 格式化时间为 "YYYYMMDDHH24MISS"
  11332. formattedTime := currentTime.Format("20060102150405")
  11333. inputData := make(map[string]interface{})
  11334. inputData2 := make(map[string]interface{})
  11335. inputData["transNo"] = "1401"
  11336. inputData["transType"] = "passwordCheck"
  11337. inputData["timestamp"] = formattedTime
  11338. inputData2["fixmedinsCode"] = code
  11339. inputData2["psnNo"] = ""
  11340. inputData["data"] = inputData2
  11341. jsonBytes, err := json.Marshal(inputData)
  11342. if err != nil {
  11343. fmt.Println("Error encoding map to JSON:", err)
  11344. }
  11345. ret2, _, _ := readCard.Call(StrPtr("1401"), (uintptr)(unsafe.Pointer(&jsonBytes[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  11346. fmt.Println(string(str1))
  11347. fmt.Println(string(str))
  11348. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11349. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11350. if ret2 != 0 {
  11351. return ""
  11352. }
  11353. return string(str)
  11354. }
  11355. func (c *HisApiController) GetoleInfo() Response {
  11356. ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED)
  11357. defer ole.CoUninitialize()
  11358. // Replace with the ProgID or CLSID of your COM object
  11359. progID := "YinHai.XJ.Actual.Interface.New"
  11360. // Create COM object
  11361. unknown, err := oleutil.CreateObject(progID)
  11362. if err != nil {
  11363. fmt.Println("Unable to create COM object:", err)
  11364. }
  11365. defer unknown.Release()
  11366. // Query for the IDispatch interface
  11367. dispatch, err := unknown.QueryInterface(ole.IID_IDispatch)
  11368. if err != nil {
  11369. fmt.Println("Unable to get IDispatch interface:", err)
  11370. }
  11371. defer dispatch.Release()
  11372. // Prepare parameters
  11373. transNo := "1401"
  11374. transType := "passwordCheck"
  11375. timestamp := time.Now().Unix()
  11376. fixmedinsCode := "H45072101171"
  11377. psnNo := ""
  11378. data := fmt.Sprintf(`{"transNo":"%s","transType":"%s","timestamp":"%s","data":{"fixmedinsCode":"%s","psnNo":"%s"}}`, transNo, transType, timestamp, fixmedinsCode, psnNo)
  11379. result2 := ""
  11380. // Call COM object's method using the IDispatch interface
  11381. resulr, err := oleutil.CallMethod(dispatch, "gxyb_call", "1401", data, &result2)
  11382. fmt.Println(resulr)
  11383. fmt.Println(result2)
  11384. if err != nil {
  11385. fmt.Println("调用COM对象方法失败:", err)
  11386. }
  11387. var response Response
  11388. err2 := json.Unmarshal([]byte(result2), &response)
  11389. if err2 != nil {
  11390. fmt.Println("解析JSON失败:", err)
  11391. }
  11392. return response
  11393. }
  11394. func (c *HisApiController) GetBasBaseInfo() string {
  11395. DllDef := syscall.MustLoadDLL("SSCard.dll")
  11396. readCard := DllDef.MustFindProc("ReadCardBas")
  11397. if readCard == nil {
  11398. fmt.Println("readcard is nil")
  11399. readCard = DllDef.MustFindProc("ReadCardBas")
  11400. }
  11401. str := make([]byte, 1024)
  11402. str1 := make([]byte, 1024)
  11403. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  11404. fmt.Println(string(str1))
  11405. fmt.Println(string(str))
  11406. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11407. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11408. if ret2 != 0 {
  11409. return ""
  11410. }
  11411. return string(str)
  11412. }
  11413. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  11414. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  11415. readCard := DllDef.MustFindProc("read_cardinfo")
  11416. if readCard == nil {
  11417. fmt.Println("readcard is nil")
  11418. readCard = DllDef.MustFindProc("read_cardinfo")
  11419. }
  11420. str := make([]byte, 1024) //卡号
  11421. str1 := make([]byte, 1024) //卡识别码
  11422. str2 := make([]byte, 1024) //身份证号
  11423. str3 := make([]byte, 1024) //姓名
  11424. str4 := make([]byte, 1024) //错误信息
  11425. 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])))
  11426. fmt.Println(string(str1))
  11427. fmt.Println(string(str))
  11428. fmt.Println(string(str2))
  11429. fmt.Println(string(str3))
  11430. fmt.Println(string(str4))
  11431. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  11432. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  11433. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  11434. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  11435. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  11436. if ret2 != 0 {
  11437. return "", "", "", "", ""
  11438. }
  11439. return string(str), string(str1), string(str2), string(str3), string(str4)
  11440. }
  11441. type CustomFundPay struct {
  11442. FundPayType string `json:"fund_pay_type"`
  11443. FundPayamt float64 `json:"fund_payamt"`
  11444. InscpScpAmt float64 `json:"inscp_scp_amt"`
  11445. }
  11446. //func (c *HisApiController) GetBatchSettleList() {
  11447. // start_time_str := c.GetString("start_time")
  11448. // //end_time_str := c.GetString("end_time")
  11449. // admin_user_id, _ := c.GetInt64("admin_user_id")
  11450. //
  11451. // orders,_ := service.GetHisOrderByIDThree(start_time_str)
  11452. //
  11453. // for _, item := range orders {
  11454. // order, _ := service.GetHisOrderByIDTwo(item.ID)
  11455. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  11456. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  11457. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  11458. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11459. // //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  11460. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11461. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  11462. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  11463. //
  11464. // if order.ID == 0 {
  11465. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  11466. // return
  11467. // }
  11468. //
  11469. // //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  11470. // //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  11471. // //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  11472. // //fmt.Println(count)
  11473. // //var zero string
  11474. // //number := count + 1
  11475. // //if number >= 1000 {
  11476. // // zero = "0000" + strconv.FormatInt(number, 10)
  11477. // //} else if number >= 10000 {
  11478. // // zero = "000" + strconv.FormatInt(number, 10)
  11479. // //} else if number >= 100000 {
  11480. // // zero = "00" + strconv.FormatInt(number, 10)
  11481. // //} else if number >= 1000000 {
  11482. // // zero = "0" + strconv.FormatInt(number, 10)
  11483. // //} else {
  11484. // // zero = strconv.FormatInt(number, 10)
  11485. // //}
  11486. // //fmt.Println(zero)
  11487. //
  11488. // struct4101 := service.Struct4101{
  11489. // PsnNo: order.PsnNo,
  11490. // MdtrtId: order.MdtrtId,
  11491. // SetlId: order.SetlId,
  11492. // PsnName: order.PsnName,
  11493. // Gend: order.Gend,
  11494. // Brdy: his.Brdy,
  11495. // Age: his.Age,
  11496. // Naty: order.Naty,
  11497. // PatnCertType: "01",
  11498. // Certno: order.Certno,
  11499. // Prfs: "90",
  11500. // ConerName: roles[0].UserName,
  11501. // PatnRlts: "99",
  11502. // ConerAddr: miConfig.OrgName,
  11503. // ConerTel: admin.Mobile,
  11504. // HiType: order.Insutype,
  11505. // Insuplc: miConfig.InsuplcAdmdvs,
  11506. // MaindiagFlag: "1",
  11507. // BillCode: order.SetlId,
  11508. // BillNo: order.SetlId,
  11509. // BizSn: order.Number,
  11510. // PsnSelfPay: order.PsnPartAmt,
  11511. // PsnOwnPay: order.PsnPartAmt,
  11512. // AcctPay: order.AcctPay,
  11513. // PsnCashpay: order.PsnCashPay,
  11514. // HiPaymtd: "1",
  11515. // Hsorg: miConfig.InsuplcAdmdvs,
  11516. // HsorgOpter: miConfig.InsuplcAdmdvs,
  11517. // MedinsFillPsn: curRoles.UserName,
  11518. // MedinsFillDept: miConfig.OrgName,
  11519. // IptMedType: "2",
  11520. // }
  11521. // struct4101.SetlBegnDate = order.SetlTime
  11522. // struct4101.SetlEndDate = order.SetlTime
  11523. // time_arr := strings.Split(order.SetlTime, " ")
  11524. // struct4101.AdmTime = time_arr[0]
  11525. // struct4101.AdmEndTime = time_arr[0]
  11526. //
  11527. // var rf []CustomFundPay
  11528. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  11529. //
  11530. // var tempFunPays []service.CustomStruct
  11531. // for _, item := range rf {
  11532. // var tempFunPay service.CustomStruct
  11533. // tempFunPay.FundPayamt = item.FundPayamt
  11534. // tempFunPay.FundPayType = item.FundPayType
  11535. // tempFunPays = append(tempFunPays, tempFunPay)
  11536. // }
  11537. // struct4101.CustomStruct = tempFunPays
  11538. //
  11539. // var tempDiaginfos []service.DiaginfoStructTwo
  11540. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  11541. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  11542. //
  11543. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  11544. // var config []*models.HisXtDiagnoseConfig
  11545. // for _, item := range diagnosis_ids {
  11546. // id, _ := strconv.ParseInt(item, 10, 64)
  11547. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  11548. // config = append(config, &diagnosisConfig)
  11549. // }
  11550. //
  11551. // for index, item := range config {
  11552. // if index == 0 {
  11553. // var tempDiaginfo service.DiaginfoStructTwo
  11554. // tempDiaginfo.DiagCode = item.CountryCode
  11555. // tempDiaginfo.DiagName = item.CountryContentName
  11556. // tempDiaginfo.DiagType = "1"
  11557. // tempDiaginfo.MaindiagFlag = "1"
  11558. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11559. // } else {
  11560. // var tempDiaginfo service.DiaginfoStructTwo
  11561. // tempDiaginfo.DiagCode = item.CountryCode
  11562. // tempDiaginfo.DiagName = item.CountryContentName
  11563. // tempDiaginfo.DiagType = "1"
  11564. // tempDiaginfo.MaindiagFlag = "0"
  11565. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  11566. // }
  11567. // }
  11568. // struct4101.Diseinfo = tempDiaginfos
  11569. //
  11570. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  11571. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  11572. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  11573. // tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  11574. // tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  11575. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  11576. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  11577. //
  11578. // var iteminfo service.IteminfoStruct
  11579. //
  11580. // var bedCostTotal float64 = 0 //床位总费
  11581. // var bedCostSelfTotal float64 = 0 //床位自费
  11582. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  11583. //
  11584. // var operationCostTotal float64 = 0 //手术费
  11585. // var operationCostSelfTotal float64 = 0 //手术费
  11586. // var operationCostPartSelfTotal float64 = 0 //手术费
  11587. //
  11588. // var otherCostTotal float64 = 0 //其他费用
  11589. // var otherCostSelfTotal float64 = 0 //其他费用
  11590. // var otherCostPartSelfTotal float64 = 0 //其他费用
  11591. //
  11592. // var materialCostTotal float64 = 0 //材料费
  11593. // var materialCostSelfTotal float64 = 0 //材料费
  11594. // var materialCostPartSelfTotal float64 = 0 //材料费
  11595. //
  11596. // var westernMedicineCostTotal float64 = 0 //西药费
  11597. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  11598. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  11599. //
  11600. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  11601. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  11602. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  11603. //
  11604. // var checkCostTotal float64 = 0 //检查费
  11605. // var checkCostSelfTotal float64 = 0 //检查费
  11606. // var checkCostPartSelfTotal float64 = 0 //检查费
  11607. //
  11608. // var laboratoryCostTotal float64 = 0 //化验费
  11609. // var laboratoryCostSelfTotal float64 = 0 //化验费
  11610. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  11611. //
  11612. // var treatCostTotal float64 = 0 //治疗费用
  11613. // var treatCostSelfTotal float64 = 0 //治疗费用
  11614. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  11615. //
  11616. // decimal.DivisionPrecision = 2
  11617. //
  11618. // var bed_fulamt_ownpay_amt float64 = 0
  11619. // var operation_fulamt_ownpay_amt float64 = 0
  11620. // var other_fulamt_ownpay_amt float64 = 0
  11621. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  11622. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  11623. // var check_fulamt_ownpay_amt float64 = 0
  11624. // var material_fulamt_ownpay_amt float64 = 0
  11625. // var laboratory_fulamt_ownpay_amt float64 = 0
  11626. // var treat_fulamt_ownpay_amt float64 = 0
  11627. //
  11628. // var bed_claa_sunmfee float64 = 0
  11629. // var bed_clab_amt float64 = 0
  11630. // var bed_other_amt float64 = 0
  11631. //
  11632. // var operation_claa_sunmfee float64 = 0
  11633. // var operation_clab_amt float64 = 0
  11634. // var operation_other_amt float64 = 0
  11635. //
  11636. // var other_claa_sunmfee float64 = 0
  11637. // var other_clab_amt float64 = 0
  11638. // var other_other_amt float64 = 0
  11639. //
  11640. // var westernMedicine_claa_sunmfee float64 = 0
  11641. // var westernMedicine_clab_amt float64 = 0
  11642. // var westernMedicine_other_amt float64 = 0
  11643. //
  11644. // var chineseTraditional_claa_sunmfee float64 = 0
  11645. // var chineseTraditional_clab_amt float64 = 0
  11646. // var chineseTraditional_other_amt float64 = 0
  11647. //
  11648. // var check_claa_sunmfee float64 = 0
  11649. // var check_clab_amt float64 = 0
  11650. // var check_other_amt float64 = 0
  11651. //
  11652. // var material_claa_sunmfee float64 = 0
  11653. // var material_clab_amt float64 = 0
  11654. // var material_other_amt float64 = 0
  11655. //
  11656. // var laboratory_claa_sunmfee float64 = 0
  11657. // var laboratory_clab_amt float64 = 0
  11658. // var laboratory_other_amt float64 = 0
  11659. //
  11660. // var treat_claa_sunmfee float64 = 0
  11661. // var treat_clab_amt float64 = 0
  11662. // var treat_other_amt float64 = 0
  11663. //
  11664. // for _, item := range order.HisOrderInfo {
  11665. // if item.MedChrgitmType == "01" { //床位费
  11666. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11667. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11668. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11669. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11670. // if item.ChrgitmLv == "1" {
  11671. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11672. // }
  11673. // if item.ChrgitmLv == "2" {
  11674. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11675. //
  11676. // }
  11677. // if item.ChrgitmLv == "3" {
  11678. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11679. // }
  11680. //
  11681. // }
  11682. //
  11683. // if item.MedChrgitmType == "03" { //检查费
  11684. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11685. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11686. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11687. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11688. // if item.ChrgitmLv == "1" {
  11689. //
  11690. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11691. //
  11692. // }
  11693. // if item.ChrgitmLv == "2" {
  11694. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11695. //
  11696. // }
  11697. // if item.ChrgitmLv == "3" {
  11698. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11699. // }
  11700. // }
  11701. //
  11702. // if item.MedChrgitmType == "04" { //化验费
  11703. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11704. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11705. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11706. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11707. // if item.ChrgitmLv == "1" {
  11708. //
  11709. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11710. //
  11711. // }
  11712. // if item.ChrgitmLv == "2" {
  11713. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11714. //
  11715. // }
  11716. // if item.ChrgitmLv == "3" {
  11717. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11718. // }
  11719. // }
  11720. //
  11721. // if item.MedChrgitmType == "05" { //治疗费
  11722. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11723. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11724. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11725. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11726. // if item.ChrgitmLv == "1" {
  11727. //
  11728. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11729. //
  11730. // }
  11731. // if item.ChrgitmLv == "2" {
  11732. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11733. //
  11734. // }
  11735. // if item.ChrgitmLv == "3" {
  11736. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11737. // }
  11738. // }
  11739. //
  11740. // if item.MedChrgitmType == "06" { //手术费
  11741. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11742. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11743. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11744. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11745. //
  11746. // if item.ChrgitmLv == "1" {
  11747. //
  11748. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11749. //
  11750. // }
  11751. // if item.ChrgitmLv == "2" {
  11752. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11753. //
  11754. // }
  11755. // if item.ChrgitmLv == "3" {
  11756. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11757. // }
  11758. // }
  11759. //
  11760. // if item.MedChrgitmType == "08" { //材料费
  11761. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11762. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11763. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11764. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11765. // if item.ChrgitmLv == "1" {
  11766. //
  11767. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11768. //
  11769. // }
  11770. // if item.ChrgitmLv == "2" {
  11771. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11772. //
  11773. // }
  11774. // if item.ChrgitmLv == "3" {
  11775. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11776. // }
  11777. // }
  11778. //
  11779. // if item.MedChrgitmType == "09" { //西药费
  11780. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11781. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11782. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11783. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11784. // if item.ChrgitmLv == "1" {
  11785. //
  11786. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11787. //
  11788. // }
  11789. // if item.ChrgitmLv == "2" {
  11790. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11791. //
  11792. // }
  11793. // if item.ChrgitmLv == "3" {
  11794. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11795. // }
  11796. // }
  11797. //
  11798. // if item.MedChrgitmType == "11" { //中成费
  11799. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11800. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11801. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11802. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11803. // if item.ChrgitmLv == "1" {
  11804. //
  11805. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11806. //
  11807. // }
  11808. // if item.ChrgitmLv == "2" {
  11809. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11810. //
  11811. // }
  11812. // if item.ChrgitmLv == "3" {
  11813. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11814. // }
  11815. // }
  11816. //
  11817. // if item.MedChrgitmType == "14" { //其他费
  11818. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11819. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11820. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11821. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  11822. // if item.ChrgitmLv == "1" {
  11823. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  11824. //
  11825. // }
  11826. // if item.ChrgitmLv == "2" {
  11827. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  11828. //
  11829. // }
  11830. // if item.ChrgitmLv == "3" {
  11831. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  11832. // }
  11833. // }
  11834. //
  11835. // }
  11836. //
  11837. // var iteminfoStructs []service.IteminfoStruct
  11838. //
  11839. // if bedCostTotal != 0 {
  11840. // iteminfo.MedChrgitm = "01"
  11841. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11842. // iteminfo.Amt = bedCostTotal
  11843. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  11844. // iteminfo.ClabAmt = bed_clab_amt
  11845. // iteminfo.OthAmt = bed_other_amt
  11846. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11847. // }
  11848. //
  11849. // if checkCostTotal != 0 {
  11850. // iteminfo.MedChrgitm = "03"
  11851. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  11852. // iteminfo.Amt = checkCostTotal
  11853. // iteminfo.ClaaSumfee = check_claa_sunmfee
  11854. // iteminfo.ClabAmt = check_clab_amt
  11855. // iteminfo.OthAmt = check_other_amt
  11856. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11857. //
  11858. // }
  11859. //
  11860. // if laboratoryCostTotal != 0 {
  11861. // iteminfo.MedChrgitm = "04"
  11862. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  11863. // iteminfo.Amt = laboratoryCostTotal
  11864. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  11865. // iteminfo.ClabAmt = laboratory_clab_amt
  11866. // iteminfo.OthAmt = laboratory_other_amt
  11867. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11868. //
  11869. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11870. //
  11871. // }
  11872. //
  11873. // if treatCostTotal != 0 {
  11874. // iteminfo.MedChrgitm = "05"
  11875. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  11876. // iteminfo.Amt = treatCostTotal
  11877. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  11878. // iteminfo.ClabAmt = treat_clab_amt
  11879. // iteminfo.OthAmt = treat_other_amt
  11880. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11881. // //(struct4101.IteminfoStruct, iteminfo)
  11882. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11883. // }
  11884. //
  11885. // if operationCostTotal != 0 {
  11886. // iteminfo.MedChrgitm = "06"
  11887. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  11888. // iteminfo.Amt = operationCostTotal
  11889. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  11890. // iteminfo.ClabAmt = operation_clab_amt
  11891. // iteminfo.OthAmt = operation_other_amt
  11892. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11893. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11894. // }
  11895. //
  11896. // if materialCostTotal != 0 {
  11897. // iteminfo.MedChrgitm = "08"
  11898. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  11899. // iteminfo.Amt = materialCostTotal
  11900. // iteminfo.ClaaSumfee = material_claa_sunmfee
  11901. // iteminfo.ClabAmt = material_clab_amt
  11902. // iteminfo.OthAmt = material_other_amt
  11903. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11904. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11905. // }
  11906. //
  11907. // if westernMedicineCostTotal != 0 {
  11908. // iteminfo.MedChrgitm = "09"
  11909. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11910. // iteminfo.Amt = westernMedicineCostTotal
  11911. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11912. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11913. // iteminfo.OthAmt = westernMedicine_other_amt
  11914. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11915. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11916. //
  11917. // }
  11918. // if chineseTraditionalMedicineCostTotal != 0 {
  11919. // iteminfo.MedChrgitm = "11"
  11920. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  11921. // iteminfo.Amt = westernMedicineCostTotal
  11922. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  11923. // iteminfo.ClabAmt = westernMedicine_clab_amt
  11924. // iteminfo.OthAmt = westernMedicine_other_amt
  11925. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11926. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11927. //
  11928. // }
  11929. // if otherCostTotal != 0 {
  11930. // iteminfo.MedChrgitm = "14"
  11931. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  11932. // iteminfo.Amt = otherCostTotal
  11933. // iteminfo.ClaaSumfee = other_claa_sunmfee
  11934. // iteminfo.ClabAmt = other_clab_amt
  11935. // iteminfo.OthAmt = other_other_amt
  11936. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  11937. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  11938. //
  11939. // }
  11940. // struct4101.IteminfoStruct = iteminfoStructs
  11941. // struct4101.Ntly = "中国"
  11942. // struct4101.AdmCaty = "A03.06"
  11943. //
  11944. // struct4101.DoctorName = doctor.UserName
  11945. // struct4101.DoctorCode = doctor.DoctorNumber
  11946. //
  11947. // var res ResultSeventeen
  11948. //
  11949. // if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11950. // struct4101.BillCode = order.Number
  11951. // struct4101.BillNo = order.SetlId
  11952. // var resOther ResultSeventeenOther
  11953. // var pp models.PublicParams
  11954. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  11955. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  11956. // pp.FixmedinsName = miConfig.OrgName
  11957. // pp.FixmedinsCode = miConfig.Code
  11958. // pp.RequestUrl = miConfig.Url
  11959. // pp.Cainfo = miConfig.Cainfo
  11960. // pp.SecretKey = miConfig.SecretKey
  11961. // pp.AccessKey = miConfig.AccessKey
  11962. // pp.OpterName = curRoles.UserName
  11963. //
  11964. // client := &http.Client{}
  11965. // var req *http.Request
  11966. // data := make(map[string]interface{})
  11967. // data["struct4101"] = struct4101
  11968. // data["pp"] = pp
  11969. // bytesData, _ := json.Marshal(data)
  11970. // if miConfig.MdtrtareaAdmvs == "320921" {
  11971. // req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11972. // } else {
  11973. // req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  11974. // }
  11975. // resp, _ := client.Do(req)
  11976. // defer resp.Body.Close()
  11977. // body, ioErr := ioutil.ReadAll(resp.Body)
  11978. // if ioErr != nil {
  11979. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11980. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11981. // return
  11982. // }
  11983. // var respJSON map[string]interface{}
  11984. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11985. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11986. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11987. // return
  11988. // }
  11989. //
  11990. // respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  11991. // userJSONBytes, _ := json.Marshal(respJSON)
  11992. // fmt.Println("log")
  11993. // fmt.Println(string(userJSONBytes))
  11994. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  11995. // utils.ErrorLog("解析失败:%v", err)
  11996. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11997. // return
  11998. // }
  11999. // res.InfRefmsgid = resOther.InfRefmsgid
  12000. // res.Output = resOther.Output
  12001. // res.ErrMsg = resOther.ErrMsg
  12002. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12003. // res.Infcode = infocode
  12004. // } else if miConfig.MdtrtareaAdmvs == "360302" {
  12005. //
  12006. // var pp models.PublicParams
  12007. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12008. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12009. // pp.FixmedinsName = miConfig.OrgName
  12010. // pp.FixmedinsCode = miConfig.Code
  12011. // pp.RequestUrl = miConfig.Url
  12012. // pp.Cainfo = miConfig.Cainfo
  12013. // pp.SecretKey = miConfig.SecretKey
  12014. // pp.AccessKey = miConfig.AccessKey
  12015. // pp.OpterName = curRoles.UserName
  12016. // result, _ := service.Jxyb4101(struct4101, pp)
  12017. // var dat map[string]interface{}
  12018. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12019. // fmt.Println(dat)
  12020. // } else {
  12021. // fmt.Println(err)
  12022. // }
  12023. // userJSONBytes, _ := json.Marshal(dat)
  12024. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12025. // utils.ErrorLog("解析失败:%v", err)
  12026. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12027. // return
  12028. // }
  12029. //
  12030. // } else if miConfig.MdtrtareaAdmvs == "430800" {
  12031. // var pp models.PublicParams
  12032. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12033. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12034. // pp.FixmedinsName = miConfig.OrgName
  12035. // pp.FixmedinsCode = miConfig.Code
  12036. // pp.RequestUrl = miConfig.Url
  12037. // pp.Cainfo = miConfig.Cainfo
  12038. // pp.SecretKey = miConfig.SecretKey
  12039. // pp.AccessKey = miConfig.AccessKey
  12040. // pp.OpterName = curRoles.UserName
  12041. // result, _ := service.Hnyb4101(struct4101, pp)
  12042. // var dat map[string]interface{}
  12043. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12044. // fmt.Println(dat)
  12045. // } else {
  12046. // fmt.Println(err)
  12047. // }
  12048. // userJSONBytes, _ := json.Marshal(dat)
  12049. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12050. // utils.ErrorLog("解析失败:%v", err)
  12051. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12052. // return
  12053. // }
  12054. //
  12055. // } else if miConfig.MdtrtareaAdmvs == "150499" {
  12056. // var resOther ResultSeventeenOther
  12057. //
  12058. // var pp models.PublicParams
  12059. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12060. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12061. // pp.FixmedinsName = miConfig.OrgName
  12062. // pp.FixmedinsCode = miConfig.Code
  12063. // pp.RequestUrl = miConfig.Url
  12064. // pp.Cainfo = miConfig.Cainfo
  12065. // pp.SecretKey = miConfig.SecretKey
  12066. // pp.AccessKey = miConfig.AccessKey
  12067. // pp.OpterName = curRoles.UserName
  12068. // client := &http.Client{}
  12069. // var req *http.Request
  12070. // data := make(map[string]interface{})
  12071. // data["struct4101"] = struct4101
  12072. // data["pp"] = pp
  12073. // bytesData, _ := json.Marshal(data)
  12074. // req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12075. // resp, _ := client.Do(req)
  12076. // defer resp.Body.Close()
  12077. // body, ioErr := ioutil.ReadAll(resp.Body)
  12078. // if ioErr != nil {
  12079. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12080. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12081. // return
  12082. // }
  12083. // var respJSON map[string]interface{}
  12084. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12085. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12087. // return
  12088. // }
  12089. //
  12090. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12091. // userJSONBytes, _ := json.Marshal(respJSON)
  12092. // if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12093. // utils.ErrorLog("解析失败:%v", err)
  12094. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12095. // return
  12096. // }
  12097. // res.InfRefmsgid = resOther.InfRefmsgid
  12098. // res.Output = resOther.Output
  12099. // res.ErrMsg = resOther.ErrMsg
  12100. // infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12101. // res.Infcode = infocode
  12102. //
  12103. // } else if miConfig.MdtrtareaAdmvs == "350500" {
  12104. // var pp models.PublicParams
  12105. // pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12106. // pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12107. // pp.FixmedinsName = miConfig.OrgName
  12108. // pp.FixmedinsCode = miConfig.Code
  12109. // pp.RequestUrl = miConfig.Url
  12110. // pp.Cainfo = miConfig.Cainfo
  12111. // pp.SecretKey = miConfig.SecretKey
  12112. // pp.AccessKey = miConfig.AccessKey
  12113. // pp.OpterName = curRoles.UserName
  12114. // result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12115. // fmt.Println(requestLog)
  12116. // fmt.Println(errMsgLog)
  12117. //
  12118. // saveLog(result, requestLog, "4101a", "上传清单")
  12119. //
  12120. // var dat map[string]interface{}
  12121. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12122. // fmt.Println(dat)
  12123. // } else {
  12124. // fmt.Println(err)
  12125. // }
  12126. // userJSONBytes, _ := json.Marshal(dat)
  12127. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12128. // utils.ErrorLog("解析失败:%v", err)
  12129. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12130. // return
  12131. // }
  12132. //
  12133. // } else {
  12134. //
  12135. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  12136. // var dat map[string]interface{}
  12137. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12138. // fmt.Println(dat)
  12139. // } else {
  12140. // fmt.Println(err)
  12141. // }
  12142. // userJSONBytes, _ := json.Marshal(dat)
  12143. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12144. // utils.ErrorLog("解析失败:%v", err)
  12145. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12146. // return
  12147. // }
  12148. // }
  12149. //
  12150. // if res.Infcode != 0 {
  12151. // adminUser := c.GetAdminUserInfo()
  12152. // errlog := &models.HisOrderError{
  12153. // UserOrgId: adminUser.CurrentOrgId,
  12154. // Ctime: time.Now().Unix(),
  12155. // Mtime: time.Now().Unix(),
  12156. // ErrMsg: res.ErrMsg,
  12157. // Status: 1,
  12158. // PatientId: order.ID,
  12159. // Stage: 10265,
  12160. // }
  12161. // service.CreateErrMsgLog(errlog)
  12162. // continue
  12163. // } else {
  12164. // //order.FaPiaoNumber = zero
  12165. // //order.FaPiaoCode = last_order.FaPiaoCode
  12166. // //service.UpdateOrder(order)
  12167. // hisFundSettleListResult := &models.HisFundSettleListResult{
  12168. // Number: res.Output.SetlListId,
  12169. // Status: 1,
  12170. // Ctime: time.Now().Unix(),
  12171. // Mtime: time.Now().Unix(),
  12172. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12173. // IsUpload: 1,
  12174. // OrderId: order.ID,
  12175. // }
  12176. // service.CreateUploadRecord(hisFundSettleListResult)
  12177. // c.ServeSuccessJSON(map[string]interface{}{
  12178. // "msg": "上传成功",
  12179. // "result": hisFundSettleListResult,
  12180. // })
  12181. // continue
  12182. // }
  12183. // }
  12184. //}
  12185. func (c *HisApiController) GetbatchSettleList() {
  12186. //order_id, _ := c.GetInt64("order_id")
  12187. admin_user_id, _ := c.GetInt64("admin_user_id")
  12188. orders, _ := service.GetAllHisOrderTwo10485()
  12189. for _, item := range orders {
  12190. order, _ := service.GetHisOrderByIDTwo(item.ID)
  12191. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12192. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12193. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12194. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12195. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12196. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12197. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12198. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12199. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12200. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12201. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12202. //fmt.Println(count)
  12203. //var zero string
  12204. //number := count + 1
  12205. //if number >= 1000 {
  12206. // zero = "0000" + strconv.FormatInt(number, 10)
  12207. //} else if number >= 10000 {
  12208. // zero = "000" + strconv.FormatInt(number, 10)
  12209. //} else if number >= 100000 {
  12210. // zero = "00" + strconv.FormatInt(number, 10)
  12211. //} else if number >= 1000000 {
  12212. // zero = "0" + strconv.FormatInt(number, 10)
  12213. //} else {
  12214. // zero = strconv.FormatInt(number, 10)
  12215. //}
  12216. //fmt.Println(zero)
  12217. struct4101 := service.Struct4101{
  12218. PsnNo: order.PsnNo,
  12219. MdtrtId: order.MdtrtId,
  12220. SetlId: order.SetlId,
  12221. PsnName: order.PsnName,
  12222. Gend: order.Gend,
  12223. Brdy: his.Brdy,
  12224. Age: his.Age,
  12225. Naty: order.Naty,
  12226. PatnCertType: "01",
  12227. Certno: order.Certno,
  12228. Prfs: "90",
  12229. ConerName: roles[0].UserName,
  12230. PatnRlts: "99",
  12231. ConerAddr: miConfig.OrgName,
  12232. ConerTel: admin.Mobile,
  12233. HiType: order.Insutype,
  12234. Insuplc: miConfig.InsuplcAdmdvs,
  12235. MaindiagFlag: "1",
  12236. BillCode: order.SetlId,
  12237. BillNo: order.SetlId,
  12238. BizSn: order.Number,
  12239. PsnSelfPay: order.PsnPartAmt,
  12240. PsnOwnPay: order.PsnPartAmt,
  12241. AcctPay: order.AcctPay,
  12242. PsnCashpay: order.PsnCashPay,
  12243. HiPaymtd: "1",
  12244. Hsorg: miConfig.InsuplcAdmdvs,
  12245. HsorgOpter: miConfig.InsuplcAdmdvs,
  12246. MedinsFillPsn: curRoles.UserName,
  12247. MedinsFillDept: miConfig.OrgName,
  12248. IptMedType: "2",
  12249. }
  12250. struct4101.SetlBegnDate = order.SetlTime
  12251. struct4101.SetlEndDate = order.SetlTime
  12252. time_arr := strings.Split(order.SetlTime, " ")
  12253. struct4101.AdmTime = time_arr[0]
  12254. struct4101.AdmEndTime = time_arr[0]
  12255. //var rf []CustomFundPay
  12256. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12257. //
  12258. //var tempFunPays []service.CustomStruct
  12259. //for _, item := range rf {
  12260. // var tempFunPay service.CustomStruct
  12261. // tempFunPay.FundPayamt = item.FundPayamt
  12262. // tempFunPay.FundPayType = item.FundPayType
  12263. // tempFunPays = append(tempFunPays, tempFunPay)
  12264. //}
  12265. //struct4101.CustomStruct = tempFunPays
  12266. var tempDiaginfos []service.DiaginfoStructTwo
  12267. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12268. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12269. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  12270. var config []*models.HisXtDiagnoseConfig
  12271. for _, item := range diagnosis_ids {
  12272. id, _ := strconv.ParseInt(item, 10, 64)
  12273. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12274. config = append(config, &diagnosisConfig)
  12275. }
  12276. for index, item := range config {
  12277. if index == 0 {
  12278. var tempDiaginfo service.DiaginfoStructTwo
  12279. tempDiaginfo.DiagCode = item.CountryCode
  12280. tempDiaginfo.DiagName = item.CountryContentName
  12281. tempDiaginfo.DiagType = "1"
  12282. tempDiaginfo.MaindiagFlag = "1"
  12283. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12284. } else {
  12285. var tempDiaginfo service.DiaginfoStructTwo
  12286. tempDiaginfo.DiagCode = item.CountryCode
  12287. tempDiaginfo.DiagName = item.CountryContentName
  12288. tempDiaginfo.DiagType = "1"
  12289. tempDiaginfo.MaindiagFlag = "0"
  12290. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12291. }
  12292. }
  12293. struct4101.Diseinfo = tempDiaginfos
  12294. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12295. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12296. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12297. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  12298. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  12299. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  12300. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  12301. var iteminfo service.IteminfoStruct
  12302. var bedCostTotal float64 = 0 //床位总费
  12303. var bedCostSelfTotal float64 = 0 //床位自费
  12304. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  12305. var operationCostTotal float64 = 0 //手术费
  12306. var operationCostSelfTotal float64 = 0 //手术费
  12307. var operationCostPartSelfTotal float64 = 0 //手术费
  12308. var otherCostTotal float64 = 0 //其他费用
  12309. var otherCostSelfTotal float64 = 0 //其他费用
  12310. var otherCostPartSelfTotal float64 = 0 //其他费用
  12311. var materialCostTotal float64 = 0 //材料费
  12312. var materialCostSelfTotal float64 = 0 //材料费
  12313. var materialCostPartSelfTotal float64 = 0 //材料费
  12314. var westernMedicineCostTotal float64 = 0 //西药费
  12315. var westernMedicineCostSelfTotal float64 = 0 //西药费
  12316. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  12317. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  12318. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  12319. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  12320. var checkCostTotal float64 = 0 //检查费
  12321. var checkCostSelfTotal float64 = 0 //检查费
  12322. var checkCostPartSelfTotal float64 = 0 //检查费
  12323. var laboratoryCostTotal float64 = 0 //化验费
  12324. var laboratoryCostSelfTotal float64 = 0 //化验费
  12325. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  12326. var treatCostTotal float64 = 0 //治疗费用
  12327. var treatCostSelfTotal float64 = 0 //治疗费用
  12328. var treatCostPartSelfTotal float64 = 0 //治疗费用
  12329. decimal.DivisionPrecision = 2
  12330. var bed_fulamt_ownpay_amt float64 = 0
  12331. var operation_fulamt_ownpay_amt float64 = 0
  12332. var other_fulamt_ownpay_amt float64 = 0
  12333. var westernMedicine_fulamt_ownpay_amt float64 = 0
  12334. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  12335. var check_fulamt_ownpay_amt float64 = 0
  12336. var material_fulamt_ownpay_amt float64 = 0
  12337. var laboratory_fulamt_ownpay_amt float64 = 0
  12338. var treat_fulamt_ownpay_amt float64 = 0
  12339. var bed_claa_sunmfee float64 = 0
  12340. var bed_clab_amt float64 = 0
  12341. var bed_other_amt float64 = 0
  12342. var operation_claa_sunmfee float64 = 0
  12343. var operation_clab_amt float64 = 0
  12344. var operation_other_amt float64 = 0
  12345. var other_claa_sunmfee float64 = 0
  12346. var other_clab_amt float64 = 0
  12347. var other_other_amt float64 = 0
  12348. var westernMedicine_claa_sunmfee float64 = 0
  12349. var westernMedicine_clab_amt float64 = 0
  12350. var westernMedicine_other_amt float64 = 0
  12351. var chineseTraditional_claa_sunmfee float64 = 0
  12352. var chineseTraditional_clab_amt float64 = 0
  12353. var chineseTraditional_other_amt float64 = 0
  12354. var check_claa_sunmfee float64 = 0
  12355. var check_clab_amt float64 = 0
  12356. var check_other_amt float64 = 0
  12357. var material_claa_sunmfee float64 = 0
  12358. var material_clab_amt float64 = 0
  12359. var material_other_amt float64 = 0
  12360. var laboratory_claa_sunmfee float64 = 0
  12361. var laboratory_clab_amt float64 = 0
  12362. var laboratory_other_amt float64 = 0
  12363. var treat_claa_sunmfee float64 = 0
  12364. var treat_clab_amt float64 = 0
  12365. var treat_other_amt float64 = 0
  12366. for _, item := range order.HisOrderInfo {
  12367. if item.MedChrgitmType == "01" { //床位费
  12368. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12369. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12370. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12371. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12372. if item.ChrgitmLv == "1" {
  12373. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12374. }
  12375. if item.ChrgitmLv == "2" {
  12376. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12377. }
  12378. if item.ChrgitmLv == "3" {
  12379. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12380. }
  12381. }
  12382. if item.MedChrgitmType == "03" { //检查费
  12383. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12384. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12385. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12386. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12387. if item.ChrgitmLv == "1" {
  12388. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12389. }
  12390. if item.ChrgitmLv == "2" {
  12391. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12392. }
  12393. if item.ChrgitmLv == "3" {
  12394. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12395. }
  12396. }
  12397. if item.MedChrgitmType == "04" { //化验费
  12398. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12399. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12400. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12401. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12402. if item.ChrgitmLv == "1" {
  12403. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12404. }
  12405. if item.ChrgitmLv == "2" {
  12406. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12407. }
  12408. if item.ChrgitmLv == "3" {
  12409. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12410. }
  12411. }
  12412. if item.MedChrgitmType == "05" { //治疗费
  12413. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12414. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12415. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12416. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12417. if item.ChrgitmLv == "1" {
  12418. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12419. }
  12420. if item.ChrgitmLv == "2" {
  12421. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12422. }
  12423. if item.ChrgitmLv == "3" {
  12424. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12425. }
  12426. }
  12427. if item.MedChrgitmType == "06" { //手术费
  12428. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12429. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12430. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12431. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12432. if item.ChrgitmLv == "1" {
  12433. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12434. }
  12435. if item.ChrgitmLv == "2" {
  12436. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12437. }
  12438. if item.ChrgitmLv == "3" {
  12439. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12440. }
  12441. }
  12442. if item.MedChrgitmType == "08" { //材料费
  12443. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12444. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12445. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12446. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12447. if item.ChrgitmLv == "1" {
  12448. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12449. }
  12450. if item.ChrgitmLv == "2" {
  12451. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12452. }
  12453. if item.ChrgitmLv == "3" {
  12454. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12455. }
  12456. }
  12457. if item.MedChrgitmType == "09" { //西药费
  12458. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12459. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12460. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12461. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12462. if item.ChrgitmLv == "1" {
  12463. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12464. }
  12465. if item.ChrgitmLv == "2" {
  12466. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12467. }
  12468. if item.ChrgitmLv == "3" {
  12469. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12470. }
  12471. }
  12472. if item.MedChrgitmType == "11" { //中成费
  12473. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12474. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12475. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12476. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12477. if item.ChrgitmLv == "1" {
  12478. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12479. }
  12480. if item.ChrgitmLv == "2" {
  12481. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12482. }
  12483. if item.ChrgitmLv == "3" {
  12484. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12485. }
  12486. }
  12487. if item.MedChrgitmType == "14" { //其他费
  12488. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12489. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12490. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12491. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  12492. if item.ChrgitmLv == "1" {
  12493. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  12494. }
  12495. if item.ChrgitmLv == "2" {
  12496. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  12497. }
  12498. if item.ChrgitmLv == "3" {
  12499. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  12500. }
  12501. }
  12502. }
  12503. var iteminfoStructs []service.IteminfoStruct
  12504. if bedCostTotal != 0 {
  12505. iteminfo.MedChrgitm = "01"
  12506. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12507. iteminfo.Amt = bedCostTotal
  12508. iteminfo.ClaaSumfee = bed_claa_sunmfee
  12509. iteminfo.ClabAmt = bed_clab_amt
  12510. iteminfo.OthAmt = bed_other_amt
  12511. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12512. }
  12513. if checkCostTotal != 0 {
  12514. iteminfo.MedChrgitm = "03"
  12515. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  12516. iteminfo.Amt = checkCostTotal
  12517. iteminfo.ClaaSumfee = check_claa_sunmfee
  12518. iteminfo.ClabAmt = check_clab_amt
  12519. iteminfo.OthAmt = check_other_amt
  12520. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12521. }
  12522. if laboratoryCostTotal != 0 {
  12523. iteminfo.MedChrgitm = "04"
  12524. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  12525. iteminfo.Amt = laboratoryCostTotal
  12526. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  12527. iteminfo.ClabAmt = laboratory_clab_amt
  12528. iteminfo.OthAmt = laboratory_other_amt
  12529. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12530. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12531. }
  12532. if treatCostTotal != 0 {
  12533. iteminfo.MedChrgitm = "05"
  12534. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  12535. iteminfo.Amt = treatCostTotal
  12536. iteminfo.ClaaSumfee = treat_claa_sunmfee
  12537. iteminfo.ClabAmt = treat_clab_amt
  12538. iteminfo.OthAmt = treat_other_amt
  12539. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12540. //(struct4101.IteminfoStruct, iteminfo)
  12541. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12542. }
  12543. if operationCostTotal != 0 {
  12544. iteminfo.MedChrgitm = "06"
  12545. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  12546. iteminfo.Amt = operationCostTotal
  12547. iteminfo.ClaaSumfee = operation_claa_sunmfee
  12548. iteminfo.ClabAmt = operation_clab_amt
  12549. iteminfo.OthAmt = operation_other_amt
  12550. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12552. }
  12553. if materialCostTotal != 0 {
  12554. iteminfo.MedChrgitm = "08"
  12555. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  12556. iteminfo.Amt = materialCostTotal
  12557. iteminfo.ClaaSumfee = material_claa_sunmfee
  12558. iteminfo.ClabAmt = material_clab_amt
  12559. iteminfo.OthAmt = material_other_amt
  12560. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12562. }
  12563. if westernMedicineCostTotal != 0 {
  12564. iteminfo.MedChrgitm = "09"
  12565. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12566. iteminfo.Amt = westernMedicineCostTotal
  12567. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12568. iteminfo.ClabAmt = westernMedicine_clab_amt
  12569. iteminfo.OthAmt = westernMedicine_other_amt
  12570. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12571. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12572. }
  12573. if chineseTraditionalMedicineCostTotal != 0 {
  12574. iteminfo.MedChrgitm = "11"
  12575. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  12576. iteminfo.Amt = westernMedicineCostTotal
  12577. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  12578. iteminfo.ClabAmt = westernMedicine_clab_amt
  12579. iteminfo.OthAmt = westernMedicine_other_amt
  12580. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12581. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12582. }
  12583. if otherCostTotal != 0 {
  12584. iteminfo.MedChrgitm = "14"
  12585. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  12586. iteminfo.Amt = otherCostTotal
  12587. iteminfo.ClaaSumfee = other_claa_sunmfee
  12588. iteminfo.ClabAmt = other_clab_amt
  12589. iteminfo.OthAmt = other_other_amt
  12590. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  12591. iteminfoStructs = append(iteminfoStructs, iteminfo)
  12592. }
  12593. struct4101.IteminfoStruct = iteminfoStructs
  12594. struct4101.Ntly = "中国"
  12595. struct4101.AdmCaty = "A03.06"
  12596. struct4101.DoctorName = doctor.UserName
  12597. struct4101.DoctorCode = doctor.DoctorNumber
  12598. var res ResultSeventeen
  12599. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12600. struct4101.BillCode = order.Number
  12601. struct4101.BillNo = order.SetlId
  12602. var resOther ResultSeventeenOther
  12603. var pp models.PublicParams
  12604. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12605. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12606. pp.FixmedinsName = miConfig.OrgName
  12607. pp.FixmedinsCode = miConfig.Code
  12608. pp.RequestUrl = miConfig.Url
  12609. pp.Cainfo = miConfig.Cainfo
  12610. pp.SecretKey = miConfig.SecretKey
  12611. pp.AccessKey = miConfig.AccessKey
  12612. pp.OpterName = curRoles.UserName
  12613. client := &http.Client{}
  12614. var req *http.Request
  12615. data := make(map[string]interface{})
  12616. data["struct4101"] = struct4101
  12617. data["pp"] = pp
  12618. bytesData, _ := json.Marshal(data)
  12619. if miConfig.MdtrtareaAdmvs == "320921" {
  12620. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12621. } else {
  12622. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  12623. }
  12624. resp, _ := client.Do(req)
  12625. defer resp.Body.Close()
  12626. body, ioErr := ioutil.ReadAll(resp.Body)
  12627. if ioErr != nil {
  12628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12630. return
  12631. }
  12632. var respJSON map[string]interface{}
  12633. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12636. return
  12637. }
  12638. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  12639. userJSONBytes, _ := json.Marshal(respJSON)
  12640. fmt.Println("log")
  12641. fmt.Println(string(userJSONBytes))
  12642. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12643. utils.ErrorLog("解析失败:%v", err)
  12644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12645. return
  12646. }
  12647. res.InfRefmsgid = resOther.InfRefmsgid
  12648. res.Output = resOther.Output
  12649. res.ErrMsg = resOther.ErrMsg
  12650. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12651. res.Infcode = infocode
  12652. } else if miConfig.MdtrtareaAdmvs == "360302" {
  12653. var pp models.PublicParams
  12654. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12655. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12656. pp.FixmedinsName = miConfig.OrgName
  12657. pp.FixmedinsCode = miConfig.Code
  12658. pp.RequestUrl = miConfig.Url
  12659. pp.Cainfo = miConfig.Cainfo
  12660. pp.SecretKey = miConfig.SecretKey
  12661. pp.AccessKey = miConfig.AccessKey
  12662. pp.OpterName = curRoles.UserName
  12663. result, _ := service.Jxyb4101(struct4101, pp)
  12664. var dat map[string]interface{}
  12665. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12666. fmt.Println(dat)
  12667. } else {
  12668. fmt.Println(err)
  12669. }
  12670. userJSONBytes, _ := json.Marshal(dat)
  12671. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12672. utils.ErrorLog("解析失败:%v", err)
  12673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12674. return
  12675. }
  12676. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12677. var pp models.PublicParams
  12678. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12679. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12680. pp.FixmedinsName = miConfig.OrgName
  12681. pp.FixmedinsCode = miConfig.Code
  12682. pp.RequestUrl = miConfig.Url
  12683. pp.Cainfo = miConfig.Cainfo
  12684. pp.SecretKey = miConfig.SecretKey
  12685. pp.AccessKey = miConfig.AccessKey
  12686. pp.OpterName = curRoles.UserName
  12687. result, _ := service.Hnyb4101(struct4101, pp)
  12688. var dat map[string]interface{}
  12689. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12690. fmt.Println(dat)
  12691. } else {
  12692. fmt.Println(err)
  12693. }
  12694. userJSONBytes, _ := json.Marshal(dat)
  12695. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12696. utils.ErrorLog("解析失败:%v", err)
  12697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12698. return
  12699. }
  12700. } else if miConfig.MdtrtareaAdmvs == "150499" {
  12701. var resOther ResultSeventeenOther
  12702. var pp models.PublicParams
  12703. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12704. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12705. pp.FixmedinsName = miConfig.OrgName
  12706. pp.FixmedinsCode = miConfig.Code
  12707. pp.RequestUrl = miConfig.Url
  12708. pp.Cainfo = miConfig.Cainfo
  12709. pp.SecretKey = miConfig.SecretKey
  12710. pp.AccessKey = miConfig.AccessKey
  12711. pp.OpterName = curRoles.UserName
  12712. client := &http.Client{}
  12713. var req *http.Request
  12714. data := make(map[string]interface{})
  12715. data["struct4101"] = struct4101
  12716. data["pp"] = pp
  12717. bytesData, _ := json.Marshal(data)
  12718. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  12719. resp, _ := client.Do(req)
  12720. defer resp.Body.Close()
  12721. body, ioErr := ioutil.ReadAll(resp.Body)
  12722. if ioErr != nil {
  12723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12725. return
  12726. }
  12727. var respJSON map[string]interface{}
  12728. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12731. return
  12732. }
  12733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12734. userJSONBytes, _ := json.Marshal(respJSON)
  12735. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  12736. utils.ErrorLog("解析失败:%v", err)
  12737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12738. return
  12739. }
  12740. res.InfRefmsgid = resOther.InfRefmsgid
  12741. res.Output = resOther.Output
  12742. res.ErrMsg = resOther.ErrMsg
  12743. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  12744. res.Infcode = infocode
  12745. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12746. var pp models.PublicParams
  12747. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12748. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12749. pp.FixmedinsName = miConfig.OrgName
  12750. pp.FixmedinsCode = miConfig.Code
  12751. pp.RequestUrl = miConfig.Url
  12752. pp.Cainfo = miConfig.Cainfo
  12753. pp.SecretKey = miConfig.SecretKey
  12754. pp.AccessKey = miConfig.AccessKey
  12755. pp.OpterName = curRoles.UserName
  12756. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  12757. fmt.Println(requestLog)
  12758. fmt.Println(errMsgLog)
  12759. saveLog(result, requestLog, "4101a", "上传清单")
  12760. var dat map[string]interface{}
  12761. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12762. fmt.Println(dat)
  12763. } else {
  12764. fmt.Println(err)
  12765. }
  12766. userJSONBytes, _ := json.Marshal(dat)
  12767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12768. utils.ErrorLog("解析失败:%v", err)
  12769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12770. return
  12771. }
  12772. } else if miConfig.MdtrtareaAdmvs == "441799" {
  12773. var pp models.PublicParams
  12774. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  12775. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  12776. pp.FixmedinsName = miConfig.OrgName
  12777. pp.FixmedinsCode = miConfig.Code
  12778. pp.RequestUrl = miConfig.Url
  12779. pp.Cainfo = miConfig.Cainfo
  12780. pp.SecretKey = miConfig.SecretKey
  12781. pp.AccessKey = miConfig.AccessKey
  12782. pp.OpterName = curRoles.UserName
  12783. client := &http.Client{}
  12784. var req *http.Request
  12785. data := make(map[string]interface{})
  12786. data["struct4101"] = struct4101
  12787. data["pp"] = pp
  12788. bytesData, _ := json.Marshal(data)
  12789. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  12790. resp, _ := client.Do(req)
  12791. defer resp.Body.Close()
  12792. body, ioErr := ioutil.ReadAll(resp.Body)
  12793. if ioErr != nil {
  12794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12796. return
  12797. }
  12798. var respJSON map[string]interface{}
  12799. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  12800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12802. return
  12803. }
  12804. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12805. userJSONBytes, _ := json.Marshal(respJSON)
  12806. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12807. utils.ErrorLog("解析失败:%v", err)
  12808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12809. return
  12810. }
  12811. } else {
  12812. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  12813. var dat map[string]interface{}
  12814. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12815. fmt.Println(dat)
  12816. } else {
  12817. fmt.Println(err)
  12818. }
  12819. userJSONBytes, _ := json.Marshal(dat)
  12820. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12821. utils.ErrorLog("解析失败:%v", err)
  12822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12823. return
  12824. }
  12825. }
  12826. if res.Infcode != 0 {
  12827. errlog := &models.HisOrderError{
  12828. UserOrgId: order.UserOrgId,
  12829. Ctime: time.Now().Unix(),
  12830. Mtime: time.Now().Unix(),
  12831. ErrMsg: res.ErrMsg + "解析失败",
  12832. Status: 1,
  12833. PatientId: order.ID,
  12834. Stage: 10485,
  12835. }
  12836. service.CreateErrMsgLog(errlog)
  12837. continue
  12838. //c.ServeSuccessJSON(map[string]interface{}{
  12839. // "failed_code": -10,
  12840. // "msg": res.ErrMsg,
  12841. //})
  12842. } else {
  12843. //order.FaPiaoNumber = zero
  12844. //order.FaPiaoCode = last_order.FaPiaoCode
  12845. //service.UpdateOrder(order)
  12846. hisFundSettleListResult := &models.HisFundSettleListResult{
  12847. Number: res.Output.SetlListId,
  12848. Status: 1,
  12849. Ctime: time.Now().Unix(),
  12850. Mtime: time.Now().Unix(),
  12851. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  12852. IsUpload: 1,
  12853. OrderId: order.ID,
  12854. }
  12855. service.CreateUploadRecord(hisFundSettleListResult)
  12856. continue
  12857. }
  12858. }
  12859. }
  12860. func (c *HisApiController) GetSettleList() {
  12861. order_id, _ := c.GetInt64("order_id")
  12862. admin_user_id, _ := c.GetInt64("admin_user_id")
  12863. order, _ := service.GetHisOrderByIDTwo(order_id)
  12864. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  12865. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12866. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  12867. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  12868. //depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  12869. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  12870. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  12871. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  12872. if order.ID == 0 {
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  12874. return
  12875. }
  12876. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  12877. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  12878. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  12879. //fmt.Println(count)
  12880. //var zero string
  12881. //number := count + 1
  12882. //if number >= 1000 {
  12883. // zero = "0000" + strconv.FormatInt(number, 10)
  12884. //} else if number >= 10000 {
  12885. // zero = "000" + strconv.FormatInt(number, 10)
  12886. //} else if number >= 100000 {
  12887. // zero = "00" + strconv.FormatInt(number, 10)
  12888. //} else if number >= 1000000 {
  12889. // zero = "0" + strconv.FormatInt(number, 10)
  12890. //} else {
  12891. // zero = strconv.FormatInt(number, 10)
  12892. //}
  12893. //fmt.Println(zero)
  12894. struct4101 := service.Struct4101{
  12895. PsnNo: order.PsnNo,
  12896. MdtrtId: order.MdtrtId,
  12897. SetlId: order.SetlId,
  12898. PsnName: order.PsnName,
  12899. Gend: order.Gend,
  12900. Brdy: his.Brdy,
  12901. Age: his.Age,
  12902. Naty: order.Naty,
  12903. PatnCertType: "01",
  12904. Certno: order.Certno,
  12905. Prfs: "90",
  12906. ConerName: roles[0].UserName,
  12907. PatnRlts: "99",
  12908. ConerAddr: miConfig.OrgName,
  12909. ConerTel: admin.Mobile,
  12910. HiType: order.Insutype,
  12911. Insuplc: miConfig.InsuplcAdmdvs,
  12912. MaindiagFlag: "1",
  12913. BillCode: order.SetlId,
  12914. BillNo: order.SetlId,
  12915. BizSn: order.Number,
  12916. PsnSelfPay: order.PsnPartAmt,
  12917. PsnOwnPay: order.PsnPartAmt,
  12918. AcctPay: order.AcctPay,
  12919. PsnCashpay: order.PsnCashPay,
  12920. HiPaymtd: "1",
  12921. Hsorg: miConfig.InsuplcAdmdvs,
  12922. HsorgOpter: miConfig.InsuplcAdmdvs,
  12923. MedinsFillPsn: curRoles.UserName,
  12924. MedinsFillDept: miConfig.OrgName,
  12925. IptMedType: "2",
  12926. }
  12927. struct4101.SetlBegnDate = order.SetlTime
  12928. struct4101.SetlEndDate = order.SetlTime
  12929. time_arr := strings.Split(order.SetlTime, " ")
  12930. struct4101.AdmTime = time_arr[0]
  12931. struct4101.AdmEndTime = time_arr[0]
  12932. //
  12933. //var rf []CustomFundPay
  12934. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  12935. //
  12936. //var tempFunPays []service.CustomStruct
  12937. //for _, item := range rf {
  12938. // var tempFunPay service.CustomStruct
  12939. // tempFunPay.FundPayamt = item.FundPayamt
  12940. // tempFunPay.FundPayType = item.FundPayType
  12941. // tempFunPays = append(tempFunPays, tempFunPay)
  12942. //}
  12943. //struct4101.CustomStruct = tempFunPays
  12944. var tempDiaginfos []service.DiaginfoStructTwo
  12945. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  12946. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  12947. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  12948. var config []*models.HisXtDiagnoseConfig
  12949. for _, item := range diagnosis_ids {
  12950. id, _ := strconv.ParseInt(item, 10, 64)
  12951. diagnosisConfig, _ := service.FindDiagnoseById(id)
  12952. config = append(config, &diagnosisConfig)
  12953. }
  12954. if miConfig.Code == "H15049901371" {
  12955. //for _, item := range config {
  12956. // if item.ID == 138 {
  12957. diagnosisConfig, _ := service.FindDiagnoseById(138)
  12958. var tempDiaginfo service.DiaginfoStructTwo
  12959. tempDiaginfo.DiagCode = diagnosisConfig.CountryCode
  12960. tempDiaginfo.DiagName = diagnosisConfig.CountryContentName
  12961. tempDiaginfo.DiagType = "1"
  12962. tempDiaginfo.MaindiagFlag = "1"
  12963. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12964. //}
  12965. //}
  12966. for _, item := range config {
  12967. if item.ID != 138 {
  12968. var tempDiaginfo service.DiaginfoStructTwo
  12969. tempDiaginfo.DiagCode = item.CountryCode
  12970. tempDiaginfo.DiagName = item.CountryContentName
  12971. tempDiaginfo.DiagType = "1"
  12972. tempDiaginfo.MaindiagFlag = "0"
  12973. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12974. }
  12975. }
  12976. } else {
  12977. for index, item := range config {
  12978. if index == 0 {
  12979. var tempDiaginfo service.DiaginfoStructTwo
  12980. tempDiaginfo.DiagCode = item.CountryCode
  12981. tempDiaginfo.DiagName = item.CountryContentName
  12982. tempDiaginfo.DiagType = "1"
  12983. tempDiaginfo.MaindiagFlag = "1"
  12984. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12985. } else {
  12986. var tempDiaginfo service.DiaginfoStructTwo
  12987. tempDiaginfo.DiagCode = item.CountryCode
  12988. tempDiaginfo.DiagName = item.CountryContentName
  12989. tempDiaginfo.DiagType = "1"
  12990. tempDiaginfo.MaindiagFlag = "0"
  12991. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  12992. }
  12993. }
  12994. }
  12995. struct4101.Diseinfo = tempDiaginfos
  12996. sickConfigTwo, _ := service.FindSickById(his.SickType)
  12997. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  12998. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  12999. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  13000. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  13001. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13002. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13003. var iteminfo service.IteminfoStruct
  13004. var bedCostTotal float64 = 0 //床位总费
  13005. var bedCostSelfTotal float64 = 0 //床位自费
  13006. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13007. var operationCostTotal float64 = 0 //手术费
  13008. var operationCostSelfTotal float64 = 0 //手术费
  13009. var operationCostPartSelfTotal float64 = 0 //手术费
  13010. var otherCostTotal float64 = 0 //其他费用
  13011. var otherCostSelfTotal float64 = 0 //其他费用
  13012. var otherCostPartSelfTotal float64 = 0 //其他费用
  13013. var materialCostTotal float64 = 0 //材料费
  13014. var materialCostSelfTotal float64 = 0 //材料费
  13015. var materialCostPartSelfTotal float64 = 0 //材料费
  13016. var westernMedicineCostTotal float64 = 0 //西药费
  13017. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13018. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13019. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13020. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13021. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13022. var checkCostTotal float64 = 0 //检查费
  13023. var checkCostSelfTotal float64 = 0 //检查费
  13024. var checkCostPartSelfTotal float64 = 0 //检查费
  13025. var laboratoryCostTotal float64 = 0 //化验费
  13026. var laboratoryCostSelfTotal float64 = 0 //化验费
  13027. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13028. var treatCostTotal float64 = 0 //治疗费用
  13029. var treatCostSelfTotal float64 = 0 //治疗费用
  13030. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13031. decimal.DivisionPrecision = 2
  13032. var bed_fulamt_ownpay_amt float64 = 0
  13033. var operation_fulamt_ownpay_amt float64 = 0
  13034. var other_fulamt_ownpay_amt float64 = 0
  13035. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13036. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13037. var check_fulamt_ownpay_amt float64 = 0
  13038. var material_fulamt_ownpay_amt float64 = 0
  13039. var laboratory_fulamt_ownpay_amt float64 = 0
  13040. var treat_fulamt_ownpay_amt float64 = 0
  13041. var bed_claa_sunmfee float64 = 0
  13042. var bed_clab_amt float64 = 0
  13043. var bed_other_amt float64 = 0
  13044. var operation_claa_sunmfee float64 = 0
  13045. var operation_clab_amt float64 = 0
  13046. var operation_other_amt float64 = 0
  13047. var other_claa_sunmfee float64 = 0
  13048. var other_clab_amt float64 = 0
  13049. var other_other_amt float64 = 0
  13050. var westernMedicine_claa_sunmfee float64 = 0
  13051. var westernMedicine_clab_amt float64 = 0
  13052. var westernMedicine_other_amt float64 = 0
  13053. var chineseTraditional_claa_sunmfee float64 = 0
  13054. var chineseTraditional_clab_amt float64 = 0
  13055. var chineseTraditional_other_amt float64 = 0
  13056. var check_claa_sunmfee float64 = 0
  13057. var check_clab_amt float64 = 0
  13058. var check_other_amt float64 = 0
  13059. var material_claa_sunmfee float64 = 0
  13060. var material_clab_amt float64 = 0
  13061. var material_other_amt float64 = 0
  13062. var laboratory_claa_sunmfee float64 = 0
  13063. var laboratory_clab_amt float64 = 0
  13064. var laboratory_other_amt float64 = 0
  13065. var treat_claa_sunmfee float64 = 0
  13066. var treat_clab_amt float64 = 0
  13067. var treat_other_amt float64 = 0
  13068. for _, item := range order.HisOrderInfo {
  13069. if item.MedChrgitmType == "01" { //床位费
  13070. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13071. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13072. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13073. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13074. if item.ChrgitmLv == "1" {
  13075. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13076. }
  13077. if item.ChrgitmLv == "2" {
  13078. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13079. }
  13080. if item.ChrgitmLv == "3" {
  13081. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13082. }
  13083. }
  13084. if item.MedChrgitmType == "03" { //检查费
  13085. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13086. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13087. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13088. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13089. if item.ChrgitmLv == "1" {
  13090. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13091. }
  13092. if item.ChrgitmLv == "2" {
  13093. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13094. }
  13095. if item.ChrgitmLv == "3" {
  13096. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13097. }
  13098. }
  13099. if item.MedChrgitmType == "04" { //化验费
  13100. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13101. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13102. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13103. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13104. if item.ChrgitmLv == "1" {
  13105. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13106. }
  13107. if item.ChrgitmLv == "2" {
  13108. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13109. }
  13110. if item.ChrgitmLv == "3" {
  13111. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13112. }
  13113. }
  13114. if item.MedChrgitmType == "05" { //治疗费
  13115. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13116. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13117. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13118. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13119. if item.ChrgitmLv == "1" {
  13120. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13121. }
  13122. if item.ChrgitmLv == "2" {
  13123. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13124. }
  13125. if item.ChrgitmLv == "3" {
  13126. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13127. }
  13128. }
  13129. if item.MedChrgitmType == "06" { //手术费
  13130. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13131. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13132. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13133. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13134. if item.ChrgitmLv == "1" {
  13135. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13136. }
  13137. if item.ChrgitmLv == "2" {
  13138. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13139. }
  13140. if item.ChrgitmLv == "3" {
  13141. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13142. }
  13143. }
  13144. if item.MedChrgitmType == "08" { //材料费
  13145. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13146. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13147. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13148. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13149. if item.ChrgitmLv == "1" {
  13150. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13151. }
  13152. if item.ChrgitmLv == "2" {
  13153. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13154. }
  13155. if item.ChrgitmLv == "3" {
  13156. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13157. }
  13158. }
  13159. if item.MedChrgitmType == "09" { //西药费
  13160. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13161. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13162. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13163. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13164. if item.ChrgitmLv == "1" {
  13165. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13166. }
  13167. if item.ChrgitmLv == "2" {
  13168. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13169. }
  13170. if item.ChrgitmLv == "3" {
  13171. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13172. }
  13173. }
  13174. if item.MedChrgitmType == "11" { //中成费
  13175. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13176. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13177. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13178. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13179. if item.ChrgitmLv == "1" {
  13180. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13181. }
  13182. if item.ChrgitmLv == "2" {
  13183. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13184. }
  13185. if item.ChrgitmLv == "3" {
  13186. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13187. }
  13188. }
  13189. if item.MedChrgitmType == "14" { //其他费
  13190. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13191. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13192. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13193. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13194. if item.ChrgitmLv == "1" {
  13195. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13196. }
  13197. if item.ChrgitmLv == "2" {
  13198. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13199. }
  13200. if item.ChrgitmLv == "3" {
  13201. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13202. }
  13203. }
  13204. }
  13205. var iteminfoStructs []service.IteminfoStruct
  13206. if bedCostTotal != 0 {
  13207. iteminfo.MedChrgitm = "01"
  13208. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13209. iteminfo.Amt = bedCostTotal
  13210. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13211. iteminfo.ClabAmt = bed_clab_amt
  13212. iteminfo.OthAmt = bed_other_amt
  13213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13214. }
  13215. if checkCostTotal != 0 {
  13216. iteminfo.MedChrgitm = "03"
  13217. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13218. iteminfo.Amt = checkCostTotal
  13219. iteminfo.ClaaSumfee = check_claa_sunmfee
  13220. iteminfo.ClabAmt = check_clab_amt
  13221. iteminfo.OthAmt = check_other_amt
  13222. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13223. }
  13224. if laboratoryCostTotal != 0 {
  13225. iteminfo.MedChrgitm = "04"
  13226. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13227. iteminfo.Amt = laboratoryCostTotal
  13228. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13229. iteminfo.ClabAmt = laboratory_clab_amt
  13230. iteminfo.OthAmt = laboratory_other_amt
  13231. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13232. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13233. }
  13234. if treatCostTotal != 0 {
  13235. iteminfo.MedChrgitm = "05"
  13236. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13237. iteminfo.Amt = treatCostTotal
  13238. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13239. iteminfo.ClabAmt = treat_clab_amt
  13240. iteminfo.OthAmt = treat_other_amt
  13241. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13242. //(struct4101.IteminfoStruct, iteminfo)
  13243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13244. }
  13245. if operationCostTotal != 0 {
  13246. iteminfo.MedChrgitm = "06"
  13247. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13248. iteminfo.Amt = operationCostTotal
  13249. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13250. iteminfo.ClabAmt = operation_clab_amt
  13251. iteminfo.OthAmt = operation_other_amt
  13252. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13254. }
  13255. if materialCostTotal != 0 {
  13256. iteminfo.MedChrgitm = "08"
  13257. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13258. iteminfo.Amt = materialCostTotal
  13259. iteminfo.ClaaSumfee = material_claa_sunmfee
  13260. iteminfo.ClabAmt = material_clab_amt
  13261. iteminfo.OthAmt = material_other_amt
  13262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13264. }
  13265. if westernMedicineCostTotal != 0 {
  13266. iteminfo.MedChrgitm = "09"
  13267. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13268. iteminfo.Amt = westernMedicineCostTotal
  13269. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13270. iteminfo.ClabAmt = westernMedicine_clab_amt
  13271. iteminfo.OthAmt = westernMedicine_other_amt
  13272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13274. }
  13275. if chineseTraditionalMedicineCostTotal != 0 {
  13276. iteminfo.MedChrgitm = "11"
  13277. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13278. iteminfo.Amt = westernMedicineCostTotal
  13279. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13280. iteminfo.ClabAmt = westernMedicine_clab_amt
  13281. iteminfo.OthAmt = westernMedicine_other_amt
  13282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13284. }
  13285. if otherCostTotal != 0 {
  13286. iteminfo.MedChrgitm = "14"
  13287. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13288. iteminfo.Amt = otherCostTotal
  13289. iteminfo.ClaaSumfee = other_claa_sunmfee
  13290. iteminfo.ClabAmt = other_clab_amt
  13291. iteminfo.OthAmt = other_other_amt
  13292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13294. }
  13295. struct4101.IteminfoStruct = iteminfoStructs
  13296. struct4101.Ntly = "中国"
  13297. struct4101.AdmCaty = "A03.06"
  13298. struct4101.DoctorName = doctor.UserName
  13299. struct4101.DoctorCode = doctor.DoctorNumber
  13300. var res ResultSeventeen
  13301. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13302. struct4101.BillCode = order.Number
  13303. struct4101.BillNo = order.SetlId
  13304. var resOther ResultSeventeenOther
  13305. var pp models.PublicParams
  13306. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13307. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13308. pp.FixmedinsName = miConfig.OrgName
  13309. pp.FixmedinsCode = miConfig.Code
  13310. pp.RequestUrl = miConfig.Url
  13311. pp.Cainfo = miConfig.Cainfo
  13312. pp.SecretKey = miConfig.SecretKey
  13313. pp.AccessKey = miConfig.AccessKey
  13314. pp.OpterName = curRoles.UserName
  13315. client := &http.Client{}
  13316. var req *http.Request
  13317. data := make(map[string]interface{})
  13318. data["struct4101"] = struct4101
  13319. data["pp"] = pp
  13320. bytesData, _ := json.Marshal(data)
  13321. if miConfig.MdtrtareaAdmvs == "320921" {
  13322. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13323. } else {
  13324. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  13325. }
  13326. resp, _ := client.Do(req)
  13327. defer resp.Body.Close()
  13328. body, ioErr := ioutil.ReadAll(resp.Body)
  13329. if ioErr != nil {
  13330. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13332. return
  13333. }
  13334. var respJSON map[string]interface{}
  13335. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13336. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13338. return
  13339. }
  13340. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  13341. userJSONBytes, _ := json.Marshal(respJSON)
  13342. fmt.Println("log")
  13343. fmt.Println(string(userJSONBytes))
  13344. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13345. utils.ErrorLog("解析失败:%v", err)
  13346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13347. return
  13348. }
  13349. res.InfRefmsgid = resOther.InfRefmsgid
  13350. res.Output = resOther.Output
  13351. res.ErrMsg = resOther.ErrMsg
  13352. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13353. res.Infcode = infocode
  13354. } else if miConfig.MdtrtareaAdmvs == "360302" {
  13355. var pp models.PublicParams
  13356. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13357. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13358. pp.FixmedinsName = miConfig.OrgName
  13359. pp.FixmedinsCode = miConfig.Code
  13360. pp.RequestUrl = miConfig.Url
  13361. pp.Cainfo = miConfig.Cainfo
  13362. pp.SecretKey = miConfig.SecretKey
  13363. pp.AccessKey = miConfig.AccessKey
  13364. pp.OpterName = curRoles.UserName
  13365. result, _ := service.Jxyb4101(struct4101, pp)
  13366. var dat map[string]interface{}
  13367. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13368. fmt.Println(dat)
  13369. } else {
  13370. fmt.Println(err)
  13371. }
  13372. userJSONBytes, _ := json.Marshal(dat)
  13373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13374. utils.ErrorLog("解析失败:%v", err)
  13375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13376. return
  13377. }
  13378. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13379. var pp models.PublicParams
  13380. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13381. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13382. pp.FixmedinsName = miConfig.OrgName
  13383. pp.FixmedinsCode = miConfig.Code
  13384. pp.RequestUrl = miConfig.Url
  13385. pp.Cainfo = miConfig.Cainfo
  13386. pp.SecretKey = miConfig.SecretKey
  13387. pp.AccessKey = miConfig.AccessKey
  13388. pp.OpterName = curRoles.UserName
  13389. result, _ := service.Hnyb4101(struct4101, pp)
  13390. var dat map[string]interface{}
  13391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13392. fmt.Println(dat)
  13393. } else {
  13394. fmt.Println(err)
  13395. }
  13396. userJSONBytes, _ := json.Marshal(dat)
  13397. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13398. utils.ErrorLog("解析失败:%v", err)
  13399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13400. return
  13401. }
  13402. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13403. var resOther ResultSeventeenOther
  13404. var pp models.PublicParams
  13405. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13406. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13407. pp.FixmedinsName = miConfig.OrgName
  13408. pp.FixmedinsCode = miConfig.Code
  13409. pp.RequestUrl = miConfig.Url
  13410. pp.Cainfo = miConfig.Cainfo
  13411. pp.SecretKey = miConfig.SecretKey
  13412. pp.AccessKey = miConfig.AccessKey
  13413. pp.OpterName = curRoles.UserName
  13414. client := &http.Client{}
  13415. var req *http.Request
  13416. data := make(map[string]interface{})
  13417. data["struct4101"] = struct4101
  13418. data["pp"] = pp
  13419. bytesData, _ := json.Marshal(data)
  13420. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  13421. resp, _ := client.Do(req)
  13422. defer resp.Body.Close()
  13423. body, ioErr := ioutil.ReadAll(resp.Body)
  13424. if ioErr != nil {
  13425. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13427. return
  13428. }
  13429. var respJSON map[string]interface{}
  13430. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13433. return
  13434. }
  13435. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13436. userJSONBytes, _ := json.Marshal(respJSON)
  13437. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  13438. utils.ErrorLog("解析失败:%v", err)
  13439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13440. return
  13441. }
  13442. res.InfRefmsgid = resOther.InfRefmsgid
  13443. res.Output = resOther.Output
  13444. res.ErrMsg = resOther.ErrMsg
  13445. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  13446. res.Infcode = infocode
  13447. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13448. var pp models.PublicParams
  13449. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13450. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13451. pp.FixmedinsName = miConfig.OrgName
  13452. pp.FixmedinsCode = miConfig.Code
  13453. pp.RequestUrl = miConfig.Url
  13454. pp.Cainfo = miConfig.Cainfo
  13455. pp.SecretKey = miConfig.SecretKey
  13456. pp.AccessKey = miConfig.AccessKey
  13457. pp.OpterName = curRoles.UserName
  13458. result, requestLog, errMsgLog := service.Fjyb4101(struct4101, pp)
  13459. fmt.Println(requestLog)
  13460. fmt.Println(errMsgLog)
  13461. saveLog(result, requestLog, "4101a", "上传清单")
  13462. var dat map[string]interface{}
  13463. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13464. fmt.Println(dat)
  13465. } else {
  13466. fmt.Println(err)
  13467. }
  13468. userJSONBytes, _ := json.Marshal(dat)
  13469. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13470. utils.ErrorLog("解析失败:%v", err)
  13471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13472. return
  13473. }
  13474. } else if miConfig.MdtrtareaAdmvs == "441799" {
  13475. var pp models.PublicParams
  13476. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13477. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13478. pp.FixmedinsName = miConfig.OrgName
  13479. pp.FixmedinsCode = miConfig.Code
  13480. pp.RequestUrl = miConfig.Url
  13481. pp.Cainfo = miConfig.Cainfo
  13482. pp.SecretKey = miConfig.SecretKey
  13483. pp.AccessKey = miConfig.AccessKey
  13484. pp.OpterName = curRoles.UserName
  13485. client := &http.Client{}
  13486. var req *http.Request
  13487. data := make(map[string]interface{})
  13488. data["struct4101"] = struct4101
  13489. data["pp"] = pp
  13490. bytesData, _ := json.Marshal(data)
  13491. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/4101", bytes.NewReader(bytesData))
  13492. resp, _ := client.Do(req)
  13493. defer resp.Body.Close()
  13494. body, ioErr := ioutil.ReadAll(resp.Body)
  13495. if ioErr != nil {
  13496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13498. return
  13499. }
  13500. var respJSON map[string]interface{}
  13501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  13502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13504. return
  13505. }
  13506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13507. userJSONBytes, _ := json.Marshal(respJSON)
  13508. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13509. utils.ErrorLog("解析失败:%v", err)
  13510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13511. return
  13512. }
  13513. } else {
  13514. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  13515. var dat map[string]interface{}
  13516. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13517. fmt.Println(dat)
  13518. } else {
  13519. fmt.Println(err)
  13520. }
  13521. userJSONBytes, _ := json.Marshal(dat)
  13522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13523. utils.ErrorLog("解析失败:%v", err)
  13524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13525. return
  13526. }
  13527. }
  13528. if res.Infcode != 0 {
  13529. c.ServeSuccessJSON(map[string]interface{}{
  13530. "failed_code": -10,
  13531. "msg": res.ErrMsg,
  13532. })
  13533. return
  13534. } else {
  13535. //order.FaPiaoNumber = zero
  13536. //order.FaPiaoCode = last_order.FaPiaoCode
  13537. //service.UpdateOrder(order)
  13538. hisFundSettleListResult := &models.HisFundSettleListResult{
  13539. Number: res.Output.SetlListId,
  13540. Status: 1,
  13541. Ctime: time.Now().Unix(),
  13542. Mtime: time.Now().Unix(),
  13543. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  13544. IsUpload: 1,
  13545. OrderId: order_id,
  13546. }
  13547. service.CreateUploadRecord(hisFundSettleListResult)
  13548. c.ServeSuccessJSON(map[string]interface{}{
  13549. "msg": "上传成功",
  13550. "result": hisFundSettleListResult,
  13551. })
  13552. return
  13553. }
  13554. }
  13555. func (c *HisApiController) GetSettleListHospital() {
  13556. order_id, _ := c.GetInt64("order_id")
  13557. admin_user_id, _ := c.GetInt64("admin_user_id")
  13558. order, _ := service.GetHisOrderByIDTwo(order_id)
  13559. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  13560. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13561. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  13562. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  13563. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  13564. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  13565. if order.ID == 0 {
  13566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  13567. return
  13568. }
  13569. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  13570. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  13571. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  13572. fmt.Println(count)
  13573. var zero string
  13574. number := count + 1
  13575. if number >= 1000 {
  13576. zero = "0000" + strconv.FormatInt(number, 10)
  13577. } else if number >= 10000 {
  13578. zero = "000" + strconv.FormatInt(number, 10)
  13579. } else if number >= 100000 {
  13580. zero = "00" + strconv.FormatInt(number, 10)
  13581. } else if number >= 1000000 {
  13582. zero = "0" + strconv.FormatInt(number, 10)
  13583. } else {
  13584. zero = strconv.FormatInt(number, 10)
  13585. }
  13586. fmt.Println(zero)
  13587. struct4101 := service.Struct4101{
  13588. PsnNo: order.PsnNo,
  13589. MdtrtId: order.MdtrtId,
  13590. SetlId: order.SetlId,
  13591. PsnName: order.PsnName,
  13592. Gend: order.Gend,
  13593. Brdy: his.Brdy,
  13594. Age: int64(order.Age),
  13595. Naty: order.Naty,
  13596. PatnCertType: "01",
  13597. Certno: order.Certno,
  13598. Prfs: "90",
  13599. ConerName: roles[0].UserName,
  13600. PatnRlts: "99",
  13601. ConerAddr: miConfig.OrgName,
  13602. ConerTel: admin.Mobile,
  13603. HiType: order.Insutype,
  13604. Insuplc: miConfig.InsuplcAdmdvs,
  13605. MaindiagFlag: "1",
  13606. BillCode: order.SetlId,
  13607. BillNo: order.SetlId,
  13608. BizSn: order.Number,
  13609. PsnSelfPay: order.PsnPartAmt,
  13610. PsnOwnPay: order.PsnPartAmt,
  13611. AcctPay: order.AcctPay,
  13612. PsnCashpay: order.PsnCashPay,
  13613. HiPaymtd: "1",
  13614. Hsorg: miConfig.InsuplcAdmdvs,
  13615. HsorgOpter: miConfig.InsuplcAdmdvs,
  13616. MedinsFillPsn: curRoles.UserName,
  13617. MedinsFillDept: depart.Name,
  13618. IptMedType: "2",
  13619. AdmTime: his.InHosptialTime,
  13620. AdmEndTime: his.OutHosptialTime,
  13621. }
  13622. struct4101.SetlBegnDate = order.SetlTime
  13623. struct4101.SetlEndDate = order.SetlTime
  13624. //var rf []CustomFundPay
  13625. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  13626. //
  13627. //var tempFunPays []service.CustomStruct
  13628. //for _, item := range rf {
  13629. // var tempFunPay service.CustomStruct
  13630. // tempFunPay.FundPayamt = item.FundPayamt
  13631. // tempFunPay.FundPayType = item.FundPayType
  13632. // tempFunPays = append(tempFunPays, tempFunPay)
  13633. //}
  13634. //struct4101.CustomStruct = tempFunPays
  13635. var tempDiaginfos []service.DiaginfoStructTwo
  13636. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  13637. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  13638. //infos, _ := service.FindLastPatientPrescriptionInfoTwo2(c.GetAdminUserInfo().CurrentOrgId, his.PatientId, strings.Split(his.InHosptialTime, " ")[0], strings.Split(his.OutHosptialTime, " ")[0])
  13639. //for _, item := range infos {
  13640. // his.Diagnosis = his.Diagnosis + "," + item.Diagnosis
  13641. //}
  13642. diagnosis_ids_arr := strings.Split(his.Diagnosis, ",")
  13643. diagnosis_ids_arr = RemoveRepeatedPurviewElement2(diagnosis_ids_arr)
  13644. //diagnosis_ids := strings.Split(his.Diagnosis, ",")
  13645. fmt.Println(diagnosis_ids_arr)
  13646. if order.UserOrgId == 10210 {
  13647. var diagnosis_ids_arr_two []int64
  13648. diagnosis_ids_arr_two = append(diagnosis_ids_arr_two, 704)
  13649. var config []*models.HisXtDiagnoseConfig
  13650. for _, id := range diagnosis_ids_arr_two {
  13651. //id, _ := strconv.ParseInt(item, 10, 64)
  13652. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13653. if diagnosisConfig.ID > 0 {
  13654. config = append(config, &diagnosisConfig)
  13655. }
  13656. }
  13657. for index, item := range config {
  13658. if item.ID > 0 {
  13659. if index == 0 {
  13660. var tempDiaginfo service.DiaginfoStructTwo
  13661. tempDiaginfo.DiagCode = item.CountryCode
  13662. tempDiaginfo.DiagName = item.CountryContentName
  13663. tempDiaginfo.DiagType = "1"
  13664. tempDiaginfo.MaindiagFlag = "1"
  13665. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13666. } else {
  13667. var tempDiaginfo service.DiaginfoStructTwo
  13668. tempDiaginfo.DiagCode = item.CountryCode
  13669. tempDiaginfo.DiagName = item.CountryContentName
  13670. tempDiaginfo.DiagType = "1"
  13671. tempDiaginfo.MaindiagFlag = "0"
  13672. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13673. }
  13674. }
  13675. }
  13676. struct4101.Diseinfo = tempDiaginfos
  13677. } else {
  13678. var config []*models.HisXtDiagnoseConfig
  13679. for _, item := range diagnosis_ids_arr {
  13680. id, _ := strconv.ParseInt(item, 10, 64)
  13681. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13682. if diagnosisConfig.ID > 0 {
  13683. config = append(config, &diagnosisConfig)
  13684. }
  13685. }
  13686. for index, item := range config {
  13687. if item.ID > 0 {
  13688. if index == 0 {
  13689. var tempDiaginfo service.DiaginfoStructTwo
  13690. tempDiaginfo.DiagCode = item.CountryCode
  13691. tempDiaginfo.DiagName = item.CountryContentName
  13692. tempDiaginfo.DiagType = "1"
  13693. tempDiaginfo.MaindiagFlag = "1"
  13694. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13695. } else {
  13696. var tempDiaginfo service.DiaginfoStructTwo
  13697. tempDiaginfo.DiagCode = item.CountryCode
  13698. tempDiaginfo.DiagName = item.CountryContentName
  13699. tempDiaginfo.DiagType = "1"
  13700. tempDiaginfo.MaindiagFlag = "0"
  13701. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  13702. }
  13703. }
  13704. }
  13705. struct4101.Diseinfo = tempDiaginfos
  13706. }
  13707. sickConfigTwo, _ := service.FindSickById(his.SickType)
  13708. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  13709. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  13710. tempOpspdiseinfo2.OprnOprtCode = ""
  13711. tempOpspdiseinfo2.OprnOprtName = ""
  13712. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  13713. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  13714. var iteminfo service.IteminfoStruct
  13715. var bedCostTotal float64 = 0 //床位总费
  13716. var bedCostSelfTotal float64 = 0 //床位自费
  13717. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13718. var operationCostTotal float64 = 0 //手术费
  13719. var operationCostSelfTotal float64 = 0 //手术费
  13720. var operationCostPartSelfTotal float64 = 0 //手术费
  13721. var otherCostTotal float64 = 0 //其他费用
  13722. var otherCostSelfTotal float64 = 0 //其他费用
  13723. var otherCostPartSelfTotal float64 = 0 //其他费用
  13724. var materialCostTotal float64 = 0 //材料费
  13725. var materialCostSelfTotal float64 = 0 //材料费
  13726. var materialCostPartSelfTotal float64 = 0 //材料费
  13727. var westernMedicineCostTotal float64 = 0 //西药费
  13728. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13729. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13730. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13731. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13732. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13733. var checkCostTotal float64 = 0 //检查费
  13734. var checkCostSelfTotal float64 = 0 //检查费
  13735. var checkCostPartSelfTotal float64 = 0 //检查费
  13736. var laboratoryCostTotal float64 = 0 //化验费
  13737. var laboratoryCostSelfTotal float64 = 0 //化验费
  13738. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13739. var treatCostTotal float64 = 0 //治疗费用
  13740. var treatCostSelfTotal float64 = 0 //治疗费用
  13741. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13742. decimal.DivisionPrecision = 2
  13743. var bed_fulamt_ownpay_amt float64 = 0
  13744. var operation_fulamt_ownpay_amt float64 = 0
  13745. var other_fulamt_ownpay_amt float64 = 0
  13746. var westernMedicine_fulamt_ownpay_amt float64 = 0
  13747. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  13748. var check_fulamt_ownpay_amt float64 = 0
  13749. var material_fulamt_ownpay_amt float64 = 0
  13750. var laboratory_fulamt_ownpay_amt float64 = 0
  13751. var treat_fulamt_ownpay_amt float64 = 0
  13752. var bed_claa_sunmfee float64 = 0
  13753. var bed_clab_amt float64 = 0
  13754. var bed_other_amt float64 = 0
  13755. var operation_claa_sunmfee float64 = 0
  13756. var operation_clab_amt float64 = 0
  13757. var operation_other_amt float64 = 0
  13758. var other_claa_sunmfee float64 = 0
  13759. var other_clab_amt float64 = 0
  13760. var other_other_amt float64 = 0
  13761. var westernMedicine_claa_sunmfee float64 = 0
  13762. var westernMedicine_clab_amt float64 = 0
  13763. var westernMedicine_other_amt float64 = 0
  13764. var chineseTraditional_claa_sunmfee float64 = 0
  13765. var chineseTraditional_clab_amt float64 = 0
  13766. var chineseTraditional_other_amt float64 = 0
  13767. var check_claa_sunmfee float64 = 0
  13768. var check_clab_amt float64 = 0
  13769. var check_other_amt float64 = 0
  13770. var material_claa_sunmfee float64 = 0
  13771. var material_clab_amt float64 = 0
  13772. var material_other_amt float64 = 0
  13773. var laboratory_claa_sunmfee float64 = 0
  13774. var laboratory_clab_amt float64 = 0
  13775. var laboratory_other_amt float64 = 0
  13776. var treat_claa_sunmfee float64 = 0
  13777. var treat_clab_amt float64 = 0
  13778. var treat_other_amt float64 = 0
  13779. for _, item := range order.HisOrderInfo {
  13780. if item.MedChrgitmType == "01" { //床位费
  13781. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13782. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13783. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13784. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13785. if item.ChrgitmLv == "1" {
  13786. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13787. }
  13788. if item.ChrgitmLv == "2" {
  13789. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13790. }
  13791. if item.ChrgitmLv == "3" {
  13792. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13793. }
  13794. }
  13795. if item.MedChrgitmType == "03" { //检查费
  13796. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13797. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13798. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13799. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13800. if item.ChrgitmLv == "1" {
  13801. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13802. }
  13803. if item.ChrgitmLv == "2" {
  13804. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13805. }
  13806. if item.ChrgitmLv == "3" {
  13807. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13808. }
  13809. }
  13810. if item.MedChrgitmType == "04" { //化验费
  13811. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13812. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13813. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13814. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13815. if item.ChrgitmLv == "1" {
  13816. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13817. }
  13818. if item.ChrgitmLv == "2" {
  13819. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13820. }
  13821. if item.ChrgitmLv == "3" {
  13822. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13823. }
  13824. }
  13825. if item.MedChrgitmType == "05" { //治疗费
  13826. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13827. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13828. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13829. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13830. if item.ChrgitmLv == "1" {
  13831. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13832. }
  13833. if item.ChrgitmLv == "2" {
  13834. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13835. }
  13836. if item.ChrgitmLv == "3" {
  13837. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13838. }
  13839. }
  13840. if item.MedChrgitmType == "06" { //手术费
  13841. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13842. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13843. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13844. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13845. if item.ChrgitmLv == "1" {
  13846. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13847. }
  13848. if item.ChrgitmLv == "2" {
  13849. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13850. }
  13851. if item.ChrgitmLv == "3" {
  13852. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13853. }
  13854. }
  13855. if item.MedChrgitmType == "08" { //材料费
  13856. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13857. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13858. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13859. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13860. if item.ChrgitmLv == "1" {
  13861. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13862. }
  13863. if item.ChrgitmLv == "2" {
  13864. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13865. }
  13866. if item.ChrgitmLv == "3" {
  13867. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13868. }
  13869. }
  13870. if item.MedChrgitmType == "09" { //西药费
  13871. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13872. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13873. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13874. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13875. if item.ChrgitmLv == "1" {
  13876. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13877. }
  13878. if item.ChrgitmLv == "2" {
  13879. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13880. }
  13881. if item.ChrgitmLv == "3" {
  13882. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13883. }
  13884. }
  13885. if item.MedChrgitmType == "11" { //中成费
  13886. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13887. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13888. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13889. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13890. if item.ChrgitmLv == "1" {
  13891. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13892. }
  13893. if item.ChrgitmLv == "2" {
  13894. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13895. }
  13896. if item.ChrgitmLv == "3" {
  13897. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13898. }
  13899. }
  13900. if item.MedChrgitmType == "14" { //其他费
  13901. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13902. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13903. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13904. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13905. if item.ChrgitmLv == "1" {
  13906. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13907. }
  13908. if item.ChrgitmLv == "2" {
  13909. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13910. }
  13911. if item.ChrgitmLv == "3" {
  13912. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13913. }
  13914. }
  13915. }
  13916. var iteminfoStructs []service.IteminfoStruct
  13917. if bedCostTotal != 0 {
  13918. iteminfo.MedChrgitm = "01"
  13919. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13920. iteminfo.Amt = bedCostTotal
  13921. iteminfo.ClaaSumfee = bed_claa_sunmfee
  13922. iteminfo.ClabAmt = bed_clab_amt
  13923. iteminfo.OthAmt = bed_other_amt
  13924. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13925. }
  13926. if checkCostTotal != 0 {
  13927. iteminfo.MedChrgitm = "03"
  13928. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  13929. iteminfo.Amt = checkCostTotal
  13930. iteminfo.ClaaSumfee = check_claa_sunmfee
  13931. iteminfo.ClabAmt = check_clab_amt
  13932. iteminfo.OthAmt = check_other_amt
  13933. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13934. }
  13935. if laboratoryCostTotal != 0 {
  13936. iteminfo.MedChrgitm = "04"
  13937. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  13938. iteminfo.Amt = laboratoryCostTotal
  13939. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  13940. iteminfo.ClabAmt = laboratory_clab_amt
  13941. iteminfo.OthAmt = laboratory_other_amt
  13942. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13943. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13944. }
  13945. if treatCostTotal != 0 {
  13946. iteminfo.MedChrgitm = "05"
  13947. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  13948. iteminfo.Amt = treatCostTotal
  13949. iteminfo.ClaaSumfee = treat_claa_sunmfee
  13950. iteminfo.ClabAmt = treat_clab_amt
  13951. iteminfo.OthAmt = treat_other_amt
  13952. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13953. //(struct4101.IteminfoStruct, iteminfo)
  13954. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13955. }
  13956. if operationCostTotal != 0 {
  13957. iteminfo.MedChrgitm = "06"
  13958. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  13959. iteminfo.Amt = operationCostTotal
  13960. iteminfo.ClaaSumfee = operation_claa_sunmfee
  13961. iteminfo.ClabAmt = operation_clab_amt
  13962. iteminfo.OthAmt = operation_other_amt
  13963. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13964. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13965. }
  13966. if materialCostTotal != 0 {
  13967. iteminfo.MedChrgitm = "08"
  13968. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  13969. iteminfo.Amt = materialCostTotal
  13970. iteminfo.ClaaSumfee = material_claa_sunmfee
  13971. iteminfo.ClabAmt = material_clab_amt
  13972. iteminfo.OthAmt = material_other_amt
  13973. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13974. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13975. }
  13976. if westernMedicineCostTotal != 0 {
  13977. iteminfo.MedChrgitm = "09"
  13978. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13979. iteminfo.Amt = westernMedicineCostTotal
  13980. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13981. iteminfo.ClabAmt = westernMedicine_clab_amt
  13982. iteminfo.OthAmt = westernMedicine_other_amt
  13983. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13984. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13985. }
  13986. if chineseTraditionalMedicineCostTotal != 0 {
  13987. iteminfo.MedChrgitm = "11"
  13988. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  13989. iteminfo.Amt = westernMedicineCostTotal
  13990. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  13991. iteminfo.ClabAmt = westernMedicine_clab_amt
  13992. iteminfo.OthAmt = westernMedicine_other_amt
  13993. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  13994. iteminfoStructs = append(iteminfoStructs, iteminfo)
  13995. }
  13996. if otherCostTotal != 0 {
  13997. iteminfo.MedChrgitm = "14"
  13998. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  13999. iteminfo.Amt = otherCostTotal
  14000. iteminfo.ClaaSumfee = other_claa_sunmfee
  14001. iteminfo.ClabAmt = other_clab_amt
  14002. iteminfo.OthAmt = other_other_amt
  14003. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14004. iteminfoStructs = append(iteminfoStructs, iteminfo)
  14005. }
  14006. struct4101.IteminfoStruct = iteminfoStructs
  14007. struct4101.Ntly = "中国"
  14008. struct4101.AdmCaty = "A03.06"
  14009. var resOther ResultSeventeenOther
  14010. var res ResultSeventeen
  14011. if miConfig.MdtrtareaAdmvs == "150499" {
  14012. var pp models.PublicParams
  14013. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14014. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14015. pp.FixmedinsName = miConfig.OrgName
  14016. pp.FixmedinsCode = miConfig.Code
  14017. pp.RequestUrl = miConfig.Url
  14018. pp.Cainfo = miConfig.Cainfo
  14019. pp.SecretKey = miConfig.SecretKey
  14020. pp.AccessKey = miConfig.AccessKey
  14021. pp.OpterName = curRoles.UserName
  14022. client := &http.Client{}
  14023. var req *http.Request
  14024. data := make(map[string]interface{})
  14025. data["struct4101"] = struct4101
  14026. data["pp"] = pp
  14027. bytesData, _ := json.Marshal(data)
  14028. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  14029. resp, _ := client.Do(req)
  14030. defer resp.Body.Close()
  14031. body, ioErr := ioutil.ReadAll(resp.Body)
  14032. if ioErr != nil {
  14033. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14035. return
  14036. }
  14037. var respJSON map[string]interface{}
  14038. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14039. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14041. return
  14042. }
  14043. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14044. userJSONBytes, _ := json.Marshal(respJSON)
  14045. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  14046. utils.ErrorLog("解析失败:%v", err)
  14047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14048. return
  14049. }
  14050. res.InfRefmsgid = resOther.InfRefmsgid
  14051. res.Output = resOther.Output
  14052. res.ErrMsg = resOther.ErrMsg
  14053. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  14054. res.Infcode = infocode
  14055. } else if miConfig.MdtrtareaAdmvs == "360302" {
  14056. var pp models.PublicParams
  14057. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  14058. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  14059. pp.FixmedinsName = miConfig.OrgName
  14060. pp.FixmedinsCode = miConfig.Code
  14061. pp.RequestUrl = miConfig.Url
  14062. pp.Cainfo = miConfig.Cainfo
  14063. pp.SecretKey = miConfig.SecretKey
  14064. pp.AccessKey = miConfig.AccessKey
  14065. pp.OpterName = curRoles.UserName
  14066. result, _ := service.Jxyb4101(struct4101, pp)
  14067. var dat map[string]interface{}
  14068. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14069. fmt.Println(dat)
  14070. } else {
  14071. fmt.Println(err)
  14072. }
  14073. userJSONBytes, _ := json.Marshal(dat)
  14074. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14075. utils.ErrorLog("解析失败:%v", err)
  14076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14077. return
  14078. }
  14079. } else {
  14080. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId, admin_user_id)
  14081. var dat map[string]interface{}
  14082. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14083. fmt.Println(dat)
  14084. } else {
  14085. fmt.Println(err)
  14086. }
  14087. userJSONBytes, _ := json.Marshal(dat)
  14088. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14089. utils.ErrorLog("解析失败:%v", err)
  14090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14091. return
  14092. }
  14093. }
  14094. if res.Infcode != 0 {
  14095. c.ServeSuccessJSON(map[string]interface{}{
  14096. "failed_code": -10,
  14097. "msg": res.ErrMsg,
  14098. })
  14099. return
  14100. } else {
  14101. if miConfig.MdtrtareaAdmvs != "150499" {
  14102. order.FaPiaoNumber = zero
  14103. order.FaPiaoCode = last_order.FaPiaoCode
  14104. service.UpdateOrder(order)
  14105. }
  14106. hisFundSettleListResult := &models.HisFundSettleListResult{
  14107. Number: res.Output.SetlListId,
  14108. Status: 1,
  14109. Ctime: time.Now().Unix(),
  14110. Mtime: time.Now().Unix(),
  14111. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14112. IsUpload: 1,
  14113. OrderId: order_id,
  14114. }
  14115. service.CreateUploadRecord(hisFundSettleListResult)
  14116. c.ServeSuccessJSON(map[string]interface{}{
  14117. "msg": "上传成功",
  14118. "result": hisFundSettleListResult,
  14119. })
  14120. return
  14121. }
  14122. }
  14123. //func (c *HisApiController) GetBatchSettleList() {
  14124. // orders, _ := service.GetAllHisOrder(10106)
  14125. // for _, item := range orders {
  14126. // order_id := item.ID
  14127. // order, _ := service.GetHisOrderByIDTwo(order_id)
  14128. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  14129. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14130. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  14131. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  14132. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  14133. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  14134. //
  14135. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  14136. //
  14137. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  14138. //
  14139. // if order.ID == 0 {
  14140. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  14141. // return
  14142. // }
  14143. // if his.BalanceAccountsType == 2 {
  14144. // continue
  14145. // }
  14146. // struct4101 := service.Struct4101{
  14147. // PsnNo: order.PsnNo,
  14148. // MdtrtId: order.MdtrtId,
  14149. // SetlId: order.SetlId,
  14150. // PsnName: order.PsnName,
  14151. // Gend: order.Gend,
  14152. // Brdy: his.Brdy,
  14153. // Age: his.Age,
  14154. // Naty: order.Naty,
  14155. // PatnCertType: "01",
  14156. // Certno: order.Certno,
  14157. // Prfs: "90",
  14158. // ConerName: roles[0].UserName,
  14159. // PatnRlts: "99",
  14160. // ConerAddr: miConfig.OrgName,
  14161. // ConerTel: admin.Mobile,
  14162. // HiType: order.Insutype,
  14163. // Insuplc: his.InsuplcAdmdvs,
  14164. // MaindiagFlag: "1",
  14165. // BillCode: order.SetlId,
  14166. // BillNo: order.SetlId,
  14167. // BizSn: order.Number,
  14168. // PsnSelfPay: order.PsnPartAmt,
  14169. // PsnOwnPay: order.PsnPartAmt,
  14170. // AcctPay: order.AcctPay,
  14171. // PsnCashpay: order.PsnCashPay,
  14172. // HiPaymtd: "1",
  14173. // Hsorg: his.InsuplcAdmdvs,
  14174. // HsorgOpter: his.InsuplcAdmdvs,
  14175. // MedinsFillPsn: curRoles.UserName,
  14176. // MedinsFillDept: depart.Name,
  14177. // IptMedType: "2",
  14178. // }
  14179. // struct4101.SetlBegnDate = order.SetlTime
  14180. // struct4101.SetlEndDate = order.SetlTime
  14181. // //if order.SettleType == 1 {
  14182. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  14183. // // dateStr := t.Format("2006-01-02")
  14184. // // struct4101.SetlBegnDate = dateStr
  14185. // // struct4101.SetlEndDate = dateStr
  14186. // //} else {
  14187. // // t := time.Unix(int64(order.SettleStartTime), 0)
  14188. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  14189. // // dateStartStr := t.Format("2006-01-02")
  14190. // // dateEndStr := t2.Format("2006-01-02")
  14191. // // struct4101.SetlBegnDate = dateStartStr
  14192. // // struct4101.SetlEndDate = dateEndStr
  14193. // //}
  14194. //
  14195. // var rf []CustomFundPay
  14196. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  14197. //
  14198. // var tempFunPays []service.CustomStruct
  14199. // var tempFunPay610100 service.CustomStruct
  14200. //
  14201. // for _, item := range rf {
  14202. // if item.FundPayType == "610100" {
  14203. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  14204. // tempFunPay610100.FundPayType = item.FundPayType
  14205. // } else {
  14206. // var tempFunPay service.CustomStruct
  14207. // tempFunPay.FundPayamt = item.FundPayamt
  14208. // tempFunPay.FundPayType = item.FundPayType
  14209. // tempFunPays = append(tempFunPays, tempFunPay)
  14210. // }
  14211. // }
  14212. // tempFunPays = append(tempFunPays, tempFunPay610100)
  14213. // struct4101.CustomStruct = tempFunPays
  14214. //
  14215. // var tempDiaginfos []service.DiaginfoStructTwo
  14216. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  14217. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  14218. //
  14219. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  14220. // var config []*models.HisXtDiagnoseConfig
  14221. // for _, item := range diagnosis_ids {
  14222. // id, _ := strconv.ParseInt(item, 10, 64)
  14223. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  14224. // config = append(config, &diagnosisConfig)
  14225. // }
  14226. //
  14227. // for index, item := range config {
  14228. // if index == 0 {
  14229. // var tempDiaginfo service.DiaginfoStructTwo
  14230. // tempDiaginfo.DiagCode = item.CountryCode
  14231. // tempDiaginfo.DiagName = item.CountryContentName
  14232. // tempDiaginfo.DiagType = "1"
  14233. // tempDiaginfo.MaindiagFlag = "1"
  14234. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14235. // } else {
  14236. //
  14237. // var tempDiaginfo service.DiaginfoStructTwo
  14238. // tempDiaginfo.DiagCode = item.CountryCode
  14239. // tempDiaginfo.DiagName = item.CountryContentName
  14240. // tempDiaginfo.DiagType = "2"
  14241. // tempDiaginfo.MaindiagFlag = "0"
  14242. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  14243. // }
  14244. // }
  14245. // struct4101.Diseinfo = tempDiaginfos
  14246. //
  14247. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  14248. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  14249. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  14250. // tempOpspdiseinfo2.OprnOprtCode = ""
  14251. // tempOpspdiseinfo2.OprnOprtName = ""
  14252. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  14253. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  14254. //
  14255. // var iteminfo service.IteminfoStruct
  14256. //
  14257. // var bedCostTotal float64 = 0 //床位总费
  14258. // var bedCostSelfTotal float64 = 0 //床位自费
  14259. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14260. //
  14261. // var examineCostTotal float64 = 0 //诊查总费
  14262. // var examineCostSelfTotal float64 = 0 //诊查自费
  14263. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  14264. //
  14265. // var nursingCostTotal float64 = 0 //护理总费
  14266. // var nursingCostSelfTotal float64 = 0 //护理自费
  14267. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  14268. //
  14269. // var chineseMedicineCostTotal float64 = 0 //中成药
  14270. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  14271. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  14272. //
  14273. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  14274. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  14275. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  14276. //
  14277. // var registerCostTotal float64 = 0 //一般诊疗费
  14278. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  14279. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  14280. //
  14281. // var operationCostTotal float64 = 0 //手术费
  14282. // var operationCostSelfTotal float64 = 0 //手术费
  14283. // var operationCostPartSelfTotal float64 = 0 //手术费
  14284. //
  14285. // var otherCostTotal float64 = 0 //其他费用
  14286. // var otherCostSelfTotal float64 = 0 //其他费用
  14287. // var otherCostPartSelfTotal float64 = 0 //其他费用
  14288. //
  14289. // var materialCostTotal float64 = 0 //材料费
  14290. // var materialCostSelfTotal float64 = 0 //材料费
  14291. // var materialCostPartSelfTotal float64 = 0 //材料费
  14292. //
  14293. // var westernMedicineCostTotal float64 = 0 //西药费
  14294. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  14295. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14296. //
  14297. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14298. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14299. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14300. //
  14301. // var checkCostTotal float64 = 0 //检查费
  14302. // var checkCostSelfTotal float64 = 0 //检查费
  14303. // var checkCostPartSelfTotal float64 = 0 //检查费
  14304. //
  14305. // var laboratoryCostTotal float64 = 0 //化验费
  14306. // var laboratoryCostSelfTotal float64 = 0 //化验费
  14307. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14308. //
  14309. // var treatCostTotal float64 = 0 //治疗费用
  14310. // var treatCostSelfTotal float64 = 0 //治疗费用
  14311. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  14312. //
  14313. // decimal.DivisionPrecision = 2
  14314. //
  14315. // var bed_fulamt_ownpay_amt float64 = 0
  14316. //
  14317. // var examine_fulamt_ownpay_amt float64 = 0
  14318. //
  14319. // var nursing_fulamt_ownpay_amt float64 = 0
  14320. //
  14321. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  14322. //
  14323. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  14324. //
  14325. // var register_fulamt_ownpay_amt float64 = 0
  14326. //
  14327. // var operation_fulamt_ownpay_amt float64 = 0
  14328. // var other_fulamt_ownpay_amt float64 = 0
  14329. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  14330. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  14331. // var check_fulamt_ownpay_amt float64 = 0
  14332. // var material_fulamt_ownpay_amt float64 = 0
  14333. // var laboratory_fulamt_ownpay_amt float64 = 0
  14334. // var treat_fulamt_ownpay_amt float64 = 0
  14335. //
  14336. // var bed_claa_sunmfee float64 = 0
  14337. // var bed_clab_amt float64 = 0
  14338. // var bed_other_amt float64 = 0
  14339. //
  14340. // var examine_claa_sunmfee float64 = 0
  14341. // var examine_clab_amt float64 = 0
  14342. // var examine_other_amt float64 = 0
  14343. //
  14344. // var nursing_claa_sunmfee float64 = 0
  14345. // var nursing_clab_amt float64 = 0
  14346. // var nursing_other_amt float64 = 0
  14347. //
  14348. // var chinese_medicine_claa_sunmfee float64 = 0
  14349. // var chinese_medicine_clab_amt float64 = 0
  14350. // var chinese_medicine_other_amt float64 = 0
  14351. //
  14352. // var commonly_treatment_claa_sunmfee float64 = 0
  14353. // var commonly_treatment_clab_amt float64 = 0
  14354. // var commonly_treatment_other_amt float64 = 0
  14355. //
  14356. // var operation_claa_sunmfee float64 = 0
  14357. // var operation_clab_amt float64 = 0
  14358. // var operation_other_amt float64 = 0
  14359. //
  14360. // var other_claa_sunmfee float64 = 0
  14361. // var other_clab_amt float64 = 0
  14362. // var other_other_amt float64 = 0
  14363. //
  14364. // var westernMedicine_claa_sunmfee float64 = 0
  14365. // var westernMedicine_clab_amt float64 = 0
  14366. // var westernMedicine_other_amt float64 = 0
  14367. //
  14368. // var chineseTraditional_claa_sunmfee float64 = 0
  14369. // var chineseTraditional_clab_amt float64 = 0
  14370. // var chineseTraditional_other_amt float64 = 0
  14371. //
  14372. // var check_claa_sunmfee float64 = 0
  14373. // var check_clab_amt float64 = 0
  14374. // var check_other_amt float64 = 0
  14375. //
  14376. // var material_claa_sunmfee float64 = 0
  14377. // var material_clab_amt float64 = 0
  14378. // var material_other_amt float64 = 0
  14379. //
  14380. // var laboratory_claa_sunmfee float64 = 0
  14381. // var laboratory_clab_amt float64 = 0
  14382. // var laboratory_other_amt float64 = 0
  14383. //
  14384. // var treat_claa_sunmfee float64 = 0
  14385. // var treat_clab_amt float64 = 0
  14386. // var treat_other_amt float64 = 0
  14387. //
  14388. // var register_claa_sunmfee float64 = 0
  14389. // var register_clab_amt float64 = 0
  14390. // var register_other_amt float64 = 0
  14391. //
  14392. // for _, item := range order.HisOrderInfo {
  14393. // if item.MedChrgitmType == "01" { //床位费
  14394. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14395. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14396. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14397. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14398. // if item.ChrgitmLv == "1" {
  14399. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14400. // }
  14401. // if item.ChrgitmLv == "2" {
  14402. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14403. //
  14404. // }
  14405. // if item.ChrgitmLv == "3" {
  14406. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14407. // }
  14408. //
  14409. // }
  14410. //
  14411. // if item.MedChrgitmType == "02" { //诊查
  14412. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14413. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14414. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14415. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14416. // if item.ChrgitmLv == "1" {
  14417. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14418. // }
  14419. // if item.ChrgitmLv == "2" {
  14420. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14421. //
  14422. // }
  14423. // if item.ChrgitmLv == "3" {
  14424. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14425. // }
  14426. //
  14427. // }
  14428. //
  14429. // if item.MedChrgitmType == "03" { //检查费
  14430. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14431. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14432. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14433. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14434. // if item.ChrgitmLv == "1" {
  14435. //
  14436. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14437. //
  14438. // }
  14439. // if item.ChrgitmLv == "2" {
  14440. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14441. //
  14442. // }
  14443. // if item.ChrgitmLv == "3" {
  14444. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14445. // }
  14446. // }
  14447. //
  14448. // if item.MedChrgitmType == "04" { //化验费
  14449. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14450. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14451. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14452. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14453. // if item.ChrgitmLv == "1" {
  14454. //
  14455. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14456. //
  14457. // }
  14458. // if item.ChrgitmLv == "2" {
  14459. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14460. //
  14461. // }
  14462. // if item.ChrgitmLv == "3" {
  14463. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14464. // }
  14465. // }
  14466. //
  14467. // if item.MedChrgitmType == "05" { //治疗费
  14468. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14469. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14470. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14471. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14472. // if item.ChrgitmLv == "1" {
  14473. //
  14474. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14475. //
  14476. // }
  14477. // if item.ChrgitmLv == "2" {
  14478. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14479. //
  14480. // }
  14481. // if item.ChrgitmLv == "3" {
  14482. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14483. // }
  14484. // }
  14485. //
  14486. // if item.MedChrgitmType == "06" { //手术费
  14487. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14488. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14489. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14490. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14491. //
  14492. // if item.ChrgitmLv == "1" {
  14493. //
  14494. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14495. //
  14496. // }
  14497. // if item.ChrgitmLv == "2" {
  14498. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14499. //
  14500. // }
  14501. // if item.ChrgitmLv == "3" {
  14502. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14503. // }
  14504. // }
  14505. //
  14506. // if item.MedChrgitmType == "07" { //手术费
  14507. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14508. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14509. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14510. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14511. //
  14512. // if item.ChrgitmLv == "1" {
  14513. //
  14514. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14515. //
  14516. // }
  14517. // if item.ChrgitmLv == "2" {
  14518. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14519. //
  14520. // }
  14521. // if item.ChrgitmLv == "3" {
  14522. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14523. // }
  14524. // }
  14525. //
  14526. // if item.MedChrgitmType == "08" { //材料费
  14527. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14528. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14529. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14530. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14531. // if item.ChrgitmLv == "1" {
  14532. //
  14533. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14534. //
  14535. // }
  14536. // if item.ChrgitmLv == "2" {
  14537. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14538. //
  14539. // }
  14540. // if item.ChrgitmLv == "3" {
  14541. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14542. // }
  14543. // }
  14544. // if item.MedChrgitmType == "09" { //西药费
  14545. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14546. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14547. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14548. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14549. // if item.ChrgitmLv == "1" {
  14550. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14551. // }
  14552. // if item.ChrgitmLv == "2" {
  14553. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14554. // }
  14555. // if item.ChrgitmLv == "3" {
  14556. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14557. // }
  14558. // }
  14559. // if item.MedChrgitmType == "10" { //中药饮片
  14560. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14561. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14562. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14563. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14564. // if item.ChrgitmLv == "1" {
  14565. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14566. // }
  14567. // if item.ChrgitmLv == "2" {
  14568. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14569. // }
  14570. // if item.ChrgitmLv == "3" {
  14571. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14572. // }
  14573. // }
  14574. //
  14575. // if item.MedChrgitmType == "11" { //中成费
  14576. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14577. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14578. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14579. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14580. // if item.ChrgitmLv == "1" {
  14581. //
  14582. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14583. //
  14584. // }
  14585. // if item.ChrgitmLv == "2" {
  14586. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14587. //
  14588. // }
  14589. // if item.ChrgitmLv == "3" {
  14590. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14591. // }
  14592. // }
  14593. //
  14594. // if item.MedChrgitmType == "12" { //中成费
  14595. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14596. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14597. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14598. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14599. // if item.ChrgitmLv == "1" {
  14600. //
  14601. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14602. //
  14603. // }
  14604. // if item.ChrgitmLv == "2" {
  14605. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14606. //
  14607. // }
  14608. // if item.ChrgitmLv == "3" {
  14609. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14610. // }
  14611. // }
  14612. //
  14613. // if item.MedChrgitmType == "13" { //中成费
  14614. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14615. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14616. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14617. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14618. // if item.ChrgitmLv == "1" {
  14619. //
  14620. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14621. //
  14622. // }
  14623. // if item.ChrgitmLv == "2" {
  14624. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14625. //
  14626. // }
  14627. // if item.ChrgitmLv == "3" {
  14628. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14629. // }
  14630. // }
  14631. //
  14632. // if item.MedChrgitmType == "14" { //其他费
  14633. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14634. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14635. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14636. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14637. // if item.ChrgitmLv == "1" {
  14638. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14639. //
  14640. // }
  14641. // if item.ChrgitmLv == "2" {
  14642. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14643. //
  14644. // }
  14645. // if item.ChrgitmLv == "3" {
  14646. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14647. // }
  14648. // }
  14649. //
  14650. // }
  14651. //
  14652. // var iteminfoStructs []service.IteminfoStruct
  14653. //
  14654. // if bedCostTotal != 0 {
  14655. // iteminfo.MedChrgitm = "01"
  14656. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14657. // iteminfo.Amt = bedCostTotal
  14658. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  14659. // iteminfo.ClabAmt = bed_clab_amt
  14660. // iteminfo.OthAmt = bed_other_amt
  14661. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14662. // }
  14663. //
  14664. // if examineCostTotal != 0 {
  14665. // iteminfo.MedChrgitm = "02"
  14666. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  14667. // iteminfo.Amt = examineCostTotal
  14668. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  14669. // iteminfo.ClabAmt = examine_clab_amt
  14670. // iteminfo.OthAmt = examine_other_amt
  14671. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14672. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14673. // }
  14674. //
  14675. // if checkCostTotal != 0 {
  14676. // iteminfo.MedChrgitm = "03"
  14677. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  14678. // iteminfo.Amt = checkCostTotal
  14679. // iteminfo.ClaaSumfee = check_claa_sunmfee
  14680. // iteminfo.ClabAmt = check_clab_amt
  14681. // iteminfo.OthAmt = check_other_amt
  14682. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14683. //
  14684. // }
  14685. //
  14686. // if laboratoryCostTotal != 0 {
  14687. // iteminfo.MedChrgitm = "04"
  14688. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  14689. // iteminfo.Amt = laboratoryCostTotal
  14690. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  14691. // iteminfo.ClabAmt = laboratory_clab_amt
  14692. // iteminfo.OthAmt = laboratory_other_amt
  14693. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14694. //
  14695. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14696. //
  14697. // }
  14698. //
  14699. // if treatCostTotal != 0 {
  14700. // iteminfo.MedChrgitm = "05"
  14701. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  14702. // iteminfo.Amt = treatCostTotal
  14703. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  14704. // iteminfo.ClabAmt = treat_clab_amt
  14705. // iteminfo.OthAmt = treat_other_amt
  14706. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14707. // //(struct4101.IteminfoStruct, iteminfo)
  14708. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14709. // }
  14710. //
  14711. // if operationCostTotal != 0 {
  14712. // iteminfo.MedChrgitm = "06"
  14713. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  14714. // iteminfo.Amt = operationCostTotal
  14715. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  14716. // iteminfo.ClabAmt = operation_clab_amt
  14717. // iteminfo.OthAmt = operation_other_amt
  14718. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14719. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14720. // }
  14721. //
  14722. // if nursingCostTotal != 0 {
  14723. // iteminfo.MedChrgitm = "07"
  14724. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  14725. // iteminfo.Amt = nursingCostTotal
  14726. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  14727. // iteminfo.ClabAmt = nursing_clab_amt
  14728. // iteminfo.OthAmt = nursing_other_amt
  14729. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14730. // }
  14731. //
  14732. // if materialCostTotal != 0 {
  14733. // iteminfo.MedChrgitm = "08"
  14734. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  14735. // iteminfo.Amt = materialCostTotal
  14736. // iteminfo.ClaaSumfee = material_claa_sunmfee
  14737. // iteminfo.ClabAmt = material_clab_amt
  14738. // iteminfo.OthAmt = material_other_amt
  14739. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14740. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14741. // }
  14742. //
  14743. // if westernMedicineCostTotal != 0 {
  14744. // iteminfo.MedChrgitm = "09"
  14745. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14746. // iteminfo.Amt = westernMedicineCostTotal
  14747. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14748. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14749. // iteminfo.OthAmt = westernMedicine_other_amt
  14750. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14751. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14752. //
  14753. // }
  14754. //
  14755. // if chineseMedicineCostTotal != 0 {
  14756. // iteminfo.MedChrgitm = "10"
  14757. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  14758. // iteminfo.Amt = chineseMedicineCostTotal
  14759. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  14760. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  14761. // iteminfo.OthAmt = chinese_medicine_other_amt
  14762. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14763. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14764. //
  14765. // }
  14766. //
  14767. // if chineseTraditionalMedicineCostTotal != 0 {
  14768. // iteminfo.MedChrgitm = "11"
  14769. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  14770. // iteminfo.Amt = westernMedicineCostTotal
  14771. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  14772. // iteminfo.ClabAmt = westernMedicine_clab_amt
  14773. // iteminfo.OthAmt = westernMedicine_other_amt
  14774. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14775. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14776. //
  14777. // }
  14778. //
  14779. // if commonlyTreatmentCostTotal != 0 {
  14780. // iteminfo.MedChrgitm = "12"
  14781. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  14782. // iteminfo.Amt = commonlyTreatmentCostTotal
  14783. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  14784. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  14785. // iteminfo.OthAmt = commonly_treatment_other_amt
  14786. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14787. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14788. //
  14789. // }
  14790. //
  14791. // if registerCostTotal != 0 {
  14792. // iteminfo.MedChrgitm = "13"
  14793. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  14794. // iteminfo.Amt = registerCostTotal
  14795. // iteminfo.ClaaSumfee = register_claa_sunmfee
  14796. // iteminfo.ClabAmt = register_clab_amt
  14797. // iteminfo.OthAmt = register_other_amt
  14798. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14799. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14800. //
  14801. // }
  14802. //
  14803. // if otherCostTotal != 0 {
  14804. // iteminfo.MedChrgitm = "14"
  14805. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  14806. // iteminfo.Amt = otherCostTotal
  14807. // iteminfo.ClaaSumfee = other_claa_sunmfee
  14808. // iteminfo.ClabAmt = other_clab_amt
  14809. // iteminfo.OthAmt = other_other_amt
  14810. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  14811. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  14812. //
  14813. // }
  14814. // struct4101.IteminfoStruct = iteminfoStructs
  14815. // time_arr := strings.Split(order.SetlTime, " ")
  14816. // struct4101.AdmTime = time_arr[0]
  14817. // struct4101.AdmEndTime = time_arr[0]
  14818. //
  14819. // struct4101.DoctorName = doctor.UserName
  14820. // struct4101.DoctorCode = doctor.DoctorNumber
  14821. //
  14822. // struct4101.Ntly = "中国"
  14823. // struct4101.AdmCaty = "A03.06"
  14824. // var res ResultSeventeen
  14825. // if miConfig.MdtrtareaAdmvs == "421300" {
  14826. // data := make(map[string]interface{})
  14827. // data["struct4101"] = struct4101
  14828. // data["secret_key"] = miConfig.SecretKey
  14829. // data["org_name"] = miConfig.OrgName
  14830. // data["opera"] = curRoles.UserName
  14831. // data["code"] = miConfig.Code
  14832. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14833. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14834. //
  14835. // client := &http.Client{}
  14836. // bytesData, _ := json.Marshal(data)
  14837. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14838. // resp, _ := client.Do(req)
  14839. // defer resp.Body.Close()
  14840. // body, ioErr := ioutil.ReadAll(resp.Body)
  14841. // if ioErr != nil {
  14842. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14843. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14844. // return
  14845. // }
  14846. // var respJSON map[string]interface{}
  14847. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14848. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14850. // return
  14851. // }
  14852. //
  14853. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14854. // userJSONBytes, _ := json.Marshal(respJSON)
  14855. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14856. // utils.ErrorLog("解析失败:%v", err)
  14857. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14858. // adminUser := c.GetAdminUserInfo()
  14859. // errlog := &models.HisOrderError{
  14860. // UserOrgId: adminUser.CurrentOrgId,
  14861. // Ctime: time.Now().Unix(),
  14862. // Mtime: time.Now().Unix(),
  14863. // ErrMsg: res.ErrMsg + "解析失败",
  14864. // Status: 1,
  14865. // PatientId: order_id,
  14866. // Stage: 10088,
  14867. // }
  14868. // service.CreateErrMsgLog(errlog)
  14869. // continue
  14870. // }
  14871. //
  14872. // } else if miConfig.MdtrtareaAdmvs == "420200" {
  14873. // data := make(map[string]interface{})
  14874. // data["struct4101"] = struct4101
  14875. // data["secret_key"] = miConfig.SecretKey
  14876. // data["org_name"] = miConfig.OrgName
  14877. // data["opera"] = curRoles.UserName
  14878. // data["code"] = miConfig.Code
  14879. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  14880. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  14881. //
  14882. // client := &http.Client{}
  14883. // bytesData, _ := json.Marshal(data)
  14884. // req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  14885. // resp, _ := client.Do(req)
  14886. // defer resp.Body.Close()
  14887. // body, ioErr := ioutil.ReadAll(resp.Body)
  14888. // if ioErr != nil {
  14889. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14891. // return
  14892. // }
  14893. // var respJSON map[string]interface{}
  14894. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  14895. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14897. // return
  14898. // }
  14899. //
  14900. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14901. // userJSONBytes, _ := json.Marshal(respJSON)
  14902. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14903. // utils.ErrorLog("解析失败:%v", err)
  14904. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14905. // adminUser := c.GetAdminUserInfo()
  14906. // errlog := &models.HisOrderError{
  14907. // UserOrgId: adminUser.CurrentOrgId,
  14908. // Ctime: time.Now().Unix(),
  14909. // Mtime: time.Now().Unix(),
  14910. // ErrMsg: res.ErrMsg + "解析失败",
  14911. // Status: 1,
  14912. // PatientId: order_id,
  14913. // Stage: 10088,
  14914. // }
  14915. // service.CreateErrMsgLog(errlog)
  14916. // continue
  14917. // }
  14918. //
  14919. // } else {
  14920. // result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  14921. // fmt.Println(result)
  14922. //
  14923. // var dat map[string]interface{}
  14924. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14925. // fmt.Println(dat)
  14926. // } else {
  14927. // fmt.Println(err)
  14928. // }
  14929. // userJSONBytes, _ := json.Marshal(dat)
  14930. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14931. // utils.ErrorLog("解析失败:%v", err)
  14932. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14933. // adminUser := c.GetAdminUserInfo()
  14934. // errlog := &models.HisOrderError{
  14935. // UserOrgId: adminUser.CurrentOrgId,
  14936. // Ctime: time.Now().Unix(),
  14937. // Mtime: time.Now().Unix(),
  14938. // ErrMsg: res.ErrMsg + "解析失败",
  14939. // Status: 1,
  14940. // PatientId: order_id,
  14941. // Stage: 10106,
  14942. // }
  14943. // service.CreateErrMsgLog(errlog)
  14944. // continue
  14945. // }
  14946. // }
  14947. //
  14948. // if res.Infcode != 0 {
  14949. // adminUser := c.GetAdminUserInfo()
  14950. // errlog := &models.HisOrderError{
  14951. // UserOrgId: adminUser.CurrentOrgId,
  14952. // Ctime: time.Now().Unix(),
  14953. // Mtime: time.Now().Unix(),
  14954. // ErrMsg: res.ErrMsg,
  14955. // Status: 1,
  14956. // PatientId: order_id,
  14957. // Stage: 10106,
  14958. // }
  14959. // service.CreateErrMsgLog(errlog)
  14960. // continue
  14961. // } else {
  14962. // hisFundSettleListResult := &models.HisFundSettleListResult{
  14963. // Number: res.Output.SetlListId,
  14964. // Status: 1,
  14965. // Ctime: time.Now().Unix(),
  14966. // Mtime: time.Now().Unix(),
  14967. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  14968. // IsUpload: 1,
  14969. // OrderId: order_id,
  14970. // }
  14971. // service.CreateUploadRecord(hisFundSettleListResult)
  14972. // continue
  14973. // }
  14974. // }
  14975. //}
  14976. func (c *HisApiController) GetOrgInfo() {
  14977. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  14978. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  14979. }
  14980. func (c *HisApiController) GetHisPatientInfo() {
  14981. medical_insurance_card := c.GetString("medical_insurance_card")
  14982. id_card_type, _ := c.GetInt64("id_card_type")
  14983. id_card := c.GetString("id_card")
  14984. adminInfo := c.GetAdminUserInfo()
  14985. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14986. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14987. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  14988. IdCardNo := ""
  14989. if id_card_type == 1 {
  14990. IdCardNo = medical_insurance_card
  14991. } else if id_card_type == 2 {
  14992. IdCardNo = id_card
  14993. }
  14994. if config.IsOpen == 1 {
  14995. 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
  14996. resp, requestErr := http.Get(api)
  14997. if requestErr != nil {
  14998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14999. return
  15000. }
  15001. defer resp.Body.Close()
  15002. body, ioErr := ioutil.ReadAll(resp.Body)
  15003. if ioErr != nil {
  15004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15006. return
  15007. }
  15008. var respJSON map[string]interface{}
  15009. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15012. return
  15013. }
  15014. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15015. userJSONBytes, _ := json.Marshal(userJSON)
  15016. var res ResultTwo
  15017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15018. utils.ErrorLog("解析失败:%v", err)
  15019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15020. return
  15021. }
  15022. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15023. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15024. infoStr := string(Iinfos)
  15025. idetinfoStr := string(Idetinfos)
  15026. if res.Infcode == 0 {
  15027. his := models.VMHisPatient{
  15028. Status: 1,
  15029. Ctime: time.Now().Unix(),
  15030. Mtime: time.Now().Unix(),
  15031. PsnNo: res.Output.Baseinfo.PsnNo,
  15032. PsnCertType: res.Output.Baseinfo.PsnCertType,
  15033. Certno: res.Output.Baseinfo.Certno,
  15034. PsnName: res.Output.Baseinfo.PsnName,
  15035. Gend: res.Output.Baseinfo.Gend,
  15036. Naty: res.Output.Baseinfo.Naty,
  15037. Iinfo: infoStr,
  15038. Idetinfo: idetinfoStr,
  15039. UserOrgId: adminInfo.CurrentOrgId,
  15040. IsReturn: 1,
  15041. IdCardType: id_card_type,
  15042. }
  15043. c.ServeSuccessJSON(map[string]interface{}{
  15044. "info": his,
  15045. })
  15046. } else {
  15047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  15048. return
  15049. }
  15050. }
  15051. }
  15052. //func GetBasBaseInfo() (jsonStr string, err error) {
  15053. //
  15054. // handle := syscall.NewLazyDLL("SSCard.dll")
  15055. // add := handle.NewProc("ReadCardBas")
  15056. // str := make([]byte, 1024)
  15057. // str1 := make([]byte, 1024)
  15058. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15059. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  15060. //
  15061. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  15062. //
  15063. // fmt.Println("> Add(4,5)的结果为:", ret)
  15064. // handle.Release()
  15065. //
  15066. // return "", nil
  15067. //
  15068. //}
  15069. //func GetQRBaseInfo() (jsonStr string, err error) {
  15070. // handle := syscall.LoadDLL("SSCard.dll")
  15071. // ReadCardBas := handle.FindProc("GetQRBase")
  15072. //
  15073. // str := make([]byte, 256)
  15074. // str1 := make([]byte, 256)
  15075. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  15076. //
  15077. // fmt.Println(string(str))
  15078. // fmt.Println(r)
  15079. // return string(str), nil
  15080. //}
  15081. //func CardInit() int {
  15082. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  15083. // add := DllTestDef.MustFindProc("Init")
  15084. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15085. // if err != nil {
  15086. // fmt.Println("SSCard的运算结果为:", ret)
  15087. // }
  15088. // result := int(ret)
  15089. // return result
  15090. //}
  15091. //func CardInit() int {
  15092. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  15093. // if err != nil {
  15094. // fmt.Println("SSCard的运算结果为:", ret)
  15095. // }
  15096. // fmt.Println(err)
  15097. // result := int(ret)
  15098. // return result
  15099. //}
  15100. func IntPtr(n int) uintptr {
  15101. return uintptr(n)
  15102. }
  15103. func StrPtr(s string) uintptr {
  15104. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  15105. }
  15106. type Result2001 struct {
  15107. Cainfo interface{} `json:"cainfo"`
  15108. ErrMsg string `json:"err_msg"`
  15109. InfRefmsgid string `json:"inf_refmsgid"`
  15110. Infcode int64 `json:"infcode"`
  15111. Output struct {
  15112. Trtinfo struct {
  15113. PsnNo string `json:"psn_no"`
  15114. TrtChkType string `json:"trt_chk_type"`
  15115. FundPayType string `json:"fund_pay_type"`
  15116. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15117. Begndate string `json:"begndate"`
  15118. Enddate string `json:"enddate"`
  15119. TrtChkRslt string `json:"trt_chk_rslt"`
  15120. } `json:"trtinfo"`
  15121. } `json:"output"`
  15122. RefmsgTime string `json:"refmsg_time"`
  15123. RespondTime string `json:"respond_time"`
  15124. Signtype interface{} `json:"signtype"`
  15125. WarnMsg interface{} `json:"warn_msg"`
  15126. }
  15127. type Result2001Org10265 struct {
  15128. Cainfo interface{} `json:"cainfo"`
  15129. ErrMsg string `json:"err_msg"`
  15130. InfRefmsgid string `json:"inf_refmsgid"`
  15131. Infcode string `json:"infcode"`
  15132. Output struct {
  15133. Trtinfo struct {
  15134. PsnNo string `json:"psn_no"`
  15135. TrtChkType string `json:"trt_chk_type"`
  15136. FundPayType string `json:"fund_pay_type"`
  15137. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  15138. Begndate string `json:"begndate"`
  15139. Enddate string `json:"enddate"`
  15140. TrtChkRslt string `json:"trt_chk_rslt"`
  15141. } `json:"trtinfo"`
  15142. } `json:"output"`
  15143. RefmsgTime string `json:"refmsg_time"`
  15144. RespondTime string `json:"respond_time"`
  15145. Signtype interface{} `json:"signtype"`
  15146. WarnMsg interface{} `json:"warn_msg"`
  15147. }
  15148. type ResultTwo struct {
  15149. ErrMsg string `json:"err_msg"`
  15150. InfRefmsgid string `json:"inf_refmsgid"`
  15151. Infcode int64 `json:"infcode"`
  15152. Output struct {
  15153. Baseinfo struct {
  15154. //Brdy string `json:"brdy"`
  15155. Certno string `json:"certno"`
  15156. Gend string `json:"gend"`
  15157. Naty string `json:"naty"`
  15158. PsnCertType string `json:"psn_cert_type"`
  15159. PsnName string `json:"psn_name"`
  15160. PsnNo string `json:"psn_no"`
  15161. } `json:"baseinfo"`
  15162. Idetinfo []interface{} `json:"idetinfo"`
  15163. Iinfo []struct {
  15164. Balc float64 `json:"balc"`
  15165. CvlservFlag string `json:"cvlserv_flag"`
  15166. EmpName string `json:"emp_name"`
  15167. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15168. Insutype string `json:"insutype"`
  15169. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15170. //PausInsuDate string `json:"paus_insu_date"`
  15171. //PsnInsuDate string `json:"psn_insu_date"`
  15172. PsnInsuStas string `json:"psn_insu_stas"`
  15173. PsnType string `json:"psn_type"`
  15174. } `json:"insuinfo"`
  15175. } `json:"output"`
  15176. RefmsgTime string `json:"refmsg_time"`
  15177. RespondTime string `json:"respond_time"`
  15178. Signtype interface{} `json:"signtype"`
  15179. WarnInfo interface{} `json:"warn_info"`
  15180. }
  15181. type ResultTwo10265 struct {
  15182. ErrMsg string `json:"err_msg"`
  15183. InfRefmsgid string `json:"inf_refmsgid"`
  15184. Infcode string `json:"infcode"`
  15185. Output struct {
  15186. Baseinfo struct {
  15187. //Brdy string `json:"brdy"`
  15188. Certno string `json:"certno"`
  15189. Gend string `json:"gend"`
  15190. Naty string `json:"naty"`
  15191. PsnCertType string `json:"psn_cert_type"`
  15192. PsnName string `json:"psn_name"`
  15193. PsnNo string `json:"psn_no"`
  15194. } `json:"baseinfo"`
  15195. Idetinfo []interface{} `json:"idetinfo"`
  15196. Iinfo []struct {
  15197. Balc float64 `json:"balc"`
  15198. CvlservFlag string `json:"cvlserv_flag"`
  15199. EmpName string `json:"emp_name"`
  15200. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15201. Insutype string `json:"insutype"`
  15202. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15203. PsnInsuStas string `json:"psn_insu_stas"`
  15204. PsnType string `json:"psn_type"`
  15205. } `json:"insuinfo"`
  15206. } `json:"output"`
  15207. RefmsgTime string `json:"refmsg_time"`
  15208. RespondTime string `json:"respond_time"`
  15209. Signtype interface{} `json:"signtype"`
  15210. WarnInfo interface{} `json:"warn_info"`
  15211. }
  15212. type ResultThree struct {
  15213. Cainfo interface{} `json:"cainfo"`
  15214. ErrMsg string `json:"err_msg"`
  15215. InfRefmsgid string `json:"inf_refmsgid"`
  15216. Infcode int64 `json:"infcode"`
  15217. Output struct {
  15218. Data struct {
  15219. IptOtpNo string `json:"ipt_otp_no"`
  15220. MdtrtID string `json:"mdtrt_id"`
  15221. PsnNo string `json:"psn_no"`
  15222. } `json:"data"`
  15223. } `json:"output"`
  15224. RefmsgTime string `json:"refmsg_time"`
  15225. RespondTime string `json:"respond_time"`
  15226. Signtype interface{} `json:"signtype"`
  15227. WarnMsg interface{} `json:"warn_msg"`
  15228. }
  15229. type ResultThree10265 struct {
  15230. Cainfo interface{} `json:"cainfo"`
  15231. ErrMsg string `json:"err_msg"`
  15232. InfRefmsgid string `json:"inf_refmsgid"`
  15233. Infcode string `json:"infcode"`
  15234. Output struct {
  15235. Data struct {
  15236. IptOtpNo string `json:"ipt_otp_no"`
  15237. MdtrtID string `json:"mdtrt_id"`
  15238. PsnNo string `json:"psn_no"`
  15239. } `json:"data"`
  15240. } `json:"output"`
  15241. RefmsgTime string `json:"refmsg_time"`
  15242. RespondTime string `json:"respond_time"`
  15243. Signtype interface{} `json:"signtype"`
  15244. WarnMsg interface{} `json:"warn_msg"`
  15245. }
  15246. type ResultFour struct {
  15247. Cainfo string `json:"cainfo"`
  15248. ErrMsg string `json:"err_msg"`
  15249. InfRefmsgid string `json:"inf_refmsgid"`
  15250. Infcode int64 `json:"infcode"`
  15251. Output struct {
  15252. Result []struct {
  15253. BasMednFlag string `json:"bas_medn_flag"`
  15254. ChldMedcFlag string `json:"chld_medc_flag"`
  15255. ChrgitmLv string `json:"chrgitm_lv"`
  15256. Cnt float64 `json:"cnt"`
  15257. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15258. DrtReimFlag string `json:"drt_reim_flag"`
  15259. FeedetlSn string `json:"feedetl_sn"`
  15260. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15261. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15262. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15263. ListSpItemFlag string `json:"list_sp_item_flag"`
  15264. LmtUsedFlag string `json:"lmt_used_flag"`
  15265. MedChrgitmType string `json:"med_chrgitm_type"`
  15266. Memo string `json:"memo"`
  15267. OverlmtAmt float64 `json:"overlmt_amt"`
  15268. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15269. Pric float64 `json:"pric"`
  15270. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15271. SelfpayProp float64 `json:"selfpay_prop"`
  15272. } `json:"result"`
  15273. } `json:"output"`
  15274. RefmsgTime string `json:"refmsg_time"`
  15275. RespondTime string `json:"respond_time"`
  15276. Signtype string `json:"signtype"`
  15277. WarnMsg string `json:"warn_msg"`
  15278. }
  15279. type ResultFour10265 struct {
  15280. Cainfo string `json:"cainfo"`
  15281. ErrMsg string `json:"err_msg"`
  15282. InfRefmsgid string `json:"inf_refmsgid"`
  15283. Infcode string `json:"infcode"`
  15284. Output struct {
  15285. Result []struct {
  15286. BasMednFlag string `json:"bas_medn_flag"`
  15287. ChldMedcFlag string `json:"chld_medc_flag"`
  15288. ChrgitmLv string `json:"chrgitm_lv"`
  15289. Cnt float64 `json:"cnt"`
  15290. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  15291. DrtReimFlag string `json:"drt_reim_flag"`
  15292. FeedetlSn string `json:"feedetl_sn"`
  15293. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15294. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  15295. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15296. ListSpItemFlag string `json:"list_sp_item_flag"`
  15297. LmtUsedFlag string `json:"lmt_used_flag"`
  15298. MedChrgitmType string `json:"med_chrgitm_type"`
  15299. Memo string `json:"memo"`
  15300. OverlmtAmt float64 `json:"overlmt_amt"`
  15301. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15302. Pric float64 `json:"pric"`
  15303. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  15304. SelfpayProp float64 `json:"selfpay_prop"`
  15305. } `json:"result"`
  15306. } `json:"output"`
  15307. RefmsgTime string `json:"refmsg_time"`
  15308. RespondTime string `json:"respond_time"`
  15309. Signtype string `json:"signtype"`
  15310. WarnMsg string `json:"warn_msg"`
  15311. }
  15312. type ResultMemo struct {
  15313. InsuAdmdvs string `json:"insuAdmdvs"`
  15314. }
  15315. // [{"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}]
  15316. type ResultIDInfo struct {
  15317. Begntime string `json:"begntime"`
  15318. Endtime string `json:"endtime"`
  15319. Memo string `json:"memo"`
  15320. }
  15321. type ResultFive struct {
  15322. Balc float64 `json:"balc"`
  15323. CvlservFlag string `json:"cvlserv_flag"`
  15324. EmpName string `json:"emp_name"`
  15325. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  15326. Insutype string `json:"insutype"`
  15327. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  15328. PausInsuDate string `json:"paus_insu_date"`
  15329. PsnInsuDate string `json:"psn_insu_date"`
  15330. PsnInsuStas string `json:"psn_insu_stas"`
  15331. PsnType string `json:"psn_type"`
  15332. }
  15333. type ResultSix struct {
  15334. Cainfo interface{} `json:"cainfo"`
  15335. ErrMsg string `json:"err_msg"`
  15336. InfRefmsgid string `json:"inf_refmsgid"`
  15337. Infcode int64 `json:"infcode"`
  15338. Output struct {
  15339. } `json:"output"`
  15340. RefmsgTime string `json:"refmsg_time"`
  15341. RespondTime string `json:"respond_time"`
  15342. Signtype interface{} `json:"signtype"`
  15343. WarnMsg interface{} `json:"warn_msg"`
  15344. }
  15345. type Result2406 struct {
  15346. Cainfo interface{} `json:"cainfo"`
  15347. ErrMsg string `json:"err_msg"`
  15348. InfRefmsgid string `json:"inf_refmsgid"`
  15349. Infcode int64 `json:"infcode"`
  15350. Output struct {
  15351. Result struct {
  15352. IptPsnSpFlagDetlId string `json:"ipt_psn_sp_flag_detl_id"`
  15353. } `json:"result"`
  15354. } `json:"output"`
  15355. RefmsgTime string `json:"refmsg_time"`
  15356. RespondTime string `json:"respond_time"`
  15357. Signtype interface{} `json:"signtype"`
  15358. WarnMsg interface{} `json:"warn_msg"`
  15359. }
  15360. type GZResultSix struct {
  15361. Cainfo interface{} `json:"cainfo"`
  15362. ErrMsg string `json:"err_msg"`
  15363. InfRefmsgid string `json:"inf_refmsgid"`
  15364. Infcode int64 `json:"infcode"`
  15365. Output string `json:"output"`
  15366. RefmsgTime string `json:"refmsg_time"`
  15367. RespondTime string `json:"respond_time"`
  15368. Signtype interface{} `json:"signtype"`
  15369. WarnMsg interface{} `json:"warn_msg"`
  15370. }
  15371. type ResultSix10265 struct {
  15372. Cainfo interface{} `json:"cainfo"`
  15373. ErrMsg string `json:"err_msg"`
  15374. InfRefmsgid string `json:"inf_refmsgid"`
  15375. Infcode string `json:"infcode"`
  15376. Output struct {
  15377. } `json:"output"`
  15378. RefmsgTime string `json:"refmsg_time"`
  15379. RespondTime string `json:"respond_time"`
  15380. Signtype interface{} `json:"signtype"`
  15381. WarnMsg interface{} `json:"warn_msg"`
  15382. }
  15383. type ResultSeven struct {
  15384. Cainfo string `json:"cainfo"`
  15385. ErrMsg string `json:"err_msg"`
  15386. InfRefmsgid string `json:"inf_refmsgid"`
  15387. Infcode int64 `json:"infcode"`
  15388. Output struct {
  15389. Setlinfo struct {
  15390. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15391. AcctPay float64 `json:"acct_pay"`
  15392. ActPayDedc float64 `json:"act_pay_dedc"`
  15393. Age float64 `json:"age"`
  15394. Balc float64 `json:"balc"`
  15395. Certno string `json:"certno"`
  15396. ClrOptins string `json:"clr_optins"`
  15397. ClrType string `json:"clr_type"`
  15398. ClrWay string `json:"clr_way"`
  15399. CvlservFlag string `json:"cvlserv_flag"`
  15400. CvlservPay float64 `json:"cvlserv_pay"`
  15401. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15402. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15403. Gend string `json:"gend"`
  15404. HifesPay float64 `json:"hifes_pay"`
  15405. HifmiPay float64 `json:"hifmi_pay"`
  15406. HifpPay float64 `json:"hifp_pay"`
  15407. HospPartAmt float64 `json:"hosp_part_amt"`
  15408. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15409. Insutype string `json:"insutype"`
  15410. MafPay float64 `json:"maf_pay"`
  15411. MdtrtCertType string `json:"mdtrt_cert_type"`
  15412. HifobPay float64 `json:"hifob_pay"`
  15413. MdtrtID string `json:"mdtrt_id"`
  15414. MedType string `json:"med_type"`
  15415. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15416. MedinsSetlID string `json:"medins_setl_id"`
  15417. Naty string `json:"naty"`
  15418. OthPay float64 `json:"oth_pay"`
  15419. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15420. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15421. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15422. PsnCashPay float64 `json:"psn_cash_pay"`
  15423. PsnCertType string `json:"psn_cert_type"`
  15424. PsnName string `json:"psn_name"`
  15425. PsnNo string `json:"psn_no"`
  15426. PsnPartAmt float64 `json:"psn_part_amt"`
  15427. PsnType string `json:"psn_type"`
  15428. SetlID string `json:"setl_id"`
  15429. SetlTime string `json:"setl_time"`
  15430. } `json:"setlinfo"`
  15431. Setldetail interface{} `json:"setldetail"`
  15432. } `json:"output"`
  15433. RefmsgTime string `json:"refmsg_time"`
  15434. RespondTime string `json:"respond_time"`
  15435. Signtype interface{} `json:"signtype"`
  15436. WarnMsg interface{} `json:"warn_msg"`
  15437. }
  15438. type ResultSevenAH struct {
  15439. Cainfo string `json:"cainfo"`
  15440. ErrMsg string `json:"err_msg"`
  15441. InfRefmsgid string `json:"inf_refmsgid"`
  15442. Infcode int64 `json:"infcode"`
  15443. Output struct {
  15444. Setlinfo struct {
  15445. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15446. AcctPay float64 `json:"acct_pay"`
  15447. ActPayDedc float64 `json:"act_pay_dedc"`
  15448. Age float64 `json:"age"`
  15449. Balc float64 `json:"balc"`
  15450. Certno string `json:"certno"`
  15451. ClrOptins string `json:"clr_optins"`
  15452. ClrType string `json:"clr_type"`
  15453. ClrWay string `json:"clr_way"`
  15454. CvlservFlag string `json:"cvlserv_flag"`
  15455. CvlservPay float64 `json:"cvlserv_pay"`
  15456. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15458. Gend string `json:"gend"`
  15459. HifesPay float64 `json:"hifes_pay"`
  15460. HifmiPay float64 `json:"hifmi_pay"`
  15461. HifpPay float64 `json:"hifp_pay"`
  15462. HospPartAmt float64 `json:"hosp_part_amt"`
  15463. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15464. Insutype string `json:"insutype"`
  15465. MafPay float64 `json:"maf_pay"`
  15466. MdtrtCertType string `json:"mdtrt_cert_type"`
  15467. HifobPay float64 `json:"hifob_pay"`
  15468. MdtrtID string `json:"mdtrt_id"`
  15469. MedType string `json:"med_type"`
  15470. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15471. MedinsSetlID string `json:"medins_setl_id"`
  15472. Naty string `json:"naty"`
  15473. OthPay float64 `json:"oth_pay"`
  15474. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15475. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15476. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15477. PsnCashPay float64 `json:"psn_cash_pay"`
  15478. PsnCertType string `json:"psn_cert_type"`
  15479. PsnName string `json:"psn_name"`
  15480. PsnNo string `json:"psn_no"`
  15481. PsnPartAmt float64 `json:"psn_part_amt"`
  15482. PsnType string `json:"psn_type"`
  15483. SetlID string `json:"setl_id"`
  15484. SetlTime int64 `json:"setl_time"`
  15485. } `json:"setlinfo"`
  15486. Setldetail interface{} `json:"setldetail"`
  15487. } `json:"output"`
  15488. RefmsgTime string `json:"refmsg_time"`
  15489. RespondTime string `json:"respond_time"`
  15490. Signtype interface{} `json:"signtype"`
  15491. WarnMsg interface{} `json:"warn_msg"`
  15492. }
  15493. type ResultSeven10265 struct {
  15494. Cainfo string `json:"cainfo"`
  15495. ErrMsg string `json:"err_msg"`
  15496. InfRefmsgid string `json:"inf_refmsgid"`
  15497. Infcode string `json:"infcode"`
  15498. Output struct {
  15499. Setlinfo struct {
  15500. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15501. AcctPay float64 `json:"acct_pay"`
  15502. ActPayDedc float64 `json:"act_pay_dedc"`
  15503. Age float64 `json:"age"`
  15504. Balc float64 `json:"balc"`
  15505. Certno string `json:"certno"`
  15506. ClrOptins string `json:"clr_optins"`
  15507. ClrType string `json:"clr_type"`
  15508. ClrWay string `json:"clr_way"`
  15509. CvlservFlag string `json:"cvlserv_flag"`
  15510. CvlservPay float64 `json:"cvlserv_pay"`
  15511. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15512. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15513. Gend string `json:"gend"`
  15514. HifesPay float64 `json:"hifes_pay"`
  15515. HifmiPay float64 `json:"hifmi_pay"`
  15516. HifpPay float64 `json:"hifp_pay"`
  15517. HospPartAmt float64 `json:"hosp_part_amt"`
  15518. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15519. Insutype string `json:"insutype"`
  15520. MafPay float64 `json:"maf_pay"`
  15521. MdtrtCertType string `json:"mdtrt_cert_type"`
  15522. HifobPay float64 `json:"hifob_pay"`
  15523. MdtrtID string `json:"mdtrt_id"`
  15524. MedType string `json:"med_type"`
  15525. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15526. MedinsSetlID string `json:"medins_setl_id"`
  15527. Naty string `json:"naty"`
  15528. OthPay float64 `json:"oth_pay"`
  15529. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15530. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15531. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15532. PsnCashPay float64 `json:"psn_cash_pay"`
  15533. PsnCertType string `json:"psn_cert_type"`
  15534. PsnName string `json:"psn_name"`
  15535. PsnNo string `json:"psn_no"`
  15536. PsnPartAmt float64 `json:"psn_part_amt"`
  15537. PsnType string `json:"psn_type"`
  15538. SetlID string `json:"setl_id"`
  15539. SetlTime string `json:"setl_time"`
  15540. } `json:"setlinfo"`
  15541. Setldetail interface{} `json:"setldetail"`
  15542. } `json:"output"`
  15543. RefmsgTime string `json:"refmsg_time"`
  15544. RespondTime string `json:"respond_time"`
  15545. Signtype interface{} `json:"signtype"`
  15546. WarnMsg interface{} `json:"warn_msg"`
  15547. }
  15548. type ResultSeven10265Two struct {
  15549. Cainfo string `json:"cainfo"`
  15550. ErrMsg string `json:"err_msg"`
  15551. InfRefmsgid string `json:"inf_refmsgid"`
  15552. Infcode string `json:"infcode"`
  15553. Output struct {
  15554. Setlinfo struct {
  15555. AcctMulaidPay string `json:"acct_mulaid_pay"`
  15556. AcctPay float64 `json:"acct_pay"`
  15557. ActPayDedc float64 `json:"act_pay_dedc"`
  15558. Age float64 `json:"age"`
  15559. Balc float64 `json:"balc"`
  15560. Certno string `json:"certno"`
  15561. ClrOptins string `json:"clr_optins"`
  15562. ClrType string `json:"clr_type"`
  15563. ClrWay string `json:"clr_way"`
  15564. CvlservFlag string `json:"cvlserv_flag"`
  15565. CvlservPay float64 `json:"cvlserv_pay"`
  15566. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15567. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15568. Gend string `json:"gend"`
  15569. HifesPay float64 `json:"hifes_pay"`
  15570. HifmiPay float64 `json:"hifmi_pay"`
  15571. HifpPay float64 `json:"hifp_pay"`
  15572. HospPartAmt string `json:"hosp_part_amt"`
  15573. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15574. Insutype string `json:"insutype"`
  15575. MafPay float64 `json:"maf_pay"`
  15576. MdtrtCertType string `json:"mdtrt_cert_type"`
  15577. HifobPay float64 `json:"hifob_pay"`
  15578. MdtrtID string `json:"mdtrt_id"`
  15579. MedType string `json:"med_type"`
  15580. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15581. MedinsSetlID string `json:"medins_setl_id"`
  15582. Naty string `json:"naty"`
  15583. OthPay float64 `json:"oth_pay"`
  15584. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15585. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15586. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15587. PsnCashPay float64 `json:"psn_cash_pay"`
  15588. PsnCertType string `json:"psn_cert_type"`
  15589. PsnName string `json:"psn_name"`
  15590. PsnNo string `json:"psn_no"`
  15591. PsnPartAmt float64 `json:"psn_part_amt"`
  15592. PsnType string `json:"psn_type"`
  15593. SetlID string `json:"setl_id"`
  15594. SetlTime string `json:"setl_time"`
  15595. } `json:"setlinfo"`
  15596. Setldetail interface{} `json:"setldetail"`
  15597. } `json:"output"`
  15598. RefmsgTime string `json:"refmsg_time"`
  15599. RespondTime string `json:"respond_time"`
  15600. Signtype interface{} `json:"signtype"`
  15601. WarnMsg interface{} `json:"warn_msg"`
  15602. }
  15603. type GZResultSeven10265Two struct {
  15604. Cainfo string `json:"cainfo"`
  15605. ErrMsg string `json:"err_msg"`
  15606. InfRefmsgid string `json:"inf_refmsgid"`
  15607. Infcode int64 `json:"infcode"`
  15608. Output struct {
  15609. Setlinfo struct {
  15610. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  15611. AcctPay float64 `json:"acct_pay"`
  15612. ActPayDedc float64 `json:"act_pay_dedc"`
  15613. Age float64 `json:"age"`
  15614. Balc float64 `json:"balc"`
  15615. Certno string `json:"certno"`
  15616. ClrOptins string `json:"clr_optins"`
  15617. ClrType string `json:"clr_type"`
  15618. ClrWay string `json:"clr_way"`
  15619. CvlservFlag string `json:"cvlserv_flag"`
  15620. CvlservPay float64 `json:"cvlserv_pay"`
  15621. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15622. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15623. Gend string `json:"gend"`
  15624. HifesPay float64 `json:"hifes_pay"`
  15625. HifmiPay float64 `json:"hifmi_pay"`
  15626. HifpPay float64 `json:"hifp_pay"`
  15627. HospPartAmt float64 `json:"hosp_part_amt"`
  15628. InscpScpAmt float64 `json:"inscp_scp_amt"`
  15629. Insutype string `json:"insutype"`
  15630. MafPay float64 `json:"maf_pay"`
  15631. MdtrtCertType string `json:"mdtrt_cert_type"`
  15632. HifobPay float64 `json:"hifob_pay"`
  15633. MdtrtID string `json:"mdtrt_id"`
  15634. MedType string `json:"med_type"`
  15635. MedfeeSumamt float64 `json:"medfee_sumamt"`
  15636. MedinsSetlID string `json:"medins_setl_id"`
  15637. Naty string `json:"naty"`
  15638. OthPay float64 `json:"oth_pay"`
  15639. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15640. PoolPropSelfpay string `json:"pool_prop_selfpay"`
  15641. PreselfpayAmt float64 `json:"preselfpay_amt"`
  15642. PsnCashPay float64 `json:"psn_cash_pay"`
  15643. PsnCertType string `json:"psn_cert_type"`
  15644. PsnName string `json:"psn_name"`
  15645. PsnNo string `json:"psn_no"`
  15646. PsnPartAmt float64 `json:"psn_part_amt"`
  15647. PsnType string `json:"psn_type"`
  15648. SetlID string `json:"setl_id"`
  15649. SetlTime string `json:"setl_time"`
  15650. } `json:"setlinfo"`
  15651. Setldetail interface{} `json:"setldetail"`
  15652. } `json:"output"`
  15653. RefmsgTime string `json:"refmsg_time"`
  15654. RespondTime string `json:"respond_time"`
  15655. Signtype interface{} `json:"signtype"`
  15656. WarnMsg interface{} `json:"warn_msg"`
  15657. }
  15658. type ResultEight struct {
  15659. Cainfo string `json:"cainfo"`
  15660. ErrMsg string `json:"err_msg"`
  15661. InfRefmsgid string `json:"inf_refmsgid"`
  15662. Infcode int64 `json:"infcode"`
  15663. Output struct {
  15664. Stmtinfo struct {
  15665. SetlOptins string `json:"setl_optins"`
  15666. StmtRslt string `json:"stmt_rslt"`
  15667. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15668. } `json:"stmtinfo"`
  15669. } `json:"output"`
  15670. RefmsgTime string `json:"refmsg_time"`
  15671. RespondTime string `json:"respond_time"`
  15672. Signtype interface{} `json:"signtype"`
  15673. WarnMsg interface{} `json:"warn_msg"`
  15674. }
  15675. type ResultEightFor10188 struct {
  15676. Cainfo string `json:"cainfo"`
  15677. ErrMsg string `json:"err_msg"`
  15678. InfRefmsgid string `json:"inf_refmsgid"`
  15679. Infcode string `json:"infcode"`
  15680. Output struct {
  15681. Stmtinfo struct {
  15682. SetlOptins string `json:"setl_optins"`
  15683. StmtRslt string `json:"stmt_rslt"`
  15684. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  15685. } `json:"stmtinfo"`
  15686. } `json:"output"`
  15687. RefmsgTime string `json:"refmsg_time"`
  15688. RespondTime string `json:"respond_time"`
  15689. Signtype interface{} `json:"signtype"`
  15690. WarnMsg interface{} `json:"warn_msg"`
  15691. }
  15692. type ResultNine struct {
  15693. Cainfo string `json:"cainfo"`
  15694. ErrMsg string `json:"err_msg"`
  15695. InfRefmsgid string `json:"inf_refmsgid"`
  15696. Infcode int64 `json:"infcode"`
  15697. Output struct {
  15698. FileQuryNo string `json:"file_qury_no"`
  15699. } `json:"output"`
  15700. RefmsgTime string `json:"refmsg_time"`
  15701. RespondTime string `json:"respond_time"`
  15702. Signtype interface{} `json:"signtype"`
  15703. WarnMsg interface{} `json:"warn_msg"`
  15704. }
  15705. type ResultTen struct {
  15706. Cainfo string `json:"cainfo"`
  15707. ErrMsg string `json:"err_msg"`
  15708. InfRefmsgid string `json:"inf_refmsgid"`
  15709. Infcode int64 `json:"infcode"`
  15710. Output struct {
  15711. Fileinfo struct {
  15712. DldEndtime string `json:"dld_endtime"`
  15713. FileQuryNo string `json:"file_qury_no"`
  15714. Filename string `json:"filename"`
  15715. } `json:"fileinfo"`
  15716. } `json:"output"`
  15717. RefmsgTime string `json:"refmsg_time"`
  15718. RespondTime string `json:"respond_time"`
  15719. Signtype interface{} `json:"signtype"`
  15720. WarnMsg interface{} `json:"warn_msg"`
  15721. }
  15722. type Result5262 struct {
  15723. ErrMsg string `json:"err_msg"`
  15724. InfRefmsgid string `json:"inf_refmsgid"`
  15725. Infcode int64 `json:"infcode"`
  15726. Output struct {
  15727. PageInfo struct {
  15728. Size int `json:"size"`
  15729. RecordCounts int `json:"record_counts"`
  15730. } `json:"page_info"`
  15731. Idetinfo []interface{} `json:"idetinfo"`
  15732. Result []struct {
  15733. SetlID string `json:"setl_id"`
  15734. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15735. MdtrtID string `json:"mdtrt_id"`
  15736. InitSetlID string `json:"init_setl_id,omitempty"`
  15737. PsnNo string `json:"psn_no"`
  15738. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15739. PsnName string `json:"psn_name"`
  15740. PsnCertType string `json:"psn_cert_type"`
  15741. Certno string `json:"certno"`
  15742. Gend string `json:"gend,omitempty"`
  15743. Naty string `json:"naty,omitempty"`
  15744. Brdy string `json:"brdy,omitempty"`
  15745. Age float64 `json:"age,omitempty"`
  15746. Insutype string `json:"insutype,omitempty"`
  15747. PsnType string `json:"psn_type"`
  15748. CvlservFlag string `json:"cvlserv_flag"`
  15749. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15750. SpPsnType string `json:"sp_psn_type,omitempty"`
  15751. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15752. ClctGrde string `json:"clct_grde,omitempty"`
  15753. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15754. NwbFlag string `json:"nwb_flag,omitempty"`
  15755. InsuAdmdvs string `json:"insu_admdvs"`
  15756. EmpNo string `json:"emp_no,omitempty"`
  15757. EmpName string `json:"emp_name,omitempty"`
  15758. EmpType string `json:"emp_type,omitempty"`
  15759. EconType string `json:"econ_type,omitempty"`
  15760. AfilIndu string `json:"afil_indu,omitempty"`
  15761. AfilRlts string `json:"afil_rlts,omitempty"`
  15762. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15763. PayLoc string `json:"pay_loc,omitempty"`
  15764. FixmedinsCode string `json:"fixmedins_code"`
  15765. FixmedinsName string `json:"fixmedins_name"`
  15766. HospLv string `json:"hosp_lv,omitempty"`
  15767. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15768. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15769. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15770. Begndate string `json:"begndate"`
  15771. Enddate string `json:"enddate"`
  15772. SetlTime string `json:"setl_time"`
  15773. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15774. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15775. MedType string `json:"med_type"`
  15776. SetlType string `json:"setl_type,omitempty"`
  15777. ClrType string `json:"clr_type,omitempty"`
  15778. ClrWay string `json:"clr_way,omitempty"`
  15779. PsnSetlway string `json:"psn_setlway,omitempty"`
  15780. ClrOptins string `json:"clr_optins,omitempty"`
  15781. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15782. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15783. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15784. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15785. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15786. DedcStd float64 `json:"dedc_std,omitempty"`
  15787. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15788. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15789. HifpPay float64 `json:"hifp_pay,omitempty"`
  15790. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15791. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15792. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15793. HifesPay float64 `json:"hifes_pay,omitempty"`
  15794. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15795. HifobPay float64 `json:"hifob_pay,omitempty"`
  15796. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15797. MafPay float64 `json:"maf_pay,omitempty"`
  15798. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15799. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15800. PsnPay float64 `json:"psn_pay,omitempty"`
  15801. AcctPay float64 `json:"acct_pay,omitempty"`
  15802. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15803. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15804. Balc float64 `json:"balc,omitempty"`
  15805. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15806. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15807. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15808. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15809. Year string `json:"year,omitempty"`
  15810. DiseNo string `json:"dise_no,omitempty"`
  15811. DiseName string `json:"dise_name,omitempty"`
  15812. Invono string `json:"invono,omitempty"`
  15813. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15814. ValiFlag string `json:"vali_flag,omitempty"`
  15815. Memo string `json:"memo,omitempty"`
  15816. Rid string `json:"rid"`
  15817. UpdtTime string `json:"updt_time,omitempty"`
  15818. CrterID string `json:"crter_id,omitempty"`
  15819. CrterName string `json:"crter_name,omitempty"`
  15820. CrteTime string `json:"crte_time,omitempty"`
  15821. CrteOptinsNo string `json:"crte_optins_no,omitempty"`
  15822. OpterID string `json:"opter_id,omitempty"`
  15823. OpterName string `json:"opter_name,omitempty"`
  15824. OptTime string `json:"opt_time,omitempty"`
  15825. OptinsNo string `json:"optins_no,omitempty"`
  15826. PoolareaNo string `json:"poolarea_no,omitempty"`
  15827. } `json:"result"`
  15828. } `json:"output"`
  15829. RefmsgTime string `json:"refmsg_time"`
  15830. RespondTime string `json:"respond_time"`
  15831. Signtype interface{} `json:"signtype"`
  15832. WarnInfo interface{} `json:"warn_info"`
  15833. }
  15834. type Result5267 struct {
  15835. ErrMsg string `json:"err_msg"`
  15836. InfRefmsgid string `json:"inf_refmsgid"`
  15837. Infcode int64 `json:"infcode"`
  15838. Output struct {
  15839. PageInfo struct {
  15840. Size int `json:"size"`
  15841. RecordCounts int `json:"record_counts"`
  15842. } `json:"pageinfo"`
  15843. Result []struct {
  15844. SetlID string `json:"setl_id"`
  15845. ClrOptins string `json:"clr_optins"`
  15846. MedinsSetlID string `json:"medins_setl_id,omitempty"`
  15847. MdtrtID string `json:"mdtrt_id"`
  15848. InitSetlID string `json:"init_setl_id,omitempty"`
  15849. PsnNo string `json:"psn_no"`
  15850. PsnInsuRltsID string `json:"psn_insu_rlts_id,omitempty"`
  15851. PsnName string `json:"psn_name"`
  15852. PsnCertType string `json:"psn_cert_type"`
  15853. Certno string `json:"certno"`
  15854. Gend string `json:"gend,omitempty"`
  15855. Naty string `json:"naty,omitempty"`
  15856. Brdy string `json:"brdy,omitempty"`
  15857. Age float64 `json:"age,omitempty"`
  15858. Insutype string `json:"insutype,omitempty"`
  15859. PsnType string `json:"psn_type"`
  15860. CvlservFlag string `json:"cvlserv_flag"`
  15861. CvlservLv string `json:"cvlserv_lv,omitempty"`
  15862. SpPsnType string `json:"sp_psn_type,omitempty"`
  15863. SpPsnTypeLv string `json:"sp_psn_type_lv,omitempty"`
  15864. ClctGrde string `json:"clct_grde,omitempty"`
  15865. FlxempeFlag string `json:"flxempe_flag,omitempty"`
  15866. NwbFlag string `json:"nwb_flag,omitempty"`
  15867. InsuAdmdvs string `json:"insu_admdvs"`
  15868. EmpNo string `json:"emp_no,omitempty"`
  15869. EmpName string `json:"emp_name,omitempty"`
  15870. EmpType string `json:"emp_type,omitempty"`
  15871. EconType string `json:"econ_type,omitempty"`
  15872. AfilIndu string `json:"afil_indu,omitempty"`
  15873. AfilRlts string `json:"afil_rlts,omitempty"`
  15874. EmpMgtType string `json:"emp_mgt_type,omitempty"`
  15875. PayLoc string `json:"pay_loc,omitempty"`
  15876. FixmedinsCode string `json:"fixmedins_code"`
  15877. FixmedinsName string `json:"fixmedins_name"`
  15878. HospLv string `json:"hosp_lv,omitempty"`
  15879. FixBlngAdmdvs string `json:"fix_blng_admdvs,omitempty"`
  15880. LmtpricHospLv string `json:"lmtpric_hosp_lv,omitempty"`
  15881. DedcHospLv string `json:"dedc_hosp_lv,omitempty"`
  15882. Begndate string `json:"begndate,omitempty"`
  15883. Enddate string `json:"enddate,omitempty"`
  15884. SetlTime string `json:"setl_time,omitempty"`
  15885. MdtrtCertType string `json:"mdtrt_cert_type,omitempty"`
  15886. MdtrtCertNo string `json:"mdtrt_cert_no,omitempty"`
  15887. MedType string `json:"med_type"`
  15888. SetlType string `json:"setl_type,omitempty"`
  15889. ClrType string `json:"clr_type,omitempty"`
  15890. ClrWay string `json:"clr_way,omitempty"`
  15891. PsnSetlway string `json:"psn_setlway,omitempty"`
  15892. MedfeeSumamt float64 `json:"medfee_sumamt,omitempty"`
  15893. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt,omitempty"`
  15894. OverlmtSelfpay float64 `json:"overlmt_selfpay,omitempty"`
  15895. PreselfpayAmt float64 `json:"preselfpay_amt,omitempty"`
  15896. InscpAmt float64 `json:"inscp_amt,omitempty"`
  15897. DedcStd float64 `json:"dedc_std,omitempty"`
  15898. CrtDedc float64 `json:"crt_dedc,omitempty"`
  15899. ActPayDedc float64 `json:"act_pay_dedc,omitempty"`
  15900. HifpPay float64 `json:"hifp_pay,omitempty"`
  15901. PoolPropSelfpay float64 `json:"pool_prop_selfpay,omitempty"`
  15902. HiAgreSumfee float64 `json:"hi_agre_sumfee,omitempty"`
  15903. CvlservPay float64 `json:"cvlserv_pay,omitempty"`
  15904. HifesPay float64 `json:"hifes_pay,omitempty"`
  15905. HifmiPay float64 `json:"hifmi_pay,omitempty"`
  15906. HifobPay float64 `json:"hifob_pay,omitempty"`
  15907. HifdmPay float64 `json:"hifdm_pay,omitempty"`
  15908. MafPay float64 `json:"maf_pay,omitempty"`
  15909. OthfundPay float64 `json:"othfund_pay,omitempty"`
  15910. FundPaySumamt float64 `json:"fund_pay_sumamt,omitempty"`
  15911. PsnPay float64 `json:"psn_pay,omitempty"`
  15912. AcctPay float64 `json:"acct_pay,omitempty"`
  15913. CashPayamt float64 `json:"cash_payamt,omitempty"`
  15914. OwnpayHospPart float64 `json:"ownpay_hosp_part,omitempty"`
  15915. Balc float64 `json:"balc,omitempty"`
  15916. AcctMulaidPay float64 `json:"acct_mulaid_pay,omitempty"`
  15917. RefdSetlFlag string `json:"refd_setl_flag,omitempty"`
  15918. CalIptCnt string `json:"cal_ipt_cnt,omitempty"`
  15919. SetlCashpayWay string `json:"setl_cashpay_way,omitempty"`
  15920. Year string `json:"year,omitempty"`
  15921. DiseNo string `json:"dise_no,omitempty"`
  15922. DiseName string `json:"dise_name,omitempty"`
  15923. Invono string `json:"invono,omitempty"`
  15924. ManlReimRea string `json:"manl_reim_rea,omitempty"`
  15925. Memo string `json:"memo,omitempty"`
  15926. UpdtTime string `json:"updt_time,omitempty"`
  15927. OpterID string `json:"opter_id,omitempty"`
  15928. OpterName string `json:"opter_name,omitempty"`
  15929. OptTime string `json:"opt_time,omitempty"`
  15930. OptinsNo string `json:"optins_no,omitempty"`
  15931. PoolareaNo string `json:"poolarea_no,omitempty"`
  15932. } `json:"result"`
  15933. } `json:"output"`
  15934. RefmsgTime string `json:"refmsg_time"`
  15935. RespondTime string `json:"respond_time"`
  15936. Signtype interface{} `json:"signtype"`
  15937. WarnInfo interface{} `json:"warn_info"`
  15938. }
  15939. // type Autogenerated struct {
  15940. // Output struct {
  15941. // Setlinfo struct {
  15942. // SetlTime string `json:"setl_time"`
  15943. // CvlservPay float64 `json:"cvlserv_pay"`
  15944. // Year string `json:"year"`
  15945. // MedType string `json:"med_type"`
  15946. // PsnPay float64 `json:"psn_pay"`
  15947. // OpterID string `json:"opter_id"`
  15948. // Begndate string `json:"begndate"`
  15949. // FlxempeFlag string `json:"flxempe_flag"`
  15950. // HifmiPay float64 `json:"hifmi_pay"`
  15951. // PsnNo string `json:"psn_no"`
  15952. // ActPayDedc float64 `json:"act_pay_dedc"`
  15953. // MedinsSetlID interface{} `json:"medins_setl_id"`
  15954. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  15955. // ClrWay string `json:"clr_way"`
  15956. // OthPay float64 `json:"oth_pay"`
  15957. // Gend string `json:"gend"`
  15958. // MdtrtID string `json:"mdtrt_id"`
  15959. // AcctPay float64 `json:"acct_pay"`
  15960. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  15961. // Insutype string `json:"insutype"`
  15962. // Invono interface{} `json:"invono"`
  15963. // Enddate string `json:"enddate"`
  15964. // CashPayamt float64 `json:"cash_payamt"`
  15965. // PsnType string `json:"psn_type"`
  15966. // FixmedinsName string `json:"fixmedins_name"`
  15967. // HifpPay float64 `json:"hifp_pay"`
  15968. // NewFlag interface{} `json:"new_flag"`
  15969. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  15970. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  15971. // PayLoc string `json:"pay_loc"`
  15972. // ClrType string `json:"clr_type"`
  15973. // RefdSetlFlag string `json:"refd_setl_flag"`
  15974. // CvlservFlag string `json:"cvlserv_flag"`
  15975. // EmpName string `json:"emp_name"`
  15976. // Brdy string `json:"brdy"`
  15977. // Naty string `json:"naty"`
  15978. // Certno string `json:"certno"`
  15979. // DiseCode string `json:"dise_code"`
  15980. // FixmedinsCode string `json:"fixmedins_code"`
  15981. // DedcHospLv string `json:"dedc_hosp_lv"`
  15982. // OpterName string `json:"opter_name"`
  15983. // Balc float64 `json:"balc"`
  15984. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  15985. // PsnCertType string `json:"psn_cert_type"`
  15986. // HifobPay float64 `json:"hifob_pay"`
  15987. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  15988. // HifesPay float64 `json:"hifes_pay"`
  15989. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  15990. // OptTime string `json:"opt_time"`
  15991. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  15992. // SetlID string `json:"setl_id"`
  15993. // MafPay float64 `json:"maf_pay"`
  15994. // PsnName string `json:"psn_name"`
  15995. // InsuOptins interface{} `json:"insu_optins"`
  15996. // PrefFundPay interface{} `json:"pref_fund_pay"`
  15997. // ClrOptins string `json:"clr_optins"`
  15998. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  15999. // DiseName string `json:"dise_name"`
  16000. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16001. // Age float64 `json:"age"`
  16002. // DtrtCertType string `json:"dtrt_cert_type"`
  16003. // HospLv string `json:"hosp_lv"`
  16004. // } `json:"setlinfo"`
  16005. // Setldetail []struct {
  16006. // FundPayType string `json:"fund_pay_type"`
  16007. // FundPayamt float64 `json:"fund_payamt"`
  16008. // SetlProcInfo interface{} `json:"setl_proc_info"`
  16009. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  16010. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  16011. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  16012. // PrefFundPay interface{} `json:"pref_fund_pay"`
  16013. // } `json:"setldetail"`
  16014. // } `json:"output"`
  16015. // Infcode int `json:"infcode"`
  16016. // WarnMsg interface{} `json:"warn_msg"`
  16017. // Cainfo interface{} `json:"cainfo"`
  16018. // ErrMsg interface{} `json:"err_msg"`
  16019. // RefmsgTime string `json:"refmsg_time"`
  16020. // Signtype interface{} `json:"signtype"`
  16021. // RespondTime string `json:"respond_time"`
  16022. // InfRefmsgid string `json:"inf_refmsgid"`
  16023. // }
  16024. type Result002 struct {
  16025. Cainfo interface{} `json:"cainfo"`
  16026. ErrMsg string `json:"err_msg"`
  16027. InfRefmsgid string `json:"inf_refmsgid"`
  16028. Infcode int64 `json:"infcode"`
  16029. Output struct {
  16030. RxFile string `json:"rx_file"`
  16031. SignDigest string `json:"sign_digest"`
  16032. SignCertSn string `json:"sign_cert_sn"`
  16033. SignCertDn string `json:"sign_cert_dn"`
  16034. } `json:"output"`
  16035. RefmsgTime string `json:"refmsg_time"`
  16036. RespondTime string `json:"respond_time"`
  16037. Signtype interface{} `json:"signtype"`
  16038. WarnMsg interface{} `json:"warn_msg"`
  16039. }
  16040. type Result003 struct {
  16041. Cainfo interface{} `json:"cainfo"`
  16042. ErrMsg string `json:"err_msg"`
  16043. InfRefmsgid string `json:"inf_refmsgid"`
  16044. Infcode int64 `json:"infcode"`
  16045. Output struct {
  16046. HiRxno string `json:"hi_rxno"`
  16047. RxStasCodg string `json:"rx_stas_codg"`
  16048. RxStasName string `json:"rx_stas_name"`
  16049. } `json:"output"`
  16050. RefmsgTime string `json:"refmsg_time"`
  16051. RespondTime string `json:"respond_time"`
  16052. Signtype interface{} `json:"signtype"`
  16053. WarnMsg interface{} `json:"warn_msg"`
  16054. }
  16055. type ResultEleven struct {
  16056. Cainfo string `json:"cainfo"`
  16057. ErrMsg string `json:"err_msg"`
  16058. InfRefmsgid string `json:"inf_refmsgid"`
  16059. Infcode int64 `json:"infcode"`
  16060. Output struct {
  16061. Setlinfo struct {
  16062. SetlTime string `json:"setl_time"`
  16063. CvlservPay float64 `json:"cvlserv_pay"`
  16064. Year string `json:"year"`
  16065. MedType string `json:"med_type"`
  16066. PsnPay float64 `json:"psn_pay"`
  16067. OpterID string `json:"opter_id"`
  16068. Begndate string `json:"begndate"`
  16069. FlxempeFlag string `json:"flxempe_flag"`
  16070. HifmiPay float64 `json:"hifmi_pay"`
  16071. PsnNo string `json:"psn_no"`
  16072. ActPayDedc float64 `json:"act_pay_dedc"`
  16073. MedinsSetlID interface{} `json:"medins_setl_id"`
  16074. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16075. ClrWay string `json:"clr_way"`
  16076. OthPay float64 `json:"oth_pay"`
  16077. Gend string `json:"gend"`
  16078. MdtrtID string `json:"mdtrt_id"`
  16079. AcctPay float64 `json:"acct_pay"`
  16080. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16081. Insutype string `json:"insutype"`
  16082. Invono interface{} `json:"invono"`
  16083. Enddate string `json:"enddate"`
  16084. CashPayamt float64 `json:"cash_payamt"`
  16085. PsnType string `json:"psn_type"`
  16086. FixmedinsName string `json:"fixmedins_name"`
  16087. HifpPay float64 `json:"hifp_pay"`
  16088. NewFlag interface{} `json:"new_flag"`
  16089. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16090. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16091. PayLoc string `json:"pay_loc"`
  16092. ClrType string `json:"clr_type"`
  16093. RefdSetlFlag string `json:"refd_setl_flag"`
  16094. CvlservFlag string `json:"cvlserv_flag"`
  16095. EmpName string `json:"emp_name"`
  16096. Brdy string `json:"brdy"`
  16097. Naty string `json:"naty"`
  16098. Certno string `json:"certno"`
  16099. DiseCode string `json:"dise_code"`
  16100. FixmedinsCode string `json:"fixmedins_code"`
  16101. DedcHospLv string `json:"dedc_hosp_lv"`
  16102. OpterName string `json:"opter_name"`
  16103. Balc float64 `json:"balc"`
  16104. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16105. PsnCertType string `json:"psn_cert_type"`
  16106. HifobPay float64 `json:"hifob_pay"`
  16107. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16108. HifesPay float64 `json:"hifes_pay"`
  16109. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16110. OptTime string `json:"opt_time"`
  16111. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16112. SetlID string `json:"setl_id"`
  16113. MafPay float64 `json:"maf_pay"`
  16114. PsnName string `json:"psn_name"`
  16115. InsuOptins interface{} `json:"insu_optins"`
  16116. PrefFundPay interface{} `json:"pref_fund_pay"`
  16117. ClrOptins string `json:"clr_optins"`
  16118. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16119. DiseName string `json:"dise_name"`
  16120. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16121. Age float64 `json:"age"`
  16122. DtrtCertType string `json:"dtrt_cert_type"`
  16123. HospLv string `json:"hosp_lv"`
  16124. PsnCashPay float64 `json:"psn_cash_pay"`
  16125. } `json:"setlinfo"`
  16126. } `json:"output"`
  16127. RefmsgTime string `json:"refmsg_time"`
  16128. RespondTime string `json:"respond_time"`
  16129. Signtype interface{} `json:"signtype"`
  16130. WarnMsg interface{} `json:"warn_msg"`
  16131. }
  16132. type ResultElevenah struct {
  16133. Cainfo string `json:"cainfo"`
  16134. ErrMsg string `json:"err_msg"`
  16135. InfRefmsgid string `json:"inf_refmsgid"`
  16136. Infcode int64 `json:"infcode"`
  16137. Output struct {
  16138. Setlinfo struct {
  16139. SetlTime int64 `json:"setl_time"`
  16140. CvlservPay float64 `json:"cvlserv_pay"`
  16141. Year string `json:"year"`
  16142. MedType string `json:"med_type"`
  16143. PsnPay float64 `json:"psn_pay"`
  16144. OpterID string `json:"opter_id"`
  16145. Begndate int64 `json:"begndate"`
  16146. FlxempeFlag string `json:"flxempe_flag"`
  16147. HifmiPay float64 `json:"hifmi_pay"`
  16148. PsnNo string `json:"psn_no"`
  16149. ActPayDedc float64 `json:"act_pay_dedc"`
  16150. MedinsSetlID interface{} `json:"medins_setl_id"`
  16151. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16152. ClrWay string `json:"clr_way"`
  16153. OthPay float64 `json:"oth_pay"`
  16154. Gend string `json:"gend"`
  16155. MdtrtID string `json:"mdtrt_id"`
  16156. AcctPay float64 `json:"acct_pay"`
  16157. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16158. Insutype string `json:"insutype"`
  16159. Invono interface{} `json:"invono"`
  16160. Enddate int64 `json:"enddate"`
  16161. CashPayamt float64 `json:"cash_payamt"`
  16162. PsnType string `json:"psn_type"`
  16163. FixmedinsName string `json:"fixmedins_name"`
  16164. HifpPay float64 `json:"hifp_pay"`
  16165. NewFlag interface{} `json:"new_flag"`
  16166. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16167. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16168. PayLoc string `json:"pay_loc"`
  16169. ClrType string `json:"clr_type"`
  16170. RefdSetlFlag string `json:"refd_setl_flag"`
  16171. CvlservFlag string `json:"cvlserv_flag"`
  16172. EmpName string `json:"emp_name"`
  16173. Brdy int64 `json:"brdy"`
  16174. Naty string `json:"naty"`
  16175. Certno string `json:"certno"`
  16176. DiseCode string `json:"dise_code"`
  16177. FixmedinsCode string `json:"fixmedins_code"`
  16178. DedcHospLv string `json:"dedc_hosp_lv"`
  16179. OpterName string `json:"opter_name"`
  16180. Balc float64 `json:"balc"`
  16181. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16182. PsnCertType string `json:"psn_cert_type"`
  16183. HifobPay float64 `json:"hifob_pay"`
  16184. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16185. HifesPay float64 `json:"hifes_pay"`
  16186. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16187. OptTime int64 `json:"opt_time"`
  16188. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16189. SetlID string `json:"setl_id"`
  16190. MafPay float64 `json:"maf_pay"`
  16191. PsnName string `json:"psn_name"`
  16192. InsuOptins interface{} `json:"insu_optins"`
  16193. PrefFundPay interface{} `json:"pref_fund_pay"`
  16194. ClrOptins string `json:"clr_optins"`
  16195. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16196. DiseName string `json:"dise_name"`
  16197. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16198. Age float64 `json:"age"`
  16199. DtrtCertType string `json:"dtrt_cert_type"`
  16200. HospLv string `json:"hosp_lv"`
  16201. PsnCashPay float64 `json:"psn_cash_pay"`
  16202. } `json:"setlinfo"`
  16203. } `json:"output"`
  16204. RefmsgTime string `json:"refmsg_time"`
  16205. RespondTime string `json:"respond_time"`
  16206. Signtype interface{} `json:"signtype"`
  16207. WarnMsg interface{} `json:"warn_msg"`
  16208. }
  16209. type ResultEleven10265 struct {
  16210. Cainfo string `json:"cainfo"`
  16211. ErrMsg string `json:"err_msg"`
  16212. InfRefmsgid string `json:"inf_refmsgid"`
  16213. Infcode string `json:"infcode"`
  16214. Output struct {
  16215. Setlinfo struct {
  16216. SetlTime string `json:"setl_time"`
  16217. CvlservPay float64 `json:"cvlserv_pay"`
  16218. Year string `json:"year"`
  16219. MedType string `json:"med_type"`
  16220. PsnPay float64 `json:"psn_pay"`
  16221. OpterID string `json:"opter_id"`
  16222. Begndate string `json:"begndate"`
  16223. FlxempeFlag string `json:"flxempe_flag"`
  16224. HifmiPay float64 `json:"hifmi_pay"`
  16225. PsnNo string `json:"psn_no"`
  16226. ActPayDedc float64 `json:"act_pay_dedc"`
  16227. MedinsSetlID interface{} `json:"medins_setl_id"`
  16228. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  16229. ClrWay string `json:"clr_way"`
  16230. OthPay float64 `json:"oth_pay"`
  16231. Gend string `json:"gend"`
  16232. MdtrtID string `json:"mdtrt_id"`
  16233. AcctPay float64 `json:"acct_pay"`
  16234. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16235. Insutype string `json:"insutype"`
  16236. Invono interface{} `json:"invono"`
  16237. Enddate string `json:"enddate"`
  16238. CashPayamt float64 `json:"cash_payamt"`
  16239. PsnType string `json:"psn_type"`
  16240. FixmedinsName string `json:"fixmedins_name"`
  16241. HifpPay float64 `json:"hifp_pay"`
  16242. NewFlag interface{} `json:"new_flag"`
  16243. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16244. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16245. PayLoc string `json:"pay_loc"`
  16246. ClrType string `json:"clr_type"`
  16247. RefdSetlFlag string `json:"refd_setl_flag"`
  16248. CvlservFlag string `json:"cvlserv_flag"`
  16249. EmpName string `json:"emp_name"`
  16250. Brdy string `json:"brdy"`
  16251. Naty string `json:"naty"`
  16252. Certno string `json:"certno"`
  16253. DiseCode string `json:"dise_code"`
  16254. FixmedinsCode string `json:"fixmedins_code"`
  16255. DedcHospLv string `json:"dedc_hosp_lv"`
  16256. OpterName string `json:"opter_name"`
  16257. Balc float64 `json:"balc"`
  16258. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  16259. PsnCertType string `json:"psn_cert_type"`
  16260. HifobPay float64 `json:"hifob_pay"`
  16261. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16262. HifesPay float64 `json:"hifes_pay"`
  16263. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16264. OptTime string `json:"opt_time"`
  16265. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16266. SetlID string `json:"setl_id"`
  16267. MafPay float64 `json:"maf_pay"`
  16268. PsnName string `json:"psn_name"`
  16269. InsuOptins interface{} `json:"insu_optins"`
  16270. PrefFundPay interface{} `json:"pref_fund_pay"`
  16271. ClrOptins string `json:"clr_optins"`
  16272. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  16273. DiseName string `json:"dise_name"`
  16274. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  16275. Age float64 `json:"age"`
  16276. DtrtCertType string `json:"dtrt_cert_type"`
  16277. HospLv string `json:"hosp_lv"`
  16278. PsnCashPay float64 `json:"psn_cash_pay"`
  16279. } `json:"setlinfo"`
  16280. } `json:"output"`
  16281. RefmsgTime string `json:"refmsg_time"`
  16282. RespondTime string `json:"respond_time"`
  16283. Signtype interface{} `json:"signtype"`
  16284. WarnMsg interface{} `json:"warn_msg"`
  16285. }
  16286. type ResultTwelve struct {
  16287. Cainfo string `json:"cainfo"`
  16288. ErrMsg string `json:"err_msg"`
  16289. InfRefmsgid string `json:"inf_refmsgid"`
  16290. Infcode int64 `json:"infcode"`
  16291. Output struct {
  16292. MdtrtId string `json:"mdtrt_id"`
  16293. ChrgBchno string `json:"chrg_bchno"`
  16294. PsnNo string `json:"psn_no"`
  16295. } `json:"output"`
  16296. RefmsgTime string `json:"refmsg_time"`
  16297. RespondTime string `json:"respond_time"`
  16298. Signtype interface{} `json:"signtype"`
  16299. WarnMsg interface{} `json:"warn_msg"`
  16300. }
  16301. type ResultThirteen struct {
  16302. ErrMsg string `json:"err_msg"`
  16303. InfRefmsgid string `json:"inf_refmsgid"`
  16304. Infcode int64 `json:"infcode"`
  16305. Output struct {
  16306. Result struct {
  16307. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16308. } `json:"result"`
  16309. } `json:"output"`
  16310. RefmsgTime string `json:"refmsg_time"`
  16311. RespondTime string `json:"respond_time"`
  16312. Signtype interface{} `json:"signtype"`
  16313. WarnInfo interface{} `json:"warn_info"`
  16314. }
  16315. type ResultThirteen10265 struct {
  16316. ErrMsg string `json:"err_msg"`
  16317. InfRefmsgid string `json:"inf_refmsgid"`
  16318. Infcode string `json:"infcode"`
  16319. Output struct {
  16320. Result struct {
  16321. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  16322. } `json:"result"`
  16323. } `json:"output"`
  16324. RefmsgTime string `json:"refmsg_time"`
  16325. RespondTime string `json:"respond_time"`
  16326. Signtype interface{} `json:"signtype"`
  16327. WarnInfo interface{} `json:"warn_info"`
  16328. }
  16329. type ResultFourteen struct {
  16330. ErrMsg string `json:"err_msg"`
  16331. InfRefmsgid string `json:"inf_refmsgid"`
  16332. Infcode int64 `json:"infcode"`
  16333. Output struct {
  16334. } `json:"output"`
  16335. RefmsgTime string `json:"refmsg_time"`
  16336. RespondTime string `json:"respond_time"`
  16337. Signtype interface{} `json:"signtype"`
  16338. WarnInfo interface{} `json:"warn_info"`
  16339. }
  16340. type ResultCFYLJG001 struct {
  16341. ErrMsg string `json:"err_msg"`
  16342. InfRefmsgid string `json:"inf_refmsgid"`
  16343. Infcode int64 `json:"infcode"`
  16344. Output struct {
  16345. RxTraceCode string `json:"rx_trace_code"`
  16346. HiRxno string `json:"hi_rxno"`
  16347. } `json:"output"`
  16348. RefmsgTime string `json:"refmsg_time"`
  16349. RespondTime string `json:"respond_time"`
  16350. Signtype interface{} `json:"signtype"`
  16351. WarnInfo interface{} `json:"warn_info"`
  16352. }
  16353. type ResultCFYLJG007 struct {
  16354. ErrMsg string `json:"err_msg"`
  16355. InfRefmsgid string `json:"inf_refmsgid"`
  16356. Infcode int64 `json:"infcode"`
  16357. Output struct {
  16358. HiRxno string `json:"hi_rxno"`
  16359. RxStasName string `json:"rx_stas_name"`
  16360. RxUsedStasCodg string `json:"rx_used_stas_codg"`
  16361. Seltdelts []interface{} `json:"seltdelts"`
  16362. RxUsedStasName string `json:"rx_used_stas_name"`
  16363. RxStasCodg string `json:"rx_stas_codg"`
  16364. } `json:"output"`
  16365. RefmsgTime string `json:"refmsg_time"`
  16366. RespondTime string `json:"respond_time"`
  16367. Signtype interface{} `json:"signtype"`
  16368. WarnInfo interface{} `json:"warn_info"`
  16369. }
  16370. type ResultCFYLJG002 struct {
  16371. ErrMsg string `json:"err_msg"`
  16372. InfRefmsgid string `json:"inf_refmsgid"`
  16373. Infcode int64 `json:"infcode"`
  16374. Output struct {
  16375. RxFile string `json:"rx_file"`
  16376. SignDigest string `json:"sign_digest"`
  16377. SignCertSn string `json:"sign_cert_sn"`
  16378. SignCertDn string `json:"sign_cert_dn"`
  16379. } `json:"output"`
  16380. RefmsgTime string `json:"refmsg_time"`
  16381. RespondTime string `json:"respond_time"`
  16382. Signtype interface{} `json:"signtype"`
  16383. WarnInfo interface{} `json:"warn_info"`
  16384. }
  16385. type ResultCFYLJG003 struct {
  16386. ErrMsg string `json:"err_msg"`
  16387. InfRefmsgid string `json:"inf_refmsgid"`
  16388. Infcode int64 `json:"infcode"`
  16389. Output struct {
  16390. HiRxno string `json:"hi_rxno"`
  16391. RxStasCodg string `json:"rx_stas_codg"`
  16392. RxStasName string `json:"rx_stas_name"`
  16393. } `json:"output"`
  16394. RefmsgTime string `json:"refmsg_time"`
  16395. RespondTime string `json:"respond_time"`
  16396. Signtype interface{} `json:"signtype"`
  16397. WarnInfo interface{} `json:"warn_info"`
  16398. }
  16399. type ResultCFYLJG004 struct {
  16400. ErrMsg string `json:"err_msg"`
  16401. InfRefmsgid string `json:"inf_refmsgid"`
  16402. Infcode int64 `json:"infcode"`
  16403. Output struct {
  16404. HiRxno string `json:"hi_rxno"`
  16405. RxStasCodg string `json:"rx_stas_codg"`
  16406. RxStasName string `json:"rx_stas_name"`
  16407. } `json:"output"`
  16408. RefmsgTime string `json:"refmsg_time"`
  16409. RespondTime string `json:"respond_time"`
  16410. Signtype interface{} `json:"signtype"`
  16411. WarnInfo interface{} `json:"warn_info"`
  16412. }
  16413. type ResultCFYLJG008 struct {
  16414. ErrMsg string `json:"err_msg"`
  16415. InfRefmsgid string `json:"inf_refmsgid"`
  16416. Infcode int64 `json:"infcode"`
  16417. Output struct {
  16418. PoolareaNo string `json:"poolareaNo"`
  16419. AdmdvsName string `json:"admdvsName"`
  16420. Count string `json:"count"`
  16421. } `json:"output"`
  16422. RefmsgTime string `json:"refmsg_time"`
  16423. RespondTime string `json:"respond_time"`
  16424. Signtype interface{} `json:"signtype"`
  16425. WarnInfo interface{} `json:"warn_info"`
  16426. }
  16427. type ResultCFYLJG005 struct {
  16428. ErrMsg string `json:"err_msg"`
  16429. InfRefmsgid string `json:"inf_refmsgid"`
  16430. Infcode int64 `json:"infcode"`
  16431. Output struct {
  16432. HiRxNo string `json:"hi_rxno"`
  16433. FixMedinsCode string `json:"fixmedins_code"`
  16434. FixMedinsName string `json:"fixmedins_name"`
  16435. RxStasCodg string `json:"rx_stas_codg"`
  16436. RxStasName string `json:"rx_stas_name"`
  16437. RxUserdStasCog string `json:"rx_userd_stas_cog"`
  16438. RxUserdStasName string `json:"rx_userd_stas_name"`
  16439. PrscTime string `json:"prsc_time"`
  16440. RxDrugCnt float64 `json:"rx_drug_cnt"`
  16441. RxUsedWayCodg string `json:"rx_used_way_codg"`
  16442. RxUsedWayName string `json:"rx_used_way_name"`
  16443. RxFrquCodg string `json:"rx_frqu_codg"`
  16444. RxFrquName string `json:"rx_frqu_name"`
  16445. RxDosunt string `json:"rx_dosunt"`
  16446. RxDoscnt float64 `json:"rx_doscnt"`
  16447. RxDrordDscr string `json:"rx_drord_dscr"`
  16448. ValiDays int64 `json:"vali_days"`
  16449. ValiEndTime string `json:"vali_end_time"`
  16450. ReptFlag string `json:"rept_flag"`
  16451. MaxReptCnt int64 `json:"max_rept_cnt"`
  16452. ReptdCnt int64 `json:"reptd_cnt"`
  16453. MinInrvDays int64 `json:"min_inrv_days"`
  16454. RxTypeCode string `json:"rx_type_code"`
  16455. RxTypeName string `json:"rx_type_name"`
  16456. LongRxFlag string `json:"long_rx_flag"`
  16457. RxDetlList []struct {
  16458. MedListCodg string `json:"med_list_codg"`
  16459. MedinsListCodg string `json:"medins_list_codg"`
  16460. HospPrepFlag string `json:"hosp_prep_flag"`
  16461. RxItemTypeCode string `json:"rx_item_type_code"`
  16462. RxItemTypeName string `json:"rx_item_type_name"`
  16463. TcmDrugTypeName string `json:"tcmdrug_type_name"`
  16464. TcmDrugTypeCode string `json:"tcmdrug_type_code"`
  16465. TcmHerbFoote string `json:"tcmherb_foote"`
  16466. MednTypeCode string `json:"medn_type_code"`
  16467. MednTypeName string `json:"medn_type_name"`
  16468. MainMedcFlag string `json:"main_medc_flag"`
  16469. UrgtFlag string `json:"urgt_flag"`
  16470. BasMednFlag string `json:"bas_medn_flag"`
  16471. ImpDrugFlag string `json:"imp_drug_flag"`
  16472. ProdBarc string `json:"prod_barc"`
  16473. DrugProdname string `json:"drug_prodname"`
  16474. GennameCodg string `json:"genname_codg"`
  16475. DrugGenname string `json:"drug_genname"`
  16476. DrugDosform string `json:"drug_dosform"`
  16477. DrugSpec string `json:"drug_spec"`
  16478. PrdrName string `json:"prdr_name"`
  16479. MedcWayCodg string `json:"medc_way_codg"`
  16480. MedcWayDscr string `json:"medc_way_dscr"`
  16481. MedcBegntime string `json:"medc_begntime"`
  16482. MedcEndtime string `json:"medc_endtime"`
  16483. MedcDays float64 `json:"medc_days"`
  16484. DrugPric float64 `json:"drug_pric"`
  16485. DrugSumamt float64 `json:"drug_sumamt"`
  16486. DrugCnt float64 `json:"drug_cnt"`
  16487. DrugDosunt string `json:"drug_dosunt"`
  16488. SinDoscnt float64 `json:"sin_doscnt"`
  16489. SinDosunt string `json:"sin_dosunt"`
  16490. UsedFrquCodg string `json:"used_frqu_codg"`
  16491. UsedFrquName string `json:"used_frqu_name"`
  16492. DrugTotlcnt string `json:"drug_totlcnt"`
  16493. DrugTotlcntEmp string `json:"drug_totlcnt_emp"`
  16494. DiseCodg string `json:"dise_codg"`
  16495. HospApprFlag string `json:"hosp_appr_flag"`
  16496. } `json:"rx_detl_list"`
  16497. RxOtpinfo struct {
  16498. MedType string `json:"med_type"`
  16499. IptOtpNo string `json:"ipt_otp_no"`
  16500. OtpIptFlag string `json:"otp_ipt_flag"`
  16501. PatnName string `json:"patn_name"`
  16502. PatnAge float64 `json:"patn_age"`
  16503. PatnHgt float64 `json:"patn_hgt"`
  16504. PatnWt float64 `json:"patn_wt"`
  16505. Gend string `json:"gend"`
  16506. GesoVal float64 `json:"geso_val"`
  16507. NwbFlag string `json:"nwb_flag"`
  16508. NwbAge string `json:"nwb_age"`
  16509. SuckPrdFlag string `json:"suck_prd_flag"`
  16510. AlgsHis string `json:"algs_his"`
  16511. Insutype string `json:"insutype"`
  16512. PrscDeptName string `json:"prsc_dept_name"`
  16513. PrscDrName string `json:"prsc_dr_name"`
  16514. PharName string `json:"phar_name"`
  16515. PharChkTime string `json:"phar_chk_time"`
  16516. MdtrtTime string `json:"mdtrt_time"`
  16517. DiseCodg string `json:"dise_codg"`
  16518. DiseName string `json:"dise_name"`
  16519. SpDiseFlag string `json:"sp_dise_flag"`
  16520. MaindiagCode string `json:"maindiag_code"`
  16521. MaindiagName string `json:"maindiag_name"`
  16522. DiseCondDscr string `json:"dise_cond_dscr"`
  16523. FstdiagFlag string `json:"fstdiag_flag"`
  16524. } `json:"rx_otpinfo"`
  16525. RxDiseList []struct {
  16526. DiagType string `json:"diag_type"`
  16527. MaindiagFlag string `json:"maindiag_flag"`
  16528. DiagSrtNo string `json:"diag_srt_no"`
  16529. DiagCode string `json:"diag_code"`
  16530. DiagName string `json:"diag_name"`
  16531. DiagDept string `json:"diag_dept"`
  16532. DiagDrNo string `json:"diag_dr_no"`
  16533. DiagDrName string `json:"diag_dr_name"`
  16534. DiagTime string `json:"diag_time"`
  16535. TcmDiseCode string `json:"tcm_dise_code"`
  16536. TcmDiseName string `json:"tcm_dise_name"`
  16537. TcmSympCode string `json:"tcmsymp_code"`
  16538. TcmSymp string `json:"tcmsymp"`
  16539. } `json:"rx_dise_list"`
  16540. } `json:"output"`
  16541. RefmsgTime string `json:"refmsg_time"`
  16542. RespondTime string `json:"respond_time"`
  16543. Signtype interface{} `json:"signtype"`
  16544. WarnInfo interface{} `json:"warn_info"`
  16545. }
  16546. type ResultCFYLJG006 struct {
  16547. ErrMsg string `json:"err_msg"`
  16548. InfRefmsgid string `json:"inf_refmsgid"`
  16549. Infcode int64 `json:"infcode"`
  16550. Output struct {
  16551. HiRxNo string `json:"hi_rxno"`
  16552. PharCode string `json:"phar_code"`
  16553. PharName string `json:"phar_name"`
  16554. RxChkOpnn string `json:"rx_chk_opnn"`
  16555. RxChkTime string `json:"rx_chk_time"`
  16556. RxChkStasCodg string `json:"rx_chk_stas_codg"`
  16557. RxChkStasName string `json:"rx_chk_stas_name"`
  16558. RxStasCodg string `json:"rx_stas_codg"`
  16559. RxStasName string `json:"rx_stas_name"`
  16560. } `json:"output"`
  16561. RefmsgTime string `json:"refmsg_time"`
  16562. RespondTime string `json:"respond_time"`
  16563. Signtype interface{} `json:"signtype"`
  16564. WarnInfo interface{} `json:"warn_info"`
  16565. }
  16566. type ResultFourteen10265 struct {
  16567. ErrMsg string `json:"err_msg"`
  16568. InfRefmsgid string `json:"inf_refmsgid"`
  16569. Infcode string `json:"infcode"`
  16570. Output struct {
  16571. } `json:"output"`
  16572. RefmsgTime string `json:"refmsg_time"`
  16573. RespondTime string `json:"respond_time"`
  16574. Signtype interface{} `json:"signtype"`
  16575. WarnInfo interface{} `json:"warn_info"`
  16576. }
  16577. type ResultSixteen struct {
  16578. Cainfo string `json:"cainfo"`
  16579. ErrMsg string `json:"err_msg"`
  16580. InfRefmsgid string `json:"inf_refmsgid"`
  16581. Infcode int64 `json:"infcode"`
  16582. Output struct {
  16583. Setlinfo struct {
  16584. MdtrtID string `json:"mdtrt_id"`
  16585. SetlID string `json:"setl_id"`
  16586. ClrOptins string `json:"clr_optins"`
  16587. SetlTime string `json:"setl_time"`
  16588. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16589. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16590. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16591. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16592. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16593. ActPayDedc float64 `json:"act_pay_dedc"`
  16594. HifpPay float64 `json:"hifp_pay"`
  16595. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16596. Lfpay float64 `json:"selfpay"`
  16597. CvlservPay float64 `json:"cvlserv_pay"`
  16598. HifesPay float64 `json:"hifes_pay"`
  16599. HifmiPay float64 `json:"hifmi_pay"`
  16600. HifobPay float64 `json:"hifob_pay"`
  16601. MafPay float64 `json:"maf_pay"`
  16602. OthPay float64 `json:"oth_pay"`
  16603. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16604. PsnPartAmt float64 `json:"psn_part_amt"`
  16605. AcctPay float64 `json:"acct_pay"`
  16606. Balc float64 `json:"balc"`
  16607. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16608. HospPartAmt float64 `json:"hosp_part_amt"`
  16609. MedinsSetlID string `json:"medins_setl_id"`
  16610. PdnCashPay string `json:"pdn_cash_pay"`
  16611. } `json:"setlinfo"`
  16612. } `json:"output"`
  16613. RefmsgTime string `json:"refmsg_time"`
  16614. RespondTime string `json:"respond_time"`
  16615. Signtype interface{} `json:"signtype"`
  16616. WarnMsg interface{} `json:"warn_msg"`
  16617. }
  16618. type ResultSixteen10265 struct {
  16619. Cainfo string `json:"cainfo"`
  16620. ErrMsg string `json:"err_msg"`
  16621. InfRefmsgid string `json:"inf_refmsgid"`
  16622. Infcode string `json:"infcode"`
  16623. Output struct {
  16624. Setlinfo struct {
  16625. MdtrtID string `json:"mdtrt_id"`
  16626. SetlID string `json:"setl_id"`
  16627. ClrOptins string `json:"clr_optins"`
  16628. SetlTime string `json:"setl_time"`
  16629. MedfeeSumamt float64 `json:"medfee_sumamt"`
  16630. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  16631. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  16632. PreselfpayAmt float64 `json:"preselfpay_amt"`
  16633. InscpScpAmt float64 `json:"inscp_scp_amt"`
  16634. ActPayDedc float64 `json:"act_pay_dedc"`
  16635. HifpPay float64 `json:"hifp_pay"`
  16636. PoolPropSe float64 `json:"pool_prop_selfpay"`
  16637. Lfpay float64 `json:"selfpay"`
  16638. CvlservPay float64 `json:"cvlserv_pay"`
  16639. HifesPay float64 `json:"hifes_pay"`
  16640. HifmiPay float64 `json:"hifmi_pay"`
  16641. HifobPay float64 `json:"hifob_pay"`
  16642. MafPay float64 `json:"maf_pay"`
  16643. OthPay float64 `json:"oth_pay"`
  16644. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  16645. PsnPartAmt float64 `json:"psn_part_amt"`
  16646. AcctPay float64 `json:"acct_pay"`
  16647. Balc float64 `json:"balc"`
  16648. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  16649. HospPartAmt float64 `json:"hosp_part_amt"`
  16650. MedinsSetlID string `json:"medins_setl_id"`
  16651. PdnCashPay string `json:"pdn_cash_pay"`
  16652. } `json:"setlinfo"`
  16653. } `json:"output"`
  16654. RefmsgTime string `json:"refmsg_time"`
  16655. RespondTime string `json:"respond_time"`
  16656. Signtype interface{} `json:"signtype"`
  16657. WarnMsg interface{} `json:"warn_msg"`
  16658. }
  16659. type ResultSixteen10265Two struct {
  16660. Cainfo string `json:"cainfo"`
  16661. ErrMsg string `json:"err_msg"`
  16662. InfRefmsgid string `json:"inf_refmsgid"`
  16663. Infcode string `json:"infcode"`
  16664. Output struct {
  16665. Setlinfo interface{} `json:"setlinfo"`
  16666. } `json:"output"`
  16667. RefmsgTime string `json:"refmsg_time"`
  16668. RespondTime string `json:"respond_time"`
  16669. Signtype interface{} `json:"signtype"`
  16670. WarnMsg interface{} `json:"warn_msg"`
  16671. }
  16672. type ResultgzSixteen10265Two struct {
  16673. Cainfo string `json:"cainfo"`
  16674. ErrMsg string `json:"err_msg"`
  16675. InfRefmsgid string `json:"inf_refmsgid"`
  16676. Infcode int64 `json:"infcode"`
  16677. Output struct {
  16678. Setlinfo interface{} `json:"setlinfo"`
  16679. } `json:"output"`
  16680. RefmsgTime string `json:"refmsg_time"`
  16681. RespondTime string `json:"respond_time"`
  16682. Signtype interface{} `json:"signtype"`
  16683. WarnMsg interface{} `json:"warn_msg"`
  16684. }
  16685. type ResultSeventeen struct {
  16686. ErrMsg string `json:"err_msg"`
  16687. InfRefmsgid string `json:"inf_refmsgid"`
  16688. Infcode int64 `json:"infcode"`
  16689. Output struct {
  16690. SetlListId string `json:"setl_list_id"`
  16691. } `json:"output"`
  16692. RefmsgTime string `json:"refmsg_time"`
  16693. RespondTime string `json:"respond_time"`
  16694. Signtype string `json:"signtype"`
  16695. WarnInfo string `json:"warn_info"`
  16696. }
  16697. type ResultSeventeenOther struct {
  16698. ErrMsg string `json:"err_msg"`
  16699. InfRefmsgid string `json:"inf_refmsgid"`
  16700. Infcode string `json:"infcode"`
  16701. Output struct {
  16702. SetlListId string `json:"setl_list_id"`
  16703. } `json:"output"`
  16704. RefmsgTime string `json:"refmsg_time"`
  16705. RespondTime string `json:"respond_time"`
  16706. Signtype string `json:"signtype"`
  16707. WarnInfo string `json:"warn_info"`
  16708. }
  16709. type Result90991 struct {
  16710. ErrMsg string `json:"err_msg"`
  16711. InfRefmsgid string `json:"inf_refmsgid"`
  16712. Infcode int64 `json:"infcode"`
  16713. Output struct {
  16714. Result struct {
  16715. PsnNo string `json:"psn_no"`
  16716. CardStat string `json:"card_stat"`
  16717. Certno string `json:"certno"`
  16718. PsnName string `json:"psn_name"`
  16719. CheckStat string `json:"check_stat"`
  16720. SscnoCheckStat string `json:"sscno_check_stat"`
  16721. } `json:"result"`
  16722. } `json:"output"`
  16723. RefmsgTime string `json:"refmsg_time"`
  16724. RespondTime string `json:"respond_time"`
  16725. Signtype interface{} `json:"signtype"`
  16726. WarnInfo interface{} `json:"warn_info"`
  16727. }
  16728. type Result90100 struct {
  16729. ErrMsg string `json:"err_msg"`
  16730. InfRefmsgid string `json:"inf_refmsgid"`
  16731. Infcode int64 `json:"infcode"`
  16732. Output struct {
  16733. PoolareaNo string `json:"poolarea_no"`
  16734. PoolareaNoName string `json:"poolarea_no_name"`
  16735. Insutype string `json:"insutype"`
  16736. InsutypeName string `json:"insutype_name"`
  16737. ClctType string `json:"clct_type"`
  16738. ClctTypeName string `json:"clct_type_name"`
  16739. ClctFlag string `json:"clct_flag"`
  16740. ClctFlagName string `json:"clct_flag_name"`
  16741. AccrymBegn string `json:"accrym_begn"`
  16742. AccrymEnd string `json:"accrym_end"`
  16743. ClctTime string `json:"clct_time"`
  16744. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  16745. } `json:"output"`
  16746. RefmsgTime string `json:"refmsg_time"`
  16747. RespondTime string `json:"respond_time"`
  16748. Signtype interface{} `json:"signtype"`
  16749. WarnInfo interface{} `json:"warn_info"`
  16750. }
  16751. type Custom struct {
  16752. DetItemFeeSumamt string
  16753. Cut string
  16754. FeedetlSn string
  16755. Price string
  16756. MedListCodg string
  16757. Type int64
  16758. AdviceId int64
  16759. ProjectId int64
  16760. ItemId int64
  16761. }
  16762. type Result5301 struct {
  16763. ErrMsg string `json:"err_msg"`
  16764. InfRefmsgid string `json:"inf_refmsgid"`
  16765. Infcode int64 `json:"infcode"`
  16766. Output struct {
  16767. Result []struct {
  16768. OpspDiseCode string `json:"opsp_dise_code"`
  16769. OpspDiseName string `json:"opsp_dise_name"`
  16770. Begndate string `json:"begndate"`
  16771. Enddate string `json:"enddate"`
  16772. } `json:"feedetail"`
  16773. } `json:"output"`
  16774. RefmsgTime string `json:"refmsg_time"`
  16775. RespondTime string `json:"respond_time"`
  16776. Signtype interface{} `json:"signtype"`
  16777. WarnInfo interface{} `json:"warn_info"`
  16778. }
  16779. type Result5301For10265 struct {
  16780. ErrMsg string `json:"err_msg"`
  16781. InfRefmsgid string `json:"inf_refmsgid"`
  16782. Infcode string `json:"infcode"`
  16783. Output struct {
  16784. Result []struct {
  16785. OpspDiseCode string `json:"opsp_dise_code"`
  16786. OpspDiseName string `json:"opsp_dise_name"`
  16787. Begndate string `json:"begndate"`
  16788. Enddate string `json:"enddate"`
  16789. } `json:"feedetail"`
  16790. } `json:"output"`
  16791. RefmsgTime string `json:"refmsg_time"`
  16792. RespondTime string `json:"respond_time"`
  16793. Signtype interface{} `json:"signtype"`
  16794. WarnInfo interface{} `json:"warn_info"`
  16795. }
  16796. //获取个人信息----挂号-----上传就诊信息
  16797. func (c *HisApiController) GetRegisterInfo() {
  16798. id, _ := c.GetInt64("id")
  16799. record_time := c.GetString("record_time")
  16800. settlementValue, _ := c.GetInt64("settlement_value")
  16801. medical_insurance_card := c.GetString("medical_insurance_card")
  16802. name := c.GetString("name")
  16803. id_card_type, _ := c.GetInt64("id_card_type")
  16804. certificates, _ := c.GetInt64("certificates")
  16805. medical_care, _ := c.GetInt64("medical_care")
  16806. birthday := c.GetString("birthday")
  16807. id_card := c.GetString("id_card")
  16808. register_type, _ := c.GetInt64("register")
  16809. doctor, _ := c.GetInt64("doctor")
  16810. department, _ := c.GetInt64("department")
  16811. gender, _ := c.GetInt64("sex")
  16812. registration_fee, _ := c.GetFloat("registration_fee")
  16813. medical_expenses, _ := c.GetFloat("medical_expenses")
  16814. social_type, _ := c.GetInt64("social_type")
  16815. admin_user_id, _ := c.GetInt64("admin_user_id")
  16816. insuplc_admdvs := c.GetString("insuplc_admdvs")
  16817. mdtrt_type := c.GetString("mdtrt_type")
  16818. if id_card_type == 5 {
  16819. id_card_type = 4
  16820. }
  16821. timeLayout := "2006-01-02"
  16822. loc, _ := time.LoadLocation("Local")
  16823. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  16824. birthUnix := birthdays.Unix()
  16825. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  16826. if err != nil {
  16827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  16828. return
  16829. }
  16830. recordDateTime := theTime.Unix()
  16831. adminInfo := c.GetAdminUserInfo()
  16832. var patient service.Patients
  16833. if id == 0 {
  16834. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  16835. } else {
  16836. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  16837. }
  16838. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16839. if patientPrescription.ID == 0 {
  16840. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  16841. }
  16842. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  16843. if patient.ID == 0 {
  16844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  16845. return
  16846. }
  16847. if len(patient.IdCardNo) == 0 {
  16848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  16849. return
  16850. }
  16851. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  16852. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  16853. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  16854. //就诊结算未完成,不能进行二次挂号
  16855. //his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  16856. //if len(his) >= 1 {
  16857. // order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  16858. // if len(his) >= 1 && order.ID == 0 {
  16859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  16860. // return
  16861. // }
  16862. //}
  16863. //var register_log string
  16864. if config.IsOpen == 1 {
  16865. var res ResultTwo
  16866. var res10265 ResultTwo10265
  16867. var PsnNo string
  16868. var PsnCertType string
  16869. var Certno string
  16870. var PsnName string
  16871. var Gend string
  16872. var Naty string
  16873. var Brdy string
  16874. var Age float64
  16875. var infoStr string
  16876. var idetinfoStr string
  16877. var infocode int64
  16878. var verify_number string
  16879. fmt.Println(verify_number)
  16880. if miConfig.MdtrtareaAdmvs == "421300" || miConfig.MdtrtareaAdmvs == "420200" || miConfig.MdtrtareaAdmvs == "421182" || miConfig.MdtrtareaAdmvs == "420902" {
  16881. psn_info, _ := service.GetPsnByPatientId(id)
  16882. PsnNo = psn_info.PsnNo
  16883. PsnCertType = psn_info.PsnCertType
  16884. Certno = psn_info.Certno
  16885. PsnName = psn_info.PsnName
  16886. Gend = psn_info.Gend
  16887. Naty = psn_info.Naty
  16888. Brdy = psn_info.Brdy
  16889. Age = psn_info.Age
  16890. infoStr = psn_info.Insuinfo
  16891. idetinfoStr = psn_info.Idetinfo
  16892. infocode = 0
  16893. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16894. psn_info, _ := service.GetPsnByPatientId(id)
  16895. PsnNo = psn_info.PsnNo
  16896. PsnCertType = psn_info.PsnCertType
  16897. Certno = psn_info.Certno
  16898. PsnName = psn_info.PsnName
  16899. Gend = psn_info.Gend
  16900. Naty = psn_info.Naty
  16901. Brdy = psn_info.Brdy
  16902. Age = psn_info.Age
  16903. infoStr = psn_info.Insuinfo
  16904. idetinfoStr = psn_info.Idetinfo
  16905. infocode = 0
  16906. verify_number = psn_info.VerifyNumber
  16907. } else if miConfig.MdtrtareaAdmvs == "150499" {
  16908. if id_card_type == 2 {
  16909. //请求内网数据
  16910. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  16911. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  16912. "&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
  16913. resp, requestErr := http.Get(api)
  16914. if requestErr != nil {
  16915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16916. return
  16917. }
  16918. body, ioErr := ioutil.ReadAll(resp.Body)
  16919. if ioErr != nil {
  16920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16922. return
  16923. }
  16924. var respJSON map[string]interface{}
  16925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16928. return
  16929. }
  16930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16931. result_byte, _ := json.Marshal(respJSON)
  16932. result := string(result_byte)
  16933. var dat map[string]interface{}
  16934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16935. fmt.Println(dat)
  16936. } else {
  16937. fmt.Println(err)
  16938. }
  16939. userJSONBytes, _ := json.Marshal(dat)
  16940. var res ResultTwo
  16941. var resTwo10265 ResultTwo10265
  16942. if miConfig.Code == "H15049901371" {
  16943. if err := json.Unmarshal(userJSONBytes, &resTwo10265); err != nil {
  16944. utils.ErrorLog("解析失败:%v", err)
  16945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16946. return
  16947. }
  16948. Infcode, _ := strconv.ParseInt(resTwo10265.Infcode, 10, 64)
  16949. res.Infcode = Infcode
  16950. res.ErrMsg = resTwo10265.ErrMsg
  16951. res.Output = resTwo10265.Output
  16952. res.InfRefmsgid = resTwo10265.InfRefmsgid
  16953. res.RespondTime = resTwo10265.RespondTime
  16954. res.WarnInfo = resTwo10265.WarnInfo
  16955. } else {
  16956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16957. utils.ErrorLog("解析失败:%v", err)
  16958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16959. return
  16960. }
  16961. }
  16962. //var insutypes []string
  16963. //var insutype string
  16964. //var is390 int = 0
  16965. //var is310 int = 0
  16966. //for _, item := range res.Output.Iinfo {
  16967. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  16968. // insutypes = append(insutypes, item.Insutype)
  16969. // }
  16970. //}
  16971. //if len(insutypes) == 1 {
  16972. // insutype = insutypes[0]
  16973. //} else {
  16974. // for _, i := range insutypes {
  16975. // if i == "390" {
  16976. // is390 = 1
  16977. // }
  16978. //
  16979. // if i == "310" {
  16980. // is310 = 1
  16981. // }
  16982. // }
  16983. //}
  16984. //if is390 == 1 {
  16985. // insutype = "390"
  16986. //}
  16987. //if is310 == 1 {
  16988. // insutype = "310"
  16989. //}
  16990. //if len(insutypes) == 0 {
  16991. // insutype = "310"
  16992. //}
  16993. PsnNo = res.Output.Baseinfo.PsnNo
  16994. PsnCertType = res.Output.Baseinfo.PsnCertType
  16995. Certno = res.Output.Baseinfo.Certno
  16996. PsnName = res.Output.Baseinfo.PsnName
  16997. Gend = res.Output.Baseinfo.Gend
  16998. Naty = res.Output.Baseinfo.Naty
  16999. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17000. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17001. infoStr = string(Iinfos)
  17002. idetinfoStr = string(Idetinfos)
  17003. infocode = res.Infcode
  17004. //infocode = 0
  17005. //verify_number = psn_info.VerifyNumber
  17006. } else {
  17007. psn_info, _ := service.GetPsnByPatientId(id)
  17008. PsnNo = psn_info.PsnNo
  17009. PsnCertType = psn_info.PsnCertType
  17010. Certno = psn_info.Certno
  17011. PsnName = psn_info.PsnName
  17012. Gend = psn_info.Gend
  17013. Naty = psn_info.Naty
  17014. Brdy = psn_info.Brdy
  17015. Age = psn_info.Age
  17016. infoStr = psn_info.Insuinfo
  17017. idetinfoStr = psn_info.Idetinfo
  17018. infocode = 0
  17019. verify_number = psn_info.VerifyNumber
  17020. }
  17021. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17022. if id_card_type == 1 {
  17023. psn_info, _ := service.GetPsnByPatientId(id)
  17024. PsnNo = psn_info.PsnNo
  17025. PsnCertType = psn_info.PsnCertType
  17026. Certno = psn_info.Certno
  17027. PsnName = psn_info.PsnName
  17028. Gend = psn_info.Gend
  17029. Naty = psn_info.Naty
  17030. Brdy = psn_info.Brdy
  17031. Age = psn_info.Age
  17032. infoStr = psn_info.Insuinfo
  17033. idetinfoStr = psn_info.Idetinfo
  17034. infocode = 0
  17035. verify_number = psn_info.VerifyNumber
  17036. } else if id_card_type == 2 {
  17037. 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)
  17038. fmt.Println(errMsgLog)
  17039. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17040. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17041. utils.ErrorLog("解析失败:%v", err)
  17042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17043. return
  17044. }
  17045. PsnNo = res.Output.Baseinfo.PsnNo
  17046. PsnCertType = res.Output.Baseinfo.PsnCertType
  17047. Certno = res.Output.Baseinfo.Certno
  17048. PsnName = res.Output.Baseinfo.PsnName
  17049. Gend = res.Output.Baseinfo.Gend
  17050. Naty = res.Output.Baseinfo.Naty
  17051. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17052. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17053. infoStr = string(Iinfos)
  17054. idetinfoStr = string(Idetinfos)
  17055. infocode = res.Infcode
  17056. }
  17057. } else if miConfig.MdtrtareaAdmvs == "360302" {
  17058. if id_card_type == 1 {
  17059. psn_info, _ := service.GetPsnByPatientId(id)
  17060. PsnNo = psn_info.PsnNo
  17061. PsnCertType = psn_info.PsnCertType
  17062. Certno = psn_info.Certno
  17063. PsnName = psn_info.PsnName
  17064. Gend = psn_info.Gend
  17065. Naty = psn_info.Naty
  17066. Brdy = psn_info.Brdy
  17067. Age = psn_info.Age
  17068. infoStr = psn_info.Insuinfo
  17069. idetinfoStr = psn_info.Idetinfo
  17070. infocode = 0
  17071. verify_number = psn_info.VerifyNumber
  17072. } else if id_card_type == 2 {
  17073. 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, "")
  17074. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17075. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17076. utils.ErrorLog("解析失败:%v", err)
  17077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17078. return
  17079. }
  17080. PsnNo = res.Output.Baseinfo.PsnNo
  17081. PsnCertType = res.Output.Baseinfo.PsnCertType
  17082. Certno = res.Output.Baseinfo.Certno
  17083. PsnName = res.Output.Baseinfo.PsnName
  17084. Gend = res.Output.Baseinfo.Gend
  17085. Naty = res.Output.Baseinfo.Naty
  17086. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17087. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17088. infoStr = string(Iinfos)
  17089. idetinfoStr = string(Idetinfos)
  17090. infocode = res.Infcode
  17091. } else {
  17092. psn_info, _ := service.GetPsnByPatientId(id)
  17093. PsnNo = psn_info.PsnNo
  17094. PsnCertType = psn_info.PsnCertType
  17095. Certno = psn_info.Certno
  17096. PsnName = psn_info.PsnName
  17097. Gend = psn_info.Gend
  17098. Naty = psn_info.Naty
  17099. Brdy = psn_info.Brdy
  17100. Age = psn_info.Age
  17101. infoStr = psn_info.Insuinfo
  17102. idetinfoStr = psn_info.Idetinfo
  17103. infocode = 0
  17104. verify_number = psn_info.VerifyNumber
  17105. }
  17106. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17107. psn_info, _ := service.GetPsnByPatientId(id)
  17108. PsnNo = psn_info.PsnNo
  17109. PsnCertType = psn_info.PsnCertType
  17110. Certno = psn_info.Certno
  17111. PsnName = psn_info.PsnName
  17112. Gend = psn_info.Gend
  17113. Naty = psn_info.Naty
  17114. Brdy = psn_info.Brdy
  17115. Age = psn_info.Age
  17116. infoStr = psn_info.Insuinfo
  17117. idetinfoStr = psn_info.Idetinfo
  17118. infocode = 0
  17119. verify_number = psn_info.VerifyNumber
  17120. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17121. if id_card_type == 1 {
  17122. psn_info, _ := service.GetPsnByPatientId(id)
  17123. PsnNo = psn_info.PsnNo
  17124. PsnCertType = psn_info.PsnCertType
  17125. Certno = psn_info.Certno
  17126. PsnName = psn_info.PsnName
  17127. Gend = psn_info.Gend
  17128. Naty = psn_info.Naty
  17129. Brdy = psn_info.Brdy
  17130. Age = psn_info.Age
  17131. infoStr = psn_info.Insuinfo
  17132. idetinfoStr = psn_info.Idetinfo
  17133. infocode = 0
  17134. verify_number = psn_info.VerifyNumber
  17135. } else if id_card_type == 2 {
  17136. 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)
  17137. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17138. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17139. utils.ErrorLog("解析失败:%v", err)
  17140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17141. return
  17142. }
  17143. PsnNo = res.Output.Baseinfo.PsnNo
  17144. PsnCertType = res.Output.Baseinfo.PsnCertType
  17145. Certno = res.Output.Baseinfo.Certno
  17146. PsnName = res.Output.Baseinfo.PsnName
  17147. Gend = res.Output.Baseinfo.Gend
  17148. Naty = res.Output.Baseinfo.Naty
  17149. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17150. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17151. infoStr = string(Iinfos)
  17152. idetinfoStr = string(Idetinfos)
  17153. infocode = res.Infcode
  17154. } else if id_card_type == 4 {
  17155. psn_info, _ := service.GetPsnByPatientId(id)
  17156. PsnNo = psn_info.PsnNo
  17157. PsnCertType = psn_info.PsnCertType
  17158. Certno = psn_info.Certno
  17159. PsnName = psn_info.PsnName
  17160. Gend = psn_info.Gend
  17161. Naty = psn_info.Naty
  17162. Brdy = psn_info.Brdy
  17163. Age = psn_info.Age
  17164. infoStr = psn_info.Insuinfo
  17165. idetinfoStr = psn_info.Idetinfo
  17166. infocode = 0
  17167. verify_number = psn_info.VerifyNumber
  17168. }
  17169. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17170. var result string
  17171. var requestLog string
  17172. 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), "")
  17173. if id_card_type == 4 {
  17174. psn_info, _ := service.GetPsnByPatientId(id)
  17175. PsnNo = psn_info.PsnNo
  17176. PsnCertType = psn_info.PsnCertType
  17177. Certno = psn_info.Certno
  17178. PsnName = psn_info.PsnName
  17179. Gend = psn_info.Gend
  17180. Naty = psn_info.Naty
  17181. Brdy = psn_info.Brdy
  17182. Age = psn_info.Age
  17183. infoStr = psn_info.Insuinfo
  17184. idetinfoStr = psn_info.Idetinfo
  17185. infocode = 0
  17186. verify_number = psn_info.VerifyNumber
  17187. } else {
  17188. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17189. if miConfig.Code == "H15049901371" {
  17190. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17191. utils.ErrorLog("解析失败:%v", err)
  17192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17193. return
  17194. }
  17195. res.ErrMsg = res10265.ErrMsg
  17196. res.Output = res10265.Output
  17197. res.InfRefmsgid = res10265.InfRefmsgid
  17198. } else {
  17199. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17200. utils.ErrorLog("解析失败:%v", err)
  17201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17202. return
  17203. }
  17204. }
  17205. PsnNo = res.Output.Baseinfo.PsnNo
  17206. PsnCertType = res.Output.Baseinfo.PsnCertType
  17207. Certno = res.Output.Baseinfo.Certno
  17208. PsnName = res.Output.Baseinfo.PsnName
  17209. Gend = res.Output.Baseinfo.Gend
  17210. Naty = res.Output.Baseinfo.Naty
  17211. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17212. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17213. infoStr = string(Iinfos)
  17214. idetinfoStr = string(Idetinfos)
  17215. if miConfig.Code == "H15049901371" {
  17216. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17217. } else {
  17218. infocode = res.Infcode
  17219. }
  17220. }
  17221. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17222. psn_info, _ := service.GetPsnByPatientId(id)
  17223. PsnNo = psn_info.PsnNo
  17224. PsnCertType = psn_info.PsnCertType
  17225. Certno = psn_info.Certno
  17226. PsnName = psn_info.PsnName
  17227. Gend = psn_info.Gend
  17228. Naty = psn_info.Naty
  17229. Brdy = psn_info.Brdy
  17230. Age = psn_info.Age
  17231. infoStr = psn_info.Insuinfo
  17232. idetinfoStr = psn_info.Idetinfo
  17233. infocode = 0
  17234. verify_number = psn_info.VerifyNumber
  17235. } else if miConfig.MdtrtareaAdmvs == "450721" {
  17236. psn_info, _ := service.GetPsnByPatientId(id)
  17237. PsnNo = psn_info.PsnNo
  17238. PsnCertType = psn_info.PsnCertType
  17239. Certno = psn_info.Certno
  17240. PsnName = psn_info.PsnName
  17241. Gend = psn_info.Gend
  17242. Naty = psn_info.Naty
  17243. Brdy = psn_info.Brdy
  17244. Age = psn_info.Age
  17245. infoStr = psn_info.Insuinfo
  17246. idetinfoStr = psn_info.Idetinfo
  17247. infocode = 0
  17248. verify_number = psn_info.VerifyNumber
  17249. } else {
  17250. var result string
  17251. var requestLog string
  17252. //if miConfig.UserOrgId == 10138 {
  17253. if id_card_type != 4 || id_card_type != 1 {
  17254. var insa string
  17255. if len(patient.InsuplcAdmdvs) > 0 {
  17256. insa = patient.InsuplcAdmdvs
  17257. } else {
  17258. insa = miConfig.InsuplcAdmdvs
  17259. }
  17260. //psn_info, _ := service.GetPsnByPatientId(id)
  17261. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  17262. 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)
  17263. }
  17264. //}
  17265. //else {
  17266. // var insa string
  17267. // if len(patient.InsuplcAdmdvs) > 0 {
  17268. // insa = patient.InsuplcAdmdvs
  17269. // } else {
  17270. // insa = miConfig.InsuplcAdmdvs
  17271. // }
  17272. // 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)
  17273. //}
  17274. if id_card_type == 4 || id_card_type == 1 {
  17275. psn_info, _ := service.GetPsnByPatientId(id)
  17276. PsnNo = psn_info.PsnNo
  17277. PsnCertType = psn_info.PsnCertType
  17278. Certno = psn_info.Certno
  17279. PsnName = psn_info.PsnName
  17280. Gend = psn_info.Gend
  17281. Naty = psn_info.Naty
  17282. Brdy = psn_info.Brdy
  17283. Age = psn_info.Age
  17284. infoStr = psn_info.Insuinfo
  17285. idetinfoStr = psn_info.Idetinfo
  17286. infocode = 0
  17287. verify_number = psn_info.VerifyNumber
  17288. } else {
  17289. saveLog(result, requestLog, "1101", "人员基本信息获取")
  17290. if miConfig.Code == "H15049901371" {
  17291. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  17292. utils.ErrorLog("解析失败:%v", err)
  17293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17294. return
  17295. }
  17296. res.ErrMsg = res10265.ErrMsg
  17297. res.Output = res10265.Output
  17298. res.InfRefmsgid = res10265.InfRefmsgid
  17299. } else {
  17300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  17301. utils.ErrorLog("解析失败:%v", err)
  17302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17303. return
  17304. }
  17305. }
  17306. PsnNo = res.Output.Baseinfo.PsnNo
  17307. PsnCertType = res.Output.Baseinfo.PsnCertType
  17308. Certno = res.Output.Baseinfo.Certno
  17309. PsnName = res.Output.Baseinfo.PsnName
  17310. Gend = res.Output.Baseinfo.Gend
  17311. Naty = res.Output.Baseinfo.Naty
  17312. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  17313. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  17314. infoStr = string(Iinfos)
  17315. idetinfoStr = string(Idetinfos)
  17316. if miConfig.Code == "H15049901371" {
  17317. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  17318. } else {
  17319. infocode = res.Infcode
  17320. }
  17321. }
  17322. }
  17323. if infocode == 0 {
  17324. his := models.VMHisPatient{
  17325. Name: name,
  17326. Gender: gender,
  17327. Birthday: birthUnix,
  17328. MedicalTreatmentType: medical_care,
  17329. IdType: certificates,
  17330. IdCardNo: id_card,
  17331. BalanceAccountsType: settlementValue,
  17332. SocialType: social_type,
  17333. MedicalInsuranceNumber: medical_insurance_card,
  17334. RegisterType: register_type,
  17335. RegisterCost: registration_fee,
  17336. TreatmentCost: medical_expenses,
  17337. Status: 1,
  17338. Ctime: time.Now().Unix(),
  17339. Mtime: time.Now().Unix(),
  17340. PsnNo: PsnNo,
  17341. PsnCertType: PsnCertType,
  17342. Certno: Certno,
  17343. PsnName: PsnName,
  17344. Gend: Gend,
  17345. Naty: Naty,
  17346. Brdy: Brdy,
  17347. Age: Age,
  17348. Iinfo: infoStr,
  17349. Idetinfo: idetinfoStr,
  17350. PatientId: patient.ID,
  17351. RecordDate: theTime.Unix(),
  17352. UserOrgId: adminInfo.CurrentOrgId,
  17353. AdminUserId: admin_user_id,
  17354. IsReturn: 1,
  17355. IdCardType: id_card_type,
  17356. Doctor: doctor,
  17357. Departments: department,
  17358. MdtrtGrpType: mdtrt_type,
  17359. }
  17360. timestamp := time.Now().Unix()
  17361. tempTime := time.Unix(timestamp, 0)
  17362. timeFormat := tempTime.Format("20060102150405")
  17363. chrgBchno := rand.Intn(100000) + 10000
  17364. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  17365. his.Number = ipt_otp_no
  17366. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  17367. department, _ := service.GetDepartMentDetail(department)
  17368. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  17369. IdCardNo := ""
  17370. if id_card_type == 1 {
  17371. // IdCardNo = medical_insurance_card
  17372. IdCardNo = patient.IdCardNo
  17373. } else {
  17374. IdCardNo = patient.IdCardNo
  17375. }
  17376. var rf []*ResultFive
  17377. json.Unmarshal([]byte(his.Iinfo), &rf)
  17378. var insutypes []*ResultFive
  17379. var insutype string
  17380. var insuplc_admdvs_temp string
  17381. var is390 int = 0
  17382. var is310 int = 0
  17383. for _, item := range rf {
  17384. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17385. insutypes = append(insutypes, item)
  17386. }
  17387. }
  17388. if len(insutypes) == 1 {
  17389. insutype = insutypes[0].Insutype
  17390. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17391. if insutype == "390" {
  17392. is390 = 1
  17393. }
  17394. if insutype == "310" {
  17395. is310 = 1
  17396. }
  17397. } else {
  17398. for _, i := range insutypes {
  17399. if i.Insutype == "390" {
  17400. is390 = 1
  17401. }
  17402. if i.Insutype == "310" {
  17403. is310 = 1
  17404. }
  17405. }
  17406. }
  17407. if is390 == 1 {
  17408. insutype = "390"
  17409. }
  17410. if is310 == 1 {
  17411. insutype = "310"
  17412. }
  17413. fmt.Println(social_type)
  17414. if social_type > 0 {
  17415. insutype = strconv.FormatInt(social_type, 10)
  17416. }
  17417. var infocode int64
  17418. var resThree ResultThree
  17419. var resThree10265 ResultThree10265
  17420. if len(insuplc_admdvs) == 0 {
  17421. psn_info, _ := service.GetPsnByPatientId(id)
  17422. //if len(psn_info.InsuplcAdmdvs) > 0 {
  17423. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17424. //}
  17425. } else {
  17426. insuplc_admdvs_temp = insuplc_admdvs
  17427. }
  17428. if miConfig.MdtrtareaAdmvs == "421300" {
  17429. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17430. psn_info, _ := service.GetPsnByPatientId(id)
  17431. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17432. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17433. "&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
  17434. resp, requestErr := http.Get(api)
  17435. if requestErr != nil {
  17436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17437. return
  17438. }
  17439. body, ioErr := ioutil.ReadAll(resp.Body)
  17440. if ioErr != nil {
  17441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17443. return
  17444. }
  17445. var respJSON map[string]interface{}
  17446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17449. return
  17450. }
  17451. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17452. result, _ := json.Marshal(respJSON)
  17453. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17454. utils.ErrorLog("解析失败:%v", err)
  17455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17456. return
  17457. }
  17458. infocode = resThree.Infcode
  17459. } else if miConfig.MdtrtareaAdmvs == "420200" {
  17460. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17461. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17462. // insuplc_admdvs_temp =
  17463. //}
  17464. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17465. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17466. //}
  17467. api := "http://192.168.0.197:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17468. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17469. "&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
  17470. resp, requestErr := http.Get(api)
  17471. if requestErr != nil {
  17472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17473. return
  17474. }
  17475. body, ioErr := ioutil.ReadAll(resp.Body)
  17476. if ioErr != nil {
  17477. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17479. return
  17480. }
  17481. var respJSON map[string]interface{}
  17482. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17483. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17485. return
  17486. }
  17487. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17488. result, _ := json.Marshal(respJSON)
  17489. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17490. utils.ErrorLog("解析失败:%v", err)
  17491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17492. return
  17493. }
  17494. infocode = resThree.Infcode
  17495. } else if miConfig.MdtrtareaAdmvs == "420902" {
  17496. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17497. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17498. // insuplc_admdvs_temp =
  17499. //}
  17500. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17501. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17502. //}
  17503. utils.ErrorLog("解析失败:%v", insutype)
  17504. utils.ErrorLog("解析失败:%v", PsnNo)
  17505. utils.ErrorLog("解析失败:%v", Certno)
  17506. utils.ErrorLog("解析失败:%v", ipt_otp_no)
  17507. utils.ErrorLog("解析失败:%v", hb_doctor_info.UserName)
  17508. utils.ErrorLog("解析失败:%v", insuplc_admdvs_temp)
  17509. utils.ErrorLog("解析失败:%v", hb_doctor_info.DoctorNumber)
  17510. utils.ErrorLog("解析失败:%v", PsnNo)
  17511. utils.ErrorLog("解析失败:%v", department.Number )
  17512. utils.ErrorLog("解析失败:%v", department.Name )
  17513. utils.ErrorLog("解析失败:%v", roles.UserName)
  17514. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17515. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17516. "&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
  17517. resp, requestErr := http.Get(api)
  17518. if requestErr != nil {
  17519. utils.ErrorLog("解析失败:%v", requestErr)
  17520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17521. return
  17522. }
  17523. body, ioErr := ioutil.ReadAll(resp.Body)
  17524. if ioErr != nil {
  17525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17527. return
  17528. }
  17529. var respJSON map[string]interface{}
  17530. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17533. return
  17534. }
  17535. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17536. result, _ := json.Marshal(respJSON)
  17537. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17538. utils.ErrorLog("解析失败:%v", err)
  17539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17540. return
  17541. }
  17542. infocode = resThree.Infcode
  17543. } else if miConfig.MdtrtareaAdmvs == "421182" {
  17544. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17545. //if strings.Contains(insuplc_admdvs_temp, "4202") {
  17546. // insuplc_admdvs_temp =
  17547. //}
  17548. //if strings.Contains(insuplc_admdvs_temp, "4413") {
  17549. // insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  17550. //}
  17551. api := miConfig.Url + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17552. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17553. "&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
  17554. resp, requestErr := http.Get(api)
  17555. if requestErr != nil {
  17556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17557. return
  17558. }
  17559. body, ioErr := ioutil.ReadAll(resp.Body)
  17560. if ioErr != nil {
  17561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17563. return
  17564. }
  17565. var respJSON map[string]interface{}
  17566. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17569. return
  17570. }
  17571. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17572. result, _ := json.Marshal(respJSON)
  17573. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17574. utils.ErrorLog("解析失败:%v", err)
  17575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17576. return
  17577. }
  17578. infocode = resThree.Infcode
  17579. } else if miConfig.MdtrtareaAdmvs == "150499" {
  17580. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17581. psn_info, _ := service.GetPsnByPatientId(id)
  17582. var verify_number string
  17583. if id_card_type == 4 {
  17584. verify_number = psn_info.VerifyNumber
  17585. } else if id_card_type == 1 {
  17586. bas := strings.Split(psn_info.CardInfo, "|")
  17587. cardNumber := bas[2]
  17588. verify_number = cardNumber
  17589. }
  17590. api := "http://172.16.13.254:9532/" + "nmyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  17591. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17592. "&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
  17593. resp, requestErr := http.Get(api)
  17594. if requestErr != nil {
  17595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17596. return
  17597. }
  17598. body, ioErr := ioutil.ReadAll(resp.Body)
  17599. if ioErr != nil {
  17600. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17602. return
  17603. }
  17604. var respJSON map[string]interface{}
  17605. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17606. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17608. return
  17609. }
  17610. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17611. result, _ := json.Marshal(respJSON)
  17612. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17613. // utils.ErrorLog("解析失败:%v", err)
  17614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17615. // return
  17616. //}
  17617. //infocode = resThree.Infcode
  17618. //result, _ := json.Marshal(respJSON)
  17619. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17620. utils.ErrorLog("解析失败:%v", err)
  17621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17622. return
  17623. }
  17624. resThree.ErrMsg = resThree10265.ErrMsg
  17625. resThree.Output = resThree10265.Output
  17626. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17627. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17628. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  17629. psn_info, _ := service.GetPsnByPatientId(id)
  17630. his.PsnNo = psn_info.PsnNo
  17631. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17632. var cert_no string
  17633. if id_card_type == 3 {
  17634. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  17635. cert_no = IdCardNo
  17636. } else if id_card_type == 4 {
  17637. cert_no = IdCardNo
  17638. psn_info.VerifyNumber = psn_info.VerifyNumber
  17639. } else {
  17640. bas := strings.Split(psn_info.CardInfo, "|")
  17641. cert_no = bas[2]
  17642. }
  17643. var hisPrescription []*models.HisPrescription
  17644. for _, item := range rf {
  17645. if item.Insutype == insutype {
  17646. //insuplc_admdvs = item.InsuplcAdmdvs
  17647. his.InsuplcAdmdvs = insuplc_admdvs
  17648. }
  17649. }
  17650. his.Insutype = insutype
  17651. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17652. fmt.Println(res3101)
  17653. fmt.Println(res3101.Infcode)
  17654. if res3101.Infcode == "0" {
  17655. fmt.Println("33333333")
  17656. if len(res3101.Output.Result) > 0 {
  17657. fmt.Println("222222")
  17658. for _, item := range res3101.Output.Result {
  17659. if len(res3101.ErrMsg) == 0 {
  17660. res3101.ErrMsg = item.VolaCont
  17661. } else {
  17662. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17663. }
  17664. }
  17665. c.ServeSuccessJSON(map[string]interface{}{
  17666. "failed_code": -10,
  17667. "msg": res3101.ErrMsg,
  17668. })
  17669. return
  17670. } else {
  17671. fmt.Println("11111")
  17672. var api string
  17673. if miConfig.MdtrtareaAdmvs == "320921" {
  17674. ipt_otp_no = timeFormat
  17675. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17676. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17677. "&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
  17678. } else {
  17679. ipt_otp_no = timeFormat
  17680. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17681. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17682. "&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
  17683. }
  17684. resp, requestErr := http.Get(api)
  17685. if requestErr != nil {
  17686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17687. return
  17688. }
  17689. body, ioErr := ioutil.ReadAll(resp.Body)
  17690. if ioErr != nil {
  17691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17693. return
  17694. }
  17695. var respJSON map[string]interface{}
  17696. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17699. return
  17700. }
  17701. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17702. result, _ := json.Marshal(respJSON)
  17703. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17704. utils.ErrorLog("解析失败:%v", err)
  17705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17706. return
  17707. }
  17708. resThree.ErrMsg = resThree10265.ErrMsg
  17709. resThree.Output = resThree10265.Output
  17710. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17711. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17712. }
  17713. } else if res3101.Infcode != "0" {
  17714. c.ServeSuccessJSON(map[string]interface{}{
  17715. "failed_code": -10,
  17716. "msg": res3101.ErrMsg,
  17717. })
  17718. return
  17719. }
  17720. } else if miConfig.MdtrtareaAdmvs == "350500" {
  17721. psn_info, _ := service.GetPsnByPatientId(id)
  17722. var cert_no string
  17723. if id_card_type == 1 {
  17724. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  17725. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17726. } else if id_card_type == 4 {
  17727. cert_no = psn_info.VerifyNumber
  17728. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17729. } else {
  17730. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17731. cert_no = psn_info.VerifyNumber
  17732. }
  17733. 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)
  17734. saveLog(result, requestLog, "2201", "挂号")
  17735. if miConfig.Code == "H15049901371" {
  17736. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17737. utils.ErrorLog("解析失败:%v", err)
  17738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17739. return
  17740. }
  17741. resThree.ErrMsg = resThree10265.ErrMsg
  17742. resThree.Output = resThree10265.Output
  17743. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17744. } else {
  17745. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17746. utils.ErrorLog("解析失败:%v", err)
  17747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17748. return
  17749. }
  17750. }
  17751. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17752. } else if miConfig.MdtrtareaAdmvs == "360302" { //江西萍乡
  17753. psn_info, _ := service.GetPsnByPatientId(id)
  17754. var result string
  17755. var requestLog string
  17756. if id_card_type == 1 {
  17757. bas := strings.Split(psn_info.CardInfo, "|")
  17758. basNumber := bas[2]
  17759. card_sn := bas[3]
  17760. 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)
  17761. saveLog(result, requestLog, "2201A", "挂号")
  17762. } else if id_card_type == 2 {
  17763. 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, "", "", "", "", "", "")
  17764. saveLog(result, requestLog, "2201A", "挂号")
  17765. } else {
  17766. 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)
  17767. saveLog(result, requestLog, "2201A", "挂号")
  17768. }
  17769. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17770. utils.ErrorLog("解析失败:%v", err)
  17771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17772. return
  17773. }
  17774. infocode = resThree.Infcode
  17775. } else if miConfig.MdtrtareaAdmvs == "341203" {
  17776. psn_info, _ := service.GetPsnByPatientId(id)
  17777. his.PsnNo = psn_info.PsnNo
  17778. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  17779. var cert_no string
  17780. if id_card_type == 1 {
  17781. bas := strings.Split(psn_info.CardInfo, "|")
  17782. cert_no = bas[2]
  17783. } else if id_card_type == 4 {
  17784. cert_no = IdCardNo
  17785. psn_info.VerifyNumber = psn_info.VerifyNumber
  17786. } else {
  17787. cert_no = IdCardNo
  17788. psn_info.VerifyNumber = cert_no
  17789. }
  17790. for _, item := range rf {
  17791. if item.Insutype == insutype {
  17792. his.InsuplcAdmdvs = insuplc_admdvs
  17793. }
  17794. }
  17795. his.Insutype = insutype
  17796. var api string
  17797. ipt_otp_no = timeFormat
  17798. api = miConfig.SecretKey + "ahyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  17799. "&org_name=" + miConfig.OrgName + "&opera=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  17800. "&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
  17801. resp, requestErr := http.Get(api)
  17802. if requestErr != nil {
  17803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17804. return
  17805. }
  17806. body, ioErr := ioutil.ReadAll(resp.Body)
  17807. if ioErr != nil {
  17808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17810. return
  17811. }
  17812. var respJSON map[string]interface{}
  17813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  17814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17816. return
  17817. }
  17818. status := respJSON["data"].(map[string]interface{})["status"].(string)
  17819. if status == "0" {
  17820. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  17821. c.ServeSuccessJSON(map[string]interface{}{
  17822. "failed_code": -10,
  17823. "msg": err_msg,
  17824. })
  17825. return
  17826. }
  17827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  17828. result, _ := json.Marshal(respJSON)
  17829. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17830. utils.ErrorLog("解析失败:%v", err)
  17831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17832. return
  17833. }
  17834. infocode = resThree.Infcode
  17835. } else if miConfig.MdtrtareaAdmvs == "430800" {
  17836. psn_info, _ := service.GetPsnByPatientId(id)
  17837. var result string
  17838. var requestLog string
  17839. if id_card_type == 1 {
  17840. bas := strings.Split(psn_info.CardInfo, "|")
  17841. basNumber := bas[2]
  17842. card_sn := bas[3]
  17843. 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)
  17844. saveLog(result, requestLog, "2201A", "挂号")
  17845. } else if id_card_type == 2 {
  17846. 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, "", "")
  17847. saveLog(result, requestLog, "2201A", "挂号")
  17848. } else {
  17849. 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, "", "")
  17850. saveLog(result, requestLog, "2201A", "挂号")
  17851. }
  17852. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17853. utils.ErrorLog("解析失败:%v", err)
  17854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17855. return
  17856. }
  17857. infocode = resThree.Infcode
  17858. } else if miConfig.MdtrtareaAdmvs == "131023" {
  17859. psn_info, _ := service.GetPsnByPatientId(id)
  17860. 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)
  17861. saveLog(result, requestLog, "2201A", "挂号")
  17862. if miConfig.Code == "H15049901371" {
  17863. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17864. utils.ErrorLog("解析失败:%v", err)
  17865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17866. return
  17867. }
  17868. resThree.ErrMsg = resThree10265.ErrMsg
  17869. resThree.Output = resThree10265.Output
  17870. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17871. } else {
  17872. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17873. utils.ErrorLog("解析失败:%v", err)
  17874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17875. return
  17876. }
  17877. }
  17878. if miConfig.Code == "H15049901371" {
  17879. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17880. } else {
  17881. infocode = resThree.Infcode
  17882. }
  17883. } else {
  17884. psn_info, _ := service.GetPsnByPatientId(id)
  17885. if id_card_type == 4 || id_card_type == 1 {
  17886. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  17887. }
  17888. var rf []*ResultFive
  17889. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  17890. var insutypes []*ResultFive
  17891. var insutype string
  17892. var is390 int = 0
  17893. var is310 int = 0
  17894. for _, item := range rf {
  17895. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  17896. insutypes = append(insutypes, item)
  17897. }
  17898. }
  17899. if len(insutypes) == 1 {
  17900. insutype = insutypes[0].Insutype
  17901. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  17902. } else {
  17903. for _, i := range insutypes {
  17904. if i.Insutype == "390" {
  17905. is390 = 1
  17906. }
  17907. if i.Insutype == "310" {
  17908. is310 = 1
  17909. }
  17910. }
  17911. }
  17912. if is390 == 1 {
  17913. insutype = "390"
  17914. }
  17915. if is310 == 1 {
  17916. insutype = "310"
  17917. }
  17918. fmt.Println(len(insutypes))
  17919. if len(insutypes) == 0 {
  17920. for index, item := range rf {
  17921. if index == 0 {
  17922. insutype = item.Insutype
  17923. insuplc_admdvs = item.InsuplcAdmdvs
  17924. }
  17925. }
  17926. fmt.Println(insutype)
  17927. fmt.Println(insuplc_admdvs)
  17928. }
  17929. if social_type > 0 {
  17930. insutype = strconv.FormatInt(social_type, 10)
  17931. }
  17932. fmt.Println("--------")
  17933. fmt.Println(psn_info)
  17934. fmt.Println(psn_info.PsnNo)
  17935. if miConfig.MdtrtareaAdmvs == "441202" {
  17936. var hisPrescription []*models.HisPrescription
  17937. res3101 := Checkgd3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  17938. if res3101.Infcode == 0 {
  17939. fmt.Println("33333333")
  17940. if len(res3101.Output.Result) > 0 {
  17941. fmt.Println("222222")
  17942. for _, item := range res3101.Output.Result {
  17943. if len(res3101.ErrMsg) == 0 {
  17944. res3101.ErrMsg = item.VolaCont
  17945. } else {
  17946. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  17947. }
  17948. }
  17949. c.ServeSuccessJSON(map[string]interface{}{
  17950. "failed_code": -10,
  17951. "msg": res3101.ErrMsg,
  17952. })
  17953. return
  17954. } else {
  17955. hour := time.Now().Format("15")
  17956. min := time.Now().Format("04")
  17957. sec := time.Now().Format("05")
  17958. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  17959. fmt.Println(record_time_two)
  17960. 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)
  17961. saveLog(result, requestLog, "2201A", "挂号")
  17962. if miConfig.Code == "H15049901371" {
  17963. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  17964. utils.ErrorLog("解析失败:%v", err)
  17965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17966. return
  17967. }
  17968. resThree.ErrMsg = resThree10265.ErrMsg
  17969. resThree.Output = resThree10265.Output
  17970. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  17971. } else {
  17972. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  17973. utils.ErrorLog("解析失败:%v", err)
  17974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17975. return
  17976. }
  17977. }
  17978. if miConfig.Code == "H15049901371" {
  17979. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  17980. } else {
  17981. infocode = resThree.Infcode
  17982. }
  17983. }
  17984. } else if res3101.Infcode != 0 {
  17985. c.ServeSuccessJSON(map[string]interface{}{
  17986. "failed_code": -10,
  17987. "msg": res3101.ErrMsg,
  17988. })
  17989. return
  17990. }
  17991. } else if miConfig.MdtrtareaAdmvs == "441799" {
  17992. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  17993. psn_info, _ := service.GetPsnByPatientId(id)
  17994. var verify_number string
  17995. if id_card_type == 4 {
  17996. verify_number = psn_info.VerifyNumber
  17997. } else if id_card_type == 1 {
  17998. bas := strings.Split(psn_info.CardInfo, "|")
  17999. cardNumber := bas[2]
  18000. verify_number = cardNumber
  18001. } else {
  18002. verify_number = psn_info.Certno
  18003. }
  18004. api := miConfig.Url + "gdyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  18005. "&org_name=" + miConfig.OrgName + "&operator=" + roles.UserName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  18006. "&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
  18007. resp, requestErr := http.Get(api)
  18008. if requestErr != nil {
  18009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18010. return
  18011. }
  18012. body, ioErr := ioutil.ReadAll(resp.Body)
  18013. if ioErr != nil {
  18014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18016. return
  18017. }
  18018. var respJSON map[string]interface{}
  18019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  18020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18022. return
  18023. }
  18024. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18025. result, _ := json.Marshal(respJSON)
  18026. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18027. utils.ErrorLog("解析失败:%v", err)
  18028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18029. return
  18030. }
  18031. infocode = resThree.Infcode
  18032. } else {
  18033. hour := time.Now().Format("15")
  18034. min := time.Now().Format("04")
  18035. sec := time.Now().Format("05")
  18036. record_time_two := record_time + " " + hour + ":" + min + ":" + sec
  18037. if id_card_type == 1 {
  18038. for _, item := range rf {
  18039. if item.Insutype == strconv.FormatInt(social_type, 10) {
  18040. if strconv.FormatInt(social_type, 10) == "310" && item.PsnInsuStas == "1" {
  18041. insuplc_admdvs_temp = item.InsuplcAdmdvs
  18042. } else if strconv.FormatInt(social_type, 10) == "390" {
  18043. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18044. } else {
  18045. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18046. }
  18047. }
  18048. }
  18049. }
  18050. if miConfig.MdtrtareaAdmvs == "440205" && strconv.FormatInt(social_type, 10) == "390" {
  18051. insuplc_admdvs_temp = miConfig.MdtrtareaAdmvs
  18052. }
  18053. if id_card_type == 1 {
  18054. utils.ErrorLog("解析失败:%v", psn_info.CardInfo)
  18055. bas := strings.Split(psn_info.CardInfo, "|")
  18056. basNumber := bas[1]
  18057. IdCardNo = basNumber
  18058. }
  18059. if miConfig.MdtrtareaAdmvs == "450721" && id_card_type == 1 {
  18060. IdCardNo = psn_info.VerifyNumber
  18061. }
  18062. 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)
  18063. saveLog(result, requestLog, "2201A", "挂号")
  18064. if miConfig.Code == "H15049901371" {
  18065. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  18066. utils.ErrorLog("解析失败:%v", err)
  18067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18068. return
  18069. }
  18070. resThree.ErrMsg = resThree10265.ErrMsg
  18071. resThree.Output = resThree10265.Output
  18072. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  18073. } else {
  18074. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  18075. utils.ErrorLog("解析失败:%v", err)
  18076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18077. return
  18078. }
  18079. }
  18080. if miConfig.Code == "H15049901371" {
  18081. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  18082. } else {
  18083. infocode = resThree.Infcode
  18084. }
  18085. }
  18086. }
  18087. if infocode != 0 {
  18088. adminUser := c.GetAdminUserInfo()
  18089. errlog := &models.HisOrderError{
  18090. UserOrgId: adminUser.CurrentOrgId,
  18091. Ctime: time.Now().Unix(),
  18092. Mtime: time.Now().Unix(),
  18093. ErrMsg: resThree.ErrMsg,
  18094. Status: 1,
  18095. PatientId: id,
  18096. RecordTime: recordDateTime,
  18097. Stage: 2,
  18098. }
  18099. service.CreateErrMsgLog(errlog)
  18100. c.ServeSuccessJSON(map[string]interface{}{
  18101. "failed_code": -10,
  18102. "msg": resThree.ErrMsg,
  18103. })
  18104. return
  18105. }
  18106. his.Number = resThree.Output.Data.MdtrtID
  18107. his.PsnNo = resThree.Output.Data.PsnNo
  18108. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  18109. his.IdCardNo = patient.IdCardNo
  18110. his.PhoneNumber = patient.Phone
  18111. his.UserOrgId = adminInfo.CurrentOrgId
  18112. his.Insutype = insutype
  18113. his.Ctime = time.Now().Unix()
  18114. his.Mtime = time.Now().Unix()
  18115. his.InsuplcAdmdvs = insuplc_admdvs_temp
  18116. if miConfig.MdtrtareaAdmvs == "421300" && strings.Contains(insuplc_admdvs_temp, "4213") {
  18117. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18118. }
  18119. if miConfig.MdtrtareaAdmvs == "420200" && strings.Contains(insuplc_admdvs_temp, "4202") {
  18120. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18121. }
  18122. if miConfig.MdtrtareaAdmvs == "421182" && strings.Contains(insuplc_admdvs_temp, "4211") {
  18123. his.InsuplcAdmdvs = miConfig.MdtrtareaAdmvs
  18124. }
  18125. his.Status = 1
  18126. his.MdtrtGrpType = mdtrt_type
  18127. service.UpdateHisPatientStatus(&his)
  18128. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  18129. c.ServeSuccessJSON(map[string]interface{}{
  18130. "his_info": his,
  18131. })
  18132. } else {
  18133. adminUser := c.GetAdminUserInfo()
  18134. errlog := &models.HisOrderError{
  18135. UserOrgId: adminUser.CurrentOrgId,
  18136. Ctime: time.Now().Unix(),
  18137. Mtime: time.Now().Unix(),
  18138. ErrMsg: res.ErrMsg,
  18139. Status: 1,
  18140. PatientId: id,
  18141. RecordTime: recordDateTime,
  18142. Stage: 1,
  18143. }
  18144. service.CreateErrMsgLog(errlog)
  18145. c.ServeSuccessJSON(map[string]interface{}{
  18146. "failed_code": -10,
  18147. "msg": res.ErrMsg,
  18148. })
  18149. return
  18150. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  18151. }
  18152. }
  18153. }
  18154. func (c *HisApiController) GetUploadInfo() {
  18155. id, _ := c.GetInt64("id")
  18156. record_time := c.GetString("record_time")
  18157. his_patient_id, _ := c.GetInt64("his_patient_id")
  18158. order_id, _ := c.GetInt64("order_id")
  18159. pay_way, _ := c.GetInt64("pay_way")
  18160. pay_ways := c.GetString("pay_ways")
  18161. oth_desc := c.GetString("oth_desc")
  18162. pay_price, _ := c.GetFloat("pay_price")
  18163. pay_card_no := c.GetString("pay_card_no")
  18164. discount_price, _ := c.GetFloat("discount_price")
  18165. preferential_price, _ := c.GetFloat("preferential_price")
  18166. reality_price, _ := c.GetFloat("reality_price")
  18167. found_price, _ := c.GetFloat("found_price")
  18168. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  18169. private_price, _ := c.GetFloat("private_price")
  18170. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  18171. admin_user_id, _ := c.GetInt64("admin_user_id")
  18172. fapiao_code := c.GetString("fapiao_code")
  18173. fapiao_number := c.GetString("fapiao_number")
  18174. diagnosis_id := c.GetString("diagnosis")
  18175. sick_type, _ := c.GetInt64("sick_type")
  18176. reg_type, _ := c.GetInt64("p_type")
  18177. begin_time := c.GetString("begin_time")
  18178. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  18179. cash_pay := c.GetString("cash_pay")
  18180. band_card_pay := c.GetString("band_card_pay")
  18181. wechat_pay := c.GetString("wechat_pay")
  18182. ali_pay := c.GetString("ali_pay")
  18183. jifen_pay := c.GetString("jifen_pay")
  18184. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  18185. fmt.Println(acct_used_flag)
  18186. id_str := c.GetString("ids")
  18187. ids_arr := strings.Split(id_str, ",")
  18188. timeLayout := "2006-01-02"
  18189. loc, _ := time.LoadLocation("Local")
  18190. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  18191. if err != nil {
  18192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18193. return
  18194. }
  18195. recordDateTime := theTime.Unix()
  18196. adminUser := c.GetAdminUserInfo()
  18197. var tempOrder models.HisOrder
  18198. tempOrder, _ = service.GetHisOrderByID(order_id)
  18199. var prescriptions []*models.HisPrescription
  18200. var start_time int64
  18201. var end_time int64
  18202. //押金模块
  18203. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  18204. tmp_decimal := c.GetString("tmp_decimal")
  18205. var decimal float64 //本次使用的押金
  18206. var errmsg error
  18207. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  18208. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  18209. return
  18210. }
  18211. if len(tmp_decimal) > 0 {
  18212. if tmp_decimal[0] == 45 {
  18213. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  18214. return
  18215. }
  18216. }
  18217. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  18218. fmt.Println(errs)
  18219. decimal = tt
  18220. //if adminUser.CurrentOrgId == 10106{
  18221. // if len(fapiao_code) == 0{
  18222. // fapiao_code = "144072080589"
  18223. // }
  18224. // if len(fapiao_number) == 0{
  18225. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  18226. // if order.ID == 0{
  18227. // fapiao_number = "00001520"
  18228. // }else{
  18229. // //fapiao_code = "00001520"
  18230. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  18231. // var zero string
  18232. // if fpNumber >= 1000{
  18233. // zero = "0000" + strconv.Itoa(fpNumber)
  18234. // }else if fpNumber >= 10000{
  18235. // zero = "000" + strconv.Itoa(fpNumber)
  18236. // } else if fpNumber >= 100000{
  18237. // zero = "00" + strconv.Itoa(fpNumber)
  18238. // } else if fpNumber >= 1000000{
  18239. // zero = "0" + strconv.Itoa(fpNumber)
  18240. // }else {
  18241. // zero = strconv.Itoa(fpNumber)
  18242. // }
  18243. // fapiao_number = zero
  18244. // }
  18245. // }
  18246. //}
  18247. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  18248. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18249. var patientPrescription models.HisPrescriptionInfo
  18250. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  18251. if patientPrescription.ID == 0 {
  18252. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  18253. }
  18254. //if patientPrescription.Do
  18255. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  18256. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  18257. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  18258. diagnosis_ids := strings.Split(diagnosis_id, ",")
  18259. var config []*models.HisXtDiagnoseConfig
  18260. for _, item := range diagnosis_ids {
  18261. id, _ := strconv.ParseInt(item, 10, 64)
  18262. diagnosisConfig, _ := service.FindDiagnoseById(id)
  18263. config = append(config, &diagnosisConfig)
  18264. }
  18265. sickConfig, _ := service.FindSickById(sick_type)
  18266. //if tempOrder.ID == 0 {
  18267. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  18268. //}
  18269. if tempOrder.ID == 0 {
  18270. var result string
  18271. var requestLog string
  18272. var res2 ResultSix
  18273. var res3 GZResultSix
  18274. var ressix10265 ResultSix10265
  18275. if miConfig.MdtrtareaAdmvs == "421300" {
  18276. data := make(map[string]interface{})
  18277. client := &http.Client{}
  18278. data["psn_no"] = his.PsnNo
  18279. data["mdtrt_id"] = his.Number
  18280. data["opter"] = roles.UserName
  18281. data["org_name"] = miConfig.OrgName
  18282. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18283. data["doctor_id"] = doctor_info.DoctorNumber
  18284. data["doctor_name"] = doctor_info.UserName
  18285. data["department"] = department.Name
  18286. data["fixmedins_code"] = miConfig.Code
  18287. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18288. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18289. data["secret_key"] = miConfig.SecretKey
  18290. data["sick_code"] = sickConfig.CountryCode
  18291. data["sick_name"] = sickConfig.ClassName
  18292. data["dept"] = strconv.FormatInt(department.ID, 10)
  18293. data["config"] = config
  18294. data["begin_time"] = begin_time
  18295. bytesData, _ := json.Marshal(data)
  18296. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18297. resp, _ := client.Do(req)
  18298. defer resp.Body.Close()
  18299. body, ioErr := ioutil.ReadAll(resp.Body)
  18300. if ioErr != nil {
  18301. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18303. return
  18304. }
  18305. var respJSON map[string]interface{}
  18306. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18307. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18309. return
  18310. }
  18311. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18312. userJSONBytes, _ := json.Marshal(respJSON)
  18313. fmt.Println("log")
  18314. fmt.Println(string(userJSONBytes))
  18315. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18316. utils.ErrorLog("解析失败:%v", err)
  18317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18318. return
  18319. }
  18320. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18321. data := make(map[string]interface{})
  18322. client := &http.Client{}
  18323. data["psn_no"] = his.PsnNo
  18324. data["mdtrt_id"] = his.Number
  18325. data["opter"] = roles.UserName
  18326. data["org_name"] = miConfig.OrgName
  18327. if reg_type == 11 && his.Insutype == "390" {
  18328. data["med_type"] = "110104"
  18329. } else {
  18330. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18331. }
  18332. data["doctor_id"] = doctor_info.DoctorNumber
  18333. data["doctor_name"] = doctor_info.UserName
  18334. data["department"] = department.Name
  18335. data["fixmedins_code"] = miConfig.Code
  18336. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18337. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18338. data["secret_key"] = miConfig.SecretKey
  18339. data["sick_code"] = sickConfig.CountryCode
  18340. data["sick_name"] = sickConfig.ClassName
  18341. data["dept"] = strconv.FormatInt(department.ID, 10)
  18342. data["config"] = config
  18343. data["begin_time"] = begin_time
  18344. bytesData, _ := json.Marshal(data)
  18345. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  18346. resp, _ := client.Do(req)
  18347. defer resp.Body.Close()
  18348. body, ioErr := ioutil.ReadAll(resp.Body)
  18349. if ioErr != nil {
  18350. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18352. return
  18353. }
  18354. var respJSON map[string]interface{}
  18355. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18356. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18358. return
  18359. }
  18360. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18361. userJSONBytes, _ := json.Marshal(respJSON)
  18362. fmt.Println("log")
  18363. fmt.Println(string(userJSONBytes))
  18364. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18365. utils.ErrorLog("解析失败:%v", err)
  18366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18367. return
  18368. }
  18369. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18370. data := make(map[string]interface{})
  18371. client := &http.Client{}
  18372. data["psn_no"] = his.PsnNo
  18373. data["mdtrt_id"] = his.Number
  18374. data["opter"] = roles.UserName
  18375. data["org_name"] = miConfig.OrgName
  18376. if reg_type == 11 && his.Insutype == "390" {
  18377. data["med_type"] = "110104"
  18378. } else {
  18379. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18380. }
  18381. data["doctor_id"] = doctor_info.DoctorNumber
  18382. data["doctor_name"] = doctor_info.UserName
  18383. data["department"] = department.Name
  18384. data["fixmedins_code"] = miConfig.Code
  18385. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18386. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18387. data["secret_key"] = miConfig.SecretKey
  18388. data["sick_code"] = sickConfig.CountryCode
  18389. data["sick_name"] = sickConfig.ClassName
  18390. data["dept"] = strconv.FormatInt(department.ID, 10)
  18391. data["config"] = config
  18392. data["begin_time"] = begin_time
  18393. bytesData, _ := json.Marshal(data)
  18394. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18395. resp, _ := client.Do(req)
  18396. defer resp.Body.Close()
  18397. body, ioErr := ioutil.ReadAll(resp.Body)
  18398. if ioErr != nil {
  18399. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18401. return
  18402. }
  18403. var respJSON map[string]interface{}
  18404. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18405. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18407. return
  18408. }
  18409. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18410. userJSONBytes, _ := json.Marshal(respJSON)
  18411. fmt.Println("log")
  18412. fmt.Println(string(userJSONBytes))
  18413. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18414. utils.ErrorLog("解析失败:%v", err)
  18415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18416. return
  18417. }
  18418. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18419. data := make(map[string]interface{})
  18420. client := &http.Client{}
  18421. data["psn_no"] = his.PsnNo
  18422. data["mdtrt_id"] = his.Number
  18423. data["opter"] = roles.UserName
  18424. data["org_name"] = miConfig.OrgName
  18425. if reg_type == 11 && his.Insutype == "390" {
  18426. data["med_type"] = "110104"
  18427. } else {
  18428. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18429. }
  18430. data["doctor_id"] = doctor_info.DoctorNumber
  18431. data["doctor_name"] = doctor_info.UserName
  18432. data["department"] = department.Name
  18433. data["fixmedins_code"] = miConfig.Code
  18434. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18435. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18436. data["secret_key"] = miConfig.SecretKey
  18437. data["sick_code"] = sickConfig.CountryCode
  18438. data["sick_name"] = sickConfig.ClassName
  18439. data["dept"] = strconv.FormatInt(department.ID, 10)
  18440. data["config"] = config
  18441. data["begin_time"] = begin_time
  18442. bytesData, _ := json.Marshal(data)
  18443. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  18444. resp, _ := client.Do(req)
  18445. defer resp.Body.Close()
  18446. body, ioErr := ioutil.ReadAll(resp.Body)
  18447. if ioErr != nil {
  18448. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18450. return
  18451. }
  18452. var respJSON map[string]interface{}
  18453. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18454. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18456. return
  18457. }
  18458. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18459. userJSONBytes, _ := json.Marshal(respJSON)
  18460. fmt.Println("log")
  18461. fmt.Println(string(userJSONBytes))
  18462. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18463. utils.ErrorLog("解析失败:%v", err)
  18464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18465. return
  18466. }
  18467. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18468. data := make(map[string]interface{})
  18469. client := &http.Client{}
  18470. data["psn_no"] = his.PsnNo
  18471. data["mdtrt_id"] = his.Number
  18472. data["doctor"] = roles.UserName
  18473. data["department"] = department.Name
  18474. data["org_name"] = miConfig.OrgName
  18475. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18476. data["doctor_id"] = doctor_info.DoctorNumber
  18477. data["new_doctor_name"] = doctor_info.UserName
  18478. data["fixmedins_code"] = miConfig.Code
  18479. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18480. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18481. data["secret_key"] = miConfig.SecretKey
  18482. data["sick_code"] = sickConfig.CountryCode
  18483. data["sick_name"] = sickConfig.ClassName
  18484. data["url"] = miConfig.Url
  18485. data["ak"] = miConfig.AccessKey
  18486. data["begin_time"] = begin_time
  18487. data["cainfo"] = miConfig.Cainfo
  18488. data["dept"] = strconv.FormatInt(department.ID, 10)
  18489. data["config"] = config
  18490. bytesData, _ := json.Marshal(data)
  18491. var req *http.Request
  18492. if miConfig.MdtrtareaAdmvs == "320921" {
  18493. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18494. //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 +
  18495. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  18496. } else {
  18497. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  18498. }
  18499. resp, _ := client.Do(req)
  18500. defer resp.Body.Close()
  18501. body, ioErr := ioutil.ReadAll(resp.Body)
  18502. if ioErr != nil {
  18503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18505. return
  18506. }
  18507. var respJSON map[string]interface{}
  18508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18511. return
  18512. }
  18513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18514. userJSONBytes, _ := json.Marshal(respJSON)
  18515. fmt.Println("log")
  18516. fmt.Println(string(userJSONBytes))
  18517. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18518. utils.ErrorLog("解析失败:%v", err)
  18519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18520. return
  18521. }
  18522. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18523. res2.Output = ressix10265.Output
  18524. res2.ErrMsg = ressix10265.ErrMsg
  18525. res2.Cainfo = ressix10265.Cainfo
  18526. res2.WarnMsg = ressix10265.WarnMsg
  18527. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18528. res2.Infcode = infocode
  18529. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18530. data := make(map[string]interface{})
  18531. client := &http.Client{}
  18532. data["psn_no"] = his.PsnNo
  18533. data["mdtrt_id"] = his.Number
  18534. data["doctor"] = roles.UserName
  18535. data["department"] = department.Name
  18536. data["org_name"] = miConfig.OrgName
  18537. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18538. data["doctor_id"] = doctor_info.DoctorNumber
  18539. data["new_doctor_name"] = doctor_info.UserName
  18540. data["fixmedins_code"] = miConfig.Code
  18541. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18542. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18543. data["secret_key"] = miConfig.SecretKey
  18544. data["sick_code"] = sickConfig.CountryCode
  18545. data["sick_name"] = sickConfig.ClassName
  18546. data["url"] = miConfig.Url
  18547. data["ak"] = miConfig.AccessKey
  18548. data["begin_time"] = begin_time
  18549. data["cainfo"] = miConfig.Cainfo
  18550. data["dept"] = strconv.FormatInt(department.ID, 10)
  18551. data["config"] = config
  18552. bytesData, _ := json.Marshal(data)
  18553. var req *http.Request
  18554. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  18555. resp, _ := client.Do(req)
  18556. defer resp.Body.Close()
  18557. body, ioErr := ioutil.ReadAll(resp.Body)
  18558. if ioErr != nil {
  18559. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18561. return
  18562. }
  18563. var respJSON map[string]interface{}
  18564. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18565. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18567. return
  18568. }
  18569. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18570. userJSONBytes, _ := json.Marshal(respJSON)
  18571. fmt.Println("log")
  18572. fmt.Println(string(userJSONBytes))
  18573. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  18574. utils.ErrorLog("解析失败:%v", err)
  18575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18576. return
  18577. }
  18578. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18579. res2.Output = ressix10265.Output
  18580. res2.ErrMsg = ressix10265.ErrMsg
  18581. res2.Cainfo = ressix10265.Cainfo
  18582. res2.WarnMsg = ressix10265.WarnMsg
  18583. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18584. res2.Infcode = infocode
  18585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  18586. 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)
  18587. saveLog(result, requestLog, "2203", "上传就诊信息")
  18588. var respJSON2 map[string]interface{}
  18589. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18590. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18592. return
  18593. }
  18594. userJSONBytes2, _ := json.Marshal(respJSON2)
  18595. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18596. utils.ErrorLog("解析失败:%v", err)
  18597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18598. return
  18599. }
  18600. 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)
  18601. fmt.Println(result2)
  18602. fmt.Println(src_request)
  18603. } else if miConfig.MdtrtareaAdmvs == "441799" {
  18604. data := make(map[string]interface{})
  18605. client := &http.Client{}
  18606. data["psn_no"] = his.PsnNo
  18607. data["mdtrt_id"] = his.Number
  18608. data["doctor"] = roles.UserName
  18609. data["department"] = department.Name
  18610. data["org_name"] = miConfig.OrgName
  18611. data["med_type"] = strconv.FormatInt(reg_type, 10)
  18612. data["doctor_id"] = doctor_info.DoctorNumber
  18613. data["new_doctor_name"] = doctor_info.UserName
  18614. data["fixmedins_code"] = miConfig.Code
  18615. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18616. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18617. data["secret_key"] = miConfig.SecretKey
  18618. data["sick_code"] = sickConfig.CountryCode
  18619. data["sick_name"] = sickConfig.ClassName
  18620. data["url"] = miConfig.Url
  18621. data["ak"] = miConfig.AccessKey
  18622. data["begin_time"] = begin_time
  18623. data["cainfo"] = miConfig.Cainfo
  18624. data["dept"] = strconv.FormatInt(department.ID, 10)
  18625. data["config"] = config
  18626. bytesData, _ := json.Marshal(data)
  18627. var req *http.Request
  18628. req, _ = http.NewRequest("POST", "http://172.20.10.81:9532/"+"gdyb/2203", bytes.NewReader(bytesData))
  18629. resp, _ := client.Do(req)
  18630. defer resp.Body.Close()
  18631. body, ioErr := ioutil.ReadAll(resp.Body)
  18632. if ioErr != nil {
  18633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18635. return
  18636. }
  18637. var respJSON map[string]interface{}
  18638. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18641. return
  18642. }
  18643. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18644. userJSONBytes, _ := json.Marshal(respJSON)
  18645. fmt.Println("log")
  18646. fmt.Println(string(userJSONBytes))
  18647. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  18648. utils.ErrorLog("解析失败:%v", err)
  18649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18650. return
  18651. }
  18652. } else {
  18653. if miConfig.MdtrtareaAdmvs == "440781" { //
  18654. 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)
  18655. } else {
  18656. if miConfig.Code == "H15049901371" {
  18657. //赤峰地区国家医保医疗类别
  18658. //职工透析:医疗类别选特殊情况门诊990502
  18659. //居民定额血透门慢: 医疗类别选门诊慢病140104
  18660. var med_type string
  18661. if his.Insutype == "390" {
  18662. if reg_type == 14 {
  18663. med_type = "9933"
  18664. } else if reg_type == 11 {
  18665. med_type = "11"
  18666. }
  18667. } else if his.Insutype == "310" {
  18668. if reg_type == 14 {
  18669. med_type = "990502"
  18670. } else if reg_type == 11 {
  18671. med_type = "11"
  18672. }
  18673. }
  18674. 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)
  18675. } else {
  18676. 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)
  18677. }
  18678. }
  18679. saveLog(result, requestLog, "2203", "上传就诊信息")
  18680. var respJSON2 map[string]interface{}
  18681. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  18682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18684. return
  18685. }
  18686. userJSONBytes2, _ := json.Marshal(respJSON2)
  18687. if miConfig.Code == "H15049901371" {
  18688. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  18689. utils.ErrorLog("解析失败:%v", err)
  18690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18691. return
  18692. }
  18693. res2.InfRefmsgid = ressix10265.InfRefmsgid
  18694. res2.Output = ressix10265.Output
  18695. res2.ErrMsg = ressix10265.ErrMsg
  18696. res2.Cainfo = ressix10265.Cainfo
  18697. res2.WarnMsg = ressix10265.WarnMsg
  18698. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  18699. res2.Infcode = infocode
  18700. } else {
  18701. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  18702. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  18703. utils.ErrorLog("解析失败:%v", err)
  18704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18705. return
  18706. }
  18707. res2.Infcode = res3.Infcode
  18708. } else {
  18709. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  18710. utils.ErrorLog("解析失败:%v", err)
  18711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18712. return
  18713. }
  18714. }
  18715. }
  18716. }
  18717. if res2.Infcode != 0 {
  18718. adminUser := c.GetAdminUserInfo()
  18719. errlog := &models.HisOrderError{
  18720. UserOrgId: adminUser.CurrentOrgId,
  18721. Ctime: time.Now().Unix(),
  18722. Mtime: time.Now().Unix(),
  18723. ErrMsg: res2.ErrMsg,
  18724. Status: 1,
  18725. PatientId: id,
  18726. RecordTime: recordDateTime,
  18727. Stage: 3,
  18728. }
  18729. service.CreateErrMsgLog(errlog)
  18730. c.ServeSuccessJSON(map[string]interface{}{
  18731. "failed_code": -10,
  18732. "msg": res2.ErrMsg,
  18733. })
  18734. return
  18735. } else {
  18736. his.Diagnosis = diagnosis_id
  18737. his.SickType = sickConfig.ID
  18738. //var p_type int64
  18739. //if reg_type == 1111 || reg_type == 1112 {
  18740. // p_type = 11
  18741. //
  18742. //}
  18743. his.PType = fmt.Sprintf("%d", reg_type)
  18744. service.UpdateHisPatientThree(&his)
  18745. data := make(map[string]interface{})
  18746. if settle_accounts_type == 1 { //日结
  18747. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  18748. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  18749. } else {
  18750. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  18751. }
  18752. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  18753. data["pre"] = prescriptions
  18754. } else { //月结
  18755. start_time_str := c.GetString("start_time")
  18756. end_time_str := c.GetString("end_time")
  18757. timeLayout := "2006-01-02"
  18758. loc, _ := time.LoadLocation("Local")
  18759. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  18760. if err != nil {
  18761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18762. return
  18763. }
  18764. recordStartTime := theStartTime.Unix()
  18765. start_time = recordStartTime
  18766. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  18767. if err != nil {
  18768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  18769. return
  18770. }
  18771. recordEndTime := theEndTime.Unix()
  18772. end_time = recordEndTime
  18773. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  18774. data["pre"] = prescriptions
  18775. }
  18776. timestamp := time.Now().Unix()
  18777. tempTime := time.Unix(timestamp, 0)
  18778. timeFormat := tempTime.Format("20060102150405")
  18779. chrgBchno := rand.Intn(100000) + 10000
  18780. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  18781. strconv.FormatInt(his.PatientId, 10)
  18782. client := &http.Client{}
  18783. data["psn_no"] = his.PsnNo
  18784. data["mdtrt_id"] = his.Number
  18785. data["chrg_bchno"] = chrg_bchno
  18786. data["org_name"] = miConfig.OrgName
  18787. data["doctor"] = doctor_info.UserName
  18788. data["doctor_id"] = doctor_info.DoctorNumber
  18789. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  18790. data["fixmedins_code"] = miConfig.Code
  18791. data["dept_code"] = department.Number
  18792. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  18793. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  18794. data["secret_key"] = miConfig.SecretKey
  18795. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  18796. data["url"] = miConfig.Url
  18797. data["ak"] = miConfig.AccessKey
  18798. data["new_doctor_name"] = patientPrescription.Doctor
  18799. data["diag_code"] = sickConfig.CountryCode
  18800. data["cainfo"] = miConfig.Cainfo
  18801. data["opter"] = roles.UserName
  18802. var ids []int64
  18803. for _, item := range prescriptions {
  18804. ids = append(ids, item.ID)
  18805. }
  18806. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  18807. if config.IsOpen == 1 { //对接了医保,走医保流程
  18808. var res ResultFour
  18809. var resFour10265 ResultFour10265
  18810. if miConfig.MdtrtareaAdmvs == "421300" {
  18811. bytesData, _ := json.Marshal(data)
  18812. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18813. resp, _ := client.Do(req)
  18814. defer resp.Body.Close()
  18815. body, ioErr := ioutil.ReadAll(resp.Body)
  18816. if ioErr != nil {
  18817. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18819. return
  18820. }
  18821. var respJSON map[string]interface{}
  18822. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18823. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18825. return
  18826. }
  18827. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18828. userJSONBytes, _ := json.Marshal(respJSON)
  18829. fmt.Println("log")
  18830. fmt.Println(string(userJSONBytes))
  18831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18832. utils.ErrorLog("解析失败:%v", err)
  18833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18834. return
  18835. }
  18836. } else if miConfig.MdtrtareaAdmvs == "420200" {
  18837. bytesData, _ := json.Marshal(data)
  18838. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  18839. resp, _ := client.Do(req)
  18840. defer resp.Body.Close()
  18841. body, ioErr := ioutil.ReadAll(resp.Body)
  18842. if ioErr != nil {
  18843. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18845. return
  18846. }
  18847. var respJSON map[string]interface{}
  18848. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18849. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18851. return
  18852. }
  18853. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18854. userJSONBytes, _ := json.Marshal(respJSON)
  18855. fmt.Println("log")
  18856. fmt.Println(string(userJSONBytes))
  18857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18858. utils.ErrorLog("解析失败:%v", err)
  18859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18860. return
  18861. }
  18862. } else if miConfig.MdtrtareaAdmvs == "420902" {
  18863. bytesData, _ := json.Marshal(data)
  18864. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18865. resp, _ := client.Do(req)
  18866. defer resp.Body.Close()
  18867. body, ioErr := ioutil.ReadAll(resp.Body)
  18868. if ioErr != nil {
  18869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18871. return
  18872. }
  18873. var respJSON map[string]interface{}
  18874. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18877. return
  18878. }
  18879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18880. userJSONBytes, _ := json.Marshal(respJSON)
  18881. fmt.Println("log")
  18882. fmt.Println(string(userJSONBytes))
  18883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18884. utils.ErrorLog("解析失败:%v", err)
  18885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18886. return
  18887. }
  18888. }else if miConfig.MdtrtareaAdmvs == "421182" {
  18889. bytesData, _ := json.Marshal(data)
  18890. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  18891. resp, _ := client.Do(req)
  18892. defer resp.Body.Close()
  18893. body, ioErr := ioutil.ReadAll(resp.Body)
  18894. if ioErr != nil {
  18895. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18897. return
  18898. }
  18899. var respJSON map[string]interface{}
  18900. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18901. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18903. return
  18904. }
  18905. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18906. userJSONBytes, _ := json.Marshal(respJSON)
  18907. fmt.Println("log")
  18908. fmt.Println(string(userJSONBytes))
  18909. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  18910. utils.ErrorLog("解析失败:%v", err)
  18911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18912. return
  18913. }
  18914. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  18915. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  18916. if result3101.Infcode == "0" {
  18917. if len(result3101.Output.Result) > 0 {
  18918. var errMsgs []string
  18919. for _, item := range result3101.Output.Result {
  18920. errMsgs = append(errMsgs, item.VolaCont)
  18921. }
  18922. c.ServeSuccessJSON(map[string]interface{}{
  18923. "failed_code": -10,
  18924. "msg": errMsgs,
  18925. })
  18926. return
  18927. }
  18928. }
  18929. bytesData, _ := json.Marshal(data)
  18930. var req *http.Request
  18931. if miConfig.MdtrtareaAdmvs == "320921" {
  18932. data["diag_code"] = sickConfig.CountryCode
  18933. fmt.Println(data)
  18934. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18935. } else {
  18936. data["diag_code"] = sickConfig.CountryCode
  18937. fmt.Println(data)
  18938. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  18939. }
  18940. resp, _ := client.Do(req)
  18941. defer resp.Body.Close()
  18942. body, ioErr := ioutil.ReadAll(resp.Body)
  18943. if ioErr != nil {
  18944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  18945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18946. return
  18947. }
  18948. var respJSON map[string]interface{}
  18949. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  18950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  18951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18952. return
  18953. }
  18954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  18955. userJSONBytes, _ := json.Marshal(respJSON)
  18956. fmt.Println("log")
  18957. fmt.Println(string(userJSONBytes))
  18958. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  18959. utils.ErrorLog("解析失败:%v", err)
  18960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  18961. return
  18962. }
  18963. res.InfRefmsgid = resFour10265.InfRefmsgid
  18964. res.Output = resFour10265.Output
  18965. res.ErrMsg = resFour10265.ErrMsg
  18966. res.Cainfo = resFour10265.Cainfo
  18967. res.WarnMsg = resFour10265.WarnMsg
  18968. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  18969. res.Infcode = infocode
  18970. } else if miConfig.MdtrtareaAdmvs == "150499" {
  18971. var pagesize int = 2
  18972. var start int = 1
  18973. var stop int
  18974. var pagecount int
  18975. var curpage int
  18976. var isSuccess bool = true
  18977. data["doctor_id"] = doctor_info.DoctorNumber
  18978. //总页数,向上取整,注意除之前要先转换类型为float64
  18979. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  18980. for curpage = 1; curpage <= pagecount; curpage++ {
  18981. if curpage == 1 {
  18982. start = 1
  18983. } else {
  18984. start = (curpage-1)*pagesize + 1
  18985. }
  18986. stop = curpage * pagesize
  18987. if stop > len(prescriptions) {
  18988. stop = len(prescriptions)
  18989. }
  18990. //var requestLog string
  18991. data["pre"] = prescriptions[start-1 : stop]
  18992. fmt.Println(data["pre"])
  18993. bytesData, _ := json.Marshal(data)
  18994. var req *http.Request
  18995. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  18996. resp, _ := client.Do(req)
  18997. defer resp.Body.Close()
  18998. body, ioErr := ioutil.ReadAll(resp.Body)
  18999. if ioErr != nil {
  19000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19002. return
  19003. }
  19004. var respJSON map[string]interface{}
  19005. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19008. return
  19009. }
  19010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19011. userJSONBytes, _ := json.Marshal(respJSON)
  19012. fmt.Println("log")
  19013. fmt.Println(string(userJSONBytes))
  19014. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19015. utils.ErrorLog("解析失败:%v", err)
  19016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19017. return
  19018. }
  19019. res.InfRefmsgid = resFour10265.InfRefmsgid
  19020. res.Output = resFour10265.Output
  19021. res.ErrMsg = resFour10265.ErrMsg
  19022. res.Cainfo = resFour10265.Cainfo
  19023. res.WarnMsg = resFour10265.WarnMsg
  19024. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19025. res.Infcode = infocode
  19026. if infocode == 0 {
  19027. res.Output.Result = append(res.Output.Result, res.Output.Result...)
  19028. } else {
  19029. isSuccess = false
  19030. errlog := &models.HisOrderError{
  19031. UserOrgId: adminUser.CurrentOrgId,
  19032. Ctime: time.Now().Unix(),
  19033. Mtime: time.Now().Unix(),
  19034. Number: chrg_bchno,
  19035. ErrMsg: "",
  19036. Status: 1,
  19037. PatientId: id,
  19038. RecordTime: recordDateTime,
  19039. Stage: 4,
  19040. }
  19041. service.CreateErrMsgLog(errlog)
  19042. c.ServeSuccessJSON(map[string]interface{}{
  19043. "failed_code": -10,
  19044. "msg": res.ErrMsg,
  19045. })
  19046. return
  19047. }
  19048. }
  19049. if isSuccess {
  19050. res.Infcode = 0
  19051. }
  19052. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19053. 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)
  19054. var dat map[string]interface{}
  19055. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19056. fmt.Println(dat)
  19057. } else {
  19058. fmt.Println(err)
  19059. }
  19060. saveLog(result, request_log, "2204", "上传费用明细")
  19061. userJSONBytes, _ := json.Marshal(dat)
  19062. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19063. utils.ErrorLog("解析失败:%v", err)
  19064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19065. return
  19066. }
  19067. res.InfRefmsgid = resFour10265.InfRefmsgid
  19068. res.Output = resFour10265.Output
  19069. res.ErrMsg = resFour10265.ErrMsg
  19070. res.Cainfo = resFour10265.Cainfo
  19071. res.WarnMsg = resFour10265.WarnMsg
  19072. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19073. res.Infcode = infocode
  19074. } else if miConfig.MdtrtareaAdmvs == "441799" {
  19075. bytesData, _ := json.Marshal(data)
  19076. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  19077. resp, _ := client.Do(req)
  19078. defer resp.Body.Close()
  19079. body, ioErr := ioutil.ReadAll(resp.Body)
  19080. if ioErr != nil {
  19081. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19083. return
  19084. }
  19085. var respJSON map[string]interface{}
  19086. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  19087. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19089. return
  19090. }
  19091. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19092. userJSONBytes, _ := json.Marshal(respJSON)
  19093. fmt.Println("log")
  19094. fmt.Println(string(userJSONBytes))
  19095. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19096. utils.ErrorLog("解析失败:%v", err)
  19097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19098. return
  19099. }
  19100. } else {
  19101. if miConfig.Code == "H15049901371" {
  19102. 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)
  19103. var dat map[string]interface{}
  19104. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19105. fmt.Println(dat)
  19106. } else {
  19107. fmt.Println(err)
  19108. }
  19109. saveLog(result, request_log, "2204", "上传费用明细")
  19110. userJSONBytes, _ := json.Marshal(dat)
  19111. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  19112. utils.ErrorLog("解析失败:%v", err)
  19113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19114. return
  19115. }
  19116. res.InfRefmsgid = resFour10265.InfRefmsgid
  19117. res.Output = resFour10265.Output
  19118. res.ErrMsg = resFour10265.ErrMsg
  19119. res.Cainfo = resFour10265.Cainfo
  19120. res.WarnMsg = resFour10265.WarnMsg
  19121. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  19122. res.Infcode = infocode
  19123. } else {
  19124. 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)
  19125. var dat map[string]interface{}
  19126. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19127. fmt.Println(dat)
  19128. } else {
  19129. fmt.Println(err)
  19130. }
  19131. saveLog(result, request_log, "2204", "上传费用明细")
  19132. userJSONBytes, _ := json.Marshal(dat)
  19133. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19134. utils.ErrorLog("解析失败:%v", err)
  19135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19136. return
  19137. }
  19138. }
  19139. }
  19140. if res.Infcode == 0 {
  19141. order := &models.HisOrder{
  19142. UserOrgId: adminUser.CurrentOrgId,
  19143. HisPatientId: his.ID,
  19144. PatientId: his.PatientId,
  19145. SettleAccountsDate: recordDateTime,
  19146. MdtrtId: his.Number,
  19147. PsnNo: his.PsnNo,
  19148. MedType: strconv.FormatInt(reg_type, 10),
  19149. Ctime: time.Now().Unix(),
  19150. Mtime: time.Now().Unix(),
  19151. Status: 1,
  19152. Number: chrg_bchno,
  19153. Infcode: res.Infcode,
  19154. WarnMsg: res.WarnMsg,
  19155. Cainfo: res.Cainfo,
  19156. ErrMsg: res.ErrMsg,
  19157. RespondTime: res.RefmsgTime,
  19158. InfRefmsgid: res.InfRefmsgid,
  19159. OrderStatus: 1,
  19160. PayWay: pay_way,
  19161. PayWays: pay_ways,
  19162. OthDesc: oth_desc,
  19163. PayPrice: pay_price,
  19164. PayCardNo: pay_card_no,
  19165. DiscountPrice: discount_price,
  19166. PreferentialPrice: preferential_price,
  19167. RealityPrice: reality_price,
  19168. FoundPrice: found_price,
  19169. MedicalInsurancePrice: medical_insurance_price,
  19170. PrivatePrice: private_price,
  19171. IsMedicineInsurance: 1,
  19172. SettleType: settle_accounts_type,
  19173. SettleStartTime: start_time,
  19174. SettleEndTime: end_time,
  19175. Creator: roles.AdminUserId,
  19176. Modify: roles.AdminUserId,
  19177. FaPiaoNumber: fapiao_number,
  19178. FaPiaoCode: fapiao_code,
  19179. PType: 2,
  19180. Diagnosis: diagnosis_id,
  19181. CashPay: cash_pay,
  19182. WechatPay: wechat_pay,
  19183. AliPay: ali_pay,
  19184. JifenPay: jifen_pay,
  19185. BandCardPay: band_card_pay,
  19186. }
  19187. err = service.CreateOrder(order)
  19188. if err != nil {
  19189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  19190. return
  19191. }
  19192. for _, item := range res.Output.Result {
  19193. temp := strings.Split(item.FeedetlSn, "-")
  19194. var advice_id int64 = 0
  19195. var project_id int64 = 0
  19196. var types int64 = 0
  19197. id, _ := strconv.ParseInt(temp[2], 10, 64)
  19198. types, _ = strconv.ParseInt(temp[1], 10, 64)
  19199. if temp[1] == "1" {
  19200. advice_id = id
  19201. project_id = 0
  19202. } else if temp[1] == "2" {
  19203. advice_id = 0
  19204. project_id = id
  19205. }
  19206. if item.MedChrgitmType == "9" {
  19207. item.MedChrgitmType = "09"
  19208. }
  19209. info := &models.HisOrderInfo{
  19210. OrderNumber: order.Number,
  19211. FeedetlSn: item.FeedetlSn,
  19212. UploadDate: time.Now().Unix(),
  19213. AdviceId: advice_id,
  19214. DetItemFeeSumamt: item.DetItemFeeSumamt,
  19215. Cnt: item.Cnt,
  19216. Pric: float64(item.Pric),
  19217. PatientId: his.PatientId,
  19218. PricUplmtAmt: item.PricUplmtAmt,
  19219. SelfpayProp: item.SelfpayProp,
  19220. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  19221. OverlmtAmt: item.OverlmtAmt,
  19222. PreselfpayAmt: item.PreselfpayAmt,
  19223. BasMednFlag: item.BasMednFlag,
  19224. MedChrgitmType: item.MedChrgitmType,
  19225. HiNegoDrugFlag: item.HiNegoDrugFlag,
  19226. Status: 1,
  19227. Memo: item.Memo,
  19228. Mtime: time.Now().Unix(),
  19229. InscpScpAmt: item.InscpScpAmt,
  19230. DrtReimFlag: item.DrtReimFlag,
  19231. Ctime: time.Now().Unix(),
  19232. ListSpItemFlag: item.ListSpItemFlag,
  19233. ChldMedcFlag: item.ChldMedcFlag,
  19234. LmtUsedFlag: item.LmtUsedFlag,
  19235. ChrgitmLv: item.ChrgitmLv,
  19236. UserOrgId: adminUser.CurrentOrgId,
  19237. HisPatientId: his.ID,
  19238. OrderId: order.ID,
  19239. ProjectId: project_id,
  19240. Type: types,
  19241. }
  19242. service.CreateOrderInfo(info)
  19243. }
  19244. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  19245. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  19246. var total float64
  19247. for _, item := range prescriptions {
  19248. if item.Type == 1 { //药品
  19249. for _, subItem := range item.HisDoctorAdviceInfo {
  19250. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19251. total_one := price * subItem.PrescribingNumber
  19252. total = total + total_one
  19253. }
  19254. }
  19255. if item.Type == 2 { //项目
  19256. for _, subItem := range item.HisPrescriptionProject {
  19257. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  19258. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  19259. total_one := price * cnt
  19260. total = total + total_one
  19261. }
  19262. }
  19263. }
  19264. allTotal := fmt.Sprintf("%.2f", total)
  19265. //if adminUser.CurrentOrgId == 9919 {
  19266. //
  19267. // allTotal = fmt.Sprintf("%.2f", total)
  19268. //
  19269. //} else {
  19270. //
  19271. // allTotal = fmt.Sprintf("%.2f", total)
  19272. //
  19273. //}
  19274. if res.Infcode == 0 {
  19275. var rf []*ResultFive
  19276. json.Unmarshal([]byte(his.Iinfo), &rf)
  19277. chrg_bchno := chrg_bchno
  19278. cert_no := his.Certno
  19279. var insutypes []string
  19280. var insutype string
  19281. var is390 int = 0
  19282. var is310 int = 0
  19283. for _, item := range rf {
  19284. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19285. insutypes = append(insutypes, item.Insutype)
  19286. }
  19287. }
  19288. if len(insutypes) == 1 {
  19289. insutype = insutypes[0]
  19290. } else {
  19291. for _, i := range insutypes {
  19292. if i == "390" {
  19293. is390 = 1
  19294. }
  19295. if i == "310" {
  19296. is310 = 1
  19297. }
  19298. }
  19299. }
  19300. if is390 == 1 {
  19301. insutype = "390"
  19302. }
  19303. if is310 == 1 {
  19304. insutype = "310"
  19305. }
  19306. if len(insutypes) == 0 {
  19307. insutype = "310"
  19308. }
  19309. if len(insutypes) == 2 {
  19310. insutype = strconv.FormatInt(his.SocialType, 10)
  19311. }
  19312. insutype = strconv.FormatInt(his.SocialType, 10)
  19313. //insutype = "390"
  19314. if his.IdCardType == 1 {
  19315. // cert_no = his.MedicalInsuranceNumber
  19316. cert_no = his.Certno
  19317. } else {
  19318. cert_no = his.Certno
  19319. }
  19320. var res ResultSeven
  19321. var resSeven10265 ResultSeven10265
  19322. var gzresSeven10265Two GZResultSeven10265Two
  19323. var src_resquest string
  19324. var result2 string
  19325. if miConfig.MdtrtareaAdmvs == "421300" {
  19326. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19327. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19328. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19329. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19330. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19331. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19332. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19333. resp, requestErr := http.Get(api)
  19334. if requestErr != nil {
  19335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19336. return
  19337. }
  19338. body, ioErr := ioutil.ReadAll(resp.Body)
  19339. if ioErr != nil {
  19340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19342. return
  19343. }
  19344. var respJSON map[string]interface{}
  19345. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19348. return
  19349. }
  19350. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19351. result, _ := json.Marshal(respJSON)
  19352. if miConfig.Code == "H15049901371" {
  19353. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19354. utils.ErrorLog("解析失败:%v", err)
  19355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19356. return
  19357. }
  19358. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19359. res.Output = resSeven10265.Output
  19360. res.ErrMsg = resSeven10265.ErrMsg
  19361. res.Cainfo = resSeven10265.Cainfo
  19362. res.WarnMsg = resSeven10265.WarnMsg
  19363. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19364. res.Infcode = infocode
  19365. } else {
  19366. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19367. utils.ErrorLog("解析失败:%v", err)
  19368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19369. return
  19370. }
  19371. }
  19372. } else if miConfig.MdtrtareaAdmvs == "420200" {
  19373. if reg_type == 11 && his.Insutype == "390" {
  19374. reg_type = 110104
  19375. }
  19376. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19377. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19378. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19379. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19380. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19381. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19382. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19383. resp, requestErr := http.Get(api)
  19384. if requestErr != nil {
  19385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19386. return
  19387. }
  19388. body, ioErr := ioutil.ReadAll(resp.Body)
  19389. if ioErr != nil {
  19390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19392. return
  19393. }
  19394. var respJSON map[string]interface{}
  19395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19398. return
  19399. }
  19400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19401. result, _ := json.Marshal(respJSON)
  19402. if miConfig.Code == "H15049901371" {
  19403. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19404. utils.ErrorLog("解析失败:%v", err)
  19405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19406. return
  19407. }
  19408. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19409. res.Output = resSeven10265.Output
  19410. res.ErrMsg = resSeven10265.ErrMsg
  19411. res.Cainfo = resSeven10265.Cainfo
  19412. res.WarnMsg = resSeven10265.WarnMsg
  19413. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19414. res.Infcode = infocode
  19415. } else {
  19416. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19417. utils.ErrorLog("解析失败:%v", err)
  19418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19419. return
  19420. }
  19421. }
  19422. } else if miConfig.MdtrtareaAdmvs == "420902" {
  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. if miConfig.Code == "H15049901371" {
  19453. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19454. utils.ErrorLog("解析失败:%v", err)
  19455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19456. return
  19457. }
  19458. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19459. res.Output = resSeven10265.Output
  19460. res.ErrMsg = resSeven10265.ErrMsg
  19461. res.Cainfo = resSeven10265.Cainfo
  19462. res.WarnMsg = resSeven10265.WarnMsg
  19463. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19464. res.Infcode = infocode
  19465. } else {
  19466. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19467. utils.ErrorLog("解析失败:%v", err)
  19468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19469. return
  19470. }
  19471. }
  19472. } else if miConfig.MdtrtareaAdmvs == "421182" {
  19473. if reg_type == 11 && his.Insutype == "390" {
  19474. reg_type = 110104
  19475. }
  19476. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19477. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19478. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19479. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19480. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19481. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19482. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  19483. resp, requestErr := http.Get(api)
  19484. if requestErr != nil {
  19485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19486. return
  19487. }
  19488. body, ioErr := ioutil.ReadAll(resp.Body)
  19489. if ioErr != nil {
  19490. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19492. return
  19493. }
  19494. var respJSON map[string]interface{}
  19495. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19496. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19498. return
  19499. }
  19500. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19501. result, _ := json.Marshal(respJSON)
  19502. if miConfig.Code == "H15049901371" {
  19503. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19504. utils.ErrorLog("解析失败:%v", err)
  19505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19506. return
  19507. }
  19508. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19509. res.Output = resSeven10265.Output
  19510. res.ErrMsg = resSeven10265.ErrMsg
  19511. res.Cainfo = resSeven10265.Cainfo
  19512. res.WarnMsg = resSeven10265.WarnMsg
  19513. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19514. res.Infcode = infocode
  19515. } else {
  19516. if err := json.Unmarshal([]byte(result), &res); err != nil {
  19517. utils.ErrorLog("解析失败:%v", err)
  19518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19519. return
  19520. }
  19521. }
  19522. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  19523. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  19524. if result3101.Infcode == "0" {
  19525. if len(result3101.Output.Result) > 0 {
  19526. var errMsgs []string
  19527. for _, item := range result3101.Output.Result {
  19528. errMsgs = append(errMsgs, item.VolaCont)
  19529. }
  19530. c.ServeSuccessJSON(map[string]interface{}{
  19531. "failed_code": -10,
  19532. "msg": errMsgs,
  19533. })
  19534. return
  19535. } else {
  19536. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19537. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  19538. bas := strings.Split(psn_info.CardInfo, "|")
  19539. if his.IdCardType == 1 {
  19540. cert_no = bas[2]
  19541. } else if his.IdCardType == 3 {
  19542. cert_no = his.Certno
  19543. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  19544. } else if his.IdCardType == 4 {
  19545. cert_no = his.Certno
  19546. psn_info.VerifyNumber = psn_info.VerifyNumber
  19547. }
  19548. var api string
  19549. if miConfig.MdtrtareaAdmvs == "320921" {
  19550. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19551. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19552. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19554. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19555. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19556. "&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
  19557. } else {
  19558. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19559. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19560. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19561. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19562. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19563. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19564. "&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
  19565. }
  19566. resp, requestErr := http.Get(api)
  19567. if requestErr != nil {
  19568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19569. return
  19570. }
  19571. body, ioErr := ioutil.ReadAll(resp.Body)
  19572. if ioErr != nil {
  19573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19575. return
  19576. }
  19577. var respJSON map[string]interface{}
  19578. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19581. return
  19582. }
  19583. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19584. result, _ := json.Marshal(respJSON)
  19585. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19586. utils.ErrorLog("解析失败:%v", err)
  19587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19588. return
  19589. }
  19590. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19591. res.Output = resSeven10265.Output
  19592. res.ErrMsg = resSeven10265.ErrMsg
  19593. res.Cainfo = resSeven10265.Cainfo
  19594. res.WarnMsg = resSeven10265.WarnMsg
  19595. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19596. res.Infcode = infocode
  19597. }
  19598. }
  19599. } else if miConfig.MdtrtareaAdmvs == "150499" {
  19600. psn_info, _ := service.GetPsnByPatientId(id)
  19601. var verify_number string
  19602. if psn_info.IdCardType == 4 {
  19603. verify_number = psn_info.VerifyNumber
  19604. } else if psn_info.IdCardType == 1 {
  19605. bas := strings.Split(psn_info.CardInfo, "|")
  19606. cardNumber := bas[2]
  19607. verify_number = cardNumber
  19608. } else {
  19609. psn_info.IdCardType = 2
  19610. verify_number = psn_info.Certno
  19611. }
  19612. var api string
  19613. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  19614. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  19615. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  19616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  19617. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  19618. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  19619. "&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
  19620. resp, requestErr := http.Get(api)
  19621. if requestErr != nil {
  19622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19623. return
  19624. }
  19625. body, ioErr := ioutil.ReadAll(resp.Body)
  19626. if ioErr != nil {
  19627. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  19628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19629. return
  19630. }
  19631. var respJSON map[string]interface{}
  19632. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  19633. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  19634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19635. return
  19636. }
  19637. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  19638. result, _ := json.Marshal(respJSON)
  19639. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  19640. utils.ErrorLog("解析失败:%v", err)
  19641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19642. return
  19643. }
  19644. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19645. res.Output = resSeven10265.Output
  19646. res.ErrMsg = resSeven10265.ErrMsg
  19647. res.Cainfo = resSeven10265.Cainfo
  19648. res.WarnMsg = resSeven10265.WarnMsg
  19649. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19650. res.Infcode = infocode
  19651. } else if miConfig.MdtrtareaAdmvs == "350500" {
  19652. var cert_no string
  19653. if his.IdCardType == 4 {
  19654. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19655. cert_no = psn_info.VerifyNumber
  19656. 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)
  19657. } else if his.IdCardType == 1 {
  19658. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19659. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  19660. 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)
  19661. }
  19662. //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)
  19663. var dat map[string]interface{}
  19664. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19665. fmt.Println(dat)
  19666. } else {
  19667. fmt.Println(err)
  19668. }
  19669. saveLog(result2, src_resquest, "2207", "结算")
  19670. userJSONBytes, _ := json.Marshal(dat)
  19671. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19672. utils.ErrorLog("解析失败:%v", err)
  19673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19674. return
  19675. }
  19676. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19677. res.Output = resSeven10265.Output
  19678. res.ErrMsg = resSeven10265.ErrMsg
  19679. res.Cainfo = resSeven10265.Cainfo
  19680. res.WarnMsg = resSeven10265.WarnMsg
  19681. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19682. res.Infcode = infocode
  19683. } else if miConfig.MdtrtareaAdmvs == "450721" {
  19684. res2 := c.GetoleInfo()
  19685. if res2.Infcode == 0 {
  19686. var result string
  19687. var request_log string
  19688. var result_log string
  19689. if res2.Output.MdtrtCertType == "02" {
  19690. 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)
  19691. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19692. } else if res2.Output.MdtrtCertType == "01" {
  19693. 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)
  19694. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19695. } else {
  19696. 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)
  19697. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  19698. }
  19699. var dat map[string]interface{}
  19700. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  19701. fmt.Println(dat)
  19702. } else {
  19703. fmt.Println(err)
  19704. }
  19705. userJSONBytes, _ := json.Marshal(dat)
  19706. var res5 ResultTwo
  19707. //var resTwo10265 ResultTwo10265
  19708. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  19709. utils.ErrorLog("解析失败:%v", err)
  19710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19711. return
  19712. }
  19713. if res5.Infcode == -1 {
  19714. c.ServeSuccessJSON(map[string]interface{}{
  19715. "failed_code": -10,
  19716. "msg": res5.ErrMsg,
  19717. })
  19718. return
  19719. }
  19720. var insutypes []string
  19721. var insutype string
  19722. var is390 int = 0
  19723. var is310 int = 0
  19724. for _, item := range res5.Output.Iinfo {
  19725. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  19726. insutypes = append(insutypes, item.Insutype)
  19727. }
  19728. }
  19729. if len(insutypes) == 1 {
  19730. insutype = insutypes[0]
  19731. } else {
  19732. for _, i := range insutypes {
  19733. if i == "390" {
  19734. is390 = 1
  19735. }
  19736. if i == "310" {
  19737. is310 = 1
  19738. }
  19739. }
  19740. }
  19741. if is390 == 1 {
  19742. insutype = "390"
  19743. }
  19744. if is310 == 1 {
  19745. insutype = "310"
  19746. }
  19747. if len(insutypes) == 0 {
  19748. insutype = "310"
  19749. }
  19750. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  19751. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  19752. infoStr := string(Iinfos)
  19753. idetinfoStr := string(Idetinfos)
  19754. psn := &models.HisPsn{
  19755. PsnNo: res5.Output.Baseinfo.PsnNo,
  19756. PatientId: id,
  19757. Certno: res5.Output.Baseinfo.Certno,
  19758. Gend: res5.Output.Baseinfo.Gend,
  19759. Naty: res5.Output.Baseinfo.Naty,
  19760. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  19761. PsnName: res5.Output.Baseinfo.PsnName,
  19762. Idetinfo: idetinfoStr,
  19763. Insuinfo: infoStr,
  19764. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  19765. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  19766. VerifyNumber: res2.Output.EcToken,
  19767. }
  19768. if res2.Output.MdtrtCertType == "01" {
  19769. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19770. psn.VerifyNumber = res2.Output.EcToken
  19771. } else if res2.Output.MdtrtCertType == "02" {
  19772. psn.VerifyNumber = res2.Output.CardNo
  19773. } else {
  19774. psn.VerifyNumber = res2.Output.MdtrtCertNo
  19775. }
  19776. service.CreateHisPsn(psn)
  19777. if res2.Output.MdtrtCertType == "01" {
  19778. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19779. token := res2.Output.EcToken
  19780. 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)
  19781. } else if res2.Output.MdtrtCertType == "02" {
  19782. 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)
  19783. } else {
  19784. 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)
  19785. }
  19786. var dat2 map[string]interface{}
  19787. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  19788. fmt.Println(dat2)
  19789. } else {
  19790. fmt.Println(err)
  19791. }
  19792. userJSONBytes3, _ := json.Marshal(dat2)
  19793. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  19794. utils.ErrorLog("解析失败:%v", err)
  19795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19796. return
  19797. }
  19798. saveLog(result2, src_resquest, "2207", "结算")
  19799. } else {
  19800. c.ServeSuccessJSON(map[string]interface{}{
  19801. "failed_code": -10,
  19802. "msg": res2.ErrMsg,
  19803. })
  19804. return
  19805. }
  19806. } else {
  19807. if miConfig.Code == "H15049901371" {
  19808. //赤峰地区国家医保医疗类别
  19809. //职工透析:医疗类别选特殊情况门诊990502
  19810. //居民定额血透门慢: 医疗类别选门诊慢病140104
  19811. var med_type string
  19812. if his.Insutype == "390" {
  19813. if reg_type == 14 {
  19814. med_type = "9933"
  19815. } else if reg_type == 11 {
  19816. med_type = "11"
  19817. }
  19818. } else if his.Insutype == "310" {
  19819. if reg_type == 14 {
  19820. med_type = "990502"
  19821. } else if reg_type == 11 {
  19822. med_type = "11"
  19823. }
  19824. }
  19825. 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)
  19826. } else {
  19827. if his.IdCardType == 4 {
  19828. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19829. var token string
  19830. token = psn_info.VerifyNumber
  19831. 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)
  19832. } else {
  19833. if his.IdCardType == 1 {
  19834. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  19835. bas := strings.Split(psn_info.CardInfo, "|")
  19836. basNumber := bas[2]
  19837. cert_no = basNumber
  19838. }
  19839. 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)
  19840. }
  19841. }
  19842. //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)
  19843. var dat map[string]interface{}
  19844. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  19845. fmt.Println(dat)
  19846. } else {
  19847. fmt.Println(err)
  19848. }
  19849. saveLog(result2, src_resquest, "2207", "结算")
  19850. userJSONBytes, _ := json.Marshal(dat)
  19851. if miConfig.Code == "H15049901371" {
  19852. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  19853. utils.ErrorLog("解析失败:%v", err)
  19854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19855. return
  19856. }
  19857. res.InfRefmsgid = resSeven10265.InfRefmsgid
  19858. res.Output = resSeven10265.Output
  19859. res.ErrMsg = resSeven10265.ErrMsg
  19860. res.Cainfo = resSeven10265.Cainfo
  19861. res.WarnMsg = resSeven10265.WarnMsg
  19862. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  19863. res.Infcode = infocode
  19864. } else {
  19865. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  19866. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  19867. utils.ErrorLog("解析失败:%v", err)
  19868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19869. return
  19870. }
  19871. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  19872. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  19873. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  19874. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19875. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  19876. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  19877. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  19878. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  19879. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  19880. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19881. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19882. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19883. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19884. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  19885. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  19886. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  19887. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  19888. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  19889. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  19890. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  19891. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  19892. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  19893. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  19894. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  19895. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  19896. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  19897. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  19898. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  19899. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  19900. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  19901. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  19902. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  19903. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  19904. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  19905. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  19906. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  19907. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  19908. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  19909. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  19910. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  19911. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  19912. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  19913. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  19914. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  19915. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  19916. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  19917. res.ErrMsg = gzresSeven10265Two.ErrMsg
  19918. res.Cainfo = gzresSeven10265Two.Cainfo
  19919. res.WarnMsg = gzresSeven10265Two.WarnMsg
  19920. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  19921. //res.Infcode = infocode
  19922. } else {
  19923. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  19924. utils.ErrorLog("解析失败:%v", err)
  19925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  19926. return
  19927. }
  19928. }
  19929. }
  19930. }
  19931. if res.Infcode == -1 {
  19932. errlog := &models.HisOrderError{
  19933. UserOrgId: adminUser.CurrentOrgId,
  19934. Ctime: time.Now().Unix(),
  19935. Mtime: time.Now().Unix(),
  19936. Number: chrg_bchno,
  19937. ErrMsg: res.ErrMsg,
  19938. Status: 1,
  19939. PatientId: id,
  19940. RecordTime: recordDateTime,
  19941. Stage: 6,
  19942. }
  19943. service.CreateErrMsgLog(errlog)
  19944. c.ServeSuccessJSON(map[string]interface{}{
  19945. "failed_code": -10,
  19946. "msg": res.ErrMsg,
  19947. })
  19948. return
  19949. } else {
  19950. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  19951. order.OrderStatus = 2
  19952. order.Status = 1
  19953. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  19954. order.SetlId = res.Output.Setlinfo.SetlID
  19955. order.PsnNo = res.Output.Setlinfo.PsnNo
  19956. order.PsnName = res.Output.Setlinfo.PsnName
  19957. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  19958. order.Certno = res.Output.Setlinfo.Certno
  19959. order.Gend = res.Output.Setlinfo.Gend
  19960. order.Naty = res.Output.Setlinfo.Naty
  19961. order.Age = res.Output.Setlinfo.Age
  19962. order.Insutype = res.Output.Setlinfo.Insutype
  19963. order.PsnType = res.Output.Setlinfo.PsnType
  19964. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  19965. order.SetlTime = res.Output.Setlinfo.SetlTime
  19966. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  19967. if res.Output.Setlinfo.MedType == "140101" {
  19968. order.MedType = "14"
  19969. } else {
  19970. if res.Output.Setlinfo.MedType == "110104" {
  19971. order.MedType = "11"
  19972. } else {
  19973. order.MedType = res.Output.Setlinfo.MedType
  19974. }
  19975. }
  19976. if reg_type == 1112 {
  19977. order.MedType = "1112"
  19978. }
  19979. if reg_type == 1111 {
  19980. order.MedType = "1111"
  19981. }
  19982. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  19983. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  19984. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  19985. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  19986. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  19987. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  19988. order.HifpPay = res.Output.Setlinfo.HifpPay
  19989. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  19990. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  19991. order.HifesPay = res.Output.Setlinfo.HifesPay
  19992. order.HifobPay = res.Output.Setlinfo.HifobPay
  19993. order.MafPay = res.Output.Setlinfo.MafPay
  19994. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  19995. order.OthPay = res.Output.Setlinfo.OthPay
  19996. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  19997. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  19998. order.AcctPay = res.Output.Setlinfo.AcctPay
  19999. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20000. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20001. order.Balc = res.Output.Setlinfo.Balc
  20002. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20003. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20004. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20005. order.ClrType = res.Output.Setlinfo.ClrType
  20006. order.ClrWay = res.Output.Setlinfo.ClrWay
  20007. order.Creator = order.Creator
  20008. order.Modify = roles.AdminUserId
  20009. order.RequestLog = src_resquest
  20010. order.FaPiaoNumber = fapiao_number
  20011. order.FaPiaoCode = fapiao_code
  20012. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  20013. //detailStr := string(setlDetail)
  20014. //order.SetlDetail = detailStr
  20015. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  20016. err = service.UpDateOrder(order)
  20017. if err == nil {
  20018. //判断是否使用了押金
  20019. if dec_way == "true" {
  20020. tmpstring := strconv.FormatInt(order.ID, 10)
  20021. order.Decimal = decimal
  20022. service.UpDateOrder(order)
  20023. //扣押金
  20024. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  20025. if errmsg != nil {
  20026. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  20027. return
  20028. }
  20029. }
  20030. c.ServeSuccessJSON(map[string]interface{}{
  20031. "msg": "结算成功",
  20032. })
  20033. } else {
  20034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  20035. return
  20036. }
  20037. }
  20038. } else {
  20039. adminUser := c.GetAdminUserInfo()
  20040. errlog := &models.HisOrderError{
  20041. UserOrgId: adminUser.CurrentOrgId,
  20042. Ctime: time.Now().Unix(),
  20043. Mtime: time.Now().Unix(),
  20044. ErrMsg: res.ErrMsg,
  20045. Status: 1,
  20046. PatientId: id,
  20047. RecordTime: recordDateTime,
  20048. Stage: 4,
  20049. }
  20050. service.CreateErrMsgLog(errlog)
  20051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  20052. return
  20053. }
  20054. } else {
  20055. adminUser := c.GetAdminUserInfo()
  20056. errlog := &models.HisOrderError{
  20057. UserOrgId: adminUser.CurrentOrgId,
  20058. Ctime: time.Now().Unix(),
  20059. Mtime: time.Now().Unix(),
  20060. ErrMsg: res.ErrMsg,
  20061. Status: 1,
  20062. PatientId: id,
  20063. RecordTime: recordDateTime,
  20064. Stage: 4,
  20065. }
  20066. service.CreateErrMsgLog(errlog)
  20067. c.ServeSuccessJSON(map[string]interface{}{
  20068. "failed_code": -10,
  20069. "msg": res.ErrMsg,
  20070. })
  20071. return
  20072. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  20073. //return
  20074. }
  20075. }
  20076. }
  20077. } else if tempOrder.ID > 0 {
  20078. if tempOrder.IsPre == 1 {
  20079. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  20080. var rf []*ResultFive
  20081. json.Unmarshal([]byte(his.Iinfo), &rf)
  20082. chrg_bchno := tempOrder.Number
  20083. cert_no := his.Certno
  20084. var insutypes []string
  20085. var insutype string
  20086. var is390 int = 0
  20087. var is310 int = 0
  20088. for _, item := range rf {
  20089. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20090. insutypes = append(insutypes, item.Insutype)
  20091. }
  20092. }
  20093. if len(insutypes) == 1 {
  20094. insutype = insutypes[0]
  20095. } else {
  20096. for _, i := range insutypes {
  20097. if i == "390" {
  20098. is390 = 1
  20099. }
  20100. if i == "310" {
  20101. is310 = 1
  20102. }
  20103. }
  20104. }
  20105. if is390 == 1 {
  20106. insutype = "390"
  20107. }
  20108. if is310 == 1 {
  20109. insutype = "310"
  20110. }
  20111. if len(insutypes) == 0 {
  20112. insutype = "310"
  20113. }
  20114. if len(insutypes) == 2 {
  20115. insutype = strconv.FormatInt(his.SocialType, 10)
  20116. }
  20117. //insutype = "390"
  20118. if his.IdCardType == 1 {
  20119. // cert_no = his.MedicalInsuranceNumber
  20120. cert_no = his.Certno
  20121. } else {
  20122. cert_no = his.Certno
  20123. }
  20124. var res ResultSeven
  20125. var ahres ResultSevenAH
  20126. var resSeven10265 ResultSeven10265
  20127. var gzresSeven10265Two GZResultSeven10265Two
  20128. var src_resquest string
  20129. var result2 string
  20130. if miConfig.MdtrtareaAdmvs == "450721" {
  20131. res2 := c.GetoleInfo()
  20132. if res2.Infcode == 0 {
  20133. var result string
  20134. var request_log string
  20135. var result_log string
  20136. if res2.Output.MdtrtCertType == "02" {
  20137. 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)
  20138. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20139. } else if res2.Output.MdtrtCertType == "01" {
  20140. 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)
  20141. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20142. } else {
  20143. 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)
  20144. saveLog(result_log, request_log, "1101", "人员基本信息获取")
  20145. }
  20146. var dat map[string]interface{}
  20147. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  20148. fmt.Println(dat)
  20149. } else {
  20150. fmt.Println(err)
  20151. }
  20152. userJSONBytes, _ := json.Marshal(dat)
  20153. var res5 ResultTwo
  20154. //var resTwo10265 ResultTwo10265
  20155. if err := json.Unmarshal(userJSONBytes, &res5); err != nil {
  20156. utils.ErrorLog("解析失败:%v", err)
  20157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20158. return
  20159. }
  20160. //utils.ErrorLog("解析失败:%v", res5.Infcode)
  20161. if res5.Infcode == -1 {
  20162. c.ServeSuccessJSON(map[string]interface{}{
  20163. "failed_code": -10,
  20164. "msg": res5.ErrMsg,
  20165. })
  20166. return
  20167. }
  20168. var insutypes []string
  20169. var insutype string
  20170. var is390 int = 0
  20171. var is310 int = 0
  20172. for _, item := range res5.Output.Iinfo {
  20173. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  20174. insutypes = append(insutypes, item.Insutype)
  20175. }
  20176. }
  20177. if len(insutypes) == 1 {
  20178. insutype = insutypes[0]
  20179. } else {
  20180. for _, i := range insutypes {
  20181. if i == "390" {
  20182. is390 = 1
  20183. }
  20184. if i == "310" {
  20185. is310 = 1
  20186. }
  20187. }
  20188. }
  20189. if is390 == 1 {
  20190. insutype = "390"
  20191. }
  20192. if is310 == 1 {
  20193. insutype = "310"
  20194. }
  20195. if len(insutypes) == 0 {
  20196. insutype = "310"
  20197. }
  20198. Iinfos, _ := json.Marshal(res5.Output.Iinfo)
  20199. Idetinfos, _ := json.Marshal(res5.Output.Idetinfo)
  20200. infoStr := string(Iinfos)
  20201. idetinfoStr := string(Idetinfos)
  20202. psn := &models.HisPsn{
  20203. PsnNo: res5.Output.Baseinfo.PsnNo,
  20204. PatientId: id,
  20205. Certno: res5.Output.Baseinfo.Certno,
  20206. Gend: res5.Output.Baseinfo.Gend,
  20207. Naty: res5.Output.Baseinfo.Naty,
  20208. PsnCertType: res5.Output.Baseinfo.PsnCertType,
  20209. PsnName: res5.Output.Baseinfo.PsnName,
  20210. Idetinfo: idetinfoStr,
  20211. Insuinfo: infoStr,
  20212. CardInfo: res2.Output.CardNo + "|" + res2.Output.CardSN,
  20213. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  20214. VerifyNumber: res2.Output.EcToken,
  20215. }
  20216. service.CreateHisPsn(psn)
  20217. if res2.Output.MdtrtCertType == "01" {
  20218. //psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20219. token := res2.Output.EcToken
  20220. 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)
  20221. } else if res2.Output.MdtrtCertType == "02" {
  20222. 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)
  20223. } else {
  20224. 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)
  20225. }
  20226. var dat2 map[string]interface{}
  20227. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  20228. fmt.Println(dat2)
  20229. } else {
  20230. fmt.Println(err)
  20231. }
  20232. userJSONBytes3, _ := json.Marshal(dat2)
  20233. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  20234. utils.ErrorLog("解析失败:%v", err)
  20235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20236. return
  20237. }
  20238. saveLog(result2, src_resquest, "2207", "结算")
  20239. } else {
  20240. c.ServeSuccessJSON(map[string]interface{}{
  20241. "failed_code": -10,
  20242. "msg": res2.ErrMsg,
  20243. })
  20244. return
  20245. }
  20246. } else if miConfig.MdtrtareaAdmvs == "421300" {
  20247. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20248. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20249. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20250. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20251. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20252. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20253. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20254. resp, requestErr := http.Get(api)
  20255. if requestErr != nil {
  20256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20257. return
  20258. }
  20259. body, ioErr := ioutil.ReadAll(resp.Body)
  20260. if ioErr != nil {
  20261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20263. return
  20264. }
  20265. var respJSON map[string]interface{}
  20266. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20269. return
  20270. }
  20271. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20272. result, _ := json.Marshal(respJSON)
  20273. fmt.Println("log")
  20274. fmt.Println(string(result))
  20275. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20276. utils.ErrorLog("解析失败:%v", err)
  20277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20278. return
  20279. }
  20280. } else if miConfig.MdtrtareaAdmvs == "420200" {
  20281. if reg_type == 11 && his.Insutype == "390" {
  20282. reg_type = 110104
  20283. }
  20284. api := "http://192.168.0.197:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20285. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20286. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20287. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20288. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20289. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20290. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20291. resp, requestErr := http.Get(api)
  20292. if requestErr != nil {
  20293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20294. return
  20295. }
  20296. body, ioErr := ioutil.ReadAll(resp.Body)
  20297. if ioErr != nil {
  20298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20300. return
  20301. }
  20302. var respJSON map[string]interface{}
  20303. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20306. return
  20307. }
  20308. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20309. result, _ := json.Marshal(respJSON)
  20310. fmt.Println("log")
  20311. fmt.Println(string(result))
  20312. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20313. utils.ErrorLog("解析失败:%v", err)
  20314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20315. return
  20316. }
  20317. }else if miConfig.MdtrtareaAdmvs == "420902" {
  20318. if reg_type == 11 && his.Insutype == "390" {
  20319. reg_type = 110104
  20320. }
  20321. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20322. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20323. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20324. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20325. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20326. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20327. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20328. resp, requestErr := http.Get(api)
  20329. if requestErr != nil {
  20330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20331. return
  20332. }
  20333. body, ioErr := ioutil.ReadAll(resp.Body)
  20334. if ioErr != nil {
  20335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20337. return
  20338. }
  20339. var respJSON map[string]interface{}
  20340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20343. return
  20344. }
  20345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20346. result, _ := json.Marshal(respJSON)
  20347. fmt.Println("log")
  20348. fmt.Println(string(result))
  20349. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20350. utils.ErrorLog("解析失败:%v", err)
  20351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20352. return
  20353. }
  20354. } else if miConfig.MdtrtareaAdmvs == "421182" {
  20355. if reg_type == 11 && his.Insutype == "390" {
  20356. reg_type = 110104
  20357. }
  20358. api := miConfig.Url + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20359. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20360. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20361. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20362. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20363. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20364. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  20365. resp, requestErr := http.Get(api)
  20366. if requestErr != nil {
  20367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20368. return
  20369. }
  20370. body, ioErr := ioutil.ReadAll(resp.Body)
  20371. if ioErr != nil {
  20372. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20374. return
  20375. }
  20376. var respJSON map[string]interface{}
  20377. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20378. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20380. return
  20381. }
  20382. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20383. result, _ := json.Marshal(respJSON)
  20384. fmt.Println("log")
  20385. fmt.Println(string(result))
  20386. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20387. utils.ErrorLog("解析失败:%v", err)
  20388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20389. return
  20390. }
  20391. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  20392. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  20393. if result3101.Infcode == "0" {
  20394. if len(result3101.Output.Result) > 0 {
  20395. var errMsgs []string
  20396. for _, item := range result3101.Output.Result {
  20397. errMsgs = append(errMsgs, item.VolaCont)
  20398. }
  20399. c.ServeSuccessJSON(map[string]interface{}{
  20400. "failed_code": -10,
  20401. "msg": errMsgs,
  20402. })
  20403. return
  20404. } else {
  20405. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20406. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20407. bas := strings.Split(psn_info.CardInfo, "|")
  20408. if his.IdCardType == 1 {
  20409. cert_no = bas[2]
  20410. } else if his.IdCardType == 3 {
  20411. cert_no = his.Certno
  20412. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20413. } else if his.IdCardType == 4 {
  20414. cert_no = his.Certno
  20415. psn_info.VerifyNumber = psn_info.VerifyNumber
  20416. }
  20417. //江苏地区国家医保医疗类别
  20418. //职工透析:医疗类别选特殊情况门诊9933
  20419. //居民血透门慢: 医疗类别选门诊慢病1402
  20420. //var med_type string
  20421. //if his.Insutype == "310" {
  20422. // if reg_type == 14 {
  20423. // med_type = "9933"
  20424. // } else if reg_type == 11 {
  20425. // med_type = "11"
  20426. //
  20427. // }
  20428. //} else if his.Insutype == "390" {
  20429. // if reg_type == 14 {
  20430. // med_type = "1402"
  20431. // } else if reg_type == 11 {
  20432. // med_type = "11"
  20433. // }
  20434. //}
  20435. var api string
  20436. if miConfig.MdtrtareaAdmvs == "320921" {
  20437. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20438. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20439. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20441. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20442. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20443. "&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
  20444. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20445. } else {
  20446. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  20447. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20448. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20449. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20450. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20451. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20452. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20453. "&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
  20454. }
  20455. resp, requestErr := http.Get(api)
  20456. if requestErr != nil {
  20457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20458. return
  20459. }
  20460. body, ioErr := ioutil.ReadAll(resp.Body)
  20461. if ioErr != nil {
  20462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20464. return
  20465. }
  20466. var respJSON map[string]interface{}
  20467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20470. return
  20471. }
  20472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20473. result, _ := json.Marshal(respJSON)
  20474. fmt.Println("log")
  20475. fmt.Println(string(result))
  20476. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20477. utils.ErrorLog("解析失败:%v", err)
  20478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20479. return
  20480. }
  20481. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20482. res.Output = resSeven10265.Output
  20483. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20484. res.ErrMsg = resSeven10265.ErrMsg
  20485. res.Cainfo = resSeven10265.Cainfo
  20486. res.WarnMsg = resSeven10265.WarnMsg
  20487. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20488. res.Infcode = infocode
  20489. }
  20490. }
  20491. } else if miConfig.MdtrtareaAdmvs == "150499" {
  20492. psn_info, _ := service.GetPsnByPatientId(id)
  20493. var verify_number string
  20494. if psn_info.IdCardType == 4 {
  20495. verify_number = psn_info.VerifyNumber
  20496. } else if psn_info.IdCardType == 1 {
  20497. bas := strings.Split(psn_info.CardInfo, "|")
  20498. cardNumber := bas[2]
  20499. verify_number = cardNumber
  20500. } else {
  20501. verify_number = psn_info.Certno
  20502. psn_info.IdCardType = 2
  20503. }
  20504. var api string
  20505. api = "http://172.16.13.254:9532/" + "nmyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20506. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20507. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20508. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20509. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20510. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20511. "&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
  20512. resp, requestErr := http.Get(api)
  20513. if requestErr != nil {
  20514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20515. return
  20516. }
  20517. body, ioErr := ioutil.ReadAll(resp.Body)
  20518. if ioErr != nil {
  20519. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20521. return
  20522. }
  20523. var respJSON map[string]interface{}
  20524. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20525. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20527. return
  20528. }
  20529. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20530. result, _ := json.Marshal(respJSON)
  20531. fmt.Println("log")
  20532. fmt.Println(string(result))
  20533. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  20534. utils.ErrorLog("解析失败:%v", err)
  20535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20536. return
  20537. }
  20538. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20539. res.Output = resSeven10265.Output
  20540. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20541. res.ErrMsg = resSeven10265.ErrMsg
  20542. res.Cainfo = resSeven10265.Cainfo
  20543. res.WarnMsg = resSeven10265.WarnMsg
  20544. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20545. res.Infcode = infocode
  20546. } else if miConfig.MdtrtareaAdmvs == "350500" {
  20547. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20548. var cert_no string
  20549. if his.IdCardType == 1 {
  20550. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20551. } else {
  20552. cert_no = psn_info.VerifyNumber
  20553. }
  20554. 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)
  20555. var dat map[string]interface{}
  20556. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20557. fmt.Println(dat)
  20558. } else {
  20559. fmt.Println(err)
  20560. }
  20561. saveLog(result2, src_resquest, "2207", "结算")
  20562. userJSONBytes, _ := json.Marshal(dat)
  20563. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20564. utils.ErrorLog("解析失败:%v", err)
  20565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20566. return
  20567. }
  20568. } else if miConfig.MdtrtareaAdmvs == "360302" {
  20569. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20570. var cert_no string
  20571. var card_sn string
  20572. if his.IdCardType == 1 {
  20573. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20574. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20575. bas := strings.Split(psn_info.CardInfo, "|")
  20576. card_sn = bas[3]
  20577. } else if his.IdCardType == 2 {
  20578. cert_no = his.IdCardNo
  20579. } else {
  20580. cert_no = psn_info.VerifyNumber
  20581. }
  20582. var rf []*ResultFive
  20583. json.Unmarshal([]byte(his.Iinfo), &rf)
  20584. var psn_type string
  20585. for _, item := range rf {
  20586. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  20587. psn_type = item.PsnType
  20588. }
  20589. }
  20590. 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)
  20591. var dat map[string]interface{}
  20592. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20593. fmt.Println(dat)
  20594. } else {
  20595. fmt.Println(err)
  20596. }
  20597. saveLog(result2, src_resquest, "2207", "结算")
  20598. userJSONBytes, _ := json.Marshal(dat)
  20599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20600. utils.ErrorLog("解析失败:%v", err)
  20601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20602. return
  20603. }
  20604. } else if miConfig.MdtrtareaAdmvs == "341203" {
  20605. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20606. if his.IdCardType == 1 {
  20607. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20608. bas := strings.Split(psn_info.CardInfo, "|")
  20609. cert_no = bas[2]
  20610. } else if his.IdCardType == 3 {
  20611. cert_no = his.Certno
  20612. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  20613. } else if his.IdCardType == 4 {
  20614. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  20615. cert_no = his.Certno
  20616. psn_info.VerifyNumber = psn_info.VerifyNumber
  20617. } else {
  20618. cert_no = his.Certno
  20619. psn_info.VerifyNumber = his.Certno
  20620. }
  20621. var api string
  20622. var med_type string
  20623. if his.Insutype == "390" {
  20624. if reg_type == 992102 {
  20625. med_type = "992102"
  20626. }
  20627. if reg_type == 140104 {
  20628. med_type = "140104"
  20629. }
  20630. if reg_type == 14 {
  20631. med_type = "14"
  20632. }
  20633. } else if his.Insutype == "310" {
  20634. if reg_type == 992102 {
  20635. med_type = "992102"
  20636. }
  20637. if reg_type == 14 {
  20638. med_type = "14"
  20639. }
  20640. }
  20641. api = miConfig.SecretKey + "ahyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20642. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20643. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20644. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20645. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  20646. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20647. "&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
  20648. resp, requestErr := http.Get(api)
  20649. if requestErr != nil {
  20650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20651. return
  20652. }
  20653. body, ioErr := ioutil.ReadAll(resp.Body)
  20654. if ioErr != nil {
  20655. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20657. return
  20658. }
  20659. var respJSON map[string]interface{}
  20660. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20661. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20663. return
  20664. }
  20665. status := respJSON["data"].(map[string]interface{})["status"].(string)
  20666. if status == "0" {
  20667. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  20668. c.ServeSuccessJSON(map[string]interface{}{
  20669. "failed_code": -10,
  20670. "msg": err_msg,
  20671. })
  20672. return
  20673. }
  20674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20675. result, _ := json.Marshal(respJSON)
  20676. fmt.Println("log")
  20677. fmt.Println(string(result))
  20678. if err := json.Unmarshal(result, &ahres); err != nil {
  20679. utils.ErrorLog("解析失败:%v", err)
  20680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20681. return
  20682. }
  20683. res.InfRefmsgid = ahres.InfRefmsgid
  20684. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  20685. // 创建对应的Time类型
  20686. t := time.UnixMilli(timestamp)
  20687. // 格式化成指定的日期字符串
  20688. str := t.Format("2006-01-02 15:04:05")
  20689. res.Output.Setlinfo.SetlTime = str
  20690. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  20691. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  20692. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20693. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  20694. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  20695. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  20696. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20697. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  20698. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  20699. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  20700. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  20701. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  20702. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  20703. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  20704. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  20705. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  20706. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  20707. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  20708. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  20709. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20710. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  20711. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  20712. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  20713. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  20714. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  20715. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  20716. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  20717. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  20718. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  20719. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  20720. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  20721. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  20722. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  20723. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  20724. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  20725. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  20726. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  20727. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrType
  20728. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  20729. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  20730. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  20731. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  20732. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  20733. res.Output.Setldetail = ahres.Output.Setldetail
  20734. res.ErrMsg = ahres.ErrMsg
  20735. res.Cainfo = ahres.Cainfo
  20736. res.WarnMsg = ahres.WarnMsg
  20737. res.Infcode = ahres.Infcode
  20738. } else if miConfig.MdtrtareaAdmvs == "430800" {
  20739. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20740. var cert_no string
  20741. if his.IdCardType == 1 {
  20742. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  20743. } else if his.IdCardType == 2 {
  20744. cert_no = his.IdCardNo
  20745. } else {
  20746. cert_no = psn_info.VerifyNumber
  20747. }
  20748. 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, "")
  20749. var dat map[string]interface{}
  20750. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20751. fmt.Println(dat)
  20752. } else {
  20753. fmt.Println(err)
  20754. }
  20755. saveLog(result2, src_resquest, "2207", "结算")
  20756. userJSONBytes, _ := json.Marshal(dat)
  20757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20758. utils.ErrorLog("解析失败:%v", err)
  20759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20760. return
  20761. }
  20762. } else if miConfig.MdtrtareaAdmvs == "441799" {
  20763. psn_info, _ := service.GetPsnByPatientId(id)
  20764. var verify_number string
  20765. if psn_info.IdCardType == 4 {
  20766. verify_number = psn_info.VerifyNumber
  20767. } else if psn_info.IdCardType == 1 {
  20768. bas := strings.Split(psn_info.CardInfo, "|")
  20769. cardNumber := bas[2]
  20770. verify_number = cardNumber
  20771. } else {
  20772. verify_number = psn_info.Certno
  20773. psn_info.IdCardType = 2
  20774. }
  20775. var api string
  20776. api = miConfig.Url + "gdyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  20777. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  20778. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  20779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  20780. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  20781. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  20782. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + tempOrder.MedType + "&acct_used_flag=" + acct_used_flag + "&verify_number=" + verify_number
  20783. resp, requestErr := http.Get(api)
  20784. if requestErr != nil {
  20785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20786. return
  20787. }
  20788. body, ioErr := ioutil.ReadAll(resp.Body)
  20789. if ioErr != nil {
  20790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  20791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20792. return
  20793. }
  20794. var respJSON map[string]interface{}
  20795. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  20796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  20797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20798. return
  20799. }
  20800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  20801. result, _ := json.Marshal(respJSON)
  20802. if err := json.Unmarshal([]byte(result), &res); err != nil {
  20803. utils.ErrorLog("解析失败:%v", err)
  20804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20805. return
  20806. }
  20807. } else {
  20808. var src_resquest string
  20809. if miConfig.Code == "H15049901371" {
  20810. //赤峰地区国家医保医疗类别
  20811. //职工透析:医疗类别选特殊情况门诊990502
  20812. //居民定额血透门慢: 医疗类别选门诊慢病140104
  20813. var med_type string
  20814. if his.Insutype == "390" {
  20815. if reg_type == 14 {
  20816. med_type = "9933"
  20817. } else if reg_type == 11 {
  20818. med_type = "11"
  20819. }
  20820. } else if his.Insutype == "310" {
  20821. if reg_type == 14 {
  20822. med_type = "990502"
  20823. } else if reg_type == 11 {
  20824. med_type = "11"
  20825. }
  20826. }
  20827. 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)
  20828. } else {
  20829. if his.IdCardType == 4 {
  20830. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  20831. token := psn_info.VerifyNumber
  20832. 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)
  20833. } else {
  20834. 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)
  20835. }
  20836. }
  20837. var dat map[string]interface{}
  20838. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  20839. fmt.Println(dat)
  20840. } else {
  20841. fmt.Println(err)
  20842. }
  20843. saveLog(result2, src_resquest, "2207", "结算")
  20844. userJSONBytes, _ := json.Marshal(dat)
  20845. if miConfig.Code == "H15049901371" {
  20846. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  20847. utils.ErrorLog("解析失败:%v", err)
  20848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20849. return
  20850. }
  20851. res.InfRefmsgid = resSeven10265.InfRefmsgid
  20852. res.Output = resSeven10265.Output
  20853. res.ErrMsg = resSeven10265.ErrMsg
  20854. res.Cainfo = resSeven10265.Cainfo
  20855. res.WarnMsg = resSeven10265.WarnMsg
  20856. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  20857. res.Infcode = infocode
  20858. } else {
  20859. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  20860. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  20861. utils.ErrorLog("解析失败:%v", err)
  20862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20863. return
  20864. }
  20865. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  20866. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  20867. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  20868. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20869. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  20870. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  20871. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  20872. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  20873. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  20874. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20875. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20876. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20877. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20878. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  20879. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  20880. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  20881. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  20882. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  20883. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  20884. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  20885. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  20886. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  20887. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  20888. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  20889. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  20890. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  20891. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  20892. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  20893. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  20894. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  20895. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  20896. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  20897. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  20898. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  20899. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  20900. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  20901. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  20902. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  20903. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  20904. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  20905. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  20906. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  20907. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  20908. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  20909. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  20910. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  20911. res.ErrMsg = gzresSeven10265Two.ErrMsg
  20912. res.Cainfo = gzresSeven10265Two.Cainfo
  20913. res.WarnMsg = gzresSeven10265Two.WarnMsg
  20914. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  20915. //res.Infcode = infocode
  20916. } else {
  20917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  20918. utils.ErrorLog("解析失败:%v", err)
  20919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  20920. return
  20921. }
  20922. }
  20923. }
  20924. }
  20925. if res.Infcode != 0 {
  20926. errlog := &models.HisOrderError{
  20927. UserOrgId: adminUser.CurrentOrgId,
  20928. Ctime: time.Now().Unix(),
  20929. Mtime: time.Now().Unix(),
  20930. Number: chrg_bchno,
  20931. ErrMsg: res.ErrMsg,
  20932. Status: 1,
  20933. PatientId: id,
  20934. RecordTime: recordDateTime,
  20935. Stage: 6,
  20936. }
  20937. service.CreateErrMsgLog(errlog)
  20938. c.ServeSuccessJSON(map[string]interface{}{
  20939. "failed_code": -10,
  20940. "msg": res.ErrMsg,
  20941. })
  20942. return
  20943. } else {
  20944. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  20945. order.OrderStatus = 2
  20946. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  20947. order.SetlId = res.Output.Setlinfo.SetlID
  20948. order.PsnNo = res.Output.Setlinfo.PsnNo
  20949. order.PsnName = res.Output.Setlinfo.PsnName
  20950. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  20951. order.Certno = res.Output.Setlinfo.Certno
  20952. order.Gend = res.Output.Setlinfo.Gend
  20953. order.Naty = res.Output.Setlinfo.Naty
  20954. order.Age = res.Output.Setlinfo.Age
  20955. order.Insutype = res.Output.Setlinfo.Insutype
  20956. order.PsnType = res.Output.Setlinfo.PsnType
  20957. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  20958. order.SetlTime = res.Output.Setlinfo.SetlTime
  20959. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  20960. order.PayWays = pay_ways
  20961. order.AcctUsedFlag = acct_used_flag
  20962. order.WechatPay = wechat_pay
  20963. order.AliPay = ali_pay
  20964. order.JifenPay = jifen_pay
  20965. order.BandCardPay = band_card_pay
  20966. order.CashPay = cash_pay
  20967. order.OthDesc = oth_desc
  20968. //order.MedType = res.Output.Setlinfo.MedType
  20969. if reg_type == 1112 {
  20970. order.MedType = "1112"
  20971. }
  20972. if reg_type == 1111 {
  20973. order.MedType = "1111"
  20974. }
  20975. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  20976. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  20977. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  20978. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  20979. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  20980. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  20981. order.HifpPay = res.Output.Setlinfo.HifpPay
  20982. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  20983. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  20984. order.HifesPay = res.Output.Setlinfo.HifesPay
  20985. order.HifobPay = res.Output.Setlinfo.HifobPay
  20986. order.MafPay = res.Output.Setlinfo.MafPay
  20987. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  20988. order.OthPay = res.Output.Setlinfo.OthPay
  20989. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  20990. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  20991. order.AcctPay = res.Output.Setlinfo.AcctPay
  20992. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  20993. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  20994. order.Balc = res.Output.Setlinfo.Balc
  20995. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  20996. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  20997. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  20998. order.ClrWay = res.Output.Setlinfo.ClrWay
  20999. order.Creator = order.Creator
  21000. order.ClrType = res.Output.Setlinfo.ClrType
  21001. order.Modify = roles.AdminUserId
  21002. order.RequestLog = src_resquest
  21003. order.Diagnosis = diagnosis_id
  21004. order.FaPiaoNumber = fapiao_number
  21005. order.FaPiaoCode = fapiao_code
  21006. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  21007. detailStr := string(setlDetail)
  21008. order.SetlDetail = detailStr
  21009. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  21010. err = service.UpDateOrder(order)
  21011. if err == nil {
  21012. //判断是否使用了押金
  21013. if dec_way == "true" {
  21014. tmpstring := strconv.FormatInt(order.ID, 10)
  21015. //扣押金
  21016. order.Decimal = decimal
  21017. service.UpDateOrder(order)
  21018. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  21019. if errmsg != nil {
  21020. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  21021. return
  21022. }
  21023. }
  21024. c.ServeSuccessJSON(map[string]interface{}{
  21025. "msg": "结算成功",
  21026. })
  21027. } else {
  21028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  21029. return
  21030. }
  21031. }
  21032. }
  21033. }
  21034. }
  21035. // 上传明细-预结算-
  21036. func (c *HisApiController) GetPreUploadInfo() {
  21037. id, _ := c.GetInt64("id")
  21038. record_time := c.GetString("record_time")
  21039. his_patient_id, _ := c.GetInt64("his_patient_id")
  21040. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  21041. admin_user_id, _ := c.GetInt64("admin_user_id")
  21042. diagnosis_id := c.GetString("diagnosis")
  21043. sick_type, _ := c.GetInt64("sick_type")
  21044. reg_type, _ := c.GetInt64("p_type")
  21045. begin_time := c.GetString("begin_time")
  21046. acct_used_flag := c.GetString("acct_used_flag")
  21047. id_str := c.GetString("ids")
  21048. ids_arr := strings.Split(id_str, ",")
  21049. timeLayout := "2006-01-02"
  21050. loc, _ := time.LoadLocation("Local")
  21051. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  21052. if err != nil {
  21053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21054. return
  21055. }
  21056. recordDateTime := theTime.Unix()
  21057. adminUser := c.GetAdminUserInfo()
  21058. diagnosis_ids := strings.Split(diagnosis_id, ",")
  21059. var config []*models.HisXtDiagnoseConfig
  21060. for _, item := range diagnosis_ids {
  21061. id, _ := strconv.ParseInt(item, 10, 64)
  21062. diagnosisConfig, _ := service.FindDiagnoseById(id)
  21063. config = append(config, &diagnosisConfig)
  21064. }
  21065. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  21066. sickConfig, _ := service.FindSickById(sick_type)
  21067. var prescriptions []*models.HisPrescription
  21068. var start_time int64
  21069. var end_time int64
  21070. var isSuccess bool = true
  21071. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  21072. fmt.Println(his_patient_id)
  21073. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21074. timestamp := time.Now().Unix()
  21075. tempTime := time.Unix(timestamp, 0)
  21076. timeFormat := tempTime.Format("20060102150405")
  21077. chrgBchno := rand.Intn(100000) + 10000
  21078. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10)
  21079. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21080. var patientPrescription models.HisPrescriptionInfo
  21081. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  21082. if patientPrescription.ID == 0 {
  21083. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  21084. }
  21085. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  21086. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  21087. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  21088. strconv.FormatInt(his.PatientId, 10)
  21089. var res2406 Result2406
  21090. //安徽单病种处理
  21091. if miConfig.MdtrtareaAdmvs == "341203" && reg_type == 992102 {
  21092. data := make(map[string]interface{})
  21093. client := &http.Client{}
  21094. data["psn_no"] = his.PsnNo
  21095. data["mdtrt_id"] = his.Number
  21096. data["operator"] = roles.UserName
  21097. data["cert_no"] = his.IdCardNo
  21098. data["org_name"] = miConfig.OrgName
  21099. data["psn_name"] = his.Name
  21100. data["ipt_otp_no"] = his.IptOtpNo
  21101. data["ipt_psn_sp_flag_type"] = "0901"
  21102. data["ipt_psn_sp_flag"] = "1"
  21103. data["fixmedins_code"] = miConfig.Code
  21104. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21106. data["url"] = miConfig.Url
  21107. utils.ErrorLog("接口返回数据解析JSON失败: %v", data)
  21108. bytesData, _ := json.Marshal(data)
  21109. var req *http.Request
  21110. utils.ErrorLog("接口返回数据解析JSON失败: %v", miConfig.SecretKey)
  21111. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2406", bytes.NewReader(bytesData))
  21112. resp, _ := client.Do(req)
  21113. defer resp.Body.Close()
  21114. body, ioErr := ioutil.ReadAll(resp.Body)
  21115. if ioErr != nil {
  21116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21118. return
  21119. }
  21120. var respJSON map[string]interface{}
  21121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21124. return
  21125. }
  21126. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21127. if status == "0" {
  21128. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21129. c.ServeSuccessJSON(map[string]interface{}{
  21130. "failed_code": -10,
  21131. "msg": err_msg,
  21132. })
  21133. return
  21134. }
  21135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21136. userJSONBytes, _ := json.Marshal(respJSON)
  21137. fmt.Println("log")
  21138. fmt.Println(string(userJSONBytes))
  21139. if err := json.Unmarshal(userJSONBytes, &res2406); err != nil {
  21140. utils.ErrorLog("解析失败:%v", err)
  21141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21142. return
  21143. }
  21144. }
  21145. if res2406.Infcode != 0 {
  21146. adminUser := c.GetAdminUserInfo()
  21147. errlog := &models.HisOrderError{
  21148. UserOrgId: adminUser.CurrentOrgId,
  21149. Ctime: time.Now().Unix(),
  21150. Mtime: time.Now().Unix(),
  21151. ErrMsg: res2406.ErrMsg,
  21152. Status: 1,
  21153. PatientId: id,
  21154. RecordTime: recordDateTime,
  21155. Stage: 3,
  21156. }
  21157. service.CreateErrMsgLog(errlog)
  21158. c.ServeSuccessJSON(map[string]interface{}{
  21159. "failed_code": -10,
  21160. "msg": res2406.ErrMsg,
  21161. })
  21162. return
  21163. }
  21164. var res2 ResultSix
  21165. var res3 GZResultSix
  21166. var resSix10265 ResultSix10265
  21167. //var time_stamp string
  21168. if miConfig.MdtrtareaAdmvs == "421300" {
  21169. data := make(map[string]interface{})
  21170. client := &http.Client{}
  21171. data["psn_no"] = his.PsnNo
  21172. data["mdtrt_id"] = his.Number
  21173. data["department"] = department.Name
  21174. data["org_name"] = miConfig.OrgName
  21175. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21176. data["doctor_id"] = doctor_info.DoctorNumber
  21177. data["doctor_name"] = roles.UserName
  21178. data["fixmedins_code"] = miConfig.Code
  21179. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21180. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21181. data["secret_key"] = miConfig.SecretKey
  21182. data["sick_code"] = sickConfig.CountryCode
  21183. data["sick_name"] = sickConfig.ClassName
  21184. data["begin_time"] = begin_time
  21185. data["dept"] = strconv.FormatInt(department.ID, 10)
  21186. data["config"] = config
  21187. data["opter"] = roles.UserName
  21188. fmt.Println(data)
  21189. bytesData, _ := json.Marshal(data)
  21190. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21191. resp, _ := client.Do(req)
  21192. defer resp.Body.Close()
  21193. body, ioErr := ioutil.ReadAll(resp.Body)
  21194. if ioErr != nil {
  21195. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21197. return
  21198. }
  21199. var respJSON map[string]interface{}
  21200. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21201. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21203. return
  21204. }
  21205. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21206. userJSONBytes, _ := json.Marshal(respJSON)
  21207. fmt.Println("log")
  21208. fmt.Println(string(userJSONBytes))
  21209. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21210. utils.ErrorLog("解析失败:%v", err)
  21211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21212. return
  21213. }
  21214. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21215. data := make(map[string]interface{})
  21216. client := &http.Client{}
  21217. data["psn_no"] = his.PsnNo
  21218. data["mdtrt_id"] = his.Number
  21219. data["department"] = department.Name
  21220. data["org_name"] = miConfig.OrgName
  21221. if reg_type == 11 && his.Insutype == "390" {
  21222. data["med_type"] = "110104"
  21223. } else {
  21224. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21225. }
  21226. data["doctor_id"] = doctor_info.DoctorNumber
  21227. data["doctor_name"] = roles.UserName
  21228. data["fixmedins_code"] = miConfig.Code
  21229. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21230. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21231. data["secret_key"] = miConfig.SecretKey
  21232. data["sick_code"] = sickConfig.CountryCode
  21233. data["sick_name"] = sickConfig.ClassName
  21234. data["begin_time"] = begin_time
  21235. data["dept"] = strconv.FormatInt(department.ID, 10)
  21236. data["config"] = config
  21237. data["opter"] = roles.UserName
  21238. fmt.Println(data)
  21239. bytesData, _ := json.Marshal(data)
  21240. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  21241. resp, _ := client.Do(req)
  21242. defer resp.Body.Close()
  21243. body, ioErr := ioutil.ReadAll(resp.Body)
  21244. if ioErr != nil {
  21245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21247. return
  21248. }
  21249. var respJSON map[string]interface{}
  21250. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21253. return
  21254. }
  21255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21256. userJSONBytes, _ := json.Marshal(respJSON)
  21257. fmt.Println("log")
  21258. fmt.Println(string(userJSONBytes))
  21259. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21260. utils.ErrorLog("解析失败:%v", err)
  21261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21262. return
  21263. }
  21264. } else if miConfig.MdtrtareaAdmvs == "420902" {
  21265. data := make(map[string]interface{})
  21266. client := &http.Client{}
  21267. data["psn_no"] = his.PsnNo
  21268. data["mdtrt_id"] = his.Number
  21269. data["department"] = department.Name
  21270. data["org_name"] = miConfig.OrgName
  21271. if reg_type == 11 && his.Insutype == "390" {
  21272. data["med_type"] = "110104"
  21273. } else {
  21274. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21275. }
  21276. data["doctor_id"] = doctor_info.DoctorNumber
  21277. data["doctor_name"] = roles.UserName
  21278. data["fixmedins_code"] = miConfig.Code
  21279. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21280. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21281. data["secret_key"] = miConfig.SecretKey
  21282. data["sick_code"] = sickConfig.CountryCode
  21283. data["sick_name"] = sickConfig.ClassName
  21284. data["begin_time"] = begin_time
  21285. data["dept"] = strconv.FormatInt(department.ID, 10)
  21286. data["config"] = config
  21287. data["opter"] = roles.UserName
  21288. fmt.Println(data)
  21289. bytesData, _ := json.Marshal(data)
  21290. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21291. resp, _ := client.Do(req)
  21292. defer resp.Body.Close()
  21293. body, ioErr := ioutil.ReadAll(resp.Body)
  21294. if ioErr != nil {
  21295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21297. return
  21298. }
  21299. var respJSON map[string]interface{}
  21300. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21303. return
  21304. }
  21305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21306. userJSONBytes, _ := json.Marshal(respJSON)
  21307. fmt.Println("log")
  21308. fmt.Println(string(userJSONBytes))
  21309. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21310. utils.ErrorLog("解析失败:%v", err)
  21311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21312. return
  21313. }
  21314. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21315. data := make(map[string]interface{})
  21316. client := &http.Client{}
  21317. data["psn_no"] = his.PsnNo
  21318. data["mdtrt_id"] = his.Number
  21319. data["department"] = department.Name
  21320. data["org_name"] = miConfig.OrgName
  21321. if reg_type == 11 && his.Insutype == "390" {
  21322. data["med_type"] = "110104"
  21323. } else {
  21324. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21325. }
  21326. data["doctor_id"] = doctor_info.DoctorNumber
  21327. data["doctor_name"] = roles.UserName
  21328. data["fixmedins_code"] = miConfig.Code
  21329. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21330. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21331. data["secret_key"] = miConfig.SecretKey
  21332. data["sick_code"] = sickConfig.CountryCode
  21333. data["sick_name"] = sickConfig.ClassName
  21334. data["begin_time"] = begin_time
  21335. data["dept"] = strconv.FormatInt(department.ID, 10)
  21336. data["config"] = config
  21337. data["opter"] = roles.UserName
  21338. fmt.Println(data)
  21339. bytesData, _ := json.Marshal(data)
  21340. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2203", bytes.NewReader(bytesData))
  21341. resp, _ := client.Do(req)
  21342. defer resp.Body.Close()
  21343. body, ioErr := ioutil.ReadAll(resp.Body)
  21344. if ioErr != nil {
  21345. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21347. return
  21348. }
  21349. var respJSON map[string]interface{}
  21350. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21351. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21353. return
  21354. }
  21355. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21356. userJSONBytes, _ := json.Marshal(respJSON)
  21357. fmt.Println("log")
  21358. fmt.Println(string(userJSONBytes))
  21359. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21360. utils.ErrorLog("解析失败:%v", err)
  21361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21362. return
  21363. }
  21364. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21365. data := make(map[string]interface{})
  21366. client := &http.Client{}
  21367. data["psn_no"] = his.PsnNo
  21368. data["mdtrt_id"] = his.Number
  21369. data["doctor"] = roles.UserName
  21370. data["department"] = department.Name
  21371. data["org_name"] = miConfig.OrgName
  21372. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21373. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21374. data["fixmedins_code"] = miConfig.Code
  21375. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21376. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21377. data["secret_key"] = miConfig.SecretKey
  21378. data["sick_code"] = sickConfig.CountryCode
  21379. data["sick_name"] = sickConfig.ClassName
  21380. data["begin_time"] = begin_time
  21381. data["dept"] = strconv.FormatInt(department.ID, 10)
  21382. data["config"] = config
  21383. data["url"] = miConfig.Url
  21384. data["ak"] = miConfig.AccessKey
  21385. data["cainfo"] = miConfig.Cainfo
  21386. bytesData, _ := json.Marshal(data)
  21387. var req *http.Request
  21388. if miConfig.MdtrtareaAdmvs == "320921" {
  21389. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21390. } else {
  21391. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  21392. }
  21393. resp, _ := client.Do(req)
  21394. defer resp.Body.Close()
  21395. body, ioErr := ioutil.ReadAll(resp.Body)
  21396. if ioErr != nil {
  21397. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21399. return
  21400. }
  21401. var respJSON map[string]interface{}
  21402. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21403. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21405. return
  21406. }
  21407. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21408. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21409. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21411. userJSONBytes, _ := json.Marshal(respJSON)
  21412. fmt.Println("log")
  21413. fmt.Println(string(userJSONBytes))
  21414. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21415. utils.ErrorLog("解析失败:%v", err)
  21416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21417. return
  21418. }
  21419. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21420. res2.Output = resSix10265.Output
  21421. res2.ErrMsg = resSix10265.ErrMsg
  21422. res2.Cainfo = resSix10265.Cainfo
  21423. res2.WarnMsg = resSix10265.WarnMsg
  21424. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21425. res2.Infcode = infocode
  21426. } else if miConfig.MdtrtareaAdmvs == "150499" {
  21427. data := make(map[string]interface{})
  21428. client := &http.Client{}
  21429. data["psn_no"] = his.PsnNo
  21430. data["mdtrt_id"] = his.Number
  21431. data["doctor"] = roles.UserName
  21432. data["department"] = department.Name
  21433. data["org_name"] = miConfig.OrgName
  21434. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21435. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  21436. data["fixmedins_code"] = miConfig.Code
  21437. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21438. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21439. data["secret_key"] = miConfig.SecretKey
  21440. data["sick_code"] = sickConfig.CountryCode
  21441. data["sick_name"] = sickConfig.ClassName
  21442. data["begin_time"] = begin_time
  21443. data["dept"] = strconv.FormatInt(department.ID, 10)
  21444. data["config"] = config
  21445. //data["url"] = miConfig.Url
  21446. //data["ak"] = miConfig.AccessKey
  21447. data["cainfo"] = miConfig.Cainfo
  21448. fmt.Println(data)
  21449. bytesData, _ := json.Marshal(data)
  21450. var req *http.Request
  21451. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2203", bytes.NewReader(bytesData))
  21452. resp, _ := client.Do(req)
  21453. defer resp.Body.Close()
  21454. body, ioErr := ioutil.ReadAll(resp.Body)
  21455. if ioErr != nil {
  21456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21458. return
  21459. }
  21460. var respJSON map[string]interface{}
  21461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21464. return
  21465. }
  21466. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  21467. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  21468. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  21469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21470. userJSONBytes, _ := json.Marshal(respJSON)
  21471. fmt.Println("log")
  21472. fmt.Println(string(userJSONBytes))
  21473. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  21474. utils.ErrorLog("解析失败:%v", err)
  21475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21476. return
  21477. }
  21478. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21479. res2.Output = resSix10265.Output
  21480. res2.ErrMsg = resSix10265.ErrMsg
  21481. res2.Cainfo = resSix10265.Cainfo
  21482. res2.WarnMsg = resSix10265.WarnMsg
  21483. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21484. res2.Infcode = infocode
  21485. } else if miConfig.MdtrtareaAdmvs == "350500" {
  21486. 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)
  21487. saveLog(result, requestLog, "2203", "上传就诊信息")
  21488. var respJSON2 map[string]interface{}
  21489. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21490. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21492. return
  21493. }
  21494. userJSONBytes2, _ := json.Marshal(respJSON2)
  21495. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21496. utils.ErrorLog("解析失败:%v", err)
  21497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21498. return
  21499. }
  21500. } else if miConfig.MdtrtareaAdmvs == "360302" {
  21501. var result string
  21502. var requestLog string
  21503. 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, "")
  21504. saveLog(result, requestLog, "2203", "上传就诊信息")
  21505. var respJSON2 map[string]interface{}
  21506. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21509. return
  21510. }
  21511. userJSONBytes2, _ := json.Marshal(respJSON2)
  21512. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21513. utils.ErrorLog("解析失败:%v", err)
  21514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21515. return
  21516. }
  21517. } else if miConfig.MdtrtareaAdmvs == "341203" {
  21518. data := make(map[string]interface{})
  21519. client := &http.Client{}
  21520. data["psn_no"] = his.PsnNo
  21521. data["mdtrt_id"] = his.Number
  21522. data["operator"] = roles.UserName
  21523. data["department"] = department.Name
  21524. data["org_name"] = miConfig.OrgName
  21525. var med_type string
  21526. if his.Insutype == "390" {
  21527. if reg_type == 992102 {
  21528. med_type = "992102"
  21529. data["sick_code"] = "ZDZ940"
  21530. data["sick_name"] = "慢性肾衰竭"
  21531. }
  21532. if reg_type == 140104 {
  21533. med_type = "140104"
  21534. data["sick_code"] = sickConfig.CountryCode
  21535. data["sick_name"] = sickConfig.ClassName
  21536. }
  21537. if reg_type == 14 {
  21538. med_type = "140104"
  21539. data["sick_code"] = sickConfig.CountryCode
  21540. data["sick_name"] = sickConfig.ClassName
  21541. }
  21542. } else if his.Insutype == "310" {
  21543. if reg_type == 992102 {
  21544. med_type = "992102"
  21545. data["sick_code"] = "ZDZ940"
  21546. data["sick_name"] = "慢性肾衰竭"
  21547. }
  21548. if reg_type == 140104 {
  21549. med_type = "140104"
  21550. data["sick_code"] = sickConfig.CountryCode
  21551. data["sick_name"] = sickConfig.ClassName
  21552. }
  21553. if reg_type == 14 {
  21554. med_type = "14"
  21555. data["sick_code"] = sickConfig.CountryCode
  21556. data["sick_name"] = sickConfig.ClassName
  21557. }
  21558. }
  21559. data["med_type"] = med_type
  21560. data["doctor_number"] = doctor_info.DoctorNumber
  21561. data["doctor_name"] = doctor_info.UserName
  21562. data["fixmedins_code"] = miConfig.Code
  21563. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21564. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21565. data["secret_key"] = miConfig.SecretKey
  21566. data["begin_time"] = begin_time
  21567. data["dept"] = strconv.FormatInt(department.ID, 10)
  21568. data["config"] = config
  21569. data["url"] = miConfig.Url
  21570. data["ak"] = miConfig.AccessKey
  21571. data["cainfo"] = miConfig.Cainfo
  21572. bytesData, _ := json.Marshal(data)
  21573. var req *http.Request
  21574. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2203", bytes.NewReader(bytesData))
  21575. resp, _ := client.Do(req)
  21576. defer resp.Body.Close()
  21577. body, ioErr := ioutil.ReadAll(resp.Body)
  21578. if ioErr != nil {
  21579. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21581. return
  21582. }
  21583. var respJSON map[string]interface{}
  21584. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21585. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21587. return
  21588. }
  21589. status := respJSON["data"].(map[string]interface{})["status"].(string)
  21590. if status == "0" {
  21591. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  21592. c.ServeSuccessJSON(map[string]interface{}{
  21593. "failed_code": -10,
  21594. "msg": err_msg,
  21595. })
  21596. return
  21597. }
  21598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21599. userJSONBytes, _ := json.Marshal(respJSON)
  21600. fmt.Println("log")
  21601. fmt.Println(string(userJSONBytes))
  21602. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21603. utils.ErrorLog("解析失败:%v", err)
  21604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21605. return
  21606. }
  21607. } else if miConfig.MdtrtareaAdmvs == "430800" {
  21608. var result string
  21609. var requestLog string
  21610. 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, "")
  21611. saveLog(result, requestLog, "2203", "上传就诊信息")
  21612. var respJSON2 map[string]interface{}
  21613. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21616. return
  21617. }
  21618. userJSONBytes2, _ := json.Marshal(respJSON2)
  21619. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21620. utils.ErrorLog("解析失败:%v", err)
  21621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21622. return
  21623. }
  21624. } else if miConfig.MdtrtareaAdmvs == "441799" {
  21625. data := make(map[string]interface{})
  21626. client := &http.Client{}
  21627. data["psn_no"] = his.PsnNo
  21628. data["mdtrt_id"] = his.Number
  21629. data["doctor"] = roles.UserName
  21630. data["department"] = department.Name
  21631. data["org_name"] = miConfig.OrgName
  21632. data["med_type"] = strconv.FormatInt(reg_type, 10)
  21633. data["doctor_id"] = doctor_info.DoctorNumber
  21634. data["fixmedins_code"] = miConfig.Code
  21635. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21636. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21637. data["secret_key"] = miConfig.SecretKey
  21638. data["sick_code"] = sickConfig.CountryCode
  21639. data["sick_name"] = sickConfig.ClassName
  21640. data["begin_time"] = begin_time
  21641. data["new_doctor_name"] = doctor_info.UserName
  21642. data["dept"] = strconv.FormatInt(department.ID, 10)
  21643. data["config"] = config
  21644. bytesData, _ := json.Marshal(data)
  21645. var req *http.Request
  21646. req, _ = http.NewRequest("POST", miConfig.Url+"gdyb/2203", bytes.NewReader(bytesData))
  21647. resp, _ := client.Do(req)
  21648. defer resp.Body.Close()
  21649. body, ioErr := ioutil.ReadAll(resp.Body)
  21650. if ioErr != nil {
  21651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21653. return
  21654. }
  21655. var respJSON map[string]interface{}
  21656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21659. return
  21660. }
  21661. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21662. userJSONBytes, _ := json.Marshal(respJSON)
  21663. fmt.Println("log")
  21664. fmt.Println(string(userJSONBytes))
  21665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  21666. utils.ErrorLog("解析失败:%v", err)
  21667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21668. return
  21669. }
  21670. } else {
  21671. var result string
  21672. var requestLog string
  21673. if miConfig.MdtrtareaAdmvs == "440781" { //
  21674. 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)
  21675. } else {
  21676. if miConfig.Code == "H15049901371" {
  21677. //赤峰地区国家医保医疗类别
  21678. //职工透析:医疗类别选特殊情况门诊990502
  21679. //居民定额血透门慢: 医疗类别选门诊慢病140104
  21680. var med_type string
  21681. if his.Insutype == "390" {
  21682. if reg_type == 14 {
  21683. med_type = "9933"
  21684. } else if reg_type == 11 {
  21685. med_type = "11"
  21686. }
  21687. } else if his.Insutype == "310" {
  21688. if reg_type == 14 {
  21689. med_type = "990502"
  21690. } else if reg_type == 11 {
  21691. med_type = "11"
  21692. }
  21693. }
  21694. 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)
  21695. } else {
  21696. 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)
  21697. }
  21698. saveLog(result, requestLog, "2203", "上传就诊信息")
  21699. var respJSON2 map[string]interface{}
  21700. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  21701. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21703. return
  21704. }
  21705. userJSONBytes2, _ := json.Marshal(respJSON2)
  21706. if miConfig.Code == "H15049901371" {
  21707. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  21708. utils.ErrorLog("解析失败:%v", err)
  21709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21710. return
  21711. }
  21712. res2.InfRefmsgid = resSix10265.InfRefmsgid
  21713. res2.Output = resSix10265.Output
  21714. res2.ErrMsg = resSix10265.ErrMsg
  21715. res2.Cainfo = resSix10265.Cainfo
  21716. res2.WarnMsg = resSix10265.WarnMsg
  21717. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  21718. res2.Infcode = infocode
  21719. } else {
  21720. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  21721. if err := json.Unmarshal(userJSONBytes2, &res3); err != nil {
  21722. utils.ErrorLog("解析失败:%v", err)
  21723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21724. return
  21725. }
  21726. res2.Infcode = res3.Infcode
  21727. } else {
  21728. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  21729. utils.ErrorLog("解析失败:%v", err)
  21730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21731. return
  21732. }
  21733. }
  21734. }
  21735. }
  21736. }
  21737. if res2.Infcode == -1 {
  21738. adminUser := c.GetAdminUserInfo()
  21739. errlog := &models.HisOrderError{
  21740. UserOrgId: adminUser.CurrentOrgId,
  21741. Ctime: time.Now().Unix(),
  21742. Mtime: time.Now().Unix(),
  21743. ErrMsg: res2.ErrMsg,
  21744. Status: 1,
  21745. PatientId: id,
  21746. RecordTime: recordDateTime,
  21747. Stage: 3,
  21748. }
  21749. service.CreateErrMsgLog(errlog)
  21750. c.ServeSuccessJSON(map[string]interface{}{
  21751. "failed_code": -10,
  21752. "msg": res2.ErrMsg,
  21753. })
  21754. return
  21755. }
  21756. if res2.Infcode != 0 {
  21757. adminUser := c.GetAdminUserInfo()
  21758. errlog := &models.HisOrderError{
  21759. UserOrgId: adminUser.CurrentOrgId,
  21760. Ctime: time.Now().Unix(),
  21761. Mtime: time.Now().Unix(),
  21762. ErrMsg: res2.ErrMsg,
  21763. Status: 1,
  21764. PatientId: id,
  21765. RecordTime: recordDateTime,
  21766. Stage: 3,
  21767. }
  21768. service.CreateErrMsgLog(errlog)
  21769. c.ServeSuccessJSON(map[string]interface{}{
  21770. "failed_code": -10,
  21771. "msg": res2.ErrMsg,
  21772. })
  21773. return
  21774. } else {
  21775. his.Diagnosis = diagnosis_id
  21776. his.SickType = sickConfig.ID
  21777. his.PType = fmt.Sprintf("%d", reg_type)
  21778. service.UpdateHisPatientThree(&his)
  21779. data := make(map[string]interface{})
  21780. if settle_accounts_type == 1 { //日结
  21781. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  21782. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  21783. } else {
  21784. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  21785. }
  21786. data["pre"] = prescriptions
  21787. } else { //月结
  21788. start_time_str := c.GetString("start_time")
  21789. end_time_str := c.GetString("end_time")
  21790. timeLayout := "2006-01-02"
  21791. loc, _ := time.LoadLocation("Local")
  21792. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  21793. if err != nil {
  21794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21795. return
  21796. }
  21797. recordStartTime := theStartTime.Unix()
  21798. start_time = recordStartTime
  21799. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  21800. if err != nil {
  21801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  21802. return
  21803. }
  21804. recordEndTime := theEndTime.Unix()
  21805. end_time = recordEndTime
  21806. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  21807. data["pre"] = prescriptions
  21808. }
  21809. client := &http.Client{}
  21810. data["psn_no"] = his.PsnNo
  21811. data["mdtrt_id"] = his.Number
  21812. data["chrg_bchno"] = chrg_bchno
  21813. data["org_name"] = miConfig.OrgName
  21814. data["doctor"] = doctor_info.UserName
  21815. data["doctor_id"] = doctor_info.DoctorNumber
  21816. data["dept"] = department.Name
  21817. data["fixmedins_code"] = miConfig.Code
  21818. data["opter"] = roles.UserName
  21819. data["dept_code"] = department.Number
  21820. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  21821. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  21822. data["secret_key"] = miConfig.SecretKey
  21823. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  21824. data["url"] = miConfig.Url
  21825. data["ak"] = miConfig.AccessKey
  21826. data["new_doctor_name"] = patientPrescription.Doctor
  21827. if his.Insutype == "390" {
  21828. if reg_type == 992102 {
  21829. data["diag_code"] = "ZDZ940"
  21830. }
  21831. if reg_type == 140104 {
  21832. data["diag_code"] = sickConfig.CountryCode
  21833. }
  21834. if reg_type == 14 {
  21835. data["diag_code"] = sickConfig.CountryCode
  21836. }
  21837. } else if his.Insutype == "310" {
  21838. if reg_type == 992102 {
  21839. data["diag_code"] = "ZDZ940"
  21840. }
  21841. if reg_type == 14 {
  21842. data["diag_code"] = sickConfig.CountryCode
  21843. }
  21844. }
  21845. data["cainfo"] = miConfig.Cainfo
  21846. data["opter"] = roles.UserName
  21847. var ids []int64
  21848. for _, item := range prescriptions {
  21849. ids = append(ids, item.ID)
  21850. }
  21851. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  21852. if config.IsOpen == 1 { //对接了医保,走医保流程
  21853. var res ResultFour
  21854. var resFour10265 ResultFour10265
  21855. if miConfig.MdtrtareaAdmvs == "421300" {
  21856. bytesData, _ := json.Marshal(data)
  21857. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21858. resp, _ := client.Do(req)
  21859. defer resp.Body.Close()
  21860. body, ioErr := ioutil.ReadAll(resp.Body)
  21861. if ioErr != nil {
  21862. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21864. return
  21865. }
  21866. var respJSON map[string]interface{}
  21867. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21868. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21870. return
  21871. }
  21872. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21873. userJSONBytes, _ := json.Marshal(respJSON)
  21874. fmt.Println("log")
  21875. fmt.Println(string(userJSONBytes))
  21876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21877. utils.ErrorLog("解析失败:%v", err)
  21878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21879. return
  21880. }
  21881. } else if miConfig.MdtrtareaAdmvs == "420200" {
  21882. bytesData, _ := json.Marshal(data)
  21883. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  21884. resp, _ := client.Do(req)
  21885. defer resp.Body.Close()
  21886. body, ioErr := ioutil.ReadAll(resp.Body)
  21887. if ioErr != nil {
  21888. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21890. return
  21891. }
  21892. var respJSON map[string]interface{}
  21893. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21894. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21896. return
  21897. }
  21898. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21899. userJSONBytes, _ := json.Marshal(respJSON)
  21900. fmt.Println("log")
  21901. fmt.Println(string(userJSONBytes))
  21902. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21903. utils.ErrorLog("解析失败:%v", err)
  21904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21905. return
  21906. }
  21907. }else if miConfig.MdtrtareaAdmvs == "420902" {
  21908. bytesData, _ := json.Marshal(data)
  21909. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21910. resp, _ := client.Do(req)
  21911. defer resp.Body.Close()
  21912. body, ioErr := ioutil.ReadAll(resp.Body)
  21913. if ioErr != nil {
  21914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21916. return
  21917. }
  21918. var respJSON map[string]interface{}
  21919. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21922. return
  21923. }
  21924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21925. userJSONBytes, _ := json.Marshal(respJSON)
  21926. fmt.Println("log")
  21927. fmt.Println(string(userJSONBytes))
  21928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21929. utils.ErrorLog("解析失败:%v", err)
  21930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21931. return
  21932. }
  21933. } else if miConfig.MdtrtareaAdmvs == "421182" {
  21934. bytesData, _ := json.Marshal(data)
  21935. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/2204", bytes.NewReader(bytesData))
  21936. resp, _ := client.Do(req)
  21937. defer resp.Body.Close()
  21938. body, ioErr := ioutil.ReadAll(resp.Body)
  21939. if ioErr != nil {
  21940. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21942. return
  21943. }
  21944. var respJSON map[string]interface{}
  21945. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21946. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21948. return
  21949. }
  21950. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  21951. userJSONBytes, _ := json.Marshal(respJSON)
  21952. fmt.Println("log")
  21953. fmt.Println(string(userJSONBytes))
  21954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  21955. utils.ErrorLog("解析失败:%v", err)
  21956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21957. return
  21958. }
  21959. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  21960. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  21961. if result3101.Infcode == "0" {
  21962. if len(result3101.Output.Result) > 0 {
  21963. var errMsgs []string
  21964. for _, item := range result3101.Output.Result {
  21965. errMsgs = append(errMsgs, item.VolaCont)
  21966. }
  21967. c.ServeSuccessJSON(map[string]interface{}{
  21968. "failed_code": -10,
  21969. "msg": errMsgs,
  21970. })
  21971. return
  21972. } else {
  21973. if miConfig.MdtrtareaAdmvs == "320921" {
  21974. data["doctor_id"] = "D320923012139"
  21975. } else {
  21976. data["doctor_id"] = "D371621008686"
  21977. }
  21978. bytesData, _ := json.Marshal(data)
  21979. var req *http.Request
  21980. if miConfig.MdtrtareaAdmvs == "320921" {
  21981. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21982. } else {
  21983. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  21984. }
  21985. resp, _ := client.Do(req)
  21986. defer resp.Body.Close()
  21987. body, ioErr := ioutil.ReadAll(resp.Body)
  21988. if ioErr != nil {
  21989. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  21990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21991. return
  21992. }
  21993. var respJSON map[string]interface{}
  21994. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  21995. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  21996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  21997. return
  21998. }
  21999. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22000. userJSONBytes, _ := json.Marshal(respJSON)
  22001. fmt.Println("log")
  22002. fmt.Println(string(userJSONBytes))
  22003. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22004. utils.ErrorLog("解析失败:%v", err)
  22005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22006. return
  22007. }
  22008. res.InfRefmsgid = resFour10265.InfRefmsgid
  22009. res.Output = resFour10265.Output
  22010. res.ErrMsg = resFour10265.ErrMsg
  22011. res.Cainfo = resFour10265.Cainfo
  22012. res.WarnMsg = resFour10265.WarnMsg
  22013. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22014. res.Infcode = infocode
  22015. }
  22016. }
  22017. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22018. var pagesize int = 5
  22019. var start int = 1
  22020. var stop int
  22021. var pagecount int
  22022. var curpage int
  22023. data["doctor_id"] = doctor_info.DoctorNumber
  22024. var res2 ResultFour
  22025. //var result res.
  22026. //总页数,向上取整,注意除之前要先转换类型为float64
  22027. pagecount = int(math.Ceil(float64(len(prescriptions)) / float64(pagesize)))
  22028. for curpage = 1; curpage <= pagecount; curpage++ {
  22029. if curpage == 1 {
  22030. start = 1
  22031. } else {
  22032. start = (curpage-1)*pagesize + 1
  22033. }
  22034. stop = curpage * pagesize
  22035. if stop > len(prescriptions) {
  22036. stop = len(prescriptions)
  22037. }
  22038. //var requestLog string
  22039. data["pre"] = prescriptions[start-1 : stop]
  22040. fmt.Println(data["pre"])
  22041. bytesData, _ := json.Marshal(data)
  22042. var req *http.Request
  22043. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/2204", bytes.NewReader(bytesData))
  22044. resp, _ := client.Do(req)
  22045. defer resp.Body.Close()
  22046. body, ioErr := ioutil.ReadAll(resp.Body)
  22047. if ioErr != nil {
  22048. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22050. return
  22051. }
  22052. var respJSON map[string]interface{}
  22053. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22054. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22056. return
  22057. }
  22058. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22059. userJSONBytes, _ := json.Marshal(respJSON)
  22060. fmt.Println("log")
  22061. fmt.Println(string(userJSONBytes))
  22062. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22063. utils.ErrorLog("解析失败:%v", err)
  22064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22065. return
  22066. }
  22067. res.InfRefmsgid = resFour10265.InfRefmsgid
  22068. res.Output = resFour10265.Output
  22069. res.ErrMsg = resFour10265.ErrMsg
  22070. res.Cainfo = resFour10265.Cainfo
  22071. res.WarnMsg = resFour10265.WarnMsg
  22072. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22073. res.Infcode = infocode
  22074. if infocode == 0 {
  22075. res2.Output.Result = append(res2.Output.Result, res.Output.Result...)
  22076. } else {
  22077. isSuccess = false
  22078. res2.ErrMsg = res2.ErrMsg + "," + res.ErrMsg
  22079. res.Infcode = -1
  22080. res.ErrMsg = resFour10265.ErrMsg
  22081. errlog := &models.HisOrderError{
  22082. UserOrgId: adminUser.CurrentOrgId,
  22083. Ctime: time.Now().Unix(),
  22084. Mtime: time.Now().Unix(),
  22085. Number: chrg_bchno,
  22086. ErrMsg: "",
  22087. Status: 1,
  22088. PatientId: id,
  22089. RecordTime: recordDateTime,
  22090. Stage: 4,
  22091. }
  22092. service.CreateErrMsgLog(errlog)
  22093. }
  22094. }
  22095. if isSuccess {
  22096. res.Infcode = 0
  22097. res.Output.Result = res2.Output.Result
  22098. } else {
  22099. order := &models.HisOrder{
  22100. UserOrgId: adminUser.CurrentOrgId,
  22101. HisPatientId: his.ID,
  22102. PatientId: his.PatientId,
  22103. SettleAccountsDate: recordDateTime,
  22104. Ctime: time.Now().Unix(),
  22105. Mtime: time.Now().Unix(),
  22106. MdtrtId: his.Number,
  22107. PsnNo: his.PsnNo,
  22108. MedType: strconv.FormatInt(reg_type, 10),
  22109. Status: 1,
  22110. Number: chrg_bchno,
  22111. Infcode: res.Infcode,
  22112. WarnMsg: res.WarnMsg,
  22113. Cainfo: res.Cainfo,
  22114. ErrMsg: res.ErrMsg,
  22115. RespondTime: res.RefmsgTime,
  22116. InfRefmsgid: res.InfRefmsgid,
  22117. OrderStatus: 1,
  22118. IsMedicineInsurance: 1,
  22119. SettleType: settle_accounts_type,
  22120. SettleStartTime: start_time,
  22121. SettleEndTime: end_time,
  22122. Creator: roles.AdminUserId,
  22123. Modify: roles.AdminUserId,
  22124. PType: 2,
  22125. Diagnosis: diagnosis_id,
  22126. }
  22127. err = service.CreateOrder(order)
  22128. if err != nil {
  22129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22130. return
  22131. }
  22132. c.ServeSuccessJSON(map[string]interface{}{
  22133. "failed_code": -10,
  22134. "msg": res2.ErrMsg,
  22135. })
  22136. return
  22137. }
  22138. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22139. 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)
  22140. var dat map[string]interface{}
  22141. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22142. fmt.Println(dat)
  22143. } else {
  22144. fmt.Println(err)
  22145. }
  22146. saveLog(result, request_log, "2204", "上传费用明细")
  22147. userJSONBytes, _ := json.Marshal(dat)
  22148. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22149. utils.ErrorLog("解析失败:%v", err)
  22150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22151. return
  22152. }
  22153. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22154. 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, "", "")
  22155. var dat map[string]interface{}
  22156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22157. fmt.Println(dat)
  22158. } else {
  22159. fmt.Println(err)
  22160. }
  22161. saveLog(result, request_log, "2204", "上传费用明细")
  22162. userJSONBytes, _ := json.Marshal(dat)
  22163. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22164. utils.ErrorLog("解析失败:%v", err)
  22165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22166. return
  22167. }
  22168. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22169. bytesData, _ := json.Marshal(data)
  22170. var req *http.Request
  22171. req, _ = http.NewRequest("POST", miConfig.SecretKey+"ahyb/2204", bytes.NewReader(bytesData))
  22172. resp, _ := client.Do(req)
  22173. defer resp.Body.Close()
  22174. body, ioErr := ioutil.ReadAll(resp.Body)
  22175. if ioErr != nil {
  22176. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22178. return
  22179. }
  22180. var respJSON map[string]interface{}
  22181. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22182. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22184. return
  22185. }
  22186. status := respJSON["data"].(map[string]interface{})["status"].(string)
  22187. if status == "0" {
  22188. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  22189. c.ServeSuccessJSON(map[string]interface{}{
  22190. "failed_code": -10,
  22191. "msg": err_msg,
  22192. })
  22193. return
  22194. }
  22195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22196. userJSONBytes, _ := json.Marshal(respJSON)
  22197. fmt.Println("log")
  22198. fmt.Println(string(userJSONBytes))
  22199. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22200. utils.ErrorLog("解析失败:%v", err)
  22201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22202. return
  22203. }
  22204. } else if miConfig.MdtrtareaAdmvs == "430800" {
  22205. 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, "", "")
  22206. var dat map[string]interface{}
  22207. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22208. fmt.Println(dat)
  22209. } else {
  22210. fmt.Println(err)
  22211. }
  22212. saveLog(result, request_log, "2204", "上传费用明细")
  22213. userJSONBytes, _ := json.Marshal(dat)
  22214. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22215. utils.ErrorLog("解析失败:%v", err)
  22216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22217. return
  22218. }
  22219. } else if miConfig.MdtrtareaAdmvs == "441799" {
  22220. bytesData, _ := json.Marshal(data)
  22221. req, _ := http.NewRequest("POST", miConfig.Url+"gdyb/2204", bytes.NewReader(bytesData))
  22222. resp, _ := client.Do(req)
  22223. defer resp.Body.Close()
  22224. body, ioErr := ioutil.ReadAll(resp.Body)
  22225. if ioErr != nil {
  22226. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22228. return
  22229. }
  22230. var respJSON map[string]interface{}
  22231. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  22232. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22234. return
  22235. }
  22236. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22237. userJSONBytes, _ := json.Marshal(respJSON)
  22238. fmt.Println("log")
  22239. fmt.Println(string(userJSONBytes))
  22240. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22241. utils.ErrorLog("解析失败:%v", err)
  22242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22243. return
  22244. }
  22245. } else {
  22246. if miConfig.MdtrtareaAdmvs == "441202" {
  22247. result3101 := Checkgd3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  22248. if result3101.Infcode == 0 {
  22249. if len(result3101.Output.Result) > 0 {
  22250. var errMsgs []string
  22251. for _, item := range result3101.Output.Result {
  22252. errMsgs = append(errMsgs, item.VolaCont)
  22253. }
  22254. c.ServeSuccessJSON(map[string]interface{}{
  22255. "failed_code": -10,
  22256. "msg": errMsgs,
  22257. })
  22258. return
  22259. } else {
  22260. 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)
  22261. var dat map[string]interface{}
  22262. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22263. fmt.Println(dat)
  22264. } else {
  22265. fmt.Println(err)
  22266. }
  22267. saveLog(result, request_log, "2204", "上传费用明细")
  22268. userJSONBytes, _ := json.Marshal(dat)
  22269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22270. utils.ErrorLog("解析失败:%v", err)
  22271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22272. return
  22273. }
  22274. }
  22275. } else {
  22276. c.ServeSuccessJSON(map[string]interface{}{
  22277. "failed_code": -10,
  22278. "msg": result3101.ErrMsg,
  22279. })
  22280. return
  22281. }
  22282. } else {
  22283. if miConfig.Code == "H15049901371" {
  22284. 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)
  22285. var dat map[string]interface{}
  22286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22287. fmt.Println(dat)
  22288. } else {
  22289. fmt.Println(err)
  22290. }
  22291. saveLog(result, request_log, "2204", "上传费用明细")
  22292. userJSONBytes, _ := json.Marshal(dat)
  22293. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  22294. utils.ErrorLog("解析失败:%v", err)
  22295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22296. return
  22297. }
  22298. res.InfRefmsgid = resFour10265.InfRefmsgid
  22299. res.Output = resFour10265.Output
  22300. res.ErrMsg = resFour10265.ErrMsg
  22301. res.Cainfo = resFour10265.Cainfo
  22302. res.WarnMsg = resFour10265.WarnMsg
  22303. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  22304. res.Infcode = infocode
  22305. } else {
  22306. 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)
  22307. var dat map[string]interface{}
  22308. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22309. fmt.Println(dat)
  22310. } else {
  22311. fmt.Println(err)
  22312. }
  22313. saveLog(result, request_log, "2204", "上传费用明细")
  22314. userJSONBytes, _ := json.Marshal(dat)
  22315. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22316. utils.ErrorLog("解析失败:%v", err)
  22317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22318. return
  22319. }
  22320. }
  22321. }
  22322. }
  22323. var total_two float64
  22324. if res.Infcode == 0 {
  22325. order := &models.HisOrder{
  22326. UserOrgId: adminUser.CurrentOrgId,
  22327. HisPatientId: his.ID,
  22328. PatientId: his.PatientId,
  22329. SettleAccountsDate: recordDateTime,
  22330. Ctime: time.Now().Unix(),
  22331. Mtime: time.Now().Unix(),
  22332. MdtrtId: his.Number,
  22333. PsnNo: his.PsnNo,
  22334. MedType: strconv.FormatInt(reg_type, 10),
  22335. Status: 1,
  22336. Number: chrg_bchno,
  22337. Infcode: res.Infcode,
  22338. WarnMsg: res.WarnMsg,
  22339. Cainfo: res.Cainfo,
  22340. ErrMsg: res.ErrMsg,
  22341. RespondTime: res.RefmsgTime,
  22342. InfRefmsgid: res.InfRefmsgid,
  22343. OrderStatus: 1,
  22344. IsMedicineInsurance: 1,
  22345. SettleType: settle_accounts_type,
  22346. SettleStartTime: start_time,
  22347. SettleEndTime: end_time,
  22348. Creator: roles.AdminUserId,
  22349. Modify: roles.AdminUserId,
  22350. PType: 2,
  22351. Diagnosis: diagnosis_id,
  22352. }
  22353. err = service.CreateOrder(order)
  22354. if err != nil {
  22355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  22356. return
  22357. }
  22358. for _, item := range res.Output.Result {
  22359. temp := strings.Split(item.FeedetlSn, "-")
  22360. var advice_id int64 = 0
  22361. var project_id int64 = 0
  22362. var types int64 = 0
  22363. id, _ := strconv.ParseInt(temp[2], 10, 64)
  22364. types, _ = strconv.ParseInt(temp[1], 10, 64)
  22365. if temp[1] == "1" {
  22366. advice_id = id
  22367. project_id = 0
  22368. } else if temp[1] == "2" {
  22369. advice_id = 0
  22370. project_id = id
  22371. }
  22372. total_two = total_two + item.DetItemFeeSumamt
  22373. info := &models.HisOrderInfo{
  22374. OrderNumber: order.Number,
  22375. FeedetlSn: item.FeedetlSn,
  22376. UploadDate: time.Now().Unix(),
  22377. AdviceId: advice_id,
  22378. DetItemFeeSumamt: item.DetItemFeeSumamt,
  22379. Cnt: item.Cnt,
  22380. Pric: float64(item.Pric),
  22381. PatientId: his.PatientId,
  22382. PricUplmtAmt: item.PricUplmtAmt,
  22383. SelfpayProp: item.SelfpayProp,
  22384. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  22385. OverlmtAmt: item.OverlmtAmt,
  22386. PreselfpayAmt: item.PreselfpayAmt,
  22387. BasMednFlag: item.BasMednFlag,
  22388. MedChrgitmType: item.MedChrgitmType,
  22389. HiNegoDrugFlag: item.HiNegoDrugFlag,
  22390. Status: 1,
  22391. Memo: item.Memo,
  22392. Mtime: time.Now().Unix(),
  22393. InscpScpAmt: item.InscpScpAmt,
  22394. DrtReimFlag: item.DrtReimFlag,
  22395. Ctime: time.Now().Unix(),
  22396. ListSpItemFlag: item.ListSpItemFlag,
  22397. ChldMedcFlag: item.ChldMedcFlag,
  22398. LmtUsedFlag: item.LmtUsedFlag,
  22399. ChrgitmLv: item.ChrgitmLv,
  22400. UserOrgId: adminUser.CurrentOrgId,
  22401. HisPatientId: his.ID,
  22402. OrderId: order.ID,
  22403. ProjectId: project_id,
  22404. Type: types,
  22405. }
  22406. service.CreateOrderInfo(info)
  22407. }
  22408. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  22409. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  22410. var total float64
  22411. for _, item := range prescriptions {
  22412. if item.Type == 1 { //药品
  22413. for _, subItem := range item.HisDoctorAdviceInfo {
  22414. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22415. total_one := price * subItem.PrescribingNumber
  22416. fmt.Println("subItem")
  22417. fmt.Println(subItem.Price)
  22418. fmt.Println("price")
  22419. fmt.Println(price)
  22420. fmt.Println("total_one")
  22421. fmt.Println(total_one)
  22422. total = total + total_one
  22423. fmt.Println(total)
  22424. }
  22425. }
  22426. if item.Type == 2 { //项目
  22427. for _, subItem := range item.HisPrescriptionProject {
  22428. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  22429. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  22430. total_one := price * cnt
  22431. total = total + total_one
  22432. }
  22433. }
  22434. }
  22435. allTotal := fmt.Sprintf("%.2f", total)
  22436. if res.Infcode == 0 {
  22437. var rf []*ResultFive
  22438. json.Unmarshal([]byte(his.Iinfo), &rf)
  22439. chrg_bchno := chrg_bchno
  22440. cert_no := his.Certno
  22441. var insutypes []string
  22442. var insutype string
  22443. var is390 int = 0
  22444. var is310 int = 0
  22445. for _, item := range rf {
  22446. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  22447. insutypes = append(insutypes, item.Insutype)
  22448. }
  22449. }
  22450. if len(insutypes) == 1 {
  22451. insutype = insutypes[0]
  22452. } else {
  22453. for _, i := range insutypes {
  22454. if i == "390" {
  22455. is390 = 1
  22456. }
  22457. if i == "310" {
  22458. is310 = 1
  22459. }
  22460. }
  22461. }
  22462. if is390 == 1 {
  22463. insutype = "390"
  22464. }
  22465. if is310 == 1 {
  22466. insutype = "310"
  22467. }
  22468. if len(insutypes) == 0 {
  22469. insutype = "390"
  22470. }
  22471. if len(insutypes) == 2 {
  22472. insutype = strconv.FormatInt(his.SocialType, 10)
  22473. }
  22474. //insutype = "390"
  22475. if his.IdCardType == 1 {
  22476. cert_no = his.MedicalInsuranceNumber
  22477. } else {
  22478. cert_no = his.Certno
  22479. }
  22480. var res ResultSeven
  22481. var ahres ResultSevenAH
  22482. var resSeven10265 ResultSeven10265
  22483. var resSeven10265Two ResultSeven10265Two
  22484. var gzresSeven10265Two GZResultSeven10265Two
  22485. if miConfig.MdtrtareaAdmvs == "421300" {
  22486. formattedString := strconv.FormatFloat(total, 'f', 2, 64)
  22487. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22488. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22489. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22490. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22491. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22492. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22493. "&insutype=" + insutype + "&total=" + formattedString + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22494. resp, requestErr := http.Get(api)
  22495. if requestErr != nil {
  22496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22497. return
  22498. }
  22499. body, ioErr := ioutil.ReadAll(resp.Body)
  22500. if ioErr != nil {
  22501. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22503. return
  22504. }
  22505. var respJSON map[string]interface{}
  22506. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22507. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22509. return
  22510. }
  22511. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22512. result, _ := json.Marshal(respJSON)
  22513. fmt.Println("log")
  22514. fmt.Println(string(result))
  22515. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22516. utils.ErrorLog("解析失败:%v", err)
  22517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22518. return
  22519. }
  22520. } else if miConfig.MdtrtareaAdmvs == "420200" {
  22521. if reg_type == 11 && his.Insutype == "390" {
  22522. reg_type = 110104
  22523. }
  22524. api := "http://192.168.0.197:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22525. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22526. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22527. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22528. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22529. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22530. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22531. resp, requestErr := http.Get(api)
  22532. if requestErr != nil {
  22533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22534. return
  22535. }
  22536. body, ioErr := ioutil.ReadAll(resp.Body)
  22537. if ioErr != nil {
  22538. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22540. return
  22541. }
  22542. var respJSON map[string]interface{}
  22543. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22544. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22546. return
  22547. }
  22548. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22549. result, _ := json.Marshal(respJSON)
  22550. fmt.Println("log")
  22551. fmt.Println(string(result))
  22552. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22553. utils.ErrorLog("解析失败:%v", err)
  22554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22555. return
  22556. }
  22557. } else if miConfig.MdtrtareaAdmvs == "420902" {
  22558. if reg_type == 11 && his.Insutype == "390" {
  22559. reg_type = 110104
  22560. }
  22561. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22562. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22563. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22564. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22565. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22566. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22567. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22568. resp, requestErr := http.Get(api)
  22569. if requestErr != nil {
  22570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22571. return
  22572. }
  22573. body, ioErr := ioutil.ReadAll(resp.Body)
  22574. if ioErr != nil {
  22575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22577. return
  22578. }
  22579. var respJSON map[string]interface{}
  22580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22583. return
  22584. }
  22585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22586. result, _ := json.Marshal(respJSON)
  22587. fmt.Println("log")
  22588. fmt.Println(string(result))
  22589. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22590. utils.ErrorLog("解析失败:%v", err)
  22591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22592. return
  22593. }
  22594. } else if miConfig.MdtrtareaAdmvs == "421182" {
  22595. if reg_type == 11 && his.Insutype == "390" {
  22596. reg_type = 110104
  22597. }
  22598. api := miConfig.Url + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22599. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22600. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22601. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22602. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22603. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22604. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  22605. resp, requestErr := http.Get(api)
  22606. if requestErr != nil {
  22607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22608. return
  22609. }
  22610. body, ioErr := ioutil.ReadAll(resp.Body)
  22611. if ioErr != nil {
  22612. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22614. return
  22615. }
  22616. var respJSON map[string]interface{}
  22617. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22618. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22620. return
  22621. }
  22622. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22623. result, _ := json.Marshal(respJSON)
  22624. fmt.Println("log")
  22625. fmt.Println(string(result))
  22626. if err := json.Unmarshal([]byte(result), &res); err != nil {
  22627. utils.ErrorLog("解析失败:%v", err)
  22628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22629. return
  22630. }
  22631. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  22632. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  22633. if result3101.Infcode == "0" {
  22634. if len(result3101.Output.Result) > 0 {
  22635. var errMsgs []string
  22636. for _, item := range result3101.Output.Result {
  22637. errMsgs = append(errMsgs, item.VolaCont)
  22638. }
  22639. c.ServeSuccessJSON(map[string]interface{}{
  22640. "failed_code": -10,
  22641. "msg": errMsgs,
  22642. })
  22643. return
  22644. } else {
  22645. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22646. if his.IdCardType != 4 {
  22647. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22648. bas := strings.Split(psn_info.CardInfo, "|")
  22649. if his.IdCardType == 1 {
  22650. cert_no = bas[2]
  22651. } else {
  22652. cert_no = bas[1]
  22653. }
  22654. } else {
  22655. cert_no = his.Certno
  22656. }
  22657. //江苏地区国家医保医疗类别
  22658. //职工透析:医疗类别选特殊情况门诊9933
  22659. //居民血透门慢: 医疗类别选门诊慢病1402
  22660. //var med_type string
  22661. //if his.Insutype == "310" {
  22662. // if reg_type == 14 {
  22663. // med_type = "9933"
  22664. // } else if reg_type == 11 {
  22665. // med_type = "11"
  22666. //
  22667. // }
  22668. //} else if his.Insutype == "390" {
  22669. // if reg_type == 14 {
  22670. // med_type = "1402"
  22671. // } else if reg_type == 11 {
  22672. // med_type = "11"
  22673. // }
  22674. //}
  22675. var api string
  22676. if miConfig.MdtrtareaAdmvs == "320921" {
  22677. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22678. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22679. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22680. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22681. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22682. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22683. "&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
  22684. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22685. } else {
  22686. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22687. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22688. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22689. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22690. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22691. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22692. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22693. "&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
  22694. }
  22695. resp, requestErr := http.Get(api)
  22696. if requestErr != nil {
  22697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22698. return
  22699. }
  22700. body, ioErr := ioutil.ReadAll(resp.Body)
  22701. if ioErr != nil {
  22702. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22704. return
  22705. }
  22706. var respJSON map[string]interface{}
  22707. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22708. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22710. return
  22711. }
  22712. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22713. result, _ := json.Marshal(respJSON)
  22714. fmt.Println("log")
  22715. fmt.Println(string(result))
  22716. if strings.Contains(miConfig.MdtrtareaAdmvs, "3209") {
  22717. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22718. utils.ErrorLog("解析失败:%v", err)
  22719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22720. return
  22721. }
  22722. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22723. res.Output = resSeven10265.Output
  22724. res.ErrMsg = resSeven10265.ErrMsg
  22725. res.Cainfo = resSeven10265.Cainfo
  22726. res.WarnMsg = resSeven10265.WarnMsg
  22727. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22728. res.Infcode = infocode
  22729. } else {
  22730. if err := json.Unmarshal([]byte(result), &resSeven10265Two); err != nil {
  22731. utils.ErrorLog("解析失败:%v", err)
  22732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22733. return
  22734. }
  22735. res.InfRefmsgid = resSeven10265Two.InfRefmsgid
  22736. //AcctMulaidPay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.AcctMulaidPay, 64)
  22737. //res.Output.Setlinfo.AcctMulaidPay = AcctMulaidPay
  22738. res.Output.Setlinfo.AcctPay = resSeven10265Two.Output.Setlinfo.AcctPay
  22739. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22740. res.Output.Setlinfo.ActPayDedc = resSeven10265Two.Output.Setlinfo.ActPayDedc
  22741. res.Output.Setlinfo.Age = resSeven10265Two.Output.Setlinfo.Age
  22742. res.Output.Setlinfo.Balc = resSeven10265Two.Output.Setlinfo.Balc
  22743. //res.Output.Setlinfo.Brdy = resSeven10265Two.Output.Setlinfo.Brdy
  22744. res.Output.Setlinfo.Certno = resSeven10265Two.Output.Setlinfo.Certno
  22745. res.Output.Setlinfo.ClrOptins = resSeven10265Two.Output.Setlinfo.ClrOptins
  22746. res.Output.Setlinfo.ClrType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22747. res.Output.Setlinfo.ClrWay = resSeven10265Two.Output.Setlinfo.ClrOptins
  22748. res.Output.Setlinfo.CvlservFlag = resSeven10265Two.Output.Setlinfo.ClrOptins
  22749. res.Output.Setlinfo.CvlservPay = resSeven10265Two.Output.Setlinfo.CvlservPay
  22750. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  22751. res.Output.Setlinfo.FundPaySumamt = resSeven10265Two.Output.Setlinfo.FundPaySumamt
  22752. res.Output.Setlinfo.Gend = resSeven10265Two.Output.Setlinfo.Gend
  22753. res.Output.Setlinfo.HifesPay = resSeven10265Two.Output.Setlinfo.HifesPay
  22754. res.Output.Setlinfo.HifmiPay = resSeven10265Two.Output.Setlinfo.HifmiPay
  22755. res.Output.Setlinfo.HifpPay = resSeven10265Two.Output.Setlinfo.HifpPay
  22756. HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22757. res.Output.Setlinfo.HospPartAmt = HospPartAmt
  22758. res.Output.Setlinfo.InscpScpAmt = resSeven10265Two.Output.Setlinfo.InscpScpAmt
  22759. res.Output.Setlinfo.Insutype = resSeven10265Two.Output.Setlinfo.Insutype
  22760. res.Output.Setlinfo.MafPay = resSeven10265Two.Output.Setlinfo.MafPay
  22761. res.Output.Setlinfo.MdtrtCertType = resSeven10265Two.Output.Setlinfo.MdtrtCertType
  22762. res.Output.Setlinfo.HifobPay = resSeven10265Two.Output.Setlinfo.HifobPay
  22763. res.Output.Setlinfo.MdtrtID = resSeven10265Two.Output.Setlinfo.MdtrtID
  22764. res.Output.Setlinfo.MedType = resSeven10265Two.Output.Setlinfo.MedType
  22765. res.Output.Setlinfo.MedfeeSumamt = resSeven10265Two.Output.Setlinfo.MedfeeSumamt
  22766. res.Output.Setlinfo.MedinsSetlID = resSeven10265Two.Output.Setlinfo.MedinsSetlID
  22767. res.Output.Setlinfo.Naty = resSeven10265Two.Output.Setlinfo.Naty
  22768. res.Output.Setlinfo.OthPay = resSeven10265Two.Output.Setlinfo.OthPay
  22769. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  22770. PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22771. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  22772. res.Output.Setlinfo.PreselfpayAmt = resSeven10265Two.Output.Setlinfo.PreselfpayAmt
  22773. res.Output.Setlinfo.PsnCashPay = resSeven10265Two.Output.Setlinfo.PsnCashPay
  22774. res.Output.Setlinfo.PsnCertType = resSeven10265Two.Output.Setlinfo.ClrOptins
  22775. res.Output.Setlinfo.PsnName = resSeven10265Two.Output.Setlinfo.PsnName
  22776. res.Output.Setlinfo.PsnNo = resSeven10265Two.Output.Setlinfo.PsnNo
  22777. res.Output.Setlinfo.PsnPartAmt = resSeven10265Two.Output.Setlinfo.PsnPartAmt
  22778. res.Output.Setlinfo.PsnType = resSeven10265Two.Output.Setlinfo.PsnType
  22779. res.Output.Setlinfo.SetlID = resSeven10265Two.Output.Setlinfo.SetlID
  22780. res.Output.Setlinfo.SetlTime = resSeven10265Two.Output.Setlinfo.SetlTime
  22781. //res.Output.Setldetail = resSeven10265Two.Output.Setldetail
  22782. res.ErrMsg = resSeven10265Two.ErrMsg
  22783. res.Cainfo = resSeven10265Two.Cainfo
  22784. res.WarnMsg = resSeven10265Two.WarnMsg
  22785. infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  22786. res.Infcode = infocode
  22787. }
  22788. }
  22789. }
  22790. } else if miConfig.MdtrtareaAdmvs == "150499" {
  22791. psn_info, _ := service.GetPsnByPatientId(id)
  22792. var verify_number string
  22793. if psn_info.IdCardType == 4 {
  22794. verify_number = psn_info.VerifyNumber
  22795. } else if psn_info.IdCardType == 1 {
  22796. bas := strings.Split(psn_info.CardInfo, "|")
  22797. cardNumber := bas[2]
  22798. verify_number = cardNumber
  22799. } else {
  22800. psn_info.IdCardType = 2
  22801. verify_number = psn_info.Certno
  22802. }
  22803. var api string
  22804. api = "http://172.16.13.254:9532/" + "nmyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22805. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22806. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22807. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22808. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(psn_info.IdCardType, 10) +
  22809. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22810. "&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
  22811. resp, requestErr := http.Get(api)
  22812. if requestErr != nil {
  22813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22814. return
  22815. }
  22816. body, ioErr := ioutil.ReadAll(resp.Body)
  22817. if ioErr != nil {
  22818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22820. return
  22821. }
  22822. var respJSON map[string]interface{}
  22823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  22824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  22825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22826. return
  22827. }
  22828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  22829. result, _ := json.Marshal(respJSON)
  22830. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  22831. utils.ErrorLog("解析失败:%v", err)
  22832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22833. return
  22834. }
  22835. res.InfRefmsgid = resSeven10265.InfRefmsgid
  22836. res.Output.Setlinfo.AcctMulaidPay = resSeven10265.Output.Setlinfo.AcctMulaidPay
  22837. res.Output.Setlinfo.AcctPay = resSeven10265.Output.Setlinfo.AcctPay
  22838. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22839. res.Output.Setlinfo.ActPayDedc = resSeven10265.Output.Setlinfo.ActPayDedc
  22840. res.Output.Setlinfo.Age = resSeven10265.Output.Setlinfo.Age
  22841. res.Output.Setlinfo.Balc = resSeven10265.Output.Setlinfo.Balc
  22842. //res.Output.Setlinfo.Brdy = resSeven10265.Output.Setlinfo.Brdy
  22843. res.Output.Setlinfo.Certno = resSeven10265.Output.Setlinfo.Certno
  22844. res.Output.Setlinfo.ClrOptins = resSeven10265.Output.Setlinfo.ClrOptins
  22845. res.Output.Setlinfo.ClrType = resSeven10265.Output.Setlinfo.ClrOptins
  22846. res.Output.Setlinfo.ClrWay = resSeven10265.Output.Setlinfo.ClrOptins
  22847. res.Output.Setlinfo.CvlservFlag = resSeven10265.Output.Setlinfo.ClrOptins
  22848. res.Output.Setlinfo.CvlservPay = resSeven10265.Output.Setlinfo.CvlservPay
  22849. res.Output.Setlinfo.FulamtOwnpayAmt = resSeven10265.Output.Setlinfo.FulamtOwnpayAmt
  22850. res.Output.Setlinfo.FundPaySumamt = resSeven10265.Output.Setlinfo.FundPaySumamt
  22851. res.Output.Setlinfo.Gend = resSeven10265.Output.Setlinfo.Gend
  22852. res.Output.Setlinfo.HifesPay = resSeven10265.Output.Setlinfo.HifesPay
  22853. res.Output.Setlinfo.HifmiPay = resSeven10265.Output.Setlinfo.HifmiPay
  22854. res.Output.Setlinfo.HifpPay = resSeven10265.Output.Setlinfo.HifpPay
  22855. //HospPartAmt, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  22856. res.Output.Setlinfo.HospPartAmt = resSeven10265.Output.Setlinfo.HospPartAmt
  22857. res.Output.Setlinfo.InscpScpAmt = resSeven10265.Output.Setlinfo.InscpScpAmt
  22858. res.Output.Setlinfo.Insutype = resSeven10265.Output.Setlinfo.Insutype
  22859. res.Output.Setlinfo.MafPay = resSeven10265.Output.Setlinfo.MafPay
  22860. res.Output.Setlinfo.MdtrtCertType = resSeven10265.Output.Setlinfo.MdtrtCertType
  22861. res.Output.Setlinfo.HifobPay = resSeven10265.Output.Setlinfo.HifobPay
  22862. res.Output.Setlinfo.MdtrtID = resSeven10265.Output.Setlinfo.MdtrtID
  22863. res.Output.Setlinfo.MedType = resSeven10265.Output.Setlinfo.MedType
  22864. res.Output.Setlinfo.MedfeeSumamt = resSeven10265.Output.Setlinfo.MedfeeSumamt
  22865. res.Output.Setlinfo.MedinsSetlID = resSeven10265.Output.Setlinfo.MedinsSetlID
  22866. res.Output.Setlinfo.Naty = resSeven10265.Output.Setlinfo.Naty
  22867. res.Output.Setlinfo.OthPay = resSeven10265.Output.Setlinfo.OthPay
  22868. res.Output.Setlinfo.OverlmtSelfpay = resSeven10265.Output.Setlinfo.OverlmtSelfpay
  22869. //PoolPropSelfpay, _ := strconv.ParseFloat(resSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  22870. res.Output.Setlinfo.PoolPropSelfpay = resSeven10265.Output.Setlinfo.PoolPropSelfpay
  22871. res.Output.Setlinfo.PreselfpayAmt = resSeven10265.Output.Setlinfo.PreselfpayAmt
  22872. res.Output.Setlinfo.PsnCashPay = resSeven10265.Output.Setlinfo.PsnCashPay
  22873. res.Output.Setlinfo.PsnCertType = resSeven10265.Output.Setlinfo.ClrOptins
  22874. res.Output.Setlinfo.PsnName = resSeven10265.Output.Setlinfo.PsnName
  22875. res.Output.Setlinfo.PsnNo = resSeven10265.Output.Setlinfo.PsnNo
  22876. res.Output.Setlinfo.PsnPartAmt = resSeven10265.Output.Setlinfo.PsnPartAmt
  22877. res.Output.Setlinfo.PsnType = resSeven10265.Output.Setlinfo.PsnType
  22878. res.Output.Setlinfo.SetlID = resSeven10265.Output.Setlinfo.SetlID
  22879. res.Output.Setlinfo.SetlTime = resSeven10265.Output.Setlinfo.SetlTime
  22880. //res.Output.Setldetail = resSeven10265.Output.Setldetail
  22881. res.ErrMsg = resSeven10265.ErrMsg
  22882. res.Cainfo = resSeven10265.Cainfo
  22883. res.WarnMsg = resSeven10265.WarnMsg
  22884. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  22885. res.Infcode = infocode
  22886. } else if miConfig.MdtrtareaAdmvs == "350500" {
  22887. acct_used_flag := "1"
  22888. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  22889. var result string
  22890. var request_log string
  22891. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  22892. 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)
  22893. } else {
  22894. 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)
  22895. }
  22896. var dat map[string]interface{}
  22897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22898. fmt.Println(dat)
  22899. } else {
  22900. fmt.Println(err)
  22901. }
  22902. saveLog(result, request_log, "2206", "预结算")
  22903. userJSONBytes, _ := json.Marshal(dat)
  22904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22905. utils.ErrorLog("解析失败:%v", err)
  22906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22907. return
  22908. }
  22909. } else if miConfig.MdtrtareaAdmvs == "360302" {
  22910. var result string
  22911. var request_log string
  22912. if his.IdCardType == 2 {
  22913. 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, "")
  22914. } else if his.IdCardType == 1 {
  22915. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22916. bas := strings.Split(psn_info.CardInfo, "|")
  22917. basNumber := bas[2]
  22918. card_sn := bas[3]
  22919. var rf []*ResultFive
  22920. json.Unmarshal([]byte(his.Iinfo), &rf)
  22921. var psn_type string
  22922. for _, item := range rf {
  22923. if item.InsuplcAdmdvs == his.InsuplcAdmdvs {
  22924. psn_type = item.PsnType
  22925. }
  22926. }
  22927. 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)
  22928. } else {
  22929. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22930. 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, "")
  22931. }
  22932. var dat map[string]interface{}
  22933. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  22934. fmt.Println(dat)
  22935. } else {
  22936. fmt.Println(err)
  22937. }
  22938. saveLog(result, request_log, "2206", "预结算")
  22939. userJSONBytes, _ := json.Marshal(dat)
  22940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  22941. utils.ErrorLog("解析失败:%v", err)
  22942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22943. return
  22944. }
  22945. } else if miConfig.MdtrtareaAdmvs == "341203" {
  22946. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  22947. if his.IdCardType == 4 {
  22948. psn_info.VerifyNumber = psn_info.VerifyNumber
  22949. cert_no = psn_info.Certno
  22950. } else if his.IdCardType == 2 {
  22951. cert_no = psn_info.Certno
  22952. psn_info.VerifyNumber = psn_info.Certno
  22953. } else {
  22954. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  22955. bas := strings.Split(psn_info.CardInfo, "|")
  22956. if his.IdCardType == 1 {
  22957. cert_no = bas[2]
  22958. } else {
  22959. cert_no = bas[1]
  22960. }
  22961. }
  22962. var api string
  22963. var med_type string
  22964. if his.Insutype == "390" {
  22965. if reg_type == 992102 {
  22966. med_type = "992102"
  22967. }
  22968. if reg_type == 140104 {
  22969. med_type = "140104"
  22970. }
  22971. if reg_type == 14 {
  22972. med_type = "140104"
  22973. }
  22974. } else if his.Insutype == "310" {
  22975. if reg_type == 992102 {
  22976. med_type = "992102"
  22977. }
  22978. if reg_type == 14 {
  22979. med_type = "14"
  22980. }
  22981. }
  22982. api = miConfig.SecretKey + "ahyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  22983. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  22984. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  22985. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  22986. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  22987. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  22988. "&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
  22989. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  22990. resp, requestErr := http.Get(api)
  22991. if requestErr != nil {
  22992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22993. return
  22994. }
  22995. body, ioErr := ioutil.ReadAll(resp.Body)
  22996. if ioErr != nil {
  22997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  22998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  22999. return
  23000. }
  23001. var respJSON map[string]interface{}
  23002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23005. return
  23006. }
  23007. status := respJSON["data"].(map[string]interface{})["status"].(string)
  23008. if status == "0" {
  23009. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  23010. c.ServeSuccessJSON(map[string]interface{}{
  23011. "failed_code": -10,
  23012. "msg": err_msg,
  23013. })
  23014. return
  23015. }
  23016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23017. result, _ := json.Marshal(respJSON)
  23018. fmt.Println("log")
  23019. fmt.Println(string(result))
  23020. if err := json.Unmarshal([]byte(result), &ahres); err != nil {
  23021. utils.ErrorLog("解析失败:%v", err)
  23022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23023. return
  23024. }
  23025. res.InfRefmsgid = ahres.InfRefmsgid
  23026. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23027. // 创建对应的Time类型
  23028. t := time.UnixMilli(timestamp)
  23029. // 格式化成指定的日期字符串
  23030. str := t.Format("2006-01-02 15:04:05")
  23031. res.Output.Setlinfo.SetlTime = str
  23032. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23033. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23034. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23035. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23036. res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23037. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23038. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23039. res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23040. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23041. res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23042. res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23043. res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23044. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23045. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23046. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23047. res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23048. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23049. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23050. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23051. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23052. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23053. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23054. res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23055. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23056. res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23057. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23058. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23059. res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23060. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23061. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23062. res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23063. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23064. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23065. res.Output.Setlinfo.PoolPropSelfpay = ahres.Output.Setlinfo.PoolPropSelfpay
  23066. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23067. res.Output.Setlinfo.PsnCashPay = ahres.Output.Setlinfo.PsnCashPay
  23068. res.Output.Setlinfo.PsnCertType = ahres.Output.Setlinfo.ClrOptins
  23069. res.Output.Setlinfo.PsnName = ahres.Output.Setlinfo.PsnName
  23070. res.Output.Setlinfo.PsnNo = ahres.Output.Setlinfo.PsnNo
  23071. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23072. res.Output.Setlinfo.PsnType = ahres.Output.Setlinfo.PsnType
  23073. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23074. //res.Output.Setldetail = ahres.Output.Setldetail
  23075. res.ErrMsg = ahres.ErrMsg
  23076. res.Cainfo = ahres.Cainfo
  23077. res.WarnMsg = ahres.WarnMsg
  23078. res.Infcode = ahres.Infcode
  23079. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23080. var result string
  23081. var request_log string
  23082. if his.IdCardType == 2 {
  23083. 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")
  23084. } else if his.IdCardType == 1 {
  23085. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23086. bas := strings.Split(psn_info.CardInfo, "|")
  23087. basNumber := bas[2]
  23088. card_sn := bas[3]
  23089. 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")
  23090. } else {
  23091. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23092. 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")
  23093. }
  23094. var dat map[string]interface{}
  23095. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23096. fmt.Println(dat)
  23097. } else {
  23098. fmt.Println(err)
  23099. }
  23100. saveLog(result, request_log, "2206", "预结算")
  23101. userJSONBytes, _ := json.Marshal(dat)
  23102. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23103. utils.ErrorLog("解析失败:%v", err)
  23104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23105. return
  23106. }
  23107. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23108. api := miConfig.Url + "gdyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  23109. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  23110. "&operator=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  23111. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  23112. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  23113. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  23114. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  23115. resp, requestErr := http.Get(api)
  23116. if requestErr != nil {
  23117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23118. return
  23119. }
  23120. body, ioErr := ioutil.ReadAll(resp.Body)
  23121. if ioErr != nil {
  23122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  23123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23124. return
  23125. }
  23126. var respJSON map[string]interface{}
  23127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  23128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23130. return
  23131. }
  23132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23133. result, _ := json.Marshal(respJSON)
  23134. fmt.Println("log")
  23135. fmt.Println(string(result))
  23136. if err := json.Unmarshal([]byte(result), &res); err != nil {
  23137. utils.ErrorLog("解析失败:%v", err)
  23138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23139. return
  23140. }
  23141. } else {
  23142. if miConfig.MdtrtareaAdmvs == "441202" {
  23143. result3101 := Checkgd3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  23144. if result3101.Infcode == 0 {
  23145. if len(result3101.Output.Result) > 0 {
  23146. var errMsgs []string
  23147. for _, item := range result3101.Output.Result {
  23148. errMsgs = append(errMsgs, item.VolaCont)
  23149. }
  23150. c.ServeSuccessJSON(map[string]interface{}{
  23151. "failed_code": -10,
  23152. "msg": errMsgs,
  23153. })
  23154. return
  23155. } else {
  23156. var result string
  23157. var request_log string
  23158. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23159. allTotal = fmt.Sprintf("%.2f", total_two)
  23160. if his.IdCardType == 4 {
  23161. 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)
  23162. } else {
  23163. 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)
  23164. }
  23165. var dat map[string]interface{}
  23166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23167. fmt.Println(dat)
  23168. } else {
  23169. fmt.Println(err)
  23170. }
  23171. saveLog(result, request_log, "2206", "预结算")
  23172. //userJSONBytes, _ := json.Marshal(dat)
  23173. //
  23174. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23175. // utils.ErrorLog("解析失败:%v", err)
  23176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23177. // return
  23178. //}
  23179. userJSONBytes, _ := json.Marshal(dat)
  23180. if miConfig.Code == "H15049901371" {
  23181. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23182. utils.ErrorLog("解析失败:%v", err)
  23183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23184. return
  23185. }
  23186. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23187. res.Output = resSeven10265.Output
  23188. res.ErrMsg = resSeven10265.ErrMsg
  23189. res.Cainfo = resSeven10265.Cainfo
  23190. res.WarnMsg = resSeven10265.WarnMsg
  23191. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23192. res.Infcode = infocode
  23193. } else {
  23194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23195. utils.ErrorLog("解析失败:%v", err)
  23196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23197. return
  23198. }
  23199. }
  23200. }
  23201. } else {
  23202. c.ServeSuccessJSON(map[string]interface{}{
  23203. "failed_code": -10,
  23204. "msg": result3101.ErrMsg,
  23205. })
  23206. return
  23207. }
  23208. } else {
  23209. var result string
  23210. var request_log string
  23211. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  23212. allTotal = fmt.Sprintf("%.2f", total_two)
  23213. if his.IdCardType == 4 {
  23214. 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)
  23215. } else {
  23216. 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)
  23217. }
  23218. var dat map[string]interface{}
  23219. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23220. fmt.Println(dat)
  23221. } else {
  23222. fmt.Println(err)
  23223. }
  23224. saveLog(result, request_log, "2206", "预结算")
  23225. //userJSONBytes, _ := json.Marshal(dat)
  23226. //
  23227. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23228. // utils.ErrorLog("解析失败:%v", err)
  23229. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23230. // return
  23231. //}
  23232. userJSONBytes, _ := json.Marshal(dat)
  23233. if miConfig.Code == "H15049901371" {
  23234. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  23235. utils.ErrorLog("解析失败:%v", err)
  23236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23237. return
  23238. }
  23239. res.InfRefmsgid = resSeven10265.InfRefmsgid
  23240. res.Output = resSeven10265.Output
  23241. res.ErrMsg = resSeven10265.ErrMsg
  23242. res.Cainfo = resSeven10265.Cainfo
  23243. res.WarnMsg = resSeven10265.WarnMsg
  23244. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  23245. res.Infcode = infocode
  23246. } else {
  23247. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23248. if err := json.Unmarshal(userJSONBytes, &gzresSeven10265Two); err != nil {
  23249. utils.ErrorLog("解析失败:%v", err)
  23250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23251. return
  23252. }
  23253. res.InfRefmsgid = gzresSeven10265Two.InfRefmsgid
  23254. res.Output.Setlinfo.AcctMulaidPay = gzresSeven10265Two.Output.Setlinfo.AcctMulaidPay
  23255. res.Output.Setlinfo.AcctPay = gzresSeven10265Two.Output.Setlinfo.AcctPay
  23256. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23257. res.Output.Setlinfo.ActPayDedc = gzresSeven10265Two.Output.Setlinfo.ActPayDedc
  23258. res.Output.Setlinfo.Age = gzresSeven10265Two.Output.Setlinfo.Age
  23259. res.Output.Setlinfo.Balc = gzresSeven10265Two.Output.Setlinfo.Balc
  23260. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23261. res.Output.Setlinfo.Certno = gzresSeven10265Two.Output.Setlinfo.Certno
  23262. res.Output.Setlinfo.ClrOptins = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23263. res.Output.Setlinfo.ClrType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23264. res.Output.Setlinfo.ClrWay = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23265. res.Output.Setlinfo.CvlservFlag = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23266. res.Output.Setlinfo.CvlservPay = gzresSeven10265Two.Output.Setlinfo.CvlservPay
  23267. res.Output.Setlinfo.FulamtOwnpayAmt = gzresSeven10265Two.Output.Setlinfo.FulamtOwnpayAmt
  23268. res.Output.Setlinfo.FundPaySumamt = gzresSeven10265Two.Output.Setlinfo.FundPaySumamt
  23269. res.Output.Setlinfo.Gend = gzresSeven10265Two.Output.Setlinfo.Gend
  23270. res.Output.Setlinfo.HifesPay = gzresSeven10265Two.Output.Setlinfo.HifesPay
  23271. res.Output.Setlinfo.HifmiPay = gzresSeven10265Two.Output.Setlinfo.HifmiPay
  23272. res.Output.Setlinfo.HifpPay = gzresSeven10265Two.Output.Setlinfo.HifpPay
  23273. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23274. res.Output.Setlinfo.HospPartAmt = gzresSeven10265Two.Output.Setlinfo.HospPartAmt
  23275. res.Output.Setlinfo.InscpScpAmt = gzresSeven10265Two.Output.Setlinfo.InscpScpAmt
  23276. res.Output.Setlinfo.Insutype = gzresSeven10265Two.Output.Setlinfo.Insutype
  23277. res.Output.Setlinfo.MafPay = gzresSeven10265Two.Output.Setlinfo.MafPay
  23278. res.Output.Setlinfo.MdtrtCertType = gzresSeven10265Two.Output.Setlinfo.MdtrtCertType
  23279. res.Output.Setlinfo.HifobPay = gzresSeven10265Two.Output.Setlinfo.HifobPay
  23280. res.Output.Setlinfo.MdtrtID = gzresSeven10265Two.Output.Setlinfo.MdtrtID
  23281. res.Output.Setlinfo.MedType = gzresSeven10265Two.Output.Setlinfo.MedType
  23282. res.Output.Setlinfo.MedfeeSumamt = gzresSeven10265Two.Output.Setlinfo.MedfeeSumamt
  23283. res.Output.Setlinfo.MedinsSetlID = gzresSeven10265Two.Output.Setlinfo.MedinsSetlID
  23284. res.Output.Setlinfo.Naty = gzresSeven10265Two.Output.Setlinfo.Naty
  23285. res.Output.Setlinfo.OthPay = gzresSeven10265Two.Output.Setlinfo.OthPay
  23286. res.Output.Setlinfo.OverlmtSelfpay = gzresSeven10265Two.Output.Setlinfo.OverlmtSelfpay
  23287. PoolPropSelfpay, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.PoolPropSelfpay, 64)
  23288. res.Output.Setlinfo.PoolPropSelfpay = PoolPropSelfpay
  23289. res.Output.Setlinfo.PreselfpayAmt = gzresSeven10265Two.Output.Setlinfo.PreselfpayAmt
  23290. res.Output.Setlinfo.PsnCashPay = gzresSeven10265Two.Output.Setlinfo.PsnCashPay
  23291. res.Output.Setlinfo.PsnCertType = gzresSeven10265Two.Output.Setlinfo.ClrOptins
  23292. res.Output.Setlinfo.PsnName = gzresSeven10265Two.Output.Setlinfo.PsnName
  23293. res.Output.Setlinfo.PsnNo = gzresSeven10265Two.Output.Setlinfo.PsnNo
  23294. res.Output.Setlinfo.PsnPartAmt = gzresSeven10265Two.Output.Setlinfo.PsnPartAmt
  23295. res.Output.Setlinfo.PsnType = gzresSeven10265Two.Output.Setlinfo.PsnType
  23296. res.Output.Setlinfo.SetlID = gzresSeven10265Two.Output.Setlinfo.SetlID
  23297. res.Output.Setlinfo.SetlTime = gzresSeven10265Two.Output.Setlinfo.SetlTime
  23298. //res.Output.Setldetail = gzresSeven10265Two.Output.Setldetail
  23299. res.ErrMsg = gzresSeven10265Two.ErrMsg
  23300. res.Cainfo = gzresSeven10265Two.Cainfo
  23301. res.WarnMsg = gzresSeven10265Two.WarnMsg
  23302. //infocode, _ := strconv.ParseInt(resSeven10265Two.Infcode, 10, 64)
  23303. //res.Infcode = infocode
  23304. } else {
  23305. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23306. utils.ErrorLog("解析失败:%v", err)
  23307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23308. return
  23309. }
  23310. }
  23311. }
  23312. }
  23313. }
  23314. utils.ErrorLog("解析失败:%v", res.Infcode)
  23315. if res.Infcode == -1 {
  23316. errlog := &models.HisOrderError{
  23317. UserOrgId: adminUser.CurrentOrgId,
  23318. Ctime: time.Now().Unix(),
  23319. Mtime: time.Now().Unix(),
  23320. Number: chrg_bchno,
  23321. ErrMsg: res.ErrMsg,
  23322. Status: 1,
  23323. PatientId: id,
  23324. RecordTime: recordDateTime,
  23325. Stage: 20,
  23326. }
  23327. service.CreateErrMsgLog(errlog)
  23328. c.ServeSuccessJSON(map[string]interface{}{
  23329. "failed_code": -10,
  23330. "msg": res.ErrMsg,
  23331. })
  23332. return
  23333. }
  23334. if res.Infcode != 0 {
  23335. errlog := &models.HisOrderError{
  23336. UserOrgId: adminUser.CurrentOrgId,
  23337. Ctime: time.Now().Unix(),
  23338. Mtime: time.Now().Unix(),
  23339. Number: chrg_bchno,
  23340. ErrMsg: res.ErrMsg,
  23341. Status: 1,
  23342. PatientId: id,
  23343. RecordTime: recordDateTime,
  23344. Stage: 20,
  23345. }
  23346. service.CreateErrMsgLog(errlog)
  23347. c.ServeSuccessJSON(map[string]interface{}{
  23348. "failed_code": -10,
  23349. "msg": res.ErrMsg,
  23350. })
  23351. return
  23352. } else {
  23353. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  23354. order.OrderStatus = 1
  23355. order.IsPre = 1
  23356. order.Status = 1
  23357. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  23358. order.SetlId = res.Output.Setlinfo.SetlID
  23359. order.PsnNo = res.Output.Setlinfo.PsnNo
  23360. order.PsnName = res.Output.Setlinfo.PsnName
  23361. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  23362. order.Certno = res.Output.Setlinfo.Certno
  23363. order.Gend = res.Output.Setlinfo.Gend
  23364. order.Naty = res.Output.Setlinfo.Naty
  23365. order.Age = res.Output.Setlinfo.Age
  23366. order.Insutype = res.Output.Setlinfo.Insutype
  23367. order.PsnType = res.Output.Setlinfo.PsnType
  23368. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  23369. order.SetlTime = res.Output.Setlinfo.SetlTime
  23370. order.AcctUsedFlag = acct_used_flag
  23371. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  23372. if res.Output.Setlinfo.MedType == "140101" {
  23373. order.MedType = "14"
  23374. } else {
  23375. if res.Output.Setlinfo.MedType == "110104" {
  23376. order.MedType = "11"
  23377. } else {
  23378. order.MedType = res.Output.Setlinfo.MedType
  23379. }
  23380. }
  23381. if res.Output.Setlinfo.MedType == "992102" {
  23382. order.MedType = "992102"
  23383. }
  23384. if res.Output.Setlinfo.MedType == "140104" {
  23385. order.MedType = "140104"
  23386. }
  23387. if res.Output.Setlinfo.MedType == "14" {
  23388. order.MedType = "14"
  23389. }
  23390. if reg_type == 1112 {
  23391. order.MedType = "1112"
  23392. }
  23393. if reg_type == 1111 {
  23394. order.MedType = "1111"
  23395. }
  23396. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  23397. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  23398. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  23399. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  23400. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  23401. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  23402. order.HifpPay = res.Output.Setlinfo.HifpPay
  23403. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  23404. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  23405. order.HifesPay = res.Output.Setlinfo.HifesPay
  23406. order.HifobPay = res.Output.Setlinfo.HifobPay
  23407. order.MafPay = res.Output.Setlinfo.MafPay
  23408. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  23409. order.OthPay = res.Output.Setlinfo.OthPay
  23410. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  23411. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  23412. order.AcctPay = res.Output.Setlinfo.AcctPay
  23413. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  23414. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  23415. order.Balc = res.Output.Setlinfo.Balc
  23416. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  23417. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  23418. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  23419. order.ClrWay = res.Output.Setlinfo.ClrWay
  23420. order.Creator = order.Creator
  23421. order.Modify = roles.AdminUserId
  23422. //setlDetail, _ := json.Marshal(res.Output.Setldetail)
  23423. //detailStr := string(setlDetail)
  23424. //order.SetlDetail = detailStr
  23425. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  23426. err = service.UpDateOrder(order)
  23427. if err == nil {
  23428. c.ServeSuccessJSON(map[string]interface{}{
  23429. "msg": "预结算成功",
  23430. })
  23431. } else {
  23432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  23433. return
  23434. }
  23435. }
  23436. } else {
  23437. adminUser := c.GetAdminUserInfo()
  23438. errlog := &models.HisOrderError{
  23439. UserOrgId: adminUser.CurrentOrgId,
  23440. Ctime: time.Now().Unix(),
  23441. Mtime: time.Now().Unix(),
  23442. ErrMsg: res.ErrMsg,
  23443. Status: 1,
  23444. PatientId: id,
  23445. RecordTime: recordDateTime,
  23446. Stage: 4,
  23447. }
  23448. service.CreateErrMsgLog(errlog)
  23449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  23450. return
  23451. }
  23452. } else {
  23453. if miConfig.MdtrtareaAdmvs == "150499" {
  23454. order := &models.HisOrder{
  23455. UserOrgId: adminUser.CurrentOrgId,
  23456. HisPatientId: his.ID,
  23457. PatientId: his.PatientId,
  23458. SettleAccountsDate: recordDateTime,
  23459. Ctime: time.Now().Unix(),
  23460. Mtime: time.Now().Unix(),
  23461. MdtrtId: his.Number,
  23462. PsnNo: his.PsnNo,
  23463. MedType: strconv.FormatInt(reg_type, 10),
  23464. Status: 1,
  23465. Number: chrg_bchno,
  23466. Infcode: res.Infcode,
  23467. WarnMsg: res.WarnMsg,
  23468. Cainfo: res.Cainfo,
  23469. ErrMsg: res.ErrMsg,
  23470. RespondTime: res.RefmsgTime,
  23471. InfRefmsgid: res.InfRefmsgid,
  23472. OrderStatus: 1,
  23473. IsMedicineInsurance: 1,
  23474. SettleType: settle_accounts_type,
  23475. SettleStartTime: start_time,
  23476. SettleEndTime: end_time,
  23477. Creator: roles.AdminUserId,
  23478. Modify: roles.AdminUserId,
  23479. PType: 2,
  23480. Diagnosis: diagnosis_id,
  23481. }
  23482. err = service.CreateOrder(order)
  23483. if err != nil {
  23484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  23485. return
  23486. }
  23487. }
  23488. adminUser := c.GetAdminUserInfo()
  23489. errlog := &models.HisOrderError{
  23490. UserOrgId: adminUser.CurrentOrgId,
  23491. Ctime: time.Now().Unix(),
  23492. Mtime: time.Now().Unix(),
  23493. ErrMsg: res.ErrMsg,
  23494. Status: 1,
  23495. PatientId: id,
  23496. RecordTime: recordDateTime,
  23497. Stage: 4,
  23498. }
  23499. service.CreateErrMsgLog(errlog)
  23500. c.ServeSuccessJSON(map[string]interface{}{
  23501. "failed_code": -10,
  23502. "msg": res.ErrMsg,
  23503. })
  23504. return
  23505. }
  23506. }
  23507. }
  23508. }
  23509. // 退款
  23510. func (c *HisApiController) Refund() {
  23511. order_id, _ := c.GetInt64("order_id")
  23512. admin_user_id, _ := c.GetInt64("admin_user_id")
  23513. adminUser := c.GetAdminUserInfo()
  23514. var order models.HisOrder
  23515. order, _ = service.GetHisOrderByID(order_id)
  23516. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  23517. if order.ID == 0 {
  23518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  23519. return
  23520. }
  23521. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  23522. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  23523. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  23524. if config.IsOpen == 1 { //对接了医保,走医保流程
  23525. var res ResultSixteen
  23526. var ahres ResultSevenAH
  23527. var resSixteen10265 ResultSixteen10265
  23528. var resSixteen10265Two ResultSixteen10265Two
  23529. var gz ResultgzSixteen10265Two
  23530. var src_resquest string
  23531. var result string
  23532. if miConfig.MdtrtareaAdmvs == "421300" {
  23533. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23534. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23535. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23536. resp3, requestErr3 := http.Get(api3)
  23537. if requestErr3 != nil {
  23538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23539. return
  23540. }
  23541. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23542. if ioErr3 != nil {
  23543. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23545. return
  23546. }
  23547. var respJSON3 map[string]interface{}
  23548. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23549. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23551. return
  23552. }
  23553. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23554. userJSONBytes3, _ := json.Marshal(respJSON3)
  23555. fmt.Println("log")
  23556. fmt.Println(string(userJSONBytes3))
  23557. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23558. utils.ErrorLog("解析失败:%v", err)
  23559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23560. return
  23561. }
  23562. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23563. api3 := "http://192.168.0.197:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  23564. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23565. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23566. resp3, requestErr3 := http.Get(api3)
  23567. if requestErr3 != nil {
  23568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23569. return
  23570. }
  23571. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23572. if ioErr3 != nil {
  23573. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23575. return
  23576. }
  23577. var respJSON3 map[string]interface{}
  23578. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23579. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23581. return
  23582. }
  23583. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23584. userJSONBytes3, _ := json.Marshal(respJSON3)
  23585. fmt.Println("log")
  23586. fmt.Println(string(userJSONBytes3))
  23587. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23588. utils.ErrorLog("解析失败:%v", err)
  23589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23590. return
  23591. }
  23592. } else if miConfig.MdtrtareaAdmvs == "420902" {
  23593. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23594. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23595. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23596. resp3, requestErr3 := http.Get(api3)
  23597. if requestErr3 != nil {
  23598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23599. return
  23600. }
  23601. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23602. if ioErr3 != nil {
  23603. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23605. return
  23606. }
  23607. var respJSON3 map[string]interface{}
  23608. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23609. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23611. return
  23612. }
  23613. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23614. userJSONBytes3, _ := json.Marshal(respJSON3)
  23615. fmt.Println("log")
  23616. fmt.Println(string(userJSONBytes3))
  23617. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23618. utils.ErrorLog("解析失败:%v", err)
  23619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23620. return
  23621. }
  23622. } else if miConfig.MdtrtareaAdmvs == "421182" {
  23623. api3 := miConfig.Url + "hbyb/2208?psn_no=" + order.PsnNo +
  23624. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23625. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23626. resp3, requestErr3 := http.Get(api3)
  23627. if requestErr3 != nil {
  23628. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23629. return
  23630. }
  23631. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23632. if ioErr3 != nil {
  23633. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23635. return
  23636. }
  23637. var respJSON3 map[string]interface{}
  23638. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23639. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23641. return
  23642. }
  23643. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23644. userJSONBytes3, _ := json.Marshal(respJSON3)
  23645. fmt.Println("log")
  23646. fmt.Println(string(userJSONBytes3))
  23647. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23648. utils.ErrorLog("解析失败:%v", err)
  23649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23650. return
  23651. }
  23652. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  23653. var api3 string
  23654. if miConfig.MdtrtareaAdmvs == "320921" {
  23655. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23656. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23657. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23658. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23659. } else {
  23660. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  23661. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  23662. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23663. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23664. }
  23665. resp3, requestErr3 := http.Get(api3)
  23666. if requestErr3 != nil {
  23667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23668. return
  23669. }
  23670. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23671. if ioErr3 != nil {
  23672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23674. return
  23675. }
  23676. var respJSON3 map[string]interface{}
  23677. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23680. return
  23681. }
  23682. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23683. userJSONBytes3, _ := json.Marshal(respJSON3)
  23684. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23685. utils.ErrorLog("解析失败:%v", err)
  23686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23687. return
  23688. }
  23689. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23690. res.Output = resSixteen10265.Output
  23691. res.ErrMsg = resSixteen10265.ErrMsg
  23692. res.Cainfo = resSixteen10265.Cainfo
  23693. res.WarnMsg = resSixteen10265.WarnMsg
  23694. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23695. res.Infcode = infocode
  23696. } else if miConfig.MdtrtareaAdmvs == "150499" {
  23697. var api3 string
  23698. api3 = "http://172.16.13.254:9532/" + "nmyb/2208?psn_no=" + order.PsnNo +
  23699. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23700. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23701. resp3, requestErr3 := http.Get(api3)
  23702. if requestErr3 != nil {
  23703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23704. return
  23705. }
  23706. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23707. if ioErr3 != nil {
  23708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23710. return
  23711. }
  23712. var respJSON3 map[string]interface{}
  23713. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23716. return
  23717. }
  23718. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23719. userJSONBytes3, _ := json.Marshal(respJSON3)
  23720. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265Two); err != nil {
  23721. utils.ErrorLog("解析失败:%v", err)
  23722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23723. return
  23724. }
  23725. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23726. res.Output = resSixteen10265.Output
  23727. res.ErrMsg = resSixteen10265.ErrMsg
  23728. res.Cainfo = resSixteen10265.Cainfo
  23729. res.WarnMsg = resSixteen10265.WarnMsg
  23730. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23731. res.Infcode = infocode
  23732. } else if miConfig.MdtrtareaAdmvs == "350500" {
  23733. 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)
  23734. var dat map[string]interface{}
  23735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23736. fmt.Println(dat)
  23737. } else {
  23738. fmt.Println(err)
  23739. }
  23740. saveLog(result, src_resquest, "2208", "退费")
  23741. userJSONBytes, _ := json.Marshal(dat)
  23742. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23743. utils.ErrorLog("解析失败:%v", err)
  23744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23745. return
  23746. }
  23747. } else if miConfig.MdtrtareaAdmvs == "360302" {
  23748. 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, "")
  23749. var dat map[string]interface{}
  23750. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23751. fmt.Println(dat)
  23752. } else {
  23753. fmt.Println(err)
  23754. }
  23755. saveLog(result, src_resquest, "2208", "退费")
  23756. userJSONBytes, _ := json.Marshal(dat)
  23757. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23758. utils.ErrorLog("解析失败:%v", err)
  23759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23760. return
  23761. }
  23762. } else if miConfig.MdtrtareaAdmvs == "341203" {
  23763. var api3 string
  23764. api3 = miConfig.SecretKey + "ahyb/2208?psn_no=" + order.PsnNo +
  23765. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  23767. resp3, requestErr3 := http.Get(api3)
  23768. if requestErr3 != nil {
  23769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23770. return
  23771. }
  23772. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23773. if ioErr3 != nil {
  23774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23776. return
  23777. }
  23778. var respJSON3 map[string]interface{}
  23779. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23782. return
  23783. }
  23784. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  23785. if status == "0" {
  23786. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  23787. c.ServeSuccessJSON(map[string]interface{}{
  23788. "failed_code": -10,
  23789. "msg": err_msg,
  23790. })
  23791. return
  23792. }
  23793. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23794. userJSONBytes3, _ := json.Marshal(respJSON3)
  23795. //if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23796. // utils.ErrorLog("解析失败:%v", err)
  23797. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23798. // return
  23799. //}
  23800. if err := json.Unmarshal(userJSONBytes3, &ahres); err != nil {
  23801. utils.ErrorLog("解析失败:%v", err)
  23802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23803. return
  23804. }
  23805. res.InfRefmsgid = ahres.InfRefmsgid
  23806. timestamp := int64(ahres.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  23807. // 创建对应的Time类型
  23808. t := time.UnixMilli(timestamp)
  23809. // 格式化成指定的日期字符串
  23810. str := t.Format("2006-01-02 15:04:05")
  23811. res.Output.Setlinfo.SetlTime = str
  23812. res.Output.Setlinfo.AcctMulaidPay = ahres.Output.Setlinfo.AcctMulaidPay
  23813. res.Output.Setlinfo.AcctPay = ahres.Output.Setlinfo.AcctPay
  23814. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23815. res.Output.Setlinfo.ActPayDedc = ahres.Output.Setlinfo.ActPayDedc
  23816. //res.Output.Setlinfo.Age = ahres.Output.Setlinfo.Age
  23817. res.Output.Setlinfo.Balc = ahres.Output.Setlinfo.Balc
  23818. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  23819. //res.Output.Setlinfo.Certno = ahres.Output.Setlinfo.Certno
  23820. res.Output.Setlinfo.ClrOptins = ahres.Output.Setlinfo.ClrOptins
  23821. //
  23822. //res.Output.Setlinfo.ClrType = ahres.Output.Setlinfo.ClrOptins
  23823. //res.Output.Setlinfo.ClrWay = ahres.Output.Setlinfo.ClrOptins
  23824. //res.Output.Setlinfo.CvlservFlag = ahres.Output.Setlinfo.ClrOptins
  23825. res.Output.Setlinfo.CvlservPay = ahres.Output.Setlinfo.CvlservPay
  23826. res.Output.Setlinfo.FulamtOwnpayAmt = ahres.Output.Setlinfo.FulamtOwnpayAmt
  23827. res.Output.Setlinfo.FundPaySumamt = ahres.Output.Setlinfo.FundPaySumamt
  23828. //res.Output.Setlinfo.Gend = ahres.Output.Setlinfo.Gend
  23829. res.Output.Setlinfo.HifesPay = ahres.Output.Setlinfo.HifesPay
  23830. res.Output.Setlinfo.HifmiPay = ahres.Output.Setlinfo.HifmiPay
  23831. res.Output.Setlinfo.HifpPay = ahres.Output.Setlinfo.HifpPay
  23832. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  23833. res.Output.Setlinfo.HospPartAmt = ahres.Output.Setlinfo.HospPartAmt
  23834. res.Output.Setlinfo.InscpScpAmt = ahres.Output.Setlinfo.InscpScpAmt
  23835. //res.Output.Setlinfo.Insutype = ahres.Output.Setlinfo.Insutype
  23836. res.Output.Setlinfo.MafPay = ahres.Output.Setlinfo.MafPay
  23837. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  23838. res.Output.Setlinfo.HifobPay = ahres.Output.Setlinfo.HifobPay
  23839. res.Output.Setlinfo.MdtrtID = ahres.Output.Setlinfo.MdtrtID
  23840. //res.Output.Setlinfo.MedType = ahres.Output.Setlinfo.MedType
  23841. res.Output.Setlinfo.MedfeeSumamt = ahres.Output.Setlinfo.MedfeeSumamt
  23842. res.Output.Setlinfo.MedinsSetlID = ahres.Output.Setlinfo.MedinsSetlID
  23843. //res.Output.Setlinfo.Naty = ahres.Output.Setlinfo.Naty
  23844. res.Output.Setlinfo.OthPay = ahres.Output.Setlinfo.OthPay
  23845. res.Output.Setlinfo.OverlmtSelfpay = ahres.Output.Setlinfo.OverlmtSelfpay
  23846. res.Output.Setlinfo.PreselfpayAmt = ahres.Output.Setlinfo.PreselfpayAmt
  23847. res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  23848. res.Output.Setlinfo.SetlID = ahres.Output.Setlinfo.SetlID
  23849. //res.Output.Setldetail = ahres.Output.Setldetail
  23850. res.ErrMsg = ahres.ErrMsg
  23851. res.Cainfo = ahres.Cainfo
  23852. res.WarnMsg = ahres.WarnMsg
  23853. res.Infcode = ahres.Infcode
  23854. } else if miConfig.MdtrtareaAdmvs == "430800" {
  23855. 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, "")
  23856. var dat map[string]interface{}
  23857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23858. fmt.Println(dat)
  23859. } else {
  23860. fmt.Println(err)
  23861. }
  23862. saveLog(result, src_resquest, "2208", "退费")
  23863. userJSONBytes, _ := json.Marshal(dat)
  23864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23865. utils.ErrorLog("解析失败:%v", err)
  23866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23867. return
  23868. }
  23869. } else if miConfig.MdtrtareaAdmvs == "441799" {
  23870. api3 := miConfig.Url + "gdyb/2208?psn_no=" + order.PsnNo +
  23871. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23872. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23873. resp3, requestErr3 := http.Get(api3)
  23874. if requestErr3 != nil {
  23875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23876. return
  23877. }
  23878. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23879. if ioErr3 != nil {
  23880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23882. return
  23883. }
  23884. var respJSON3 map[string]interface{}
  23885. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23888. return
  23889. }
  23890. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23891. userJSONBytes3, _ := json.Marshal(respJSON3)
  23892. fmt.Println("log")
  23893. fmt.Println(string(userJSONBytes3))
  23894. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  23895. utils.ErrorLog("解析失败:%v", err)
  23896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23897. return
  23898. }
  23899. } else {
  23900. if miConfig.Code == "H15049901371" {
  23901. 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)
  23902. var dat map[string]interface{}
  23903. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23904. fmt.Println(dat)
  23905. } else {
  23906. fmt.Println(err)
  23907. }
  23908. saveLog(result, src_resquest, "2208", "退费")
  23909. userJSONBytes, _ := json.Marshal(dat)
  23910. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  23911. utils.ErrorLog("解析失败:%v", err)
  23912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23913. return
  23914. }
  23915. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  23916. res.Output = resSixteen10265.Output
  23917. res.ErrMsg = resSixteen10265.ErrMsg
  23918. res.Cainfo = resSixteen10265.Cainfo
  23919. res.WarnMsg = resSixteen10265.WarnMsg
  23920. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  23921. res.Infcode = infocode
  23922. } else {
  23923. 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)
  23924. var dat map[string]interface{}
  23925. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  23926. fmt.Println(dat)
  23927. } else {
  23928. fmt.Println(err)
  23929. }
  23930. saveLog(result, src_resquest, "2208", "退费")
  23931. userJSONBytes, _ := json.Marshal(dat)
  23932. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  23933. if err := json.Unmarshal(userJSONBytes, &gz); err != nil {
  23934. utils.ErrorLog("解析失败:%v", err)
  23935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23936. return
  23937. }
  23938. res.Infcode = gz.Infcode
  23939. } else {
  23940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  23941. utils.ErrorLog("解析失败:%v", err)
  23942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23943. return
  23944. }
  23945. }
  23946. }
  23947. }
  23948. if res.Infcode == 0 {
  23949. var res2 ResultSix
  23950. var resSix10265 ResultSix10265
  23951. if miConfig.MdtrtareaAdmvs == "421300" {
  23952. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23953. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23954. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23955. resp3, requestErr3 := http.Get(api3)
  23956. if requestErr3 != nil {
  23957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23958. return
  23959. }
  23960. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23961. if ioErr3 != nil {
  23962. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23964. return
  23965. }
  23966. var respJSON3 map[string]interface{}
  23967. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23970. return
  23971. }
  23972. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  23973. userJSONBytes3, _ := json.Marshal(respJSON3)
  23974. fmt.Println("log")
  23975. fmt.Println(string(userJSONBytes3))
  23976. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  23977. utils.ErrorLog("解析失败:%v", err)
  23978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23979. return
  23980. }
  23981. } else if miConfig.MdtrtareaAdmvs == "420200" {
  23982. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  23983. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  23984. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  23985. resp3, requestErr3 := http.Get(api3)
  23986. if requestErr3 != nil {
  23987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23988. return
  23989. }
  23990. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  23991. if ioErr3 != nil {
  23992. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  23993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  23994. return
  23995. }
  23996. var respJSON3 map[string]interface{}
  23997. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  23998. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  23999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24000. return
  24001. }
  24002. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24003. userJSONBytes3, _ := json.Marshal(respJSON3)
  24004. fmt.Println("log")
  24005. fmt.Println(string(userJSONBytes3))
  24006. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24007. utils.ErrorLog("解析失败:%v", err)
  24008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24009. return
  24010. }
  24011. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24012. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24013. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24014. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24015. resp3, requestErr3 := http.Get(api3)
  24016. if requestErr3 != nil {
  24017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24018. return
  24019. }
  24020. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24021. if ioErr3 != nil {
  24022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24024. return
  24025. }
  24026. var respJSON3 map[string]interface{}
  24027. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24030. return
  24031. }
  24032. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24033. userJSONBytes3, _ := json.Marshal(respJSON3)
  24034. fmt.Println("log")
  24035. fmt.Println(string(userJSONBytes3))
  24036. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24037. utils.ErrorLog("解析失败:%v", err)
  24038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24039. return
  24040. }
  24041. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24042. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24043. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24044. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24045. resp3, requestErr3 := http.Get(api3)
  24046. if requestErr3 != nil {
  24047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24048. return
  24049. }
  24050. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24051. if ioErr3 != nil {
  24052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24054. return
  24055. }
  24056. var respJSON3 map[string]interface{}
  24057. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24060. return
  24061. }
  24062. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24063. userJSONBytes3, _ := json.Marshal(respJSON3)
  24064. fmt.Println("log")
  24065. fmt.Println(string(userJSONBytes3))
  24066. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24067. utils.ErrorLog("解析失败:%v", err)
  24068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24069. return
  24070. }
  24071. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24072. var api3 string
  24073. if miConfig.MdtrtareaAdmvs == "320921" {
  24074. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24075. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24077. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24078. } else {
  24079. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24080. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24081. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24083. }
  24084. resp3, requestErr3 := http.Get(api3)
  24085. if requestErr3 != nil {
  24086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24087. return
  24088. }
  24089. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24090. if ioErr3 != nil {
  24091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24093. return
  24094. }
  24095. var respJSON3 map[string]interface{}
  24096. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24099. return
  24100. }
  24101. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24102. userJSONBytes3, _ := json.Marshal(respJSON3)
  24103. fmt.Println("log")
  24104. fmt.Println(string(userJSONBytes3))
  24105. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24106. utils.ErrorLog("解析失败:%v", err)
  24107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24108. return
  24109. }
  24110. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24111. res2.Output = resSix10265.Output
  24112. res2.ErrMsg = resSix10265.ErrMsg
  24113. res2.Cainfo = resSix10265.Cainfo
  24114. res2.WarnMsg = resSix10265.WarnMsg
  24115. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24116. res2.Infcode = infocode
  24117. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24118. var api3 string
  24119. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  24120. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24121. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24122. resp3, requestErr3 := http.Get(api3)
  24123. if requestErr3 != nil {
  24124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24125. return
  24126. }
  24127. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24128. if ioErr3 != nil {
  24129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24131. return
  24132. }
  24133. var respJSON3 map[string]interface{}
  24134. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24137. return
  24138. }
  24139. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24140. userJSONBytes3, _ := json.Marshal(respJSON3)
  24141. fmt.Println("log")
  24142. fmt.Println(string(userJSONBytes3))
  24143. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24144. utils.ErrorLog("解析失败:%v", err)
  24145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24146. return
  24147. }
  24148. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24149. res2.Output = resSix10265.Output
  24150. res2.ErrMsg = resSix10265.ErrMsg
  24151. res2.Cainfo = resSix10265.Cainfo
  24152. res2.WarnMsg = resSix10265.WarnMsg
  24153. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24154. res2.Infcode = infocode
  24155. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24156. 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)
  24157. var dat map[string]interface{}
  24158. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24159. fmt.Println(dat)
  24160. } else {
  24161. fmt.Println(err)
  24162. }
  24163. saveLog(result2, src_request, "2205", "撤销明细")
  24164. userJSONBytes, _ := json.Marshal(dat)
  24165. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24166. utils.ErrorLog("解析失败:%v", err)
  24167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24168. return
  24169. }
  24170. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24171. 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, "")
  24172. var dat map[string]interface{}
  24173. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24174. fmt.Println(dat)
  24175. } else {
  24176. fmt.Println(err)
  24177. }
  24178. saveLog(result2, src_request, "2205", "撤销明细")
  24179. userJSONBytes, _ := json.Marshal(dat)
  24180. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24181. utils.ErrorLog("解析失败:%v", err)
  24182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24183. return
  24184. }
  24185. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24186. var api3 string
  24187. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  24188. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24189. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24190. resp3, requestErr3 := http.Get(api3)
  24191. if requestErr3 != nil {
  24192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24193. return
  24194. }
  24195. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24196. if ioErr3 != nil {
  24197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24199. return
  24200. }
  24201. var respJSON3 map[string]interface{}
  24202. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24205. return
  24206. }
  24207. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24208. if status == "0" {
  24209. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24210. c.ServeSuccessJSON(map[string]interface{}{
  24211. "failed_code": -10,
  24212. "msg": err_msg,
  24213. })
  24214. return
  24215. }
  24216. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24217. userJSONBytes3, _ := json.Marshal(respJSON3)
  24218. fmt.Println("log")
  24219. fmt.Println(string(userJSONBytes3))
  24220. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24221. utils.ErrorLog("解析失败:%v", err)
  24222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24223. return
  24224. }
  24225. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24226. 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, "")
  24227. var dat map[string]interface{}
  24228. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24229. fmt.Println(dat)
  24230. } else {
  24231. fmt.Println(err)
  24232. }
  24233. saveLog(result2, src_request, "2205", "撤销明细")
  24234. userJSONBytes, _ := json.Marshal(dat)
  24235. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24236. utils.ErrorLog("解析失败:%v", err)
  24237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24238. return
  24239. }
  24240. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24241. api3 := miConfig.Url + "gdyb/six?psn_no=" + order.PsnNo +
  24242. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24243. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24244. resp3, requestErr3 := http.Get(api3)
  24245. if requestErr3 != nil {
  24246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24247. return
  24248. }
  24249. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24250. if ioErr3 != nil {
  24251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24253. return
  24254. }
  24255. var respJSON3 map[string]interface{}
  24256. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24259. return
  24260. }
  24261. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24262. userJSONBytes3, _ := json.Marshal(respJSON3)
  24263. fmt.Println("log")
  24264. fmt.Println(string(userJSONBytes3))
  24265. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24266. utils.ErrorLog("解析失败:%v", err)
  24267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24268. return
  24269. }
  24270. } else {
  24271. if miConfig.Code == "H15049901371" {
  24272. 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)
  24273. var dat map[string]interface{}
  24274. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24275. fmt.Println(dat)
  24276. } else {
  24277. fmt.Println(err)
  24278. }
  24279. saveLog(result2, src_request, "2205", "撤销明细")
  24280. userJSONBytes, _ := json.Marshal(dat)
  24281. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  24282. utils.ErrorLog("解析失败:%v", err)
  24283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24284. return
  24285. }
  24286. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24287. res2.Output = resSix10265.Output
  24288. res2.ErrMsg = resSix10265.ErrMsg
  24289. res2.Cainfo = resSix10265.Cainfo
  24290. res2.WarnMsg = resSix10265.WarnMsg
  24291. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24292. res2.Infcode = infocode
  24293. } else {
  24294. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24295. res2.Infcode = 0
  24296. } else {
  24297. 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)
  24298. var dat map[string]interface{}
  24299. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  24300. fmt.Println(dat)
  24301. } else {
  24302. fmt.Println(err)
  24303. }
  24304. saveLog(result2, src_request, "2205", "撤销明细")
  24305. userJSONBytes, _ := json.Marshal(dat)
  24306. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24307. utils.ErrorLog("解析失败:%v", err)
  24308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24309. return
  24310. }
  24311. }
  24312. }
  24313. }
  24314. if res2.Infcode == -1 {
  24315. c.ServeSuccessJSON(map[string]interface{}{
  24316. "failed_code": -10,
  24317. "msg": res2.ErrMsg,
  24318. })
  24319. return
  24320. }
  24321. if res2.Infcode == 0 {
  24322. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  24323. if err == nil {
  24324. //当押金不为零时产生退费记录
  24325. if order.Decimal != 0 {
  24326. tmp := strconv.FormatInt(order.ID, 10)
  24327. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  24328. if err != nil {
  24329. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24330. return
  24331. }
  24332. }
  24333. c.ServeSuccessJSON(map[string]interface{}{
  24334. "msg": "退费成功",
  24335. })
  24336. } else {
  24337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24338. return
  24339. }
  24340. } else {
  24341. c.ServeSuccessJSON(map[string]interface{}{
  24342. "failed_code": -10,
  24343. "msg": res2.ErrMsg,
  24344. })
  24345. }
  24346. } else {
  24347. c.ServeSuccessJSON(map[string]interface{}{
  24348. "failed_code": -10,
  24349. "msg": res.ErrMsg,
  24350. })
  24351. }
  24352. }
  24353. }
  24354. func (c *HisApiController) RefundNumber() {
  24355. record_time := c.GetString("record_time")
  24356. //patient_id, _ := c.GetInt64("patient_id")
  24357. admin_user_id, _ := c.GetInt64("admin_user_id")
  24358. his_patient_id, _ := c.GetInt64("id")
  24359. timeLayout := "2006-01-02"
  24360. loc, _ := time.LoadLocation("Local")
  24361. adminUser := c.GetAdminUserInfo()
  24362. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24363. fmt.Println(err)
  24364. if err != nil {
  24365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24366. return
  24367. }
  24368. recordDateTime := theTime.Unix()
  24369. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24370. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  24371. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24372. //order, _ := service.GetHisOrderByID(order_id)
  24373. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24374. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24375. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24376. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  24377. if count > 0 {
  24378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  24379. return
  24380. }
  24381. if config.IsOpen == 1 { //对接了医保,走医保流程
  24382. var res2 ResultSix
  24383. var res3 GZResultSix
  24384. var resSix10265 ResultSix10265
  24385. if miConfig.MdtrtareaAdmvs == "421300" {
  24386. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24387. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24388. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24389. resp3, requestErr3 := http.Get(api3)
  24390. if requestErr3 != nil {
  24391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24392. return
  24393. }
  24394. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24395. if ioErr3 != nil {
  24396. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24398. return
  24399. }
  24400. var respJSON3 map[string]interface{}
  24401. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24402. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24404. return
  24405. }
  24406. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24407. userJSONBytes3, _ := json.Marshal(respJSON3)
  24408. fmt.Println("log")
  24409. fmt.Println(string(userJSONBytes3))
  24410. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24411. utils.ErrorLog("解析失败:%v", err)
  24412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24413. return
  24414. }
  24415. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24416. api3 := "http://192.168.0.197:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  24417. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24419. resp3, requestErr3 := http.Get(api3)
  24420. if requestErr3 != nil {
  24421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24422. return
  24423. }
  24424. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24425. if ioErr3 != nil {
  24426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24428. return
  24429. }
  24430. var respJSON3 map[string]interface{}
  24431. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24434. return
  24435. }
  24436. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24437. userJSONBytes3, _ := json.Marshal(respJSON3)
  24438. fmt.Println("log")
  24439. fmt.Println(string(userJSONBytes3))
  24440. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24441. utils.ErrorLog("解析失败:%v", err)
  24442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24443. return
  24444. }
  24445. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24446. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24447. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24448. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24449. resp3, requestErr3 := http.Get(api3)
  24450. if requestErr3 != nil {
  24451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24452. return
  24453. }
  24454. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24455. if ioErr3 != nil {
  24456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24458. return
  24459. }
  24460. var respJSON3 map[string]interface{}
  24461. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24464. return
  24465. }
  24466. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24467. userJSONBytes3, _ := json.Marshal(respJSON3)
  24468. fmt.Println("log")
  24469. fmt.Println(string(userJSONBytes3))
  24470. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24471. utils.ErrorLog("解析失败:%v", err)
  24472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24473. return
  24474. }
  24475. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24476. api3 := miConfig.Url + "hbyb/2202?psn_no=" + his.PsnNo +
  24477. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24478. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24479. resp3, requestErr3 := http.Get(api3)
  24480. if requestErr3 != nil {
  24481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24482. return
  24483. }
  24484. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24485. if ioErr3 != nil {
  24486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24488. return
  24489. }
  24490. var respJSON3 map[string]interface{}
  24491. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24494. return
  24495. }
  24496. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24497. userJSONBytes3, _ := json.Marshal(respJSON3)
  24498. fmt.Println("log")
  24499. fmt.Println(string(userJSONBytes3))
  24500. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24501. utils.ErrorLog("解析失败:%v", err)
  24502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24503. return
  24504. }
  24505. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24506. var api3 string
  24507. if miConfig.MdtrtareaAdmvs == "320921" {
  24508. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24509. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24510. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24511. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24512. } else {
  24513. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24514. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  24515. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24516. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24517. }
  24518. resp3, requestErr3 := http.Get(api3)
  24519. if requestErr3 != nil {
  24520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24521. return
  24522. }
  24523. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24524. if ioErr3 != nil {
  24525. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24527. return
  24528. }
  24529. var respJSON3 map[string]interface{}
  24530. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24531. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24533. return
  24534. }
  24535. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24536. userJSONBytes3, _ := json.Marshal(respJSON3)
  24537. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24538. utils.ErrorLog("解析失败:%v", err)
  24539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24540. return
  24541. }
  24542. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24543. res2.Output = resSix10265.Output
  24544. res2.ErrMsg = resSix10265.ErrMsg
  24545. res2.Cainfo = resSix10265.Cainfo
  24546. res2.WarnMsg = resSix10265.WarnMsg
  24547. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24548. res2.Infcode = infocode
  24549. } else if miConfig.MdtrtareaAdmvs == "150499" {
  24550. var api3 string
  24551. api3 = "http://172.16.13.254:9532/" + "nmyb/2202?psn_no=" + his.PsnNo +
  24552. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24554. resp3, requestErr3 := http.Get(api3)
  24555. if requestErr3 != nil {
  24556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24557. return
  24558. }
  24559. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24560. if ioErr3 != nil {
  24561. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24563. return
  24564. }
  24565. var respJSON3 map[string]interface{}
  24566. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24569. return
  24570. }
  24571. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24572. userJSONBytes3, _ := json.Marshal(respJSON3)
  24573. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24574. utils.ErrorLog("解析失败:%v", err)
  24575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24576. return
  24577. }
  24578. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24579. res2.Output = resSix10265.Output
  24580. res2.ErrMsg = resSix10265.ErrMsg
  24581. res2.Cainfo = resSix10265.Cainfo
  24582. res2.WarnMsg = resSix10265.WarnMsg
  24583. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24584. res2.Infcode = infocode
  24585. } else if miConfig.MdtrtareaAdmvs == "350500" {
  24586. 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)
  24587. var dat map[string]interface{}
  24588. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24589. fmt.Println(dat)
  24590. } else {
  24591. fmt.Println(err)
  24592. }
  24593. saveLog(result, request, "2202", "退号")
  24594. userJSONBytes, _ := json.Marshal(dat)
  24595. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24596. utils.ErrorLog("解析失败:%v", err)
  24597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24598. return
  24599. }
  24600. } else if miConfig.MdtrtareaAdmvs == "360302" {
  24601. 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, "")
  24602. var dat map[string]interface{}
  24603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24604. fmt.Println(dat)
  24605. } else {
  24606. fmt.Println(err)
  24607. }
  24608. saveLog(result, request, "2202", "退号")
  24609. userJSONBytes, _ := json.Marshal(dat)
  24610. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24611. utils.ErrorLog("解析失败:%v", err)
  24612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24613. return
  24614. }
  24615. } else if miConfig.MdtrtareaAdmvs == "341203" {
  24616. var api3 string
  24617. api3 = miConfig.SecretKey + "ahyb/2202?psn_no=" + his.PsnNo +
  24618. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24619. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24620. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24621. resp3, requestErr3 := http.Get(api3)
  24622. if requestErr3 != nil {
  24623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24624. return
  24625. }
  24626. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24627. if ioErr3 != nil {
  24628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24630. return
  24631. }
  24632. var respJSON3 map[string]interface{}
  24633. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24636. return
  24637. }
  24638. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  24639. if status == "0" {
  24640. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  24641. c.ServeSuccessJSON(map[string]interface{}{
  24642. "failed_code": -10,
  24643. "msg": err_msg,
  24644. })
  24645. return
  24646. }
  24647. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24648. userJSONBytes3, _ := json.Marshal(respJSON3)
  24649. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24650. utils.ErrorLog("解析失败:%v", err)
  24651. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24652. return
  24653. }
  24654. utils.ErrorLog("接口返回数据解析JSON失败: %v", res2.Infcode)
  24655. } else if miConfig.MdtrtareaAdmvs == "430800" {
  24656. 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, "")
  24657. var dat map[string]interface{}
  24658. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  24659. fmt.Println(dat)
  24660. } else {
  24661. fmt.Println(err)
  24662. }
  24663. saveLog(result, request, "2202", "退号")
  24664. userJSONBytes, _ := json.Marshal(dat)
  24665. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  24666. utils.ErrorLog("解析失败:%v", err)
  24667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24668. return
  24669. }
  24670. } else if miConfig.MdtrtareaAdmvs == "441799" {
  24671. api3 := miConfig.Url + "gdyb/2202?psn_no=" + his.PsnNo +
  24672. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24673. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24674. resp3, requestErr3 := http.Get(api3)
  24675. if requestErr3 != nil {
  24676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24677. return
  24678. }
  24679. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24680. if ioErr3 != nil {
  24681. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24683. return
  24684. }
  24685. var respJSON3 map[string]interface{}
  24686. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24687. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24689. return
  24690. }
  24691. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24692. userJSONBytes3, _ := json.Marshal(respJSON3)
  24693. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24694. utils.ErrorLog("解析失败:%v", err)
  24695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24696. return
  24697. }
  24698. } else {
  24699. var api3 string
  24700. if miConfig.Code == "H15049901371" {
  24701. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  24702. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24703. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24704. } else {
  24705. api3 = "http://127.0.0.1:9532/" + "gdyb/2202?psn_no=" + his.PsnNo +
  24706. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&operator=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24707. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  24708. }
  24709. resp3, requestErr3 := http.Get(api3)
  24710. if requestErr3 != nil {
  24711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24712. return
  24713. }
  24714. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24715. if ioErr3 != nil {
  24716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24718. return
  24719. }
  24720. var respJSON3 map[string]interface{}
  24721. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24724. return
  24725. }
  24726. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24727. userJSONBytes3, _ := json.Marshal(respJSON3)
  24728. if miConfig.Code == "H15049901371" {
  24729. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  24730. utils.ErrorLog("解析失败:%v", err)
  24731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24732. return
  24733. }
  24734. res2.InfRefmsgid = resSix10265.InfRefmsgid
  24735. res2.Output = resSix10265.Output
  24736. res2.ErrMsg = resSix10265.ErrMsg
  24737. res2.Cainfo = resSix10265.Cainfo
  24738. res2.WarnMsg = resSix10265.WarnMsg
  24739. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  24740. res2.Infcode = infocode
  24741. } else {
  24742. if strings.Contains(his.InsuplcAdmdvs, "4401") {
  24743. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  24744. utils.ErrorLog("解析失败:%v", err)
  24745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24746. return
  24747. }
  24748. res2.Infcode = res3.Infcode
  24749. } else {
  24750. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24751. utils.ErrorLog("解析失败:%v", err)
  24752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24753. return
  24754. }
  24755. }
  24756. }
  24757. }
  24758. if res2.Infcode == -1 {
  24759. utils.ErrorLog("解析失败:%v", res2.Infcode)
  24760. c.ServeSuccessJSON(map[string]interface{}{
  24761. "failed_code": -10,
  24762. "msg": res2.ErrMsg,
  24763. })
  24764. return
  24765. }
  24766. if res2.Infcode == 0 {
  24767. if err == nil {
  24768. c.ServeSuccessJSON(map[string]interface{}{
  24769. "msg": "退号成功",
  24770. })
  24771. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  24772. } else {
  24773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24774. return
  24775. }
  24776. }
  24777. } else {
  24778. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  24779. //if err == nil {
  24780. // c.ServeSuccessJSON(map[string]interface{}{
  24781. // "msg": "退费成功",
  24782. // })
  24783. //} else {
  24784. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24785. // return
  24786. //}
  24787. }
  24788. }
  24789. func (c *HisApiController) RefundDetail() {
  24790. order_id, _ := c.GetInt64("order_id")
  24791. admin_user_id, _ := c.GetInt64("admin_user_id")
  24792. //his_patient_id, _ := c.GetInt64("his_patient_id")
  24793. number := c.GetString("number")
  24794. record_time := c.GetString("record_time")
  24795. patient_id, _ := c.GetInt64("patient_id")
  24796. //med_type, _ := c.GetInt64("med_type")
  24797. timeLayout := "2006-01-02"
  24798. loc, _ := time.LoadLocation("Local")
  24799. adminUser := c.GetAdminUserInfo()
  24800. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  24801. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  24802. fmt.Println(err)
  24803. if err != nil {
  24804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  24805. return
  24806. }
  24807. recordDateTime := theTime.Unix()
  24808. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  24809. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  24810. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  24811. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  24812. var order models.HisOrder
  24813. order, _ = service.GetHisOrderByID(order_id)
  24814. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  24815. if config.IsOpen == 1 { //对接了医保,走医保流程
  24816. var res2 ResultSix
  24817. if miConfig.MdtrtareaAdmvs == "421300" {
  24818. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24819. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24820. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24821. resp3, requestErr3 := http.Get(api3)
  24822. if requestErr3 != nil {
  24823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24824. return
  24825. }
  24826. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24827. if ioErr3 != nil {
  24828. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24830. return
  24831. }
  24832. var respJSON3 map[string]interface{}
  24833. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24834. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24836. return
  24837. }
  24838. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24839. userJSONBytes3, _ := json.Marshal(respJSON3)
  24840. fmt.Println("log")
  24841. fmt.Println(string(userJSONBytes3))
  24842. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24843. utils.ErrorLog("解析失败:%v", err)
  24844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24845. return
  24846. }
  24847. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24848. if err == nil {
  24849. c.ServeSuccessJSON(map[string]interface{}{
  24850. "msg": "撤销明细成功",
  24851. })
  24852. return
  24853. } else {
  24854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24855. return
  24856. }
  24857. } else if miConfig.MdtrtareaAdmvs == "420200" {
  24858. api3 := "http://192.168.0.197:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  24859. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24860. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24861. resp3, requestErr3 := http.Get(api3)
  24862. if requestErr3 != nil {
  24863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24864. return
  24865. }
  24866. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24867. if ioErr3 != nil {
  24868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24870. return
  24871. }
  24872. var respJSON3 map[string]interface{}
  24873. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24876. return
  24877. }
  24878. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24879. userJSONBytes3, _ := json.Marshal(respJSON3)
  24880. fmt.Println("log")
  24881. fmt.Println(string(userJSONBytes3))
  24882. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24883. utils.ErrorLog("解析失败:%v", err)
  24884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24885. return
  24886. }
  24887. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24888. if err == nil {
  24889. c.ServeSuccessJSON(map[string]interface{}{
  24890. "msg": "撤销明细成功",
  24891. })
  24892. return
  24893. } else {
  24894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24895. return
  24896. }
  24897. } else if miConfig.MdtrtareaAdmvs == "420902" {
  24898. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24899. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24901. resp3, requestErr3 := http.Get(api3)
  24902. if requestErr3 != nil {
  24903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24904. return
  24905. }
  24906. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24907. if ioErr3 != nil {
  24908. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24910. return
  24911. }
  24912. var respJSON3 map[string]interface{}
  24913. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24914. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24916. return
  24917. }
  24918. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24919. userJSONBytes3, _ := json.Marshal(respJSON3)
  24920. fmt.Println("log")
  24921. fmt.Println(string(userJSONBytes3))
  24922. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24923. utils.ErrorLog("解析失败:%v", err)
  24924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24925. return
  24926. }
  24927. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24928. if err == nil {
  24929. c.ServeSuccessJSON(map[string]interface{}{
  24930. "msg": "撤销明细成功",
  24931. })
  24932. return
  24933. } else {
  24934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24935. return
  24936. }
  24937. } else if miConfig.MdtrtareaAdmvs == "421182" {
  24938. api3 := miConfig.Url + "hbyb/2205?psn_no=" + order.PsnNo +
  24939. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24940. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  24941. resp3, requestErr3 := http.Get(api3)
  24942. if requestErr3 != nil {
  24943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24944. return
  24945. }
  24946. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24947. if ioErr3 != nil {
  24948. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  24949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24950. return
  24951. }
  24952. var respJSON3 map[string]interface{}
  24953. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  24954. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  24955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24956. return
  24957. }
  24958. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  24959. userJSONBytes3, _ := json.Marshal(respJSON3)
  24960. fmt.Println("log")
  24961. fmt.Println(string(userJSONBytes3))
  24962. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  24963. utils.ErrorLog("解析失败:%v", err)
  24964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24965. return
  24966. }
  24967. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  24968. if err == nil {
  24969. c.ServeSuccessJSON(map[string]interface{}{
  24970. "msg": "撤销明细成功",
  24971. })
  24972. return
  24973. } else {
  24974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24975. return
  24976. }
  24977. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  24978. var resSix10265 ResultSix10265
  24979. var api3 string
  24980. if miConfig.MdtrtareaAdmvs == "320921" {
  24981. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24982. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24983. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24984. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24985. } else {
  24986. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  24987. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  24988. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  24989. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  24990. }
  24991. resp3, requestErr3 := http.Get(api3)
  24992. utils.ErrorLog("接口: %v", requestErr3)
  24993. if requestErr3 != nil {
  24994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  24995. return
  24996. }
  24997. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  24998. if ioErr3 != nil {
  24999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25001. return
  25002. }
  25003. var respJSON3 map[string]interface{}
  25004. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25007. return
  25008. }
  25009. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25010. userJSONBytes3, _ := json.Marshal(respJSON3)
  25011. fmt.Println("log")
  25012. fmt.Println(string(userJSONBytes3))
  25013. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25014. utils.ErrorLog("解析失败:%v", err)
  25015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25016. return
  25017. }
  25018. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25019. res2.Output = resSix10265.Output
  25020. res2.ErrMsg = resSix10265.ErrMsg
  25021. res2.Cainfo = resSix10265.Cainfo
  25022. res2.WarnMsg = resSix10265.WarnMsg
  25023. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25024. res2.Infcode = infocode
  25025. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25026. if err == nil {
  25027. c.ServeSuccessJSON(map[string]interface{}{
  25028. "msg": "撤销明细成功",
  25029. })
  25030. return
  25031. } else {
  25032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25033. return
  25034. }
  25035. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25036. var api3 string
  25037. api3 = miConfig.SecretKey + "ahyb/2205?psn_no=" + order.PsnNo +
  25038. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25039. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25040. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25041. resp3, requestErr3 := http.Get(api3)
  25042. utils.ErrorLog("接口: %v", requestErr3)
  25043. if requestErr3 != nil {
  25044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25045. return
  25046. }
  25047. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25048. if ioErr3 != nil {
  25049. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25051. return
  25052. }
  25053. var respJSON3 map[string]interface{}
  25054. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25055. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25057. return
  25058. }
  25059. status := respJSON3["data"].(map[string]interface{})["status"].(string)
  25060. if status == "0" {
  25061. err_msg := respJSON3["data"].(map[string]interface{})["msg"].(string)
  25062. c.ServeSuccessJSON(map[string]interface{}{
  25063. "failed_code": -10,
  25064. "msg": err_msg,
  25065. })
  25066. return
  25067. }
  25068. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25069. userJSONBytes3, _ := json.Marshal(respJSON3)
  25070. fmt.Println("log")
  25071. fmt.Println(string(userJSONBytes3))
  25072. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25073. utils.ErrorLog("解析失败:%v", err)
  25074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25075. return
  25076. }
  25077. fmt.Println(res2.Infcode)
  25078. if res2.Infcode == -1 {
  25079. c.ServeSuccessJSON(map[string]interface{}{
  25080. "failed_code": -10,
  25081. "msg": res2.ErrMsg,
  25082. })
  25083. return
  25084. }
  25085. if res2.Infcode == 0 {
  25086. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25087. if err == nil {
  25088. c.ServeSuccessJSON(map[string]interface{}{
  25089. "msg": "撤销明细成功",
  25090. })
  25091. return
  25092. } else {
  25093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25094. return
  25095. }
  25096. } else {
  25097. c.ServeSuccessJSON(map[string]interface{}{
  25098. "failed_code": -10,
  25099. "msg": res2.ErrMsg,
  25100. })
  25101. }
  25102. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25103. if err == nil {
  25104. c.ServeSuccessJSON(map[string]interface{}{
  25105. "msg": "撤销明细成功",
  25106. })
  25107. return
  25108. } else {
  25109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25110. return
  25111. }
  25112. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25113. var resSix10265 ResultSix10265
  25114. var api3 string
  25115. api3 = "http://172.16.13.254:9532/" + "nmyb/2205?psn_no=" + order.PsnNo +
  25116. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25117. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25118. resp3, requestErr3 := http.Get(api3)
  25119. if requestErr3 != nil {
  25120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25121. return
  25122. }
  25123. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  25124. if ioErr3 != nil {
  25125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  25126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25127. return
  25128. }
  25129. var respJSON3 map[string]interface{}
  25130. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  25131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25133. return
  25134. }
  25135. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25136. userJSONBytes3, _ := json.Marshal(respJSON3)
  25137. fmt.Println("log")
  25138. fmt.Println(string(userJSONBytes3))
  25139. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  25140. utils.ErrorLog("解析失败:%v", err)
  25141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25142. return
  25143. }
  25144. res2.InfRefmsgid = resSix10265.InfRefmsgid
  25145. res2.Output = resSix10265.Output
  25146. res2.ErrMsg = resSix10265.ErrMsg
  25147. res2.Cainfo = resSix10265.Cainfo
  25148. res2.WarnMsg = resSix10265.WarnMsg
  25149. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  25150. res2.Infcode = infocode
  25151. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25152. if err == nil {
  25153. c.ServeSuccessJSON(map[string]interface{}{
  25154. "msg": "撤销明细成功",
  25155. })
  25156. return
  25157. } else {
  25158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25159. return
  25160. }
  25161. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25162. 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)
  25163. var dat map[string]interface{}
  25164. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25165. fmt.Println(dat)
  25166. } else {
  25167. fmt.Println(err)
  25168. }
  25169. saveLog(result2, src_request, "2205", "撤销明细")
  25170. userJSONBytes, _ := json.Marshal(dat)
  25171. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25172. utils.ErrorLog("解析失败:%v", err)
  25173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25174. return
  25175. }
  25176. if res2.Infcode == 0 {
  25177. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25178. if err == nil {
  25179. c.ServeSuccessJSON(map[string]interface{}{
  25180. "msg": "撤销明细成功",
  25181. })
  25182. return
  25183. } else {
  25184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25185. return
  25186. }
  25187. } else {
  25188. c.ServeSuccessJSON(map[string]interface{}{
  25189. "failed_code": -10,
  25190. "msg": res2.ErrMsg,
  25191. })
  25192. }
  25193. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25194. 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, "")
  25195. var dat map[string]interface{}
  25196. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25197. fmt.Println(dat)
  25198. } else {
  25199. fmt.Println(err)
  25200. }
  25201. saveLog(result2, src_request, "2205", "撤销明细")
  25202. userJSONBytes, _ := json.Marshal(dat)
  25203. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25204. utils.ErrorLog("解析失败:%v", err)
  25205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25206. return
  25207. }
  25208. if res2.Infcode == 0 {
  25209. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25210. if err == nil {
  25211. c.ServeSuccessJSON(map[string]interface{}{
  25212. "msg": "撤销明细成功",
  25213. })
  25214. return
  25215. } else {
  25216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25217. return
  25218. }
  25219. } else {
  25220. c.ServeSuccessJSON(map[string]interface{}{
  25221. "failed_code": -10,
  25222. "msg": res2.ErrMsg,
  25223. })
  25224. }
  25225. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25226. 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, "")
  25227. var dat map[string]interface{}
  25228. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  25229. fmt.Println(dat)
  25230. } else {
  25231. fmt.Println(err)
  25232. }
  25233. saveLog(result2, src_request, "2205", "撤销明细")
  25234. userJSONBytes, _ := json.Marshal(dat)
  25235. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  25236. utils.ErrorLog("解析失败:%v", err)
  25237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25238. return
  25239. }
  25240. if res2.Infcode == 0 {
  25241. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25242. if err == nil {
  25243. c.ServeSuccessJSON(map[string]interface{}{
  25244. "msg": "撤销明细成功",
  25245. })
  25246. return
  25247. } else {
  25248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25249. return
  25250. }
  25251. } else {
  25252. c.ServeSuccessJSON(map[string]interface{}{
  25253. "failed_code": -10,
  25254. "msg": res2.ErrMsg,
  25255. })
  25256. }
  25257. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25258. api2 := miConfig.Url + "gdyb/six?psn_no=" + his.PsnNo +
  25259. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25260. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  25261. resp2, requestErr2 := http.Get(api2)
  25262. if requestErr2 != nil {
  25263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25264. return
  25265. }
  25266. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25267. if ioErr2 != nil {
  25268. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25270. return
  25271. }
  25272. var respJSON2 map[string]interface{}
  25273. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25274. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25276. return
  25277. }
  25278. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25279. userJSONBytes3, _ := json.Marshal(respJSON2)
  25280. fmt.Println("log")
  25281. fmt.Println(string(userJSONBytes3))
  25282. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  25283. utils.ErrorLog("解析失败:%v", err)
  25284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25285. return
  25286. }
  25287. if res2.Infcode == 0 {
  25288. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25289. if err == nil {
  25290. c.ServeSuccessJSON(map[string]interface{}{
  25291. "msg": "撤销明细成功",
  25292. })
  25293. return
  25294. } else {
  25295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25296. return
  25297. }
  25298. } else {
  25299. c.ServeSuccessJSON(map[string]interface{}{
  25300. "failed_code": -10,
  25301. "msg": res2.ErrMsg,
  25302. })
  25303. }
  25304. } else {
  25305. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  25306. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  25307. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25308. resp2, requestErr2 := http.Get(api2)
  25309. if requestErr2 != nil {
  25310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25311. return
  25312. }
  25313. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  25314. if ioErr2 != nil {
  25315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  25316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25317. return
  25318. }
  25319. var respJSON2 map[string]interface{}
  25320. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  25321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25323. return
  25324. }
  25325. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25326. if err == nil {
  25327. c.ServeSuccessJSON(map[string]interface{}{
  25328. "msg": "撤销明细成功",
  25329. })
  25330. return
  25331. } else {
  25332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25333. return
  25334. }
  25335. }
  25336. } else {
  25337. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  25338. if err == nil {
  25339. c.ServeSuccessJSON(map[string]interface{}{
  25340. "msg": "退费成功",
  25341. })
  25342. } else {
  25343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25344. return
  25345. }
  25346. }
  25347. }
  25348. // 对账
  25349. func (c *HisApiController) GetCheckAccount() {
  25350. start_time := c.GetString("start_time")
  25351. end_time := c.GetString("end_time")
  25352. insutype := c.GetString("insutype")
  25353. clr_type := c.GetString("clr_type")
  25354. clr_org := c.GetString("clr_optins")
  25355. admin_user_id, _ := c.GetInt64("admin_user_id")
  25356. adminUser := c.GetAdminUserInfo()
  25357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25359. if len(clr_org) == 0 {
  25360. clr_org = miConfig.InsuplcAdmdvs
  25361. }
  25362. timeLayout := "2006-01-02"
  25363. loc, _ := time.LoadLocation("Local")
  25364. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25365. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25366. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25367. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  25368. fixmedins_setl_cnt := int64(len(orders))
  25369. var medfee_sumamt float64
  25370. var acct_pay float64
  25371. var fund_pay_sumamt float64
  25372. for _, item := range orders {
  25373. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25374. acct_pay = acct_pay + item.AcctPay
  25375. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25376. }
  25377. var user_name string
  25378. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  25379. if role.ID == 0 {
  25380. user_name = "xxx"
  25381. } else {
  25382. user_name = role.UserName
  25383. }
  25384. var res ResultEight
  25385. var res10188 ResultEightFor10188
  25386. if config.IsOpen == 1 {
  25387. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  25388. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  25389. "insutype=" + insutype +
  25390. "&clr_type=" + clr_type +
  25391. "&setl_optins=" + clr_org +
  25392. "&stmt_begndate=" + start_time +
  25393. "&stm_enddate=" + end_time +
  25394. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25395. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25396. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25397. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25398. "&fixmedins_code=" + miConfig.Code +
  25399. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25400. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25401. "&secret_key=" + miConfig.SecretKey +
  25402. "&org_name=" + miConfig.OrgName +
  25403. "&doctor=" + user_name +
  25404. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  25405. fmt.Println(api)
  25406. resp, requestErr := http.Get(api)
  25407. if requestErr != nil {
  25408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25409. return
  25410. }
  25411. body, ioErr := ioutil.ReadAll(resp.Body)
  25412. fmt.Println(body)
  25413. if ioErr != nil {
  25414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25416. return
  25417. }
  25418. var respJSON map[string]interface{}
  25419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25422. return
  25423. }
  25424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25425. userJSONBytes, _ := json.Marshal(respJSON)
  25426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25427. utils.ErrorLog("解析失败:%v", err)
  25428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25429. return
  25430. }
  25431. res.InfRefmsgid = res10188.InfRefmsgid
  25432. res.Output = res10188.Output
  25433. res.ErrMsg = res10188.ErrMsg
  25434. res.Cainfo = res10188.Cainfo
  25435. res.WarnMsg = res10188.WarnMsg
  25436. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25437. res.Infcode = infocode
  25438. } else if miConfig.MdtrtareaAdmvs == "150499" {
  25439. if clr_type != "9903" {
  25440. clr_type = "99" // 就诊 ID(来自2201接口返回)
  25441. }
  25442. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  25443. "insutype=" + insutype +
  25444. "&clr_type=" + clr_type +
  25445. "&setl_optins=" + clr_org +
  25446. "&stmt_begndate=" + start_time +
  25447. "&stm_enddate=" + end_time +
  25448. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25449. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25450. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25451. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25452. "&fixmedins_code=" + miConfig.Code +
  25453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25454. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25455. "&secret_key=" + miConfig.SecretKey +
  25456. "&org_name=" + miConfig.OrgName +
  25457. "&doctor=" + user_name
  25458. resp, requestErr := http.Get(api)
  25459. if requestErr != nil {
  25460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25461. return
  25462. }
  25463. body, ioErr := ioutil.ReadAll(resp.Body)
  25464. if ioErr != nil {
  25465. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25467. return
  25468. }
  25469. var respJSON map[string]interface{}
  25470. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25473. return
  25474. }
  25475. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25476. result, _ := json.Marshal(respJSON)
  25477. fmt.Println("log")
  25478. fmt.Println(string(result))
  25479. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  25480. utils.ErrorLog("解析失败:%v", err)
  25481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25482. return
  25483. }
  25484. res.InfRefmsgid = res10188.InfRefmsgid
  25485. res.Output = res10188.Output
  25486. res.ErrMsg = res10188.ErrMsg
  25487. res.Cainfo = res10188.Cainfo
  25488. res.WarnMsg = res10188.WarnMsg
  25489. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  25490. res.Infcode = infocode
  25491. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25492. var baseParams models.BaseParams
  25493. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25494. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25495. baseParams.SecretKey = miConfig.SecretKey
  25496. baseParams.OrgName = miConfig.OrgName
  25497. baseParams.FixmedinsCode = miConfig.Code
  25498. baseParams.EncKey = miConfig.EncKey
  25499. baseParams.AppSecret = miConfig.AppSecret
  25500. baseParams.SignKey = miConfig.SignKey
  25501. baseParams.AppID = miConfig.Code
  25502. baseParams.Doctor = role.UserName
  25503. baseParams.RequestUrl = miConfig.Url
  25504. businessParams := models.BusinessParams{
  25505. Insutype: insutype,
  25506. ClrType: clr_type,
  25507. SetlOptins: clr_org,
  25508. StmtBegndate: start_time,
  25509. StmtEnddate: end_time,
  25510. MedfeeSumamt: medfee_sumamt,
  25511. FundPaySumamt: fund_pay_sumamt,
  25512. AcctPay: acct_pay,
  25513. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25514. }
  25515. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25516. fmt.Println(requestLog)
  25517. fmt.Println(result)
  25518. fmt.Println(err_msg)
  25519. var dat map[string]interface{}
  25520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25521. fmt.Println(dat)
  25522. } else {
  25523. fmt.Println(err)
  25524. }
  25525. userJSONBytes, _ := json.Marshal(dat)
  25526. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25527. utils.ErrorLog("解析失败:%v", err)
  25528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25529. return
  25530. }
  25531. } else if miConfig.MdtrtareaAdmvs == "430800" {
  25532. var baseParams models.BaseParams
  25533. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25534. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25535. baseParams.SecretKey = miConfig.SecretKey
  25536. baseParams.OrgName = miConfig.OrgName
  25537. baseParams.FixmedinsCode = miConfig.Code
  25538. baseParams.EncKey = miConfig.EncKey
  25539. baseParams.AppSecret = miConfig.AppSecret
  25540. baseParams.SignKey = miConfig.SignKey
  25541. baseParams.AppID = miConfig.Code
  25542. baseParams.Doctor = role.UserName
  25543. baseParams.RequestUrl = miConfig.Url
  25544. baseParams.AccessKey = miConfig.AccessKey
  25545. businessParams := models.BusinessParams{
  25546. Insutype: insutype,
  25547. ClrType: clr_type,
  25548. SetlOptins: "430822",
  25549. StmtBegndate: start_time,
  25550. StmtEnddate: end_time,
  25551. MedfeeSumamt: medfee_sumamt,
  25552. FundPaySumamt: fund_pay_sumamt,
  25553. AcctPay: acct_pay,
  25554. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25555. }
  25556. 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)
  25557. fmt.Println(requestLog)
  25558. fmt.Println(result)
  25559. var dat map[string]interface{}
  25560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25561. fmt.Println(dat)
  25562. } else {
  25563. fmt.Println(err)
  25564. }
  25565. userJSONBytes, _ := json.Marshal(dat)
  25566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25567. utils.ErrorLog("解析失败:%v", err)
  25568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25569. return
  25570. }
  25571. } else if miConfig.MdtrtareaAdmvs == "350500" {
  25572. var baseParams models.BaseParams
  25573. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25574. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25575. baseParams.SecretKey = miConfig.SecretKey
  25576. baseParams.OrgName = miConfig.OrgName
  25577. baseParams.FixmedinsCode = miConfig.Code
  25578. baseParams.EncKey = miConfig.EncKey
  25579. baseParams.AppSecret = miConfig.AppSecret
  25580. baseParams.SignKey = miConfig.SignKey
  25581. baseParams.AppID = miConfig.Code
  25582. baseParams.Doctor = role.UserName
  25583. baseParams.RequestUrl = miConfig.Url
  25584. businessParams := models.BusinessParams{
  25585. Insutype: insutype,
  25586. ClrType: clr_type,
  25587. SetlOptins: clr_org,
  25588. StmtBegndate: start_time,
  25589. StmtEnddate: end_time,
  25590. MedfeeSumamt: medfee_sumamt,
  25591. FundPaySumamt: fund_pay_sumamt,
  25592. AcctPay: acct_pay,
  25593. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25594. }
  25595. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt),fmt.Sprintf("%.4f", acct_pay))
  25596. fmt.Println(requestLog)
  25597. fmt.Println(result)
  25598. fmt.Println(err_msg)
  25599. var dat map[string]interface{}
  25600. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25601. fmt.Println(dat)
  25602. } else {
  25603. fmt.Println(err)
  25604. }
  25605. userJSONBytes, _ := json.Marshal(dat)
  25606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25607. utils.ErrorLog("解析失败:%v", err)
  25608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25609. return
  25610. }
  25611. } else if miConfig.MdtrtareaAdmvs == "441799" {
  25612. if len(clr_type) == 0 {
  25613. clr_type = "11"
  25614. }
  25615. api := miConfig.Url + "gdyb/ten?" +
  25616. "insutype=" + insutype +
  25617. "&clr_type=" + clr_type +
  25618. "&setl_optins=" + clr_org +
  25619. "&stmt_begndate=" + start_time +
  25620. "&stm_enddate=" + end_time +
  25621. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25622. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25623. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25624. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25625. "&fixmedins_code=" + miConfig.Code +
  25626. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25627. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25628. "&secret_key=" + miConfig.SecretKey +
  25629. "&org_name=" + miConfig.OrgName +
  25630. "&doctor=" + user_name
  25631. fmt.Println(api)
  25632. resp, requestErr := http.Get(api)
  25633. if requestErr != nil {
  25634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25635. return
  25636. }
  25637. body, ioErr := ioutil.ReadAll(resp.Body)
  25638. fmt.Println(body)
  25639. if ioErr != nil {
  25640. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25642. return
  25643. }
  25644. var respJSON map[string]interface{}
  25645. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25648. return
  25649. }
  25650. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25651. userJSONBytes, _ := json.Marshal(respJSON)
  25652. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25653. utils.ErrorLog("解析失败:%v", err)
  25654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25655. return
  25656. }
  25657. } else if miConfig.MdtrtareaAdmvs == "360302" {
  25658. var baseParams models.BaseParams
  25659. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  25660. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  25661. baseParams.SecretKey = miConfig.SecretKey
  25662. baseParams.OrgName = miConfig.OrgName
  25663. baseParams.FixmedinsCode = miConfig.Code
  25664. baseParams.EncKey = miConfig.EncKey
  25665. baseParams.AppSecret = miConfig.AppSecret
  25666. baseParams.SignKey = miConfig.SignKey
  25667. baseParams.AppID = miConfig.Code
  25668. baseParams.Doctor = role.UserName
  25669. baseParams.RequestUrl = miConfig.Url
  25670. if clr_type == "9903" {
  25671. clr_type = "9901"
  25672. }
  25673. businessParams := models.BusinessParams{
  25674. Insutype: insutype,
  25675. ClrType: clr_type,
  25676. SetlOptins: "360302",
  25677. StmtBegndate: start_time,
  25678. StmtEnddate: end_time,
  25679. MedfeeSumamt: 0,
  25680. FundPaySumamt: 0,
  25681. AcctPay: 0,
  25682. FixmedinsSetlCnt: fixmedins_setl_cnt,
  25683. }
  25684. 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))
  25685. fmt.Println(requestLog)
  25686. fmt.Println(result)
  25687. var dat map[string]interface{}
  25688. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  25689. fmt.Println(dat)
  25690. } else {
  25691. fmt.Println(err)
  25692. }
  25693. userJSONBytes, _ := json.Marshal(dat)
  25694. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25695. utils.ErrorLog("解析失败:%v", err)
  25696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25697. return
  25698. }
  25699. } else if miConfig.MdtrtareaAdmvs == "341203" {
  25700. var api string
  25701. api = miConfig.SecretKey + "ahyb/3201?insutype=" + insutype +
  25702. "&clr_type=" + clr_type +
  25703. "&setl_optins=" + clr_org +
  25704. "&stmt_begndate=" + start_time +
  25705. "&stm_enddate=" + end_time +
  25706. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25707. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25708. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25709. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  25710. "&fixmedins_code=" + miConfig.Code +
  25711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25712. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25713. "&secret_key=" + miConfig.SecretKey +
  25714. "&org_name=" + miConfig.OrgName +
  25715. "&doctor=" + user_name + "&url=" + miConfig.Url
  25716. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25717. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  25718. resp, requestErr := http.Get(api)
  25719. if requestErr != nil {
  25720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25721. return
  25722. }
  25723. body, ioErr := ioutil.ReadAll(resp.Body)
  25724. if ioErr != nil {
  25725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25727. return
  25728. }
  25729. var respJSON map[string]interface{}
  25730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25733. return
  25734. }
  25735. status := respJSON["data"].(map[string]interface{})["status"].(string)
  25736. if status == "0" {
  25737. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  25738. c.ServeSuccessJSON(map[string]interface{}{
  25739. "failed_code": -10,
  25740. "msg": err_msg,
  25741. })
  25742. return
  25743. }
  25744. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25745. userJSONBytes, _ := json.Marshal(respJSON)
  25746. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25747. utils.ErrorLog("解析失败:%v", err)
  25748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25749. return
  25750. }
  25751. } else {
  25752. if len(clr_type) == 0 {
  25753. clr_type = "11"
  25754. }
  25755. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25756. "insutype=" + insutype +
  25757. "&clr_type=" + clr_type +
  25758. "&setl_optins=" + clr_org +
  25759. "&stmt_begndate=" + start_time +
  25760. "&stm_enddate=" + end_time +
  25761. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  25762. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  25763. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  25764. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  25765. "&fixmedins_code=" + miConfig.Code +
  25766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25767. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25768. "&secret_key=" + miConfig.SecretKey +
  25769. "&org_name=" + miConfig.OrgName +
  25770. "&doctor=" + user_name + "&admin_user_id=" + strconv.FormatInt(admin_user_id, 10)
  25771. fmt.Println(api)
  25772. resp, requestErr := http.Get(api)
  25773. if requestErr != nil {
  25774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25775. return
  25776. }
  25777. body, ioErr := ioutil.ReadAll(resp.Body)
  25778. fmt.Println(body)
  25779. if ioErr != nil {
  25780. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25782. return
  25783. }
  25784. var respJSON map[string]interface{}
  25785. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25786. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25788. return
  25789. }
  25790. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25791. userJSONBytes, _ := json.Marshal(respJSON)
  25792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25793. utils.ErrorLog("解析失败:%v", err)
  25794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25795. return
  25796. }
  25797. }
  25798. if res.Infcode == 0 {
  25799. if res.Output.Stmtinfo.StmtRslt == "0" {
  25800. micc := &models.MedicalInsuranceCostCompare{
  25801. StartTime: startime.Unix(),
  25802. EndTime: endtime.Unix(),
  25803. Insutype: insutype,
  25804. CheckType: 1,
  25805. Num: fixmedins_setl_cnt,
  25806. Mtime: time.Now().Unix(),
  25807. Status: 1,
  25808. UserOrgId: adminUser.CurrentOrgId,
  25809. CostTotal: medfee_sumamt,
  25810. FuncTotal: fund_pay_sumamt,
  25811. PsnPay: acct_pay,
  25812. Creator: admin_user_id,
  25813. Ctime: time.Now().Unix(),
  25814. ClrType: clr_type,
  25815. }
  25816. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  25817. if err == nil {
  25818. c.ServeSuccessJSON(map[string]interface{}{
  25819. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25820. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25821. })
  25822. } else {
  25823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25824. }
  25825. } else {
  25826. c.ServeSuccessJSON(map[string]interface{}{
  25827. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  25828. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  25829. })
  25830. }
  25831. } else {
  25832. c.ServeSuccessJSON(map[string]interface{}{
  25833. "failed_code": -10,
  25834. "msg": res.ErrMsg,
  25835. })
  25836. }
  25837. }
  25838. }
  25839. func (c *HisApiController) Check310() {
  25840. adminUser := c.GetAdminUserInfo()
  25841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25842. var user_name string
  25843. user_name = "高慧裕"
  25844. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25845. "insutype=" + "310" +
  25846. "&clr_type=" + "" +
  25847. "&setl_optins=" + "441202" +
  25848. "&stmt_begndate=" + "2022-03-01" +
  25849. "&stm_enddate=" + "2022-03-31" +
  25850. "&medfee_sumamt=" + "194930.12" +
  25851. "&fund_pay_sumamt=" + "188741.46" +
  25852. "&acct_pay=" + "0" +
  25853. "&fixmedins_setl_cnt=" + "452" +
  25854. "&fixmedins_code=" + miConfig.Code +
  25855. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25856. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25857. "&secret_key=" + miConfig.SecretKey +
  25858. "&org_name=" + miConfig.OrgName +
  25859. "&doctor=" + user_name
  25860. fmt.Println(api)
  25861. resp, requestErr := http.Get(api)
  25862. if requestErr != nil {
  25863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25864. return
  25865. }
  25866. body, ioErr := ioutil.ReadAll(resp.Body)
  25867. fmt.Println(body)
  25868. if ioErr != nil {
  25869. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25871. return
  25872. }
  25873. var respJSON map[string]interface{}
  25874. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25875. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25877. return
  25878. }
  25879. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25880. userJSONBytes, _ := json.Marshal(respJSON)
  25881. var res ResultEight
  25882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25883. utils.ErrorLog("解析失败:%v", err)
  25884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25885. return
  25886. }
  25887. }
  25888. func (c *HisApiController) Check390() {
  25889. adminUser := c.GetAdminUserInfo()
  25890. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25891. var user_name string
  25892. user_name = "高慧裕"
  25893. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  25894. "insutype=" + "390" +
  25895. "&clr_type=" + "" +
  25896. "&setl_optins=" + "441202" +
  25897. "&stmt_begndate=" + "2022-03-01" +
  25898. "&stm_enddate=" + "2022-03-31" +
  25899. "&medfee_sumamt=" + "1068448.89" +
  25900. "&fund_pay_sumamt=" + "1014677.62" +
  25901. "&acct_pay=" + "0" +
  25902. "&fixmedins_setl_cnt=" + "1950" +
  25903. "&fixmedins_code=" + miConfig.Code +
  25904. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  25905. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  25906. "&secret_key=" + miConfig.SecretKey +
  25907. "&org_name=" + miConfig.OrgName +
  25908. "&doctor=" + user_name
  25909. fmt.Println(api)
  25910. resp, requestErr := http.Get(api)
  25911. if requestErr != nil {
  25912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25913. return
  25914. }
  25915. body, ioErr := ioutil.ReadAll(resp.Body)
  25916. fmt.Println(body)
  25917. if ioErr != nil {
  25918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  25919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25920. return
  25921. }
  25922. var respJSON map[string]interface{}
  25923. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  25924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  25925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25926. return
  25927. }
  25928. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  25929. userJSONBytes, _ := json.Marshal(respJSON)
  25930. var res ResultEight
  25931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  25932. utils.ErrorLog("解析失败:%v", err)
  25933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  25934. return
  25935. }
  25936. }
  25937. // 对账明细
  25938. func (c *HisApiController) GetCheckDetailAccount() {
  25939. start_time := c.GetString("start_time")
  25940. end_time := c.GetString("end_time")
  25941. admin_user_id, _ := c.GetInt64("admin_user_id")
  25942. adminUser := c.GetAdminUserInfo()
  25943. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  25944. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  25945. timeLayout := "2006-01-02"
  25946. loc, _ := time.LoadLocation("Local")
  25947. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  25948. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  25949. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  25950. rand.Seed(time.Now().UnixNano())
  25951. num := rand.Intn(30000)
  25952. Mkdir(miConfig.OrgName)
  25953. file := strconv.FormatInt(int64(num), 10)
  25954. file_name := file + ".txt"
  25955. zip_name := file + ".zip"
  25956. zip_path := miConfig.OrgName + "/" + zip_name
  25957. file_path := miConfig.OrgName + "/" + file_name
  25958. decimal.DivisionPrecision = 2
  25959. var medfee_sumamt float64
  25960. var psn_cash_pay float64
  25961. var fund_pay_sumamt float64
  25962. fixmedins_setl_cnt := int64(len(orders))
  25963. for _, item := range orders {
  25964. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  25965. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  25966. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  25967. }
  25968. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  25969. defer f.Close()
  25970. if err != nil {
  25971. fmt.Println(err.Error())
  25972. } else {
  25973. for _, item := range orders {
  25974. var refd_setl_flag string
  25975. if item.OrderStatus == 2 {
  25976. refd_setl_flag = "0"
  25977. var str string
  25978. str = item.SetlId + " " +
  25979. item.MdtrtId + " " +
  25980. item.PsnNo + " " +
  25981. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25982. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25983. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  25984. _, err = f.Write([]byte(str))
  25985. }
  25986. if item.OrderStatus == 3 {
  25987. var str string
  25988. str = item.SetlId + " " +
  25989. item.MdtrtId + " " +
  25990. item.PsnNo + " " +
  25991. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  25992. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  25993. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  25994. _, err = f.Write([]byte(str))
  25995. var str2 string
  25996. str2 = item.SetlId + " " +
  25997. item.MdtrtId + " " +
  25998. item.PsnNo + " " +
  25999. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  26000. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  26001. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  26002. _, err = f.Write([]byte(str2))
  26003. }
  26004. }
  26005. }
  26006. Zip(file_path, zip_path)
  26007. fmt.Println(ReadFile(zip_path))
  26008. fmt.Println(string(ReadFile(zip_path)))
  26009. if config.IsOpen == 1 {
  26010. var user_name string
  26011. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26012. if role.ID == 0 {
  26013. user_name = "管理员"
  26014. } else {
  26015. user_name = role.UserName
  26016. }
  26017. baseParams := models.BaseParams{
  26018. SecretKey: miConfig.SecretKey,
  26019. FixmedinsCode: miConfig.Code,
  26020. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26021. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26022. OrgName: miConfig.OrgName,
  26023. Doctor: user_name,
  26024. }
  26025. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  26026. var dat map[string]interface{}
  26027. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26028. fmt.Println(dat)
  26029. } else {
  26030. fmt.Println(err)
  26031. }
  26032. userJSONBytes, _ := json.Marshal(dat)
  26033. var res ResultNine
  26034. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26035. utils.ErrorLog("解析失败:%v", err)
  26036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26037. return
  26038. }
  26039. if res.Infcode == 0 {
  26040. fileNo := res.Output.FileQuryNo
  26041. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  26042. "file_qury_no=" + fileNo +
  26043. "&setl_optins=" + "定点医保中心" +
  26044. "&stmt_begndate=" + start_time +
  26045. "&stm_enddate=" + end_time +
  26046. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  26047. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  26048. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  26049. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  26050. "&fixmedins_code=" + miConfig.Code +
  26051. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  26052. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  26053. "&secret_key=" + miConfig.SecretKey +
  26054. "&org_name=" + miConfig.OrgName +
  26055. "&doctor=" + user_name
  26056. resp, requestErr := http.Get(api)
  26057. if requestErr != nil {
  26058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26059. return
  26060. }
  26061. body, ioErr := ioutil.ReadAll(resp.Body)
  26062. if ioErr != nil {
  26063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26065. return
  26066. }
  26067. var respJSON map[string]interface{}
  26068. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26071. return
  26072. }
  26073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26074. userJSONBytes, _ := json.Marshal(respJSON)
  26075. var res ResultTen
  26076. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26077. utils.ErrorLog("解析失败:%v", err)
  26078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26079. return
  26080. }
  26081. if res.Infcode == 0 {
  26082. service.Gdyb9102(baseParams, res.Output.Fileinfo.Filename, res.Output.Fileinfo.FileQuryNo)
  26083. micc := &models.MedicalInsuranceCostCompare{
  26084. StartTime: startime.Unix(),
  26085. EndTime: endtime.Unix(),
  26086. Insutype: "0",
  26087. CheckType: 2,
  26088. Num: fixmedins_setl_cnt,
  26089. Mtime: time.Now().Unix(),
  26090. Status: 1,
  26091. UserOrgId: adminUser.CurrentOrgId,
  26092. CostTotal: medfee_sumamt,
  26093. FuncTotal: fund_pay_sumamt,
  26094. PsnPay: psn_cash_pay,
  26095. Creator: admin_user_id,
  26096. Ctime: time.Now().Unix(),
  26097. }
  26098. service.CreateMedicalInsuranceCostCompareRecord(micc)
  26099. c.ServeSuccessJSON(map[string]interface{}{
  26100. "msg": "明细对账成功",
  26101. })
  26102. }
  26103. } else {
  26104. }
  26105. }
  26106. }
  26107. type CustomOrderInfo struct {
  26108. Name string
  26109. Spec string
  26110. Unit string
  26111. Count float64
  26112. Price float64
  26113. Total float64
  26114. }
  26115. func (c *HisApiController) GetBatchSettleAccounts() {
  26116. admin_user_id, _ := c.GetInt64("admin_user_id")
  26117. order_ids := c.GetString("order_ids")
  26118. order_ids_arr := strings.Split(order_ids, ",")
  26119. data3 := []map[string]interface{}{}
  26120. for _, item := range order_ids_arr {
  26121. id, _ := strconv.ParseInt(item, 10, 64)
  26122. order_id := id
  26123. adminUser := c.GetAdminUserInfo()
  26124. order, _ := service.GetHisOrderByID(order_id)
  26125. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26126. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26127. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26128. orderInfos = append(orderInfos, orderInfos_two...)
  26129. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26130. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26131. var diagnosis_ids []string
  26132. if his.ID > 0 {
  26133. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26134. } else {
  26135. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26136. }
  26137. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26138. var dia_config []*models.HisXtDiagnoseConfig
  26139. var name string
  26140. for _, item := range diagnosis_ids {
  26141. id, _ := strconv.ParseInt(item, 10, 64)
  26142. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26143. dia_config = append(dia_config, &diagnosisConfig)
  26144. if len(name) == 0 {
  26145. name = diagnosisConfig.ClassName
  26146. }
  26147. //} else {
  26148. // name = name + "," + diagnosisConfig.ClassName
  26149. //}
  26150. }
  26151. var bedCostTotal float64 = 0 //床位总费
  26152. var bedCostSelfTotal float64 = 0 //床位自费
  26153. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26154. var bedSelfTotal float64 = 0 //床位部分项目自费
  26155. var bedInscpTotal float64 = 0 //床位部分项目自费
  26156. var operationCostTotal float64 = 0 //手术费
  26157. var operationCostSelfTotal float64 = 0 //手术费
  26158. var operationCostPartSelfTotal float64 = 0 //手术费
  26159. var operationSelfTotal float64 = 0 //床位部分项目自费
  26160. var operationInscpTotal float64 = 0 //床位部分项目自费
  26161. var otherCostTotal float64 = 0 //其他费用
  26162. var otherCostSelfTotal float64 = 0 //其他费用
  26163. var otherCostPartSelfTotal float64 = 0 //其他费用
  26164. var otherSelfTotal float64 = 0 //床位部分项目自费
  26165. var otherInscpTotal float64 = 0 //床位部分项目自费
  26166. var materialCostTotal float64 = 0 //材料费
  26167. var materialCostSelfTotal float64 = 0 //材料费
  26168. var materialCostPartSelfTotal float64 = 0 //材料费
  26169. var materialSelfTotal float64 = 0 //床位部分项目自费
  26170. var materialInscpTotal float64 = 0 //床位部分项目自费
  26171. var westernMedicineCostTotal float64 = 0 //西药费
  26172. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26173. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26174. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26175. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26176. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26177. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26178. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26179. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26180. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26181. var checkCostTotal float64 = 0 //检查费
  26182. var checkCostSelfTotal float64 = 0 //检查费
  26183. var checkCostPartSelfTotal float64 = 0 //检查费
  26184. var checkSelfTotal float64 = 0 //床位部分项目自费
  26185. var checkInscpTotal float64 = 0 //床位部分项目自费
  26186. var laboratoryCostTotal float64 = 0 //化验费
  26187. var laboratoryCostSelfTotal float64 = 0 //化验费
  26188. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26189. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26190. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26191. var treatCostTotal float64 = 0 //治疗费用
  26192. var treatCostSelfTotal float64 = 0 //治疗费用
  26193. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26194. var treatSelfTotal float64 = 0 //床位部分项目自费
  26195. var treatInscpTotal float64 = 0 //床位部分项目自费
  26196. decimal.DivisionPrecision = 2
  26197. for _, item := range orderInfos {
  26198. if item.MedChrgitmType == "01" { //床位费
  26199. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26200. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26201. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26202. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26203. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26204. }
  26205. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26206. if item.MedChrgitmType == "03" { //检查费
  26207. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26208. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26209. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26210. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26211. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26212. }
  26213. } else {
  26214. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26215. fmt.Println("------------")
  26216. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26217. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26218. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26219. }
  26220. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26221. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26222. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26223. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26224. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26225. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26226. }
  26227. }
  26228. if item.MedChrgitmType == "04" { //化验费
  26229. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26230. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26231. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26232. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26233. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26234. }
  26235. if item.MedChrgitmType == "05" { //治疗费
  26236. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26237. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26238. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26239. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26240. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26241. }
  26242. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26243. fmt.Println("------------")
  26244. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26245. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26246. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26247. }
  26248. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26249. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26250. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26251. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26252. }
  26253. //if item.MedChrgitmType == "06" { //手术费
  26254. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26255. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26256. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26257. // operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26258. // operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26259. //
  26260. //}
  26261. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26262. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26263. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26264. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26265. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26266. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26267. }
  26268. if item.MedChrgitmType == "09" { //西药费
  26269. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26270. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26271. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26272. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26273. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26274. }
  26275. if item.MedChrgitmType == "11" { //中成费
  26276. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26277. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26278. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26279. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26280. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26281. }
  26282. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26283. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26284. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26285. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26286. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26287. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26288. }
  26289. }
  26290. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26291. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26292. var user_name string
  26293. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26294. if role.ID == 0 {
  26295. user_name = "管理员"
  26296. } else {
  26297. user_name = role.UserName
  26298. }
  26299. baseParams := models.BaseParams{
  26300. SecretKey: miConfig.SecretKey,
  26301. FixmedinsCode: miConfig.Code,
  26302. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26303. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26304. OrgName: miConfig.OrgName,
  26305. Doctor: user_name,
  26306. RequestUrl: miConfig.Url,
  26307. AccessKey: miConfig.AccessKey,
  26308. }
  26309. businessParams := models.BusinessParams{
  26310. PsnNo: order.PsnNo,
  26311. MdtrtId: order.MdtrtId,
  26312. SetlId: order.SetlId,
  26313. }
  26314. var res ResultEleven
  26315. var resEleven10265 ResultEleven10265
  26316. if config.IsOpen == 1 {
  26317. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  26318. result := service.Gdyb5203(baseParams, businessParams)
  26319. service.Gdyb5204(baseParams, businessParams)
  26320. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  26321. var dat map[string]interface{}
  26322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26323. fmt.Println(dat)
  26324. } else {
  26325. fmt.Println(err)
  26326. }
  26327. userJSONBytes, _ := json.Marshal(dat)
  26328. if miConfig.Code == "H15049901371" {
  26329. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  26330. utils.ErrorLog("解析失败:%v", err)
  26331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26332. return
  26333. }
  26334. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26335. res.Output = resEleven10265.Output
  26336. res.ErrMsg = resEleven10265.ErrMsg
  26337. res.Cainfo = resEleven10265.Cainfo
  26338. res.WarnMsg = resEleven10265.WarnMsg
  26339. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26340. res.Infcode = infocode
  26341. } else {
  26342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26343. utils.ErrorLog("解析失败:%v", err)
  26344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26345. return
  26346. }
  26347. }
  26348. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26349. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  26350. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  26351. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  26352. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  26353. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26354. var doctor_name string
  26355. if roles.ID == 0 {
  26356. doctor_name = "管理员"
  26357. } else {
  26358. doctor_name = roles.UserName
  26359. }
  26360. yiliao_leibie := ""
  26361. switch order.MedType {
  26362. case "11":
  26363. yiliao_leibie = "普通门诊"
  26364. break
  26365. case "12":
  26366. yiliao_leibie = "门诊挂号"
  26367. break
  26368. case "13":
  26369. yiliao_leibie = "急诊"
  26370. break
  26371. case "14":
  26372. yiliao_leibie = "门诊特殊病"
  26373. break
  26374. case "15":
  26375. yiliao_leibie = "门诊统筹"
  26376. break
  26377. case "16":
  26378. yiliao_leibie = "门诊慢性病"
  26379. break
  26380. case "21":
  26381. yiliao_leibie = "普通住院"
  26382. break
  26383. }
  26384. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  26385. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  26386. if res.Infcode == 0 {
  26387. data2 := map[string]interface{}{
  26388. "diagnosis": name,
  26389. "order_infos": orderInfos,
  26390. "number": order.MdtrtId,
  26391. "date": order.SettleAccountsDate,
  26392. "charge_admin": charge_admin,
  26393. "printor_admin": printor_admin,
  26394. "info": res.Output.Setlinfo,
  26395. "order": order,
  26396. "bedCostTotal": bedCostTotal,
  26397. "bedCostSelfTotal": bedCostSelfTotal,
  26398. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  26399. "bedSelfTotal": bedSelfTotal,
  26400. "bedInscpTotal": bedInscpTotal,
  26401. "operationCostTotal": operationCostTotal,
  26402. "operationCostSelfTotal": operationCostSelfTotal,
  26403. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  26404. "operationSelfTotal": operationSelfTotal,
  26405. "operationInscpTotal": operationInscpTotal,
  26406. "otherCostTotal": otherCostTotal,
  26407. "otherCostSelfTotal": otherCostSelfTotal,
  26408. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  26409. "otherSelfTotal": otherSelfTotal,
  26410. "otherInscpTotal": otherInscpTotal,
  26411. "materialCostTotal": materialCostTotal,
  26412. "materialCostSelfTotal": materialCostSelfTotal,
  26413. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  26414. "materialSelfTotal": materialSelfTotal,
  26415. "materialInscpTotal": materialInscpTotal,
  26416. "westernMedicineCostTotal": westernMedicineCostTotal,
  26417. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  26418. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  26419. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  26420. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  26421. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  26422. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  26423. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  26424. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  26425. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  26426. "checkCostTotal": checkCostTotal,
  26427. "checkCostSelfTotal": checkCostSelfTotal,
  26428. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  26429. "checkSelfTotal": checkSelfTotal,
  26430. "checkInscpTotal": checkInscpTotal,
  26431. "laboratoryCostTotal": laboratoryCostTotal,
  26432. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  26433. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  26434. "laboratorySelfTotal": laboratorySelfTotal,
  26435. "laboratoryInscpTotal": laboratoryInscpTotal,
  26436. "treatCostTotal": treatCostTotal,
  26437. "treatCostSelfTotal": treatCostSelfTotal,
  26438. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  26439. "treatSelfTotal": treatSelfTotal,
  26440. "treatInscpTotal": treatInscpTotal,
  26441. "doctor_info": doctor_info,
  26442. "doctor_code": adminRole_two.DoctorCode,
  26443. "doctor_name": doctor_name,
  26444. "health_card_no": order.PsnNo,
  26445. "department": departments.Name,
  26446. "yiliao_leibie": yiliao_leibie,
  26447. "after_money": order.AccountPrice,
  26448. "patient": patient,
  26449. "org_name": miConfig.OrgName,
  26450. "org_code": miConfig.Code,
  26451. "order_number": order.Number,
  26452. "his_hospital": his_hospital,
  26453. "his": his,
  26454. "dia_config": dia_config,
  26455. "psn_cash_pay": order.PsnCashPay,
  26456. //"check_order_info": cus_slice,
  26457. }
  26458. data3 = append(data3, data2)
  26459. }
  26460. }
  26461. }
  26462. c.ServeSuccessJSON(map[string]interface{}{
  26463. "infos": data3,
  26464. })
  26465. }
  26466. func (c *HisApiController) GetSettleAccounts() {
  26467. //id, _ := c.GetInt64("id")
  26468. //record_time := c.GetString("record_time")
  26469. order_id, _ := c.GetInt64("order_id")
  26470. admin_user_id, _ := c.GetInt64("admin_user_id")
  26471. //timeLayout := "2006-01-02"
  26472. //loc, _ := time.LoadLocation("Local")
  26473. //
  26474. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  26475. //if err != nil {
  26476. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  26477. // return
  26478. //}Hbyb5203
  26479. //recordDateTime := theTime.Unix()
  26480. adminUser := c.GetAdminUserInfo()
  26481. order, _ := service.GetHisOrderByID(order_id)
  26482. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  26483. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  26484. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  26485. orderInfos = append(orderInfos, orderInfos_two...)
  26486. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  26487. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  26488. var diagnosis_ids []string
  26489. if his.ID > 0 {
  26490. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  26491. } else {
  26492. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  26493. }
  26494. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  26495. var dia_config []*models.HisXtDiagnoseConfig
  26496. var name string
  26497. for _, item := range diagnosis_ids {
  26498. id, _ := strconv.ParseInt(item, 10, 64)
  26499. diagnosisConfig, _ := service.FindDiagnoseById(id)
  26500. dia_config = append(dia_config, &diagnosisConfig)
  26501. if len(name) == 0 {
  26502. name = diagnosisConfig.ClassName
  26503. } else {
  26504. name = name + "," + diagnosisConfig.ClassName
  26505. }
  26506. }
  26507. if patient.UserOrgId == 10215 {
  26508. name = "慢性肾功能不全(血透治疗)"
  26509. }
  26510. var bedCostTotal float64 = 0 //床位总费
  26511. var bedCostSelfTotal float64 = 0 //床位自费
  26512. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  26513. var bedSelfTotal float64 = 0 //床位部分项目自费
  26514. var bedInscpTotal float64 = 0 //床位部分项目自费
  26515. var operationCostTotal float64 = 0 //手术费
  26516. var operationCostSelfTotal float64 = 0 //手术费
  26517. var operationCostPartSelfTotal float64 = 0 //手术费
  26518. var operationSelfTotal float64 = 0 //床位部分项目自费
  26519. var operationInscpTotal float64 = 0 //床位部分项目自费
  26520. var otherCostTotal float64 = 0 //其他费用
  26521. var otherCostSelfTotal float64 = 0 //其他费用
  26522. var otherCostPartSelfTotal float64 = 0 //其他费用
  26523. var otherSelfTotal float64 = 0 //床位部分项目自费
  26524. var otherInscpTotal float64 = 0 //床位部分项目自费
  26525. var materialCostTotal float64 = 0 //材料费
  26526. var materialCostSelfTotal float64 = 0 //材料费
  26527. var materialCostPartSelfTotal float64 = 0 //材料费
  26528. var materialSelfTotal float64 = 0 //床位部分项目自费
  26529. var materialInscpTotal float64 = 0 //床位部分项目自费
  26530. var westernMedicineCostTotal float64 = 0 //西药费
  26531. var westernMedicineCostSelfTotal float64 = 0 //西药费
  26532. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  26533. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  26534. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  26535. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  26536. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  26537. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  26538. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  26539. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  26540. var checkCostTotal float64 = 0 //检查费
  26541. var checkCostSelfTotal float64 = 0 //检查费
  26542. var checkCostPartSelfTotal float64 = 0 //检查费
  26543. var checkSelfTotal float64 = 0 //床位部分项目自费
  26544. var checkInscpTotal float64 = 0 //床位部分项目自费
  26545. var laboratoryCostTotal float64 = 0 //化验费
  26546. var laboratoryCostSelfTotal float64 = 0 //化验费
  26547. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  26548. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  26549. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  26550. var treatCostTotal float64 = 0 //治疗费用
  26551. var treatCostSelfTotal float64 = 0 //治疗费用
  26552. var treatCostPartSelfTotal float64 = 0 //治疗费用
  26553. var treatSelfTotal float64 = 0 //床位部分项目自费
  26554. var treatInscpTotal float64 = 0 //床位部分项目自费
  26555. decimal.DivisionPrecision = 2
  26556. for _, item := range orderInfos {
  26557. if item.MedChrgitmType == "01" { //床位费
  26558. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26559. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26560. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26561. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26562. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26563. }
  26564. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  26565. if item.MedChrgitmType == "03" { //检查费
  26566. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26567. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26568. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26569. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26570. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26571. }
  26572. } else {
  26573. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId == 9504 { //手术费
  26574. fmt.Println("------------")
  26575. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26576. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26577. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26578. }
  26579. if item.MedChrgitmType == "03" && adminUser.CurrentOrgId != 9504 { //手术费
  26580. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26581. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26582. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26583. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26584. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26585. }
  26586. }
  26587. if item.MedChrgitmType == "04" { //化验费
  26588. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26589. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26590. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26591. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26592. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26593. }
  26594. if item.MedChrgitmType == "05" { //治疗费
  26595. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26596. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26597. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26598. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26599. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26600. }
  26601. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId == 9504 { //手术费
  26602. fmt.Println("------------")
  26603. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26604. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26605. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26606. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26607. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26608. }
  26609. if item.MedChrgitmType == "06" && adminUser.CurrentOrgId != 9504 { //手术费
  26610. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26611. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26612. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26613. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26614. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26615. }
  26616. if item.MedChrgitmType == "08" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //材料费
  26617. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26618. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26619. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26620. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26621. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26622. }
  26623. if item.MedChrgitmType == "09" { //西药费
  26624. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26625. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26626. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26627. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26628. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26629. }
  26630. if item.MedChrgitmType == "11" { //中成费
  26631. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26632. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26633. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26634. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26635. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26636. }
  26637. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  26638. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  26639. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  26640. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  26641. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  26642. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  26643. }
  26644. }
  26645. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  26646. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  26647. var user_name string
  26648. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  26649. if role.ID == 0 {
  26650. user_name = "管理员"
  26651. } else {
  26652. user_name = role.UserName
  26653. }
  26654. baseParams := models.BaseParams{
  26655. SecretKey: miConfig.SecretKey,
  26656. FixmedinsCode: miConfig.Code,
  26657. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  26658. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  26659. OrgName: miConfig.OrgName,
  26660. Doctor: user_name,
  26661. RequestUrl: miConfig.Url,
  26662. AccessKey: miConfig.AccessKey,
  26663. }
  26664. businessParams := models.BusinessParams{
  26665. PsnNo: order.PsnNo,
  26666. MdtrtId: order.MdtrtId,
  26667. SetlId: order.SetlId,
  26668. }
  26669. var res ResultEleven
  26670. var resah ResultElevenah
  26671. var resEleven10265 ResultEleven10265
  26672. if config.IsOpen == 1 {
  26673. if miConfig.MdtrtareaAdmvs == "421300" {
  26674. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26675. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26676. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26677. resp, requestErr := http.Get(api)
  26678. if requestErr != nil {
  26679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26680. return
  26681. }
  26682. body, ioErr := ioutil.ReadAll(resp.Body)
  26683. if ioErr != nil {
  26684. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26686. return
  26687. }
  26688. var respJSON map[string]interface{}
  26689. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26690. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26692. return
  26693. }
  26694. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26695. result, _ := json.Marshal(respJSON)
  26696. fmt.Println("log")
  26697. fmt.Println(string(result))
  26698. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26699. utils.ErrorLog("解析失败:%v", err)
  26700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26701. return
  26702. }
  26703. } else if miConfig.MdtrtareaAdmvs == "420200" {
  26704. api := "http://192.168.0.197:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26705. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26706. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26707. resp, requestErr := http.Get(api)
  26708. if requestErr != nil {
  26709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26710. return
  26711. }
  26712. body, ioErr := ioutil.ReadAll(resp.Body)
  26713. if ioErr != nil {
  26714. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26716. return
  26717. }
  26718. var respJSON map[string]interface{}
  26719. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26720. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26722. return
  26723. }
  26724. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26725. result, _ := json.Marshal(respJSON)
  26726. fmt.Println("log")
  26727. fmt.Println(string(result))
  26728. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26729. utils.ErrorLog("解析失败:%v", err)
  26730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26731. return
  26732. }
  26733. } else if miConfig.MdtrtareaAdmvs == "420902" {
  26734. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26735. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26736. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  26737. resp, requestErr := http.Get(api)
  26738. if requestErr != nil {
  26739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26740. return
  26741. }
  26742. body, ioErr := ioutil.ReadAll(resp.Body)
  26743. if ioErr != nil {
  26744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26746. return
  26747. }
  26748. var respJSON map[string]interface{}
  26749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26752. return
  26753. }
  26754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26755. result, _ := json.Marshal(respJSON)
  26756. fmt.Println("log")
  26757. fmt.Println(string(result))
  26758. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26759. utils.ErrorLog("解析失败:%v", err)
  26760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26761. return
  26762. }
  26763. }else if miConfig.MdtrtareaAdmvs == "421182" {
  26764. api := miConfig.Url + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26765. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26766. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&med_type=" + order.MedType
  26767. resp, requestErr := http.Get(api)
  26768. if requestErr != nil {
  26769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26770. return
  26771. }
  26772. body, ioErr := ioutil.ReadAll(resp.Body)
  26773. if ioErr != nil {
  26774. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26776. return
  26777. }
  26778. var respJSON map[string]interface{}
  26779. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26780. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26782. return
  26783. }
  26784. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26785. result, _ := json.Marshal(respJSON)
  26786. fmt.Println("log")
  26787. fmt.Println(string(result))
  26788. if err := json.Unmarshal([]byte(result), &res); err != nil {
  26789. utils.ErrorLog("解析失败:%v", err)
  26790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26791. return
  26792. }
  26793. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  26794. var api string
  26795. if miConfig.MdtrtareaAdmvs == "320921" {
  26796. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26797. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26798. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26799. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26800. } else {
  26801. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26802. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26803. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26804. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26805. }
  26806. resp, requestErr := http.Get(api)
  26807. if requestErr != nil {
  26808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26809. return
  26810. }
  26811. body, ioErr := ioutil.ReadAll(resp.Body)
  26812. if ioErr != nil {
  26813. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26815. return
  26816. }
  26817. var respJSON map[string]interface{}
  26818. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26819. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26821. return
  26822. }
  26823. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26824. result, _ := json.Marshal(respJSON)
  26825. fmt.Println("log")
  26826. fmt.Println(string(result))
  26827. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  26828. utils.ErrorLog("解析失败:%v", err)
  26829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26830. return
  26831. }
  26832. res.InfRefmsgid = resEleven10265.InfRefmsgid
  26833. res.Output = resEleven10265.Output
  26834. res.ErrMsg = resEleven10265.ErrMsg
  26835. res.Cainfo = resEleven10265.Cainfo
  26836. res.WarnMsg = resEleven10265.WarnMsg
  26837. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  26838. res.Infcode = infocode
  26839. } else if miConfig.MdtrtareaAdmvs == "350500" {
  26840. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  26841. saveLog(result, requestLog, "5203", "结算单")
  26842. var dat map[string]interface{}
  26843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26844. fmt.Println(dat)
  26845. } else {
  26846. fmt.Println(err)
  26847. }
  26848. userJSONBytes, _ := json.Marshal(dat)
  26849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26850. utils.ErrorLog("解析失败:%v", err)
  26851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26852. return
  26853. }
  26854. } else if miConfig.MdtrtareaAdmvs == "360302" {
  26855. baseParams.InsuplcAdmdvs = his_hospital.InsuplcAdmdvs
  26856. result3, requestLog3 := service.Jxyb5201(baseParams, businessParams)
  26857. fmt.Println(result3)
  26858. fmt.Println(requestLog3)
  26859. result2, requestLog2 := service.Jxyb5202(baseParams, businessParams)
  26860. fmt.Println(result2)
  26861. fmt.Println(requestLog2)
  26862. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  26863. saveLog(result, requestLog, "5203", "结算单")
  26864. var dat map[string]interface{}
  26865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  26866. fmt.Println(dat)
  26867. } else {
  26868. fmt.Println(err)
  26869. }
  26870. userJSONBytes, _ := json.Marshal(dat)
  26871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  26872. utils.ErrorLog("解析失败:%v", err)
  26873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26874. return
  26875. }
  26876. } else if miConfig.MdtrtareaAdmvs == "341203" {
  26877. var api string
  26878. api = miConfig.SecretKey + "ahyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  26879. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  26880. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  26881. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26882. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  26883. resp, requestErr := http.Get(api)
  26884. if requestErr != nil {
  26885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26886. return
  26887. }
  26888. body, ioErr := ioutil.ReadAll(resp.Body)
  26889. if ioErr != nil {
  26890. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  26891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26892. return
  26893. }
  26894. var respJSON map[string]interface{}
  26895. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  26896. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  26897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26898. return
  26899. }
  26900. status := respJSON["data"].(map[string]interface{})["status"].(string)
  26901. if status == "0" {
  26902. err_msg := respJSON["data"].(map[string]interface{})["msg"].(string)
  26903. c.ServeSuccessJSON(map[string]interface{}{
  26904. "failed_code": -10,
  26905. "msg": err_msg,
  26906. })
  26907. return
  26908. }
  26909. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  26910. result, _ := json.Marshal(respJSON)
  26911. fmt.Println("log")
  26912. fmt.Println(string(result))
  26913. if err := json.Unmarshal([]byte(result), &resah); err != nil {
  26914. utils.ErrorLog("解析失败:%v", err)
  26915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  26916. return
  26917. }
  26918. res.InfRefmsgid = resah.InfRefmsgid
  26919. timestamp := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26920. // 创建对应的Time类型
  26921. t := time.UnixMilli(timestamp)
  26922. // 格式化成指定的日期字符串
  26923. str := t.Format("2006-01-02 15:04:05")
  26924. timestamp2 := int64(resah.Output.Setlinfo.SetlTime) // 输入要转换的时间戳(这里仅作示例)
  26925. // 创建对应的Time类型
  26926. t3 := time.UnixMilli(timestamp2)
  26927. // 格式化成指定的日期字符串
  26928. str2 := t3.Format("2006-01-02 15:04:05")
  26929. timestamp3 := int64(resah.Output.Setlinfo.Begndate) // 输入要转换的时间戳(这里仅作示例)
  26930. // 创建对应的Time类型
  26931. t4 := time.UnixMilli(timestamp3)
  26932. // 格式化成指定的日期字符串
  26933. str3 := t4.Format("2006-01-02 15:04:05")
  26934. timestamp4 := int64(resah.Output.Setlinfo.Enddate) // 输入要转换的时间戳(这里仅作示例)
  26935. // 创建对应的Time类型
  26936. t5 := time.UnixMilli(timestamp4)
  26937. // 格式化成指定的日期字符串
  26938. str5 := t5.Format("2006-01-02 15:04:05")
  26939. res.Output.Setlinfo.Brdy = str2
  26940. res.Output.Setlinfo.SetlTime = str
  26941. res.Output.Setlinfo.Begndate = str3
  26942. res.Output.Setlinfo.Enddate = str5
  26943. res.Output.Setlinfo.Year = resah.Output.Setlinfo.Year
  26944. res.Output.Setlinfo.PsnPay = resah.Output.Setlinfo.PsnPay
  26945. res.Output.Setlinfo.OpterID = resah.Output.Setlinfo.OpterID
  26946. res.Output.Setlinfo.FlxempeFlag = resah.Output.Setlinfo.FlxempeFlag
  26947. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26948. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26949. res.Output.Setlinfo.AcctMulaidPay = resah.Output.Setlinfo.AcctMulaidPay
  26950. res.Output.Setlinfo.AcctPay = resah.Output.Setlinfo.AcctPay
  26951. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26952. res.Output.Setlinfo.ActPayDedc = resah.Output.Setlinfo.ActPayDedc
  26953. res.Output.Setlinfo.Age = resah.Output.Setlinfo.Age
  26954. res.Output.Setlinfo.Balc = resah.Output.Setlinfo.Balc
  26955. //res.Output.Setlinfo.Brdy = gzresSeven10265Two.Output.Setlinfo.Brdy
  26956. res.Output.Setlinfo.Certno = resah.Output.Setlinfo.Certno
  26957. res.Output.Setlinfo.ClrOptins = resah.Output.Setlinfo.ClrOptins
  26958. res.Output.Setlinfo.ClrType = resah.Output.Setlinfo.ClrOptins
  26959. res.Output.Setlinfo.ClrWay = resah.Output.Setlinfo.ClrOptins
  26960. res.Output.Setlinfo.CvlservFlag = resah.Output.Setlinfo.ClrOptins
  26961. res.Output.Setlinfo.CvlservPay = resah.Output.Setlinfo.CvlservPay
  26962. res.Output.Setlinfo.FulamtOwnpayAmt = resah.Output.Setlinfo.FulamtOwnpayAmt
  26963. res.Output.Setlinfo.FundPaySumamt = resah.Output.Setlinfo.FundPaySumamt
  26964. res.Output.Setlinfo.Gend = resah.Output.Setlinfo.Gend
  26965. res.Output.Setlinfo.HifesPay = resah.Output.Setlinfo.HifesPay
  26966. res.Output.Setlinfo.HifmiPay = resah.Output.Setlinfo.HifmiPay
  26967. res.Output.Setlinfo.HifpPay = resah.Output.Setlinfo.HifpPay
  26968. //HospPartAmt, _ := strconv.ParseFloat(gzresSeven10265Two.Output.Setlinfo.HospPartAmt, 64)
  26969. //res.Output.Setlinfo.HospPartAmt = resah.Output.Setlinfo.HospPartAmt
  26970. res.Output.Setlinfo.InscpScpAmt = resah.Output.Setlinfo.InscpScpAmt
  26971. res.Output.Setlinfo.Insutype = resah.Output.Setlinfo.Insutype
  26972. res.Output.Setlinfo.MafPay = resah.Output.Setlinfo.MafPay
  26973. //res.Output.Setlinfo.MdtrtCertType = ahres.Output.Setlinfo.MdtrtCertType
  26974. res.Output.Setlinfo.HifobPay = resah.Output.Setlinfo.HifobPay
  26975. res.Output.Setlinfo.MdtrtID = resah.Output.Setlinfo.MdtrtID
  26976. res.Output.Setlinfo.MedType = resah.Output.Setlinfo.MedType
  26977. res.Output.Setlinfo.MedfeeSumamt = resah.Output.Setlinfo.MedfeeSumamt
  26978. res.Output.Setlinfo.MedinsSetlID = resah.Output.Setlinfo.MedinsSetlID
  26979. res.Output.Setlinfo.Naty = resah.Output.Setlinfo.Naty
  26980. res.Output.Setlinfo.OthPay = resah.Output.Setlinfo.OthPay
  26981. res.Output.Setlinfo.OverlmtSelfpay = resah.Output.Setlinfo.OverlmtSelfpay
  26982. res.Output.Setlinfo.PoolPropSelfpay = resah.Output.Setlinfo.PoolPropSelfpay
  26983. res.Output.Setlinfo.PreselfpayAmt = resah.Output.Setlinfo.PreselfpayAmt
  26984. res.Output.Setlinfo.PsnCashPay = resah.Output.Setlinfo.PsnCashPay
  26985. res.Output.Setlinfo.PsnCertType = resah.Output.Setlinfo.ClrOptins
  26986. res.Output.Setlinfo.PsnName = resah.Output.Setlinfo.PsnName
  26987. res.Output.Setlinfo.PsnNo = resah.Output.Setlinfo.PsnNo
  26988. //res.Output.Setlinfo.PsnPartAmt = ahres.Output.Setlinfo.PsnPartAmt
  26989. res.Output.Setlinfo.PsnType = resah.Output.Setlinfo.PsnType
  26990. res.Output.Setlinfo.SetlID = resah.Output.Setlinfo.SetlID
  26991. //res.Output.Setldetail = resah.Output.Setldetail
  26992. res.ErrMsg = resah.ErrMsg
  26993. res.Cainfo = resah.Cainfo
  26994. res.WarnMsg = resah.WarnMsg
  26995. } else if miConfig.MdtrtareaAdmvs == "430800" {
  26996. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  26997. saveLog(result, requestLog, "5203", "结算单")
  26998. var dat map[string]interface{}
  26999. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27000. fmt.Println(dat)
  27001. } else {
  27002. fmt.Println(err)
  27003. }
  27004. userJSONBytes, _ := json.Marshal(dat)
  27005. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27006. utils.ErrorLog("解析失败:%v", err)
  27007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27008. return
  27009. }
  27010. } else if miConfig.MdtrtareaAdmvs == "150499" {
  27011. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27012. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27013. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27014. resp, requestErr := http.Get(api)
  27015. if requestErr != nil {
  27016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27017. return
  27018. }
  27019. body, ioErr := ioutil.ReadAll(resp.Body)
  27020. if ioErr != nil {
  27021. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27023. return
  27024. }
  27025. var respJSON map[string]interface{}
  27026. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27027. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27029. return
  27030. }
  27031. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27032. result, _ := json.Marshal(respJSON)
  27033. fmt.Println("log")
  27034. fmt.Println(string(result))
  27035. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  27036. utils.ErrorLog("解析失败:%v", err)
  27037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27038. return
  27039. }
  27040. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27041. res.Output = resEleven10265.Output
  27042. res.ErrMsg = resEleven10265.ErrMsg
  27043. res.Cainfo = resEleven10265.Cainfo
  27044. res.WarnMsg = resEleven10265.WarnMsg
  27045. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27046. res.Infcode = infocode
  27047. } else if miConfig.MdtrtareaAdmvs == "441799" {
  27048. api := miConfig.Url + "gdyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  27049. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  27050. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  27051. resp, requestErr := http.Get(api)
  27052. if requestErr != nil {
  27053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27054. return
  27055. }
  27056. body, ioErr := ioutil.ReadAll(resp.Body)
  27057. if ioErr != nil {
  27058. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27060. return
  27061. }
  27062. var respJSON map[string]interface{}
  27063. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27064. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27066. return
  27067. }
  27068. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27069. result, _ := json.Marshal(respJSON)
  27070. if err := json.Unmarshal([]byte(result), &res); err != nil {
  27071. utils.ErrorLog("解析失败:%v", err)
  27072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27073. return
  27074. }
  27075. } else if miConfig.MdtrtareaAdmvs == "450721" {
  27076. service.Gxyb9001(baseParams.OrgName, baseParams.Doctor, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, admin_user_id, order.SetlId, order.MdtrtId, order.PsnNo, order.MedinsSetlId)
  27077. //return
  27078. } else {
  27079. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  27080. if len(his.InsuplcAdmdvs) == 0 {
  27081. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  27082. } else {
  27083. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  27084. }
  27085. result := service.Gdyb5203(baseParams, businessParams)
  27086. //service.Gdyb5204(baseParams, businessParams)
  27087. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  27088. var dat map[string]interface{}
  27089. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27090. fmt.Println(dat)
  27091. } else {
  27092. fmt.Println(err)
  27093. }
  27094. userJSONBytes, _ := json.Marshal(dat)
  27095. if miConfig.Code == "H15049901371" {
  27096. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  27097. utils.ErrorLog("解析失败:%v", err)
  27098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27099. return
  27100. }
  27101. res.InfRefmsgid = resEleven10265.InfRefmsgid
  27102. res.Output = resEleven10265.Output
  27103. res.ErrMsg = resEleven10265.ErrMsg
  27104. res.Cainfo = resEleven10265.Cainfo
  27105. res.WarnMsg = resEleven10265.WarnMsg
  27106. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  27107. res.Infcode = infocode
  27108. } else {
  27109. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27110. utils.ErrorLog("解析失败:%v", err)
  27111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27112. return
  27113. }
  27114. }
  27115. }
  27116. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27117. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  27118. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  27119. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  27120. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  27121. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27122. var doctor_name string
  27123. if roles.ID == 0 {
  27124. doctor_name = "管理员"
  27125. } else {
  27126. doctor_name = roles.UserName
  27127. }
  27128. yiliao_leibie := ""
  27129. switch order.MedType {
  27130. case "11":
  27131. yiliao_leibie = "普通门诊"
  27132. break
  27133. case "12":
  27134. yiliao_leibie = "门诊挂号"
  27135. break
  27136. case "13":
  27137. yiliao_leibie = "急诊"
  27138. break
  27139. case "14":
  27140. yiliao_leibie = "门诊特殊病"
  27141. break
  27142. case "15":
  27143. yiliao_leibie = "门诊统筹"
  27144. break
  27145. case "16":
  27146. yiliao_leibie = "门诊慢性病"
  27147. break
  27148. case "21":
  27149. yiliao_leibie = "普通住院"
  27150. break
  27151. }
  27152. //var rf []CustomFundPay
  27153. //json.Unmarshal([]byte(order.SetlDetail), &rf)
  27154. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27155. res.Output.Setlinfo.PsnCashPay = order.PsnCashPay
  27156. if res.Infcode == 0 {
  27157. if adminUser.CurrentOrgId == 10215 || adminUser.CurrentOrgId == 10387 || adminUser.CurrentOrgId == 9919 || adminUser.CurrentOrgId == 10088 || adminUser.CurrentOrgId == 10150 || adminUser.CurrentOrgId == 10510 {
  27158. c.ServeSuccessJSON(map[string]interface{}{
  27159. "diagnosis": name,
  27160. "order_infos": orderInfos,
  27161. "number": order.MdtrtId,
  27162. "date": order.SettleAccountsDate,
  27163. "charge_admin": charge_admin,
  27164. "printor_admin": printor_admin,
  27165. "info": res.Output.Setlinfo,
  27166. "order": order,
  27167. "bedCostTotal": bedCostTotal,
  27168. "bedCostSelfTotal": bedCostSelfTotal,
  27169. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27170. "bedSelfTotal": bedSelfTotal,
  27171. "bedInscpTotal": bedInscpTotal,
  27172. "operationCostTotal": operationCostTotal,
  27173. "operationCostSelfTotal": operationCostSelfTotal,
  27174. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27175. "operationSelfTotal": operationSelfTotal,
  27176. "operationInscpTotal": operationInscpTotal,
  27177. "otherCostTotal": otherCostTotal,
  27178. "otherCostSelfTotal": otherCostSelfTotal,
  27179. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27180. "otherSelfTotal": otherSelfTotal,
  27181. "otherInscpTotal": otherInscpTotal,
  27182. "materialCostTotal": materialCostTotal,
  27183. "materialCostSelfTotal": materialCostSelfTotal,
  27184. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27185. "materialSelfTotal": materialSelfTotal,
  27186. "materialInscpTotal": materialInscpTotal,
  27187. "westernMedicineCostTotal": westernMedicineCostTotal,
  27188. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27189. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27190. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27191. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27192. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27193. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27194. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27195. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27196. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27197. "checkCostTotal": checkCostTotal,
  27198. "checkCostSelfTotal": checkCostSelfTotal,
  27199. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27200. "checkSelfTotal": checkSelfTotal,
  27201. "checkInscpTotal": checkInscpTotal,
  27202. "laboratoryCostTotal": laboratoryCostTotal,
  27203. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27204. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27205. "laboratorySelfTotal": laboratorySelfTotal,
  27206. "laboratoryInscpTotal": laboratoryInscpTotal,
  27207. "treatCostTotal": treatCostTotal,
  27208. "treatCostSelfTotal": treatCostSelfTotal,
  27209. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27210. "treatSelfTotal": treatSelfTotal,
  27211. "treatInscpTotal": treatInscpTotal,
  27212. "doctor_info": doctor_info,
  27213. "doctor_code": adminRole_two.DoctorCode,
  27214. "doctor_name": doctor_name,
  27215. "health_card_no": order.PsnNo,
  27216. "department": departments.Name,
  27217. "yiliao_leibie": yiliao_leibie,
  27218. "after_money": order.AccountPrice,
  27219. "patient": patient,
  27220. "org_name": miConfig.OrgName,
  27221. "org_code": miConfig.Code,
  27222. "order_number": order.Number,
  27223. "his_hospital": his_hospital,
  27224. "his": his,
  27225. "dia_config": dia_config,
  27226. "psn_cash_pay": order.PsnCashPay,
  27227. //"funds": rf,
  27228. //"check_order_info": cus_slice,
  27229. })
  27230. } else {
  27231. c.ServeSuccessJSON(map[string]interface{}{
  27232. "diagnosis": name,
  27233. "order_infos": orderInfos,
  27234. "number": order.MdtrtId,
  27235. "date": order.SettleAccountsDate,
  27236. "charge_admin": charge_admin,
  27237. "printor_admin": printor_admin,
  27238. "info": order,
  27239. "order": order,
  27240. "bedCostTotal": bedCostTotal,
  27241. "bedCostSelfTotal": bedCostSelfTotal,
  27242. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  27243. "bedSelfTotal": bedSelfTotal,
  27244. "bedInscpTotal": bedInscpTotal,
  27245. "operationCostTotal": operationCostTotal,
  27246. "operationCostSelfTotal": operationCostSelfTotal,
  27247. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  27248. "operationSelfTotal": operationSelfTotal,
  27249. "operationInscpTotal": operationInscpTotal,
  27250. "otherCostTotal": otherCostTotal,
  27251. "otherCostSelfTotal": otherCostSelfTotal,
  27252. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  27253. "otherSelfTotal": otherSelfTotal,
  27254. "otherInscpTotal": otherInscpTotal,
  27255. "materialCostTotal": materialCostTotal,
  27256. "materialCostSelfTotal": materialCostSelfTotal,
  27257. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  27258. "materialSelfTotal": materialSelfTotal,
  27259. "materialInscpTotal": materialInscpTotal,
  27260. "westernMedicineCostTotal": westernMedicineCostTotal,
  27261. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  27262. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  27263. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  27264. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  27265. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  27266. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  27267. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  27268. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  27269. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  27270. "checkCostTotal": checkCostTotal,
  27271. "checkCostSelfTotal": checkCostSelfTotal,
  27272. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  27273. "checkSelfTotal": checkSelfTotal,
  27274. "checkInscpTotal": checkInscpTotal,
  27275. "laboratoryCostTotal": laboratoryCostTotal,
  27276. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  27277. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  27278. "laboratorySelfTotal": laboratorySelfTotal,
  27279. "laboratoryInscpTotal": laboratoryInscpTotal,
  27280. "treatCostTotal": treatCostTotal,
  27281. "treatCostSelfTotal": treatCostSelfTotal,
  27282. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  27283. "treatSelfTotal": treatSelfTotal,
  27284. "treatInscpTotal": treatInscpTotal,
  27285. "doctor_info": doctor_info,
  27286. "doctor_code": adminRole_two.DoctorCode,
  27287. "doctor_name": doctor_name,
  27288. "health_card_no": order.PsnNo,
  27289. "department": departments.Name,
  27290. "yiliao_leibie": yiliao_leibie,
  27291. "after_money": order.AccountPrice,
  27292. "patient": patient,
  27293. "org_name": miConfig.OrgName,
  27294. "org_code": miConfig.Code,
  27295. "order_number": order.Number,
  27296. "his_hospital": his_hospital,
  27297. "his": his,
  27298. "dia_config": dia_config,
  27299. "psn_cash_pay": order.PsnCashPay,
  27300. //"funds": rf,
  27301. //"check_order_info": cus_slice,
  27302. })
  27303. }
  27304. }
  27305. }
  27306. }
  27307. //func (c *HisApiController) CheckTreatment() {
  27308. // patient_id, _ := c.GetInt64("patient_id")
  27309. // id_card_no := c.GetString("id_card_no")
  27310. // insutype := c.GetString("insutype")
  27311. // med_type := c.GetString("med_type")
  27312. // admin_user_id, _ := c.GetInt64("admin_user_id")
  27313. //
  27314. // adminUser := c.GetAdminUserInfo()
  27315. // patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  27316. //
  27317. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27318. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27319. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27320. //
  27321. // if miConfig.MdtrtareaAdmvs == "421300" {
  27322. // var res ResultTwo
  27323. // api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  27324. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27325. // "&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)
  27326. // resp, requestErr := http.Get(api)
  27327. // if requestErr != nil {
  27328. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27329. // return
  27330. // }
  27331. //
  27332. // body, ioErr := ioutil.ReadAll(resp.Body)
  27333. // if ioErr != nil {
  27334. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27336. // return
  27337. // }
  27338. // var respJSON map[string]interface{}
  27339. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27340. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27341. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27342. // return
  27343. // }
  27344. //
  27345. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27346. // result, _ := json.Marshal(respJSON)
  27347. //
  27348. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27349. // utils.ErrorLog("解析失败:%v", err)
  27350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27351. // return
  27352. // }
  27353. //
  27354. // if res.Infcode == 0 {
  27355. //
  27356. // api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  27357. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  27358. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  27359. // resp, requestErr := http.Get(api)
  27360. // if requestErr != nil {
  27361. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27362. // return
  27363. // }
  27364. //
  27365. // body, ioErr := ioutil.ReadAll(resp.Body)
  27366. // if ioErr != nil {
  27367. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27369. // return
  27370. // }
  27371. // var respJSON map[string]interface{}
  27372. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27373. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27374. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27375. // return
  27376. // }
  27377. // var res Result2001
  27378. //
  27379. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27380. // result2, _ := json.Marshal(respJSON)
  27381. //
  27382. // if err := json.Unmarshal([]byte(result2), &res); err != nil {
  27383. // utils.ErrorLog("解析失败:%v", err)
  27384. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27385. // return
  27386. // }
  27387. //
  27388. // if res.Infcode == 0 {
  27389. // c.ServeSuccessJSON(map[string]interface{}{
  27390. // "msg": res.Output.Trtinfo,
  27391. // })
  27392. // }
  27393. //
  27394. // } else {
  27395. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  27396. // return
  27397. // }
  27398. //
  27399. // } else {
  27400. //
  27401. // result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  27402. // var dat map[string]interface{}
  27403. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27404. // fmt.Println(dat)
  27405. // } else {
  27406. // fmt.Println(err)
  27407. // }
  27408. // userJSONBytes, _ := json.Marshal(dat)
  27409. // var res ResultTwo
  27410. // var res10265 ResultTwo10265
  27411. // if miConfig.Code == "H15049901371" {
  27412. // if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  27413. // utils.ErrorLog("解析失败:%v", err)
  27414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27415. // return
  27416. // }
  27417. // res.ErrMsg = res10265.ErrMsg
  27418. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27419. // res.Infcode = infocode
  27420. // res.Output = res10265.Output
  27421. // res.InfRefmsgid = res10265.InfRefmsgid
  27422. // } else {
  27423. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27424. // utils.ErrorLog("解析失败:%v", err)
  27425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27426. // return
  27427. // }
  27428. // }
  27429. //
  27430. // var user_name string
  27431. // role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  27432. // if role.ID == 0 {
  27433. // user_name = "xxx"
  27434. // } else {
  27435. // user_name = role.UserName
  27436. // }
  27437. //
  27438. // baseParams := models.BaseParams{
  27439. // SecretKey: miConfig.SecretKey,
  27440. // FixmedinsCode: miConfig.Code,
  27441. // InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27442. // MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27443. // OrgName: miConfig.OrgName,
  27444. // Doctor: user_name,
  27445. // }
  27446. //
  27447. // if config.IsOpen == 1 {
  27448. // if miConfig.Code == "H15049901371" {
  27449. // if med_type == "14" {
  27450. // if insutype == "390" {
  27451. // med_type = "9933"
  27452. // } else if insutype == "310" {
  27453. // med_type = "990502"
  27454. // }
  27455. // } else if med_type == "11" {
  27456. // med_type = "11"
  27457. // }
  27458. // }
  27459. // result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  27460. // var dat map[string]interface{}
  27461. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27462. // fmt.Println(dat)
  27463. // } else {
  27464. // fmt.Println(err)
  27465. // }
  27466. // var res Result2001
  27467. // var res10265 Result2001Org10265
  27468. // if miConfig.Code == "H15049901371" {
  27469. // if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  27470. // utils.ErrorLog("解析失败:%v", err)
  27471. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27472. // return
  27473. // }
  27474. // res.ErrMsg = res10265.ErrMsg
  27475. // res.Output = res10265.Output
  27476. // res.InfRefmsgid = res10265.InfRefmsgid
  27477. // infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  27478. // res.Infcode = infocode
  27479. // } else {
  27480. // if err := json.Unmarshal([]byte(result), &res); err != nil {
  27481. // utils.ErrorLog("解析失败:%v", err)
  27482. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27483. // return
  27484. // }
  27485. // }
  27486. // if res.Infcode == 0 {
  27487. // c.ServeSuccessJSON(map[string]interface{}{
  27488. // "msg": res.Output.Trtinfo,
  27489. // })
  27490. // }
  27491. // }
  27492. // }
  27493. //}
  27494. //func (c *HisApiController) PutRecord() {
  27495. // id, _ := c.GetInt64("id")
  27496. // record_time := c.GetString("record_time")
  27497. // timeLayout := "2006-01-02"
  27498. // loc, _ := time.LoadLocation("Local")
  27499. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27500. // if err != nil {
  27501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27502. // return
  27503. // }
  27504. // recordDateTime := theTime.Unix()
  27505. //
  27506. // adminInfo := c.GetAdminUserInfo()
  27507. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  27508. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27509. //
  27510. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27511. //
  27512. // fmt.Println(miConfig.SecretKey)
  27513. //
  27514. // if patient == nil {
  27515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  27516. // return
  27517. // }
  27518. // if len(patient.IdCardNo) == 0 {
  27519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  27520. // return
  27521. // }
  27522. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  27523. // if config.IsOpen == 1 {
  27524. // 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
  27525. // resp, requestErr := http.Get(api)
  27526. // if requestErr != nil {
  27527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27528. // return
  27529. // }
  27530. // defer resp.Body.Close()
  27531. // body, ioErr := ioutil.ReadAll(resp.Body)
  27532. // if ioErr != nil {
  27533. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  27534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27535. // return
  27536. // }
  27537. // var respJSON map[string]interface{}
  27538. //
  27539. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  27540. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27542. // return
  27543. // }
  27544. //
  27545. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27546. // userJSONBytes, _ := json.Marshal(userJSON)
  27547. // var res ResultTwo
  27548. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27549. // utils.ErrorLog("解析失败:%v", err)
  27550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27551. // return
  27552. // }
  27553. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  27554. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  27555. // infoStr := string(Iinfos)
  27556. // idetinfoStr := string(Idetinfos)
  27557. //
  27558. // if res.Infcode == 0 {
  27559. // his := models.VMHisPatient{
  27560. // Status: 1,
  27561. // Ctime: time.Now().Unix(),
  27562. // Mtime: time.Now().Unix(),
  27563. // PsnNo: res.Output.Baseinfo.PsnNo,
  27564. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  27565. // Certno: res.Output.Baseinfo.Certno,
  27566. // PsnName: res.Output.Baseinfo.PsnName,
  27567. // Gend: res.Output.Baseinfo.Gend,
  27568. // Naty: res.Output.Baseinfo.Naty,
  27569. // Brdy: res.Output.Baseinfo.Brdy,
  27570. // Age: res.Output.Baseinfo.Age,
  27571. // Iinfo: infoStr,
  27572. // Idetinfo: idetinfoStr,
  27573. // PatientId: patient.ID,
  27574. // RecordDate: theTime.Unix(),
  27575. // UserOrgId: adminInfo.CurrentOrgId,
  27576. // AdminUserId: adminInfo.AdminUser.Id,
  27577. // IsReturn: 1,
  27578. // }
  27579. //
  27580. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  27581. // //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")
  27582. // //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")
  27583. //
  27584. // //var dat map[string]interface{}
  27585. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27586. // // fmt.Println(dat)
  27587. // //} else {
  27588. // // fmt.Println(err)
  27589. // //}
  27590. //
  27591. // var dat2 map[string]interface{}
  27592. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  27593. // fmt.Println(dat2)
  27594. // } else {
  27595. // fmt.Println(err)
  27596. // }
  27597. //
  27598. // } else {
  27599. // adminUser := c.GetAdminUserInfo()
  27600. // errlog := &models.HisOrderError{
  27601. // UserOrgId: adminUser.CurrentOrgId,
  27602. // Ctime: time.Now().Unix(),
  27603. // Mtime: time.Now().Unix(),
  27604. // ErrMsg: res.ErrMsg,
  27605. // Status: 1,
  27606. // PatientId: id,
  27607. // RecordTime: recordDateTime,
  27608. // Stage: 1,
  27609. // }
  27610. // service.CreateErrMsgLog(errlog)
  27611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  27612. // return
  27613. // }
  27614. // }
  27615. //
  27616. //}
  27617. //func (c *HisApiController) GetUploadDiag() {
  27618. // id, _ := c.GetInt64("id")
  27619. // record_time := c.GetString("record_time")
  27620. //
  27621. // diagnosis_id, _ := c.GetInt64("diagnosis")
  27622. // sick_type, _ := c.GetInt64("sick_type")
  27623. // reg_type, _ := c.GetInt64("reg_type")
  27624. //
  27625. // timeLayout := "2006-01-02"
  27626. // loc, _ := time.LoadLocation("Local")
  27627. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  27628. // if err != nil {
  27629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  27630. // return
  27631. // }
  27632. //
  27633. // var patientPrescription models.HisPrescriptionInfo
  27634. // recordDateTime := theTime.Unix()
  27635. // adminInfo := c.GetAdminUserInfo()
  27636. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27637. //
  27638. // if patientPrescription.ID == 0 {
  27639. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27640. // }
  27641. //
  27642. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  27643. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  27644. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  27645. // sickConfig, _ := service.FindSickById(sick_type)
  27646. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  27647. //
  27648. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  27649. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  27650. // "&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 +
  27651. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  27652. // resp2, requestErr2 := http.Get(api2)
  27653. // if requestErr2 != nil {
  27654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27655. // return
  27656. // }
  27657. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  27658. // if ioErr2 != nil {
  27659. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  27660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27661. // return
  27662. // }
  27663. // var respJSON2 map[string]interface{}
  27664. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  27665. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  27666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27667. // return
  27668. // }
  27669. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  27670. // userJSONBytes2, _ := json.Marshal(respJSON2)
  27671. //
  27672. // var res2 ResultSix
  27673. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  27674. // utils.ErrorLog("解析失败:%v", err)
  27675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27676. // return
  27677. // }
  27678. // if res2.Infcode != 0 {
  27679. // adminUser := c.GetAdminUserInfo()
  27680. // errlog := &models.HisOrderError{
  27681. // UserOrgId: adminUser.CurrentOrgId,
  27682. // Ctime: time.Now().Unix(),
  27683. // Mtime: time.Now().Unix(),
  27684. // ErrMsg: res2.ErrMsg,
  27685. // Status: 1,
  27686. // PatientId: id,
  27687. // RecordTime: recordDateTime,
  27688. // Stage: 3,
  27689. // }
  27690. // service.CreateErrMsgLog(errlog)
  27691. //
  27692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  27693. // return
  27694. // }
  27695. //
  27696. // c.ServeSuccessJSON(map[string]interface{}{
  27697. // "msg": "上传成功",
  27698. // })
  27699. //
  27700. //}
  27701. type QueryResult struct {
  27702. ID int64
  27703. Name string
  27704. Code string
  27705. List_type_code string
  27706. }
  27707. func (c *HisApiController) GetCheckCode() {
  27708. ids_str := c.GetString("ids")
  27709. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27710. ids_arr := strings.Split(ids_str, ",")
  27711. var queryResult []QueryResult
  27712. ids := make([]int64, 0)
  27713. for _, item := range ids_arr {
  27714. id, _ := strconv.ParseInt(item, 10, 64)
  27715. ids = append(ids, id)
  27716. }
  27717. if record_type == 1 {
  27718. drugs, _ := service.GetBatchDrugList(ids)
  27719. for _, item := range drugs {
  27720. result := QueryResult{
  27721. ID: item.ID,
  27722. Name: item.DrugName,
  27723. Code: item.MedicalInsuranceNumber,
  27724. List_type_code: "101",
  27725. }
  27726. queryResult = append(queryResult, result)
  27727. }
  27728. } else if record_type == 2 {
  27729. goods, _ := service.GetBatchGoodInformationList(ids)
  27730. fmt.Println(goods)
  27731. for _, item := range goods {
  27732. result := QueryResult{
  27733. ID: item.ID,
  27734. Name: item.GoodName,
  27735. Code: item.SocialSecurityDirectoryCode,
  27736. List_type_code: "301",
  27737. }
  27738. queryResult = append(queryResult, result)
  27739. }
  27740. } else if record_type == 3 {
  27741. projects, _ := service.GetBathchMyPorjecgList(ids)
  27742. for _, item := range projects {
  27743. result := QueryResult{
  27744. ID: item.ID,
  27745. Name: item.ProjectName,
  27746. Code: item.MedicalCode,
  27747. List_type_code: "201",
  27748. }
  27749. queryResult = append(queryResult, result)
  27750. }
  27751. }
  27752. admin_user_id, _ := c.GetInt64("admin_user_id")
  27753. adminUser := c.GetAdminUserInfo()
  27754. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27755. //config, _ := /**/service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27756. var user_name string
  27757. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27758. if role.ID == 0 {
  27759. user_name = "管理员"
  27760. } else {
  27761. user_name = role.UserName
  27762. }
  27763. baseParams := models.BaseParams{
  27764. SecretKey: miConfig.SecretKey,
  27765. FixmedinsCode: miConfig.Code,
  27766. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27767. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27768. OrgName: miConfig.OrgName,
  27769. Doctor: user_name,
  27770. }
  27771. var result string
  27772. if miConfig.MdtrtareaAdmvs == "430800" {
  27773. for _, item := range queryResult {
  27774. if record_type == 1 {
  27775. 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)
  27776. } else if record_type == 2 {
  27777. fmt.Println(item.Code)
  27778. 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)
  27779. } else if record_type == 3 {
  27780. 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)
  27781. }
  27782. var dat map[string]interface{}
  27783. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27784. fmt.Println(dat)
  27785. } else {
  27786. fmt.Println(err)
  27787. }
  27788. userJSONBytes, _ := json.Marshal(dat)
  27789. var res ResultSix
  27790. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27791. utils.ErrorLog("解析失败:%v", err)
  27792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27793. return
  27794. }
  27795. if res.Infcode == 0 {
  27796. if record_type == 1 {
  27797. service.UpdateBaseDrugById(item.ID)
  27798. } else if record_type == 2 {
  27799. service.UpdateGoodInformaitonByDetail(item.ID)
  27800. } else if record_type == 3 {
  27801. service.UpdateProjectById(item.ID)
  27802. }
  27803. c.ServeSuccessJSON(map[string]interface{}{
  27804. "failed_code": 0,
  27805. "msg": "目录对照成功",
  27806. })
  27807. } else {
  27808. c.ServeSuccessJSON(map[string]interface{}{
  27809. "failed_code": -10,
  27810. "msg": res.ErrMsg,
  27811. })
  27812. }
  27813. }
  27814. } else {
  27815. for _, item := range queryResult {
  27816. var result string
  27817. if record_type == 1 {
  27818. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27819. } else if record_type == 2 {
  27820. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27821. } else if record_type == 3 {
  27822. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2023-04-26", "", item.List_type_code, admin_user_id)
  27823. }
  27824. var dat map[string]interface{}
  27825. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27826. fmt.Println(dat)
  27827. } else {
  27828. fmt.Println(err)
  27829. }
  27830. userJSONBytes, _ := json.Marshal(dat)
  27831. var res ResultSix
  27832. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27833. utils.ErrorLog("解析失败:%v", err)
  27834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27835. return
  27836. }
  27837. if res.Infcode == 0 {
  27838. if record_type == 1 {
  27839. service.UpdateBaseDrugById(item.ID)
  27840. } else if record_type == 2 {
  27841. service.UpdateGoodInformaitonByDetail(item.ID)
  27842. } else if record_type == 3 {
  27843. service.UpdateProjectById(item.ID)
  27844. }
  27845. c.ServeSuccessJSON(map[string]interface{}{
  27846. "failed_code": 0,
  27847. "msg": "目录对照成功",
  27848. })
  27849. } else {
  27850. c.ServeSuccessJSON(map[string]interface{}{
  27851. "failed_code": -10,
  27852. "msg": res.ErrMsg,
  27853. })
  27854. }
  27855. }
  27856. }
  27857. }
  27858. func (c *HisApiController) UnCheckCode() {
  27859. ids_str := c.GetString("ids")
  27860. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  27861. admin_user_id, _ := c.GetInt64("admin_user_id")
  27862. ids_arr := strings.Split(ids_str, ",")
  27863. var queryResult []QueryResult
  27864. ids := make([]int64, 0)
  27865. for _, item := range ids_arr {
  27866. id, _ := strconv.ParseInt(item, 10, 64)
  27867. ids = append(ids, id)
  27868. }
  27869. if record_type == 1 {
  27870. drugs, _ := service.GetBatchDrugList(ids)
  27871. for _, item := range drugs {
  27872. result := QueryResult{
  27873. ID: item.ID,
  27874. Name: item.DrugName,
  27875. Code: item.MedicalInsuranceNumber,
  27876. List_type_code: "101",
  27877. }
  27878. queryResult = append(queryResult, result)
  27879. }
  27880. } else if record_type == 2 {
  27881. goods, _ := service.GetBatchGoodInformationList(ids)
  27882. for _, item := range goods {
  27883. result := QueryResult{
  27884. ID: item.ID,
  27885. Name: item.GoodName,
  27886. Code: item.SocialSecurityDirectoryCode,
  27887. List_type_code: "301",
  27888. }
  27889. queryResult = append(queryResult, result)
  27890. }
  27891. } else if record_type == 3 {
  27892. projects, _ := service.GetBathchMyPorjecgList(ids)
  27893. for _, item := range projects {
  27894. result := QueryResult{
  27895. ID: item.ID,
  27896. Name: item.ProjectName,
  27897. Code: item.MedicalCode,
  27898. List_type_code: "201",
  27899. }
  27900. queryResult = append(queryResult, result)
  27901. }
  27902. }
  27903. adminUser := c.GetAdminUserInfo()
  27904. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  27905. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  27906. var user_name string
  27907. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  27908. if role.ID == 0 {
  27909. user_name = "xxx"
  27910. } else {
  27911. user_name = role.UserName
  27912. }
  27913. baseParams := &models.BaseParams{
  27914. SecretKey: miConfig.SecretKey,
  27915. FixmedinsCode: miConfig.Code,
  27916. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  27917. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  27918. OrgName: miConfig.OrgName,
  27919. Doctor: user_name,
  27920. }
  27921. if config.IsOpen == 1 {
  27922. if miConfig.MdtrtareaAdmvs == "430800" {
  27923. for _, item := range queryResult {
  27924. var result string
  27925. if record_type == 1 {
  27926. 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)
  27927. } else if record_type == 2 {
  27928. fmt.Println(item.Code)
  27929. 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)
  27930. } else if record_type == 3 {
  27931. 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)
  27932. }
  27933. var dat map[string]interface{}
  27934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  27935. fmt.Println(dat)
  27936. } else {
  27937. fmt.Println(err)
  27938. }
  27939. userJSONBytes, _ := json.Marshal(dat)
  27940. var res ResultSix
  27941. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27942. utils.ErrorLog("解析失败:%v", err)
  27943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27944. return
  27945. }
  27946. if res.Infcode == 0 {
  27947. if record_type == 1 {
  27948. service.UpdateBaseDrugById(item.ID)
  27949. } else if record_type == 2 {
  27950. service.UpdateGoodInformaitonByDetail(item.ID)
  27951. } else if record_type == 3 {
  27952. service.UpdateProjectById(item.ID)
  27953. }
  27954. c.ServeSuccessJSON(map[string]interface{}{
  27955. "failed_code": 0,
  27956. "msg": "目录对照成功",
  27957. })
  27958. } else {
  27959. c.ServeSuccessJSON(map[string]interface{}{
  27960. "failed_code": -10,
  27961. "msg": res.ErrMsg,
  27962. })
  27963. }
  27964. }
  27965. } else {
  27966. for _, item := range queryResult {
  27967. var result string
  27968. if record_type == 1 {
  27969. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27970. } else if record_type == 2 {
  27971. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27972. } else if record_type == 3 {
  27973. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  27974. }
  27975. var dat2 map[string]interface{}
  27976. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  27977. fmt.Println(dat2)
  27978. } else {
  27979. fmt.Println(err)
  27980. }
  27981. userJSONBytes, _ := json.Marshal(dat2)
  27982. var res ResultSix
  27983. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  27984. utils.ErrorLog("解析失败:%v", err)
  27985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  27986. return
  27987. }
  27988. if res.Infcode == 0 {
  27989. if record_type == 1 {
  27990. service.UpdateDrugByIdDetail(item.ID)
  27991. } else if record_type == 2 {
  27992. service.UpdateGoodInfoById(item.ID)
  27993. } else if record_type == 3 {
  27994. service.UpdateMyProjectById(item.ID)
  27995. }
  27996. c.ServeSuccessJSON(map[string]interface{}{
  27997. "failed_code": 0,
  27998. "msg": "撤销目录对照成功",
  27999. })
  28000. } else {
  28001. c.ServeSuccessJSON(map[string]interface{}{
  28002. "failed_code": -10,
  28003. "msg": res.ErrMsg,
  28004. })
  28005. }
  28006. }
  28007. }
  28008. }
  28009. }
  28010. func (c *HisApiController) GetPatientInfo() {
  28011. id_card_no := c.GetString("id_card_no")
  28012. admin_user_id, _ := c.GetInt64("admin_user_id")
  28013. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  28014. if patient.ID == 0 {
  28015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  28016. return
  28017. }
  28018. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  28019. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  28020. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  28021. var res ResultTwo
  28022. var res10265 ResultTwo10265
  28023. if config.IsOpen == 1 {
  28024. if miConfig.MdtrtareaAdmvs == "150499" {
  28025. //请求内网数据
  28026. api := "http://172.16.13.254:9532/" + "nmyb/1101?cert_no=" + patient.IdCardNo +
  28027. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28028. "&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
  28029. resp, requestErr := http.Get(api)
  28030. if requestErr != nil {
  28031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28032. return
  28033. }
  28034. body, ioErr := ioutil.ReadAll(resp.Body)
  28035. if ioErr != nil {
  28036. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28038. return
  28039. }
  28040. var respJSON map[string]interface{}
  28041. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28042. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28044. return
  28045. }
  28046. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28047. result_byte, _ := json.Marshal(respJSON)
  28048. result := string(result_byte)
  28049. var dat map[string]interface{}
  28050. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28051. fmt.Println(dat)
  28052. } else {
  28053. fmt.Println(err)
  28054. }
  28055. userJSONBytes, _ := json.Marshal(dat)
  28056. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28057. utils.ErrorLog("解析失败:%v", err)
  28058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28059. return
  28060. }
  28061. Infcode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28062. res.Infcode = Infcode
  28063. res.ErrMsg = res10265.ErrMsg
  28064. res.Output = res10265.Output
  28065. res.InfRefmsgid = res10265.InfRefmsgid
  28066. res.RespondTime = res10265.RespondTime
  28067. res.WarnInfo = res10265.WarnInfo
  28068. } else {
  28069. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  28070. var dat map[string]interface{}
  28071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28072. fmt.Println(dat)
  28073. } else {
  28074. fmt.Println(err)
  28075. }
  28076. userJSONBytes, _ := json.Marshal(dat)
  28077. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28078. utils.ErrorLog("解析失败:%v", err)
  28079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28080. return
  28081. }
  28082. }
  28083. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28084. // utils.ErrorLog("解析失败:%v", err)
  28085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28086. // return
  28087. //}
  28088. for index, item := range res.Output.Iinfo {
  28089. if item.PsnInsuStas == "2" {
  28090. fmt.Println("--------")
  28091. res.Output.Iinfo[index].Insutype = "300"
  28092. res.Output.Iinfo[index].PsnInsuStas = "1"
  28093. }
  28094. }
  28095. fmt.Println(res.Output.Iinfo)
  28096. if res.Infcode != 0 {
  28097. c.ServeSuccessJSON(map[string]interface{}{
  28098. "failed_code": -10,
  28099. "msg": res.ErrMsg,
  28100. })
  28101. } else {
  28102. c.ServeSuccessJSON(map[string]interface{}{
  28103. "failed_code": 0,
  28104. "info": res,
  28105. })
  28106. }
  28107. }
  28108. }
  28109. func (c *HisApiController) PsnPutOnRecord() {
  28110. record_type, _ := c.GetInt64("type")
  28111. patient_id, _ := c.GetInt64("patient_id")
  28112. admin_user_id, _ := c.GetInt64("admin_user_id")
  28113. start_time := c.GetString("start_time")
  28114. end_time := c.GetString("end_time")
  28115. adminUser := c.GetAdminUserInfo()
  28116. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28118. var patients []*models.Patients
  28119. if record_type == 1 { //全部备案
  28120. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  28121. patients = append(patients, patient...)
  28122. } else { //单个备案
  28123. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28124. patients = append(patients, patient)
  28125. }
  28126. var user_name string
  28127. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28128. if role.ID == 0 {
  28129. user_name = "xxx"
  28130. } else {
  28131. user_name = role.UserName
  28132. }
  28133. if config.IsOpen == 1 {
  28134. for _, item := range patients {
  28135. 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
  28136. resp, requestErr := http.Get(api)
  28137. if requestErr != nil {
  28138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28139. return
  28140. }
  28141. defer resp.Body.Close()
  28142. body, ioErr := ioutil.ReadAll(resp.Body)
  28143. if ioErr != nil {
  28144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28146. return
  28147. }
  28148. var respJSON map[string]interface{}
  28149. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28152. return
  28153. }
  28154. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28155. userJSONBytes, _ := json.Marshal(userJSON)
  28156. var res ResultTwo
  28157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28158. utils.ErrorLog("解析失败:%v", err)
  28159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28160. return
  28161. }
  28162. if res.Infcode == 0 {
  28163. 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)
  28164. var dat map[string]interface{}
  28165. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28166. fmt.Println(dat)
  28167. } else {
  28168. fmt.Println(err)
  28169. }
  28170. userJSONBytes, _ := json.Marshal(dat)
  28171. var res2 ResultThirteen
  28172. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28173. utils.ErrorLog("解析失败:%v", err)
  28174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28175. return
  28176. }
  28177. if res2.Infcode == 0 {
  28178. psnResult := &models.GdybPsnRecord{
  28179. UserOrgId: adminUser.CurrentOrgId,
  28180. PatientId: item.ID,
  28181. PsnNo: res.Output.Baseinfo.PsnNo,
  28182. Ctime: time.Now().Unix(),
  28183. Mtime: time.Now().Unix(),
  28184. Status: 1,
  28185. IsCancel: 1,
  28186. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28187. }
  28188. service.CreatePsnRecord(psnResult)
  28189. } else {
  28190. c.ServeSuccessJSON(map[string]interface{}{
  28191. "failed_code": -10,
  28192. "msg": res2.ErrMsg,
  28193. })
  28194. return
  28195. }
  28196. }
  28197. }
  28198. }
  28199. }
  28200. func (c *HisApiController) PsnUnPutOnRecord() {
  28201. id, _ := c.GetInt64("id")
  28202. //record_type, _ := c.GetInt64("type")
  28203. admin_user_id, _ := c.GetInt64("admin_user_id")
  28204. adminUser := c.GetAdminUserInfo()
  28205. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28206. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28207. var user_name string
  28208. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28209. if role.ID == 0 {
  28210. user_name = "xxx"
  28211. } else {
  28212. user_name = role.UserName
  28213. }
  28214. psn_record, _ := service.GetPsnRecordById(id)
  28215. if psn_record.ID == 0 {
  28216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28217. return
  28218. }
  28219. if config.IsOpen == 1 {
  28220. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28221. var dat map[string]interface{}
  28222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28223. fmt.Println(dat)
  28224. } else {
  28225. fmt.Println(err)
  28226. }
  28227. userJSONBytes, _ := json.Marshal(dat)
  28228. var res ResultFourteen
  28229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28230. utils.ErrorLog("解析失败:%v", err)
  28231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28232. return
  28233. }
  28234. if res.Infcode == 0 {
  28235. psn_record.IsCancel = 2
  28236. service.CreatePsnRecord(&psn_record)
  28237. } else {
  28238. c.ServeSuccessJSON(map[string]interface{}{
  28239. "failed_code": -10,
  28240. "msg": res.ErrMsg,
  28241. })
  28242. return
  28243. }
  28244. }
  28245. }
  28246. func (c *HisApiController) PsnPutNCDSOnRecord() {
  28247. patient_id, _ := c.GetInt64("patient_id")
  28248. insutype_two := c.GetString("insutype")
  28249. psn_no := c.GetString("psn_no")
  28250. doctor_id, _ := c.GetInt64("doctor_id")
  28251. sick_id, _ := c.GetInt64("sick_id")
  28252. department_id, _ := c.GetInt64("department_id")
  28253. start_time := c.GetString("start_time")
  28254. end_time := c.GetString("end_time")
  28255. check_time := c.GetString("check_time")
  28256. hospital_code := c.GetString("hospital_code")
  28257. hospital_name := c.GetString("hospital_name")
  28258. adminUser := c.GetAdminUserInfo()
  28259. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  28260. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28261. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28262. sick, _ := service.FindSickById(sick_id)
  28263. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28264. if len(hospital_code) == 0 {
  28265. hospital_code = miConfig.Code
  28266. }
  28267. if len(hospital_name) == 0 {
  28268. hospital_name = miConfig.OrgName
  28269. }
  28270. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  28271. var res ResultTwo
  28272. var res10265 ResultTwo10265
  28273. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28274. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  28275. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  28276. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28277. "&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
  28278. resp, requestErr := http.Get(api)
  28279. if requestErr != nil {
  28280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28281. return
  28282. }
  28283. body, ioErr := ioutil.ReadAll(resp.Body)
  28284. if ioErr != nil {
  28285. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28287. return
  28288. }
  28289. var respJSON map[string]interface{}
  28290. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28291. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28293. return
  28294. }
  28295. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28296. result, _ := json.Marshal(respJSON)
  28297. fmt.Println("log")
  28298. fmt.Println(string(result))
  28299. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28300. utils.ErrorLog("解析失败:%v", err)
  28301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28302. return
  28303. }
  28304. res.ErrMsg = res10265.ErrMsg
  28305. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28306. res.Infcode = infocode
  28307. res.Output = res10265.Output
  28308. res.InfRefmsgid = res10265.InfRefmsgid
  28309. } else {
  28310. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28311. if miConfig.Code == "H15049901371" {
  28312. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28313. utils.ErrorLog("解析失败:%v", err)
  28314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28315. return
  28316. }
  28317. res.ErrMsg = res10265.ErrMsg
  28318. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28319. res.Infcode = infocode
  28320. res.Output = res10265.Output
  28321. res.InfRefmsgid = res10265.InfRefmsgid
  28322. } else {
  28323. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28324. utils.ErrorLog("解析失败:%v", err)
  28325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28326. return
  28327. }
  28328. }
  28329. }
  28330. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28331. infoStr := string(Iinfos)
  28332. var rf []*ResultFive
  28333. json.Unmarshal([]byte(infoStr), &rf)
  28334. var insuplc_admdvs string
  28335. var insutype string
  28336. var is390 int = 0
  28337. var is310 int = 0
  28338. var insutypes []*ResultFive
  28339. for _, item := range rf {
  28340. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28341. insutypes = append(insutypes, item)
  28342. }
  28343. }
  28344. if len(insutypes) == 1 {
  28345. insutype = insutypes[0].Insutype
  28346. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28347. } else {
  28348. for _, i := range insutypes {
  28349. if i.Insutype == "390" {
  28350. is390 = 1
  28351. }
  28352. if i.Insutype == "310" {
  28353. is310 = 1
  28354. }
  28355. }
  28356. }
  28357. if is390 == 1 {
  28358. insutype = "390"
  28359. }
  28360. if is310 == 1 {
  28361. insutype = "310"
  28362. }
  28363. if len(insutypes) == 2 {
  28364. insutype = insutype_two
  28365. }
  28366. if len(insutypes) == 0 {
  28367. insutype = "310"
  28368. }
  28369. insutype = insutype_two
  28370. fmt.Println(insutype)
  28371. for _, item := range rf {
  28372. fmt.Println(item.Insutype)
  28373. fmt.Println(insutype)
  28374. if item.Insutype == insutype {
  28375. fmt.Println(item.Insutype)
  28376. fmt.Println(insutype)
  28377. insuplc_admdvs = item.InsuplcAdmdvs
  28378. }
  28379. }
  28380. fmt.Println(insuplc_admdvs)
  28381. var res2 ResultThirteen
  28382. var res10265_2 ResultThirteen10265
  28383. if config.IsOpen == 1 {
  28384. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  28385. } else {
  28386. if miConfig.MdtrtareaAdmvs == "150499" {
  28387. //
  28388. //api := "http://172.16.13.254:9532/" + "nmyb/2503?psn_no=" + psn_no + "&insutype=" + insutype + "sick_name" + sick.ClassName + "&sick_code=" + sick.CountryCode +
  28389. // "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  28390. // "&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
  28391. //resp, requestErr := http.Get(api)
  28392. //if requestErr != nil {
  28393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28394. // return
  28395. //}
  28396. //
  28397. //body, ioErr := ioutil.ReadAll(resp.Body)
  28398. //if ioErr != nil {
  28399. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  28400. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28401. // return
  28402. //}
  28403. //var respJSON map[string]interface{}
  28404. //if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  28405. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  28406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28407. // return
  28408. //}
  28409. //
  28410. //respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  28411. //result, _ := json.Marshal(respJSON)
  28412. //if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  28413. // utils.ErrorLog("解析失败:%v", err)
  28414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28415. // return
  28416. //}
  28417. //infocode = resThree.Infcode
  28418. //result, _ := json.Marshal(respJSON)
  28419. //if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  28420. // utils.ErrorLog("解析失败:%v", err)
  28421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28422. // return
  28423. //}
  28424. //
  28425. //resThree.ErrMsg = resThree10265.ErrMsg
  28426. //
  28427. //resThree.Output = resThree10265.Output
  28428. //
  28429. //resThree.InfRefmsgid = resThree10265.InfRefmsgid
  28430. //
  28431. //infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  28432. //
  28433. } else {
  28434. 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)
  28435. var dat map[string]interface{}
  28436. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28437. fmt.Println(dat)
  28438. } else {
  28439. fmt.Println(err)
  28440. }
  28441. userJSONBytes, _ := json.Marshal(dat)
  28442. if miConfig.Code == "H15049901371" {
  28443. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  28444. utils.ErrorLog("解析失败:%v", err)
  28445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28446. return
  28447. }
  28448. res2.ErrMsg = res10265_2.ErrMsg
  28449. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  28450. res2.Infcode = infocode
  28451. res2.Output = res10265_2.Output
  28452. res2.InfRefmsgid = res10265_2.InfRefmsgid
  28453. } else {
  28454. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  28455. utils.ErrorLog("解析失败:%v", err)
  28456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28457. return
  28458. }
  28459. }
  28460. }
  28461. }
  28462. if res2.Infcode == 0 {
  28463. psnResult := &models.GdybPsnNcdsRecord{
  28464. UserOrgId: adminUser.CurrentOrgId,
  28465. PatientId: patient.ID,
  28466. PsnNo: psn_no,
  28467. DoctorId: doctor.AdminUserId,
  28468. DepartmentId: department_id,
  28469. SickType: sick_id,
  28470. Insutype: insutype,
  28471. Ctime: time.Now().Unix(),
  28472. Mtime: time.Now().Unix(),
  28473. Status: 1,
  28474. IsCancel: 1,
  28475. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  28476. }
  28477. service.CreatePsnNCDSRecord(psnResult)
  28478. c.ServeSuccessJSON(map[string]interface{}{
  28479. "failed_code": 0,
  28480. "msg": "备案成功",
  28481. "result": psnResult,
  28482. })
  28483. } else {
  28484. c.ServeSuccessJSON(map[string]interface{}{
  28485. "failed_code": -10,
  28486. "msg": res2.ErrMsg,
  28487. })
  28488. return
  28489. }
  28490. }
  28491. }
  28492. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  28493. id, _ := c.GetInt64("id")
  28494. admin_user_id, _ := c.GetInt64("admin_user_id")
  28495. adminUser := c.GetAdminUserInfo()
  28496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28497. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  28498. //config, _ := service.Ge(adminUser.CurrentOrgId)
  28499. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  28500. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28501. //var user_name string
  28502. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28503. //if role.ID == 0 {
  28504. // user_name = "xxx"
  28505. //} else {
  28506. // user_name = role.UserName
  28507. //}
  28508. psn_record, _ := service.GetPsnNCDSRecordById(id)
  28509. if psn_record.ID == 0 {
  28510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  28511. return
  28512. }
  28513. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  28514. var res ResultTwo
  28515. var res10265 ResultTwo10265
  28516. if miConfig.Code == "H15049901371" {
  28517. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  28518. utils.ErrorLog("解析失败:%v", err)
  28519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28520. return
  28521. }
  28522. res.ErrMsg = res10265.ErrMsg
  28523. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28524. res.Infcode = infocode
  28525. res.Output = res10265.Output
  28526. res.InfRefmsgid = res10265.InfRefmsgid
  28527. } else {
  28528. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28529. utils.ErrorLog("解析失败:%v", err)
  28530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28531. return
  28532. }
  28533. }
  28534. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  28535. infoStr := string(Iinfos)
  28536. var rf []*ResultFive
  28537. json.Unmarshal([]byte(infoStr), &rf)
  28538. var insuplc_admdvs string
  28539. var insutype string
  28540. var is390 int = 0
  28541. var is310 int = 0
  28542. var insutypes []*ResultFive
  28543. for _, item := range rf {
  28544. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  28545. insutypes = append(insutypes, item)
  28546. }
  28547. }
  28548. if len(insutypes) == 1 {
  28549. insutype = insutypes[0].Insutype
  28550. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  28551. } else {
  28552. for _, i := range insutypes {
  28553. if i.Insutype == "390" {
  28554. is390 = 1
  28555. }
  28556. if i.Insutype == "310" {
  28557. is310 = 1
  28558. }
  28559. }
  28560. }
  28561. if is390 == 1 {
  28562. insutype = "390"
  28563. }
  28564. if is310 == 1 {
  28565. insutype = "310"
  28566. }
  28567. if len(insutypes) == 0 {
  28568. insutype = "310"
  28569. }
  28570. insutype = psn_record.Insutype
  28571. for _, item := range rf {
  28572. if item.Insutype == insutype {
  28573. insuplc_admdvs = item.InsuplcAdmdvs
  28574. }
  28575. }
  28576. if config.IsOpen == 1 {
  28577. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  28578. var dat map[string]interface{}
  28579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28580. fmt.Println(dat)
  28581. } else {
  28582. fmt.Println(err)
  28583. }
  28584. userJSONBytes, _ := json.Marshal(dat)
  28585. var res ResultFourteen
  28586. var res10265 ResultFourteen10265
  28587. if miConfig.Code == "H15049901371" {
  28588. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  28589. utils.ErrorLog("解析失败:%v", err)
  28590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28591. return
  28592. }
  28593. res.ErrMsg = res10265.ErrMsg
  28594. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  28595. res.Infcode = infocode
  28596. res.Output = res10265.Output
  28597. res.InfRefmsgid = res10265.InfRefmsgid
  28598. } else {
  28599. if err := json.Unmarshal([]byte(result), &res); err != nil {
  28600. utils.ErrorLog("解析失败:%v", err)
  28601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28602. return
  28603. }
  28604. }
  28605. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28606. // utils.ErrorLog("解析失败:%v", err)
  28607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28608. // return
  28609. //}
  28610. if res.Infcode == 0 {
  28611. psn_record.IsCancel = 2
  28612. service.CreatePsnNCDSRecord(&psn_record)
  28613. c.ServeSuccessJSON(map[string]interface{}{
  28614. "failed_code": 0,
  28615. "msg": "撤销备案成功",
  28616. })
  28617. } else {
  28618. c.ServeSuccessJSON(map[string]interface{}{
  28619. "failed_code": -10,
  28620. "msg": res.ErrMsg,
  28621. })
  28622. return
  28623. }
  28624. }
  28625. }
  28626. func (c *HisApiController) TestTest() {
  28627. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  28628. fmt.Println(patient.Iinfo)
  28629. }
  28630. type CustomData struct {
  28631. MsgId string
  28632. PsnNo string
  28633. Info string
  28634. }
  28635. func (c *HisApiController) ReversalData() {
  28636. var customData []*CustomData
  28637. custom := &CustomData{
  28638. MsgId: "H44022900158202103301714472004",
  28639. PsnNo: "44020000001101329945",
  28640. Info: "2207",
  28641. }
  28642. customData = append(customData, custom)
  28643. custom1 := &CustomData{
  28644. MsgId: "H4402290015820210330172057803",
  28645. PsnNo: "44020000001101161813",
  28646. Info: "2207",
  28647. }
  28648. customData = append(customData, custom1)
  28649. custom2 := &CustomData{
  28650. MsgId: "H44022900158202103301705198813",
  28651. PsnNo: "44190000133097375417",
  28652. Info: "2207",
  28653. }
  28654. customData = append(customData, custom2)
  28655. custom3 := &CustomData{
  28656. MsgId: "H44022900158202103301715524756",
  28657. PsnNo: "44020000001100187221",
  28658. Info: "2207",
  28659. }
  28660. customData = append(customData, custom3)
  28661. custom4 := &CustomData{
  28662. MsgId: "H44022900158202103301730376224",
  28663. PsnNo: "44020000001101959155",
  28664. Info: "2207",
  28665. }
  28666. customData = append(customData, custom4)
  28667. custom5 := &CustomData{
  28668. MsgId: "H44022900158202103301748008725",
  28669. PsnNo: "44020000001104246641",
  28670. Info: "2207",
  28671. }
  28672. customData = append(customData, custom5)
  28673. custom6 := &CustomData{
  28674. MsgId: "H44022900158202103301718096755",
  28675. PsnNo: "44020000001102211860",
  28676. Info: "2207",
  28677. }
  28678. customData = append(customData, custom6)
  28679. custom7 := &CustomData{
  28680. MsgId: "H44022900158202103301736551640",
  28681. PsnNo: "44020000001102687718",
  28682. Info: "2207",
  28683. }
  28684. customData = append(customData, custom7)
  28685. custom8 := &CustomData{
  28686. MsgId: "H44022900158202103301743097676",
  28687. PsnNo: "44020000001102127785",
  28688. Info: "2207",
  28689. }
  28690. customData = append(customData, custom8)
  28691. custom9 := &CustomData{
  28692. MsgId: "H44022900158202103301712304203",
  28693. PsnNo: "44020000001101518097",
  28694. Info: "2207",
  28695. }
  28696. customData = append(customData, custom9)
  28697. custom10 := &CustomData{
  28698. MsgId: "H44022900158202103301738448785",
  28699. PsnNo: "44020000001100500813",
  28700. Info: "2207",
  28701. }
  28702. customData = append(customData, custom10)
  28703. custom11 := &CustomData{
  28704. MsgId: "H44022900158202103301732455843",
  28705. PsnNo: "44020000001102690557",
  28706. Info: "2207",
  28707. }
  28708. customData = append(customData, custom11)
  28709. custom12 := &CustomData{
  28710. MsgId: "H44022900158202103301745421708",
  28711. PsnNo: "44020000001102211928",
  28712. Info: "2207",
  28713. }
  28714. customData = append(customData, custom12)
  28715. custom1212 := &CustomData{
  28716. MsgId: "H440229001582021033017351627",
  28717. PsnNo: "44020000001102481733",
  28718. Info: "2207",
  28719. }
  28720. customData = append(customData, custom1212)
  28721. custom13 := &CustomData{
  28722. MsgId: "H44022900158202103301740327951",
  28723. PsnNo: "44020000001103174866",
  28724. Info: "2207",
  28725. }
  28726. customData = append(customData, custom13)
  28727. custom14 := &CustomData{
  28728. MsgId: "H4402290015820210330174922668",
  28729. PsnNo: "44020000001102927272",
  28730. Info: "2207",
  28731. }
  28732. customData = append(customData, custom14)
  28733. custom15 := &CustomData{
  28734. MsgId: "H44022900158202103301752362273",
  28735. PsnNo: "44020000001102942890",
  28736. Info: "2207",
  28737. }
  28738. customData = append(customData, custom15)
  28739. custom16 := &CustomData{
  28740. MsgId: "H44022900158202103301751082917",
  28741. PsnNo: "44020000001101662162",
  28742. Info: "2207",
  28743. }
  28744. customData = append(customData, custom16)
  28745. custom17 := &CustomData{
  28746. MsgId: "H44022900158202103301754147728",
  28747. PsnNo: "44020000000229014511",
  28748. Info: "2207",
  28749. }
  28750. customData = append(customData, custom17)
  28751. adminUser := c.GetAdminUserInfo()
  28752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28753. for _, item := range customData {
  28754. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  28755. fmt.Println(result)
  28756. }
  28757. }
  28758. func (c *HisApiController) GetAllopatry() {
  28759. year := c.GetString("year")
  28760. month := c.GetString("month")
  28761. admin_user_id, _ := c.GetInt64("admin_user_id")
  28762. adminUser := c.GetAdminUserInfo()
  28763. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28765. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28766. var dat map[string]interface{}
  28767. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28768. fmt.Println(dat)
  28769. } else {
  28770. fmt.Println(err)
  28771. }
  28772. userJSONBytes, _ := json.Marshal(dat)
  28773. var res models.Result9001
  28774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28775. utils.ErrorLog("解析失败:%v", err)
  28776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28777. return
  28778. }
  28779. fmt.Println(res.Output.Signinoutb)
  28780. fmt.Println(res.Output.Signinoutb.SignNo)
  28781. fmt.Println(string(userJSONBytes))
  28782. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28783. var dat3 map[string]interface{}
  28784. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  28785. fmt.Println(dat3)
  28786. } else {
  28787. fmt.Println(err)
  28788. }
  28789. userJSONBytes3, _ := json.Marshal(dat3)
  28790. var res3 models.Result3260
  28791. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  28792. utils.ErrorLog("解析失败:%v", err)
  28793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28794. return
  28795. }
  28796. var curpage int
  28797. var pagesize int = 100
  28798. var start int = 1
  28799. //var stop int
  28800. //pagecount := 10
  28801. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  28802. var res22 []models.Result3260
  28803. for curpage = 1; curpage <= pagecount; curpage++ {
  28804. if curpage == 1 {
  28805. start = 0
  28806. } else {
  28807. start = (curpage-1)*pagesize + 1
  28808. }
  28809. fmt.Println(start)
  28810. //stop = curpage * pagesize
  28811. //if stop > int(res3.Output.Totalrow) {
  28812. // stop =int(res3.Output.Totalrow)
  28813. //}
  28814. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  28815. var dat2 map[string]interface{}
  28816. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28817. fmt.Println(dat)
  28818. } else {
  28819. fmt.Println(err)
  28820. }
  28821. userJSONBytes2, _ := json.Marshal(dat2)
  28822. var res2 models.Result3260
  28823. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28824. utils.ErrorLog("解析失败:%v", err)
  28825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28826. return
  28827. }
  28828. if res2.Infcode == 0 {
  28829. res22 = append(res22, res2)
  28830. //service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28831. //var dat2 map[string]interface{}
  28832. //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28833. // fmt.Println(dat)
  28834. //} else {
  28835. // fmt.Println(err)
  28836. //}
  28837. //c.ServeSuccessJSON(map[string]interface{}{
  28838. // "list": res2.Output.Data,
  28839. //})
  28840. //continue
  28841. }
  28842. }
  28843. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28844. //service.Gdyb3263(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res22, res.Output.Signinoutb.SignNo)
  28845. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  28846. //var dat2 map[string]interface{}
  28847. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28848. // fmt.Println(dat)
  28849. //} else {
  28850. // fmt.Println(err)
  28851. //}
  28852. //userJSONBytes2, _ := json.Marshal(dat2)
  28853. //var res2 models.Result3260
  28854. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28855. // utils.ErrorLog("解析失败:%v", err)
  28856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28857. // return
  28858. //}
  28859. //if res2.Infcode == 0 {
  28860. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28861. // var dat2 map[string]interface{}
  28862. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  28863. // fmt.Println(dat)
  28864. // } else {
  28865. // fmt.Println(err)
  28866. // }
  28867. // c.ServeSuccessJSON(map[string]interface{}{
  28868. // "list": res2.Output.Data,
  28869. // })
  28870. //}
  28871. }
  28872. func (c *HisApiController) ComfirmAllopatry() {
  28873. year := c.GetString("year")
  28874. month := c.GetString("month")
  28875. admin_user_id, _ := c.GetInt64("admin_user_id")
  28876. adminUser := c.GetAdminUserInfo()
  28877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28878. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28879. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28880. var dat map[string]interface{}
  28881. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28882. fmt.Println(dat)
  28883. } else {
  28884. fmt.Println(err)
  28885. }
  28886. userJSONBytes, _ := json.Marshal(dat)
  28887. var res models.Result9001
  28888. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28889. utils.ErrorLog("解析失败:%v", err)
  28890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28891. return
  28892. }
  28893. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  28894. var dat2 map[string]interface{}
  28895. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  28896. fmt.Println(dat)
  28897. } else {
  28898. fmt.Println(err)
  28899. }
  28900. userJSONBytes2, _ := json.Marshal(dat2)
  28901. var res2 models.Result3260
  28902. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  28903. utils.ErrorLog("解析失败:%v", err)
  28904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28905. return
  28906. }
  28907. //if res2.Infcode == 0 {
  28908. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  28909. // var dat map[string]interface{}
  28910. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  28911. // fmt.Println(dat)
  28912. // } else {
  28913. // fmt.Println(err)
  28914. // }
  28915. // userJSONBytes, _ := json.Marshal(dat)
  28916. // var res3 models.Result3261
  28917. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  28918. // utils.ErrorLog("解析失败:%v", err)
  28919. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28920. // return
  28921. // }
  28922. //
  28923. // if res3.Infcode == 0 {
  28924. // record := &models.HisYidiClearRecord{
  28925. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  28926. // Ctime: time.Now().Unix(),
  28927. // Mtime: time.Now().Unix(),
  28928. // Status: 1,
  28929. // MsgId: msgId,
  28930. // }
  28931. // service.SaveClearRecord(record)
  28932. // c.ServeSuccessJSON(map[string]interface{}{
  28933. // "msg": "提取成功",
  28934. // })
  28935. // }
  28936. //}
  28937. }
  28938. func (c *HisApiController) RefundAllopatry() {
  28939. year := c.GetString("year")
  28940. month := c.GetString("month")
  28941. //id, _ := c.GetInt64("id")
  28942. admin_user_id, _ := c.GetInt64("admin_user_id")
  28943. adminUser := c.GetAdminUserInfo()
  28944. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  28945. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  28946. //record, _ := service.GetClearRecordById(id)
  28947. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  28948. var dat map[string]interface{}
  28949. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  28950. fmt.Println(dat)
  28951. } else {
  28952. fmt.Println(err)
  28953. }
  28954. userJSONBytes, _ := json.Marshal(dat)
  28955. var res models.Result9001
  28956. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  28957. utils.ErrorLog("解析失败:%v", err)
  28958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28959. return
  28960. }
  28961. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  28962. var dat2 map[string]interface{}
  28963. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  28964. fmt.Println(dat)
  28965. } else {
  28966. fmt.Println(err)
  28967. }
  28968. userJSONBytes2, _ := json.Marshal(dat2)
  28969. var empty ResultFourteen
  28970. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  28971. utils.ErrorLog("解析失败:%v", err)
  28972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  28973. return
  28974. }
  28975. if empty.Infcode == 0 {
  28976. c.ServeSuccessJSON(map[string]interface{}{
  28977. "msg": "撤销成功",
  28978. })
  28979. return
  28980. }
  28981. }
  28982. func (c *HisApiController) ReversalOtherData() {
  28983. var customData []*CustomData
  28984. custom := &CustomData{
  28985. MsgId: "H44022900158202103301714472004",
  28986. PsnNo: "44020000001101329945",
  28987. Info: "2208",
  28988. }
  28989. customData = append(customData, custom)
  28990. custom1 := &CustomData{
  28991. MsgId: "H4402290015820210330172057803",
  28992. PsnNo: "44020000001101161813",
  28993. Info: "2208",
  28994. }
  28995. customData = append(customData, custom1)
  28996. custom2 := &CustomData{
  28997. MsgId: "H44022900158202103301705198813",
  28998. PsnNo: "44190000133097375417",
  28999. Info: "2208",
  29000. }
  29001. customData = append(customData, custom2)
  29002. custom3 := &CustomData{
  29003. MsgId: "H44022900158202103301715524756",
  29004. PsnNo: "44020000001100187221",
  29005. Info: "2208",
  29006. }
  29007. customData = append(customData, custom3)
  29008. custom4 := &CustomData{
  29009. MsgId: "H44022900158202103301730376224",
  29010. PsnNo: "44020000001101959155",
  29011. Info: "2208",
  29012. }
  29013. customData = append(customData, custom4)
  29014. custom5 := &CustomData{
  29015. MsgId: "H44022900158202103301748008725",
  29016. PsnNo: "44020000001104246641",
  29017. Info: "2208",
  29018. }
  29019. customData = append(customData, custom5)
  29020. custom6 := &CustomData{
  29021. MsgId: "H44022900158202103301718096755",
  29022. PsnNo: "44020000001102211860",
  29023. Info: "2208",
  29024. }
  29025. customData = append(customData, custom6)
  29026. custom7 := &CustomData{
  29027. MsgId: "H44022900158202103301736551640",
  29028. PsnNo: "44020000001102687718",
  29029. Info: "2208",
  29030. }
  29031. customData = append(customData, custom7)
  29032. custom8 := &CustomData{
  29033. MsgId: "H44022900158202103301743097676",
  29034. PsnNo: "44020000001102127785",
  29035. Info: "2208",
  29036. }
  29037. customData = append(customData, custom8)
  29038. custom9 := &CustomData{
  29039. MsgId: "H44022900158202103301712304203",
  29040. PsnNo: "44020000001101518097",
  29041. Info: "2208",
  29042. }
  29043. customData = append(customData, custom9)
  29044. custom10 := &CustomData{
  29045. MsgId: "H44022900158202103301738448785",
  29046. PsnNo: "44020000001100500813",
  29047. Info: "2208",
  29048. }
  29049. customData = append(customData, custom10)
  29050. custom11 := &CustomData{
  29051. MsgId: "H44022900158202103301732455843",
  29052. PsnNo: "44020000001102690557",
  29053. Info: "2208",
  29054. }
  29055. customData = append(customData, custom11)
  29056. custom12 := &CustomData{
  29057. MsgId: "H44022900158202103301745421708",
  29058. PsnNo: "44020000001102211928",
  29059. Info: "2208",
  29060. }
  29061. customData = append(customData, custom12)
  29062. custom1212 := &CustomData{
  29063. MsgId: "H440229001582021033017351627",
  29064. PsnNo: "44020000001102481733",
  29065. Info: "2208",
  29066. }
  29067. customData = append(customData, custom1212)
  29068. custom13 := &CustomData{
  29069. MsgId: "H44022900158202103301740327951",
  29070. PsnNo: "44020000001103174866",
  29071. Info: "2208",
  29072. }
  29073. customData = append(customData, custom13)
  29074. custom14 := &CustomData{
  29075. MsgId: "H4402290015820210330174922668",
  29076. PsnNo: "44020000001102927272",
  29077. Info: "2208",
  29078. }
  29079. customData = append(customData, custom14)
  29080. custom15 := &CustomData{
  29081. MsgId: "H44022900158202103301752362273",
  29082. PsnNo: "44020000001102942890",
  29083. Info: "2208",
  29084. }
  29085. customData = append(customData, custom15)
  29086. custom16 := &CustomData{
  29087. MsgId: "H44022900158202103301751082917",
  29088. PsnNo: "44020000001101662162",
  29089. Info: "2208",
  29090. }
  29091. customData = append(customData, custom16)
  29092. custom17 := &CustomData{
  29093. MsgId: "H44022900158202103301754147728",
  29094. PsnNo: "44020000000229014511",
  29095. Info: "2208",
  29096. }
  29097. customData = append(customData, custom17)
  29098. adminUser := c.GetAdminUserInfo()
  29099. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29100. for _, item := range customData {
  29101. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  29102. fmt.Println(result)
  29103. }
  29104. }
  29105. func PathExists(path string) (bool, error) {
  29106. _, err := os.Stat(path)
  29107. if err == nil {
  29108. return true, nil
  29109. }
  29110. if os.IsNotExist(err) {
  29111. return false, nil
  29112. }
  29113. return false, err
  29114. }
  29115. // 创建文件夹
  29116. func Mkdir(dir string) {
  29117. // 创建文件夹
  29118. exist, err := PathExists(dir)
  29119. if err != nil {
  29120. fmt.Println(err.Error())
  29121. } else {
  29122. if exist {
  29123. fmt.Println(dir + "文件夹已存在!")
  29124. } else {
  29125. // 文件夹名称,权限
  29126. err := os.Mkdir(dir, os.ModePerm)
  29127. if err != nil {
  29128. fmt.Println(dir+"文件夹创建失败:", err.Error())
  29129. } else {
  29130. fmt.Println(dir + "文件夹创建成功!")
  29131. }
  29132. }
  29133. }
  29134. }
  29135. // 压缩文件
  29136. func Zip(srcFile string, destZip string) error {
  29137. zipfile, err := os.Create(destZip)
  29138. if err != nil {
  29139. return err
  29140. }
  29141. defer zipfile.Close()
  29142. archive := zip.NewWriter(zipfile)
  29143. defer archive.Close()
  29144. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  29145. if err != nil {
  29146. return err
  29147. }
  29148. header, err := zip.FileInfoHeader(info)
  29149. if err != nil {
  29150. return err
  29151. }
  29152. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  29153. // header.Name = path
  29154. if info.IsDir() {
  29155. header.Name += "/"
  29156. } else {
  29157. header.Method = zip.Deflate
  29158. }
  29159. writer, err := archive.CreateHeader(header)
  29160. if err != nil {
  29161. return err
  29162. }
  29163. if !info.IsDir() {
  29164. file, err := os.Open(path)
  29165. if err != nil {
  29166. return err
  29167. }
  29168. defer file.Close()
  29169. _, err = io.Copy(writer, file)
  29170. }
  29171. return err
  29172. })
  29173. return err
  29174. }
  29175. func ReadFile(filePath string) []byte {
  29176. f, err := os.Open(filePath)
  29177. if err != nil {
  29178. fmt.Println("read file fail", err)
  29179. return nil
  29180. }
  29181. defer f.Close()
  29182. fd, err := ioutil.ReadAll(f)
  29183. if err != nil {
  29184. fmt.Println("read to fd fail", err)
  29185. return nil
  29186. }
  29187. return fd
  29188. }
  29189. func saveLogq(result string, request string, infno string, desc string) {
  29190. dir := "日志"
  29191. utils.Mkdir(dir)
  29192. month := time.Unix(1557042972, 0).Format("1")
  29193. year := time.Now().Format("2006")
  29194. month = time.Now().Format("01")
  29195. day := time.Now().Format("02")
  29196. hour := time.Now().Format("15")
  29197. min := time.Now().Format("04")
  29198. sec := time.Now().Format("05")
  29199. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29200. file := year + month + day + "_log"
  29201. file_name := file + ".txt"
  29202. file_path := "日志" + "/" + file_name
  29203. exist, _ := utils.PathExists(file_path)
  29204. if exist { //存在
  29205. fmt.Println("存在")
  29206. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29207. if err != nil {
  29208. fmt.Println("read fail")
  29209. }
  29210. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29211. n, _ := f.Seek(0, 2)
  29212. _, err = f.WriteAt([]byte(content), n)
  29213. } else { //不存在
  29214. fmt.Println("文件不存在,创建文件")
  29215. f, err := os.Create("日志" + "/" + file_name)
  29216. defer f.Close()
  29217. if err != nil {
  29218. } else {
  29219. _, err = f.Write([]byte("记录日志"))
  29220. }
  29221. }
  29222. }
  29223. func saveLog(result string, request string, infno string, desc string) {
  29224. org_id, _ := beego.AppConfig.Int64("org_id")
  29225. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29226. dir := miConfig.OrgName + "日志"
  29227. utils.Mkdir(dir)
  29228. month := time.Unix(1557042972, 0).Format("1")
  29229. year := time.Now().Format("2006")
  29230. month = time.Now().Format("01")
  29231. day := time.Now().Format("02")
  29232. hour := time.Now().Format("15")
  29233. min := time.Now().Format("04")
  29234. sec := time.Now().Format("05")
  29235. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  29236. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  29237. file_name := file + ".txt"
  29238. file_path := miConfig.OrgName + "日志" + "/" + file_name
  29239. exist, _ := utils.PathExists(file_path)
  29240. if exist { //存在
  29241. fmt.Println("存在")
  29242. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  29243. if err != nil {
  29244. fmt.Println("read fail")
  29245. }
  29246. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  29247. n, _ := f.Seek(0, 2)
  29248. _, err = f.WriteAt([]byte(content), n)
  29249. } else { //不存在
  29250. fmt.Println("文件不存在,创建文件")
  29251. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  29252. defer f.Close()
  29253. if err != nil {
  29254. } else {
  29255. _, err = f.Write([]byte("记录日志"))
  29256. }
  29257. }
  29258. }
  29259. type Charset string
  29260. const (
  29261. UTF8 = Charset("UTF-8")
  29262. GB18030 = Charset("GB18030")
  29263. )
  29264. func ConvertToString(src string, srcCode string, tagCode string) string {
  29265. srcCoder := mahonia.NewDecoder(srcCode)
  29266. srcResult := srcCoder.ConvertString(src)
  29267. tagCoder := mahonia.NewDecoder(tagCode)
  29268. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  29269. result := string(cdata)
  29270. return result
  29271. }
  29272. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  29273. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29274. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29275. var token string
  29276. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29277. var api string
  29278. if miConfig.MdtrtareaAdmvs == "320921" {
  29279. 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 +
  29280. "&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
  29281. fmt.Println(api)
  29282. } else {
  29283. 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 +
  29284. "&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
  29285. }
  29286. resp, requestErr := http.Get(api)
  29287. if requestErr != nil {
  29288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29289. return ""
  29290. }
  29291. body, ioErr := ioutil.ReadAll(resp.Body)
  29292. if ioErr != nil {
  29293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29295. return ""
  29296. }
  29297. var respJSON map[string]interface{}
  29298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29301. return ""
  29302. }
  29303. var status string
  29304. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29305. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29306. var res ResultTwo //1101结果
  29307. var res10265 ResultTwo10265 //1101结果
  29308. if status == "0" { //读卡成功
  29309. var card_info string //卡信息
  29310. var busi_card_info string
  29311. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29312. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29313. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29314. fmt.Println(card_info)
  29315. fmt.Println(busi_card_info)
  29316. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29317. result, _ := json.Marshal(respJSON)
  29318. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29319. utils.ErrorLog("解析失败:%v", err)
  29320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29321. return ""
  29322. }
  29323. res.ErrMsg = res10265.ErrMsg
  29324. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29325. res.Infcode = infocode
  29326. res.Output = res10265.Output
  29327. res.InfRefmsgid = res10265.InfRefmsgid
  29328. if res.Infcode == 0 {
  29329. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29330. if err == gorm.ErrRecordNotFound {
  29331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29332. return ""
  29333. } else if err != nil {
  29334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29335. return ""
  29336. } else {
  29337. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29338. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29339. infoStr := string(Iinfos)
  29340. idetinfoStr := string(Idetinfos)
  29341. psn := &models.HisPsn{
  29342. PsnNo: res.Output.Baseinfo.PsnNo,
  29343. PatientId: patient.ID,
  29344. Certno: res.Output.Baseinfo.Certno,
  29345. Gend: res.Output.Baseinfo.Gend,
  29346. Naty: res.Output.Baseinfo.Naty,
  29347. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29348. PsnName: res.Output.Baseinfo.PsnName,
  29349. Idetinfo: idetinfoStr,
  29350. Insuinfo: infoStr,
  29351. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29352. CardInfo: card_info,
  29353. VerifyNumber: token,
  29354. }
  29355. service.CreateHisPsn(psn)
  29356. return token
  29357. }
  29358. }
  29359. } else {
  29360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29361. return ""
  29362. }
  29363. } else { //读卡失败
  29364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29365. return ""
  29366. }
  29367. return token
  29368. }
  29369. func ReadEleCardforah(admin_user_id int64, org_id int64, c *HisApiController) string {
  29370. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29371. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29372. var token string
  29373. var api string
  29374. api = miConfig.SecretKey + "ahyb/readcardcharge?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  29375. "&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
  29376. fmt.Println(api)
  29377. resp, requestErr := http.Get(api)
  29378. if requestErr != nil {
  29379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29380. return ""
  29381. }
  29382. body, ioErr := ioutil.ReadAll(resp.Body)
  29383. if ioErr != nil {
  29384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29386. return ""
  29387. }
  29388. var respJSON map[string]interface{}
  29389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29392. return ""
  29393. }
  29394. var status string
  29395. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29396. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29397. var res ResultTwo //1101结果
  29398. if status == "1" { //读卡成功
  29399. var card_info string //卡信息
  29400. var busi_card_info string
  29401. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29402. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29403. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29404. fmt.Println(card_info)
  29405. fmt.Println(busi_card_info)
  29406. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29407. result, _ := json.Marshal(respJSON)
  29408. if err := json.Unmarshal([]byte(result), &res); err != nil {
  29409. utils.ErrorLog("解析失败:%v", err)
  29410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29411. return ""
  29412. }
  29413. if res.Infcode == 0 {
  29414. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29415. if err == gorm.ErrRecordNotFound {
  29416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29417. return ""
  29418. } else if err != nil {
  29419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29420. return ""
  29421. } else {
  29422. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29423. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29424. infoStr := string(Iinfos)
  29425. idetinfoStr := string(Idetinfos)
  29426. psn := &models.HisPsn{
  29427. PsnNo: res.Output.Baseinfo.PsnNo,
  29428. PatientId: patient.ID,
  29429. Certno: res.Output.Baseinfo.Certno,
  29430. Gend: res.Output.Baseinfo.Gend,
  29431. Naty: res.Output.Baseinfo.Naty,
  29432. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29433. PsnName: res.Output.Baseinfo.PsnName,
  29434. Idetinfo: idetinfoStr,
  29435. Insuinfo: infoStr,
  29436. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29437. CardInfo: card_info,
  29438. VerifyNumber: token,
  29439. }
  29440. service.CreateHisPsn(psn)
  29441. return token
  29442. }
  29443. }
  29444. } else {
  29445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29446. return ""
  29447. }
  29448. return token
  29449. }
  29450. func ReadEleFace(admin_user_id int64, org_id int64, c *HisApiController) string {
  29451. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  29452. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  29453. var token string
  29454. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  29455. var api string
  29456. if miConfig.MdtrtareaAdmvs == "320921" {
  29457. 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 +
  29458. "&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
  29459. fmt.Println(api)
  29460. } else {
  29461. 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 +
  29462. "&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
  29463. }
  29464. resp, requestErr := http.Get(api)
  29465. if requestErr != nil {
  29466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29467. return ""
  29468. }
  29469. body, ioErr := ioutil.ReadAll(resp.Body)
  29470. if ioErr != nil {
  29471. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29473. return ""
  29474. }
  29475. var respJSON map[string]interface{}
  29476. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  29477. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29479. return ""
  29480. }
  29481. var status string
  29482. status = respJSON["data"].(map[string]interface{})["status"].(string)
  29483. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  29484. var res ResultTwo //1101结果
  29485. var res10265 ResultTwo10265 //1101结果
  29486. if status == "0" { //读卡成功
  29487. var card_info string //卡信息
  29488. var busi_card_info string
  29489. token = respJSON["data"].(map[string]interface{})["token"].(string)
  29490. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  29491. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  29492. fmt.Println(card_info)
  29493. fmt.Println(busi_card_info)
  29494. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  29495. result, _ := json.Marshal(respJSON)
  29496. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  29497. utils.ErrorLog("解析失败:%v", err)
  29498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29499. return ""
  29500. }
  29501. res.ErrMsg = res10265.ErrMsg
  29502. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  29503. res.Infcode = infocode
  29504. res.Output = res10265.Output
  29505. res.InfRefmsgid = res10265.InfRefmsgid
  29506. if res.Infcode == 0 {
  29507. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  29508. if err == gorm.ErrRecordNotFound {
  29509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  29510. return ""
  29511. } else if err != nil {
  29512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  29513. return ""
  29514. } else {
  29515. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  29516. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  29517. infoStr := string(Iinfos)
  29518. idetinfoStr := string(Idetinfos)
  29519. psn := &models.HisPsn{
  29520. PsnNo: res.Output.Baseinfo.PsnNo,
  29521. PatientId: patient.ID,
  29522. Certno: res.Output.Baseinfo.Certno,
  29523. Gend: res.Output.Baseinfo.Gend,
  29524. Naty: res.Output.Baseinfo.Naty,
  29525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  29526. PsnName: res.Output.Baseinfo.PsnName,
  29527. Idetinfo: idetinfoStr,
  29528. Insuinfo: infoStr,
  29529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  29530. CardInfo: card_info,
  29531. VerifyNumber: token,
  29532. }
  29533. service.CreateHisPsn(psn)
  29534. return token
  29535. }
  29536. }
  29537. } else {
  29538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29539. return ""
  29540. }
  29541. } else { //读卡失败
  29542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  29543. return ""
  29544. }
  29545. return token
  29546. }
  29547. func DeleteExtraSpaceTwo(s string) string {
  29548. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29549. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29550. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29551. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29552. s2 := make([]byte, len(s1)) //定义字符数组切片
  29553. copy(s2, s1) //将字符串复制到切片
  29554. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29555. for len(spc_index) > 0 { //找到适配项
  29556. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29557. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29558. }
  29559. return string(s2)
  29560. }
  29561. func Remove0000(s string) string {
  29562. str := make([]rune, 0, len(s))
  29563. for _, v := range []rune(s) {
  29564. if v == 0 {
  29565. continue
  29566. }
  29567. str = append(str, v)
  29568. }
  29569. return string(str)
  29570. }
  29571. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  29572. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  29573. readCard := DllDef.MustFindProc("EcQuery")
  29574. pCardInfo := make([]byte, 8192)
  29575. pBusiCardInfo := make([]byte, 8192)
  29576. data := make(map[string]interface{})
  29577. //pData := make(map[string]interface{})
  29578. inputData := make(map[string]interface{})
  29579. inputData["orgId"] = code
  29580. inputData["businessType"] = "01101"
  29581. inputData["operatorId"] = operator_id
  29582. inputData["operatorName"] = operator_name
  29583. inputData["officeId"] = "001"
  29584. inputData["officeName"] = "血透室"
  29585. //
  29586. data["data"] = inputData
  29587. data["transType"] = "ec.query"
  29588. data["orgId"] = code
  29589. bytesData, _ := json.Marshal(data)
  29590. pCardInfo = bytesData
  29591. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  29592. fmt.Println(ret2)
  29593. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  29594. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  29595. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  29596. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  29597. if ret2 != 0 {
  29598. return "", ""
  29599. }
  29600. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  29601. }
  29602. func DeleteExtraSpace(s string) string {
  29603. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  29604. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  29605. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  29606. reg, _ := regexp.Compile(regstr) //编译正则表达式
  29607. s2 := make([]byte, len(s1)) //定义字符数组切片
  29608. copy(s2, s1) //将字符串复制到切片
  29609. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  29610. for len(spc_index) > 0 { //找到适配项
  29611. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  29612. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  29613. }
  29614. return string(s2)
  29615. }
  29616. // 对账
  29617. func (c *HisApiController) Post3202() {
  29618. start_time := c.GetString("start_time")
  29619. end_time := c.GetString("end_time")
  29620. //insutype := c.GetString("insutype")
  29621. clr_type := c.GetString("clr_type")
  29622. clr_org := c.GetString("clr_optins")
  29623. admin_user_id, _ := c.GetInt64("admin_user_id")
  29624. adminUser := c.GetAdminUserInfo()
  29625. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29626. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29627. if len(clr_org) == 0 {
  29628. clr_org = miConfig.MdtrtareaAdmvs
  29629. }
  29630. timeLayout := "2006-01-02"
  29631. loc, _ := time.LoadLocation("Local")
  29632. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29633. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29634. var orders []*models.HisOrder
  29635. if clr_org == "421300" {
  29636. orders, _ = service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29637. } else {
  29638. orders, _ = service.GetOrderByTime11222(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29639. }
  29640. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29641. //fixmedins_setl_cnt := int64(len(orders))
  29642. var medfee_sumamt float64
  29643. var acct_pay float64
  29644. var fund_pay_sumamt float64
  29645. for _, item := range orders {
  29646. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29647. acct_pay = acct_pay + item.AcctPay
  29648. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29649. }
  29650. //var medfee_sumamt_two float64
  29651. //var acct_pay_two float64
  29652. //var fund_pay_sumamt_two float64
  29653. //for _, item := range orders_two {
  29654. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29655. // acct_pay_two = acct_pay_two + item.AcctPay
  29656. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29657. //}
  29658. //var user_name string
  29659. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29660. //if role.ID == 0 {
  29661. // user_name = "xxx"
  29662. //} else {
  29663. // user_name = role.UserName
  29664. //}
  29665. var res ResultSix
  29666. if config.IsOpen == 1 {
  29667. var bps []*models.BusinessParamsTwo
  29668. var bp models.BusinessParamsTwo
  29669. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29670. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29671. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29672. bp.MedfeeSumamt = medfee_sumamt_str
  29673. bp.AcctPay = acct_pay_str
  29674. bp.FundPaySumamt = fund_pay_sumamt_str
  29675. bp.Insutype = ""
  29676. bp.StmtBegndate = start_time
  29677. bp.ClrType = clr_type
  29678. bp.SetlOptins = clr_org
  29679. bp.StmtEnddate = end_time
  29680. bps = append(bps, &bp)
  29681. data := make(map[string]interface{})
  29682. data["bps"] = bps
  29683. data["org_name"] = miConfig.OrgName
  29684. data["doctor"] = role.UserName
  29685. data["fixmedins_code"] = miConfig.Code
  29686. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29687. //data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29688. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29689. if miConfig.MdtrtareaAdmvs == "421300" {
  29690. client := &http.Client{}
  29691. bytesData, _ := json.Marshal(data)
  29692. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29693. resp, _ := client.Do(req)
  29694. defer resp.Body.Close()
  29695. body, ioErr := ioutil.ReadAll(resp.Body)
  29696. if ioErr != nil {
  29697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29699. return
  29700. }
  29701. var respJSON map[string]interface{}
  29702. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29705. return
  29706. }
  29707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29708. userJSONBytes, _ := json.Marshal(respJSON)
  29709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29710. utils.ErrorLog("解析失败:%v", err)
  29711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29712. return
  29713. }
  29714. }
  29715. if miConfig.MdtrtareaAdmvs == "420200" {
  29716. client := &http.Client{}
  29717. bytesData, _ := json.Marshal(data)
  29718. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  29719. resp, _ := client.Do(req)
  29720. defer resp.Body.Close()
  29721. body, ioErr := ioutil.ReadAll(resp.Body)
  29722. if ioErr != nil {
  29723. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29725. return
  29726. }
  29727. var respJSON map[string]interface{}
  29728. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29731. return
  29732. }
  29733. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29734. userJSONBytes, _ := json.Marshal(respJSON)
  29735. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29736. utils.ErrorLog("解析失败:%v", err)
  29737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29738. return
  29739. }
  29740. }
  29741. if miConfig.MdtrtareaAdmvs == "421182" {
  29742. client := &http.Client{}
  29743. bytesData, _ := json.Marshal(data)
  29744. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202", bytes.NewReader(bytesData))
  29745. resp, _ := client.Do(req)
  29746. defer resp.Body.Close()
  29747. body, ioErr := ioutil.ReadAll(resp.Body)
  29748. if ioErr != nil {
  29749. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29751. return
  29752. }
  29753. var respJSON map[string]interface{}
  29754. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29755. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29757. return
  29758. }
  29759. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29760. userJSONBytes, _ := json.Marshal(respJSON)
  29761. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29762. utils.ErrorLog("解析失败:%v", err)
  29763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29764. return
  29765. }
  29766. }
  29767. if res.Infcode == 0 {
  29768. c.ServeSuccessJSON(map[string]interface{}{
  29769. "msg": "发起成功",
  29770. })
  29771. } else {
  29772. c.ServeSuccessJSON(map[string]interface{}{
  29773. "failed_code": -10,
  29774. "msg": res.ErrMsg,
  29775. })
  29776. }
  29777. }
  29778. }
  29779. func (c *HisApiController) Post3202b() {
  29780. start_time := c.GetString("start_time")
  29781. end_time := c.GetString("end_time")
  29782. //insutype := c.GetString("insutype")
  29783. clr_type := c.GetString("clr_type")
  29784. clr_org := c.GetString("clr_optins")
  29785. admin_user_id, _ := c.GetInt64("admin_user_id")
  29786. adminUser := c.GetAdminUserInfo()
  29787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29789. if len(clr_org) == 0 {
  29790. clr_org = miConfig.MdtrtareaAdmvs
  29791. }
  29792. timeLayout := "2006-01-02"
  29793. loc, _ := time.LoadLocation("Local")
  29794. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29795. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29796. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29797. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29798. //fixmedins_setl_cnt := int64(len(orders))
  29799. var medfee_sumamt float64
  29800. var acct_pay float64
  29801. var fund_pay_sumamt float64
  29802. for _, item := range orders {
  29803. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29804. acct_pay = acct_pay + item.AcctPay
  29805. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  29806. }
  29807. //var medfee_sumamt_two float64
  29808. //var acct_pay_two float64
  29809. //var fund_pay_sumamt_two float64
  29810. //for _, item := range orders_two {
  29811. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  29812. // acct_pay_two = acct_pay_two + item.AcctPay
  29813. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  29814. //}
  29815. //var user_name string
  29816. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29817. //if role.ID == 0 {
  29818. // user_name = "xxx"
  29819. //} else {
  29820. // user_name = role.UserName
  29821. //}
  29822. var res ResultSix
  29823. if config.IsOpen == 1 {
  29824. var bps []*models.BusinessParamsTwo
  29825. var bp models.BusinessParamsTwo
  29826. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29827. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  29828. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  29829. bp.MedfeeSumamt = medfee_sumamt_str
  29830. bp.AcctPay = acct_pay_str
  29831. bp.FundPaySumamt = fund_pay_sumamt_str
  29832. bp.Insutype = "390"
  29833. bp.StmtBegndate = start_time
  29834. bp.ClrType = clr_type
  29835. bp.SetlOptins = clr_org
  29836. bp.StmtEnddate = end_time
  29837. bps = append(bps, &bp)
  29838. data := make(map[string]interface{})
  29839. data["bps"] = bps
  29840. data["org_name"] = miConfig.OrgName
  29841. data["doctor"] = role.UserName
  29842. data["fixmedins_code"] = miConfig.Code
  29843. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29844. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29845. if miConfig.MdtrtareaAdmvs == "421300" {
  29846. client := &http.Client{}
  29847. bytesData, _ := json.Marshal(data)
  29848. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29849. resp, _ := client.Do(req)
  29850. defer resp.Body.Close()
  29851. body, ioErr := ioutil.ReadAll(resp.Body)
  29852. if ioErr != nil {
  29853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29855. return
  29856. }
  29857. var respJSON map[string]interface{}
  29858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29861. return
  29862. }
  29863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29864. userJSONBytes, _ := json.Marshal(respJSON)
  29865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29866. utils.ErrorLog("解析失败:%v", err)
  29867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29868. return
  29869. }
  29870. }
  29871. if miConfig.MdtrtareaAdmvs == "420200" {
  29872. client := &http.Client{}
  29873. bytesData, _ := json.Marshal(data)
  29874. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/3202b", bytes.NewReader(bytesData))
  29875. resp, _ := client.Do(req)
  29876. defer resp.Body.Close()
  29877. body, ioErr := ioutil.ReadAll(resp.Body)
  29878. if ioErr != nil {
  29879. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29881. return
  29882. }
  29883. var respJSON map[string]interface{}
  29884. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29885. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29887. return
  29888. }
  29889. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29890. userJSONBytes, _ := json.Marshal(respJSON)
  29891. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29892. utils.ErrorLog("解析失败:%v", err)
  29893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29894. return
  29895. }
  29896. }
  29897. if miConfig.MdtrtareaAdmvs == "421182" {
  29898. client := &http.Client{}
  29899. bytesData, _ := json.Marshal(data)
  29900. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/3202b", bytes.NewReader(bytesData))
  29901. resp, _ := client.Do(req)
  29902. defer resp.Body.Close()
  29903. body, ioErr := ioutil.ReadAll(resp.Body)
  29904. if ioErr != nil {
  29905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29907. return
  29908. }
  29909. var respJSON map[string]interface{}
  29910. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29913. return
  29914. }
  29915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29916. userJSONBytes, _ := json.Marshal(respJSON)
  29917. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29918. utils.ErrorLog("解析失败:%v", err)
  29919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29920. return
  29921. }
  29922. }
  29923. if res.Infcode == 0 {
  29924. c.ServeSuccessJSON(map[string]interface{}{
  29925. "msg": "发起成功",
  29926. })
  29927. } else {
  29928. c.ServeSuccessJSON(map[string]interface{}{
  29929. "failed_code": -10,
  29930. "msg": res.ErrMsg,
  29931. })
  29932. }
  29933. }
  29934. }
  29935. func (c *HisApiController) Post1608() {
  29936. start_time := c.GetString("start_time")
  29937. end_time := c.GetString("end_time")
  29938. admin_user_id, _ := c.GetInt64("admin_user_id")
  29939. adminUser := c.GetAdminUserInfo()
  29940. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  29941. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  29942. timeLayout := "2006-01-02"
  29943. loc, _ := time.LoadLocation("Local")
  29944. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  29945. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  29946. orders, _ := service.GetOrderByTimeFourfor11(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  29947. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  29948. fixmedins_setl_cnt := int64(len(orders))
  29949. var medfee_sumamt float64
  29950. var func_smamt float64
  29951. for _, item := range orders {
  29952. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  29953. func_smamt = func_smamt + item.FundPaySumamt + item.AcctPay
  29954. }
  29955. times := strings.Split(start_time, "-")
  29956. time_tows := strings.Split(end_time, "-")
  29957. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  29958. var res ResultSix
  29959. if config.IsOpen == 1 {
  29960. //var bps []*models.BusinessParamsTwo
  29961. //var bp models.BusinessParamsTwo
  29962. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  29963. func_smamt_str := fmt.Sprintf("%.2f", func_smamt)
  29964. data := make(map[string]interface{})
  29965. data["org_name"] = miConfig.OrgName
  29966. data["doctor"] = role.UserName
  29967. data["func_smamt"] = func_smamt_str
  29968. data["fixmedins_code"] = miConfig.Code
  29969. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  29970. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  29971. data["cnt"] = strconv.FormatInt(fixmedins_setl_cnt, 10)
  29972. data["medfee_sumamt"] = medfee_sumamt_str
  29973. data["start_time"] = times[0] + times[1] + times[2]
  29974. data["end_time"] = time_tows[0] + time_tows[1] + time_tows[2]
  29975. if miConfig.MdtrtareaAdmvs == "421300" {
  29976. client := &http.Client{}
  29977. bytesData, _ := json.Marshal(data)
  29978. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  29979. resp, _ := client.Do(req)
  29980. defer resp.Body.Close()
  29981. body, ioErr := ioutil.ReadAll(resp.Body)
  29982. if ioErr != nil {
  29983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  29984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29985. return
  29986. }
  29987. var respJSON map[string]interface{}
  29988. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  29989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  29990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29991. return
  29992. }
  29993. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  29994. userJSONBytes, _ := json.Marshal(respJSON)
  29995. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  29996. utils.ErrorLog("解析失败:%v", err)
  29997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  29998. return
  29999. }
  30000. }
  30001. if miConfig.MdtrtareaAdmvs == "420200" {
  30002. client := &http.Client{}
  30003. bytesData, _ := json.Marshal(data)
  30004. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/1608", bytes.NewReader(bytesData))
  30005. resp, _ := client.Do(req)
  30006. defer resp.Body.Close()
  30007. body, ioErr := ioutil.ReadAll(resp.Body)
  30008. if ioErr != nil {
  30009. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30011. return
  30012. }
  30013. var respJSON map[string]interface{}
  30014. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30015. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30017. return
  30018. }
  30019. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30020. userJSONBytes, _ := json.Marshal(respJSON)
  30021. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30022. utils.ErrorLog("解析失败:%v", err)
  30023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30024. return
  30025. }
  30026. }
  30027. if miConfig.MdtrtareaAdmvs == "421182" {
  30028. client := &http.Client{}
  30029. bytesData, _ := json.Marshal(data)
  30030. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/1608", bytes.NewReader(bytesData))
  30031. resp, _ := client.Do(req)
  30032. defer resp.Body.Close()
  30033. body, ioErr := ioutil.ReadAll(resp.Body)
  30034. if ioErr != nil {
  30035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30037. return
  30038. }
  30039. var respJSON map[string]interface{}
  30040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30043. return
  30044. }
  30045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30046. userJSONBytes, _ := json.Marshal(respJSON)
  30047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30048. utils.ErrorLog("解析失败:%v", err)
  30049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30050. return
  30051. }
  30052. }
  30053. if res.Infcode == 0 {
  30054. c.ServeSuccessJSON(map[string]interface{}{
  30055. "msg": "发起成功",
  30056. })
  30057. } else {
  30058. c.ServeSuccessJSON(map[string]interface{}{
  30059. "failed_code": -10,
  30060. "msg": res.ErrMsg,
  30061. })
  30062. }
  30063. }
  30064. }
  30065. // 5.11.1.1【5262】结算信息按时间段查询
  30066. func Post5262(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30067. admin_user_id, _ := c.GetInt64("admin_user_id")
  30068. adminUser := c.GetAdminUserInfo()
  30069. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30070. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30071. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30072. var res Result5262
  30073. if config.IsOpen == 1 {
  30074. if miConfig.MdtrtareaAdmvs == "421300" {
  30075. data := make(map[string]interface{})
  30076. data["bps"] = bp
  30077. data["org_name"] = miConfig.OrgName
  30078. data["doctor"] = role.UserName
  30079. data["fixmedins_code"] = miConfig.Code
  30080. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30081. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30082. data["page"] = strconv.FormatInt(page, 10)
  30083. data["limit"] = strconv.FormatInt(limit, 10)
  30084. fmt.Println(data)
  30085. client := &http.Client{}
  30086. bytesData, _ := json.Marshal(data)
  30087. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30088. resp, _ := client.Do(req)
  30089. defer resp.Body.Close()
  30090. body, ioErr := ioutil.ReadAll(resp.Body)
  30091. if ioErr != nil {
  30092. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30094. return
  30095. }
  30096. var respJSON map[string]interface{}
  30097. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30098. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30100. return
  30101. }
  30102. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30103. userJSONBytes, _ := json.Marshal(respJSON)
  30104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30105. utils.ErrorLog("解析失败:%v", err)
  30106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30107. return
  30108. }
  30109. }
  30110. if miConfig.MdtrtareaAdmvs == "420200" {
  30111. data := make(map[string]interface{})
  30112. data["bps"] = bp
  30113. data["org_name"] = miConfig.OrgName
  30114. data["doctor"] = role.UserName
  30115. data["fixmedins_code"] = miConfig.Code
  30116. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30117. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30118. data["page"] = strconv.FormatInt(page, 10)
  30119. data["limit"] = strconv.FormatInt(limit, 10)
  30120. fmt.Println(data)
  30121. client := &http.Client{}
  30122. bytesData, _ := json.Marshal(data)
  30123. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5262", bytes.NewReader(bytesData))
  30124. resp, _ := client.Do(req)
  30125. defer resp.Body.Close()
  30126. body, ioErr := ioutil.ReadAll(resp.Body)
  30127. if ioErr != nil {
  30128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30130. return
  30131. }
  30132. var respJSON map[string]interface{}
  30133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30136. return
  30137. }
  30138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30139. userJSONBytes, _ := json.Marshal(respJSON)
  30140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30141. utils.ErrorLog("解析失败:%v", err)
  30142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30143. return
  30144. }
  30145. }
  30146. if miConfig.MdtrtareaAdmvs == "421182" {
  30147. data := make(map[string]interface{})
  30148. data["bps"] = bp
  30149. data["org_name"] = miConfig.OrgName
  30150. data["doctor"] = role.UserName
  30151. data["fixmedins_code"] = miConfig.Code
  30152. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30153. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30154. data["page"] = strconv.FormatInt(page, 10)
  30155. data["limit"] = strconv.FormatInt(limit, 10)
  30156. fmt.Println(data)
  30157. client := &http.Client{}
  30158. bytesData, _ := json.Marshal(data)
  30159. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5262", bytes.NewReader(bytesData))
  30160. resp, _ := client.Do(req)
  30161. defer resp.Body.Close()
  30162. body, ioErr := ioutil.ReadAll(resp.Body)
  30163. if ioErr != nil {
  30164. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30166. return
  30167. }
  30168. var respJSON map[string]interface{}
  30169. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30172. return
  30173. }
  30174. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30175. userJSONBytes, _ := json.Marshal(respJSON)
  30176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30177. utils.ErrorLog("解析失败:%v", err)
  30178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30179. return
  30180. }
  30181. }
  30182. if res.Infcode == 0 {
  30183. c.ServeSuccessJSON(map[string]interface{}{
  30184. "order": res.Output.Result,
  30185. "total": res.Output.PageInfo.RecordCounts,
  30186. })
  30187. } else {
  30188. c.ServeSuccessJSON(map[string]interface{}{
  30189. "failed_code": -10,
  30190. "msg": res.ErrMsg,
  30191. })
  30192. }
  30193. }
  30194. }
  30195. // 5.11.1.2【5267】异地结算信息时间段查询
  30196. func Post5267(c *HisApiController, bp models.BusinessParams5262, page int64, limit int64) {
  30197. admin_user_id, _ := c.GetInt64("admin_user_id")
  30198. adminUser := c.GetAdminUserInfo()
  30199. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  30200. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  30201. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  30202. var res Result5267
  30203. if config.IsOpen == 1 {
  30204. if miConfig.MdtrtareaAdmvs == "421300" {
  30205. data := make(map[string]interface{})
  30206. data["bps"] = bp
  30207. data["org_name"] = miConfig.OrgName
  30208. data["doctor"] = role.UserName
  30209. data["fixmedins_code"] = miConfig.Code
  30210. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30211. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30212. data["page"] = page
  30213. data["limit"] = limit
  30214. fmt.Println(data)
  30215. client := &http.Client{}
  30216. bytesData, _ := json.Marshal(data)
  30217. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30218. resp, _ := client.Do(req)
  30219. defer resp.Body.Close()
  30220. body, ioErr := ioutil.ReadAll(resp.Body)
  30221. if ioErr != nil {
  30222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30224. return
  30225. }
  30226. var respJSON map[string]interface{}
  30227. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30230. return
  30231. }
  30232. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30233. userJSONBytes, _ := json.Marshal(respJSON)
  30234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30235. utils.ErrorLog("解析失败:%v", err)
  30236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30237. return
  30238. }
  30239. }
  30240. if miConfig.MdtrtareaAdmvs == "420200" {
  30241. data := make(map[string]interface{})
  30242. data["bps"] = bp
  30243. data["org_name"] = miConfig.OrgName
  30244. data["doctor"] = role.UserName
  30245. data["fixmedins_code"] = miConfig.Code
  30246. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30247. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30248. data["page"] = page
  30249. data["limit"] = limit
  30250. fmt.Println(data)
  30251. client := &http.Client{}
  30252. bytesData, _ := json.Marshal(data)
  30253. req, _ := http.NewRequest("POST", "http://192.168.0.197:9532/"+"hbyb/5267", bytes.NewReader(bytesData))
  30254. resp, _ := client.Do(req)
  30255. defer resp.Body.Close()
  30256. body, ioErr := ioutil.ReadAll(resp.Body)
  30257. if ioErr != nil {
  30258. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30260. return
  30261. }
  30262. var respJSON map[string]interface{}
  30263. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30264. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30266. return
  30267. }
  30268. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30269. userJSONBytes, _ := json.Marshal(respJSON)
  30270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30271. utils.ErrorLog("解析失败:%v", err)
  30272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30273. return
  30274. }
  30275. }
  30276. if miConfig.MdtrtareaAdmvs == "421182" {
  30277. data := make(map[string]interface{})
  30278. data["bps"] = bp
  30279. data["org_name"] = miConfig.OrgName
  30280. data["doctor"] = role.UserName
  30281. data["fixmedins_code"] = miConfig.Code
  30282. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  30283. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  30284. data["page"] = page
  30285. data["limit"] = limit
  30286. fmt.Println(data)
  30287. client := &http.Client{}
  30288. bytesData, _ := json.Marshal(data)
  30289. req, _ := http.NewRequest("POST", miConfig.Url+"hbyb/5267", bytes.NewReader(bytesData))
  30290. resp, _ := client.Do(req)
  30291. defer resp.Body.Close()
  30292. body, ioErr := ioutil.ReadAll(resp.Body)
  30293. if ioErr != nil {
  30294. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30296. return
  30297. }
  30298. var respJSON map[string]interface{}
  30299. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30300. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30302. return
  30303. }
  30304. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  30305. userJSONBytes, _ := json.Marshal(respJSON)
  30306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  30307. utils.ErrorLog("解析失败:%v", err)
  30308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30309. return
  30310. }
  30311. }
  30312. if res.Infcode == 0 {
  30313. c.ServeSuccessJSON(map[string]interface{}{
  30314. "order": res.Output.Result,
  30315. "total": res.Output.PageInfo.RecordCounts,
  30316. })
  30317. } else {
  30318. c.ServeSuccessJSON(map[string]interface{}{
  30319. "failed_code": -10,
  30320. "msg": res.ErrMsg,
  30321. })
  30322. }
  30323. }
  30324. }
  30325. func (c *HisApiController) Post3501() {
  30326. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30327. data := make(map[string]interface{})
  30328. var struct3501s []models.Struct3501
  30329. var struct3501 models.Struct3501
  30330. struct3501.OrgName = miConfig.OrgName
  30331. struct3501.AccessKey = miConfig.AccessKey
  30332. struct3501.RequestUrl = miConfig.Url
  30333. struct3501.SecretKey = miConfig.SecretKey
  30334. struct3501.ManuDate = "2022-08-17"
  30335. struct3501.FixmedinsBchno = ""
  30336. struct3501.ManuLotnum = ""
  30337. struct3501.RxFlag = "0"
  30338. struct3501.ExpyEnd = "2022-08-17"
  30339. struct3501.Invdate = "2022-08-17"
  30340. struct3501.InvCnt = "20.25"
  30341. struct3501.Memo = ""
  30342. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30343. struct3501.FixmedinsHilistId = miConfig.Code
  30344. struct3501.FixmedinsHilistName = miConfig.OrgName
  30345. struct3501s = append(struct3501s, struct3501)
  30346. data["struct_3501s"] = struct3501s
  30347. client := &http.Client{}
  30348. bytesData, _ := json.Marshal(data)
  30349. var req *http.Request
  30350. if miConfig.MdtrtareaAdmvs == "320921" {
  30351. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30352. } else {
  30353. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30354. }
  30355. resp, _ := client.Do(req)
  30356. defer resp.Body.Close()
  30357. body, ioErr := ioutil.ReadAll(resp.Body)
  30358. if ioErr != nil {
  30359. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30361. return
  30362. }
  30363. var respJSON map[string]interface{}
  30364. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30365. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30367. return
  30368. }
  30369. var res ResultSix
  30370. var resSix10265 ResultSix10265 //1101结果
  30371. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30372. result, _ := json.Marshal(respJSON)
  30373. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30374. utils.ErrorLog("解析失败:%v", err)
  30375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30376. return
  30377. }
  30378. res.InfRefmsgid = resSix10265.InfRefmsgid
  30379. res.Output = resSix10265.Output
  30380. res.ErrMsg = resSix10265.ErrMsg
  30381. res.Cainfo = resSix10265.Cainfo
  30382. res.WarnMsg = resSix10265.WarnMsg
  30383. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30384. res.Infcode = infocode
  30385. if infocode == 0 {
  30386. c.ServeSuccessJSON(map[string]interface{}{
  30387. "msg": "上传成功",
  30388. })
  30389. return
  30390. } else {
  30391. c.ServeSuccessJSON(map[string]interface{}{
  30392. "failed_code": -10,
  30393. "msg": res.ErrMsg,
  30394. })
  30395. return
  30396. }
  30397. }
  30398. func (c *HisApiController) Post3502() {
  30399. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30400. data := make(map[string]interface{})
  30401. var struct3502s []models.Struct3502
  30402. var struct3502 models.Struct3502
  30403. struct3502.OrgName = miConfig.OrgName
  30404. struct3502.AccessKey = miConfig.AccessKey
  30405. struct3502.RequestUrl = miConfig.Url
  30406. struct3502.SecretKey = miConfig.SecretKey
  30407. struct3502.ManuDate = "2022-08-15"
  30408. struct3502.FixmedinsBchno = ""
  30409. struct3502.ManuLotnum = ""
  30410. struct3502.RxFlag = "0"
  30411. struct3502.ExpyEnd = "2022-08-15"
  30412. struct3502.Invdate = "2022-08-15"
  30413. struct3502.InvCnt = "20.25"
  30414. struct3502.Memo = ""
  30415. struct3502.MedListCodg = "XB01ABD056B002020200517"
  30416. struct3502.FixmedinsHilistId = miConfig.Code
  30417. struct3502.FixmedinsHilistName = miConfig.OrgName
  30418. struct3502s = append(struct3502s, struct3502)
  30419. data["struct_3502s"] = struct3502s
  30420. client := &http.Client{}
  30421. bytesData, _ := json.Marshal(data)
  30422. var req *http.Request
  30423. if miConfig.MdtrtareaAdmvs == "320921" {
  30424. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30425. } else {
  30426. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30427. }
  30428. resp, _ := client.Do(req)
  30429. defer resp.Body.Close()
  30430. body, ioErr := ioutil.ReadAll(resp.Body)
  30431. if ioErr != nil {
  30432. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30434. return
  30435. }
  30436. var respJSON map[string]interface{}
  30437. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30440. return
  30441. }
  30442. var res ResultSix
  30443. var resSix10265 ResultSix10265 //1101结果
  30444. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30445. result, _ := json.Marshal(respJSON)
  30446. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30447. utils.ErrorLog("解析失败:%v", err)
  30448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30449. return
  30450. }
  30451. res.InfRefmsgid = resSix10265.InfRefmsgid
  30452. res.Output = resSix10265.Output
  30453. res.ErrMsg = resSix10265.ErrMsg
  30454. res.Cainfo = resSix10265.Cainfo
  30455. res.WarnMsg = resSix10265.WarnMsg
  30456. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30457. res.Infcode = infocode
  30458. if infocode == 0 {
  30459. c.ServeSuccessJSON(map[string]interface{}{
  30460. "msg": "上传成功",
  30461. })
  30462. return
  30463. } else {
  30464. c.ServeSuccessJSON(map[string]interface{}{
  30465. "failed_code": -10,
  30466. "msg": res.ErrMsg,
  30467. })
  30468. return
  30469. }
  30470. }
  30471. func (c *HisApiController) Post3503() {
  30472. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30473. data := make(map[string]interface{})
  30474. var struct3501s []models.Struct3501
  30475. var struct3501 models.Struct3501
  30476. struct3501.OrgName = miConfig.OrgName
  30477. struct3501.AccessKey = miConfig.AccessKey
  30478. struct3501.RequestUrl = miConfig.Url
  30479. struct3501.SecretKey = miConfig.SecretKey
  30480. struct3501.ManuDate = "2022-08-15"
  30481. struct3501.FixmedinsBchno = ""
  30482. struct3501.ManuLotnum = ""
  30483. struct3501.RxFlag = "0"
  30484. struct3501.ExpyEnd = "2022-08-15"
  30485. struct3501.Invdate = "2022-08-15"
  30486. struct3501.InvCnt = "20.25"
  30487. struct3501.Memo = ""
  30488. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30489. struct3501.FixmedinsHilistId = miConfig.Code
  30490. struct3501.FixmedinsHilistName = miConfig.OrgName
  30491. struct3501s = append(struct3501s, struct3501)
  30492. data["struct_3501s"] = struct3501s
  30493. client := &http.Client{}
  30494. bytesData, _ := json.Marshal(data)
  30495. var req *http.Request
  30496. if miConfig.MdtrtareaAdmvs == "320921" {
  30497. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30498. } else {
  30499. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30500. }
  30501. resp, _ := client.Do(req)
  30502. defer resp.Body.Close()
  30503. body, ioErr := ioutil.ReadAll(resp.Body)
  30504. if ioErr != nil {
  30505. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30507. return
  30508. }
  30509. var respJSON map[string]interface{}
  30510. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30511. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30513. return
  30514. }
  30515. var res ResultSix
  30516. var resSix10265 ResultSix10265 //1101结果
  30517. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30518. result, _ := json.Marshal(respJSON)
  30519. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30520. utils.ErrorLog("解析失败:%v", err)
  30521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30522. return
  30523. }
  30524. res.InfRefmsgid = resSix10265.InfRefmsgid
  30525. res.Output = resSix10265.Output
  30526. res.ErrMsg = resSix10265.ErrMsg
  30527. res.Cainfo = resSix10265.Cainfo
  30528. res.WarnMsg = resSix10265.WarnMsg
  30529. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30530. res.Infcode = infocode
  30531. if infocode == 0 {
  30532. c.ServeSuccessJSON(map[string]interface{}{
  30533. "msg": "上传成功",
  30534. })
  30535. return
  30536. } else {
  30537. c.ServeSuccessJSON(map[string]interface{}{
  30538. "failed_code": -10,
  30539. "msg": res.ErrMsg,
  30540. })
  30541. return
  30542. }
  30543. }
  30544. func (c *HisApiController) Post3504() {
  30545. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30546. data := make(map[string]interface{})
  30547. var struct3501s []models.Struct3501
  30548. var struct3501 models.Struct3501
  30549. struct3501.OrgName = miConfig.OrgName
  30550. struct3501.AccessKey = miConfig.AccessKey
  30551. struct3501.RequestUrl = miConfig.Url
  30552. struct3501.SecretKey = miConfig.SecretKey
  30553. struct3501.ManuDate = "2022-08-15"
  30554. struct3501.FixmedinsBchno = ""
  30555. struct3501.ManuLotnum = ""
  30556. struct3501.RxFlag = "0"
  30557. struct3501.ExpyEnd = "2022-08-15"
  30558. struct3501.Invdate = "2022-08-15"
  30559. struct3501.InvCnt = "20.25"
  30560. struct3501.Memo = ""
  30561. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30562. struct3501.FixmedinsHilistId = miConfig.Code
  30563. struct3501.FixmedinsHilistName = miConfig.OrgName
  30564. struct3501s = append(struct3501s, struct3501)
  30565. data["struct_3501s"] = struct3501s
  30566. client := &http.Client{}
  30567. bytesData, _ := json.Marshal(data)
  30568. var req *http.Request
  30569. if miConfig.MdtrtareaAdmvs == "320921" {
  30570. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30571. } else {
  30572. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30573. }
  30574. resp, _ := client.Do(req)
  30575. defer resp.Body.Close()
  30576. body, ioErr := ioutil.ReadAll(resp.Body)
  30577. if ioErr != nil {
  30578. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30580. return
  30581. }
  30582. var respJSON map[string]interface{}
  30583. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30584. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30586. return
  30587. }
  30588. var res ResultSix
  30589. var resSix10265 ResultSix10265 //1101结果
  30590. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30591. result, _ := json.Marshal(respJSON)
  30592. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30593. utils.ErrorLog("解析失败:%v", err)
  30594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30595. return
  30596. }
  30597. res.InfRefmsgid = resSix10265.InfRefmsgid
  30598. res.Output = resSix10265.Output
  30599. res.ErrMsg = resSix10265.ErrMsg
  30600. res.Cainfo = resSix10265.Cainfo
  30601. res.WarnMsg = resSix10265.WarnMsg
  30602. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30603. res.Infcode = infocode
  30604. if infocode == 0 {
  30605. c.ServeSuccessJSON(map[string]interface{}{
  30606. "msg": "上传成功",
  30607. })
  30608. return
  30609. } else {
  30610. c.ServeSuccessJSON(map[string]interface{}{
  30611. "failed_code": -10,
  30612. "msg": res.ErrMsg,
  30613. })
  30614. return
  30615. }
  30616. }
  30617. func (c *HisApiController) Post3505() {
  30618. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30619. data := make(map[string]interface{})
  30620. var struct3501s []models.Struct3501
  30621. var struct3501 models.Struct3501
  30622. struct3501.OrgName = miConfig.OrgName
  30623. struct3501.AccessKey = miConfig.AccessKey
  30624. struct3501.RequestUrl = miConfig.Url
  30625. struct3501.SecretKey = miConfig.SecretKey
  30626. struct3501.ManuDate = "2022-08-15"
  30627. struct3501.FixmedinsBchno = ""
  30628. struct3501.ManuLotnum = ""
  30629. struct3501.RxFlag = "0"
  30630. struct3501.ExpyEnd = "2022-08-15"
  30631. struct3501.Invdate = "2022-08-15"
  30632. struct3501.InvCnt = "20.25"
  30633. struct3501.Memo = ""
  30634. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30635. struct3501.FixmedinsHilistId = miConfig.Code
  30636. struct3501.FixmedinsHilistName = miConfig.OrgName
  30637. struct3501s = append(struct3501s, struct3501)
  30638. data["struct_3501s"] = struct3501s
  30639. client := &http.Client{}
  30640. bytesData, _ := json.Marshal(data)
  30641. var req *http.Request
  30642. if miConfig.MdtrtareaAdmvs == "320921" {
  30643. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30644. } else {
  30645. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30646. }
  30647. resp, _ := client.Do(req)
  30648. defer resp.Body.Close()
  30649. body, ioErr := ioutil.ReadAll(resp.Body)
  30650. if ioErr != nil {
  30651. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30653. return
  30654. }
  30655. var respJSON map[string]interface{}
  30656. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30659. return
  30660. }
  30661. var res ResultSix
  30662. var resSix10265 ResultSix10265 //1101结果
  30663. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30664. result, _ := json.Marshal(respJSON)
  30665. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30666. utils.ErrorLog("解析失败:%v", err)
  30667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30668. return
  30669. }
  30670. res.InfRefmsgid = resSix10265.InfRefmsgid
  30671. res.Output = resSix10265.Output
  30672. res.ErrMsg = resSix10265.ErrMsg
  30673. res.Cainfo = resSix10265.Cainfo
  30674. res.WarnMsg = resSix10265.WarnMsg
  30675. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30676. res.Infcode = infocode
  30677. if infocode == 0 {
  30678. c.ServeSuccessJSON(map[string]interface{}{
  30679. "msg": "上传成功",
  30680. })
  30681. return
  30682. } else {
  30683. c.ServeSuccessJSON(map[string]interface{}{
  30684. "failed_code": -10,
  30685. "msg": res.ErrMsg,
  30686. })
  30687. return
  30688. }
  30689. }
  30690. func (c *HisApiController) Post3506() {
  30691. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30692. data := make(map[string]interface{})
  30693. var struct3501s []models.Struct3501
  30694. var struct3501 models.Struct3501
  30695. struct3501.OrgName = miConfig.OrgName
  30696. struct3501.AccessKey = miConfig.AccessKey
  30697. struct3501.RequestUrl = miConfig.Url
  30698. struct3501.SecretKey = miConfig.SecretKey
  30699. struct3501.ManuDate = "2022-08-15"
  30700. struct3501.FixmedinsBchno = ""
  30701. struct3501.ManuLotnum = ""
  30702. struct3501.RxFlag = "0"
  30703. struct3501.ExpyEnd = "2022-08-15"
  30704. struct3501.Invdate = "2022-08-15"
  30705. struct3501.InvCnt = "20.25"
  30706. struct3501.Memo = ""
  30707. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30708. struct3501.FixmedinsHilistId = miConfig.Code
  30709. struct3501.FixmedinsHilistName = miConfig.OrgName
  30710. struct3501s = append(struct3501s, struct3501)
  30711. data["struct_3501s"] = struct3501s
  30712. client := &http.Client{}
  30713. bytesData, _ := json.Marshal(data)
  30714. var req *http.Request
  30715. if miConfig.MdtrtareaAdmvs == "320921" {
  30716. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30717. } else {
  30718. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30719. }
  30720. resp, _ := client.Do(req)
  30721. defer resp.Body.Close()
  30722. body, ioErr := ioutil.ReadAll(resp.Body)
  30723. if ioErr != nil {
  30724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30726. return
  30727. }
  30728. var respJSON map[string]interface{}
  30729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30732. return
  30733. }
  30734. var res ResultSix
  30735. var resSix10265 ResultSix10265 //1101结果
  30736. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30737. result, _ := json.Marshal(respJSON)
  30738. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30739. utils.ErrorLog("解析失败:%v", err)
  30740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30741. return
  30742. }
  30743. res.InfRefmsgid = resSix10265.InfRefmsgid
  30744. res.Output = resSix10265.Output
  30745. res.ErrMsg = resSix10265.ErrMsg
  30746. res.Cainfo = resSix10265.Cainfo
  30747. res.WarnMsg = resSix10265.WarnMsg
  30748. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30749. res.Infcode = infocode
  30750. if infocode == 0 {
  30751. c.ServeSuccessJSON(map[string]interface{}{
  30752. "msg": "上传成功",
  30753. })
  30754. return
  30755. } else {
  30756. c.ServeSuccessJSON(map[string]interface{}{
  30757. "failed_code": -10,
  30758. "msg": res.ErrMsg,
  30759. })
  30760. return
  30761. }
  30762. }
  30763. func (c *HisApiController) Post3507() {
  30764. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  30765. data := make(map[string]interface{})
  30766. var struct3501s []models.Struct3501
  30767. var struct3501 models.Struct3501
  30768. struct3501.OrgName = miConfig.OrgName
  30769. struct3501.AccessKey = miConfig.AccessKey
  30770. struct3501.RequestUrl = miConfig.Url
  30771. struct3501.SecretKey = miConfig.SecretKey
  30772. struct3501.ManuDate = "2022-08-15"
  30773. struct3501.FixmedinsBchno = ""
  30774. struct3501.ManuLotnum = ""
  30775. struct3501.RxFlag = "0"
  30776. struct3501.ExpyEnd = "2022-08-15"
  30777. struct3501.Invdate = "2022-08-15"
  30778. struct3501.InvCnt = "20.25"
  30779. struct3501.Memo = ""
  30780. struct3501.MedListCodg = "XB01ABD056B002020200517"
  30781. struct3501.FixmedinsHilistId = miConfig.Code
  30782. struct3501.FixmedinsHilistName = miConfig.OrgName
  30783. struct3501s = append(struct3501s, struct3501)
  30784. data["struct_3501s"] = struct3501s
  30785. client := &http.Client{}
  30786. bytesData, _ := json.Marshal(data)
  30787. var req *http.Request
  30788. if miConfig.MdtrtareaAdmvs == "320921" {
  30789. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30790. } else {
  30791. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  30792. }
  30793. resp, _ := client.Do(req)
  30794. defer resp.Body.Close()
  30795. body, ioErr := ioutil.ReadAll(resp.Body)
  30796. if ioErr != nil {
  30797. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  30798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30799. return
  30800. }
  30801. var respJSON map[string]interface{}
  30802. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  30803. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  30804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30805. return
  30806. }
  30807. var res ResultSix
  30808. var resSix10265 ResultSix10265 //1101结果
  30809. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  30810. result, _ := json.Marshal(respJSON)
  30811. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  30812. utils.ErrorLog("解析失败:%v", err)
  30813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  30814. return
  30815. }
  30816. res.InfRefmsgid = resSix10265.InfRefmsgid
  30817. res.Output = resSix10265.Output
  30818. res.ErrMsg = resSix10265.ErrMsg
  30819. res.Cainfo = resSix10265.Cainfo
  30820. res.WarnMsg = resSix10265.WarnMsg
  30821. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  30822. res.Infcode = infocode
  30823. if infocode == 0 {
  30824. c.ServeSuccessJSON(map[string]interface{}{
  30825. "msg": "上传成功",
  30826. })
  30827. return
  30828. } else {
  30829. c.ServeSuccessJSON(map[string]interface{}{
  30830. "failed_code": -10,
  30831. "msg": res.ErrMsg,
  30832. })
  30833. return
  30834. }
  30835. }
  30836. func GetjxELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30837. // WebSocket服务器地址
  30838. serverURL := "ws://127.0.0.1:8899"
  30839. // 解析WebSocket服务器地址
  30840. u, err := url.Parse(serverURL)
  30841. if err != nil {
  30842. }
  30843. // 建立WebSocket连接
  30844. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30845. if err != nil {
  30846. }
  30847. defer conn.Close()
  30848. input2 := make(map[string]interface{})
  30849. input := make(map[string]interface{})
  30850. inputData := make(map[string]interface{})
  30851. inputData["orgId"] = code
  30852. inputData["businessType"] = "01101"
  30853. inputData["operatorId"] = operator_id
  30854. inputData["operatorName"] = operator_name
  30855. inputData["officeId"] = "001"
  30856. inputData["officeName"] = "血透室"
  30857. inputData["deviceType"] = ""
  30858. input["data"] = inputData
  30859. input["orgId"] = code
  30860. input["transType"] = "ec.query"
  30861. //if md == ""
  30862. if md[:4] == "4403" {
  30863. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30864. } else if md[:4] == "4401" {
  30865. input2["url"] = "http://hosp-sz.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30866. } else {
  30867. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30868. }
  30869. input2["indata"] = input
  30870. fmt.Println(input2)
  30871. bytesData, _ := json.Marshal(input2)
  30872. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30873. if err != nil {
  30874. fmt.Println(err)
  30875. }
  30876. // 接收消息
  30877. _, receivedMessage, err := conn.ReadMessage()
  30878. if err != nil {
  30879. fmt.Println(err)
  30880. }
  30881. return "", string(receivedMessage)
  30882. }
  30883. func GetjxELeInfoaaa(code string, operator_id string, operator_name string) (string, string) {
  30884. // WebSocket服务器地址
  30885. serverURL := "ws://127.0.0.1:8899"
  30886. // 解析WebSocket服务器地址
  30887. u, err := url.Parse(serverURL)
  30888. if err != nil {
  30889. }
  30890. // 建立WebSocket连接
  30891. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30892. if err != nil {
  30893. }
  30894. defer conn.Close()
  30895. input2 := make(map[string]interface{})
  30896. input := make(map[string]interface{})
  30897. inputData := make(map[string]interface{})
  30898. inputData["orgId"] = code
  30899. inputData["businessType"] = "01103"
  30900. inputData["operatorId"] = operator_id
  30901. inputData["operatorName"] = operator_name
  30902. inputData["officeId"] = "001"
  30903. inputData["officeName"] = "血透室"
  30904. inputData["deviceType"] = ""
  30905. input["data"] = inputData
  30906. input["orgId"] = code
  30907. input["transType"] = "ec.query"
  30908. //if md ==
  30909. input2["url"] = "http://10.77.211.236/1.0.0/localQrCodeQuery"
  30910. input2["indata"] = input
  30911. fmt.Println(input2)
  30912. bytesData, _ := json.Marshal(input2)
  30913. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30914. if err != nil {
  30915. fmt.Println(err)
  30916. }
  30917. // 接收消息
  30918. _, receivedMessage, err := conn.ReadMessage()
  30919. if err != nil {
  30920. fmt.Println(err)
  30921. }
  30922. return "", string(receivedMessage)
  30923. }
  30924. func GetELeInfo(code string, operator_id string, operator_name string, md string) (string, string) {
  30925. // WebSocket服务器地址
  30926. serverURL := "ws://127.0.0.1:8899"
  30927. // 解析WebSocket服务器地址
  30928. u, err := url.Parse(serverURL)
  30929. if err != nil {
  30930. }
  30931. // 建立WebSocket连接
  30932. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30933. if err != nil {
  30934. }
  30935. defer conn.Close()
  30936. input2 := make(map[string]interface{})
  30937. input := make(map[string]interface{})
  30938. inputData := make(map[string]interface{})
  30939. inputData["orgId"] = code
  30940. inputData["businessType"] = "01101"
  30941. inputData["operatorId"] = operator_id
  30942. inputData["operatorName"] = operator_name
  30943. inputData["officeId"] = "001"
  30944. inputData["officeName"] = "血透室"
  30945. inputData["deviceType"] = ""
  30946. input["data"] = inputData
  30947. input["orgId"] = code
  30948. input["transType"] = "ec.query"
  30949. //if md == ""
  30950. if md[:4] == "4403" {
  30951. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30952. } else if md[:4] == "4401" {
  30953. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30954. } else {
  30955. input2["url"] = "http://hosp.gd.hsip.gov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30956. }
  30957. input2["indata"] = input
  30958. fmt.Println(input2)
  30959. bytesData, _ := json.Marshal(input2)
  30960. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  30961. if err != nil {
  30962. fmt.Println(err)
  30963. }
  30964. // 接收消息
  30965. _, receivedMessage, err := conn.ReadMessage()
  30966. if err != nil {
  30967. fmt.Println(err)
  30968. }
  30969. return "", string(receivedMessage)
  30970. }
  30971. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  30972. // WebSocket服务器地址
  30973. serverURL := "ws://127.0.0.1:8899"
  30974. // 解析WebSocket服务器地址
  30975. u, err := url.Parse(serverURL)
  30976. if err != nil {
  30977. }
  30978. // 建立WebSocket连接
  30979. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  30980. if err != nil {
  30981. }
  30982. defer conn.Close()
  30983. input2 := make(map[string]interface{})
  30984. input := make(map[string]interface{})
  30985. inputData := make(map[string]interface{})
  30986. inputData["orgId"] = code
  30987. inputData["businessType"] = "01301"
  30988. inputData["operatorId"] = operator_id
  30989. inputData["operatorName"] = operator_name
  30990. inputData["officeId"] = "001"
  30991. inputData["officeName"] = "血透室"
  30992. inputData["deviceType"] = ""
  30993. input["data"] = inputData
  30994. input["orgId"] = code
  30995. input["transType"] = "ec.query"
  30996. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  30997. input2["indata"] = input
  30998. bytesData, _ := json.Marshal(input2)
  30999. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  31000. if err != nil {
  31001. fmt.Println(err)
  31002. }
  31003. // 接收消息
  31004. _, receivedMessage, err := conn.ReadMessage()
  31005. if err != nil {
  31006. fmt.Println(err)
  31007. }
  31008. return "", string(receivedMessage)
  31009. }
  31010. func RemoveRepeatedPurviewElement2(arr []string) (newArr []string) {
  31011. newArr = make([]string, 0)
  31012. for i := 0; i < len(arr); i++ {
  31013. repeat := false
  31014. for j := i + 1; j < len(arr); j++ {
  31015. if arr[i] == arr[j] {
  31016. repeat = true
  31017. break
  31018. }
  31019. }
  31020. if !repeat {
  31021. newArr = append(newArr, arr[i])
  31022. }
  31023. }
  31024. return
  31025. }
  31026. func getBirthdateAndAge(idNumber string) (string, int, error) {
  31027. if len(idNumber) != 18 {
  31028. return "", 0, fmt.Errorf("invalid ID number length. It should be 18 digits")
  31029. }
  31030. // 提取出生日期
  31031. year, err := strconv.Atoi(idNumber[6:10])
  31032. if err != nil {
  31033. return "", 0, err
  31034. }
  31035. month, err := strconv.Atoi(idNumber[10:12])
  31036. if err != nil {
  31037. return "", 0, err
  31038. }
  31039. day, err := strconv.Atoi(idNumber[12:14])
  31040. if err != nil {
  31041. return "", 0, err
  31042. }
  31043. // 格式化生日字符串
  31044. birthdate := time.Date(year, time.Month(month), day, 0, 0, 0, 0, time.UTC)
  31045. birthdateFormatted := birthdate.Format("2006-01-02")
  31046. // 计算年龄
  31047. today := time.Now()
  31048. age := today.Year() - birthdate.Year()
  31049. if today.YearDay() < birthdate.YearDay() {
  31050. age--
  31051. }
  31052. return birthdateFormatted, age, nil
  31053. }